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
9
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.7 to 0.1.8

2

dist/main.cjs.js

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

"use strict";var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,a=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;const n="undefined"!=typeof window,l=n&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),d=n&&"IntersectionObserver"in window,c=n&&"classList"in document.createElement("p"),h=n&&window.devicePixelRatio>1,p={elements_selector:".lazy",container:l||n?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({},p,e),w=function(e,t){var s;let i="LazyLoad::Initialized",r=new e(t);try{s=new CustomEvent(i,{detail:{instance:r}})}catch(o){(s=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:r})}window.dispatchEvent(s)},u=(e,t)=>e.getAttribute("data-"+t),m=e=>u(e,"ll-status"),b=(e,t)=>((e,t,s)=>{var i="data-"+t;null!==s?e.setAttribute(i,s):e.removeAttribute(i)})(e,"ll-status",t),v=e=>b(e,null),y=e=>null===m(e),f=e=>"native"===m(e),M=["loading","loaded","applied","error"],x=(e,t,s,i)=>{e&&(void 0===i?void 0===s?e(t):e(t,s):e(t,s,i))},E=(e,t)=>{c?e.classList.add(t):e.className+=(e.className?" ":"")+t},N=(e,t)=>{c?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},T=e=>e.llTempImage,I=(e,t)=>{if(!t)return;const s=t._observer;s&&s.unobserve(e)},L=(e,t)=>{e&&(e.loadingCount+=t)},C=(e,t)=>{e&&(e.toLoadCount=t)},j=e=>{let t=[];for(let s,i=0;s=e.children[i];i+=1)"SOURCE"===s.tagName&&t.push(s);return t},A=(e,t,s)=>{s&&e.setAttribute(t,s)},S=(e,t)=>{e.removeAttribute(t)},z=e=>!!e.llOriginalAttrs,D=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},P=e=>{if(!z(e))return;const t=e.llOriginalAttrs;A(e,"src",t.src),A(e,"srcset",t.srcset),A(e,"sizes",t.sizes)},k=(e,t)=>{A(e,"sizes",u(e,t.data_sizes)),A(e,"srcset",u(e,t.data_srcset)),A(e,"src",u(e,t.data_src))},O=e=>{S(e,"src"),S(e,"srcset"),S(e,"sizes")},$=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;j(s).forEach(t)},_={IMG:(e,t)=>{$(e,(e=>{D(e),k(e,t)})),D(e),k(e,t)},IFRAME:(e,t)=>{A(e,"src",u(e,t.data_src))},VIDEO:(e,t)=>{((e,t)=>{j(e).forEach(t)})(e,(e=>{A(e,"src",u(e,t.data_src))})),A(e,"poster",u(e,t.data_poster)),A(e,"src",u(e,t.data_src)),e.load()}},V=(e,t)=>{const s=_[e.tagName];s&&s(e,t)},Y=(e,t,s)=>{E(e,t.class_applied),b(e,"applied"),t.unobserve_completed&&I(e,t),x(t.callback_applied,e,s)},U=(e,t,s)=>{L(s,1),E(e,t.class_loading),b(e,"loading"),x(t.callback_loading,e,s)},R=["IMG","IFRAME","VIDEO"],Z=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||x(e.callback_finish,t)},W=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},F=(e,t,s)=>{e.removeEventListener(t,s)},H=e=>!!e.llEvLisnrs,Q=e=>{if(!H(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];F(e,s,i)}delete e.llEvLisnrs},B=(e,t,s)=>{(e=>{delete e.llTempImage})(e),L(s,-1),(e=>{e&&(e.toLoadCount-=1)})(s),N(e,t.class_loading),t.unobserve_completed&&I(e,s)},G=(e,t,s)=>{const i=T(e)||e;if(H(i))return;((e,t,s)=>{H(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";W(e,i,t),W(e,"error",s)})(i,(r=>{((e,t,s,i)=>{const r=f(t);B(t,s,i),E(t,s.class_loaded),b(t,"loaded"),x(s.callback_loaded,t,i),r||Z(s,i)})(0,e,t,s),Q(i)}),(r=>{((e,t,s,i)=>{const r=f(t);B(t,s,i),E(t,s.class_error),b(t,"error"),x(s.callback_error,t,i),r||Z(s,i)})(0,e,t,s),Q(i)}))},X=(e,t,s)=>{(e=>{e.llTempImage=document.createElement("IMG")})(e),G(e,t,s),((e,t,s)=>{const i=u(e,t.data_bg),r=u(e,t.data_bg_hidpi),o=h&&r?r:i;o&&(e.style.backgroundImage=`url("${o}")`,T(e).setAttribute("src",o),U(e,t,s))})(e,t,s),((e,t,s)=>{const i=u(e,t.data_bg_multi),r=u(e,t.data_bg_multi_hidpi),o=h&&r?r:i;o&&(e.style.backgroundImage=o,Y(e,t,s))})(e,t,s)},K=(e,t,s)=>{(e=>R.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{G(e,t,s),V(e,t),U(e,t,s)})(e,t,s):X(e,t,s)},q=(e,t,s,i)=>{s.cancel_on_exit&&(e=>"loading"===m(e))(e)&&"IMG"===e.tagName&&(Q(e),(e=>{$(e,(e=>{O(e)})),O(e)})(e),(e=>{$(e,(e=>{P(e)})),P(e)})(e),N(e,s.class_loading),L(i,-1),v(e),x(s.callback_cancel,e,t,i))},J=(e,t,s,i)=>{const r=(e=>M.indexOf(m(e))>=0)(e);b(e,"entered"),E(e,s.class_entered),N(e,s.class_exited),((e,t,s)=>{t.unobserve_entered&&I(e,s)})(e,s,i),x(s.callback_enter,e,t,i),r||K(e,s,i)},ee=["IMG","IFRAME","VIDEO"],te=e=>e.use_native&&"loading"in HTMLImageElement.prototype,se=(e,t,s)=>{e.forEach((e=>{-1!==ee.indexOf(e.tagName)&&((e,t,s)=>{e.setAttribute("loading","lazy"),G(e,t,s),V(e,t),b(e,"native")})(e,t,s)})),C(s,0)},ie=(e,t,s)=>{e.forEach((e=>(e=>e.isIntersecting||e.intersectionRatio>0)(e)?J(e.target,e,t,s):((e,t,s,i)=>{y(e)||(E(e,s.class_exited),q(e,t,s,i),x(s.callback_exit,e,t,i))})(e.target,e,t,s)))},re=(e,t)=>{d&&!te(e)&&(t._observer=new IntersectionObserver((s=>{ie(s,e,t)}),(e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}))(e)))},oe=e=>Array.prototype.slice.call(e),ae=e=>e.container.querySelectorAll(e.elements_selector),ne=e=>(e=>"error"===m(e))(e),le=(e,t)=>(e=>oe(e).filter(y))(e||ae(t)),de=(e,t)=>{var s;(s=ae(e),oe(s).filter(ne)).forEach((t=>{N(t,e.class_error),v(t)})),t.update()},ce=function(e,t){const s=g(e);this._settings=s,this.loadingCount=0,re(s,this),((e,t)=>{n&&window.addEventListener("online",(()=>{de(e,t)}))})(s,this),this.update(t)};ce.prototype={update:function(e){const t=this._settings,s=le(e,t);var i,r;(C(this,s.length),!l&&d)?te(t)?se(s,t,this):(i=this._observer,r=s,(e=>{e.disconnect()})(i),((e,t)=>{t.forEach((t=>{e.observe(t)}))})(i,r)):this.loadAll(s)},destroy:function(){this._observer&&this._observer.disconnect(),ae(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;le(e,t).forEach((e=>{I(e,this),K(e,t,this)}))}},ce.load=(e,t)=>{const s=g(t);K(e,s)},ce.resetStatus=e=>{v(e)},n&&((e,t)=>{if(t)if(t.length)for(let s,i=0;s=t[i];i+=1)w(e,s);else w(e,t)})(ce,window.lazyLoadOptions);const he=(e,t,s,i)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const r=Object.getOwnPropertyDescriptor(e,s),o=Object.getOwnPropertyDescriptor(t,s);!pe(r,o)&&i||Object.defineProperty(e,s,o)},pe=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}`,we=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ue=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),me=(e,n,l)=>{const d=""===l?"":`with ${l.trim()}() `,c=ge.bind(null,d,n.toString());var h;Object.defineProperty(c,"name",ue),Object.defineProperty(e,"toString",(h=((e,t)=>{for(var s in t||(t={}))r.call(t,s)&&a(e,s,t[s]);if(i)for(var s of i(t))o.call(t,s)&&a(e,s,t[s]);return e})({},we),t(h,s({value:c}))))};var be=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=e;for(const r of Reflect.ownKeys(t))he(e,t,r,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 ve=(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:r=!1,after:o=!0}=t;if(!r&&!o)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,l;const d=function(...t){const d=this,c=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),o&&(l=e.apply(d,t))},h=r&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,n&&(clearTimeout(n),n=void 0),o&&(l=e.apply(d,t))}),s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(c,i)),h&&(l=e.apply(d,t)),l};return be(d,e),d.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},d};class ye{constructor(){this.disposers=new Map,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 r=this.genDisposerID();return this.disposers.set(r,(()=>{e.removeEventListener(t,s)})),r}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++}}var fe="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTQxOC4xNTggMjU3LjQxOUwxNzQuNjYzIDQxMy4zM2MtNi4wMTcgMy45MTktMTUuNzA4IDMuNzcyLTIxLjI5MS0uMjktMi43OTEtMi4wMTgtNC4yOTUtNC40ODMtNC4yOTUtNy4wODRWOTQuMTA5YzAtNS42NSA2Ljg4My0xMC4yODkgMTUuMjcxLTEwLjI4OSA0LjI5OCAwIDguMzkxIDEuMzA3IDExLjE4MSAzLjMzMmwyNDIuNjI5IDE1NS40ODRjNi4wMTYgMy45MTcgNi40NTEgMTAuMjkyLjY0OSAxNC40OTEtLjIxNi4xNTQtLjQzMi4xNTQtLjY0OS4yOTJ6TTE3MC42MjEgMzkxLjI4OGwyMjMuMTE2LTE0MS4zMDFMMTcwLjcxIDEwNy43NTNsLS4wODkgMjgzLjUzNXoiIC8+Cjwvc3ZnPgo=";class Me{constructor({readonly:e,box:t,pages:s,onNewPageIndex:i,onPlay:r}){if(this.pageIndex=0,this.isShowPreview=!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=r,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add((()=>{const e=new ce({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))}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,r)=>{var o;const a=String(r),n=document.createElement("a");n.className=t+" "+this.wrapClassName(`preview-page-${r}`),n.setAttribute("href","#"),n.dataset.pageIndex=a;const l=document.createElement("span");l.className=s,l.textContent=String(r+1),l.dataset.pageIndex=a;const d=document.createElement("img");d.width=i.width,d.height=i.height,d.dataset.src=null!=(o=i.thumbnail)?o:i.src,d.dataset.pageIndex=a,n.appendChild(d),n.appendChild(l),e.appendChild(n)})),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");e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly"));const t=this.renderFooterBtn("btn-sidebar","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+CiAgICA8cGF0aAogICAgICAgIGQ9Ik01MCA4SDE0Yy0zLjMwOSAwLTYgMi42OTEtNiA2djM2YzAgMy4zMDkgMi42OTEgNiA2IDZoMzZjMy4zMDkgMCA2LTIuNjkxIDYtNlYxNGMwLTMuMzA5LTIuNjkxLTYtNi02ek0xMiA1MFYxNGMwLTEuMTAzLjg5Ny0yIDItMmg4djQwaC04Yy0xLjEwMyAwLTItLjg5Ny0yLTJ6bTQwIDBjMCAxLjEwMy0uODk3IDItMiAySDI2VjEyaDI0YzEuMTAzIDAgMiAuODk3IDIgMnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(t,"click",(()=>{this.readonly||this.togglePreview()}));const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTE3Ny44MSAyNDkuOTU5TDMzNy40NzMgOTAuMjk1YzIuNzIyLTIuODY1IDIuNjUxLTcuMzc4LS4xNDMtMTAuMS0yLjc5My0yLjY1LTcuMTYzLTIuNjUtOS45NTYgMGwtMTY0Ljc1IDE2NC43NWMtMi43OTMgMi43OTMtMi43OTMgNy4zMDYgMCAxMC4xbDE2NC43NSAxNjQuNzVjMi44NjUgMi43MjIgNy4zNzggMi42NSAxMC4wOTktLjE0MyAyLjY1MS0yLjc5NCAyLjY1MS03LjE2MyAwLTkuOTU3TDE3Ny44MDkgMjQ5Ljk1OXoiIC8+Cjwvc3ZnPgo=");if(this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),s.appendChild(i),this.onPlay){const e=this.renderFooterBtn("btn-page-play",fe),t=this.debounce((()=>{const t=e.querySelector("img");t&&(t.src=fe)}),500);this.sideEffect.addEventListener(e,"click",(()=>{if(this.readonly)return;const s=e.querySelector("img");s&&(s.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTMxMi40OTEgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6TTE2NS4yNTcgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6IiAvPgo8L3N2Zz4K"),this.onPlay&&this.onPlay(),t()})),s.appendChild(e)}const r=this.renderFooterBtn("btn-page-next","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTMyMi4xOSAyNTAuMDQxTDE2Mi41MjcgNDA5LjcwNWMtMi43MjIgMi44NjUtMi42NTEgNy4zNzguMTQzIDEwLjEgMi43OTMgMi42NSA3LjE2MyAyLjY1IDkuOTU2IDBsMTY0Ljc1LTE2NC43NWMyLjc5My0yLjc5MyAyLjc5My03LjMwNiAwLTEwLjFsLTE2NC43NS0xNjQuNzVjLTIuODY1LTIuNzIyLTcuMzc4LTIuNjUtMTAuMDk5LjE0My0yLjY1MSAyLjc5NC0yLjY1MSA3LjE2MyAwIDkuOTU3bDE1OS42NjQgMTU5LjczNnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(r,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),s.appendChild(r);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"change",(()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)}));const n=document.createElement("span");n.textContent=" / "+this.pages.length,o.appendChild(a),o.appendChild(n),this.$footer.appendChild(t),this.$footer.appendChild(s),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t){const s=document.createElement("button");s.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e);const i=document.createElement("img");return i.src=t,s.appendChild(i),s}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=ve(e,{wait:t});return this.sideEffect.addDisposer((()=>s.cancel())),s}wrapClassName(e){return"netless-app-docs-viewer-"+e}}function xe(e,t,s){return Math.min(Math.max(e,t),s)}function Ee(e){return e.touches?e.touches[0]:e}function Ne(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class Te{constructor({whiteboardView:e,readonly:t,box:s,pages:i,pagesSize:r,pageScrollTop:o=0,onUserScroll:a}){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=o,this.pagesSize=r,this.onUserScroll=a,this.viewer=new Me({readonly:t,box:s,pages:i,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add((()=>{const e=new ce({container:this.$pages,elements_selector:`.${this.wrapClassName("page")}`});return()=>e.destroy()}),"page-lazyload"),this.setupWhiteboardCamera(),setTimeout((()=>{0!==this.pageScrollTop&&this.pageScrollTo(this.pageScrollTop)}),1e3),this.setupScrollTopEvent(),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.box.$titleBar&&(this.box.$titleBar.style.height="13%"),this.box.$footer&&(this.box.$footer.style.height="13%")}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 r=document.createElement("img");r.className=t+" "+this.wrapClassName(`page-${i}`),r.draggable=!1,r.width=s.width,r.height=s.height,r.dataset.src=s.src,r.dataset.pageIndex=String(i),e.appendChild(r)}))}return this.$pages}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.whiteboardView.divElement=this.$whiteboardView,this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{if(Ne(e),!this.readonly){const t=xe(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;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}=Ee(e),r=e=>{const{clientY:r}=Ee(e),{height:o}=this.whiteboardView.size;this.elScrollTo(xe(t+s/o*(r-i),0,s-this.scrollbarHeight*(s/o)))},o=()=>{this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!1),window.removeEventListener("mousemove",r,!0),window.removeEventListener("touchmove",r,!0),window.removeEventListener("mouseup",o,!0),window.removeEventListener("touchend",o,!0),window.removeEventListener("touchcancel",o,!0)};window.addEventListener("mousemove",r,!0),window.addEventListener("touchmove",r,!0),window.addEventListener("mouseup",o,!0),window.addEventListener("touchend",o,!0),window.addEventListener("touchcancel",o,!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=xe(e,0,this.pages.length-1);const t=this.$pages.querySelector("."+this.wrapClassName(`page-${e}`));if(t){const e=t.offsetTop;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:r}=this.whiteboardView.size,{width:o,height:a}=this.pagesSize;this.whiteboardView.moveCamera({centerY:this.scrollTopElToPage(t+r/2),animationMode:"immediately"}),this.setScrollbarHeight(r/(i/o*a)),this.$scrollbar.style.transform=`translateY(${s/a*r}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,r=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*r,width:i,height:t*r,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=ve(e,t);return this.sideEffect.addDisposer((()=>i.cancel()),s),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}setScrollbarHeight(e){e=xe(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 r=e=>{const{clientY:r}=e.touches[0];this.elScrollTo(xe(t+(i-r),0,s))},o=e=>{({clientY:i}=e.touches[0]),window.removeEventListener("touchmove",r,!0),window.removeEventListener("touchend",o,!0),window.removeEventListener("touchcancel",o,!0)};window.addEventListener("touchmove",r,!0),window.addEventListener("touchend",o,!0),window.addEventListener("touchcancel",o,!0)}}class Ie{constructor({displayer:e,whiteboardView:t,getRoom:s,readonly:i,box:r,pages:o}){this.onPlayPPT=()=>{const e=this.getWhiteboardRoom();e&&e.pptNextStep()},this.scaleDocsToFit=()=>{const e=this.pages[this.getPageIndex()];e&&this.whiteboardView.moveCameraToContain({originX:-e.width/2,originY:-e.height/2,width:e.width,height:e.height})},this.onNewPageIndex=e=>{this.jumpToPage(e)},this.sideEffect=new ye,this.whiteboardView=t,this.readonly=i,this.box=r,this.pages=o,this.displayer=e,this.getWhiteboardRoom=s,this.viewer=new Me({readonly:i,box:r,pages:o,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){if((e=xe(e,0,this.pages.length-1))!==this.getPageIndex()){const t=this.getWhiteboardRoom();t&&t.setSceneIndex(e)}e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e)}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView())}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.whiteboardView.divElement=this.$whiteboardView),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Le={kind:"DocsViewer",config:{minwidth:320,minheight:200},setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(i.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}.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;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>img{width:100%}.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}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;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-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}\n"),i[0].src.startsWith("ppt")?function(e,t,s){const i=e.getDisplayer(),r=e.getView();r.disableCameraTransform=!0;const o=new Ie({displayer:i,whiteboardView:r,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:t.readonly,box:t,pages:s}).mount();e.emitter.on("sceneStateChange",(e=>{o.jumpToPage(e.index)})),t.events.on("readonly",(e=>{o.setReadonly(e)}))}(e,t,i):function(e,t,s){var i;const r={width:s[0].width,height:s.reduce(((e,t)=>e+t.height*(s[0].width/t.width)),0)},o=e.getView();o.disableCameraTransform=!0;const a=new Te({whiteboardView:o,readonly:t.readonly,box:t,pages:s,pagesSize:r,pageScrollTop:null==(i=e.getAttributes())?void 0:i.pageScrollTop,onUserScroll:s=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===s||t.readonly||e.updateAttributes(["pageScrollTop"],s)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),t.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,t,i)}};module.exports=Le;
"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;const n="undefined"!=typeof window,l=n&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),d=n&&"IntersectionObserver"in window,c=n&&"classList"in document.createElement("p"),h=n&&window.devicePixelRatio>1,p={elements_selector:".lazy",container:l||n?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({},p,e),w=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)},u=(e,t)=>e.getAttribute("data-"+t),m=e=>u(e,"ll-status"),b=(e,t)=>((e,t,s)=>{var i="data-"+t;null!==s?e.setAttribute(i,s):e.removeAttribute(i)})(e,"ll-status",t),v=e=>b(e,null),y=e=>null===m(e),f=e=>"native"===m(e),M=["loading","loaded","applied","error"],x=(e,t,s,i)=>{e&&(void 0===i?void 0===s?e(t):e(t,s):e(t,s,i))},E=(e,t)=>{c?e.classList.add(t):e.className+=(e.className?" ":"")+t},T=(e,t)=>{c?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},N=e=>e.llTempImage,I=(e,t)=>{if(!t)return;const s=t._observer;s&&s.unobserve(e)},L=(e,t)=>{e&&(e.loadingCount+=t)},C=(e,t)=>{e&&(e.toLoadCount=t)},j=e=>{let t=[];for(let s,i=0;s=e.children[i];i+=1)"SOURCE"===s.tagName&&t.push(s);return t},A=(e,t,s)=>{s&&e.setAttribute(t,s)},S=(e,t)=>{e.removeAttribute(t)},z=e=>!!e.llOriginalAttrs,D=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},P=e=>{if(!z(e))return;const t=e.llOriginalAttrs;A(e,"src",t.src),A(e,"srcset",t.srcset),A(e,"sizes",t.sizes)},k=(e,t)=>{A(e,"sizes",u(e,t.data_sizes)),A(e,"srcset",u(e,t.data_srcset)),A(e,"src",u(e,t.data_src))},O=e=>{S(e,"src"),S(e,"srcset"),S(e,"sizes")},$=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;j(s).forEach(t)},_={IMG:(e,t)=>{$(e,(e=>{D(e),k(e,t)})),D(e),k(e,t)},IFRAME:(e,t)=>{A(e,"src",u(e,t.data_src))},VIDEO:(e,t)=>{((e,t)=>{j(e).forEach(t)})(e,(e=>{A(e,"src",u(e,t.data_src))})),A(e,"poster",u(e,t.data_poster)),A(e,"src",u(e,t.data_src)),e.load()}},V=(e,t)=>{const s=_[e.tagName];s&&s(e,t)},Y=(e,t,s)=>{E(e,t.class_applied),b(e,"applied"),t.unobserve_completed&&I(e,t),x(t.callback_applied,e,s)},U=(e,t,s)=>{L(s,1),E(e,t.class_loading),b(e,"loading"),x(t.callback_loading,e,s)},R=["IMG","IFRAME","VIDEO"],Z=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||x(e.callback_finish,t)},W=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},F=(e,t,s)=>{e.removeEventListener(t,s)},H=e=>!!e.llEvLisnrs,Q=e=>{if(!H(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];F(e,s,i)}delete e.llEvLisnrs},B=(e,t,s)=>{(e=>{delete e.llTempImage})(e),L(s,-1),(e=>{e&&(e.toLoadCount-=1)})(s),T(e,t.class_loading),t.unobserve_completed&&I(e,s)},G=(e,t,s)=>{const i=N(e)||e;if(H(i))return;((e,t,s)=>{H(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";W(e,i,t),W(e,"error",s)})(i,(o=>{((e,t,s,i)=>{const o=f(t);B(t,s,i),E(t,s.class_loaded),b(t,"loaded"),x(s.callback_loaded,t,i),o||Z(s,i)})(0,e,t,s),Q(i)}),(o=>{((e,t,s,i)=>{const o=f(t);B(t,s,i),E(t,s.class_error),b(t,"error"),x(s.callback_error,t,i),o||Z(s,i)})(0,e,t,s),Q(i)}))},X=(e,t,s)=>{(e=>{e.llTempImage=document.createElement("IMG")})(e),G(e,t,s),((e,t,s)=>{const i=u(e,t.data_bg),o=u(e,t.data_bg_hidpi),r=h&&o?o:i;r&&(e.style.backgroundImage=`url("${r}")`,N(e).setAttribute("src",r),U(e,t,s))})(e,t,s),((e,t,s)=>{const i=u(e,t.data_bg_multi),o=u(e,t.data_bg_multi_hidpi),r=h&&o?o:i;r&&(e.style.backgroundImage=r,Y(e,t,s))})(e,t,s)},K=(e,t,s)=>{(e=>R.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{G(e,t,s),V(e,t),U(e,t,s)})(e,t,s):X(e,t,s)},q=(e,t,s,i)=>{s.cancel_on_exit&&(e=>"loading"===m(e))(e)&&"IMG"===e.tagName&&(Q(e),(e=>{$(e,(e=>{O(e)})),O(e)})(e),(e=>{$(e,(e=>{P(e)})),P(e)})(e),T(e,s.class_loading),L(i,-1),v(e),x(s.callback_cancel,e,t,i))},J=(e,t,s,i)=>{const o=(e=>M.indexOf(m(e))>=0)(e);b(e,"entered"),E(e,s.class_entered),T(e,s.class_exited),((e,t,s)=>{t.unobserve_entered&&I(e,s)})(e,s,i),x(s.callback_enter,e,t,i),o||K(e,s,i)},ee=["IMG","IFRAME","VIDEO"],te=e=>e.use_native&&"loading"in HTMLImageElement.prototype,se=(e,t,s)=>{e.forEach((e=>{-1!==ee.indexOf(e.tagName)&&((e,t,s)=>{e.setAttribute("loading","lazy"),G(e,t,s),V(e,t),b(e,"native")})(e,t,s)})),C(s,0)},ie=(e,t,s)=>{e.forEach((e=>(e=>e.isIntersecting||e.intersectionRatio>0)(e)?J(e.target,e,t,s):((e,t,s,i)=>{y(e)||(E(e,s.class_exited),q(e,t,s,i),x(s.callback_exit,e,t,i))})(e.target,e,t,s)))},oe=(e,t)=>{d&&!te(e)&&(t._observer=new IntersectionObserver((s=>{ie(s,e,t)}),(e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}))(e)))},re=e=>Array.prototype.slice.call(e),ae=e=>e.container.querySelectorAll(e.elements_selector),ne=e=>(e=>"error"===m(e))(e),le=(e,t)=>(e=>re(e).filter(y))(e||ae(t)),de=(e,t)=>{var s;(s=ae(e),re(s).filter(ne)).forEach((t=>{T(t,e.class_error),v(t)})),t.update()},ce=function(e,t){const s=g(e);this._settings=s,this.loadingCount=0,oe(s,this),((e,t)=>{n&&window.addEventListener("online",(()=>{de(e,t)}))})(s,this),this.update(t)};ce.prototype={update:function(e){const t=this._settings,s=le(e,t);var i,o;(C(this,s.length),!l&&d)?te(t)?se(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(),ae(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;le(e,t).forEach((e=>{I(e,this),K(e,t,this)}))}},ce.load=(e,t)=>{const s=g(t);K(e,s)},ce.resetStatus=e=>{v(e)},n&&((e,t)=>{if(t)if(t.length)for(let s,i=0;s=t[i];i+=1)w(e,s);else w(e,t)})(ce,window.lazyLoadOptions);const he=(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);!pe(o,r)&&i||Object.defineProperty(e,s,r)},pe=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}`,we=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ue=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),me=(e,n,l)=>{const d=""===l?"":`with ${l.trim()}() `,c=ge.bind(null,d,n.toString());var h;Object.defineProperty(c,"name",ue),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})({},we),t(h,s({value:c}))))};var be=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=e;for(const o of Reflect.ownKeys(t))he(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 ve=(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 d=function(...t){const d=this,c=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),r&&(l=e.apply(d,t))},h=o&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,n&&(clearTimeout(n),n=void 0),r&&(l=e.apply(d,t))}),s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(c,i)),h&&(l=e.apply(d,t)),l};return be(d,e),d.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},d};class ye{constructor(){this.disposers=new Map,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++}}var fe="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTQxOC4xNTggMjU3LjQxOUwxNzQuNjYzIDQxMy4zM2MtNi4wMTcgMy45MTktMTUuNzA4IDMuNzcyLTIxLjI5MS0uMjktMi43OTEtMi4wMTgtNC4yOTUtNC40ODMtNC4yOTUtNy4wODRWOTQuMTA5YzAtNS42NSA2Ljg4My0xMC4yODkgMTUuMjcxLTEwLjI4OSA0LjI5OCAwIDguMzkxIDEuMzA3IDExLjE4MSAzLjMzMmwyNDIuNjI5IDE1NS40ODRjNi4wMTYgMy45MTcgNi40NTEgMTAuMjkyLjY0OSAxNC40OTEtLjIxNi4xNTQtLjQzMi4xNTQtLjY0OS4yOTJ6TTE3MC42MjEgMzkxLjI4OGwyMjMuMTE2LTE0MS4zMDFMMTcwLjcxIDEwNy43NTNsLS4wODkgMjgzLjUzNXoiIC8+Cjwvc3ZnPgo=";class Me{constructor({readonly:e,box:t,pages:s,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.isShowPreview=!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 ce({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))}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=String(o),n=document.createElement("a");n.className=t+" "+this.wrapClassName(`preview-page-${o}`),n.setAttribute("href","#"),n.dataset.pageIndex=a;const l=document.createElement("span");l.className=s,l.textContent=String(o+1),l.dataset.pageIndex=a;const d=document.createElement("img");d.width=i.width,d.height=i.height,d.dataset.src=null!=(r=i.thumbnail)?r:i.src,d.dataset.pageIndex=a,n.appendChild(d),n.appendChild(l),e.appendChild(n)})),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");e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly"));const t=this.renderFooterBtn("btn-sidebar","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+CiAgICA8cGF0aAogICAgICAgIGQ9Ik01MCA4SDE0Yy0zLjMwOSAwLTYgMi42OTEtNiA2djM2YzAgMy4zMDkgMi42OTEgNiA2IDZoMzZjMy4zMDkgMCA2LTIuNjkxIDYtNlYxNGMwLTMuMzA5LTIuNjkxLTYtNi02ek0xMiA1MFYxNGMwLTEuMTAzLjg5Ny0yIDItMmg4djQwaC04Yy0xLjEwMyAwLTItLjg5Ny0yLTJ6bTQwIDBjMCAxLjEwMy0uODk3IDItMiAySDI2VjEyaDI0YzEuMTAzIDAgMiAuODk3IDIgMnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(t,"click",(()=>{this.readonly||this.togglePreview()}));const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTE3Ny44MSAyNDkuOTU5TDMzNy40NzMgOTAuMjk1YzIuNzIyLTIuODY1IDIuNjUxLTcuMzc4LS4xNDMtMTAuMS0yLjc5My0yLjY1LTcuMTYzLTIuNjUtOS45NTYgMGwtMTY0Ljc1IDE2NC43NWMtMi43OTMgMi43OTMtMi43OTMgNy4zMDYgMCAxMC4xbDE2NC43NSAxNjQuNzVjMi44NjUgMi43MjIgNy4zNzggMi42NSAxMC4wOTktLjE0MyAyLjY1MS0yLjc5NCAyLjY1MS03LjE2MyAwLTkuOTU3TDE3Ny44MDkgMjQ5Ljk1OXoiIC8+Cjwvc3ZnPgo=");if(this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),s.appendChild(i),this.onPlay){const e=this.renderFooterBtn("btn-page-play",fe),t=this.debounce((()=>{const t=e.querySelector("img");t&&(t.src=fe)}),500);this.sideEffect.addEventListener(e,"click",(()=>{if(this.readonly)return;const s=e.querySelector("img");s&&(s.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTMxMi40OTEgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6TTE2NS4yNTcgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6IiAvPgo8L3N2Zz4K"),this.onPlay&&this.onPlay(),t()})),s.appendChild(e)}const o=this.renderFooterBtn("btn-page-next","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTMyMi4xOSAyNTAuMDQxTDE2Mi41MjcgNDA5LjcwNWMtMi43MjIgMi44NjUtMi42NTEgNy4zNzguMTQzIDEwLjEgMi43OTMgMi42NSA3LjE2MyAyLjY1IDkuOTU2IDBsMTY0Ljc1LTE2NC43NWMyLjc5My0yLjc5MyAyLjc5My03LjMwNiAwLTEwLjFsLTE2NC43NS0xNjQuNzVjLTIuODY1LTIuNzIyLTcuMzc4LTIuNjUtMTAuMDk5LjE0My0yLjY1MSAyLjc5NC0yLjY1MSA3LjE2MyAwIDkuOTU3bDE1OS42NjQgMTU5LjczNnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(o,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),s.appendChild(o);const r=document.createElement("div");r.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"change",(()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)}));const n=document.createElement("span");n.textContent=" / "+this.pages.length,r.appendChild(a),r.appendChild(n),this.$footer.appendChild(t),this.$footer.appendChild(s),this.$footer.appendChild(r)}return this.$footer}renderFooterBtn(e,t){const s=document.createElement("button");s.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e);const i=document.createElement("img");return i.src=t,s.appendChild(i),s}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=ve(e,{wait:t});return this.sideEffect.addDisposer((()=>s.cancel())),s}wrapClassName(e){return"netless-app-docs-viewer-"+e}}function xe(e,t,s){return Math.min(Math.max(e,t),s)}function Ee(e){return e.touches?e.touches[0]:e}function Te(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class Ne{constructor({whiteboardView:e,readonly:t,box:s,pages:i,pagesSize:o,pageScrollTop:r=0,onUserScroll:a}){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.onUserScroll=a,this.viewer=new Me({readonly:t,box:s,pages:i,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add((()=>{const e=new ce({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}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.box.$titleBar&&(this.box.$titleBar.style.height="13%"),this.box.$footer&&(this.box.$footer.style.height="13%")}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.whiteboardView.divElement=this.$whiteboardView,this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{if(Te(e),!this.readonly){const t=xe(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(Te(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;Te(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}=Ee(e),o=e=>{const{clientY:o}=Ee(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=xe(e,0,this.pages.length-1);const t=this.$pages.querySelector("."+this.wrapClassName(`page-${e}`));if(t){const e=t.offsetTop;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=ve(e,t);return this.sideEffect.addDisposer((()=>i.cancel()),s),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}setScrollbarHeight(e){e=xe(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(xe(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 Ie{constructor({displayer:e,whiteboardView:t,getRoom:s,readonly:i,box:o,pages:r}){this.onPlayPPT=()=>{const e=this.getWhiteboardRoom();e&&e.pptNextStep()},this.scaleDocsToFit=()=>{const e=this.pages[this.getPageIndex()];e&&this.whiteboardView.moveCameraToContain({originX:-e.width/2,originY:-e.height/2,width:e.width,height:e.height})},this.onNewPageIndex=e=>{this.jumpToPage(e)},this.sideEffect=new ye,this.whiteboardView=t,this.readonly=i,this.box=o,this.pages=r,this.displayer=e,this.getWhiteboardRoom=s,this.viewer=new Me({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){if((e=xe(e,0,this.pages.length-1))!==this.getPageIndex()){const t=this.getWhiteboardRoom();t&&t.setSceneIndex(e)}e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e)}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView())}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.whiteboardView.divElement=this.$whiteboardView),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Le={kind:"DocsViewer",config:{minwidth:320,minheight:200},setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(i.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}.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;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>img{width:100%}.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}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;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-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}\n"),i[0].src.startsWith("ppt")?function(e,t,s){const i=e.getDisplayer(),o=e.getView();o.disableCameraTransform=!0;const r=new Ie({displayer:i,whiteboardView:o,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:t.readonly,box:t,pages:s}).mount();e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),t.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,t,i):function(e,t,s){var i;const o={width:s[0].width,height:s.reduce(((e,t)=>e+t.height*(s[0].width/t.width)),0)},r=e.getView();r.disableCameraTransform=!0;const a=new Ne({whiteboardView:r,readonly:t.readonly,box:t,pages:s,pagesSize:o,pageScrollTop:null==(i=e.getAttributes())?void 0:i.pageScrollTop,onUserScroll:s=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===s||t.readonly||e.updateAttributes(["pageScrollTop"],s)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),t.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,t,i)}};module.exports=Le;
//# sourceMappingURL=main.cjs.js.map

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

var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,a=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;const n="undefined"!=typeof window,l=n&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),d=n&&"IntersectionObserver"in window,c=n&&"classList"in document.createElement("p"),h=n&&window.devicePixelRatio>1,p={elements_selector:".lazy",container:l||n?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({},p,e),w=function(e,t){var s;let i="LazyLoad::Initialized",r=new e(t);try{s=new CustomEvent(i,{detail:{instance:r}})}catch(o){(s=document.createEvent("CustomEvent")).initCustomEvent(i,!1,!1,{instance:r})}window.dispatchEvent(s)},u=(e,t)=>e.getAttribute("data-"+t),m=e=>u(e,"ll-status"),b=(e,t)=>((e,t,s)=>{var i="data-"+t;null!==s?e.setAttribute(i,s):e.removeAttribute(i)})(e,"ll-status",t),v=e=>b(e,null),y=e=>null===m(e),f=e=>"native"===m(e),M=["loading","loaded","applied","error"],x=(e,t,s,i)=>{e&&(void 0===i?void 0===s?e(t):e(t,s):e(t,s,i))},E=(e,t)=>{c?e.classList.add(t):e.className+=(e.className?" ":"")+t},N=(e,t)=>{c?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},T=e=>e.llTempImage,I=(e,t)=>{if(!t)return;const s=t._observer;s&&s.unobserve(e)},L=(e,t)=>{e&&(e.loadingCount+=t)},C=(e,t)=>{e&&(e.toLoadCount=t)},j=e=>{let t=[];for(let s,i=0;s=e.children[i];i+=1)"SOURCE"===s.tagName&&t.push(s);return t},A=(e,t,s)=>{s&&e.setAttribute(t,s)},S=(e,t)=>{e.removeAttribute(t)},z=e=>!!e.llOriginalAttrs,D=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},P=e=>{if(!z(e))return;const t=e.llOriginalAttrs;A(e,"src",t.src),A(e,"srcset",t.srcset),A(e,"sizes",t.sizes)},k=(e,t)=>{A(e,"sizes",u(e,t.data_sizes)),A(e,"srcset",u(e,t.data_srcset)),A(e,"src",u(e,t.data_src))},O=e=>{S(e,"src"),S(e,"srcset"),S(e,"sizes")},$=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;j(s).forEach(t)},_={IMG:(e,t)=>{$(e,(e=>{D(e),k(e,t)})),D(e),k(e,t)},IFRAME:(e,t)=>{A(e,"src",u(e,t.data_src))},VIDEO:(e,t)=>{((e,t)=>{j(e).forEach(t)})(e,(e=>{A(e,"src",u(e,t.data_src))})),A(e,"poster",u(e,t.data_poster)),A(e,"src",u(e,t.data_src)),e.load()}},V=(e,t)=>{const s=_[e.tagName];s&&s(e,t)},Y=(e,t,s)=>{E(e,t.class_applied),b(e,"applied"),t.unobserve_completed&&I(e,t),x(t.callback_applied,e,s)},U=(e,t,s)=>{L(s,1),E(e,t.class_loading),b(e,"loading"),x(t.callback_loading,e,s)},R=["IMG","IFRAME","VIDEO"],Z=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||x(e.callback_finish,t)},W=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},F=(e,t,s)=>{e.removeEventListener(t,s)},H=e=>!!e.llEvLisnrs,Q=e=>{if(!H(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];F(e,s,i)}delete e.llEvLisnrs},B=(e,t,s)=>{(e=>{delete e.llTempImage})(e),L(s,-1),(e=>{e&&(e.toLoadCount-=1)})(s),N(e,t.class_loading),t.unobserve_completed&&I(e,s)},G=(e,t,s)=>{const i=T(e)||e;if(H(i))return;((e,t,s)=>{H(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";W(e,i,t),W(e,"error",s)})(i,(r=>{((e,t,s,i)=>{const r=f(t);B(t,s,i),E(t,s.class_loaded),b(t,"loaded"),x(s.callback_loaded,t,i),r||Z(s,i)})(0,e,t,s),Q(i)}),(r=>{((e,t,s,i)=>{const r=f(t);B(t,s,i),E(t,s.class_error),b(t,"error"),x(s.callback_error,t,i),r||Z(s,i)})(0,e,t,s),Q(i)}))},X=(e,t,s)=>{(e=>{e.llTempImage=document.createElement("IMG")})(e),G(e,t,s),((e,t,s)=>{const i=u(e,t.data_bg),r=u(e,t.data_bg_hidpi),o=h&&r?r:i;o&&(e.style.backgroundImage=`url("${o}")`,T(e).setAttribute("src",o),U(e,t,s))})(e,t,s),((e,t,s)=>{const i=u(e,t.data_bg_multi),r=u(e,t.data_bg_multi_hidpi),o=h&&r?r:i;o&&(e.style.backgroundImage=o,Y(e,t,s))})(e,t,s)},K=(e,t,s)=>{(e=>R.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{G(e,t,s),V(e,t),U(e,t,s)})(e,t,s):X(e,t,s)},q=(e,t,s,i)=>{s.cancel_on_exit&&(e=>"loading"===m(e))(e)&&"IMG"===e.tagName&&(Q(e),(e=>{$(e,(e=>{O(e)})),O(e)})(e),(e=>{$(e,(e=>{P(e)})),P(e)})(e),N(e,s.class_loading),L(i,-1),v(e),x(s.callback_cancel,e,t,i))},J=(e,t,s,i)=>{const r=(e=>M.indexOf(m(e))>=0)(e);b(e,"entered"),E(e,s.class_entered),N(e,s.class_exited),((e,t,s)=>{t.unobserve_entered&&I(e,s)})(e,s,i),x(s.callback_enter,e,t,i),r||K(e,s,i)},ee=["IMG","IFRAME","VIDEO"],te=e=>e.use_native&&"loading"in HTMLImageElement.prototype,se=(e,t,s)=>{e.forEach((e=>{-1!==ee.indexOf(e.tagName)&&((e,t,s)=>{e.setAttribute("loading","lazy"),G(e,t,s),V(e,t),b(e,"native")})(e,t,s)})),C(s,0)},ie=(e,t,s)=>{e.forEach((e=>(e=>e.isIntersecting||e.intersectionRatio>0)(e)?J(e.target,e,t,s):((e,t,s,i)=>{y(e)||(E(e,s.class_exited),q(e,t,s,i),x(s.callback_exit,e,t,i))})(e.target,e,t,s)))},re=(e,t)=>{d&&!te(e)&&(t._observer=new IntersectionObserver((s=>{ie(s,e,t)}),(e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}))(e)))},oe=e=>Array.prototype.slice.call(e),ae=e=>e.container.querySelectorAll(e.elements_selector),ne=e=>(e=>"error"===m(e))(e),le=(e,t)=>(e=>oe(e).filter(y))(e||ae(t)),de=(e,t)=>{var s;(s=ae(e),oe(s).filter(ne)).forEach((t=>{N(t,e.class_error),v(t)})),t.update()},ce=function(e,t){const s=g(e);this._settings=s,this.loadingCount=0,re(s,this),((e,t)=>{n&&window.addEventListener("online",(()=>{de(e,t)}))})(s,this),this.update(t)};ce.prototype={update:function(e){const t=this._settings,s=le(e,t);var i,r;(C(this,s.length),!l&&d)?te(t)?se(s,t,this):(i=this._observer,r=s,(e=>{e.disconnect()})(i),((e,t)=>{t.forEach((t=>{e.observe(t)}))})(i,r)):this.loadAll(s)},destroy:function(){this._observer&&this._observer.disconnect(),ae(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;le(e,t).forEach((e=>{I(e,this),K(e,t,this)}))}},ce.load=(e,t)=>{const s=g(t);K(e,s)},ce.resetStatus=e=>{v(e)},n&&((e,t)=>{if(t)if(t.length)for(let s,i=0;s=t[i];i+=1)w(e,s);else w(e,t)})(ce,window.lazyLoadOptions);const he=(e,t,s,i)=>{if("length"===s||"prototype"===s)return;if("arguments"===s||"caller"===s)return;const r=Object.getOwnPropertyDescriptor(e,s),o=Object.getOwnPropertyDescriptor(t,s);!pe(r,o)&&i||Object.defineProperty(e,s,o)},pe=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}`,we=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ue=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),me=(e,n,l)=>{const d=""===l?"":`with ${l.trim()}() `,c=ge.bind(null,d,n.toString());var h;Object.defineProperty(c,"name",ue),Object.defineProperty(e,"toString",(h=((e,t)=>{for(var s in t||(t={}))r.call(t,s)&&a(e,s,t[s]);if(i)for(var s of i(t))o.call(t,s)&&a(e,s,t[s]);return e})({},we),t(h,s({value:c}))))};var be=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=e;for(const r of Reflect.ownKeys(t))he(e,t,r,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 ve=(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:r=!1,after:o=!0}=t;if(!r&&!o)throw new Error("Both `before` and `after` are false, function wouldn't be called.");let a,n,l;const d=function(...t){const d=this,c=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),o&&(l=e.apply(d,t))},h=r&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,n&&(clearTimeout(n),n=void 0),o&&(l=e.apply(d,t))}),s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(c,i)),h&&(l=e.apply(d,t)),l};return be(d,e),d.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},d};class ye{constructor(){this.disposers=new Map,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 r=this.genDisposerID();return this.disposers.set(r,(()=>{e.removeEventListener(t,s)})),r}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++}}var fe="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTQxOC4xNTggMjU3LjQxOUwxNzQuNjYzIDQxMy4zM2MtNi4wMTcgMy45MTktMTUuNzA4IDMuNzcyLTIxLjI5MS0uMjktMi43OTEtMi4wMTgtNC4yOTUtNC40ODMtNC4yOTUtNy4wODRWOTQuMTA5YzAtNS42NSA2Ljg4My0xMC4yODkgMTUuMjcxLTEwLjI4OSA0LjI5OCAwIDguMzkxIDEuMzA3IDExLjE4MSAzLjMzMmwyNDIuNjI5IDE1NS40ODRjNi4wMTYgMy45MTcgNi40NTEgMTAuMjkyLjY0OSAxNC40OTEtLjIxNi4xNTQtLjQzMi4xNTQtLjY0OS4yOTJ6TTE3MC42MjEgMzkxLjI4OGwyMjMuMTE2LTE0MS4zMDFMMTcwLjcxIDEwNy43NTNsLS4wODkgMjgzLjUzNXoiIC8+Cjwvc3ZnPgo=";class Me{constructor({readonly:e,box:t,pages:s,onNewPageIndex:i,onPlay:r}){if(this.pageIndex=0,this.isShowPreview=!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=r,this.render()}mount(){this.box.mountContent(this.$content),this.box.mountFooter(this.$footer),this.sideEffect.add((()=>{const e=new ce({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))}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,r)=>{var o;const a=String(r),n=document.createElement("a");n.className=t+" "+this.wrapClassName(`preview-page-${r}`),n.setAttribute("href","#"),n.dataset.pageIndex=a;const l=document.createElement("span");l.className=s,l.textContent=String(r+1),l.dataset.pageIndex=a;const d=document.createElement("img");d.width=i.width,d.height=i.height,d.dataset.src=null!=(o=i.thumbnail)?o:i.src,d.dataset.pageIndex=a,n.appendChild(d),n.appendChild(l),e.appendChild(n)})),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");e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly"));const t=this.renderFooterBtn("btn-sidebar","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+CiAgICA8cGF0aAogICAgICAgIGQ9Ik01MCA4SDE0Yy0zLjMwOSAwLTYgMi42OTEtNiA2djM2YzAgMy4zMDkgMi42OTEgNiA2IDZoMzZjMy4zMDkgMCA2LTIuNjkxIDYtNlYxNGMwLTMuMzA5LTIuNjkxLTYtNi02ek0xMiA1MFYxNGMwLTEuMTAzLjg5Ny0yIDItMmg4djQwaC04Yy0xLjEwMyAwLTItLjg5Ny0yLTJ6bTQwIDBjMCAxLjEwMy0uODk3IDItMiAySDI2VjEyaDI0YzEuMTAzIDAgMiAuODk3IDIgMnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(t,"click",(()=>{this.readonly||this.togglePreview()}));const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTE3Ny44MSAyNDkuOTU5TDMzNy40NzMgOTAuMjk1YzIuNzIyLTIuODY1IDIuNjUxLTcuMzc4LS4xNDMtMTAuMS0yLjc5My0yLjY1LTcuMTYzLTIuNjUtOS45NTYgMGwtMTY0Ljc1IDE2NC43NWMtMi43OTMgMi43OTMtMi43OTMgNy4zMDYgMCAxMC4xbDE2NC43NSAxNjQuNzVjMi44NjUgMi43MjIgNy4zNzggMi42NSAxMC4wOTktLjE0MyAyLjY1MS0yLjc5NCAyLjY1MS03LjE2MyAwLTkuOTU3TDE3Ny44MDkgMjQ5Ljk1OXoiIC8+Cjwvc3ZnPgo=");if(this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),s.appendChild(i),this.onPlay){const e=this.renderFooterBtn("btn-page-play",fe),t=this.debounce((()=>{const t=e.querySelector("img");t&&(t.src=fe)}),500);this.sideEffect.addEventListener(e,"click",(()=>{if(this.readonly)return;const s=e.querySelector("img");s&&(s.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTMxMi40OTEgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6TTE2NS4yNTcgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6IiAvPgo8L3N2Zz4K"),this.onPlay&&this.onPlay(),t()})),s.appendChild(e)}const r=this.renderFooterBtn("btn-page-next","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTMyMi4xOSAyNTAuMDQxTDE2Mi41MjcgNDA5LjcwNWMtMi43MjIgMi44NjUtMi42NTEgNy4zNzguMTQzIDEwLjEgMi43OTMgMi42NSA3LjE2MyAyLjY1IDkuOTU2IDBsMTY0Ljc1LTE2NC43NWMyLjc5My0yLjc5MyAyLjc5My03LjMwNiAwLTEwLjFsLTE2NC43NS0xNjQuNzVjLTIuODY1LTIuNzIyLTcuMzc4LTIuNjUtMTAuMDk5LjE0My0yLjY1MSAyLjc5NC0yLjY1MSA3LjE2MyAwIDkuOTU3bDE1OS42NjQgMTU5LjczNnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(r,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),s.appendChild(r);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"change",(()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)}));const n=document.createElement("span");n.textContent=" / "+this.pages.length,o.appendChild(a),o.appendChild(n),this.$footer.appendChild(t),this.$footer.appendChild(s),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t){const s=document.createElement("button");s.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e);const i=document.createElement("img");return i.src=t,s.appendChild(i),s}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=ve(e,{wait:t});return this.sideEffect.addDisposer((()=>s.cancel())),s}wrapClassName(e){return"netless-app-docs-viewer-"+e}}function xe(e,t,s){return Math.min(Math.max(e,t),s)}function Ee(e){return e.touches?e.touches[0]:e}function Ne(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class Te{constructor({whiteboardView:e,readonly:t,box:s,pages:i,pagesSize:r,pageScrollTop:o=0,onUserScroll:a}){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=o,this.pagesSize=r,this.onUserScroll=a,this.viewer=new Me({readonly:t,box:s,pages:i,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add((()=>{const e=new ce({container:this.$pages,elements_selector:`.${this.wrapClassName("page")}`});return()=>e.destroy()}),"page-lazyload"),this.setupWhiteboardCamera(),setTimeout((()=>{0!==this.pageScrollTop&&this.pageScrollTo(this.pageScrollTop)}),1e3),this.setupScrollTopEvent(),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.box.$titleBar&&(this.box.$titleBar.style.height="13%"),this.box.$footer&&(this.box.$footer.style.height="13%")}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 r=document.createElement("img");r.className=t+" "+this.wrapClassName(`page-${i}`),r.draggable=!1,r.width=s.width,r.height=s.height,r.dataset.src=s.src,r.dataset.pageIndex=String(i),e.appendChild(r)}))}return this.$pages}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.whiteboardView.divElement=this.$whiteboardView,this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{if(Ne(e),!this.readonly){const t=xe(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;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}=Ee(e),r=e=>{const{clientY:r}=Ee(e),{height:o}=this.whiteboardView.size;this.elScrollTo(xe(t+s/o*(r-i),0,s-this.scrollbarHeight*(s/o)))},o=()=>{this.$scrollbar.classList.toggle(this.wrapClassName("scrollbar-dragging"),!1),window.removeEventListener("mousemove",r,!0),window.removeEventListener("touchmove",r,!0),window.removeEventListener("mouseup",o,!0),window.removeEventListener("touchend",o,!0),window.removeEventListener("touchcancel",o,!0)};window.addEventListener("mousemove",r,!0),window.addEventListener("touchmove",r,!0),window.addEventListener("mouseup",o,!0),window.addEventListener("touchend",o,!0),window.addEventListener("touchcancel",o,!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=xe(e,0,this.pages.length-1);const t=this.$pages.querySelector("."+this.wrapClassName(`page-${e}`));if(t){const e=t.offsetTop;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:r}=this.whiteboardView.size,{width:o,height:a}=this.pagesSize;this.whiteboardView.moveCamera({centerY:this.scrollTopElToPage(t+r/2),animationMode:"immediately"}),this.setScrollbarHeight(r/(i/o*a)),this.$scrollbar.style.transform=`translateY(${s/a*r}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,r=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*r,width:i,height:t*r,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=ve(e,t);return this.sideEffect.addDisposer((()=>i.cancel()),s),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}setScrollbarHeight(e){e=xe(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 r=e=>{const{clientY:r}=e.touches[0];this.elScrollTo(xe(t+(i-r),0,s))},o=e=>{({clientY:i}=e.touches[0]),window.removeEventListener("touchmove",r,!0),window.removeEventListener("touchend",o,!0),window.removeEventListener("touchcancel",o,!0)};window.addEventListener("touchmove",r,!0),window.addEventListener("touchend",o,!0),window.addEventListener("touchcancel",o,!0)}}class Ie{constructor({displayer:e,whiteboardView:t,getRoom:s,readonly:i,box:r,pages:o}){this.onPlayPPT=()=>{const e=this.getWhiteboardRoom();e&&e.pptNextStep()},this.scaleDocsToFit=()=>{const e=this.pages[this.getPageIndex()];e&&this.whiteboardView.moveCameraToContain({originX:-e.width/2,originY:-e.height/2,width:e.width,height:e.height})},this.onNewPageIndex=e=>{this.jumpToPage(e)},this.sideEffect=new ye,this.whiteboardView=t,this.readonly=i,this.box=r,this.pages=o,this.displayer=e,this.getWhiteboardRoom=s,this.viewer=new Me({readonly:i,box:r,pages:o,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){if((e=xe(e,0,this.pages.length-1))!==this.getPageIndex()){const t=this.getWhiteboardRoom();t&&t.setSceneIndex(e)}e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e)}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView())}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.whiteboardView.divElement=this.$whiteboardView),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Le={kind:"DocsViewer",config:{minwidth:320,minheight:200},setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(i.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}.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;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>img{width:100%}.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}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;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-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}\n"),i[0].src.startsWith("ppt")?function(e,t,s){const i=e.getDisplayer(),r=e.getView();r.disableCameraTransform=!0;const o=new Ie({displayer:i,whiteboardView:r,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:t.readonly,box:t,pages:s}).mount();e.emitter.on("sceneStateChange",(e=>{o.jumpToPage(e.index)})),t.events.on("readonly",(e=>{o.setReadonly(e)}))}(e,t,i):function(e,t,s){var i;const r={width:s[0].width,height:s.reduce(((e,t)=>e+t.height*(s[0].width/t.width)),0)},o=e.getView();o.disableCameraTransform=!0;const a=new Te({whiteboardView:o,readonly:t.readonly,box:t,pages:s,pagesSize:r,pageScrollTop:null==(i=e.getAttributes())?void 0:i.pageScrollTop,onUserScroll:s=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===s||t.readonly||e.updateAttributes(["pageScrollTop"],s)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),t.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,t,i)}};export{Le 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;const n="undefined"!=typeof window,l=n&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),d=n&&"IntersectionObserver"in window,c=n&&"classList"in document.createElement("p"),h=n&&window.devicePixelRatio>1,p={elements_selector:".lazy",container:l||n?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({},p,e),w=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)},u=(e,t)=>e.getAttribute("data-"+t),m=e=>u(e,"ll-status"),b=(e,t)=>((e,t,s)=>{var i="data-"+t;null!==s?e.setAttribute(i,s):e.removeAttribute(i)})(e,"ll-status",t),v=e=>b(e,null),y=e=>null===m(e),f=e=>"native"===m(e),M=["loading","loaded","applied","error"],x=(e,t,s,i)=>{e&&(void 0===i?void 0===s?e(t):e(t,s):e(t,s,i))},E=(e,t)=>{c?e.classList.add(t):e.className+=(e.className?" ":"")+t},T=(e,t)=>{c?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},N=e=>e.llTempImage,I=(e,t)=>{if(!t)return;const s=t._observer;s&&s.unobserve(e)},L=(e,t)=>{e&&(e.loadingCount+=t)},C=(e,t)=>{e&&(e.toLoadCount=t)},j=e=>{let t=[];for(let s,i=0;s=e.children[i];i+=1)"SOURCE"===s.tagName&&t.push(s);return t},A=(e,t,s)=>{s&&e.setAttribute(t,s)},S=(e,t)=>{e.removeAttribute(t)},z=e=>!!e.llOriginalAttrs,D=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},P=e=>{if(!z(e))return;const t=e.llOriginalAttrs;A(e,"src",t.src),A(e,"srcset",t.srcset),A(e,"sizes",t.sizes)},k=(e,t)=>{A(e,"sizes",u(e,t.data_sizes)),A(e,"srcset",u(e,t.data_srcset)),A(e,"src",u(e,t.data_src))},O=e=>{S(e,"src"),S(e,"srcset"),S(e,"sizes")},$=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;j(s).forEach(t)},_={IMG:(e,t)=>{$(e,(e=>{D(e),k(e,t)})),D(e),k(e,t)},IFRAME:(e,t)=>{A(e,"src",u(e,t.data_src))},VIDEO:(e,t)=>{((e,t)=>{j(e).forEach(t)})(e,(e=>{A(e,"src",u(e,t.data_src))})),A(e,"poster",u(e,t.data_poster)),A(e,"src",u(e,t.data_src)),e.load()}},V=(e,t)=>{const s=_[e.tagName];s&&s(e,t)},Y=(e,t,s)=>{E(e,t.class_applied),b(e,"applied"),t.unobserve_completed&&I(e,t),x(t.callback_applied,e,s)},U=(e,t,s)=>{L(s,1),E(e,t.class_loading),b(e,"loading"),x(t.callback_loading,e,s)},R=["IMG","IFRAME","VIDEO"],Z=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||x(e.callback_finish,t)},W=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},F=(e,t,s)=>{e.removeEventListener(t,s)},H=e=>!!e.llEvLisnrs,Q=e=>{if(!H(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];F(e,s,i)}delete e.llEvLisnrs},B=(e,t,s)=>{(e=>{delete e.llTempImage})(e),L(s,-1),(e=>{e&&(e.toLoadCount-=1)})(s),T(e,t.class_loading),t.unobserve_completed&&I(e,s)},G=(e,t,s)=>{const i=N(e)||e;if(H(i))return;((e,t,s)=>{H(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";W(e,i,t),W(e,"error",s)})(i,(o=>{((e,t,s,i)=>{const o=f(t);B(t,s,i),E(t,s.class_loaded),b(t,"loaded"),x(s.callback_loaded,t,i),o||Z(s,i)})(0,e,t,s),Q(i)}),(o=>{((e,t,s,i)=>{const o=f(t);B(t,s,i),E(t,s.class_error),b(t,"error"),x(s.callback_error,t,i),o||Z(s,i)})(0,e,t,s),Q(i)}))},X=(e,t,s)=>{(e=>{e.llTempImage=document.createElement("IMG")})(e),G(e,t,s),((e,t,s)=>{const i=u(e,t.data_bg),o=u(e,t.data_bg_hidpi),r=h&&o?o:i;r&&(e.style.backgroundImage=`url("${r}")`,N(e).setAttribute("src",r),U(e,t,s))})(e,t,s),((e,t,s)=>{const i=u(e,t.data_bg_multi),o=u(e,t.data_bg_multi_hidpi),r=h&&o?o:i;r&&(e.style.backgroundImage=r,Y(e,t,s))})(e,t,s)},K=(e,t,s)=>{(e=>R.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{G(e,t,s),V(e,t),U(e,t,s)})(e,t,s):X(e,t,s)},q=(e,t,s,i)=>{s.cancel_on_exit&&(e=>"loading"===m(e))(e)&&"IMG"===e.tagName&&(Q(e),(e=>{$(e,(e=>{O(e)})),O(e)})(e),(e=>{$(e,(e=>{P(e)})),P(e)})(e),T(e,s.class_loading),L(i,-1),v(e),x(s.callback_cancel,e,t,i))},J=(e,t,s,i)=>{const o=(e=>M.indexOf(m(e))>=0)(e);b(e,"entered"),E(e,s.class_entered),T(e,s.class_exited),((e,t,s)=>{t.unobserve_entered&&I(e,s)})(e,s,i),x(s.callback_enter,e,t,i),o||K(e,s,i)},ee=["IMG","IFRAME","VIDEO"],te=e=>e.use_native&&"loading"in HTMLImageElement.prototype,se=(e,t,s)=>{e.forEach((e=>{-1!==ee.indexOf(e.tagName)&&((e,t,s)=>{e.setAttribute("loading","lazy"),G(e,t,s),V(e,t),b(e,"native")})(e,t,s)})),C(s,0)},ie=(e,t,s)=>{e.forEach((e=>(e=>e.isIntersecting||e.intersectionRatio>0)(e)?J(e.target,e,t,s):((e,t,s,i)=>{y(e)||(E(e,s.class_exited),q(e,t,s,i),x(s.callback_exit,e,t,i))})(e.target,e,t,s)))},oe=(e,t)=>{d&&!te(e)&&(t._observer=new IntersectionObserver((s=>{ie(s,e,t)}),(e=>({root:e.container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}))(e)))},re=e=>Array.prototype.slice.call(e),ae=e=>e.container.querySelectorAll(e.elements_selector),ne=e=>(e=>"error"===m(e))(e),le=(e,t)=>(e=>re(e).filter(y))(e||ae(t)),de=(e,t)=>{var s;(s=ae(e),re(s).filter(ne)).forEach((t=>{T(t,e.class_error),v(t)})),t.update()},ce=function(e,t){const s=g(e);this._settings=s,this.loadingCount=0,oe(s,this),((e,t)=>{n&&window.addEventListener("online",(()=>{de(e,t)}))})(s,this),this.update(t)};ce.prototype={update:function(e){const t=this._settings,s=le(e,t);var i,o;(C(this,s.length),!l&&d)?te(t)?se(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(),ae(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;le(e,t).forEach((e=>{I(e,this),K(e,t,this)}))}},ce.load=(e,t)=>{const s=g(t);K(e,s)},ce.resetStatus=e=>{v(e)},n&&((e,t)=>{if(t)if(t.length)for(let s,i=0;s=t[i];i+=1)w(e,s);else w(e,t)})(ce,window.lazyLoadOptions);const he=(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);!pe(o,r)&&i||Object.defineProperty(e,s,r)},pe=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}`,we=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ue=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),me=(e,n,l)=>{const d=""===l?"":`with ${l.trim()}() `,c=ge.bind(null,d,n.toString());var h;Object.defineProperty(c,"name",ue),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})({},we),t(h,s({value:c}))))};var be=(e,t,{ignoreNonConfigurable:s=!1}={})=>{const{name:i}=e;for(const o of Reflect.ownKeys(t))he(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 ve=(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 d=function(...t){const d=this,c=()=>{n=void 0,a&&(clearTimeout(a),a=void 0),r&&(l=e.apply(d,t))},h=o&&!a;return clearTimeout(a),a=setTimeout((()=>{a=void 0,n&&(clearTimeout(n),n=void 0),r&&(l=e.apply(d,t))}),s),i>0&&i!==Number.Infinity&&!n&&(n=setTimeout(c,i)),h&&(l=e.apply(d,t)),l};return be(d,e),d.cancel=()=>{a&&(clearTimeout(a),a=void 0),n&&(clearTimeout(n),n=void 0)},d};class ye{constructor(){this.disposers=new Map,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++}}var fe="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTQxOC4xNTggMjU3LjQxOUwxNzQuNjYzIDQxMy4zM2MtNi4wMTcgMy45MTktMTUuNzA4IDMuNzcyLTIxLjI5MS0uMjktMi43OTEtMi4wMTgtNC4yOTUtNC40ODMtNC4yOTUtNy4wODRWOTQuMTA5YzAtNS42NSA2Ljg4My0xMC4yODkgMTUuMjcxLTEwLjI4OSA0LjI5OCAwIDguMzkxIDEuMzA3IDExLjE4MSAzLjMzMmwyNDIuNjI5IDE1NS40ODRjNi4wMTYgMy45MTcgNi40NTEgMTAuMjkyLjY0OSAxNC40OTEtLjIxNi4xNTQtLjQzMi4xNTQtLjY0OS4yOTJ6TTE3MC42MjEgMzkxLjI4OGwyMjMuMTE2LTE0MS4zMDFMMTcwLjcxIDEwNy43NTNsLS4wODkgMjgzLjUzNXoiIC8+Cjwvc3ZnPgo=";class Me{constructor({readonly:e,box:t,pages:s,onNewPageIndex:i,onPlay:o}){if(this.pageIndex=0,this.isShowPreview=!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 ce({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))}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=String(o),n=document.createElement("a");n.className=t+" "+this.wrapClassName(`preview-page-${o}`),n.setAttribute("href","#"),n.dataset.pageIndex=a;const l=document.createElement("span");l.className=s,l.textContent=String(o+1),l.dataset.pageIndex=a;const d=document.createElement("img");d.width=i.width,d.height=i.height,d.dataset.src=null!=(r=i.thumbnail)?r:i.src,d.dataset.pageIndex=a,n.appendChild(d),n.appendChild(l),e.appendChild(n)})),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");e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly"));const t=this.renderFooterBtn("btn-sidebar","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+CiAgICA8cGF0aAogICAgICAgIGQ9Ik01MCA4SDE0Yy0zLjMwOSAwLTYgMi42OTEtNiA2djM2YzAgMy4zMDkgMi42OTEgNiA2IDZoMzZjMy4zMDkgMCA2LTIuNjkxIDYtNlYxNGMwLTMuMzA5LTIuNjkxLTYtNi02ek0xMiA1MFYxNGMwLTEuMTAzLjg5Ny0yIDItMmg4djQwaC04Yy0xLjEwMyAwLTItLjg5Ny0yLTJ6bTQwIDBjMCAxLjEwMy0uODk3IDItMiAySDI2VjEyaDI0YzEuMTAzIDAgMiAuODk3IDIgMnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(t,"click",(()=>{this.readonly||this.togglePreview()}));const s=document.createElement("div");s.className=this.wrapClassName("page-jumps");const i=this.renderFooterBtn("btn-page-back","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTE3Ny44MSAyNDkuOTU5TDMzNy40NzMgOTAuMjk1YzIuNzIyLTIuODY1IDIuNjUxLTcuMzc4LS4xNDMtMTAuMS0yLjc5My0yLjY1LTcuMTYzLTIuNjUtOS45NTYgMGwtMTY0Ljc1IDE2NC43NWMtMi43OTMgMi43OTMtMi43OTMgNy4zMDYgMCAxMC4xbDE2NC43NSAxNjQuNzVjMi44NjUgMi43MjIgNy4zNzggMi42NSAxMC4wOTktLjE0MyAyLjY1MS0yLjc5NCAyLjY1MS03LjE2MyAwLTkuOTU3TDE3Ny44MDkgMjQ5Ljk1OXoiIC8+Cjwvc3ZnPgo=");if(this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),s.appendChild(i),this.onPlay){const e=this.renderFooterBtn("btn-page-play",fe),t=this.debounce((()=>{const t=e.querySelector("img");t&&(t.src=fe)}),500);this.sideEffect.addEventListener(e,"click",(()=>{if(this.readonly)return;const s=e.querySelector("img");s&&(s.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTMxMi40OTEgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6TTE2NS4yNTcgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6IiAvPgo8L3N2Zz4K"),this.onPlay&&this.onPlay(),t()})),s.appendChild(e)}const o=this.renderFooterBtn("btn-page-next","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTMyMi4xOSAyNTAuMDQxTDE2Mi41MjcgNDA5LjcwNWMtMi43MjIgMi44NjUtMi42NTEgNy4zNzguMTQzIDEwLjEgMi43OTMgMi42NSA3LjE2MyAyLjY1IDkuOTU2IDBsMTY0Ljc1LTE2NC43NWMyLjc5My0yLjc5MyAyLjc5My03LjMwNiAwLTEwLjFsLTE2NC43NS0xNjQuNzVjLTIuODY1LTIuNzIyLTcuMzc4LTIuNjUtMTAuMDk5LjE0My0yLjY1MSAyLjc5NC0yLjY1MSA3LjE2MyAwIDkuOTU3bDE1OS42NjQgMTU5LjczNnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(o,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),s.appendChild(o);const r=document.createElement("div");r.className=this.wrapClassName("page-number");const a=document.createElement("input");a.className=this.wrapClassName("page-number-input"),a.value=String(this.pageIndex+1),this.readonly&&(a.disabled=!0),this.$pageNumberInput=a,this.sideEffect.addEventListener(a,"change",(()=>{this.readonly||a.value&&this.onNewPageIndex(Number(a.value)-1)}));const n=document.createElement("span");n.textContent=" / "+this.pages.length,r.appendChild(a),r.appendChild(n),this.$footer.appendChild(t),this.$footer.appendChild(s),this.$footer.appendChild(r)}return this.$footer}renderFooterBtn(e,t){const s=document.createElement("button");s.className=this.wrapClassName("footer-btn")+" "+this.wrapClassName(e);const i=document.createElement("img");return i.src=t,s.appendChild(i),s}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=ve(e,{wait:t});return this.sideEffect.addDisposer((()=>s.cancel())),s}wrapClassName(e){return"netless-app-docs-viewer-"+e}}function xe(e,t,s){return Math.min(Math.max(e,t),s)}function Ee(e){return e.touches?e.touches[0]:e}function Te(e){e.stopPropagation(),e.cancelable&&e.preventDefault()}class Ne{constructor({whiteboardView:e,readonly:t,box:s,pages:i,pagesSize:o,pageScrollTop:r=0,onUserScroll:a}){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.onUserScroll=a,this.viewer=new Me({readonly:t,box:s,pages:i,onNewPageIndex:this.onNewPageIndex}),this.render()}mount(){return this.viewer.mount(),this.sideEffect.add((()=>{const e=new ce({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}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.box.$titleBar&&(this.box.$titleBar.style.height="13%"),this.box.$footer&&(this.box.$footer.style.height="13%")}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.whiteboardView.divElement=this.$whiteboardView,this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{if(Te(e),!this.readonly){const t=xe(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(Te(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;Te(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}=Ee(e),o=e=>{const{clientY:o}=Ee(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=xe(e,0,this.pages.length-1);const t=this.$pages.querySelector("."+this.wrapClassName(`page-${e}`));if(t){const e=t.offsetTop;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=ve(e,t);return this.sideEffect.addDisposer((()=>i.cancel()),s),i}wrapClassName(e){return"netless-app-docs-viewer-static-"+e}setScrollbarHeight(e){e=xe(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(xe(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 Ie{constructor({displayer:e,whiteboardView:t,getRoom:s,readonly:i,box:o,pages:r}){this.onPlayPPT=()=>{const e=this.getWhiteboardRoom();e&&e.pptNextStep()},this.scaleDocsToFit=()=>{const e=this.pages[this.getPageIndex()];e&&this.whiteboardView.moveCameraToContain({originX:-e.width/2,originY:-e.height/2,width:e.width,height:e.height})},this.onNewPageIndex=e=>{this.jumpToPage(e)},this.sideEffect=new ye,this.whiteboardView=t,this.readonly=i,this.box=o,this.pages=r,this.displayer=e,this.getWhiteboardRoom=s,this.viewer=new Me({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){if((e=xe(e,0,this.pages.length-1))!==this.getPageIndex()){const t=this.getWhiteboardRoom();t&&t.setSceneIndex(e)}e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e)}render(){this.viewer.$content.appendChild(this.renderMask()),this.viewer.$content.appendChild(this.renderWhiteboardView())}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.whiteboardView.divElement=this.$whiteboardView),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Le={kind:"DocsViewer",config:{minwidth:320,minheight:200},setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(i.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}.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;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>img{width:100%}.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}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;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-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}\n"),i[0].src.startsWith("ppt")?function(e,t,s){const i=e.getDisplayer(),o=e.getView();o.disableCameraTransform=!0;const r=new Ie({displayer:i,whiteboardView:o,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:t.readonly,box:t,pages:s}).mount();e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),t.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,t,i):function(e,t,s){var i;const o={width:s[0].width,height:s.reduce(((e,t)=>e+t.height*(s[0].width/t.width)),0)},r=e.getView();r.disableCameraTransform=!0;const a=new Ne({whiteboardView:r,readonly:t.readonly,box:t,pages:s,pagesSize:o,pageScrollTop:null==(i=e.getAttributes())?void 0:i.pageScrollTop,onUserScroll:s=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===s||t.readonly||e.updateAttributes(["pageScrollTop"],s)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),t.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,t,i)}};export{Le as default};
//# sourceMappingURL=main.es.js.map

@@ -6,2 +6,3 @@ export declare type SideEffectDisposer = () => void;

addEventListener<K extends keyof HTMLElementEventMap>(el: HTMLElement, type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): string;
setTimeout(handler: () => void, timeout: number, disposerID?: string): void;
/**

@@ -8,0 +9,0 @@ * remove but not run the disposer

{
"name": "@netless/app-docs-viewer",
"version": "0.1.7",
"version": "0.1.8",
"private": false,

@@ -5,0 +5,0 @@ "description": "Netless App Docs Viewer",

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

setTimeout(() => {
this.sideEffect.setTimeout(() => {
if (this.pageScrollTop !== 0) {

@@ -209,2 +209,10 @@ this.pageScrollTo(this.pageScrollTop);

if (
(ev as MouseEvent).button != null &&
(ev as MouseEvent).button !== 0
) {
// Not left mouse
return;
}
preventEvent(ev);

@@ -227,11 +235,4 @@

this.elScrollTo(
clamp(
startTop +
(clientY - startY) *
(elScrollHeight / wbHeight),
0,
elScrollHeight -
this.scrollbarHeight *
(elScrollHeight / wbHeight)
)
startTop +
(clientY - startY) * (elScrollHeight / wbHeight)
);

@@ -345,2 +346,3 @@ };

const { width: pageWidth, height: pageHeight } = this.pagesSize;
const elScrollHeight = (wbWidth / pageWidth) * pageHeight;

@@ -352,7 +354,6 @@ this.whiteboardView.moveCamera({

this.setScrollbarHeight(
wbHeight / ((wbWidth / pageWidth) * pageHeight)
);
this.setScrollbarHeight((wbHeight / elScrollHeight) * wbHeight);
this.$scrollbar.style.transform = `translateY(${
(pageScrollTop / pageHeight) * wbHeight
(elScrollTop / (elScrollHeight - wbHeight)) *
(wbHeight - this.scrollbarHeight)
}px)`;

@@ -359,0 +360,0 @@

@@ -37,2 +37,17 @@ export type SideEffectDisposer = () => void;

public setTimeout(
handler: () => void,
timeout: number,
disposerID: string = this.genDisposerID()
): void {
const timeoutHandler = (): void => {
handler();
this.remove(disposerID);
};
const ticket = window.setTimeout(timeoutHandler, timeout);
this.disposers.set(disposerID, () => {
window.clearTimeout(ticket);
});
}
/**

@@ -39,0 +54,0 @@ * remove but not run the disposer

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