@netless/app-docs-viewer
Advanced tools
Comparing version 0.1.11 to 0.1.12
@@ -34,2 +34,3 @@ import { ReadonlyTeleBox } from "@netless/window-manager"; | ||
setPageIndex(pageIndex: number): void; | ||
setSmallBox(isSmallBox: boolean): void; | ||
render(): HTMLElement; | ||
@@ -45,3 +46,4 @@ protected renderContent(): HTMLElement; | ||
protected isShowPreview: boolean; | ||
protected isSmallBox: boolean; | ||
protected sideEffect: SideEffectManager; | ||
} |
@@ -39,2 +39,3 @@ import type { ReadonlyTeleBox, View, Displayer, Room } from "@netless/window-manager"; | ||
protected sideEffect: SideEffectManager; | ||
protected shouldResetPPT: boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
"use strict";var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;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},k=e=>{if(!z(e))return;const t=e.llOriginalAttrs;A(e,"src",t.src),A(e,"srcset",t.srcset),A(e,"sizes",t.sizes)},P=(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))},$=e=>{S(e,"src"),S(e,"srcset"),S(e,"sizes")},O=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;j(s).forEach(t)},_={IMG:(e,t)=>{O(e,(e=>{D(e),P(e,t)})),D(e),P(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)},W=["IMG","IFRAME","VIDEO"],R=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||x(e.callback_finish,t)},Z=(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";Z(e,i,t),Z(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||R(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||R(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=>W.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=>{O(e,(e=>{$(e)})),$(e)})(e),(e=>{O(e,(e=>{k(e)})),k(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=null!=(r=i.thumbnail)?r:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),l=document.createElement("a");l.className=t+" "+this.wrapClassName(`preview-page-${o}`),l.setAttribute("href","#"),l.dataset.pageIndex=n;const d=document.createElement("span");d.className=s,d.textContent=String(o+1),d.dataset.pageIndex=n;const c=document.createElement("img");c.width=i.width,c.height=i.height,c.dataset.src=a,c.dataset.pageIndex=n,l.appendChild(c),l.appendChild(d),e.appendChild(l)})),this.sideEffect.addEventListener(e,"click",(e=>{var t;if(this.readonly)return;const s=null==(t=e.target.dataset)?void 0:t.pageIndex;s&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.onNewPageIndex(Number(s)),this.togglePreview(!1))}))}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",(e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)}))),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.pages.some((e=>e.thumbnail||!e.src.startsWith("ppt")))){const e=this.renderFooterBtn("btn-sidebar","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+CiAgICA8cGF0aAogICAgICAgIGQ9Ik01MCA4SDE0Yy0zLjMwOSAwLTYgMi42OTEtNiA2djM2YzAgMy4zMDkgMi42OTEgNiA2IDZoMzZjMy4zMDkgMCA2LTIuNjkxIDYtNlYxNGMwLTMuMzA5LTIuNjkxLTYtNi02ek0xMiA1MFYxNGMwLTEuMTAzLjg5Ny0yIDItMmg4djQwaC04Yy0xLjEwMyAwLTItLjg5Ny0yLTJ6bTQwIDBjMCAxLjEwMy0uODk3IDItMiAySDI2VjEyaDI0YzEuMTAzIDAgMiAuODk3IDIgMnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||this.togglePreview()})),this.$footer.appendChild(e)}const t=document.createElement("div");t.className=this.wrapClassName("page-jumps");const s=this.renderFooterBtn("btn-page-back","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTE3Ny44MSAyNDkuOTU5TDMzNy40NzMgOTAuMjk1YzIuNzIyLTIuODY1IDIuNjUxLTcuMzc4LS4xNDMtMTAuMS0yLjc5My0yLjY1LTcuMTYzLTIuNjUtOS45NTYgMGwtMTY0Ljc1IDE2NC43NWMtMi43OTMgMi43OTMtMi43OTMgNy4zMDYgMCAxMC4xbDE2NC43NSAxNjQuNzVjMi44NjUgMi43MjIgNy4zNzggMi42NSAxMC4wOTktLjE0MyAyLjY1MS0yLjc5NCAyLjY1MS03LjE2MyAwLTkuOTU3TDE3Ny44MDkgMjQ5Ljk1OXoiIC8+Cjwvc3ZnPgo=");if(this.sideEffect.addEventListener(s,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),t.appendChild(s),this.onPlay){const e=this.renderFooterBtn("btn-page-play",fe),s=this.debounce((()=>{const t=e.querySelector("img");t&&(t.src=fe)}),500);this.sideEffect.addEventListener(e,"click",(()=>{if(this.readonly)return;const t=e.querySelector("img");t&&(t.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTMxMi40OTEgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6TTE2NS4yNTcgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6IiAvPgo8L3N2Zz4K"),this.onPlay&&this.onPlay(),s()})),t.appendChild(e)}const i=this.renderFooterBtn("btn-page-next","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTMyMi4xOSAyNTAuMDQxTDE2Mi41MjcgNDA5LjcwNWMtMi43MjIgMi44NjUtMi42NTEgNy4zNzguMTQzIDEwLjEgMi43OTMgMi42NSA3LjE2MyAyLjY1IDkuOTU2IDBsMTY0Ljc1LTE2NC43NWMyLjc5My0yLjc5MyAyLjc5My03LjMwNiAwLTEwLjFsLTE2NC43NS0xNjQuNzVjLTIuODY1LTIuNzIyLTcuMzc4LTIuNjUtMTAuMDk5LjE0My0yLjY1MSAyLjc5NC0yLjY1MSA3LjE2MyAwIDkuOTU3bDE1OS42NjQgMTU5LjczNnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),t.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const r=document.createElement("input");r.className=this.wrapClassName("page-number-input"),r.value=String(this.pageIndex+1),this.readonly&&(r.disabled=!0),this.$pageNumberInput=r,this.sideEffect.addEventListener(r,"change",(()=>{this.readonly||r.value&&this.onNewPageIndex(Number(r.value)-1)}));const a=document.createElement("span");a.textContent=" / "+this.pages.length,o.appendChild(r),o.appendChild(a),this.$footer.appendChild(t),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t){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,mountWhiteboard:a,onUserScroll:n}){this.onNewPageIndex=e=>{this.scrollToPage(e)},this.sideEffect=new ye,this.scrollbarHeight=30,this.whiteboardView=e,this.readonly=t,this.box=s,this.pages=i,this.pageScrollTop=r,this.pagesSize=o,this.mountWhiteboard=a,this.onUserScroll=n,this.viewer=new 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.mountWhiteboard(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+5;this.elScrollTo(e),this.onUserScroll&&this.onUserScroll(this.scrollTopElToPage(e))}}}setupScrollTopEvent(){const e=this.debounce((()=>{if(this.pages.length>0&&this.$pages){if(this.$pages.getBoundingClientRect().width>0){let e=0;for(let t=0;t<this.pages.length;t+=1)if(e+=this.pages[t].height,this.pageScrollTop<=e)return void this.viewer.setPageIndex(t);this.viewer.setPageIndex(this.pages.length-1)}}}),{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.addEventListener(this.$pages,"scroll",(()=>{const t=this.$pages.scrollTop,s=this.scrollTopElToPage(t);this.pageScrollTop=s;const{width:i,height:o}=this.whiteboardView.size,{width:r,height:a}=this.pagesSize,n=i/r*a;this.whiteboardView.moveCamera({centerY:this.scrollTopElToPage(t+o/2),animationMode:"immediately"}),this.setScrollbarHeight(o/n*o),this.$scrollbar.style.transform=`translateY(${t/(n-o)*(o-this.scrollbarHeight)}px)`,e()}))}setupWhiteboardCamera(){this.sideEffect.add((()=>{const e=({width:e,height:t})=>{if(e>0&&t>0){const s=this.$pages.scrollTop,i=this.pagesSize.width,o=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*o,width:i,height:t*o,animationMode:"immediately"}),this.elScrollTo(s)}};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}}),"whiteboard-size-update")}debounce(e,t,s){const i=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,mountWhiteboard:a}){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.mountWhiteboard=a,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),this.scaleDocsToFit())}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.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Le={kind:"DocsViewer",setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=e.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");i.disableCameraTransform=!0;const o=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(o.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(".netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7}.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;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;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"),o[0].src.startsWith("ppt")?function(e,t,s,i){const o=e.getDisplayer(),r=new Ie({displayer:o,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),s.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,i,t,o):function(e,t,s,i){var o;const r={width:i[0].width,height:i.reduce(((e,t)=>e+t.height*(i[0].width/t.width)),0)},a=new Ne({whiteboardView:t,readonly:s.readonly,box:s,pages:i,pagesSize:r,pageScrollTop:null==(o=e.getAttributes())?void 0:o.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:t=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===t||s.readonly||e.updateAttributes(["pageScrollTop"],t)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),s.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,i,t,o)}};module.exports=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),f=e=>null===m(e),y=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))},$=e=>{S(e,"src"),S(e,"srcset"),S(e,"sizes")},O=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;j(s).forEach(t)},_={IMG:(e,t)=>{O(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)},R=(e,t,s)=>{L(s,1),E(e,t.class_loading),b(e,"loading"),x(t.callback_loading,e,s)},U=["IMG","IFRAME","VIDEO"],W=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||x(e.callback_finish,t)},Z=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},H=(e,t,s)=>{e.removeEventListener(t,s)},B=e=>!!e.llEvLisnrs,F=e=>{if(!B(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];H(e,s,i)}delete e.llEvLisnrs},Q=(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(B(i))return;((e,t,s)=>{B(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";Z(e,i,t),Z(e,"error",s)})(i,(o=>{((e,t,s,i)=>{const o=y(t);Q(t,s,i),E(t,s.class_loaded),b(t,"loaded"),x(s.callback_loaded,t,i),o||W(s,i)})(0,e,t,s),F(i)}),(o=>{((e,t,s,i)=>{const o=y(t);Q(t,s,i),E(t,s.class_error),b(t,"error"),x(s.callback_error,t,i),o||W(s,i)})(0,e,t,s),F(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),R(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=>U.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{G(e,t,s),V(e,t),R(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&&(F(e),(e=>{O(e,(e=>{$(e)})),$(e)})(e),(e=>{O(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)=>{f(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(f))(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 fe{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 ye="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.isSmallBox=!1,this.sideEffect=new fe,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))}setSmallBox(e){this.isSmallBox!==e&&this.$footer.classList.toggle(this.wrapClassName("float-footer"),e)}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const t=this.wrapClassName("preview-page"),s=this.wrapClassName("preview-page-name");this.pages.forEach(((i,o)=>{var r;const a=null!=(r=i.thumbnail)?r:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),l=document.createElement("a");l.className=t+" "+this.wrapClassName(`preview-page-${o}`),l.setAttribute("href","#"),l.dataset.pageIndex=n;const d=document.createElement("span");d.className=s,d.textContent=String(o+1),d.dataset.pageIndex=n;const c=document.createElement("img");c.width=i.width,c.height=i.height,c.dataset.src=a,c.dataset.pageIndex=n,l.appendChild(c),l.appendChild(d),e.appendChild(l)})),this.sideEffect.addEventListener(e,"click",(e=>{var t;if(this.readonly)return;const s=null==(t=e.target.dataset)?void 0:t.pageIndex;s&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.onNewPageIndex(Number(s)),this.togglePreview(!1))}))}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",(e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)}))),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some((e=>e.thumbnail||!e.src.startsWith("ppt")))){const e=this.renderFooterBtn("btn-sidebar","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+CiAgICA8cGF0aAogICAgICAgIGQ9Ik01MCA4SDE0Yy0zLjMwOSAwLTYgMi42OTEtNiA2djM2YzAgMy4zMDkgMi42OTEgNiA2IDZoMzZjMy4zMDkgMCA2LTIuNjkxIDYtNlYxNGMwLTMuMzA5LTIuNjkxLTYtNi02ek0xMiA1MFYxNGMwLTEuMTAzLjg5Ny0yIDItMmg4djQwaC04Yy0xLjEwMyAwLTItLjg5Ny0yLTJ6bTQwIDBjMCAxLjEwMy0uODk3IDItMiAySDI2VjEyaDI0YzEuMTAzIDAgMiAuODk3IDIgMnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||this.togglePreview()})),this.$footer.appendChild(e)}const t=document.createElement("div");t.className=this.wrapClassName("page-jumps");const s=this.renderFooterBtn("btn-page-back","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTE3Ny44MSAyNDkuOTU5TDMzNy40NzMgOTAuMjk1YzIuNzIyLTIuODY1IDIuNjUxLTcuMzc4LS4xNDMtMTAuMS0yLjc5My0yLjY1LTcuMTYzLTIuNjUtOS45NTYgMGwtMTY0Ljc1IDE2NC43NWMtMi43OTMgMi43OTMtMi43OTMgNy4zMDYgMCAxMC4xbDE2NC43NSAxNjQuNzVjMi44NjUgMi43MjIgNy4zNzggMi42NSAxMC4wOTktLjE0MyAyLjY1MS0yLjc5NCAyLjY1MS03LjE2MyAwLTkuOTU3TDE3Ny44MDkgMjQ5Ljk1OXoiIC8+Cjwvc3ZnPgo=");if(this.sideEffect.addEventListener(s,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),t.appendChild(s),this.onPlay){const e=this.renderFooterBtn("btn-page-play",ye),s=this.debounce((()=>{const t=e.querySelector("img");t&&(t.src=ye)}),500);this.sideEffect.addEventListener(e,"click",(()=>{if(this.readonly)return;const t=e.querySelector("img");t&&(t.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTMxMi40OTEgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6TTE2NS4yNTcgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6IiAvPgo8L3N2Zz4K"),this.onPlay&&this.onPlay(),s()})),t.appendChild(e)}const i=this.renderFooterBtn("btn-page-next","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTMyMi4xOSAyNTAuMDQxTDE2Mi41MjcgNDA5LjcwNWMtMi43MjIgMi44NjUtMi42NTEgNy4zNzguMTQzIDEwLjEgMi43OTMgMi42NSA3LjE2MyAyLjY1IDkuOTU2IDBsMTY0Ljc1LTE2NC43NWMyLjc5My0yLjc5MyAyLjc5My03LjMwNiAwLTEwLjFsLTE2NC43NS0xNjQuNzVjLTIuODY1LTIuNzIyLTcuMzc4LTIuNjUtMTAuMDk5LjE0My0yLjY1MSAyLjc5NC0yLjY1MSA3LjE2MyAwIDkuOTU3bDE1OS42NjQgMTU5LjczNnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),t.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const r=document.createElement("input");r.className=this.wrapClassName("page-number-input"),r.value=String(this.pageIndex+1),this.readonly&&(r.disabled=!0),this.$pageNumberInput=r,this.sideEffect.addEventListener(r,"change",(()=>{this.readonly||r.value&&this.onNewPageIndex(Number(r.value)-1)}));const a=document.createElement("span");a.textContent=" / "+this.pages.length,o.appendChild(r),o.appendChild(a),this.$footer.appendChild(t),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t){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,mountWhiteboard:a,onUserScroll:n}){this.onNewPageIndex=e=>{this.scrollToPage(e)},this.sideEffect=new fe,this.scrollbarHeight=30,this.whiteboardView=e,this.readonly=t,this.box=s,this.pages=i,this.pageScrollTop=r,this.pagesSize=o,this.mountWhiteboard=a,this.onUserScroll=n,this.viewer=new 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.whiteboardView.callbacks.on("onSizeUpdated",(()=>{this.renderRatioHeight()})),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.onUserScroll=void 0,this.unmount(),this.viewer.destroy()}syncPageScrollTop(e){e>=0&&Math.abs(this.pageScrollTop-e)>10&&this.pageScrollTo(e)}render(){this.viewer.$content.appendChild(this.renderPages()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.viewer.$content.appendChild(this.renderScrollbar()),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,t=e<=640;if(this.viewer.setSmallBox(t),t){const t=26/640,s=26/e,i=26/640,o=0,r=Math.max((t+i-(s+o))/2,0);if(this.box.$titleBar){const e=s+r;this.box.$titleBar.style.height=100*e+"%"}if(this.box.$footer){const e=o+r;this.box.$footer.style.height=100*e+"%"}}else{if(this.box.$titleBar){const t=Math.max(26/640,26/e);this.box.$titleBar.style.height=100*t+"%"}if(this.box.$footer){const t=Math.max(26/640,26/e);this.box.$footer.style.height=100*t+"%"}}}renderPages(){if(!this.$pages){const e=document.createElement("div");e.className=this.wrapClassName("pages"),this.$pages=e;const t=this.wrapClassName("page");this.pages.forEach(((s,i)=>{const o=document.createElement("img");o.className=t+" "+this.wrapClassName(`page-${i}`),o.draggable=!1,o.width=s.width,o.height=s.height,o.dataset.src=s.src,o.dataset.pageIndex=String(i),e.appendChild(o)}))}return this.$pages}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{if(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+5;this.elScrollTo(e),this.onUserScroll&&this.onUserScroll(this.scrollTopElToPage(e))}}}setupScrollTopEvent(){const e=this.debounce((()=>{if(this.pages.length>0&&this.$pages){if(this.$pages.getBoundingClientRect().width>0){let e=0;for(let t=0;t<this.pages.length;t+=1)if(e+=this.pages[t].height,this.pageScrollTop<=e)return void this.viewer.setPageIndex(t);this.viewer.setPageIndex(this.pages.length-1)}}}),{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.addEventListener(this.$pages,"scroll",(()=>{const t=this.$pages.scrollTop,s=this.scrollTopElToPage(t);this.pageScrollTop=s;const{width:i,height:o}=this.whiteboardView.size,{width:r,height:a}=this.pagesSize,n=i/r*a;this.whiteboardView.moveCamera({centerY:this.scrollTopElToPage(t+o/2),animationMode:"immediately"}),this.setScrollbarHeight(o/n*o),this.$scrollbar.style.transform=`translateY(${t/(n-o)*(o-this.scrollbarHeight)}px)`,e()}))}setupWhiteboardCamera(){this.sideEffect.add((()=>{const e=({width:e,height:t})=>{if(e>0&&t>0){const s=this.$pages.scrollTop,i=this.pagesSize.width,o=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*o,width:i,height:t*o,animationMode:"immediately"}),this.elScrollTo(s)}};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}}),"whiteboard-size-update")}debounce(e,t,s){const i=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,mountWhiteboard:a}){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.shouldResetPPT=!0,this.jumpToPage(e)},this.sideEffect=new fe,this.shouldResetPPT=!1,this.whiteboardView=t,this.readonly=i,this.box=o,this.pages=r,this.displayer=e,this.getWhiteboardRoom=s,this.mountWhiteboard=a,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),this.scaleDocsToFit())}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),this.shouldResetPPT){const e=this.getWhiteboardRoom();e&&e.setGlobalState({__pptState:void 0}),this.shouldResetPPT=!1}}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.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Le={kind:"DocsViewer",setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=e.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");i.disableCameraTransform=!0;const o=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(o.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(".netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);opacity:0;transition:opacity .4s}.netless-app-docs-viewer-float-footer:hover{opacity:1}.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;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;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"),o[0].src.startsWith("ppt")?function(e,t,s,i){const o=e.getDisplayer(),r=new Ie({displayer:o,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),s.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,i,t,o):function(e,t,s,i){var o;const r={width:i[0].width,height:i.reduce(((e,t)=>e+t.height*(i[0].width/t.width)),0)},a=new Ne({whiteboardView:t,readonly:s.readonly,box:s,pages:i,pagesSize:r,pageScrollTop:null==(o=e.getAttributes())?void 0:o.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:t=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===t||s.readonly||e.updateAttributes(["pageScrollTop"],t)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),s.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,i,t,o)}};module.exports=Le; | ||
//# sourceMappingURL=main.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
var e=Object.defineProperty,t=Object.defineProperties,s=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,s,i)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;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},k=e=>{if(!z(e))return;const t=e.llOriginalAttrs;A(e,"src",t.src),A(e,"srcset",t.srcset),A(e,"sizes",t.sizes)},P=(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))},$=e=>{S(e,"src"),S(e,"srcset"),S(e,"sizes")},O=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;j(s).forEach(t)},_={IMG:(e,t)=>{O(e,(e=>{D(e),P(e,t)})),D(e),P(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)},W=["IMG","IFRAME","VIDEO"],R=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||x(e.callback_finish,t)},Z=(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";Z(e,i,t),Z(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||R(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||R(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=>W.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=>{O(e,(e=>{$(e)})),$(e)})(e),(e=>{O(e,(e=>{k(e)})),k(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=null!=(r=i.thumbnail)?r:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),l=document.createElement("a");l.className=t+" "+this.wrapClassName(`preview-page-${o}`),l.setAttribute("href","#"),l.dataset.pageIndex=n;const d=document.createElement("span");d.className=s,d.textContent=String(o+1),d.dataset.pageIndex=n;const c=document.createElement("img");c.width=i.width,c.height=i.height,c.dataset.src=a,c.dataset.pageIndex=n,l.appendChild(c),l.appendChild(d),e.appendChild(l)})),this.sideEffect.addEventListener(e,"click",(e=>{var t;if(this.readonly)return;const s=null==(t=e.target.dataset)?void 0:t.pageIndex;s&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.onNewPageIndex(Number(s)),this.togglePreview(!1))}))}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",(e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)}))),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.pages.some((e=>e.thumbnail||!e.src.startsWith("ppt")))){const e=this.renderFooterBtn("btn-sidebar","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+CiAgICA8cGF0aAogICAgICAgIGQ9Ik01MCA4SDE0Yy0zLjMwOSAwLTYgMi42OTEtNiA2djM2YzAgMy4zMDkgMi42OTEgNiA2IDZoMzZjMy4zMDkgMCA2LTIuNjkxIDYtNlYxNGMwLTMuMzA5LTIuNjkxLTYtNi02ek0xMiA1MFYxNGMwLTEuMTAzLjg5Ny0yIDItMmg4djQwaC04Yy0xLjEwMyAwLTItLjg5Ny0yLTJ6bTQwIDBjMCAxLjEwMy0uODk3IDItMiAySDI2VjEyaDI0YzEuMTAzIDAgMiAuODk3IDIgMnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||this.togglePreview()})),this.$footer.appendChild(e)}const t=document.createElement("div");t.className=this.wrapClassName("page-jumps");const s=this.renderFooterBtn("btn-page-back","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTE3Ny44MSAyNDkuOTU5TDMzNy40NzMgOTAuMjk1YzIuNzIyLTIuODY1IDIuNjUxLTcuMzc4LS4xNDMtMTAuMS0yLjc5My0yLjY1LTcuMTYzLTIuNjUtOS45NTYgMGwtMTY0Ljc1IDE2NC43NWMtMi43OTMgMi43OTMtMi43OTMgNy4zMDYgMCAxMC4xbDE2NC43NSAxNjQuNzVjMi44NjUgMi43MjIgNy4zNzggMi42NSAxMC4wOTktLjE0MyAyLjY1MS0yLjc5NCAyLjY1MS03LjE2MyAwLTkuOTU3TDE3Ny44MDkgMjQ5Ljk1OXoiIC8+Cjwvc3ZnPgo=");if(this.sideEffect.addEventListener(s,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),t.appendChild(s),this.onPlay){const e=this.renderFooterBtn("btn-page-play",fe),s=this.debounce((()=>{const t=e.querySelector("img");t&&(t.src=fe)}),500);this.sideEffect.addEventListener(e,"click",(()=>{if(this.readonly)return;const t=e.querySelector("img");t&&(t.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTMxMi40OTEgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6TTE2NS4yNTcgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6IiAvPgo8L3N2Zz4K"),this.onPlay&&this.onPlay(),s()})),t.appendChild(e)}const i=this.renderFooterBtn("btn-page-next","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTMyMi4xOSAyNTAuMDQxTDE2Mi41MjcgNDA5LjcwNWMtMi43MjIgMi44NjUtMi42NTEgNy4zNzguMTQzIDEwLjEgMi43OTMgMi42NSA3LjE2MyAyLjY1IDkuOTU2IDBsMTY0Ljc1LTE2NC43NWMyLjc5My0yLjc5MyAyLjc5My03LjMwNiAwLTEwLjFsLTE2NC43NS0xNjQuNzVjLTIuODY1LTIuNzIyLTcuMzc4LTIuNjUtMTAuMDk5LjE0My0yLjY1MSAyLjc5NC0yLjY1MSA3LjE2MyAwIDkuOTU3bDE1OS42NjQgMTU5LjczNnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),t.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const r=document.createElement("input");r.className=this.wrapClassName("page-number-input"),r.value=String(this.pageIndex+1),this.readonly&&(r.disabled=!0),this.$pageNumberInput=r,this.sideEffect.addEventListener(r,"change",(()=>{this.readonly||r.value&&this.onNewPageIndex(Number(r.value)-1)}));const a=document.createElement("span");a.textContent=" / "+this.pages.length,o.appendChild(r),o.appendChild(a),this.$footer.appendChild(t),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t){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,mountWhiteboard:a,onUserScroll:n}){this.onNewPageIndex=e=>{this.scrollToPage(e)},this.sideEffect=new ye,this.scrollbarHeight=30,this.whiteboardView=e,this.readonly=t,this.box=s,this.pages=i,this.pageScrollTop=r,this.pagesSize=o,this.mountWhiteboard=a,this.onUserScroll=n,this.viewer=new 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.mountWhiteboard(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+5;this.elScrollTo(e),this.onUserScroll&&this.onUserScroll(this.scrollTopElToPage(e))}}}setupScrollTopEvent(){const e=this.debounce((()=>{if(this.pages.length>0&&this.$pages){if(this.$pages.getBoundingClientRect().width>0){let e=0;for(let t=0;t<this.pages.length;t+=1)if(e+=this.pages[t].height,this.pageScrollTop<=e)return void this.viewer.setPageIndex(t);this.viewer.setPageIndex(this.pages.length-1)}}}),{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.addEventListener(this.$pages,"scroll",(()=>{const t=this.$pages.scrollTop,s=this.scrollTopElToPage(t);this.pageScrollTop=s;const{width:i,height:o}=this.whiteboardView.size,{width:r,height:a}=this.pagesSize,n=i/r*a;this.whiteboardView.moveCamera({centerY:this.scrollTopElToPage(t+o/2),animationMode:"immediately"}),this.setScrollbarHeight(o/n*o),this.$scrollbar.style.transform=`translateY(${t/(n-o)*(o-this.scrollbarHeight)}px)`,e()}))}setupWhiteboardCamera(){this.sideEffect.add((()=>{const e=({width:e,height:t})=>{if(e>0&&t>0){const s=this.$pages.scrollTop,i=this.pagesSize.width,o=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*o,width:i,height:t*o,animationMode:"immediately"}),this.elScrollTo(s)}};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}}),"whiteboard-size-update")}debounce(e,t,s){const i=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,mountWhiteboard:a}){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.mountWhiteboard=a,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),this.scaleDocsToFit())}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.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Le={kind:"DocsViewer",setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=e.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");i.disableCameraTransform=!0;const o=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(o.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(".netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7}.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;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;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"),o[0].src.startsWith("ppt")?function(e,t,s,i){const o=e.getDisplayer(),r=new Ie({displayer:o,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),s.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,i,t,o):function(e,t,s,i){var o;const r={width:i[0].width,height:i.reduce(((e,t)=>e+t.height*(i[0].width/t.width)),0)},a=new Ne({whiteboardView:t,readonly:s.readonly,box:s,pages:i,pagesSize:r,pageScrollTop:null==(o=e.getAttributes())?void 0:o.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:t=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===t||s.readonly||e.updateAttributes(["pageScrollTop"],t)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),s.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,i,t,o)}};export{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),f=e=>null===m(e),y=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))},$=e=>{S(e,"src"),S(e,"srcset"),S(e,"sizes")},O=(e,t)=>{const s=e.parentNode;if(!s||"PICTURE"!==s.tagName)return;j(s).forEach(t)},_={IMG:(e,t)=>{O(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)},R=(e,t,s)=>{L(s,1),E(e,t.class_loading),b(e,"loading"),x(t.callback_loading,e,s)},U=["IMG","IFRAME","VIDEO"],W=(e,t)=>{!t||(e=>e.loadingCount>0)(t)||(e=>e.toLoadCount>0)(t)||x(e.callback_finish,t)},Z=(e,t,s)=>{e.addEventListener(t,s),e.llEvLisnrs[t]=s},H=(e,t,s)=>{e.removeEventListener(t,s)},B=e=>!!e.llEvLisnrs,F=e=>{if(!B(e))return;const t=e.llEvLisnrs;for(let s in t){const i=t[s];H(e,s,i)}delete e.llEvLisnrs},Q=(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(B(i))return;((e,t,s)=>{B(e)||(e.llEvLisnrs={});const i="VIDEO"===e.tagName?"loadeddata":"load";Z(e,i,t),Z(e,"error",s)})(i,(o=>{((e,t,s,i)=>{const o=y(t);Q(t,s,i),E(t,s.class_loaded),b(t,"loaded"),x(s.callback_loaded,t,i),o||W(s,i)})(0,e,t,s),F(i)}),(o=>{((e,t,s,i)=>{const o=y(t);Q(t,s,i),E(t,s.class_error),b(t,"error"),x(s.callback_error,t,i),o||W(s,i)})(0,e,t,s),F(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),R(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=>U.indexOf(e.tagName)>-1)(e)?((e,t,s)=>{G(e,t,s),V(e,t),R(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&&(F(e),(e=>{O(e,(e=>{$(e)})),$(e)})(e),(e=>{O(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)=>{f(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(f))(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 fe{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 ye="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.isSmallBox=!1,this.sideEffect=new fe,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))}setSmallBox(e){this.isSmallBox!==e&&this.$footer.classList.toggle(this.wrapClassName("float-footer"),e)}render(){return this.renderContent(),this.renderFooter(),this.$content}renderContent(){if(!this.$content){const e=document.createElement("div");e.className=this.wrapClassName("content"),this.$content=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),e.appendChild(this.renderPreviewMask()),e.appendChild(this.renderPreview())}return this.$content}renderPreview(){if(!this.$preview){const e=document.createElement("div");e.className=this.wrapClassName("preview")+" tele-fancy-scrollbar",this.$preview=e;const t=this.wrapClassName("preview-page"),s=this.wrapClassName("preview-page-name");this.pages.forEach(((i,o)=>{var r;const a=null!=(r=i.thumbnail)?r:i.src.startsWith("ppt")?void 0:i.src;if(!a)return;const n=String(o),l=document.createElement("a");l.className=t+" "+this.wrapClassName(`preview-page-${o}`),l.setAttribute("href","#"),l.dataset.pageIndex=n;const d=document.createElement("span");d.className=s,d.textContent=String(o+1),d.dataset.pageIndex=n;const c=document.createElement("img");c.width=i.width,c.height=i.height,c.dataset.src=a,c.dataset.pageIndex=n,l.appendChild(c),l.appendChild(d),e.appendChild(l)})),this.sideEffect.addEventListener(e,"click",(e=>{var t;if(this.readonly)return;const s=null==(t=e.target.dataset)?void 0:t.pageIndex;s&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.onNewPageIndex(Number(s)),this.togglePreview(!1))}))}return this.$preview}renderPreviewMask(){return this.$previewMask||(this.$previewMask=document.createElement("div"),this.$previewMask.className=this.wrapClassName("preview-mask"),this.sideEffect.addEventListener(this.$previewMask,"click",(e=>{this.readonly||e.target===this.$previewMask&&this.togglePreview(!1)}))),this.$previewMask}renderFooter(){if(!this.$footer){const e=document.createElement("div");if(e.className=this.wrapClassName("footer"),this.$footer=e,this.readonly&&e.classList.add(this.wrapClassName("readonly")),this.isSmallBox&&e.classList.add(this.wrapClassName("float-footer")),this.pages.some((e=>e.thumbnail||!e.src.startsWith("ppt")))){const e=this.renderFooterBtn("btn-sidebar","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+CiAgICA8cGF0aAogICAgICAgIGQ9Ik01MCA4SDE0Yy0zLjMwOSAwLTYgMi42OTEtNiA2djM2YzAgMy4zMDkgMi42OTEgNiA2IDZoMzZjMy4zMDkgMCA2LTIuNjkxIDYtNlYxNGMwLTMuMzA5LTIuNjkxLTYtNi02ek0xMiA1MFYxNGMwLTEuMTAzLjg5Ny0yIDItMmg4djQwaC04Yy0xLjEwMyAwLTItLjg5Ny0yLTJ6bTQwIDBjMCAxLjEwMy0uODk3IDItMiAySDI2VjEyaDI0YzEuMTAzIDAgMiAuODk3IDIgMnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(e,"click",(()=>{this.readonly||this.togglePreview()})),this.$footer.appendChild(e)}const t=document.createElement("div");t.className=this.wrapClassName("page-jumps");const s=this.renderFooterBtn("btn-page-back","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTE3Ny44MSAyNDkuOTU5TDMzNy40NzMgOTAuMjk1YzIuNzIyLTIuODY1IDIuNjUxLTcuMzc4LS4xNDMtMTAuMS0yLjc5My0yLjY1LTcuMTYzLTIuNjUtOS45NTYgMGwtMTY0Ljc1IDE2NC43NWMtMi43OTMgMi43OTMtMi43OTMgNy4zMDYgMCAxMC4xbDE2NC43NSAxNjQuNzVjMi44NjUgMi43MjIgNy4zNzggMi42NSAxMC4wOTktLjE0MyAyLjY1MS0yLjc5NCAyLjY1MS03LjE2MyAwLTkuOTU3TDE3Ny44MDkgMjQ5Ljk1OXoiIC8+Cjwvc3ZnPgo=");if(this.sideEffect.addEventListener(s,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex-1)})),t.appendChild(s),this.onPlay){const e=this.renderFooterBtn("btn-page-play",ye),s=this.debounce((()=>{const t=e.querySelector("img");t&&(t.src=ye)}),500);this.sideEffect.addEventListener(e,"click",(()=>{if(this.readonly)return;const t=e.querySelector("img");t&&(t.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoIGZpbGw9IiMxZTIwMWQiCiAgICAgICAgZD0iTTMxMi40OTEgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6TTE2NS4yNTcgNzguMjYxYzAtNi4xNTkgNC44OTMtMTEuMjEzIDExLjA0LTExLjIxMyA2LjE1OCAwIDExLjIxMSA1LjA1NCAxMS4yMTEgMTEuMjEzdjM0My40NzhjMCA2LjE1OS01LjA1MyAxMS4yMTMtMTEuMjExIDExLjIxMy02LjE0NyAwLTExLjA0LTUuMDU0LTExLjA0LTExLjIxM1Y3OC4yNjF6IiAvPgo8L3N2Zz4K"),this.onPlay&&this.onPlay(),s()})),t.appendChild(e)}const i=this.renderFooterBtn("btn-page-next","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MDAgNTAwIj4KICAgIDxwYXRoCiAgICAgICAgZD0iTTMyMi4xOSAyNTAuMDQxTDE2Mi41MjcgNDA5LjcwNWMtMi43MjIgMi44NjUtMi42NTEgNy4zNzguMTQzIDEwLjEgMi43OTMgMi42NSA3LjE2MyAyLjY1IDkuOTU2IDBsMTY0Ljc1LTE2NC43NWMyLjc5My0yLjc5MyAyLjc5My03LjMwNiAwLTEwLjFsLTE2NC43NS0xNjQuNzVjLTIuODY1LTIuNzIyLTcuMzc4LTIuNjUtMTAuMDk5LjE0My0yLjY1MSAyLjc5NC0yLjY1MSA3LjE2MyAwIDkuOTU3bDE1OS42NjQgMTU5LjczNnoiIC8+Cjwvc3ZnPgo=");this.sideEffect.addEventListener(i,"click",(()=>{this.readonly||this.onNewPageIndex(this.pageIndex+1)})),t.appendChild(i);const o=document.createElement("div");o.className=this.wrapClassName("page-number");const r=document.createElement("input");r.className=this.wrapClassName("page-number-input"),r.value=String(this.pageIndex+1),this.readonly&&(r.disabled=!0),this.$pageNumberInput=r,this.sideEffect.addEventListener(r,"change",(()=>{this.readonly||r.value&&this.onNewPageIndex(Number(r.value)-1)}));const a=document.createElement("span");a.textContent=" / "+this.pages.length,o.appendChild(r),o.appendChild(a),this.$footer.appendChild(t),this.$footer.appendChild(o)}return this.$footer}renderFooterBtn(e,t){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,mountWhiteboard:a,onUserScroll:n}){this.onNewPageIndex=e=>{this.scrollToPage(e)},this.sideEffect=new fe,this.scrollbarHeight=30,this.whiteboardView=e,this.readonly=t,this.box=s,this.pages=i,this.pageScrollTop=r,this.pagesSize=o,this.mountWhiteboard=a,this.onUserScroll=n,this.viewer=new 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.whiteboardView.callbacks.on("onSizeUpdated",(()=>{this.renderRatioHeight()})),this}unmount(){return this.viewer.unmount(),this}setReadonly(e){this.readonly!==e&&(this.readonly=e,this.viewer.setReadonly(e))}destroy(){this.sideEffect.flush(),this.onUserScroll=void 0,this.unmount(),this.viewer.destroy()}syncPageScrollTop(e){e>=0&&Math.abs(this.pageScrollTop-e)>10&&this.pageScrollTo(e)}render(){this.viewer.$content.appendChild(this.renderPages()),this.viewer.$content.appendChild(this.renderWhiteboardView()),this.viewer.$content.appendChild(this.renderScrollbar()),this.renderRatioHeight()}renderRatioHeight(){const e=this.box.absoluteHeight,t=e<=640;if(this.viewer.setSmallBox(t),t){const t=26/640,s=26/e,i=26/640,o=0,r=Math.max((t+i-(s+o))/2,0);if(this.box.$titleBar){const e=s+r;this.box.$titleBar.style.height=100*e+"%"}if(this.box.$footer){const e=o+r;this.box.$footer.style.height=100*e+"%"}}else{if(this.box.$titleBar){const t=Math.max(26/640,26/e);this.box.$titleBar.style.height=100*t+"%"}if(this.box.$footer){const t=Math.max(26/640,26/e);this.box.$footer.style.height=100*t+"%"}}}renderPages(){if(!this.$pages){const e=document.createElement("div");e.className=this.wrapClassName("pages"),this.$pages=e;const t=this.wrapClassName("page");this.pages.forEach(((s,i)=>{const o=document.createElement("img");o.className=t+" "+this.wrapClassName(`page-${i}`),o.draggable=!1,o.width=s.width,o.height=s.height,o.dataset.src=s.src,o.dataset.pageIndex=String(i),e.appendChild(o)}))}return this.$pages}renderWhiteboardView(){return this.$whiteboardView||(this.$whiteboardView=document.createElement("div"),this.$whiteboardView.className=this.wrapClassName("wb-view"),this.mountWhiteboard(this.$whiteboardView),this.sideEffect.addEventListener(this.$whiteboardView,"wheel",(e=>{if(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+5;this.elScrollTo(e),this.onUserScroll&&this.onUserScroll(this.scrollTopElToPage(e))}}}setupScrollTopEvent(){const e=this.debounce((()=>{if(this.pages.length>0&&this.$pages){if(this.$pages.getBoundingClientRect().width>0){let e=0;for(let t=0;t<this.pages.length;t+=1)if(e+=this.pages[t].height,this.pageScrollTop<=e)return void this.viewer.setPageIndex(t);this.viewer.setPageIndex(this.pages.length-1)}}}),{wait:5,maxWait:100},"debounce-updatePageIndex");this.sideEffect.addEventListener(this.$pages,"scroll",(()=>{const t=this.$pages.scrollTop,s=this.scrollTopElToPage(t);this.pageScrollTop=s;const{width:i,height:o}=this.whiteboardView.size,{width:r,height:a}=this.pagesSize,n=i/r*a;this.whiteboardView.moveCamera({centerY:this.scrollTopElToPage(t+o/2),animationMode:"immediately"}),this.setScrollbarHeight(o/n*o),this.$scrollbar.style.transform=`translateY(${t/(n-o)*(o-this.scrollbarHeight)}px)`,e()}))}setupWhiteboardCamera(){this.sideEffect.add((()=>{const e=({width:e,height:t})=>{if(e>0&&t>0){const s=this.$pages.scrollTop,i=this.pagesSize.width,o=i/e;this.whiteboardView.moveCameraToContain({originX:0,originY:s*o,width:i,height:t*o,animationMode:"immediately"}),this.elScrollTo(s)}};return this.whiteboardView.callbacks.on("onSizeUpdated",e),()=>{this.whiteboardView.callbacks.off("onSizeUpdated",e)}}),"whiteboard-size-update")}debounce(e,t,s){const i=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,mountWhiteboard:a}){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.shouldResetPPT=!0,this.jumpToPage(e)},this.sideEffect=new fe,this.shouldResetPPT=!1,this.whiteboardView=t,this.readonly=i,this.box=o,this.pages=r,this.displayer=e,this.getWhiteboardRoom=s,this.mountWhiteboard=a,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),this.scaleDocsToFit())}if(e!==this.viewer.pageIndex&&this.viewer.setPageIndex(e),this.shouldResetPPT){const e=this.getWhiteboardRoom();e&&e.setGlobalState({__pptState:void 0}),this.shouldResetPPT=!1}}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.mountWhiteboard(this.$whiteboardView)),this.$whiteboardView}wrapClassName(e){return"netless-app-docs-viewer-dynamic-"+e}}const Le={kind:"DocsViewer",setup(e){const t=e.getBox(),s=e.getScenes();if(!s)throw new Error("[Docs Viewer]: scenes not found.");const i=e.getView();if(!i)throw new Error("[Docs Viewer]: no whiteboard view.");i.disableCameraTransform=!0;const o=s.map((({ppt:e})=>e?{width:e.width,height:e.height,src:e.src,thumbnail:e.previewURL}:null)).filter((e=>Boolean(e)));if(o.length<=0)throw new Error("[Docs Viewer]: empty scenes.");t.mountStyles(".netless-app-docs-viewer-content{position:relative;height:100%;overflow:hidden}.netless-app-docs-viewer-preview-mask{display:none;position:absolute;z-index:200;top:0;left:0;width:100%;height:100%}.netless-app-docs-viewer-preview{display:flex;flex-direction:column;align-items:center;position:absolute;z-index:300;top:0;left:0;width:33%;max-width:200px;height:100%;padding-top:10px;transform:translate(-100%);background:rgba(237,237,240,.9);box-shadow:inset -1px 0 #0000001c;transition:transform .4s}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview-mask{display:block}.netless-app-docs-viewer-preview-active .netless-app-docs-viewer-preview{transform:translate(0)}.netless-app-docs-viewer-preview-page{position:relative;display:block;width:55%;margin-bottom:10px;font-size:0;color:transparent;outline:none;border:7px solid transparent;border-radius:4px;transition:border-color .3s;user-select:none}.netless-app-docs-viewer-preview-page:hover,.netless-app-docs-viewer-preview-page.netless-app-docs-viewer-preview-page-active{border-color:#444e601a}.netless-app-docs-viewer-preview-page>img{width:100%;height:auto;box-sizing:border-box;border:1px solid rgba(0,0,0,.5);border-radius:1px;background-color:#fff;box-shadow:0 2px 8px #0000004d}.netless-app-docs-viewer-preview-page-name{position:absolute;top:1px;left:-10px;transform:translate(-100%);text-align:right;font-size:12px;color:#5f5f5f;user-select:none}.netless-app-docs-viewer-footer{box-sizing:border-box;height:26px;display:flex;align-items:center;padding:0 16px;border-top:1px solid #eeeef7}.netless-app-docs-viewer-float-footer{width:100%;min-height:26px;position:absolute;left:0;bottom:0;z-index:2000;background:rgba(249,249,252,.9);opacity:0;transition:opacity .4s}.netless-app-docs-viewer-float-footer:hover{opacity:1}.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;white-space:nowrap;word-break:keep-all}.netless-app-docs-viewer-page-number-input{border:none;outline:none;width:1.5em;text-align:right;border-radius:2px;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"),o[0].src.startsWith("ppt")?function(e,t,s,i){const o=e.getDisplayer(),r=new Ie({displayer:o,whiteboardView:t,getRoom:()=>e.getIsWritable()?e.getDisplayer():void 0,readonly:s.readonly,box:s,pages:i,mountWhiteboard:e.mountView.bind(e)}).mount();e.mountView(r.$whiteboardView),e.emitter.on("sceneStateChange",(e=>{r.jumpToPage(e.index)})),s.events.on("readonly",(e=>{r.setReadonly(e)}))}(e,i,t,o):function(e,t,s,i){var o;const r={width:i[0].width,height:i.reduce(((e,t)=>e+t.height*(i[0].width/t.width)),0)},a=new Ne({whiteboardView:t,readonly:s.readonly,box:s,pages:i,pagesSize:r,pageScrollTop:null==(o=e.getAttributes())?void 0:o.pageScrollTop,mountWhiteboard:e.mountView.bind(e),onUserScroll:t=>{var i;(null==(i=e.getAttributes())?void 0:i.pageScrollTop)===t||s.readonly||e.updateAttributes(["pageScrollTop"],t)}}).mount();e.emitter.on("attributesUpdate",(e=>{e&&null!=e.pageScrollTop&&a.syncPageScrollTop(e.pageScrollTop)})),s.events.on("readonly",(e=>{a.setReadonly(e)}))}(e,i,t,o)}};export{Le as default}; | ||
//# sourceMappingURL=main.es.js.map |
@@ -44,2 +44,3 @@ import type { ReadonlyTeleBox } from "@netless/window-manager"; | ||
render(): void; | ||
protected renderRatioHeight(): void; | ||
protected renderPages(): HTMLElement; | ||
@@ -46,0 +47,0 @@ protected renderWhiteboardView(): HTMLDivElement; |
{ | ||
"name": "@netless/app-docs-viewer", | ||
"version": "0.1.11", | ||
"private": false, | ||
"description": "Netless App Docs Viewer", | ||
"homepage": "https://github.com/netless-io/netless-app-docs-viewer", | ||
"license": "MIT", | ||
"author": "CRIMX <straybugs@gmail.com> (https://github.com/crimx/)", | ||
"sideEffects": [ | ||
"*.css" | ||
], | ||
"main": "./dist/main.cjs.js", | ||
"module": "./dist/main.es.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"src", | ||
"dist" | ||
], | ||
"scripts": { | ||
"start": "vite ./playground --open --host", | ||
"lint": "lint-staged", | ||
"types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --jsx react --esModuleInterop --outDir dist", | ||
"build": "vite build && yarn run types", | ||
"build:dev": "vite build --mode development && yarn run types", | ||
"cleanup": "rimraf ./build" | ||
}, | ||
"devDependencies": { | ||
"@babel/plugin-proposal-class-properties": "^7.13.0", | ||
"@netless/eslint-plugin": "^1.1.2", | ||
"@netless/window-manager": "^0.0.0-beta.35", | ||
"@rollup/plugin-commonjs": "^17.1.0", | ||
"@rollup/plugin-node-resolve": "^11.2.0", | ||
"@rollup/plugin-url": "^6.0.0", | ||
"@types/node": "^14.14.16", | ||
"@typescript-eslint/eslint-plugin": "^4.11.0", | ||
"@typescript-eslint/parser": "^4.11.0", | ||
"cross-env": "^7.0.2", | ||
"eslint": "^7.31.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-config-react-app": "^6.0.0", | ||
"eslint-loader": "^4.0.2", | ||
"eslint-plugin-jsx-a11y": "^6.3.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.20.6", | ||
"eslint-plugin-react-app": "^6.2.2", | ||
"fork-ts-checker-webpack-plugin": "^6.0.4", | ||
"lint-staged": "^10.5.4", | ||
"minimist": "^1.2.5", | ||
"prettier": "^2.0.5", | ||
"rimraf": "^3.0.0", | ||
"sass": "^1.36.0", | ||
"typescript": "^4.1.2", | ||
"vite": "^2.5.0", | ||
"white-web-sdk": "^2.13.17" | ||
}, | ||
"dependencies": { | ||
"debounce-fn": "^5.0.0", | ||
"vanilla-lazyload": "^17.4.0" | ||
} | ||
"name": "@netless/app-docs-viewer", | ||
"version": "0.1.12", | ||
"description": "Netless App Docs Viewer", | ||
"repository": "netless-io/netless-app", | ||
"license": "MIT", | ||
"author": "CRIMX <straybugs@gmail.com> (https://github.com/crimx/)", | ||
"sideEffects": [ | ||
"*.css" | ||
], | ||
"main": "./dist/main.cjs.js", | ||
"module": "./dist/main.es.js", | ||
"types": "./src/index.ts", | ||
"files": [ | ||
"src", | ||
"dist" | ||
], | ||
"scripts": { | ||
"types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --outDir dist", | ||
"build": "vite build && npm run types", | ||
"build:dev": "vite build --mode development && npm run types", | ||
"cleanup": "rimraf ./build" | ||
}, | ||
"dependencies": { | ||
"debounce-fn": "^5.0.0", | ||
"vanilla-lazyload": "^17.4.0" | ||
} | ||
} |
@@ -110,2 +110,11 @@ import sidebarSVG from "./icons/sidebar.svg"; | ||
public setSmallBox(isSmallBox: boolean): void { | ||
if (this.isSmallBox !== isSmallBox) { | ||
this.$footer.classList.toggle( | ||
this.wrapClassName("float-footer"), | ||
isSmallBox | ||
); | ||
} | ||
} | ||
public render(): HTMLElement { | ||
@@ -224,2 +233,6 @@ this.renderContent(); | ||
if (this.isSmallBox) { | ||
$footer.classList.add(this.wrapClassName("float-footer")); | ||
} | ||
if ( | ||
@@ -375,3 +388,5 @@ this.pages.some( | ||
protected isSmallBox = false; | ||
protected sideEffect = new SideEffectManager(); | ||
} |
@@ -123,2 +123,9 @@ import type { | ||
} | ||
if (this.shouldResetPPT) { | ||
const room = this.getWhiteboardRoom(); | ||
if (room) { | ||
room.setGlobalState({ __pptState: undefined }); | ||
} | ||
this.shouldResetPPT = false; | ||
} | ||
} | ||
@@ -178,2 +185,3 @@ | ||
protected onNewPageIndex = (index: number): void => { | ||
this.shouldResetPPT = true; | ||
this.jumpToPage(index); | ||
@@ -187,2 +195,4 @@ }; | ||
protected sideEffect = new SideEffectManager(); | ||
protected shouldResetPPT = false; | ||
} |
@@ -11,2 +11,4 @@ import type { AnimationMode, ReadonlyTeleBox } from "@netless/window-manager"; | ||
const RATIO_BASE_CONTAINER_HEIGHT = 640; | ||
export interface StaticDocsViewerConfig { | ||
@@ -92,2 +94,6 @@ whiteboardView: View; | ||
this.whiteboardView.callbacks.on("onSizeUpdated", () => { | ||
this.renderRatioHeight(); | ||
}); | ||
return this; | ||
@@ -129,8 +135,51 @@ } | ||
this.viewer.$content.appendChild(this.renderScrollbar()); | ||
if (this.box.$titleBar) { | ||
this.box.$titleBar.style.height = `${(26 / 200) * 100}%`; | ||
this.renderRatioHeight(); | ||
} | ||
protected renderRatioHeight(): void { | ||
const boxHeight = this.box.absoluteHeight; | ||
const isSmallBox = boxHeight <= RATIO_BASE_CONTAINER_HEIGHT; | ||
this.viewer.setSmallBox(isSmallBox); | ||
if (isSmallBox) { | ||
const titleBarSupposedHeight = 26 / RATIO_BASE_CONTAINER_HEIGHT; | ||
const titleBarActualHeight = 26 / boxHeight; | ||
const footerSupposedHeight = 26 / RATIO_BASE_CONTAINER_HEIGHT; | ||
const footerActualHeight = 0; | ||
const emptySpace = Math.max( | ||
(titleBarSupposedHeight + | ||
footerSupposedHeight - | ||
(titleBarActualHeight + footerActualHeight)) / | ||
2, | ||
0 | ||
); | ||
if (this.box.$titleBar) { | ||
const titleBarHeight = titleBarActualHeight + emptySpace; | ||
this.box.$titleBar.style.height = `${titleBarHeight * 100}%`; | ||
} | ||
if (this.box.$footer) { | ||
const footerHeight = footerActualHeight + emptySpace; | ||
this.box.$footer.style.height = `${footerHeight * 100}%`; | ||
} | ||
} else { | ||
if (this.box.$titleBar) { | ||
const titleBarHeight = Math.max( | ||
26 / RATIO_BASE_CONTAINER_HEIGHT, | ||
26 / boxHeight | ||
); | ||
this.box.$titleBar.style.height = `${titleBarHeight * 100}%`; | ||
} | ||
if (this.box.$footer) { | ||
const footerHeight = Math.max( | ||
26 / RATIO_BASE_CONTAINER_HEIGHT, | ||
26 / boxHeight | ||
); | ||
this.box.$footer.style.height = `${footerHeight * 100}%`; | ||
} | ||
} | ||
if (this.box.$footer) { | ||
this.box.$footer.style.height = `${(26 / 200) * 100}%`; | ||
} | ||
} | ||
@@ -137,0 +186,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
0
1613
0
333152
27
2
0