"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[44184],{78983:function(e,t,n){n(29305),n(32733),n(84701),n(69892),n(44962),n(89336),n(78557),n(95021),n(73687),n(83994),n(82367);var a,r,i=n(10736),o=n(39738),l=n(44797),c=n(5898),s=n(59774),d=n(2290),f=n.p+"notificationicon.d6ecf2254db85ff3b545.png";function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function g(){document.removeEventListener("click",g),document.removeEventListener("keydown",g),window.Notification&&"default"===window.Notification.permission&&Notification.requestPermission()}function m(){l.A.off(s.tF,"localusersignedin",m),document.addEventListener("click",g),document.addEventListener("keydown",g)}function v(){var e=navigator.serviceWorker;e&&e.ready.then((function(e){r=e}))}function y(e,t,n){try{var a=new Notification(e,t);a.show&&a.show(),n&&function(e,t){setTimeout((function(){e.close?e.close():e.cancel&&e.cancel()}),t)}(a,n)}catch(a){if(!t.actions)throw a;t.actions=[],y(e,t,n)}}function I(e,t,n){var a=e.title;e.data=e.data||{},e.data.serverId=n.serverInfo().Id,e.icon=e.icon||f,e.badge=e.badge||f,v(),r?function(e,t){r.showNotification(e,t)}(a,e):y(a,e,t)}function h(e,t){if(!o.f.isPlayingLocally(["Video"])){var n=e.Name;e.SeriesName&&(n=e.SeriesName+" - "+n);var a={title:"New "+e.Type,body:n,vibrate:!0,tag:"newItem"+e.Id,data:{}},r=e.ImageTags||{};r.Primary&&(a.icon=t.getScaledImageUrl(e.Id,{width:80,tag:r.Primary,type:"Primary"})),I(a,15e3,t)}}function A(e,t,n){e.getCurrentUser().then((function(a){if(a.Policy.IsAdministrator){var r={tag:"install"+t.Id,data:{}};if("completed"===n?(r.title=c.Ay.translate("PackageInstallCompleted",t.Name,t.Version),r.vibrate=!0):"cancelled"===n?r.title=c.Ay.translate("PackageInstallCancelled",t.Name,t.Version):"failed"===n?(r.title=c.Ay.translate("PackageInstallFailed",t.Name,t.Version),r.vibrate=!0):"progress"===n&&(r.title=c.Ay.translate("InstallingPackage",t.Name,t.Version),r.actions=[{action:"cancel-install",title:c.Ay.translate("ButtonCancel"),icon:f}],r.data.id=t.id),"progress"===n){var i=Math.round(t.PercentComplete||0);r.body=i+"% complete."}I(r,"cancelled"===n?5e3:0,e)}}))}(a=s.tF.currentApiClient())?a.getCurrentUser().then((function(){return m()})).catch((function(){l.A.on(s.tF,"localusersignedin",m)})):m(),v(),l.A.on(i.default,"LibraryChanged",(function(e,t,n){!function(e,t){var n=e.ItemsAdded;n.length&&(n.length>12&&(n.length=12),(0,d.J)(t,t.getCurrentUserId(),{Recursive:!0,Limit:3,Filters:"IsNotFolder",SortBy:"DateCreated",SortOrder:"Descending",Ids:n.join(","),MediaTypes:"Audio,Video",EnableTotalRecordCount:!1}).then((function(e){var n,a=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0,r=function(){};return{s:r,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){l=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw i}}}}(e.Items);try{for(a.s();!(n=a.n()).done;)h(n.value,t)}catch(e){a.e(e)}finally{a.f()}})))}(n,t)})),l.A.on(i.default,"PackageInstallationCompleted",(function(e,t,n){A(t,n,"completed")})),l.A.on(i.default,"PackageInstallationFailed",(function(e,t,n){A(t,n,"failed")})),l.A.on(i.default,"PackageInstallationCancelled",(function(e,t,n){A(t,n,"cancelled")})),l.A.on(i.default,"PackageInstalling",(function(e,t,n){A(t,n,"progress")})),l.A.on(i.default,"ServerShuttingDown",(function(e,t){I({tag:"restart"+t.serverInfo().Id,title:c.Ay.translate("ServerNameIsShuttingDown",t.serverInfo().Name)},0,t)})),l.A.on(i.default,"ServerRestarting",(function(e,t){I({tag:"restart"+t.serverInfo().Id,title:c.Ay.translate("ServerNameIsRestarting",t.serverInfo().Name)},0,t)})),l.A.on(i.default,"RestartRequired",(function(e,t){var n={tag:"restart"+t.serverInfo().Id,title:c.Ay.translate("PleaseRestartServerName",t.serverInfo().Name)};n.actions=[{action:"restart",title:c.Ay.translate("Restart"),icon:f}],I(n,0,t)}))}}]);