Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@netless/app-docs-viewer

Package Overview
Dependencies
Maintainers
10
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netless/app-docs-viewer - npm Package Compare versions

Comparing version 0.1.19 to 0.1.20

dist/constants.d.ts

2

dist/main.cjs.js

@@ -1,2 +0,2 @@

"use strict";var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i,n=(e,t,s)=>(a(e,"symbol"!=typeof t?t+"":t,s),s);const l="undefined"!=typeof window,c=l&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),d=l&&"IntersectionObserver"in window,h=l&&"classList"in document.createElement("p"),p=l&&window.devicePixelRatio>1,w={elements_selector:".lazy",container:c||l?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},g=e=>Object.assign({},w,e),u=function(e,t){var s;let i="LazyLoad::Initialized",o=new e(t);try{s=new CustomEvent(i,{detail:{instance:o}})}catch(r){(s=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:o})}window.dispatchEvent(s)},m=(e,t)=>e.getAttribute("data-"+t),b=e=>m(e,"ll-status"),v=(e,t)=>((e,t,s)=>{var i="data-"+t;null!==s?e.setAttribute(i,s):e.removeAttribute(i)})(e,"ll-status",t),f=e=>v(e,null),y=e=>null===b(e),x=e=>"native"===b(e),E=["loading","loaded","applied","error"],S=(e,t,s,i)=>{e&&(void 0===i?void 0===s?e(t):e(t,s):e(t,s,i))},N=(e,t)=>{h?e.classList.add(t):e.className+=(e.className?" ":"")+t},$=(e,t)=>{h?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},C=e=>e.llTempImage,_=(e,t)=>{if(!t)return;const s=t._observer;s&&s.unobserve(e)},T=(e,t)=>{e&&(e.loadingCount+=t)},P=(e,t)=>{e&&(e.toLoadCount=t)},k=e=>{let t=[];for(let s,i=0;s=e.children[i];i+=1)"SOURCE"===s.tagName&&t.push(s);return t},I=(e,t,s)=>{s&&e.setAttribute(t,s)},L=(e,t)=>{e.removeAttribute(t)},z=e=>!!e.llOriginalAttrs,V=e=>{if(z(e))return;const t={};t.src=e.getAttribute("src"),t.srcset=e.getAttribute("srcset"),t.sizes=e.getAttribute("sizes"),e.llOriginalAttrs=t},A=e=>{if(!z(e))return;const t=e.llOriginalAttrs;I(e,"src",t.src),I(e,"srcset",t.srcset),I(e,"sizes",t.sizes)},D=(e,t)=>{I(e,"sizes",m(e,t.data_sizes)),I(e,"srcset",m(e,t.data_srcset)),I(e,"src",m(e,t.data_src))},O=e=>{L(e,"src"),L(e,"srcset"),L(e,"sizes")},M=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;k(s).forEach(t)},R={IMG:(e,t)=>{M(e,(e=>{V(e),D(e,t)})),V(e),D(e,t)},IFRAME:(e,t)=>{I(e,"src",m(e,t.data_src))},VIDEO:(e,t)=>{((e,t)=>{k(e).forEach(t)})(e,(e=>{I(e,"src",m(e,t.data_src))})),I(e,"poster",m(e,t.data_poster)),I(e,"src",m(e,t.data_src)),e.load()}},W=(e,t)=>{const s=R[e.tagName];s&&s(e,t)},j=(e,t,s)=>{N(e,t.class_applied),v(e,"applied"),t.unobserve_completed&&_(e,t),S(t.callback_applied,e,s)},B=(e,t,s)=>{T(s,1),N(e,t.class_loading),v(e,"loading"),S(t.callback_loading,e,s)},F=["IMG","IFRAME","VIDEO"],U=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||S(e.callback_finish,t)},H=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},Y=(e,t,s)=>{e.removeEventListener(t,s)},G=e=>!!e.llEvLisnrs,q=e=>{if(!G(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];Y(e,s,i)}delete e.llEvLisnrs},X=(e,t,s)=>{(e=>{delete e.llTempImage})(e),T(s,-1),(e=>{e&&(e.toLoadCount-=1)})(s),$(e,t.class_loading),t.unobserve_completed&&_(e,s)},K=(e,t,s)=>{const i=C(e)||e;if(G(i))return;((e,t,s)=>{G(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";H(e,i,t),H(e,"error",s)})(i,(o=>{((e,t,s,i)=>{const o=x(t);X(t,s,i),N(t,s.class_loaded),v(t,"loaded"),S(s.callback_loaded,t,i),o||U(s,i)})(0,e,t,s),q(i)}),(o=>{((e,t,s,i)=>{const o=x(t);X(t,s,i),N(t,s.class_error),v(t,"error"),S(s.callback_error,t,i),o||U(s,i)})(0,e,t,s),q(i)}))},J=(e,t,s)=>{(e=>{e.llTempImage=document.createElement("IMG")})(e),K(e,t,s),((e,t,s)=>{const i=m(e,t.data_bg),o=m(e,t.data_bg_hidpi),r=p&&o?o:i;r&&(e.style.backgroundImage=`url("${r}")`,C(e).setAttribute("src",r),B(e,t,s))})(e,t,s),((e,t,s)=>{const i=m(e,t.data_bg_multi),o=m(e,t.data_bg_multi_hidpi),r=p&&o?o:i;r&&(e.style.backgroundImage=r,j(e,t,s))})(e,t,s)},Q=(e,t,s)=>{(e=>F.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{K(e,t,s),W(e,t),B(e,t,s)})(e,t,s):J(e,t,s)},Z=(e,t,s,i)=>{s.cancel_on_exit&&(e=>"loading"===b(e))(e)&&"IMG"===e.tagName&&(q(e),(e=>{M(e,(e=>{O(e)})),O(e)})(e),(e=>{M(e,(e=>{A(e)})),A(e)})(e),$(e,s.class_loading),T(i,-1),f(e),S(s.callback_cancel,e,t,i))},ee=(e,t,s,i)=>{const o=(e=>E.indexOf(b(e))>=0)(e);v(e,"entered"),N(e,s.class_entered),$(e,s.class_exited),((e,t,s)=>{t.unobserve_entered&&_(e,s)})(e,s,i),S(s.callback_enter,e,t,i),o||Q(e,s,i)},te=["IMG","IFRAME","VIDEO"],se=e=>e.use_native&&"loading"in HTMLImageElement.prototype,ie=(e,t,s)=>{e.forEach((e=>{-1!==te.indexOf(e.tagName)&&((e,t,s)=>{e.setAttribute("loading","lazy"),K(e,t,s),W(e,t),v(e,"native")})(e,t,s)})),P(s,0)},oe=(e,t,s)=>{e.forEach((e=>(e=>e.isIntersecting||e.intersectionRatio>0)(e)?ee(e.target,e,t,s):((e,t,s,i)=>{y(e)||(N(e,s.class_exited),Z(e,t,s,i),S(s.callback_exit,e,t,i))})(e.target,e,t,s)))},re=(e,t)=>{d&&!se(e)&&(t._observer=new IntersectionObserver((s=>{oe(s,e,t)}),(e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}))(e)))},ae=e=>Array.prototype.slice.call(e),ne=e=>e.container.querySelectorAll(e.elements_selector),le=e=>(e=>"error"===b(e))(e),ce=(e,t)=>(e=>ae(e).filter(y))(e||ne(t)),de=(e,t)=>{var s;(s=ne(e),ae(s).filter(le)).forEach((t=>{$(t,e.class_error),f(t)})),t.update()},he=function(e,t){const s=g(e);this._settings=s,this.loadingCount=0,re(s,this),((e,t)=>{l&&window.addEventListener("online",(()=>{de(e,t)}))})(s,this),this.update(t)};he.prototype={update:function(e){const t=this._settings,s=ce(e,t);var i,o;(P(this,s.length),!c&&d)?se(t)?ie(s,t,this):(i=this._observer,o=s,(e=>{e.disconnect()})(i),((e,t)=>{t.forEach((t=>{e.observe(t)}))})(i,o)):this.loadAll(s)},destroy:function(){this._observer&&this._observer.disconnect(),ne(this._settings).forEach((e=>{delete e.llOriginalAttrs})),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(e){const t=this._settings;ce(e,t).forEach((e=>{_(e,this),Q(e,t,this)}))}},he.load=(e,t)=>{const s=g(t);Q(e,s)},he.resetStatus=e=>{f(e)},l&&((e,t)=>{if(t)if(t.length)for(let s,i=0;s=t[i];i+=1)u(e,s);else u(e,t)})(he,window.lazyLoadOptions);const pe=(e,t,s,i)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const o=Object.getOwnPropertyDescriptor(e,s),r=Object.getOwnPropertyDescriptor(t,s);!we(o,r)&&i||Object.defineProperty(e,s,r)},we=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},ge=(e,t)=>`/* Wrapped ${e}*/\n${t}`,ue=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),me=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),be=(e,n,l)=>{const c=""===l?"":`with ${l.trim()}() `,d=ge.bind(null,c,n.toString());var h;Object.defineProperty(d,"name",me),Object.defineProperty(e,"toString",(h=((e,t)=>{for(var s in t||(t={}))o.call(t,s)&&a(e,s,t[s]);if(i)for(var s of i(t))r.call(t,s)&&a(e,s,t[s]);return e})({},ue),t(h,s({value:d}))))};var ve=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=e;for(const o of Reflect.ownKeys(t))pe(e,t,o,s);return((e,t)=>{const s=Object.getPrototypeOf(t);s!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,s)})(e,t),be(e,t,i),e};const fe=(e,t={})=>{if("function"!=typeof e)throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:s=0,maxWait:i=Number.Infinity,before:o=!1,after:r=!0}=t;if(!o&&!r)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,l;const c=function(...t){const c=this,d=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),r&&(l=e.apply(c,t))},h=o&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,n&&(clearTimeout(n),n=void 0),r&&(l=e.apply(c,t))}),s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(d,i)),h&&(l=e.apply(c,t)),l};return ve(c,e),c.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},c};class ye{constructor(){n(this,"disposers",new Map),n(this,"disposerIDGenCount",1)}add(e,t=this.genDisposerID()){return this.flush(t),this.disposers.set(t,e()),t}addDisposer(e,t=this.genDisposerID()){return this.add((()=>e),t)}addEventListener(e,t,s,i){e.addEventListener(t,s,i);const o=this.genDisposerID();return this.disposers.set(o,(()=>{e.removeEventListener(t,s)})),o}setTimeout(e,t,s=this.genDisposerID()){const i=window.setTimeout((()=>{e(),this.remove(s)}),t);this.disposers.set(s,(()=>{window.clearTimeout(i)}))}remove(e){const t=this.disposers.get(e);return this.disposers.delete(e),t}flush(e){if(e){const s=this.remove(e);if(s)try{s()}catch(t){console.error(t)}}else this.disposers.forEach((e=>{try{e()}catch(t){console.error(t)}})),this.disposers.clear()}genDisposerID(){return"disposer-"+this.disposerIDGenCount++}}class xe{constructor({readonly:e,box:t,pages:s,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new ye,s.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=t,this.pages=s,this.onNewPageIndex=i,this.onPlay=o,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add((()=>{const e=new he({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()}),"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flush(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const t=this.wrapClassName("preview-page"),s=this.wrapClassName("preview-page-name");this.pages.forEach(((i,o)=>{var r;const a=null!=(r=i.thumbnail)?r:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),l=document.createElement("a");l.className=t+" "+this.wrapClassName(`preview-page-${o}`),l.setAttribute("href","#"),l.dataset.pageIndex=n;const c=document.createElement("span");c.className=s,c.textContent=String(o+1),c.dataset.pageIndex=n;const d=document.createElement("img");d.width=i.width,d.height=i.height,d.dataset.src=a,d.dataset.pageIndex=n,l.appendChild(d),l.appendChild(c),e.appendChild(l)})),this.sideEffect.addEventListener(e,"click",(e=>{var t;if(this.readonly)return;const s=null==(t=e.target.dataset)?void 0:t.pageIndex;s&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.onNewPageIndex(Number(s)),this.togglePreview(!1))}))}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",(e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)}))),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some((e=>e.thumbnail||!e.src.startsWith("ppt")))){const e=this.renderFooterBtn("btn-sidebar",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M50 8H14c-3.309 0-6 2.691-6 6v36c0 3.309 2.691 6 6 6h36c3.309 0 6-2.691 6-6V14c0-3.309-2.691-6-6-6zM12 50V14c0-1.103.897-2 2-2h8v40h-8c-1.103 0-2-.897-2-2zm40 0c0 1.103-.897 2-2 2H26V12h24c1.103 0 2 .897 2 2z"),s.appendChild(i),s}(this.namespace));this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||this.togglePreview()})),this.$footer.appendChild(e)}const t=document.createElement("div");t.className=this.wrapClassName("page-jumps");const s=this.renderFooterBtn("btn-page-back",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M177.81 249.959L337.473 90.295c2.722-2.865 2.651-7.378-.143-10.1-2.793-2.65-7.163-2.65-9.956 0l-164.75 164.75c-2.793 2.793-2.793 7.306 0 10.1l164.75 164.75c2.865 2.722 7.378 2.65 10.099-.143 2.651-2.794 2.651-7.163 0-9.957L177.809 249.959z"),s.appendChild(i),s}(this.namespace));if(this.sideEffect.addEventListener(s,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),t.appendChild(s),this.onPlay){const e=this.renderFooterBtn("btn-page-play",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M418.158 257.419L174.663 413.33c-6.017 3.919-15.708 3.772-21.291-.29-2.791-2.018-4.295-4.483-4.295-7.084V94.109c0-5.65 6.883-10.289 15.271-10.289 4.298 0 8.391 1.307 11.181 3.332l242.629 155.484c6.016 3.917 6.451 10.292.649 14.491-.216.154-.432.154-.649.292zM170.621 391.288l223.116-141.301L170.71 107.753l-.089 283.535z"),s.appendChild(i),s}(this.namespace),function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M312.491 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261zM165.257 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261z"),s.appendChild(i),s}(this.namespace)),s=this.debounce((()=>{e.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)}),500);this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||(e.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),s())})),t.appendChild(e)}const i=this.renderFooterBtn("btn-page-next",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M322.19 250.041L162.527 409.705c-2.722 2.865-2.651 7.378.143 10.1 2.793 2.65 7.163 2.65 9.956 0l164.75-164.75c2.793-2.793 2.793-7.306 0-10.1l-164.75-164.75c-2.865-2.722-7.378-2.65-10.099.143-2.651 2.794-2.651 7.163 0 9.957l159.664 159.736z"),s.appendChild(i),s}(this.namespace));this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),t.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const r=document.createElement("input");r.className=this.wrapClassName("page-number-input"),r.value=String(this.pageIndex+1),this.readonly&&(r.disabled=!0),this.$pageNumberInput=r,this.sideEffect.addEventListener(r,"change",(()=>{this.readonly||r.value&&this.onNewPageIndex(Number(r.value)-1)}));const a=document.createElement("span");a.textContent=" / "+this.pages.length,o.appendChild(r),o.appendChild(a),this.$footer.appendChild(t),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t,s){const i=document.createElement("button");return i.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),i.appendChild(t),s&&i.appendChild(s),i}togglePreview(e){if(this.isShowPreview=null!=e?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const e=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));e&&this.$preview.scrollTo({top:e.offsetTop-16})}}debounce(e,t){const s=fe(e,{wait:t});return this.sideEffect.addDisposer((()=>s.cancel())),s}wrapClassName(e){return`${this.namespace}-${e}`}}function Ee(e,t,s){return Math.min(Math.max(e,t),s)}function Se(e){return e.touches?e.touches[0]:e}function Ne(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class $e{constructor({whiteboardView:e,readonly:t,box:s,pages:i,pagesSize:o,pageScrollTop:r=0,mountWhiteboard:a,onUserScroll:n}){this.onNewPageIndex=e=>{this.scrollToPage(e)},this.sideEffect=new ye,this.scrollbarHeight=30,this.whiteboardView=e,this.readonly=t,this.box=s,this.pages=i,this.pageScrollTop=r,this.pagesSize=o,this.mountWhiteboard=a,this.onUserScroll=n,this.viewer=new xe({readonly:t,box:s,pages:i,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add((()=>{const e=new he({container:this.$pages,elements_selector:`.${this.wrapClassName("page")}`});return()=>e.destroy()}),"page-lazyload"),this.setupWhiteboardCamera(),this.sideEffect.setTimeout((()=>{0!==this.pageScrollTop&&this.pageScrollTo(this.pageScrollTop)}),1e3),this.setupScrollTopEvent(),this.whiteboardView.callbacks.on("onSizeUpdated",(()=>{this.renderRatioHeight()})),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.onUserScroll=void 0,this.unmount(),this.viewer.destroy()}syncPageScrollTop(e){e>=0&&Math.abs(this.pageScrollTop-e)>10&&this.pageScrollTo(e)}render(){this.viewer.$content.appendChild(this.renderPages()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.viewer.$content.appendChild(this.renderScrollbar()),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,t=e<=640;if(this.viewer.setSmallBox(t),t){const t=26/640,s=26/e,i=26/640,o=0,r=Math.max((t+i-(s+o))/2,0);if(this.box.$titleBar){const e=s+r;this.box.$titleBar.style.height=100*e+"%"}if(this.box.$footer){const e=o+r;this.box.$footer.style.height=100*e+"%"}}else{if(this.box.$titleBar){const t=Math.max(26/640,26/e);this.box.$titleBar.style.height=100*t+"%"}if(this.box.$footer){const t=Math.max(26/640,26/e);this.box.$footer.style.height=100*t+"%"}}}renderPages(){if(!this.$pages){const e=document.createElement("div");e.className=this.wrapClassName("pages"),this.$pages=e;const t=this.wrapClassName("page");this.pages.forEach(((s,i)=>{const o=document.createElement("img");o.className=t+" "+this.wrapClassName(`page-${i}`),o.draggable=!1,o.width=s.width,o.height=s.height,o.dataset.src=s.src,o.dataset.pageIndex=String(i),e.appendChild(o)}))}return this.$pages}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{if(Ne(e),!this.readonly){const t=Ee(this.pageScrollTop+e.deltaY,0,this.pagesSize.height);this.pageScrollTo(t),this.onUserScroll&&this.onUserScroll(t)}}),{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchstart",(e=>{if(e.touches.length>1){if(Ne(e),this.readonly)return;this.handleSwipeScroll(e)}}),{passive:!1,capture:!0})),this.$whiteboardView}renderScrollbar(){if(!this.$scrollbar){const e=document.createElement("button");this.$scrollbar=e,e.className=this.wrapClassName("scrollbar"),e.style.minHeight="30px";const t=e=>{if(this.readonly)return;if(null!=e.button&&0!==e.button)return;Ne(e),this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!0);const t=this.scrollTopPageToEl(this.pageScrollTop),s=this.whiteboardView.size.width/this.pagesSize.width*this.pagesSize.height,{clientY:i}=Se(e),o=e=>{const{clientY:o}=Se(e),{height:r}=this.whiteboardView.size;this.elScrollTo(t+s/r*(o-i))},r=()=>{this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!1),window.removeEventListener("mousemove",o,!0),window.removeEventListener("touchmove",o,!0),window.removeEventListener("mouseup",r,!0),window.removeEventListener("touchend",r,!0),window.removeEventListener("touchcancel",r,!0)};window.addEventListener("mousemove",o,!0),window.addEventListener("touchmove",o,!0),window.addEventListener("mouseup",r,!0),window.addEventListener("touchend",r,!0),window.addEventListener("touchcancel",r,!0)};this.sideEffect.addEventListener(e,"mousedown",t),this.sideEffect.addEventListener(e,"touchstart",t)}return this.$scrollbar}scrollTopPageToEl(e){return e*(this.whiteboardView.size.width/this.pagesSize.width)}scrollTopElToPage(e){return e/(this.whiteboardView.size.width/this.pagesSize.width)}elScrollTo(e){this.$pages.scrollTo({top:e})}pageScrollTo(e){this.elScrollTo(this.scrollTopPageToEl(e))}scrollToPage(e){if(!this.readonly&&this.$pages&&!Number.isNaN(e)){e=Ee(e,0,this.pages.length-1);const t=this.$pages.querySelector("."+this.wrapClassName(`page-${e}`));if(t){const e=t.offsetTop+5;this.elScrollTo(e),this.onUserScroll&&this.onUserScroll(this.scrollTopElToPage(e))}}}setupScrollTopEvent(){const e=this.debounce((()=>{if(this.pages.length>0&&this.$pages){if(this.$pages.getBoundingClientRect().width>0){let e=0;for(let t=0;t<this.pages.length;t+=1)if(e+=this.pages[t].height,this.pageScrollTop<=e)return void this.viewer.setPageIndex(t);this.viewer.setPageIndex(this.pages.length-1)}}}),{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.addEventListener(this.$pages,"scroll",(()=>{const t=this.$pages.scrollTop,s=this.scrollTopElToPage(t);this.pageScrollTop=s;const{width:i,height:o}=this.whiteboardView.size,{width:r,height:a}=this.pagesSize,n=i/r*a;this.whiteboardView.moveCamera({centerY:this.scrollTopElToPage(t+o/2),animationMode:"immediately"}),this.setScrollbarHeight(o/n*o),this.$scrollbar.style.transform=`translateY(${t/(n-o)*(o-this.scrollbarHeight)}px)`,e()}))}setupWhiteboardCamera(){this.sideEffect.add((()=>{const e=({width:e,height:t})=>{if(e>0&&t>0){const s=this.$pages.scrollTop,i=this.pagesSize.width,o=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*o,width:i,height:t*o,animationMode:"immediately"}),this.elScrollTo(s)}};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}}),"whiteboard-size-update")}debounce(e,t,s){const i=fe(e,t);return this.sideEffect.addDisposer((()=>i.cancel()),s),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}setScrollbarHeight(e){e=Ee(e,30,this.whiteboardView.size.height),this.scrollbarHeight!==e&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}handleSwipeScroll(e){const t=this.scrollTopPageToEl(this.pageScrollTop),s=this.whiteboardView.size.width/this.pagesSize.width*this.pagesSize.height;let{clientY:i}=e.touches[0];const o=e=>{const{clientY:o}=e.touches[0];this.elScrollTo(Ee(t+(i-o),0,s))},r=e=>{({clientY:i}=e.touches[0]),window.removeEventListener("touchmove",o,!0),window.removeEventListener("touchend",r,!0),window.removeEventListener("touchcancel",r,!0)};window.addEventListener("touchmove",o,!0),window.addEventListener("touchend",r,!0),window.addEventListener("touchcancel",r,!0)}}class Ce{constructor({displayer:e,whiteboardView:t,getRoom:s,readonly:i,box:o,pages:r,mountWhiteboard:a}){var n;this.sideEffect=new ye,this.debounce=(n=this.sideEffect,(e,t)=>{const s=fe(e,t);return n.addDisposer((()=>s.cancel())),s}),this.onPlayPPT=()=>{const e=this.getWhiteboardRoom();e&&e.pptNextStep()},this._scaleDocsToFitImpl=()=>{const e=this.pages[this.getPageIndex()];e&&this.whiteboardView.moveCameraToContain({originX:-e.width/2,originY:-e.height/2,width:e.width,height:e.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=this.debounce(this._scaleDocsToFitImpl,{wait:1e3}),this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=e=>{this.jumpToPage(e,!0)},this.whiteboardView=t,this.readonly=i,this.box=o,this.pages=r,this.displayer=e,this.getWhiteboardRoom=s,this.mountWhiteboard=a,this.viewer=new xe({readonly:i,box:o,pages:r,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render()}mount(){this.viewer.mount();const e=this.getPageIndex();return 0!==e&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add((()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)}))),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,t){if((e=Ee(e,0,this.pages.length-1))!==this.getPageIndex()){const t=this.getWhiteboardRoom();t&&(t.setSceneIndex(e),this.scaleDocsToFit())}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),t){const e=this.getWhiteboardRoom();e&&e.setGlobalState({__pptState:void 0})}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",(e=>{var t;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":this.jumpToPage(this.getPageIndex()-1,!0);break;case"ArrowRight":case"ArrowDown":null==(t=this.getWhiteboardRoom())||t.pptNextStep()}}))}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;document.createElement("button").className=this.wrapClassName("back");document.createElement("button").className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",(e=>{var t;const s=this.getWhiteboardRoom();if(s&&"clicker"===s.state.memberState.currentApplianceName){for(let s=e.target;s;s=s.parentElement)if(null==(t=s.classList)?void 0:t.contains("ppt-event-source"))return;s.pptNextStep()}})),this.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const _e={kind:"DocsViewer",setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=e.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");i.disableCameraTransform=!0;const o=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(o.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(".netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.1);opacity:0;transition:background .4s,opacity .4s,transform .2s;will-change:transform,height;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.2);opacity:1;transition:background .4s,opacity .4s}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer}\n"),o[0].src.startsWith("ppt")?function(e,t,s,i){const o=e.getDisplayer(),r=new Ce({displayer:o,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.isAddApp&&t.callbacks.once("onSizeUpdated",(({width:t,height:o})=>{if(i.length>0){const{width:r,height:a}=i[0],n=a/r*t-o;0!==n&&e.getIsWritable()&&e.emitter.emit("setBoxSize",{width:s.width,height:s.height+n/s.containerRect.height})}}));e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),s.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,i,t,o):function(e,t,s,i){var o;const r={width:i[0].width,height:i.reduce(((e,t)=>e+t.height*(i[0].width/t.width)),0)},a=new $e({whiteboardView:t,readonly:s.readonly,box:s,pages:i,pagesSize:r,pageScrollTop:null==(o=e.getAttributes())?void 0:o.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:t=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===t||s.readonly||e.updateAttributes(["pageScrollTop"],t)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),s.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,i,t,o)}};module.exports=_e;
"use strict";var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i,n=("undefined"!=typeof require&&require,(e,t,s)=>(a(e,"symbol"!=typeof t?t+"":t,s),s));const l="undefined"!=typeof window,c=l&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),d=l&&"IntersectionObserver"in window,h=l&&"classList"in document.createElement("p"),p=l&&window.devicePixelRatio>1,g={elements_selector:".lazy",container:c||l?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},w=e=>Object.assign({},g,e),u=function(e,t){var s;let i="LazyLoad::Initialized",o=new e(t);try{s=new CustomEvent(i,{detail:{instance:o}})}catch(r){(s=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:o})}window.dispatchEvent(s)},b=(e,t)=>e.getAttribute("data-"+t),m=e=>b(e,"ll-status"),v=(e,t)=>((e,t,s)=>{var i="data-"+t;null!==s?e.setAttribute(i,s):e.removeAttribute(i)})(e,"ll-status",t),f=e=>v(e,null),y=e=>null===m(e),x=e=>"native"===m(e),E=["loading","loaded","applied","error"],S=(e,t,s,i)=>{e&&(void 0===i?void 0===s?e(t):e(t,s):e(t,s,i))},N=(e,t)=>{h?e.classList.add(t):e.className+=(e.className?" ":"")+t},C=(e,t)=>{h?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},$=e=>e.llTempImage,_=(e,t)=>{if(!t)return;const s=t._observer;s&&s.unobserve(e)},T=(e,t)=>{e&&(e.loadingCount+=t)},P=(e,t)=>{e&&(e.toLoadCount=t)},k=e=>{let t=[];for(let s,i=0;s=e.children[i];i+=1)"SOURCE"===s.tagName&&t.push(s);return t},I=(e,t,s)=>{s&&e.setAttribute(t,s)},z=(e,t)=>{e.removeAttribute(t)},L=e=>!!e.llOriginalAttrs,V=e=>{if(L(e))return;const t={};t.src=e.getAttribute("src"),t.srcset=e.getAttribute("srcset"),t.sizes=e.getAttribute("sizes"),e.llOriginalAttrs=t},A=e=>{if(!L(e))return;const t=e.llOriginalAttrs;I(e,"src",t.src),I(e,"srcset",t.srcset),I(e,"sizes",t.sizes)},D=(e,t)=>{I(e,"sizes",b(e,t.data_sizes)),I(e,"srcset",b(e,t.data_srcset)),I(e,"src",b(e,t.data_src))},O=e=>{z(e,"src"),z(e,"srcset"),z(e,"sizes")},M=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;k(s).forEach(t)},R={IMG:(e,t)=>{M(e,(e=>{V(e),D(e,t)})),V(e),D(e,t)},IFRAME:(e,t)=>{I(e,"src",b(e,t.data_src))},VIDEO:(e,t)=>{((e,t)=>{k(e).forEach(t)})(e,(e=>{I(e,"src",b(e,t.data_src))})),I(e,"poster",b(e,t.data_poster)),I(e,"src",b(e,t.data_src)),e.load()}},W=(e,t)=>{const s=R[e.tagName];s&&s(e,t)},B=(e,t,s)=>{N(e,t.class_applied),v(e,"applied"),t.unobserve_completed&&_(e,t),S(t.callback_applied,e,s)},j=(e,t,s)=>{T(s,1),N(e,t.class_loading),v(e,"loading"),S(t.callback_loading,e,s)},F=["IMG","IFRAME","VIDEO"],U=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||S(e.callback_finish,t)},H=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},Y=(e,t,s)=>{e.removeEventListener(t,s)},G=e=>!!e.llEvLisnrs,q=e=>{if(!G(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];Y(e,s,i)}delete e.llEvLisnrs},X=(e,t,s)=>{(e=>{delete e.llTempImage})(e),T(s,-1),(e=>{e&&(e.toLoadCount-=1)})(s),C(e,t.class_loading),t.unobserve_completed&&_(e,s)},K=(e,t,s)=>{const i=$(e)||e;if(G(i))return;((e,t,s)=>{G(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";H(e,i,t),H(e,"error",s)})(i,(o=>{((e,t,s,i)=>{const o=x(t);X(t,s,i),N(t,s.class_loaded),v(t,"loaded"),S(s.callback_loaded,t,i),o||U(s,i)})(0,e,t,s),q(i)}),(o=>{((e,t,s,i)=>{const o=x(t);X(t,s,i),N(t,s.class_error),v(t,"error"),S(s.callback_error,t,i),o||U(s,i)})(0,e,t,s),q(i)}))},J=(e,t,s)=>{(e=>{e.llTempImage=document.createElement("IMG")})(e),K(e,t,s),((e,t,s)=>{const i=b(e,t.data_bg),o=b(e,t.data_bg_hidpi),r=p&&o?o:i;r&&(e.style.backgroundImage=`url("${r}")`,$(e).setAttribute("src",r),j(e,t,s))})(e,t,s),((e,t,s)=>{const i=b(e,t.data_bg_multi),o=b(e,t.data_bg_multi_hidpi),r=p&&o?o:i;r&&(e.style.backgroundImage=r,B(e,t,s))})(e,t,s)},Q=(e,t,s)=>{(e=>F.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{K(e,t,s),W(e,t),j(e,t,s)})(e,t,s):J(e,t,s)},Z=(e,t,s,i)=>{s.cancel_on_exit&&(e=>"loading"===m(e))(e)&&"IMG"===e.tagName&&(q(e),(e=>{M(e,(e=>{O(e)})),O(e)})(e),(e=>{M(e,(e=>{A(e)})),A(e)})(e),C(e,s.class_loading),T(i,-1),f(e),S(s.callback_cancel,e,t,i))},ee=(e,t,s,i)=>{const o=(e=>E.indexOf(m(e))>=0)(e);v(e,"entered"),N(e,s.class_entered),C(e,s.class_exited),((e,t,s)=>{t.unobserve_entered&&_(e,s)})(e,s,i),S(s.callback_enter,e,t,i),o||Q(e,s,i)},te=["IMG","IFRAME","VIDEO"],se=e=>e.use_native&&"loading"in HTMLImageElement.prototype,ie=(e,t,s)=>{e.forEach((e=>{-1!==te.indexOf(e.tagName)&&((e,t,s)=>{e.setAttribute("loading","lazy"),K(e,t,s),W(e,t),v(e,"native")})(e,t,s)})),P(s,0)},oe=(e,t,s)=>{e.forEach((e=>(e=>e.isIntersecting||e.intersectionRatio>0)(e)?ee(e.target,e,t,s):((e,t,s,i)=>{y(e)||(N(e,s.class_exited),Z(e,t,s,i),S(s.callback_exit,e,t,i))})(e.target,e,t,s)))},re=(e,t)=>{d&&!se(e)&&(t._observer=new IntersectionObserver((s=>{oe(s,e,t)}),(e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}))(e)))},ae=e=>Array.prototype.slice.call(e),ne=e=>e.container.querySelectorAll(e.elements_selector),le=e=>(e=>"error"===m(e))(e),ce=(e,t)=>(e=>ae(e).filter(y))(e||ne(t)),de=(e,t)=>{var s;(s=ne(e),ae(s).filter(le)).forEach((t=>{C(t,e.class_error),f(t)})),t.update()},he=function(e,t){const s=w(e);this._settings=s,this.loadingCount=0,re(s,this),((e,t)=>{l&&window.addEventListener("online",(()=>{de(e,t)}))})(s,this),this.update(t)};he.prototype={update:function(e){const t=this._settings,s=ce(e,t);var i,o;(P(this,s.length),!c&&d)?se(t)?ie(s,t,this):(i=this._observer,o=s,(e=>{e.disconnect()})(i),((e,t)=>{t.forEach((t=>{e.observe(t)}))})(i,o)):this.loadAll(s)},destroy:function(){this._observer&&this._observer.disconnect(),ne(this._settings).forEach((e=>{delete e.llOriginalAttrs})),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(e){const t=this._settings;ce(e,t).forEach((e=>{_(e,this),Q(e,t,this)}))}},he.load=(e,t)=>{const s=w(t);Q(e,s)},he.resetStatus=e=>{f(e)},l&&((e,t)=>{if(t)if(t.length)for(let s,i=0;s=t[i];i+=1)u(e,s);else u(e,t)})(he,window.lazyLoadOptions);const pe=(e,t,s,i)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const o=Object.getOwnPropertyDescriptor(e,s),r=Object.getOwnPropertyDescriptor(t,s);!ge(o,r)&&i||Object.defineProperty(e,s,r)},ge=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},we=(e,t)=>`/* Wrapped ${e}*/\n${t}`,ue=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),be=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),me=(e,n,l)=>{const c=""===l?"":`with ${l.trim()}() `,d=we.bind(null,c,n.toString());var h;Object.defineProperty(d,"name",be),Object.defineProperty(e,"toString",(h=((e,t)=>{for(var s in t||(t={}))o.call(t,s)&&a(e,s,t[s]);if(i)for(var s of i(t))r.call(t,s)&&a(e,s,t[s]);return e})({},ue),t(h,s({value:d}))))};var ve=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=e;for(const o of Reflect.ownKeys(t))pe(e,t,o,s);return((e,t)=>{const s=Object.getPrototypeOf(t);s!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,s)})(e,t),me(e,t,i),e};const fe=(e,t={})=>{if("function"!=typeof e)throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:s=0,maxWait:i=Number.Infinity,before:o=!1,after:r=!0}=t;if(!o&&!r)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,l;const c=function(...t){const c=this,d=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),r&&(l=e.apply(c,t))},h=o&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,n&&(clearTimeout(n),n=void 0),r&&(l=e.apply(c,t))}),s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(d,i)),h&&(l=e.apply(c,t)),l};return ve(c,e),c.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},c};class ye{constructor(){n(this,"disposers",new Map),n(this,"disposerIDGenCount",1)}add(e,t=this.genDisposerID()){return this.flush(t),this.disposers.set(t,e()),t}addDisposer(e,t=this.genDisposerID()){return this.add((()=>e),t)}addEventListener(e,t,s,i){e.addEventListener(t,s,i);const o=this.genDisposerID();return this.disposers.set(o,(()=>{e.removeEventListener(t,s,i)})),o}setTimeout(e,t,s=this.genDisposerID()){const i=window.setTimeout((()=>{e(),this.remove(s)}),t);this.disposers.set(s,(()=>{window.clearTimeout(i)}))}remove(e){const t=this.disposers.get(e);return this.disposers.delete(e),t}flush(e){if(e){const s=this.remove(e);if(s)try{s()}catch(t){console.error(t)}}else this.disposers.forEach((e=>{try{e()}catch(t){console.error(t)}})),this.disposers.clear()}genDisposerID(){return"disposer-"+this.disposerIDGenCount++}}class xe{constructor({readonly:e,box:t,pages:s,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new ye,s.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=t,this.pages=s,this.onNewPageIndex=i,this.onPlay=o,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add((()=>{const e=new he({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()}),"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flush(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const t=this.wrapClassName("preview-page"),s=this.wrapClassName("preview-page-name");this.pages.forEach(((i,o)=>{var r;const a=null!=(r=i.thumbnail)?r:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),l=document.createElement("a");l.className=t+" "+this.wrapClassName(`preview-page-${o}`),l.setAttribute("href","#"),l.dataset.pageIndex=n;const c=document.createElement("span");c.className=s,c.textContent=String(o+1),c.dataset.pageIndex=n;const d=document.createElement("img");d.width=i.width,d.height=i.height,d.dataset.src=a,d.dataset.pageIndex=n,l.appendChild(d),l.appendChild(c),e.appendChild(l)})),this.sideEffect.addEventListener(e,"click",(e=>{var t;if(this.readonly)return;const s=null==(t=e.target.dataset)?void 0:t.pageIndex;s&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.onNewPageIndex(Number(s)),this.togglePreview(!1))}))}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",(e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)}))),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some((e=>e.thumbnail||!e.src.startsWith("ppt")))){const e=this.renderFooterBtn("btn-sidebar",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M50 8H14c-3.309 0-6 2.691-6 6v36c0 3.309 2.691 6 6 6h36c3.309 0 6-2.691 6-6V14c0-3.309-2.691-6-6-6zM12 50V14c0-1.103.897-2 2-2h8v40h-8c-1.103 0-2-.897-2-2zm40 0c0 1.103-.897 2-2 2H26V12h24c1.103 0 2 .897 2 2z"),s.appendChild(i),s}(this.namespace));this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||this.togglePreview()})),this.$footer.appendChild(e)}const t=document.createElement("div");t.className=this.wrapClassName("page-jumps");const s=this.renderFooterBtn("btn-page-back",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M177.81 249.959L337.473 90.295c2.722-2.865 2.651-7.378-.143-10.1-2.793-2.65-7.163-2.65-9.956 0l-164.75 164.75c-2.793 2.793-2.793 7.306 0 10.1l164.75 164.75c2.865 2.722 7.378 2.65 10.099-.143 2.651-2.794 2.651-7.163 0-9.957L177.809 249.959z"),s.appendChild(i),s}(this.namespace));if(this.sideEffect.addEventListener(s,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),t.appendChild(s),this.onPlay){const e=this.renderFooterBtn("btn-page-play",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M418.158 257.419L174.663 413.33c-6.017 3.919-15.708 3.772-21.291-.29-2.791-2.018-4.295-4.483-4.295-7.084V94.109c0-5.65 6.883-10.289 15.271-10.289 4.298 0 8.391 1.307 11.181 3.332l242.629 155.484c6.016 3.917 6.451 10.292.649 14.491-.216.154-.432.154-.649.292zM170.621 391.288l223.116-141.301L170.71 107.753l-.089 283.535z"),s.appendChild(i),s}(this.namespace),function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M312.491 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261zM165.257 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261z"),s.appendChild(i),s}(this.namespace)),s=this.debounce((()=>{e.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)}),500);this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||(e.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),s())})),t.appendChild(e)}const i=this.renderFooterBtn("btn-page-next",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M322.19 250.041L162.527 409.705c-2.722 2.865-2.651 7.378.143 10.1 2.793 2.65 7.163 2.65 9.956 0l164.75-164.75c2.793-2.793 2.793-7.306 0-10.1l-164.75-164.75c-2.865-2.722-7.378-2.65-10.099.143-2.651 2.794-2.651 7.163 0 9.957l159.664 159.736z"),s.appendChild(i),s}(this.namespace));this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),t.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const r=document.createElement("input");r.className=this.wrapClassName("page-number-input"),r.value=String(this.pageIndex+1),this.readonly&&(r.disabled=!0),this.$pageNumberInput=r,this.sideEffect.addEventListener(r,"change",(()=>{this.readonly||r.value&&this.onNewPageIndex(Number(r.value)-1)}));const a=document.createElement("span");a.textContent=" / "+this.pages.length,o.appendChild(r),o.appendChild(a),this.$footer.appendChild(t),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t,s){const i=document.createElement("button");return i.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),i.appendChild(t),s&&i.appendChild(s),i}togglePreview(e){if(this.isShowPreview=null!=e?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const e=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));e&&this.$preview.scrollTo({top:e.offsetTop-16})}}debounce(e,t){const s=fe(e,{wait:t});return this.sideEffect.addDisposer((()=>s.cancel())),s}wrapClassName(e){return`${this.namespace}-${e}`}}function Ee(e,t,s){return Math.min(Math.max(e,t),s)}function Se(e){return e.touches?e.touches[0]:e}function Ne(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class Ce{constructor({whiteboardView:e,readonly:t,box:s,pages:i,pagesSize:o,pageScrollTop:r=0,mountWhiteboard:a,onUserScroll:n}){this.onNewPageIndex=e=>{this.scrollToPage(e)},this.sideEffect=new ye,this.scrollbarHeight=30,this.whiteboardView=e,this.readonly=t,this.box=s,this.pages=i,this.pageScrollTop=r,this.pagesSize=o,this.mountWhiteboard=a,this.onUserScroll=n,this.viewer=new xe({readonly:t,box:s,pages:i,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add((()=>{const e=new he({container:this.$pages,elements_selector:`.${this.wrapClassName("page")}`});return()=>e.destroy()}),"page-lazyload"),this.setupWhiteboardCamera(),this.sideEffect.setTimeout((()=>{0!==this.pageScrollTop&&this.pageScrollTo(this.pageScrollTop)}),1e3),this.setupScrollTopEvent(),this.whiteboardView.callbacks.on("onSizeUpdated",(()=>{this.renderRatioHeight()})),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.onUserScroll=void 0,this.unmount(),this.viewer.destroy()}syncPageScrollTop(e){e>=0&&Math.abs(this.pageScrollTop-e)>10&&this.pageScrollTo(e)}render(){this.viewer.$content.appendChild(this.renderPages()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.viewer.$content.appendChild(this.renderScrollbar()),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,t=e<=640;if(this.viewer.setSmallBox(t),t){const t=26/640,s=26/e,i=26/640,o=0,r=Math.max((t+i-(s+o))/2,0);if(this.box.$titleBar){const e=s+r;this.box.$titleBar.style.height=100*e+"%"}if(this.box.$footer){const e=o+r;this.box.$footer.style.height=100*e+"%"}}else{if(this.box.$titleBar){const t=Math.max(26/640,26/e);this.box.$titleBar.style.height=100*t+"%"}if(this.box.$footer){const t=Math.max(26/640,26/e);this.box.$footer.style.height=100*t+"%"}}}renderPages(){if(!this.$pages){const e=document.createElement("div");e.className=this.wrapClassName("pages"),this.$pages=e;const t=this.wrapClassName("page");this.pages.forEach(((s,i)=>{const o=document.createElement("img");o.className=t+" "+this.wrapClassName(`page-${i}`),o.draggable=!1,o.width=s.width,o.height=s.height,o.dataset.src=s.src,o.dataset.pageIndex=String(i),e.appendChild(o)}))}return this.$pages}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{Ne(e),this.readonly||(this.pageScrollTo(this.pageScrollTop+e.deltaY),this.updateUserScroll())}),{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",(e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()}),{passive:!0,capture:!0})),this.$whiteboardView}renderScrollbar(){if(!this.$scrollbar){const e=document.createElement("button");this.$scrollbar=e,e.className=this.wrapClassName("scrollbar"),e.style.minHeight="30px";const t=e=>{if(this.readonly)return;if(null!=e.button&&0!==e.button)return;Ne(e),this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!0);const t=this.scrollTopPageToEl(this.pageScrollTop),s=this.whiteboardView.size.width/this.pagesSize.width*this.pagesSize.height,{clientY:i}=Se(e),o=e=>{const{clientY:o}=Se(e),{height:r}=this.whiteboardView.size;this.elScrollTo(t+s/r*(o-i))},r=()=>{this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!1),window.removeEventListener("mousemove",o,!0),window.removeEventListener("touchmove",o,!0),window.removeEventListener("mouseup",r,!0),window.removeEventListener("touchend",r,!0),window.removeEventListener("touchcancel",r,!0)};window.addEventListener("mousemove",o,!0),window.addEventListener("touchmove",o,!0),window.addEventListener("mouseup",r,!0),window.addEventListener("touchend",r,!0),window.addEventListener("touchcancel",r,!0)};this.sideEffect.addEventListener(e,"mousedown",t),this.sideEffect.addEventListener(e,"touchstart",t)}return this.$scrollbar}scrollTopPageToEl(e){return e*(this.whiteboardView.size.width/this.pagesSize.width)}scrollTopElToPage(e){return e/(this.whiteboardView.size.width/this.pagesSize.width)}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const t=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:Ee(e+t,t,this.pagesSize.height-t),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&this.$pages&&!Number.isNaN(e)){e=Ee(e,0,this.pages.length-1);const t=this.$pages.querySelector("."+this.wrapClassName(`page-${e}`));if(t){const e=t.offsetTop+5;this.elScrollTo(e),this.updateUserScroll()}}}setupScrollTopEvent(){const e=this.debounce((()=>{if(this.pages.length>0&&this.$pages){if(this.$pages.getBoundingClientRect().width>0){let e=0;for(let t=0;t<this.pages.length;t+=1)if(e+=this.pages[t].height,this.pageScrollTop<=e)return void this.viewer.setPageIndex(t);this.viewer.setPageIndex(this.pages.length-1)}}}),{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.add((()=>{const t=t=>{const{width:s,height:i}=this.whiteboardView.size,{width:o,height:r}=this.pagesSize,a=s/o*r,n=this.scrollTopPageToEl(t.centerY)-i/2,l=this.scrollTopElToPage(n);this.pageScrollTop=l,this.$pages.scrollTo({top:n}),this.setScrollbarHeight(i/a*i),this.$scrollbar.style.transform=`translateY(${n/(a-i)*(i-this.scrollbarHeight)}px)`,e()};return this.whiteboardView.callbacks.on("onCameraUpdated",t),()=>this.whiteboardView.callbacks.off("onCameraUpdated",t)}))}setupWhiteboardCamera(){this.sideEffect.add((()=>{const e=({width:e,height:t})=>{if(e>0&&t>0){const s=this.$pages.scrollTop,i=this.pagesSize.width,o=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*o,width:i,height:t*o,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>e/i,minContentMode:()=>e/i,centerX:this.pagesSize.width/2,centerY:this.pagesSize.height/2,width:this.pagesSize.width,height:this.pagesSize.height}),this.elScrollTo(s)}};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}}),"whiteboard-size-update")}updateUserScroll(){window.requestAnimationFrame((()=>{this.onUserScroll&&this.onUserScroll(this.pageScrollTop)}))}debounce(e,t,s){const i=fe(e,t);return this.sideEffect.addDisposer((()=>i.cancel()),s),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}setScrollbarHeight(e){e=Ee(e,30,this.whiteboardView.size.height),this.scrollbarHeight!==e&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}class $e{constructor({displayer:e,whiteboardView:t,getRoom:s,readonly:i,box:o,pages:r,mountWhiteboard:a}){var n;this.sideEffect=new ye,this.debounce=(n=this.sideEffect,(e,t)=>{const s=fe(e,t);return n.addDisposer((()=>s.cancel())),s}),this.onPlayPPT=()=>{const e=this.getWhiteboardRoom();e&&e.pptNextStep()},this._scaleDocsToFitImpl=()=>{const e=this.pages[this.getPageIndex()];e&&this.whiteboardView.moveCameraToContain({originX:-e.width/2,originY:-e.height/2,width:e.width,height:e.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=this.debounce(this._scaleDocsToFitImpl,{wait:1e3}),this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=e=>{this.jumpToPage(e,!0)},this.whiteboardView=t,this.readonly=i,this.box=o,this.pages=r,this.displayer=e,this.getWhiteboardRoom=s,this.mountWhiteboard=a,this.viewer=new xe({readonly:i,box:o,pages:r,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render()}mount(){this.viewer.mount();const e=this.getPageIndex();return 0!==e&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add((()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)}))),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,t){if((e=Ee(e,0,this.pages.length-1))!==this.getPageIndex()){const t=this.getWhiteboardRoom();t&&(t.setSceneIndex(e),this.scaleDocsToFit())}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),t){const e=this.getWhiteboardRoom();e&&e.setGlobalState({__pptState:void 0})}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",(e=>{var t;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":this.jumpToPage(this.getPageIndex()-1,!0);break;case"ArrowRight":case"ArrowDown":null==(t=this.getWhiteboardRoom())||t.pptNextStep()}}))}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;document.createElement("button").className=this.wrapClassName("back");document.createElement("button").className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",(e=>{var t;const s=this.getWhiteboardRoom();if(s&&"clicker"===s.state.memberState.currentApplianceName){for(let s=e.target;s;s=s.parentElement)if(null==(t=s.classList)?void 0:t.contains("ppt-event-source"))return;s.pptNextStep()}})),this.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const _e={kind:"DocsViewer",setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=e.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");const o=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(o.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(".netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.1);opacity:0;transition:background .4s,opacity .4s,transform .2s;will-change:transform,height;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.2);opacity:1;transition:background .4s,opacity .4s}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer}\n"),o[0].src.startsWith("ppt")?function(e,t,s,i){t.disableCameraTransform=!0;const o=e.getDisplayer(),r=new $e({displayer:o,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.isAddApp&&t.callbacks.once("onSizeUpdated",(({width:t,height:o})=>{if(i.length>0){const{width:r,height:a}=i[0],n=a/r*t-o;0!==n&&e.getIsWritable()&&e.emitter.emit("setBoxSize",{width:s.width,height:s.height+n/s.containerRect.height})}}));e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),s.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,i,t,o):function(e,t,s,i){var o;const r={width:i[0].width,height:i.reduce(((e,t)=>e+t.height*(i[0].width/t.width)),0)},a=new Ce({whiteboardView:t,readonly:s.readonly,box:s,pages:i,pagesSize:r,pageScrollTop:null==(o=e.getAttributes())?void 0:o.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:t=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===t||s.readonly||e.updateAttributes(["pageScrollTop"],t)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),s.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,i,t,o)}};module.exports=_e;
//# sourceMappingURL=main.cjs.js.map

@@ -1,2 +0,2 @@

var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i,n=(e,t,s)=>(a(e,"symbol"!=typeof t?t+"":t,s),s);const l="undefined"!=typeof window,c=l&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),d=l&&"IntersectionObserver"in window,h=l&&"classList"in document.createElement("p"),p=l&&window.devicePixelRatio>1,w={elements_selector:".lazy",container:c||l?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},g=e=>Object.assign({},w,e),u=function(e,t){var s;let i="LazyLoad::Initialized",o=new e(t);try{s=new CustomEvent(i,{detail:{instance:o}})}catch(r){(s=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:o})}window.dispatchEvent(s)},b=(e,t)=>e.getAttribute("data-"+t),m=e=>b(e,"ll-status"),v=(e,t)=>((e,t,s)=>{var i="data-"+t;null!==s?e.setAttribute(i,s):e.removeAttribute(i)})(e,"ll-status",t),f=e=>v(e,null),y=e=>null===m(e),x=e=>"native"===m(e),E=["loading","loaded","applied","error"],S=(e,t,s,i)=>{e&&(void 0===i?void 0===s?e(t):e(t,s):e(t,s,i))},N=(e,t)=>{h?e.classList.add(t):e.className+=(e.className?" ":"")+t},$=(e,t)=>{h?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},C=e=>e.llTempImage,_=(e,t)=>{if(!t)return;const s=t._observer;s&&s.unobserve(e)},T=(e,t)=>{e&&(e.loadingCount+=t)},P=(e,t)=>{e&&(e.toLoadCount=t)},k=e=>{let t=[];for(let s,i=0;s=e.children[i];i+=1)"SOURCE"===s.tagName&&t.push(s);return t},I=(e,t,s)=>{s&&e.setAttribute(t,s)},L=(e,t)=>{e.removeAttribute(t)},z=e=>!!e.llOriginalAttrs,V=e=>{if(z(e))return;const t={};t.src=e.getAttribute("src"),t.srcset=e.getAttribute("srcset"),t.sizes=e.getAttribute("sizes"),e.llOriginalAttrs=t},A=e=>{if(!z(e))return;const t=e.llOriginalAttrs;I(e,"src",t.src),I(e,"srcset",t.srcset),I(e,"sizes",t.sizes)},D=(e,t)=>{I(e,"sizes",b(e,t.data_sizes)),I(e,"srcset",b(e,t.data_srcset)),I(e,"src",b(e,t.data_src))},O=e=>{L(e,"src"),L(e,"srcset"),L(e,"sizes")},M=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;k(s).forEach(t)},R={IMG:(e,t)=>{M(e,(e=>{V(e),D(e,t)})),V(e),D(e,t)},IFRAME:(e,t)=>{I(e,"src",b(e,t.data_src))},VIDEO:(e,t)=>{((e,t)=>{k(e).forEach(t)})(e,(e=>{I(e,"src",b(e,t.data_src))})),I(e,"poster",b(e,t.data_poster)),I(e,"src",b(e,t.data_src)),e.load()}},W=(e,t)=>{const s=R[e.tagName];s&&s(e,t)},j=(e,t,s)=>{N(e,t.class_applied),v(e,"applied"),t.unobserve_completed&&_(e,t),S(t.callback_applied,e,s)},B=(e,t,s)=>{T(s,1),N(e,t.class_loading),v(e,"loading"),S(t.callback_loading,e,s)},F=["IMG","IFRAME","VIDEO"],U=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||S(e.callback_finish,t)},H=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},Y=(e,t,s)=>{e.removeEventListener(t,s)},G=e=>!!e.llEvLisnrs,q=e=>{if(!G(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];Y(e,s,i)}delete e.llEvLisnrs},X=(e,t,s)=>{(e=>{delete e.llTempImage})(e),T(s,-1),(e=>{e&&(e.toLoadCount-=1)})(s),$(e,t.class_loading),t.unobserve_completed&&_(e,s)},K=(e,t,s)=>{const i=C(e)||e;if(G(i))return;((e,t,s)=>{G(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";H(e,i,t),H(e,"error",s)})(i,(o=>{((e,t,s,i)=>{const o=x(t);X(t,s,i),N(t,s.class_loaded),v(t,"loaded"),S(s.callback_loaded,t,i),o||U(s,i)})(0,e,t,s),q(i)}),(o=>{((e,t,s,i)=>{const o=x(t);X(t,s,i),N(t,s.class_error),v(t,"error"),S(s.callback_error,t,i),o||U(s,i)})(0,e,t,s),q(i)}))},J=(e,t,s)=>{(e=>{e.llTempImage=document.createElement("IMG")})(e),K(e,t,s),((e,t,s)=>{const i=b(e,t.data_bg),o=b(e,t.data_bg_hidpi),r=p&&o?o:i;r&&(e.style.backgroundImage=`url("${r}")`,C(e).setAttribute("src",r),B(e,t,s))})(e,t,s),((e,t,s)=>{const i=b(e,t.data_bg_multi),o=b(e,t.data_bg_multi_hidpi),r=p&&o?o:i;r&&(e.style.backgroundImage=r,j(e,t,s))})(e,t,s)},Q=(e,t,s)=>{(e=>F.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{K(e,t,s),W(e,t),B(e,t,s)})(e,t,s):J(e,t,s)},Z=(e,t,s,i)=>{s.cancel_on_exit&&(e=>"loading"===m(e))(e)&&"IMG"===e.tagName&&(q(e),(e=>{M(e,(e=>{O(e)})),O(e)})(e),(e=>{M(e,(e=>{A(e)})),A(e)})(e),$(e,s.class_loading),T(i,-1),f(e),S(s.callback_cancel,e,t,i))},ee=(e,t,s,i)=>{const o=(e=>E.indexOf(m(e))>=0)(e);v(e,"entered"),N(e,s.class_entered),$(e,s.class_exited),((e,t,s)=>{t.unobserve_entered&&_(e,s)})(e,s,i),S(s.callback_enter,e,t,i),o||Q(e,s,i)},te=["IMG","IFRAME","VIDEO"],se=e=>e.use_native&&"loading"in HTMLImageElement.prototype,ie=(e,t,s)=>{e.forEach((e=>{-1!==te.indexOf(e.tagName)&&((e,t,s)=>{e.setAttribute("loading","lazy"),K(e,t,s),W(e,t),v(e,"native")})(e,t,s)})),P(s,0)},oe=(e,t,s)=>{e.forEach((e=>(e=>e.isIntersecting||e.intersectionRatio>0)(e)?ee(e.target,e,t,s):((e,t,s,i)=>{y(e)||(N(e,s.class_exited),Z(e,t,s,i),S(s.callback_exit,e,t,i))})(e.target,e,t,s)))},re=(e,t)=>{d&&!se(e)&&(t._observer=new IntersectionObserver((s=>{oe(s,e,t)}),(e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}))(e)))},ae=e=>Array.prototype.slice.call(e),ne=e=>e.container.querySelectorAll(e.elements_selector),le=e=>(e=>"error"===m(e))(e),ce=(e,t)=>(e=>ae(e).filter(y))(e||ne(t)),de=(e,t)=>{var s;(s=ne(e),ae(s).filter(le)).forEach((t=>{$(t,e.class_error),f(t)})),t.update()},he=function(e,t){const s=g(e);this._settings=s,this.loadingCount=0,re(s,this),((e,t)=>{l&&window.addEventListener("online",(()=>{de(e,t)}))})(s,this),this.update(t)};he.prototype={update:function(e){const t=this._settings,s=ce(e,t);var i,o;(P(this,s.length),!c&&d)?se(t)?ie(s,t,this):(i=this._observer,o=s,(e=>{e.disconnect()})(i),((e,t)=>{t.forEach((t=>{e.observe(t)}))})(i,o)):this.loadAll(s)},destroy:function(){this._observer&&this._observer.disconnect(),ne(this._settings).forEach((e=>{delete e.llOriginalAttrs})),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(e){const t=this._settings;ce(e,t).forEach((e=>{_(e,this),Q(e,t,this)}))}},he.load=(e,t)=>{const s=g(t);Q(e,s)},he.resetStatus=e=>{f(e)},l&&((e,t)=>{if(t)if(t.length)for(let s,i=0;s=t[i];i+=1)u(e,s);else u(e,t)})(he,window.lazyLoadOptions);const pe=(e,t,s,i)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const o=Object.getOwnPropertyDescriptor(e,s),r=Object.getOwnPropertyDescriptor(t,s);!we(o,r)&&i||Object.defineProperty(e,s,r)},we=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},ge=(e,t)=>`/* Wrapped ${e}*/\n${t}`,ue=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),be=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),me=(e,n,l)=>{const c=""===l?"":`with ${l.trim()}() `,d=ge.bind(null,c,n.toString());var h;Object.defineProperty(d,"name",be),Object.defineProperty(e,"toString",(h=((e,t)=>{for(var s in t||(t={}))o.call(t,s)&&a(e,s,t[s]);if(i)for(var s of i(t))r.call(t,s)&&a(e,s,t[s]);return e})({},ue),t(h,s({value:d}))))};var ve=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=e;for(const o of Reflect.ownKeys(t))pe(e,t,o,s);return((e,t)=>{const s=Object.getPrototypeOf(t);s!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,s)})(e,t),me(e,t,i),e};const fe=(e,t={})=>{if("function"!=typeof e)throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:s=0,maxWait:i=Number.Infinity,before:o=!1,after:r=!0}=t;if(!o&&!r)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,l;const c=function(...t){const c=this,d=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),r&&(l=e.apply(c,t))},h=o&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,n&&(clearTimeout(n),n=void 0),r&&(l=e.apply(c,t))}),s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(d,i)),h&&(l=e.apply(c,t)),l};return ve(c,e),c.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},c};class ye{constructor(){n(this,"disposers",new Map),n(this,"disposerIDGenCount",1)}add(e,t=this.genDisposerID()){return this.flush(t),this.disposers.set(t,e()),t}addDisposer(e,t=this.genDisposerID()){return this.add((()=>e),t)}addEventListener(e,t,s,i){e.addEventListener(t,s,i);const o=this.genDisposerID();return this.disposers.set(o,(()=>{e.removeEventListener(t,s)})),o}setTimeout(e,t,s=this.genDisposerID()){const i=window.setTimeout((()=>{e(),this.remove(s)}),t);this.disposers.set(s,(()=>{window.clearTimeout(i)}))}remove(e){const t=this.disposers.get(e);return this.disposers.delete(e),t}flush(e){if(e){const s=this.remove(e);if(s)try{s()}catch(t){console.error(t)}}else this.disposers.forEach((e=>{try{e()}catch(t){console.error(t)}})),this.disposers.clear()}genDisposerID(){return"disposer-"+this.disposerIDGenCount++}}class xe{constructor({readonly:e,box:t,pages:s,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new ye,s.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=t,this.pages=s,this.onNewPageIndex=i,this.onPlay=o,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add((()=>{const e=new he({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()}),"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flush(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const t=this.wrapClassName("preview-page"),s=this.wrapClassName("preview-page-name");this.pages.forEach(((i,o)=>{var r;const a=null!=(r=i.thumbnail)?r:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),l=document.createElement("a");l.className=t+" "+this.wrapClassName(`preview-page-${o}`),l.setAttribute("href","#"),l.dataset.pageIndex=n;const c=document.createElement("span");c.className=s,c.textContent=String(o+1),c.dataset.pageIndex=n;const d=document.createElement("img");d.width=i.width,d.height=i.height,d.dataset.src=a,d.dataset.pageIndex=n,l.appendChild(d),l.appendChild(c),e.appendChild(l)})),this.sideEffect.addEventListener(e,"click",(e=>{var t;if(this.readonly)return;const s=null==(t=e.target.dataset)?void 0:t.pageIndex;s&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.onNewPageIndex(Number(s)),this.togglePreview(!1))}))}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",(e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)}))),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some((e=>e.thumbnail||!e.src.startsWith("ppt")))){const e=this.renderFooterBtn("btn-sidebar",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M50 8H14c-3.309 0-6 2.691-6 6v36c0 3.309 2.691 6 6 6h36c3.309 0 6-2.691 6-6V14c0-3.309-2.691-6-6-6zM12 50V14c0-1.103.897-2 2-2h8v40h-8c-1.103 0-2-.897-2-2zm40 0c0 1.103-.897 2-2 2H26V12h24c1.103 0 2 .897 2 2z"),s.appendChild(i),s}(this.namespace));this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||this.togglePreview()})),this.$footer.appendChild(e)}const t=document.createElement("div");t.className=this.wrapClassName("page-jumps");const s=this.renderFooterBtn("btn-page-back",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M177.81 249.959L337.473 90.295c2.722-2.865 2.651-7.378-.143-10.1-2.793-2.65-7.163-2.65-9.956 0l-164.75 164.75c-2.793 2.793-2.793 7.306 0 10.1l164.75 164.75c2.865 2.722 7.378 2.65 10.099-.143 2.651-2.794 2.651-7.163 0-9.957L177.809 249.959z"),s.appendChild(i),s}(this.namespace));if(this.sideEffect.addEventListener(s,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),t.appendChild(s),this.onPlay){const e=this.renderFooterBtn("btn-page-play",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M418.158 257.419L174.663 413.33c-6.017 3.919-15.708 3.772-21.291-.29-2.791-2.018-4.295-4.483-4.295-7.084V94.109c0-5.65 6.883-10.289 15.271-10.289 4.298 0 8.391 1.307 11.181 3.332l242.629 155.484c6.016 3.917 6.451 10.292.649 14.491-.216.154-.432.154-.649.292zM170.621 391.288l223.116-141.301L170.71 107.753l-.089 283.535z"),s.appendChild(i),s}(this.namespace),function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M312.491 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261zM165.257 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261z"),s.appendChild(i),s}(this.namespace)),s=this.debounce((()=>{e.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)}),500);this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||(e.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),s())})),t.appendChild(e)}const i=this.renderFooterBtn("btn-page-next",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M322.19 250.041L162.527 409.705c-2.722 2.865-2.651 7.378.143 10.1 2.793 2.65 7.163 2.65 9.956 0l164.75-164.75c2.793-2.793 2.793-7.306 0-10.1l-164.75-164.75c-2.865-2.722-7.378-2.65-10.099.143-2.651 2.794-2.651 7.163 0 9.957l159.664 159.736z"),s.appendChild(i),s}(this.namespace));this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),t.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const r=document.createElement("input");r.className=this.wrapClassName("page-number-input"),r.value=String(this.pageIndex+1),this.readonly&&(r.disabled=!0),this.$pageNumberInput=r,this.sideEffect.addEventListener(r,"change",(()=>{this.readonly||r.value&&this.onNewPageIndex(Number(r.value)-1)}));const a=document.createElement("span");a.textContent=" / "+this.pages.length,o.appendChild(r),o.appendChild(a),this.$footer.appendChild(t),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t,s){const i=document.createElement("button");return i.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),i.appendChild(t),s&&i.appendChild(s),i}togglePreview(e){if(this.isShowPreview=null!=e?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const e=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));e&&this.$preview.scrollTo({top:e.offsetTop-16})}}debounce(e,t){const s=fe(e,{wait:t});return this.sideEffect.addDisposer((()=>s.cancel())),s}wrapClassName(e){return`${this.namespace}-${e}`}}function Ee(e,t,s){return Math.min(Math.max(e,t),s)}function Se(e){return e.touches?e.touches[0]:e}function Ne(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class $e{constructor({whiteboardView:e,readonly:t,box:s,pages:i,pagesSize:o,pageScrollTop:r=0,mountWhiteboard:a,onUserScroll:n}){this.onNewPageIndex=e=>{this.scrollToPage(e)},this.sideEffect=new ye,this.scrollbarHeight=30,this.whiteboardView=e,this.readonly=t,this.box=s,this.pages=i,this.pageScrollTop=r,this.pagesSize=o,this.mountWhiteboard=a,this.onUserScroll=n,this.viewer=new xe({readonly:t,box:s,pages:i,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add((()=>{const e=new he({container:this.$pages,elements_selector:`.${this.wrapClassName("page")}`});return()=>e.destroy()}),"page-lazyload"),this.setupWhiteboardCamera(),this.sideEffect.setTimeout((()=>{0!==this.pageScrollTop&&this.pageScrollTo(this.pageScrollTop)}),1e3),this.setupScrollTopEvent(),this.whiteboardView.callbacks.on("onSizeUpdated",(()=>{this.renderRatioHeight()})),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.onUserScroll=void 0,this.unmount(),this.viewer.destroy()}syncPageScrollTop(e){e>=0&&Math.abs(this.pageScrollTop-e)>10&&this.pageScrollTo(e)}render(){this.viewer.$content.appendChild(this.renderPages()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.viewer.$content.appendChild(this.renderScrollbar()),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,t=e<=640;if(this.viewer.setSmallBox(t),t){const t=26/640,s=26/e,i=26/640,o=0,r=Math.max((t+i-(s+o))/2,0);if(this.box.$titleBar){const e=s+r;this.box.$titleBar.style.height=100*e+"%"}if(this.box.$footer){const e=o+r;this.box.$footer.style.height=100*e+"%"}}else{if(this.box.$titleBar){const t=Math.max(26/640,26/e);this.box.$titleBar.style.height=100*t+"%"}if(this.box.$footer){const t=Math.max(26/640,26/e);this.box.$footer.style.height=100*t+"%"}}}renderPages(){if(!this.$pages){const e=document.createElement("div");e.className=this.wrapClassName("pages"),this.$pages=e;const t=this.wrapClassName("page");this.pages.forEach(((s,i)=>{const o=document.createElement("img");o.className=t+" "+this.wrapClassName(`page-${i}`),o.draggable=!1,o.width=s.width,o.height=s.height,o.dataset.src=s.src,o.dataset.pageIndex=String(i),e.appendChild(o)}))}return this.$pages}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{if(Ne(e),!this.readonly){const t=Ee(this.pageScrollTop+e.deltaY,0,this.pagesSize.height);this.pageScrollTo(t),this.onUserScroll&&this.onUserScroll(t)}}),{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchstart",(e=>{if(e.touches.length>1){if(Ne(e),this.readonly)return;this.handleSwipeScroll(e)}}),{passive:!1,capture:!0})),this.$whiteboardView}renderScrollbar(){if(!this.$scrollbar){const e=document.createElement("button");this.$scrollbar=e,e.className=this.wrapClassName("scrollbar"),e.style.minHeight="30px";const t=e=>{if(this.readonly)return;if(null!=e.button&&0!==e.button)return;Ne(e),this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!0);const t=this.scrollTopPageToEl(this.pageScrollTop),s=this.whiteboardView.size.width/this.pagesSize.width*this.pagesSize.height,{clientY:i}=Se(e),o=e=>{const{clientY:o}=Se(e),{height:r}=this.whiteboardView.size;this.elScrollTo(t+s/r*(o-i))},r=()=>{this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!1),window.removeEventListener("mousemove",o,!0),window.removeEventListener("touchmove",o,!0),window.removeEventListener("mouseup",r,!0),window.removeEventListener("touchend",r,!0),window.removeEventListener("touchcancel",r,!0)};window.addEventListener("mousemove",o,!0),window.addEventListener("touchmove",o,!0),window.addEventListener("mouseup",r,!0),window.addEventListener("touchend",r,!0),window.addEventListener("touchcancel",r,!0)};this.sideEffect.addEventListener(e,"mousedown",t),this.sideEffect.addEventListener(e,"touchstart",t)}return this.$scrollbar}scrollTopPageToEl(e){return e*(this.whiteboardView.size.width/this.pagesSize.width)}scrollTopElToPage(e){return e/(this.whiteboardView.size.width/this.pagesSize.width)}elScrollTo(e){this.$pages.scrollTo({top:e})}pageScrollTo(e){this.elScrollTo(this.scrollTopPageToEl(e))}scrollToPage(e){if(!this.readonly&&this.$pages&&!Number.isNaN(e)){e=Ee(e,0,this.pages.length-1);const t=this.$pages.querySelector("."+this.wrapClassName(`page-${e}`));if(t){const e=t.offsetTop+5;this.elScrollTo(e),this.onUserScroll&&this.onUserScroll(this.scrollTopElToPage(e))}}}setupScrollTopEvent(){const e=this.debounce((()=>{if(this.pages.length>0&&this.$pages){if(this.$pages.getBoundingClientRect().width>0){let e=0;for(let t=0;t<this.pages.length;t+=1)if(e+=this.pages[t].height,this.pageScrollTop<=e)return void this.viewer.setPageIndex(t);this.viewer.setPageIndex(this.pages.length-1)}}}),{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.addEventListener(this.$pages,"scroll",(()=>{const t=this.$pages.scrollTop,s=this.scrollTopElToPage(t);this.pageScrollTop=s;const{width:i,height:o}=this.whiteboardView.size,{width:r,height:a}=this.pagesSize,n=i/r*a;this.whiteboardView.moveCamera({centerY:this.scrollTopElToPage(t+o/2),animationMode:"immediately"}),this.setScrollbarHeight(o/n*o),this.$scrollbar.style.transform=`translateY(${t/(n-o)*(o-this.scrollbarHeight)}px)`,e()}))}setupWhiteboardCamera(){this.sideEffect.add((()=>{const e=({width:e,height:t})=>{if(e>0&&t>0){const s=this.$pages.scrollTop,i=this.pagesSize.width,o=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*o,width:i,height:t*o,animationMode:"immediately"}),this.elScrollTo(s)}};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}}),"whiteboard-size-update")}debounce(e,t,s){const i=fe(e,t);return this.sideEffect.addDisposer((()=>i.cancel()),s),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}setScrollbarHeight(e){e=Ee(e,30,this.whiteboardView.size.height),this.scrollbarHeight!==e&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}handleSwipeScroll(e){const t=this.scrollTopPageToEl(this.pageScrollTop),s=this.whiteboardView.size.width/this.pagesSize.width*this.pagesSize.height;let{clientY:i}=e.touches[0];const o=e=>{const{clientY:o}=e.touches[0];this.elScrollTo(Ee(t+(i-o),0,s))},r=e=>{({clientY:i}=e.touches[0]),window.removeEventListener("touchmove",o,!0),window.removeEventListener("touchend",r,!0),window.removeEventListener("touchcancel",r,!0)};window.addEventListener("touchmove",o,!0),window.addEventListener("touchend",r,!0),window.addEventListener("touchcancel",r,!0)}}class Ce{constructor({displayer:e,whiteboardView:t,getRoom:s,readonly:i,box:o,pages:r,mountWhiteboard:a}){var n;this.sideEffect=new ye,this.debounce=(n=this.sideEffect,(e,t)=>{const s=fe(e,t);return n.addDisposer((()=>s.cancel())),s}),this.onPlayPPT=()=>{const e=this.getWhiteboardRoom();e&&e.pptNextStep()},this._scaleDocsToFitImpl=()=>{const e=this.pages[this.getPageIndex()];e&&this.whiteboardView.moveCameraToContain({originX:-e.width/2,originY:-e.height/2,width:e.width,height:e.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=this.debounce(this._scaleDocsToFitImpl,{wait:1e3}),this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=e=>{this.jumpToPage(e,!0)},this.whiteboardView=t,this.readonly=i,this.box=o,this.pages=r,this.displayer=e,this.getWhiteboardRoom=s,this.mountWhiteboard=a,this.viewer=new xe({readonly:i,box:o,pages:r,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render()}mount(){this.viewer.mount();const e=this.getPageIndex();return 0!==e&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add((()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)}))),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,t){if((e=Ee(e,0,this.pages.length-1))!==this.getPageIndex()){const t=this.getWhiteboardRoom();t&&(t.setSceneIndex(e),this.scaleDocsToFit())}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),t){const e=this.getWhiteboardRoom();e&&e.setGlobalState({__pptState:void 0})}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",(e=>{var t;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":this.jumpToPage(this.getPageIndex()-1,!0);break;case"ArrowRight":case"ArrowDown":null==(t=this.getWhiteboardRoom())||t.pptNextStep()}}))}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;document.createElement("button").className=this.wrapClassName("back");document.createElement("button").className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",(e=>{var t;const s=this.getWhiteboardRoom();if(s&&"clicker"===s.state.memberState.currentApplianceName){for(let s=e.target;s;s=s.parentElement)if(null==(t=s.classList)?void 0:t.contains("ppt-event-source"))return;s.pptNextStep()}})),this.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const _e={kind:"DocsViewer",setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=e.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");i.disableCameraTransform=!0;const o=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(o.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(".netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.1);opacity:0;transition:background .4s,opacity .4s,transform .2s;will-change:transform,height;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.2);opacity:1;transition:background .4s,opacity .4s}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer}\n"),o[0].src.startsWith("ppt")?function(e,t,s,i){const o=e.getDisplayer(),r=new Ce({displayer:o,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.isAddApp&&t.callbacks.once("onSizeUpdated",(({width:t,height:o})=>{if(i.length>0){const{width:r,height:a}=i[0],n=a/r*t-o;0!==n&&e.getIsWritable()&&e.emitter.emit("setBoxSize",{width:s.width,height:s.height+n/s.containerRect.height})}}));e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),s.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,i,t,o):function(e,t,s,i){var o;const r={width:i[0].width,height:i.reduce(((e,t)=>e+t.height*(i[0].width/t.width)),0)},a=new $e({whiteboardView:t,readonly:s.readonly,box:s,pages:i,pagesSize:r,pageScrollTop:null==(o=e.getAttributes())?void 0:o.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:t=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===t||s.readonly||e.updateAttributes(["pageScrollTop"],t)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),s.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,i,t,o)}};export{_e as default};
var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i,n=("undefined"!=typeof require&&require,(e,t,s)=>(a(e,"symbol"!=typeof t?t+"":t,s),s));const l="undefined"!=typeof window,c=l&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),d=l&&"IntersectionObserver"in window,h=l&&"classList"in document.createElement("p"),p=l&&window.devicePixelRatio>1,g={elements_selector:".lazy",container:c||l?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_bg_hidpi:"bg-hidpi",data_bg_multi:"bg-multi",data_bg_multi_hidpi:"bg-multi-hidpi",data_poster:"poster",class_applied:"applied",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_entered:"entered",class_exited:"exited",unobserve_completed:!0,unobserve_entered:!1,cancel_on_exit:!0,callback_enter:null,callback_exit:null,callback_applied:null,callback_loading:null,callback_loaded:null,callback_error:null,callback_finish:null,callback_cancel:null,use_native:!1},w=e=>Object.assign({},g,e),u=function(e,t){var s;let i="LazyLoad::Initialized",o=new e(t);try{s=new CustomEvent(i,{detail:{instance:o}})}catch(r){(s=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:o})}window.dispatchEvent(s)},b=(e,t)=>e.getAttribute("data-"+t),m=e=>b(e,"ll-status"),v=(e,t)=>((e,t,s)=>{var i="data-"+t;null!==s?e.setAttribute(i,s):e.removeAttribute(i)})(e,"ll-status",t),f=e=>v(e,null),y=e=>null===m(e),x=e=>"native"===m(e),E=["loading","loaded","applied","error"],S=(e,t,s,i)=>{e&&(void 0===i?void 0===s?e(t):e(t,s):e(t,s,i))},N=(e,t)=>{h?e.classList.add(t):e.className+=(e.className?" ":"")+t},C=(e,t)=>{h?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},$=e=>e.llTempImage,_=(e,t)=>{if(!t)return;const s=t._observer;s&&s.unobserve(e)},T=(e,t)=>{e&&(e.loadingCount+=t)},P=(e,t)=>{e&&(e.toLoadCount=t)},k=e=>{let t=[];for(let s,i=0;s=e.children[i];i+=1)"SOURCE"===s.tagName&&t.push(s);return t},I=(e,t,s)=>{s&&e.setAttribute(t,s)},z=(e,t)=>{e.removeAttribute(t)},L=e=>!!e.llOriginalAttrs,V=e=>{if(L(e))return;const t={};t.src=e.getAttribute("src"),t.srcset=e.getAttribute("srcset"),t.sizes=e.getAttribute("sizes"),e.llOriginalAttrs=t},A=e=>{if(!L(e))return;const t=e.llOriginalAttrs;I(e,"src",t.src),I(e,"srcset",t.srcset),I(e,"sizes",t.sizes)},D=(e,t)=>{I(e,"sizes",b(e,t.data_sizes)),I(e,"srcset",b(e,t.data_srcset)),I(e,"src",b(e,t.data_src))},O=e=>{z(e,"src"),z(e,"srcset"),z(e,"sizes")},M=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;k(s).forEach(t)},R={IMG:(e,t)=>{M(e,(e=>{V(e),D(e,t)})),V(e),D(e,t)},IFRAME:(e,t)=>{I(e,"src",b(e,t.data_src))},VIDEO:(e,t)=>{((e,t)=>{k(e).forEach(t)})(e,(e=>{I(e,"src",b(e,t.data_src))})),I(e,"poster",b(e,t.data_poster)),I(e,"src",b(e,t.data_src)),e.load()}},W=(e,t)=>{const s=R[e.tagName];s&&s(e,t)},B=(e,t,s)=>{N(e,t.class_applied),v(e,"applied"),t.unobserve_completed&&_(e,t),S(t.callback_applied,e,s)},j=(e,t,s)=>{T(s,1),N(e,t.class_loading),v(e,"loading"),S(t.callback_loading,e,s)},F=["IMG","IFRAME","VIDEO"],U=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||S(e.callback_finish,t)},H=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},Y=(e,t,s)=>{e.removeEventListener(t,s)},G=e=>!!e.llEvLisnrs,q=e=>{if(!G(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];Y(e,s,i)}delete e.llEvLisnrs},X=(e,t,s)=>{(e=>{delete e.llTempImage})(e),T(s,-1),(e=>{e&&(e.toLoadCount-=1)})(s),C(e,t.class_loading),t.unobserve_completed&&_(e,s)},K=(e,t,s)=>{const i=$(e)||e;if(G(i))return;((e,t,s)=>{G(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";H(e,i,t),H(e,"error",s)})(i,(o=>{((e,t,s,i)=>{const o=x(t);X(t,s,i),N(t,s.class_loaded),v(t,"loaded"),S(s.callback_loaded,t,i),o||U(s,i)})(0,e,t,s),q(i)}),(o=>{((e,t,s,i)=>{const o=x(t);X(t,s,i),N(t,s.class_error),v(t,"error"),S(s.callback_error,t,i),o||U(s,i)})(0,e,t,s),q(i)}))},J=(e,t,s)=>{(e=>{e.llTempImage=document.createElement("IMG")})(e),K(e,t,s),((e,t,s)=>{const i=b(e,t.data_bg),o=b(e,t.data_bg_hidpi),r=p&&o?o:i;r&&(e.style.backgroundImage=`url("${r}")`,$(e).setAttribute("src",r),j(e,t,s))})(e,t,s),((e,t,s)=>{const i=b(e,t.data_bg_multi),o=b(e,t.data_bg_multi_hidpi),r=p&&o?o:i;r&&(e.style.backgroundImage=r,B(e,t,s))})(e,t,s)},Q=(e,t,s)=>{(e=>F.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{K(e,t,s),W(e,t),j(e,t,s)})(e,t,s):J(e,t,s)},Z=(e,t,s,i)=>{s.cancel_on_exit&&(e=>"loading"===m(e))(e)&&"IMG"===e.tagName&&(q(e),(e=>{M(e,(e=>{O(e)})),O(e)})(e),(e=>{M(e,(e=>{A(e)})),A(e)})(e),C(e,s.class_loading),T(i,-1),f(e),S(s.callback_cancel,e,t,i))},ee=(e,t,s,i)=>{const o=(e=>E.indexOf(m(e))>=0)(e);v(e,"entered"),N(e,s.class_entered),C(e,s.class_exited),((e,t,s)=>{t.unobserve_entered&&_(e,s)})(e,s,i),S(s.callback_enter,e,t,i),o||Q(e,s,i)},te=["IMG","IFRAME","VIDEO"],se=e=>e.use_native&&"loading"in HTMLImageElement.prototype,ie=(e,t,s)=>{e.forEach((e=>{-1!==te.indexOf(e.tagName)&&((e,t,s)=>{e.setAttribute("loading","lazy"),K(e,t,s),W(e,t),v(e,"native")})(e,t,s)})),P(s,0)},oe=(e,t,s)=>{e.forEach((e=>(e=>e.isIntersecting||e.intersectionRatio>0)(e)?ee(e.target,e,t,s):((e,t,s,i)=>{y(e)||(N(e,s.class_exited),Z(e,t,s,i),S(s.callback_exit,e,t,i))})(e.target,e,t,s)))},re=(e,t)=>{d&&!se(e)&&(t._observer=new IntersectionObserver((s=>{oe(s,e,t)}),(e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}))(e)))},ae=e=>Array.prototype.slice.call(e),ne=e=>e.container.querySelectorAll(e.elements_selector),le=e=>(e=>"error"===m(e))(e),ce=(e,t)=>(e=>ae(e).filter(y))(e||ne(t)),de=(e,t)=>{var s;(s=ne(e),ae(s).filter(le)).forEach((t=>{C(t,e.class_error),f(t)})),t.update()},he=function(e,t){const s=w(e);this._settings=s,this.loadingCount=0,re(s,this),((e,t)=>{l&&window.addEventListener("online",(()=>{de(e,t)}))})(s,this),this.update(t)};he.prototype={update:function(e){const t=this._settings,s=ce(e,t);var i,o;(P(this,s.length),!c&&d)?se(t)?ie(s,t,this):(i=this._observer,o=s,(e=>{e.disconnect()})(i),((e,t)=>{t.forEach((t=>{e.observe(t)}))})(i,o)):this.loadAll(s)},destroy:function(){this._observer&&this._observer.disconnect(),ne(this._settings).forEach((e=>{delete e.llOriginalAttrs})),delete this._observer,delete this._settings,delete this.loadingCount,delete this.toLoadCount},loadAll:function(e){const t=this._settings;ce(e,t).forEach((e=>{_(e,this),Q(e,t,this)}))}},he.load=(e,t)=>{const s=w(t);Q(e,s)},he.resetStatus=e=>{f(e)},l&&((e,t)=>{if(t)if(t.length)for(let s,i=0;s=t[i];i+=1)u(e,s);else u(e,t)})(he,window.lazyLoadOptions);const pe=(e,t,s,i)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const o=Object.getOwnPropertyDescriptor(e,s),r=Object.getOwnPropertyDescriptor(t,s);!ge(o,r)&&i||Object.defineProperty(e,s,r)},ge=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},we=(e,t)=>`/* Wrapped ${e}*/\n${t}`,ue=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),be=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),me=(e,n,l)=>{const c=""===l?"":`with ${l.trim()}() `,d=we.bind(null,c,n.toString());var h;Object.defineProperty(d,"name",be),Object.defineProperty(e,"toString",(h=((e,t)=>{for(var s in t||(t={}))o.call(t,s)&&a(e,s,t[s]);if(i)for(var s of i(t))r.call(t,s)&&a(e,s,t[s]);return e})({},ue),t(h,s({value:d}))))};var ve=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=e;for(const o of Reflect.ownKeys(t))pe(e,t,o,s);return((e,t)=>{const s=Object.getPrototypeOf(t);s!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,s)})(e,t),me(e,t,i),e};const fe=(e,t={})=>{if("function"!=typeof e)throw new TypeError(`Expected the first argument to be a function, got \`${typeof e}\``);const{wait:s=0,maxWait:i=Number.Infinity,before:o=!1,after:r=!0}=t;if(!o&&!r)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,l;const c=function(...t){const c=this,d=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),r&&(l=e.apply(c,t))},h=o&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,n&&(clearTimeout(n),n=void 0),r&&(l=e.apply(c,t))}),s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(d,i)),h&&(l=e.apply(c,t)),l};return ve(c,e),c.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},c};class ye{constructor(){n(this,"disposers",new Map),n(this,"disposerIDGenCount",1)}add(e,t=this.genDisposerID()){return this.flush(t),this.disposers.set(t,e()),t}addDisposer(e,t=this.genDisposerID()){return this.add((()=>e),t)}addEventListener(e,t,s,i){e.addEventListener(t,s,i);const o=this.genDisposerID();return this.disposers.set(o,(()=>{e.removeEventListener(t,s,i)})),o}setTimeout(e,t,s=this.genDisposerID()){const i=window.setTimeout((()=>{e(),this.remove(s)}),t);this.disposers.set(s,(()=>{window.clearTimeout(i)}))}remove(e){const t=this.disposers.get(e);return this.disposers.delete(e),t}flush(e){if(e){const s=this.remove(e);if(s)try{s()}catch(t){console.error(t)}}else this.disposers.forEach((e=>{try{e()}catch(t){console.error(t)}})),this.disposers.clear()}genDisposerID(){return"disposer-"+this.disposerIDGenCount++}}class xe{constructor({readonly:e,box:t,pages:s,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.namespace="netless-app-docs-viewer",this.isShowPreview=!1,this.isSmallBox=!1,this.sideEffect=new ye,s.length<=0)throw new Error("[DocsViewer] Empty pages.");this.readonly=e,this.box=t,this.pages=s,this.onNewPageIndex=i,this.onPlay=o,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add((()=>{const e=new he({container:this.$preview,elements_selector:`.${this.wrapClassName("preview-page>img")}`});return()=>e.destroy()}),"preview-lazyload")}unmount(){this.$content.remove(),this.$footer.remove()}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.$content.classList.toggle(this.wrapClassName("readonly"),e),this.$footer.classList.toggle(this.wrapClassName("readonly"),e),this.$pageNumberInput.disabled=e)}destroy(){this.sideEffect.flush(),this.unmount()}setPageIndex(e){Number.isNaN(e)||(this.pageIndex=e,this.$pageNumberInput.value=String(e+1))}setSmallBox(e){this.isSmallBox!==e&&(this.isSmallBox=e,this.$footer.classList.toggle(this.wrapClassName("float-footer"),e))}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const t=this.wrapClassName("preview-page"),s=this.wrapClassName("preview-page-name");this.pages.forEach(((i,o)=>{var r;const a=null!=(r=i.thumbnail)?r:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),l=document.createElement("a");l.className=t+" "+this.wrapClassName(`preview-page-${o}`),l.setAttribute("href","#"),l.dataset.pageIndex=n;const c=document.createElement("span");c.className=s,c.textContent=String(o+1),c.dataset.pageIndex=n;const d=document.createElement("img");d.width=i.width,d.height=i.height,d.dataset.src=a,d.dataset.pageIndex=n,l.appendChild(d),l.appendChild(c),e.appendChild(l)})),this.sideEffect.addEventListener(e,"click",(e=>{var t;if(this.readonly)return;const s=null==(t=e.target.dataset)?void 0:t.pageIndex;s&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.onNewPageIndex(Number(s)),this.togglePreview(!1))}))}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",(e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)}))),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some((e=>e.thumbnail||!e.src.startsWith("ppt")))){const e=this.renderFooterBtn("btn-sidebar",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-sidebar`),s.setAttribute("viewBox","0 0 64 64");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M50 8H14c-3.309 0-6 2.691-6 6v36c0 3.309 2.691 6 6 6h36c3.309 0 6-2.691 6-6V14c0-3.309-2.691-6-6-6zM12 50V14c0-1.103.897-2 2-2h8v40h-8c-1.103 0-2-.897-2-2zm40 0c0 1.103-.897 2-2 2H26V12h24c1.103 0 2 .897 2 2z"),s.appendChild(i),s}(this.namespace));this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||this.togglePreview()})),this.$footer.appendChild(e)}const t=document.createElement("div");t.className=this.wrapClassName("page-jumps");const s=this.renderFooterBtn("btn-page-back",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-left`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M177.81 249.959L337.473 90.295c2.722-2.865 2.651-7.378-.143-10.1-2.793-2.65-7.163-2.65-9.956 0l-164.75 164.75c-2.793 2.793-2.793 7.306 0 10.1l164.75 164.75c2.865 2.722 7.378 2.65 10.099-.143 2.651-2.794 2.651-7.163 0-9.957L177.809 249.959z"),s.appendChild(i),s}(this.namespace));if(this.sideEffect.addEventListener(s,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),t.appendChild(s),this.onPlay){const e=this.renderFooterBtn("btn-page-play",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-play`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M418.158 257.419L174.663 413.33c-6.017 3.919-15.708 3.772-21.291-.29-2.791-2.018-4.295-4.483-4.295-7.084V94.109c0-5.65 6.883-10.289 15.271-10.289 4.298 0 8.391 1.307 11.181 3.332l242.629 155.484c6.016 3.917 6.451 10.292.649 14.491-.216.154-.432.154-.649.292zM170.621 391.288l223.116-141.301L170.71 107.753l-.089 283.535z"),s.appendChild(i),s}(this.namespace),function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-pause`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M312.491 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261zM165.257 78.261c0-6.159 4.893-11.213 11.04-11.213 6.158 0 11.211 5.054 11.211 11.213v343.478c0 6.159-5.053 11.213-11.211 11.213-6.147 0-11.04-5.054-11.04-11.213V78.261z"),s.appendChild(i),s}(this.namespace)),s=this.debounce((()=>{e.classList.toggle(this.wrapClassName("footer-btn-playing"),!1)}),500);this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||(e.classList.toggle(this.wrapClassName("footer-btn-playing"),!0),this.onPlay&&this.onPlay(),s())})),t.appendChild(e)}const i=this.renderFooterBtn("btn-page-next",function(e){const t="http://www.w3.org/2000/svg",s=document.createElementNS(t,"svg");s.setAttribute("class",`${e}-footer-icon-arrow-right`),s.setAttribute("viewBox","0 0 500 500");const i=document.createElementNS(t,"path");return i.setAttribute("fill","currentColor"),i.setAttribute("d","M322.19 250.041L162.527 409.705c-2.722 2.865-2.651 7.378.143 10.1 2.793 2.65 7.163 2.65 9.956 0l164.75-164.75c2.793-2.793 2.793-7.306 0-10.1l-164.75-164.75c-2.865-2.722-7.378-2.65-10.099.143-2.651 2.794-2.651 7.163 0 9.957l159.664 159.736z"),s.appendChild(i),s}(this.namespace));this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),t.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const r=document.createElement("input");r.className=this.wrapClassName("page-number-input"),r.value=String(this.pageIndex+1),this.readonly&&(r.disabled=!0),this.$pageNumberInput=r,this.sideEffect.addEventListener(r,"change",(()=>{this.readonly||r.value&&this.onNewPageIndex(Number(r.value)-1)}));const a=document.createElement("span");a.textContent=" / "+this.pages.length,o.appendChild(r),o.appendChild(a),this.$footer.appendChild(t),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t,s){const i=document.createElement("button");return i.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e),i.appendChild(t),s&&i.appendChild(s),i}togglePreview(e){if(this.isShowPreview=null!=e?e:!this.isShowPreview,this.$content.classList.toggle(this.wrapClassName("preview-active"),this.isShowPreview),this.isShowPreview){const e=this.$preview.querySelector("."+this.wrapClassName(`preview-page-${this.pageIndex}`));e&&this.$preview.scrollTo({top:e.offsetTop-16})}}debounce(e,t){const s=fe(e,{wait:t});return this.sideEffect.addDisposer((()=>s.cancel())),s}wrapClassName(e){return`${this.namespace}-${e}`}}function Ee(e,t,s){return Math.min(Math.max(e,t),s)}function Se(e){return e.touches?e.touches[0]:e}function Ne(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class Ce{constructor({whiteboardView:e,readonly:t,box:s,pages:i,pagesSize:o,pageScrollTop:r=0,mountWhiteboard:a,onUserScroll:n}){this.onNewPageIndex=e=>{this.scrollToPage(e)},this.sideEffect=new ye,this.scrollbarHeight=30,this.whiteboardView=e,this.readonly=t,this.box=s,this.pages=i,this.pageScrollTop=r,this.pagesSize=o,this.mountWhiteboard=a,this.onUserScroll=n,this.viewer=new xe({readonly:t,box:s,pages:i,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add((()=>{const e=new he({container:this.$pages,elements_selector:`.${this.wrapClassName("page")}`});return()=>e.destroy()}),"page-lazyload"),this.setupWhiteboardCamera(),this.sideEffect.setTimeout((()=>{0!==this.pageScrollTop&&this.pageScrollTo(this.pageScrollTop)}),1e3),this.setupScrollTopEvent(),this.whiteboardView.callbacks.on("onSizeUpdated",(()=>{this.renderRatioHeight()})),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.onUserScroll=void 0,this.unmount(),this.viewer.destroy()}syncPageScrollTop(e){e>=0&&Math.abs(this.pageScrollTop-e)>10&&this.pageScrollTo(e)}render(){this.viewer.$content.appendChild(this.renderPages()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.viewer.$content.appendChild(this.renderScrollbar()),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,t=e<=640;if(this.viewer.setSmallBox(t),t){const t=26/640,s=26/e,i=26/640,o=0,r=Math.max((t+i-(s+o))/2,0);if(this.box.$titleBar){const e=s+r;this.box.$titleBar.style.height=100*e+"%"}if(this.box.$footer){const e=o+r;this.box.$footer.style.height=100*e+"%"}}else{if(this.box.$titleBar){const t=Math.max(26/640,26/e);this.box.$titleBar.style.height=100*t+"%"}if(this.box.$footer){const t=Math.max(26/640,26/e);this.box.$footer.style.height=100*t+"%"}}}renderPages(){if(!this.$pages){const e=document.createElement("div");e.className=this.wrapClassName("pages"),this.$pages=e;const t=this.wrapClassName("page");this.pages.forEach(((s,i)=>{const o=document.createElement("img");o.className=t+" "+this.wrapClassName(`page-${i}`),o.draggable=!1,o.width=s.width,o.height=s.height,o.dataset.src=s.src,o.dataset.pageIndex=String(i),e.appendChild(o)}))}return this.$pages}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{Ne(e),this.readonly||(this.pageScrollTo(this.pageScrollTop+e.deltaY),this.updateUserScroll())}),{passive:!1,capture:!0}),this.sideEffect.addEventListener(this.$whiteboardView,"touchmove",(e=>{this.readonly||e.touches.length<=1||this.updateUserScroll()}),{passive:!0,capture:!0})),this.$whiteboardView}renderScrollbar(){if(!this.$scrollbar){const e=document.createElement("button");this.$scrollbar=e,e.className=this.wrapClassName("scrollbar"),e.style.minHeight="30px";const t=e=>{if(this.readonly)return;if(null!=e.button&&0!==e.button)return;Ne(e),this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!0);const t=this.scrollTopPageToEl(this.pageScrollTop),s=this.whiteboardView.size.width/this.pagesSize.width*this.pagesSize.height,{clientY:i}=Se(e),o=e=>{const{clientY:o}=Se(e),{height:r}=this.whiteboardView.size;this.elScrollTo(t+s/r*(o-i))},r=()=>{this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!1),window.removeEventListener("mousemove",o,!0),window.removeEventListener("touchmove",o,!0),window.removeEventListener("mouseup",r,!0),window.removeEventListener("touchend",r,!0),window.removeEventListener("touchcancel",r,!0)};window.addEventListener("mousemove",o,!0),window.addEventListener("touchmove",o,!0),window.addEventListener("mouseup",r,!0),window.addEventListener("touchend",r,!0),window.addEventListener("touchcancel",r,!0)};this.sideEffect.addEventListener(e,"mousedown",t),this.sideEffect.addEventListener(e,"touchstart",t)}return this.$scrollbar}scrollTopPageToEl(e){return e*(this.whiteboardView.size.width/this.pagesSize.width)}scrollTopElToPage(e){return e/(this.whiteboardView.size.width/this.pagesSize.width)}elScrollTo(e){this.pageScrollTo(this.scrollTopElToPage(e))}pageScrollTo(e){const t=this.scrollTopElToPage(this.whiteboardView.size.height/2);this.whiteboardView.moveCamera({centerY:Ee(e+t,t,this.pagesSize.height-t),animationMode:"immediately"})}scrollToPage(e){if(!this.readonly&&this.$pages&&!Number.isNaN(e)){e=Ee(e,0,this.pages.length-1);const t=this.$pages.querySelector("."+this.wrapClassName(`page-${e}`));if(t){const e=t.offsetTop+5;this.elScrollTo(e),this.updateUserScroll()}}}setupScrollTopEvent(){const e=this.debounce((()=>{if(this.pages.length>0&&this.$pages){if(this.$pages.getBoundingClientRect().width>0){let e=0;for(let t=0;t<this.pages.length;t+=1)if(e+=this.pages[t].height,this.pageScrollTop<=e)return void this.viewer.setPageIndex(t);this.viewer.setPageIndex(this.pages.length-1)}}}),{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.add((()=>{const t=t=>{const{width:s,height:i}=this.whiteboardView.size,{width:o,height:r}=this.pagesSize,a=s/o*r,n=this.scrollTopPageToEl(t.centerY)-i/2,l=this.scrollTopElToPage(n);this.pageScrollTop=l,this.$pages.scrollTo({top:n}),this.setScrollbarHeight(i/a*i),this.$scrollbar.style.transform=`translateY(${n/(a-i)*(i-this.scrollbarHeight)}px)`,e()};return this.whiteboardView.callbacks.on("onCameraUpdated",t),()=>this.whiteboardView.callbacks.off("onCameraUpdated",t)}))}setupWhiteboardCamera(){this.sideEffect.add((()=>{const e=({width:e,height:t})=>{if(e>0&&t>0){const s=this.$pages.scrollTop,i=this.pagesSize.width,o=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*o,width:i,height:t*o,animationMode:"immediately"}),this.whiteboardView.setCameraBound({damping:1,maxContentMode:()=>e/i,minContentMode:()=>e/i,centerX:this.pagesSize.width/2,centerY:this.pagesSize.height/2,width:this.pagesSize.width,height:this.pagesSize.height}),this.elScrollTo(s)}};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}}),"whiteboard-size-update")}updateUserScroll(){window.requestAnimationFrame((()=>{this.onUserScroll&&this.onUserScroll(this.pageScrollTop)}))}debounce(e,t,s){const i=fe(e,t);return this.sideEffect.addDisposer((()=>i.cancel()),s),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}setScrollbarHeight(e){e=Ee(e,30,this.whiteboardView.size.height),this.scrollbarHeight!==e&&(this.scrollbarHeight=e,this.$scrollbar.style.height=`${e}px`)}}class $e{constructor({displayer:e,whiteboardView:t,getRoom:s,readonly:i,box:o,pages:r,mountWhiteboard:a}){var n;this.sideEffect=new ye,this.debounce=(n=this.sideEffect,(e,t)=>{const s=fe(e,t);return n.addDisposer((()=>s.cancel())),s}),this.onPlayPPT=()=>{const e=this.getWhiteboardRoom();e&&e.pptNextStep()},this._scaleDocsToFitImpl=()=>{const e=this.pages[this.getPageIndex()];e&&this.whiteboardView.moveCameraToContain({originX:-e.width/2,originY:-e.height/2,width:e.width,height:e.height,animationMode:"immediately"})},this._scaleDocsToFitDebounced=this.debounce(this._scaleDocsToFitImpl,{wait:1e3}),this.scaleDocsToFit=()=>{this._scaleDocsToFitImpl(),this._scaleDocsToFitDebounced()},this.onNewPageIndex=e=>{this.jumpToPage(e,!0)},this.whiteboardView=t,this.readonly=i,this.box=o,this.pages=r,this.displayer=e,this.getWhiteboardRoom=s,this.mountWhiteboard=a,this.viewer=new xe({readonly:i,box:o,pages:r,onNewPageIndex:this.onNewPageIndex,onPlay:this.onPlayPPT}),this.render()}mount(){this.viewer.mount();const e=this.getPageIndex();return 0!==e&&this.jumpToPage(e),this.scaleDocsToFit(),this.sideEffect.add((()=>(this.whiteboardView.callbacks.on("onSizeUpdated",this.scaleDocsToFit),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",this.scaleDocsToFit)}))),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.unmount(),this.viewer.destroy()}getPageIndex(){return this.displayer.state.sceneState.index}jumpToPage(e,t){if((e=Ee(e,0,this.pages.length-1))!==this.getPageIndex()){const t=this.getWhiteboardRoom();t&&(t.setSceneIndex(e),this.scaleDocsToFit())}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),t){const e=this.getWhiteboardRoom();e&&e.setGlobalState({__pptState:void 0})}}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.sideEffect.addEventListener(window,"keydown",(e=>{var t;if(this.box.focus)switch(e.key){case"ArrowUp":case"ArrowLeft":this.jumpToPage(this.getPageIndex()-1,!0);break;case"ArrowRight":case"ArrowDown":null==(t=this.getWhiteboardRoom())||t.pptNextStep()}}))}renderMask(){if(!this.$mask){const e=document.createElement("div");e.className=this.wrapClassName("mask"),this.$mask=e;document.createElement("button").className=this.wrapClassName("back");document.createElement("button").className=this.wrapClassName("next")}return this.$mask}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.sideEffect.addEventListener(this.$whiteboardView,"click",(e=>{var t;const s=this.getWhiteboardRoom();if(s&&"clicker"===s.state.memberState.currentApplianceName){for(let s=e.target;s;s=s.parentElement)if(null==(t=s.classList)?void 0:t.contains("ppt-event-source"))return;s.pptNextStep()}})),this.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const _e={kind:"DocsViewer",setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=e.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");const o=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(o.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(".netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7;color:#191919}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);transition:opacity .4s}.netless-app-docs-viewer-footer-btn{box-sizing:border-box;width:26px;height:26px;font-size:0;margin:0;padding:3px;border:none;border-radius:1px;outline:none;color:currentColor;background:transparent;transition:background .4s;cursor:pointer;user-select:none}.netless-app-docs-viewer-footer-btn:hover{background:rgba(237,237,240,.9)}.netless-app-docs-viewer-footer-btn>svg{width:100%;height:100%}.netless-app-docs-viewer-footer-btn>svg:nth-of-type(2){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(1){display:none}.netless-app-docs-viewer-footer-btn.netless-app-docs-viewer-footer-btn-playing>svg:nth-of-type(2){display:initial}.netless-app-docs-viewer-footer-btn~.netless-app-docs-viewer-footer-btn{margin-left:15px}.netless-app-docs-viewer-page-jumps{flex:1;display:flex;justify-content:center;align-items:center}.netless-app-docs-viewer-page-number{margin-left:auto;font-size:13px;user-select:none;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;color:currentColor;background:transparent;transition:background .4s;user-select:text}.netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-page-number-input:active{background:#fff;box-shadow:#63636333 0 2px 8px}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-footer-btn:hover{background:transparent}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input{cursor:not-allowed}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:hover,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:focus,.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:active{background:transparent;box-shadow:none}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-page-number-input:disabled{color:inherit}.netless-app-docs-viewer-readonly.netless-app-docs-viewer-float-footer{display:none}.netless-app-docs-viewer-static-pages{overflow:hidden;position:relative;height:100%;user-select:none}.netless-app-docs-viewer-static-pages:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-static-page{display:block;width:100%;height:auto;user-select:none}.netless-app-docs-viewer-static-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-static-scrollbar{position:absolute;top:0;right:0;z-index:2147483647;width:8px;min-height:30px;margin:0;padding:0;border:none;outline:none;border-radius:4px;background:rgba(68,78,96,.1);opacity:0;transition:background .4s,opacity .4s,transform .2s;will-change:transform,height;user-select:none}.netless-app-docs-viewer-static-scrollbar.netless-app-docs-viewer-static-scrollbar-dragging{background:rgba(68,78,96,.2);opacity:1;transition:background .4s,opacity .4s}.netless-app-docs-viewer-static-scrollbar:hover,.netless-app-docs-viewer-static-scrollbar:focus{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-static-scrollbar:active{background:rgba(68,78,96,.2)}.netless-app-docs-viewer-content:hover .netless-app-docs-viewer-static-scrollbar{opacity:1}.netless-app-docs-viewer-readonly .netless-app-docs-viewer-static-scrollbar{display:none}.netless-app-docs-viewer-dynamic-wb-view{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;overflow:hidden}.netless-app-docs-viewer-dynamic-wb-view .cursor-clicker .ppt-event-source{cursor:pointer}\n"),o[0].src.startsWith("ppt")?function(e,t,s,i){t.disableCameraTransform=!0;const o=e.getDisplayer(),r=new $e({displayer:o,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.isAddApp&&t.callbacks.once("onSizeUpdated",(({width:t,height:o})=>{if(i.length>0){const{width:r,height:a}=i[0],n=a/r*t-o;0!==n&&e.getIsWritable()&&e.emitter.emit("setBoxSize",{width:s.width,height:s.height+n/s.containerRect.height})}}));e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),s.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,i,t,o):function(e,t,s,i){var o;const r={width:i[0].width,height:i.reduce(((e,t)=>e+t.height*(i[0].width/t.width)),0)},a=new Ce({whiteboardView:t,readonly:s.readonly,box:s,pages:i,pagesSize:r,pageScrollTop:null==(o=e.getAttributes())?void 0:o.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:t=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===t||s.readonly||e.updateAttributes(["pageScrollTop"],t)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),s.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,i,t,o)}};export{_e as default};
//# sourceMappingURL=main.es.js.map

@@ -58,2 +58,3 @@ import type { ReadonlyTeleBox } from "@netless/window-manager";

protected setupWhiteboardCamera(): void;
protected updateUserScroll(): void;
protected debounce<ArgumentsType extends unknown[], ReturnType>(fn: (...args: ArgumentsType) => ReturnType, options: Options, disposerID?: string): DebouncedFunction<ArgumentsType, ReturnType | undefined>;

@@ -65,3 +66,2 @@ protected wrapClassName(className: string): string;

protected setScrollbarHeight(elScrollbarHeight: number): void;
protected handleSwipeScroll(ev: TouchEvent): void;
}
{
"name": "@netless/app-docs-viewer",
"version": "0.1.19",
"version": "0.1.20",
"description": "Netless App Docs Viewer",

@@ -29,4 +29,4 @@ "repository": "netless-io/netless-app",

"devDependencies": {
"@netless/app-shared": "workspace:^0.1.0"
"@netless/app-shared": "workspace:*"
}
}

@@ -8,2 +8,3 @@ import styles from "./style.scss?inline";

import { DynamicDocsViewer } from "./DynamicDocsViewer";
import { kind } from "./constants";

@@ -22,3 +23,3 @@ export type { DocsViewerPage } from "./DocsViewer";

> = {
kind: "DocsViewer",
kind,
setup(context) {

@@ -37,4 +38,2 @@ const box = context.getBox();

whiteboardView.disableCameraTransform = true;
const pages = scenes

@@ -129,2 +128,4 @@ .map(({ ppt }): DocsViewerPage | null =>

): void {
whiteboardView.disableCameraTransform = true;
const displayer = context.getDisplayer();

@@ -131,0 +132,0 @@

import type { AnimationMode, ReadonlyTeleBox } from "@netless/window-manager";
import type { View, Size } from "white-web-sdk";
import type { View, Size, Camera } from "white-web-sdk";
import LazyLoad from "vanilla-lazyload";

@@ -210,7 +210,4 @@ import type { DebouncedFunction, Options } from "debounce-fn";

if (!this.readonly) {
const scrollTop = clamp(this.pageScrollTop + ev.deltaY, 0, this.pagesSize.height);
this.pageScrollTo(scrollTop);
if (this.onUserScroll) {
this.onUserScroll(scrollTop);
}
this.pageScrollTo(this.pageScrollTop + ev.deltaY);
this.updateUserScroll();
}

@@ -222,13 +219,10 @@ },

this.$whiteboardView,
"touchstart",
"touchmove",
ev => {
if (ev.touches.length > 1) {
preventEvent(ev);
if (this.readonly) {
return;
}
this.handleSwipeScroll(ev);
if (this.readonly || ev.touches.length <= 1) {
return;
}
this.updateUserScroll();
},
{ passive: false, capture: true }
{ passive: true, capture: true }
);

@@ -302,5 +296,3 @@ }

protected elScrollTo(elScrollTop: number): void {
this.$pages.scrollTo({
top: elScrollTop,
});
this.pageScrollTo(this.scrollTopElToPage(elScrollTop));
}

@@ -310,3 +302,11 @@

protected pageScrollTo(pageScrollTop: number): void {
this.elScrollTo(this.scrollTopPageToEl(pageScrollTop));
const halfWbHeight = this.scrollTopElToPage(this.whiteboardView.size.height / 2);
this.whiteboardView.moveCamera({
centerY: clamp(
pageScrollTop + halfWbHeight,
halfWbHeight,
this.pagesSize.height - halfWbHeight
),
animationMode: "immediately" as AnimationMode,
});
}

@@ -323,5 +323,3 @@

this.elScrollTo(elOffsetTop);
if (this.onUserScroll) {
this.onUserScroll(this.scrollTopElToPage(elOffsetTop));
}
this.updateUserScroll();
}

@@ -353,22 +351,23 @@ }

this.sideEffect.addEventListener(this.$pages, "scroll", () => {
const elScrollTop = this.$pages.scrollTop;
const pageScrollTop = this.scrollTopElToPage(elScrollTop);
this.pageScrollTop = pageScrollTop;
this.sideEffect.add(() => {
const handleCameraUpdate = (camera: Camera) => {
const { width: wbWidth, height: wbHeight } = this.whiteboardView.size;
const { width: pageWidth, height: pageHeight } = this.pagesSize;
const elScrollHeight = (wbWidth / pageWidth) * pageHeight;
const { width: wbWidth, height: wbHeight } = this.whiteboardView.size;
const { width: pageWidth, height: pageHeight } = this.pagesSize;
const elScrollHeight = (wbWidth / pageWidth) * pageHeight;
const elScrollTop = this.scrollTopPageToEl(camera.centerY) - wbHeight / 2;
const pageScrollTop = this.scrollTopElToPage(elScrollTop);
this.pageScrollTop = pageScrollTop;
this.whiteboardView.moveCamera({
centerY: this.scrollTopElToPage(elScrollTop + wbHeight / 2),
animationMode: "immediately" as AnimationMode,
});
this.$pages.scrollTo({ top: elScrollTop });
this.setScrollbarHeight((wbHeight / elScrollHeight) * wbHeight);
this.$scrollbar.style.transform = `translateY(${
(elScrollTop / (elScrollHeight - wbHeight)) * (wbHeight - this.scrollbarHeight)
}px)`;
this.setScrollbarHeight((wbHeight / elScrollHeight) * wbHeight);
this.$scrollbar.style.transform = `translateY(${
(elScrollTop / (elScrollHeight - wbHeight)) * (wbHeight - this.scrollbarHeight)
}px)`;
updatePageIndex();
updatePageIndex();
};
this.whiteboardView.callbacks.on("onCameraUpdated", handleCameraUpdate);
return () => this.whiteboardView.callbacks.off("onCameraUpdated", handleCameraUpdate);
});

@@ -391,2 +390,11 @@ }

});
this.whiteboardView.setCameraBound({
damping: 1,
maxContentMode: () => width / pageWidth,
minContentMode: () => width / pageWidth,
centerX: this.pagesSize.width / 2,
centerY: this.pagesSize.height / 2,
width: this.pagesSize.width,
height: this.pagesSize.height,
});
this.elScrollTo(elScrollTop);

@@ -402,2 +410,10 @@ }

protected updateUserScroll(): void {
window.requestAnimationFrame(() => {
if (this.onUserScroll) {
this.onUserScroll(this.pageScrollTop);
}
});
}
protected debounce<ArgumentsType extends unknown[], ReturnType>(

@@ -436,25 +452,2 @@ fn: (...args: ArgumentsType) => ReturnType,

}
protected handleSwipeScroll(ev: TouchEvent): void {
const startTop = this.scrollTopPageToEl(this.pageScrollTop);
const elScrollHeight =
(this.whiteboardView.size.width / this.pagesSize.width) * this.pagesSize.height;
let { clientY: startY } = ev.touches[0];
const tracking = (ev: TouchEvent): void => {
const { clientY } = ev.touches[0];
this.elScrollTo(clamp(startTop + (startY - clientY), 0, elScrollHeight));
};
const trackEnd = (ev: TouchEvent): void => {
({ clientY: startY } = ev.touches[0]);
window.removeEventListener("touchmove", tracking, true);
window.removeEventListener("touchend", trackEnd, true);
window.removeEventListener("touchcancel", trackEnd, true);
};
window.addEventListener("touchmove", tracking, true);
window.addEventListener("touchend", trackEnd, true);
window.addEventListener("touchcancel", trackEnd, true);
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc