Files
pgsql-jellyfin/publish_test/wwwroot/pdfPlayer-plugin.f8339bb66605ccba93f3.chunk.js
T
2026-07-08 13:13:46 -04:00

1 line
6.3 KiB
JavaScript

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[4836],{38362:function(e,t,n){n.r(t),n.d(t,{PdfPlayer:function(){return f}}),n(29305),n(32733),n(84701),n(81678),n(76281),n(44962),n(89336),n(4754),n(94),n(36947),n(78557),n(96054),n(90076),n(50987),n(99425),n(83994),n(82367);var i=n(71857),o=n(75384),r=n(8566),a=n(74550),s=n(79754),u=n(36300),l=n(70267),c=n(67430),h=n(38783),d=n(44797);function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function p(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,y(i.key),i)}}function y(e){var t=function(e){if("object"!=v(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==v(t)?t:t+""}n(15453);var f=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="PDF Player",this.type=h.Q.MediaPlayer,this.id="pdfplayer",this.priority=1,this.onDialogClosed=this.onDialogClosed.bind(this),this.onWindowKeyDown=this.onWindowKeyDown.bind(this),this.onTouchStart=this.onTouchStart.bind(this)},t=[{key:"play",value:function(e){this.progress=0,this.loaded=!1,this.cancellationToken=!1,this.pages={},r.Ay.show();var t=this.createMediaElement();return this.setCurrentSrc(t,e)}},{key:"stop",value:function(){this.unbindEvents();var e={src:this.item};d.A.trigger(this,"stopped",[e]);var t=this.mediaElement;t&&(s.default.close(t),this.mediaElement=null),r.Ay.hide(),this.cancellationToken=!0}},{key:"destroy",value:function(){}},{key:"currentItem",value:function(){return this.item}},{key:"currentTime",value:function(){return this.progress}},{key:"duration",value:function(){return this.book?this.book.numPages:0}},{key:"volume",value:function(){return 100}},{key:"isMuted",value:function(){return!1}},{key:"paused",value:function(){return!1}},{key:"seekable",value:function(){return!0}},{key:"onWindowKeyDown",value:function(e){if(this.loaded&&!(e.ctrlKey||e.altKey||e.metaKey||e.shiftKey))switch(a.Ay.getKeyName(e)){case"l":case"ArrowRight":case"Right":e.preventDefault(),this.next();break;case"j":case"ArrowLeft":case"Left":e.preventDefault(),this.previous();break;case"Escape":e.preventDefault(),this.stop()}}},{key:"onTouchStart",value:function(e){this.loaded&&e.touches&&0!==e.touches.length&&(e.touches[0].clientX<u.Ay.getWindowSize().innerWidth/2?this.previous():this.next())}},{key:"onDialogClosed",value:function(){this.stop()}},{key:"bindMediaElementEvents",value:function(){var e=this.mediaElement;e.addEventListener("close",this.onDialogClosed,{once:!0}),e.querySelector(".btnExit").addEventListener("click",this.onDialogClosed,{once:!0})}},{key:"bindEvents",value:function(){this.bindMediaElementEvents(),document.addEventListener("keydown",this.onWindowKeyDown),document.addEventListener("touchstart",this.onTouchStart)}},{key:"unbindMediaElementEvents",value:function(){var e=this.mediaElement;e.removeEventListener("close",this.onDialogClosed),e.querySelector(".btnExit").removeEventListener("click",this.onDialogClosed)}},{key:"unbindEvents",value:function(){this.mediaElement&&this.unbindMediaElementEvents(),document.removeEventListener("keydown",this.onWindowKeyDown),document.removeEventListener("touchstart",this.onTouchStart)}},{key:"createMediaElement",value:function(){var e=this.mediaElement;return e||((e=document.getElementById("pdfPlayer"))||((e=s.default.createDialog({exitAnimationDuration:400,size:"fullscreen",autoFocus:!1,scrollY:!1,exitAnimation:"fadeout",removeOnClose:!0})).id="pdfPlayer",e.innerHTML='<canvas id="canvas"></canvas><div class="actionButtons"><button is="paper-icon-button-light" class="autoSize btnExit" tabindex="-1"><span class="material-icons actionButtonIcon close" aria-hidden="true"></span></button></div>',s.default.open(e)),this.mediaElement=e,e)}},{key:"setCurrentSrc",value:function(e,t){var r=this,a=t.items[0];return this.item=a,this.streamInfo={started:!0,ended:!1,item:this.item,mediaSource:{Id:a.Id}},Promise.all([n.e(59928),n.e(69601),n.e(99911)]).then(n.t.bind(n,12565,23)).then((function(e){var n=e.GlobalWorkerOptions,s=e.getDocument,u=(0,o.C)(c.tF.getApiClient(a)),h=(0,i.Q)(u).getDownloadUrl({itemId:a.Id});return r.bindEvents(),n.workerSrc=l.appRouter.baseUrl()+"/libraries/pdf.worker.js",s({url:h,isEvalSupported:!1}).promise.then((function(e){if(!r.cancellationToken){r.book=e,r.loaded=!0;var n=t.startPositionTicks/1e4;0!==n?(r.loadPage(n+1),r.progress=n):r.loadPage(1)}}))}))}},{key:"next",value:function(){this.progress!==this.duration()-1&&(this.loadPage(this.progress+2),this.progress=this.progress+1,d.A.trigger(this,"pause"))}},{key:"previous",value:function(){0!==this.progress&&(this.loadPage(this.progress),this.progress=this.progress-1,d.A.trigger(this,"pause"))}},{key:"replaceCanvas",value:function(e){var t=document.getElementById("canvas");e.id="canvas",t.parentNode.replaceChild(e,t)}},{key:"loadPage",value:function(e){for(var t="page",n=[t+e],i=1;i<=2;i++)e-i>0&&n.push(t+(e-i)),e+i<this.duration()&&n.push(t+(e+i));for(var o=0,r=n;o<r.length;o++){var a=r[o];this.pages[a]||(this.pages[a]=document.createElement("canvas"),this.renderPage(this.pages[a],parseInt(a.slice(4),10)))}for(var s in this.replaceCanvas(this.pages[t+e],e),this.pages)n.includes(s)||delete this.pages[s]}},{key:"renderPage",value:function(e,t){var n=window.devicePixelRatio||1;this.book.getPage(t).then((function(t){var i=t.getViewport({scale:1}),o=Math.min(window.innerHeight/i.height,window.innerWidth/i.width)*n,a=t.getViewport({scale:o});e.width=a.width,e.height=a.height,window.innerWidth<window.innerHeight?(e.style.width="100%",e.style.height="auto"):(e.style.height="100%",e.style.width="auto");var s={canvasContext:e.getContext("2d"),viewport:a};t.render(s).promise.then((function(){r.Ay.hide()}))}))}},{key:"canPlayMediaType",value:function(e){return"book"===(e||"").toLowerCase()}},{key:"canPlayItem",value:function(e){return!!e.Path&&e.Path.toLowerCase().endsWith("pdf")}}],t&&p(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();t.default=f}}]);