@netless/window-manager 0.3.17-canary.2 → 0.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__spreadValues=(e,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(e,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(e,i,t[i]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@netless/app-docs-viewer"),require("@netless/app-media-player"),require("emittery"),require("p-retry"),require("lodash"),require("uuid"),require("white-web-sdk"),require("@juggle/resize-observer"),require("@netless/telebox-insider")):"function"==typeof define&&define.amd?define(["exports","@netless/app-docs-viewer","@netless/app-media-player","emittery","p-retry","lodash","uuid","white-web-sdk","@juggle/resize-observer","@netless/telebox-insider"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).WindowManager={},e.AppDocsViewer,e.AppMediaPlayer,e.Emittery,e.pRetry,e.lodash,e.uuid,e.whiteWebSdk,e.resizeObserver,e.teleboxInsider)}(this,(function(e,t,i,s,a,r,n,o,h,c){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p,l,g=d(t),u=d(i),m=d(s),M=d(a);(l=p||(p={})).AppMove="AppMove",l.AppFocus="AppFocus",l.AppResize="AppResize",l.AppBoxStateChange="AppBoxStateChange",l.GetAttributes="GetAttributes",l.UpdateWindowManagerWrapper="UpdateWindowManagerWrapper",l.InitReplay="InitReplay",l.WindowCreated="WindowCreated",l.SetMainViewScenePath="SetMainViewScenePath",l.SetMainViewSceneIndex="SetMainViewSceneIndex",l.SwitchViewsToFreedom="SwitchViewsToFreedom";const w="__WindowManger";var I,A,y,C,x,b,v;(A=I||(I={})).Size="size",A.Position="position",A.SceneIndex="SceneIndex",A.ZIndex="zIndex",(C=y||(y={})).setBoxSize="setBoxSize",C.setBoxMinSize="setBoxMinSize",C.destroy="destroy",(x||(x={})).StartCreate="StartCreate",(v=b||(b={})).Leave="leave",v.Normal="normal";const S="2.13.16",N=340/720,D=340/720,T={right:"10px",bottom:"15px",position:"absolute"},f="__WindowManagerAppCache";let j,V;const L=async()=>{j=await new Promise(((e,t)=>{const i=indexedDB.open(f,2);i.onerror=e=>{t(e)},i.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains("apps")||(V=t.createObjectStore("apps",{keyPath:"kind"}),V.createIndex("kind","kind",{unique:!0}))},i.onsuccess=()=>{const t=i.result;e(t)}}))},P=(e,t)=>{var i,s;if(j)return i=j,s={kind:e,sourceCode:t},new Promise(((e,t)=>{const a=i.transaction(["apps"],"readwrite").objectStore("apps").add(s);a.onsuccess=()=>e(),a.onerror=()=>t()}))},E=async e=>{return j?await(t=j,i=e,new Promise(((e,s)=>{const a=t.transaction(["apps"]).objectStore("apps").index("kind").get(i);a.onerror=e=>s(e),a.onsuccess=()=>{a.result?e(a.result):e(null)}}))):null;var t,i};const z=async e=>{const t=await E(e);if(t)return t;{const t=await async function(e,t){const{timeout:i=1e4}=t,s=new AbortController,a=setTimeout((()=>s.abort()),i),r=await fetch(e,__spreadProps(__spreadValues({},t),{signal:s.signal,headers:{"content-type":"text/plain"}}));return clearTimeout(a),r}(e,{timeout:1e4}),i=await t.text();return await P(e,i),i}},B=(e,t)=>{let i=Function(e+`;return ${t}`)();return void 0===i&&(i=window[t]),i};const U=new class{constructor(){this.kindEmitters=new Map,this.registered=new Map,this.appClassesCache=new Map,this.appClasses=new Map}async register(e){this.registered.set(e.kind,e);const t=e.src;let i;if(i="string"==typeof t?async()=>{const i=await(async(e,t,i)=>{const s=i||"NetlessApp"+t,a=await z(e);try{return B(a,s)}catch(r){if(r.message.includes("Can only have one anonymous define call per script file")){const e=window.define;return"function"==typeof e&&e.amd&&delete e.amd,B(a,s)}}})(t,e.kind);if(i)return i;throw new Error(`[WindowManager]: load remote script failed, ${t}`)}:"function"==typeof t?t:async()=>t,this.appClasses.set(e.kind,(async()=>{let t=this.appClassesCache.get(e.kind);return t||(t=i(),this.appClassesCache.set(e.kind,t)),t})),e.addHooks){const t=this.createKindEmitter(e.kind);t&&e.addHooks(t)}}async notifyApp(e,t,i){const s=this.kindEmitters.get(e);await(null==s?void 0:s.emit(t,i))}createKindEmitter(e){if(!this.kindEmitters.has(e)){const t=new m.default;this.kindEmitters.set(e,t)}return this.kindEmitters.get(e)}},k=(e,t)=>{e.focusScenePath!==t&&(e.focusScenePath=t)},O=(e,t)=>{e&&e.isWritable&&e.state.sceneState.scenePath!==t&&e.setScenePath(t)},R=(e,t)=>{e.didRelease||e.mode===t||(e.mode=t)},Z=r.debounce(((e,t)=>{e.emit("mainViewModeChange",t)}),200),Q=e=>{const t=e.split(".").map((e=>e.padStart(2,"0"))).join("");return parseInt(t)},W=e=>new Promise((t=>setTimeout(t,e)));class G{constructor(e){this.manager=e,this.displayer=this.manager.displayer,this.boxManager=this.manager.boxManager,this.mainMagixEventListener=e=>{if(e.authorId!==this.displayer.observerId){const t=e.payload;switch(t.eventName){case p.AppMove:this.appMoveHandler(t.payload);break;case p.AppResize:this.appResizeHandler(t.payload);break;case p.SwitchViewsToFreedom:this.switchViewsToFreedomHandler();break;case p.AppBoxStateChange:this.boxStateChangeHandler(t.payload);break;case p.SetMainViewScenePath:this.setMainViewScenePathHandler(t.payload)}}},this.appMoveHandler=e=>{this.boxManager.moveBox(e)},this.appResizeHandler=e=>{var t;this.boxManager.resizeBox(Object.assign(e,{skipUpdate:!0})),null==(t=this.manager.room)||t.refreshViewSize()},this.switchViewsToFreedomHandler=()=>{this.manager.viewManager.freedomAllViews()},this.boxStateChangeHandler=e=>{nt.emit("boxStateChange",e)},this.setMainViewScenePathHandler=({nextScenePath:e})=>{k(this.manager.mainView,e)}}addListeners(){this.displayer.addMagixEventListener(w,this.mainMagixEventListener)}removeListeners(){this.displayer.removeMagixEventListener(w,this.mainMagixEventListener)}}class Y extends Error{constructor(){super(...arguments),this.message="[WindowManager]: app duplicate exists and cannot be created again"}}class F extends Error{constructor(){super(...arguments),this.message="[WindowManager]: AppManager must be initialized"}}class H extends Error{constructor(e){super(`[WindowManager]: white-web-sdk version must large than ${e}`)}}class X extends Error{constructor(){super(...arguments),this.message="[WindowManager]: kind must be a valid string"}}class J extends Error{constructor(){super(...arguments),this.message="[WindowManager]: box need created"}}class _ extends Error{constructor(){super(...arguments),this.message='[WindowManager]: ScenePath should start with "/"'}}class K{constructor(e,t,i,s){this.manager=e,this.appId=t,this.appProxy=i,this.appOptions=s,this.mobxUtils={autorun:o.autorun,reaction:o.reaction,toJS:o.toJS},this.objectUtils={listenUpdated:o.listenUpdated,unlistenUpdated:o.unlistenUpdated,listenDisposed:o.listenDisposed,unlistenDisposed:o.unlistenDisposed},this.store=this.manager.store,this.isReplay=this.manager.isReplay,this.emitter=i.appEmitter,this.boxManager=this.manager.boxManager,this.isAddApp=i.isAddApp}getDisplayer(){return this.manager.displayer}getAttributes(){return this.appProxy.attributes}getScenes(){const e=this.store.getAppAttributes(this.appId);if(!(null==e?void 0:e.isDynamicPPT))return null==e?void 0:e.options.scenes;{const e=this.manager.appProxies.get(this.appId);if(e)return e.scenes}}getView(){return this.appProxy.view}getInitScenePath(){return this.manager.getAppInitPath(this.appId)}getIsWritable(){return this.manager.canOperate}getBox(){const e=this.boxManager.getBox(this.appId);if(e)return e;throw new J}getRoom(){return this.manager.room}setAttributes(e){this.manager.safeSetAttributes({[this.appId]:e})}updateAttributes(e,t){this.manager.attributes[this.appId]&&this.manager.safeUpdateAttributes([this.appId,...e],t)}async setScenePath(e){this.appProxy.box&&(this.appProxy.setFullPath(e),this.appProxy.context.switchAppToWriter(this.appId))}mountView(e){const t=this.getView();t&&(t.divElement=e,setTimeout((()=>{var e;null==(e=this.getRoom())||e.refreshViewSize()}),1e3))}getAppOptions(){return"function"==typeof this.appOptions?this.appOptions():this.appOptions}}var q,$;($=q||(q={})).Apps="apps",$.Focus="focus",$.State="state",$.BoxState="boxState",$.MainViewCamera="mainViewCamera",$.MainViewSize="mainViewSize",$.Broadcaster="broadcaster",$.Cursors="cursors",$.Position="position",$.CursorState="cursorState",$.FullPath="fullPath";class ee{constructor(e){this.manager=e}apps(){return r.get(this.manager.attributes,[q.Apps])}get focus(){return r.get(this.manager.attributes,[q.Focus])}getAppAttributes(e){return r.get(this.apps(),[e])}getAppState(e){return r.get(this.apps(),[e,q.State])}getMaximized(){return r.get(this.manager.attributes,["maximized"])}setupAppAttributes(e,t,i){this.manager.attributes.apps||this.manager.safeSetAttributes({apps:{}});const s=["scenePath","title"];i||s.push("scenes");const a=r.pick(e.options,s),n={kind:e.kind,options:a,isDynamicPPT:i};"string"==typeof e.src&&(n.src=e.src),this.manager.safeUpdateAttributes([q.Apps,t],n),this.manager.safeUpdateAttributes([q.Apps,t,q.State],{[I.Size]:{},[I.Position]:{},[I.SceneIndex]:0,[I.ZIndex]:100})}updateAppState(e,t,i){r.get(this.manager.attributes,[q.Apps,e,q.State])&&this.manager.safeUpdateAttributes([q.Apps,e,q.State,t],i)}cleanAppAttributes(e){this.manager.safeUpdateAttributes([q.Apps,e],void 0),this.manager.safeSetAttributes({[e]:void 0});this.manager.attributes[q.Focus]===e&&this.cleanFocus()}cleanFocus(){this.manager.safeSetAttributes({[q.Focus]:void 0})}getAppSceneIndex(e){var t;return null==(t=this.getAppState(e))?void 0:t[I.SceneIndex]}getAppScenePath(e){var t,i;return null==(i=null==(t=this.getAppAttributes(e))?void 0:t.options)?void 0:i.scenePath}getMainViewScenePath(){return this.manager.attributes._mainScenePath}getMainViewSceneIndex(){return this.manager.attributes._mainSceneIndex}getBoxState(){return this.manager.attributes[q.BoxState]}setMainViewScenePath(e){this.manager.safeSetAttributes({_mainScenePath:e})}setMainViewSceneIndex(e){this.manager.safeSetAttributes({_mainSceneIndex:e})}getMainViewCamera(){return r.get(this.manager.attributes,[q.MainViewCamera])}getMainViewSize(){return r.get(this.manager.attributes,[q.MainViewSize])}setMainViewCamera(e){this.manager.safeSetAttributes({[q.MainViewCamera]:__spreadValues({},e)})}setMainViewSize(e){this.manager.safeSetAttributes({[q.MainViewSize]:__spreadValues({},e)})}setAppFocus(e,t){t?this.manager.safeSetAttributes({[q.Focus]:e}):this.manager.safeSetAttributes({[q.Focus]:void 0})}updateCursor(e,t){r.get(this.manager.attributes,[q.Cursors])||this.manager.safeUpdateAttributes([q.Cursors],{}),r.get(this.manager.attributes,[q.Cursors,e])||this.manager.safeUpdateAttributes([q.Cursors,e],{}),this.manager.safeUpdateAttributes([q.Cursors,e,q.Position],t)}updateCursorState(e,t){r.get(this.manager.attributes,[q.Cursors,e])||this.manager.safeUpdateAttributes([q.Cursors,e],{}),this.manager.safeUpdateAttributes([q.Cursors,e,q.CursorState],t)}getCursorState(e){return r.get(this.manager.attributes,[q.Cursors,e,q.CursorState])}cleanCursor(e){this.manager.safeUpdateAttributes([q.Cursors,e],void 0)}setMainViewFocusPath(){const e=this.getMainViewScenePath();e&&k(this.manager.mainView,e)}}const te=(...e)=>{ht.debug&&console.log("[WindowManager]:",...e)};class ie{constructor(e){this.manager=e,this.findMember=e=>{var t;const i=null==(t=this.manager.room)?void 0:t.state.roomMembers;return null==i?void 0:i.find((t=>t.memberId===e))},this.findMemberByUid=e=>{var t;const i=null==(t=this.manager.room)?void 0:t.state.roomMembers;return null==i?void 0:i.find((t=>{var i;return(null==(i=t.payload)?void 0:i.uid)===e}))},this.observerId=e.displayer.observerId,rt.on("observerIdChange",(e=>{this.observerId=e}))}get uid(){var e;return(null==(e=this.manager.room)?void 0:e.uid)||""}updateManagerRect(){this.manager.boxManager.updateManagerRect()}blurFocusBox(){this.manager.boxManager.blurAllBox()}switchAppToWriter(e){this.manager.viewManager.switchAppToWriter(e)}}let se;class ae{constructor(e){this.manager=e,this.store=new ee(this.manager),this.context=(e=>(se||(se=new ie(e)),se))(this.manager)}}class re extends ae{constructor(e,t,i,s){var a;super(t),this.params=e,this.boxManager=this.manager.boxManager,this.appProxies=this.manager.appProxies,this.viewManager=this.manager.viewManager,this.cameraStore=this.manager.cameraStore,this.status="normal",this.getAppInitState=e=>{var t,i;const s=this.store.getAppState(e);if(!s)return;const a=null==s?void 0:s[I.Position],r=this.store.focus,n=null==s?void 0:s[I.Size],o=null==s?void 0:s[I.SceneIndex];let h={maximized:null==(t=this.attributes)?void 0:t.maximized,minimized:null==(i=this.attributes)?void 0:i.minimized,zIndex:null==s?void 0:s.zIndex};return a&&(h=__spreadProps(__spreadValues({},h),{id:e,x:a.x,y:a.y})),r===e&&(h=__spreadProps(__spreadValues({},h),{focus:!0})),n&&(h=__spreadProps(__spreadValues({},h),{width:n.width,height:n.height})),o&&(h=__spreadProps(__spreadValues({},h),{sceneIndex:o})),h},this.appAttributesUpdateListener=e=>{var t;null==(t=this.manager.refresher)||t.add(e,(()=>o.autorun((()=>{const t=this.manager.attributes[e];t&&this.appEmitter.emit("attributesUpdate",t)}))))},this.kind=e.kind,this.id=i,this.appProxies.set(this.id,this),this.appEmitter=new m.default,this.appListener=this.makeAppEventListener(this.id),this.isAddApp=s,this.initScenes(),(null==(a=this.params.options)?void 0:a.scenePath)&&this.createView()}initScenes(){var e;const t=this.params.options;t&&(this.scenePath=t.scenePath,(null==(e=this.appAttributes)?void 0:e.isDynamicPPT)&&this.scenePath?this.scenes=this.manager.displayer.entireScenes()[this.scenePath]:this.scenes=t.scenes)}get view(){return this.manager.viewManager.getView(this.id)}get isWritable(){var e;return this.manager.canOperate&&!(null==(e=this.box)?void 0:e.readonly)}get attributes(){return this.manager.attributes[this.id]}get appAttributes(){return this.store.getAppAttributes(this.id)}getFullScenePath(){if(this.scenePath)return r.get(this.appAttributes,[q.FullPath],this.scenePath)}setFullPath(e){this.manager.safeUpdateAttributes(["apps",this.id,q.FullPath],e)}async baseInsertApp(e=!1,t){var i;const s=this.params;if(!s.kind)throw new Error("[WindowManager]: kind require");const a=await(null==(i=U.appClasses.get(s.kind))?void 0:i()),r=U.registered.get(s.kind);if(!a)throw new Error(`[WindowManager]: app load failed ${s.kind} ${s.src}`);return await this.setupApp(this.id,e,a,s.options,null==r?void 0:r.appOptions),this.context.updateManagerRect(),t&&this.focusApp(),{appId:this.id,app:a}}focusApp(){this.focusBox(),this.context.switchAppToWriter(this.id),this.store.setMainViewFocusPath()}get box(){return this.boxManager.getBox(this.id)}focusBox(){this.boxManager.focusBox({appId:this.id})}async setupApp(e,t,i,s,a){te("setupApp",e,i,s);const r=new K(this.manager,e,this,a);try{rt.once(`${e}${p.WindowCreated}`).then((async()=>{let s;t||(s=this.getAppInitState(e),this.boxManager.updateBoxState(s)),this.appEmitter.onAny(this.appListener),this.appAttributesUpdateListener(e),this.setViewFocusScenePath(),setTimeout((async()=>{const t=await i.setup(r);U.notifyApp(i.kind,"created",{appId:e,result:t}),this.afterSetupApp(s),this.fixMobileSize()}),50)})),this.boxManager.createBox({appId:e,app:i,options:s,canOperate:this.manager.canOperate,smartPosition:this.isAddApp})}catch(n){throw console.error(n),new Error(`[WindowManager]: app setup error: ${n.message}`)}}fixMobileSize(){const e=this.boxManager.getBox(this.id);e&&this.boxManager.resizeBox({appId:this.id,width:e.intrinsicWidth+.001,height:e.intrinsicHeight+.001,skipUpdate:!0})}afterSetupApp(e){e&&(e.focus&&this.scenePath&&this.context.switchAppToWriter(this.id),(null==e?void 0:e.x)&&e.y||this.boxManager.setBoxInitState(this.id))}onSeek(e){this.appEmitter.emit("seek",e);const t=this.getAppInitState(this.id);this.boxManager.updateBoxState(t)}async onReconnected(){this.appEmitter.emit("reconnected",void 0);const e=this.getAppInitState(this.id);await this.destroy(!0,!1,!0);const t=this.params,i=new re(t,this.manager,this.id,this.isAddApp);await i.baseInsertApp(!0,this.store.focus===this.id),this.boxManager.updateBoxState(e)}switchToWritable(){U.notifyApp(this.kind,"focus",{appId:this.id}),this.cameraStore.switchView(this.id,this.view,(()=>{if(this.view){if(this.view.mode===o.ViewVisionMode.Writable)return;try{this.manager.mainView.mode===o.ViewVisionMode.Writable&&(this.store.setMainViewFocusPath(),Z(nt,o.ViewVisionMode.Freedom),R(this.manager.mainView,o.ViewVisionMode.Freedom)),R(this.view,o.ViewVisionMode.Writable)}catch(e){te("switch view failed",e)}}}))}emitAppSceneStateChange(e){this.appEmitter.emit("sceneStateChange",e)}emitAppIsWritableChange(){this.appEmitter.emit("writableChange",this.isWritable)}makeAppEventListener(e){return(t,i)=>{if(this.manager.canOperate)switch(t){case"setBoxSize":this.boxManager.resizeBox({appId:e,width:i.width,height:i.height,skipUpdate:!1});break;case"setBoxMinSize":this.boxManager.setBoxMinSize({appId:e,minWidth:i.minwidth,minHeight:i.minheight});break;case"setBoxTitle":this.boxManager.setBoxTitle({appId:e,title:i.title});break;case y.destroy:if("destroyed"===this.status)return;this.destroy(!0,!1,!0,null==i?void 0:i.error),(null==i?void 0:i.error)&&console.error(null==i?void 0:i.error);break;case"focus":this.boxManager.focusBox({appId:this.id}),rt.emit("focus",{appId:this.id})}}}setScenePath(){if(!this.manager.canOperate)return;const e=this.getFullScenePath();this.manager.room&&e&&this.view&&O(this.manager.room,e)}setViewFocusScenePath(){const e=this.getFullScenePath();e&&this.view&&k(this.view,e)}async createView(){const e=await this.viewManager.createView(this.id);return this.cameraStore.register(this.id,e),this.setViewFocusScenePath(),e}async destroy(e,t,i,s){var a;"destroyed"!==this.status&&(this.status="destroyed",await U.notifyApp(this.kind,"destroy",{appId:this.id}),await this.appEmitter.emit("destroy",{error:s}),this.appEmitter.clearListeners(),rt.emit(`destroy-${this.id}`,{error:s}),e&&this.boxManager.closeBox(this.id,i),t&&this.store.cleanAppAttributes(this.id),this.appProxies.delete(this.id),this.cameraStore.unregister(this.id,this.view),this.viewManager.destroyView(this.id),this.manager.appStatus.delete(this.id),null==(a=this.manager.refresher)||a.remove(this.id))}close(){return this.destroy(!0,!0,!1)}}class ne{constructor(e,t){this.manager=e,this.appBoxMap=new Map,this.mainView=this.manager.mainView,this.teleBoxManager=this.setupBoxManager(t),this.teleBoxManager.events.on(c.TELE_BOX_MANAGER_EVENT.State,(e=>{e&&(nt.emit("boxStateChange",e),rt.emit("boxStateChange",e))})),this.teleBoxManager.events.on("minimized",(e=>{this.manager.safeSetAttributes({minimized:e}),e&&(this.manager.store.cleanFocus(),this.blurAllBox())})),this.teleBoxManager.events.on("maximized",(e=>{this.manager.safeSetAttributes({maximized:e})})),this.teleBoxManager.events.on("removed",(e=>{e.forEach((e=>{rt.emit("close",{appId:e.id})}))})),this.teleBoxManager.events.on("intrinsic_move",r.debounce((e=>{rt.emit("move",{appId:e.id,x:e.intrinsicX,y:e.intrinsicY})}),50)),this.teleBoxManager.events.on("intrinsic_resize",r.debounce((e=>{rt.emit("resize",{appId:e.id,width:e.intrinsicWidth,height:e.intrinsicHeight})}),200)),this.teleBoxManager.events.on("focused",(e=>{e&&(this.manager.canOperate?rt.emit("focus",{appId:e.id}):this.teleBoxManager.blurBox(e.id))})),this.teleBoxManager.events.on("dark_mode",(e=>{nt.emit("darkModeChange",e)})),this.teleBoxManager.events.on("prefers_color_scheme",(e=>{nt.emit("prefersColorSchemeChange",e)})),this.teleBoxManager.events.on("z_index",(e=>{this.manager.store.updateAppState(e.id,I.ZIndex,e.zIndex)}))}get boxState(){return this.teleBoxManager.state}get maximized(){return this.teleBoxManager.maximized}get minimized(){return this.teleBoxManager.minimized}get darkMode(){return this.teleBoxManager.darkMode}get prefersColorScheme(){return this.teleBoxManager.prefersColorScheme}createBox(e){var t,i,s;if(!this.teleBoxManager)return;let{minwidth:a=N,minheight:r=D}=null!=(t=e.app.config)?t:{};const{width:n,height:o}=null!=(i=e.app.config)?i:{},h=(null==(s=e.options)?void 0:s.title)||e.appId,c=this.teleBoxManager.containerRect;a>1&&(a/=c.width),r>1&&(r/=c.height);const d={title:h,minWidth:a,minHeight:r,width:n,height:o,id:e.appId};this.teleBoxManager.create(d,e.smartPosition),rt.emit(`${e.appId}${p.WindowCreated}`)}setBoxInitState(e){const t=this.teleBoxManager.queryOne({id:e});t&&t.state===c.TELE_BOX_STATE.Maximized&&rt.emit("resize",{appId:e,x:t.x,y:t.y,width:t.intrinsicWidth,height:t.intrinsicHeight})}setupBoxManager(e){const t=ht.wrapper?ht.wrapper:document.body,i=t.getBoundingClientRect(),s={root:t,containerRect:{x:0,y:0,width:i.width,height:i.height},fence:!1,prefersColorScheme:null==e?void 0:e.prefersColorScheme},a=(null==e?void 0:e.collectorContainer)||ht.wrapper,r=__spreadValues(__spreadValues({},T),null==e?void 0:e.collectorStyles),n=new c.TeleBoxCollector({styles:r}).mount(a);s.collector=n;const o=new c.TeleBoxManager(s);return this.teleBoxManager&&this.teleBoxManager.destroy(),this.teleBoxManager=o,o}getBox(e){return this.teleBoxManager.queryOne({id:e})}closeBox(e,t=!1){return this.teleBoxManager.remove(e,t)}boxIsFocus(e){const t=this.getBox(e);return null==t?void 0:t.focus}getFocusBox(){return this.teleBoxManager.query({focus:!0})[0]}getTopBox(){const e=this.teleBoxManager.query();return r.maxBy(e,"zIndex")}updateBoxState(e){if(!e)return;const t=this.getBox(e.id);t&&(this.teleBoxManager.update(t.id,{x:e.x,y:e.y,width:e.width||.5,height:e.height||.5,zIndex:e.zIndex},!0),null!=e.maximized&&(this.teleBoxManager.setMaximized(Boolean(e.maximized),!0),this.teleBoxManager.setMinimized(Boolean(e.minimized),!0)),setTimeout((()=>{e.focus&&this.teleBoxManager.focusBox(t.id,!0)}),50),nt.emit("boxStateChange",this.teleBoxManager.state))}updateManagerRect(){var e;const t=null==(e=this.mainView.divElement)?void 0:e.getBoundingClientRect();if(t&&t.width>0&&t.height>0){const e={x:0,y:0,width:t.width,height:t.height};this.teleBoxManager.setContainerRect(e),this.manager.notifyContainerRectUpdate(this.teleBoxManager.containerRect)}}moveBox({appId:e,x:t,y:i}){this.teleBoxManager.update(e,{x:t,y:i},!0)}focusBox({appId:e},t=!0){this.teleBoxManager.focusBox(e,t)}resizeBox({appId:e,width:t,height:i,skipUpdate:s}){this.teleBoxManager.update(e,{width:t,height:i},s)}setBoxMinSize(e){this.teleBoxManager.update(e.appId,{minWidth:e.minWidth,minHeight:e.minHeight},!0)}setBoxTitle(e){this.teleBoxManager.update(e.appId,{title:e.title},!0)}blurAllBox(){this.teleBoxManager.blurAll()}updateAll(e){this.teleBoxManager.updateAll(e)}setMaximized(e){this.teleBoxManager.setMaximized(e,!0)}setMinimized(e,t=!0){this.teleBoxManager.setMinimized(e,t)}focusTopBox(){if(this.teleBoxManager.query().length>=1){const e=this.getTopBox();e&&this.focusBox({appId:e.id},!1)}}setReadonly(e){this.teleBoxManager.setReadonly(e)}setPrefersColorScheme(e){this.teleBoxManager.setPrefersColorScheme(e)}destroy(){this.teleBoxManager.destroy()}}class oe{constructor(){this.cameras=new Map,this.listeners=new Map,this.onListener=(e,t)=>{t.callbacks.on("onCameraUpdated",this.getOrCreateListener(e))},this.offListener=(e,t)=>{t.callbacks.off("onCameraUpdated",this.getOrCreateListener(e))}}setCamera(e,t){this.cameras.set(e,t)}getCamera(e){return this.cameras.get(e)}deleteCamera(e){this.cameras.delete(e)}recoverCamera(e,t){const i=this.cameras.get(e);i&&t&&t.moveCamera(__spreadProps(__spreadValues({},i),{animationMode:o.AnimationMode.Immediately}))}register(e,t){this.onListener(e,t),this.setCamera(e,t.camera)}unregister(e,t){t&&this.offListener(e,t),this.listeners.delete(e),this.deleteCamera(e)}async switchView(e,t,i){t&&(this.offListener(e,t),await i(),this.recoverCamera(e,t),this.onListener(e,t))}getOrCreateListener(e){let t=this.listeners.get(e);return t||(t=t=>{this.setCamera(e,t)},this.listeners.set(e,t),t)}}class he extends ae{constructor(e){super(e),this.views=new Map,this.mainViewProxy=this.manager.mainViewProxy,this.displayer=this.manager.displayer,setTimeout((()=>{var e;null==(e=this.manager.refresher)||e.add("focus",(()=>o.reaction((()=>this.store.focus),(e=>{e?this.switchAppToWriter(e):(this.switchMainViewToWriter(),this.context.blurFocusBox())}),{fireImmediately:!0})))}),100)}get currentScenePath(){return this.displayer.state.sceneState.scenePath}get mainView(){return this.mainViewProxy.view}createView(e){const t=ce(this.displayer);return R(t,o.ViewVisionMode.Freedom),this.views.set(e,t),t}destroyView(e){const t=this.views.get(e);t&&(this.releaseView(t),this.views.delete(e))}releaseView(e){e.didRelease||e.release()}getView(e){return this.views.get(e)}switchMainViewToWriter(){if(this.timer&&clearTimeout(this.timer),this.mainView.mode!==o.ViewVisionMode.Writable)return this.freedomAllViews(),new Promise(((e,t)=>{this.timer=window.setTimeout((()=>{try{const t=this.store.getMainViewScenePath();t&&(this.freedomAllViews(),O(this.manager.room,t),this.mainViewProxy.switchViewModeToWriter()),e(!0)}catch(i){t(i)}}),100)}))}freedomAllViews(){this.manager.appProxies.forEach((e=>{e.setViewFocusScenePath(),e.view&&R(e.view,o.ViewVisionMode.Freedom)})),this.mainView.mode===o.ViewVisionMode.Writable&&(Z(nt,o.ViewVisionMode.Freedom),R(this.mainView,o.ViewVisionMode.Freedom)),this.mainView.focusScenePath||this.store.setMainViewFocusPath()}switchAppToWriter(e){this.appTimer&&clearTimeout(this.appTimer),this.freedomAllViews(),this.appTimer=setTimeout((()=>{const t=this.manager.appProxies.get(e);if(t){if(this.manager.boxManager.minimized)return;t.setScenePath(),t.switchToWritable(),t.focusBox()}}),100)}destroy(){var e;this.mainViewProxy.removeMainViewListener(),ht.wrapper&&(null==(e=ht.wrapper.parentNode)||e.removeChild(ht.wrapper),ht.wrapper=void 0),this.releaseView(this.mainView)}}const ce=e=>{const t=e.views.createView();return de(t),t},de=e=>{e.setCameraBound({maxContentMode:()=>10,minContentMode:()=>.1})};class pe extends ae{constructor(e){super(e),this.cameraStore=this.manager.cameraStore,this.started=!1,this.mainViewIsAddListener=!1,this.viewId="mainView",this.cameraReaction=()=>o.reaction((()=>this.mainViewCamera),(e=>{e&&e.id!==this.context.uid&&(this.moveCameraToContian(this.mainViewSize),this.moveCamera(e))}),{fireImmediately:!0}),this.sizeChangeHandler=r.debounce((e=>{e&&(this.moveCameraToContian(e),this.moveCamera(this.mainViewCamera))}),30),this.onCameraUpdatedByDevice=e=>{this.store.setMainViewCamera(__spreadProps(__spreadValues({},e),{id:this.context.uid})),r.isEqual(this.mainViewSize,__spreadProps(__spreadValues({},this.mainView.size),{id:this.context.uid}))||this.setMainViewSize(this.view.size)},this.mainViewClickListener=()=>{this.mainViewClickHandler()},this.setMainViewSize=r.debounce((e=>{this.store.setMainViewSize(__spreadProps(__spreadValues({},e),{id:this.context.uid}))}),50),this.onCameraOrSizeUpdated=()=>{nt.emit("cameraStateChange",this.cameraState)},this.mainView=this.createMainView(),this.moveCameraSizeByAttributes(),this.cameraStore.register(this.viewId,this.mainView),rt.once("mainViewMounted").then((()=>{setTimeout((()=>{this.start(),this.mainViewCamera&&this.mainViewSize||this.setCameraAndSize()}),200)})),rt.on("playgroundSizeChange",(()=>{this.sizeChangeHandler(this.mainViewSize)}))}get mainViewCamera(){return this.store.getMainViewCamera()}get mainViewSize(){return this.store.getMainViewSize()}moveCameraSizeByAttributes(){this.moveCameraToContian(this.mainViewSize),this.moveCamera(this.mainViewCamera)}start(){var e;this.started||(this.sizeChangeHandler(this.mainViewSize),this.addCameraListener(),null==(e=this.manager.refresher)||e.add(q.MainViewCamera,this.cameraReaction),this.started=!0)}setCameraAndSize(){this.store.setMainViewCamera(__spreadProps(__spreadValues({},this.mainView.camera),{id:this.context.uid})),this.store.setMainViewSize(__spreadProps(__spreadValues({},this.mainView.size),{id:this.context.uid}))}get view(){return this.mainView}get cameraState(){return __spreadValues(__spreadValues({},this.view.camera),this.view.size)}createMainView(){const e=ce(this.manager.displayer),t=this.store.getMainViewScenePath();return t&&k(e,t),this.store.focus||this.switchViewModeToWriter(),e}addMainViewListener(){this.mainViewIsAddListener||this.view.divElement&&(this.view.divElement.addEventListener("click",this.mainViewClickListener),this.view.divElement.addEventListener("touchend",this.mainViewClickListener),this.mainViewIsAddListener=!0)}removeMainViewListener(){this.view.divElement&&(this.view.divElement.removeEventListener("click",this.mainViewClickListener),this.view.divElement.removeEventListener("touchend",this.mainViewClickListener))}async mainViewClickHandler(){this.manager.canOperate&&this.view.mode!==o.ViewVisionMode.Writable&&(this.store.cleanFocus(),this.context.blurFocusBox())}addCameraListener(){this.view.callbacks.on("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.on("onCameraUpdated",this.onCameraOrSizeUpdated),this.view.callbacks.on("onSizeUpdated",this.onCameraOrSizeUpdated)}removeCameraListener(){this.view.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.off("onCameraUpdated",this.onCameraOrSizeUpdated),this.view.callbacks.off("onSizeUpdated",this.onCameraOrSizeUpdated)}switchViewModeToWriter(){if(this.manager.canOperate&&this.view){if(this.view.mode===o.ViewVisionMode.Writable)return;this.cameraStore.switchView(this.viewId,this.mainView,(()=>{Z(nt,o.ViewVisionMode.Writable),R(this.view,o.ViewVisionMode.Writable)}))}}moveCameraToContian(e){r.isEmpty(e)||(this.view.moveCameraToContain({width:e.width,height:e.height,originX:-e.width/2,originY:-e.height/2,animationMode:o.AnimationMode.Immediately}),this.scale=this.view.camera.scale)}moveCamera(e){if(!r.isEmpty(e)){if(r.isEqual(e,this.view.camera))return;const{centerX:t,centerY:i,scale:s}=e,a=s*(this.scale||1);this.view.moveCamera({centerX:t,centerY:i,scale:a,animationMode:o.AnimationMode.Immediately})}}stop(){var e,t;this.removeCameraListener(),null==(e=this.manager.refresher)||e.remove(q.MainViewCamera),null==(t=this.manager.refresher)||t.remove(q.MainViewSize),this.started=!1}destroy(){this.stop(),this.cameraStore.unregister(this.viewId,this.mainView)}}const le=e=>(t,i)=>{if(void 0!==t){if(o.listenUpdated){const s=t=>{t.map((e=>e.kind)).includes(e)&&i()};return o.listenUpdated(t,s),i(),()=>o.unlistenUpdated(t,s)}return o.reaction((()=>t),(()=>{i()}),{fireImmediately:!0})}},ge=le(o.UpdateEventKind.Removed),ue=le(o.UpdateEventKind.Inserted);class me{constructor(e,t){this.manager=t,this.reactors=new Map,this.disposers=new Map,this.onPhaseChanged=e=>{e===o.RoomPhase.Connected&&this.phase===o.RoomPhase.Reconnecting&&this.onReconnected(),this.phase=e},this.onReconnected=()=>{te("onReconnected refresh reactors"),this.releaseDisposers(),this.reactors.forEach(((e,t)=>{r.isFunction(e)&&this.disposers.set(t,e())})),this.manager.notifyReconnected()},this.room=e,this.phase=null==e?void 0:e.phase,null==e||e.callbacks.on("onPhaseChanged",this.onPhaseChanged)}releaseDisposers(){this.disposers.forEach((e=>{r.isFunction(e)&&e()})),this.disposers.clear()}add(e,t){r.isFunction(t)&&(this.reactors.set(e,t),this.disposers.set(e,t()))}remove(e){this.reactors.has(e)&&this.reactors.delete(e);const t=this.disposers.get(e);t&&(r.isFunction(t)&&t(),this.disposers.delete(e))}destroy(){var e;null==(e=this.room)||e.callbacks.off("onPhaseChanged",this.onPhaseChanged),this.releaseDisposers()}}class Me{constructor(e,t){this.windowManger=e,this.appProxies=new Map,this.appStatus=new Map,this.store=new ee(this),this.isReplay=this.windowManger.isReplay,this.onAppDelete=e=>{const t=Object.keys(e);this.appProxies.forEach(((e,i)=>{t.includes(i)||e.destroy(!0,!1,!0)}))},this.displayerStateListener=e=>{var t,i;const s=e.sceneState;if(s){const e=s.scenePath;this.appProxies.forEach((t=>{t.scenePath&&e.startsWith(t.scenePath)&&(t.emitAppSceneStateChange(s),t.setFullPath(e))}))}e.roomMembers&&(null==(t=this.windowManger.cursorManager)||t.setRoomMembers(e.roomMembers),null==(i=this.windowManger.cursorManager)||i.cleanMemberAttributes(e.roomMembers)),this.appProxies.forEach((t=>{t.appEmitter.emit("roomStateChange",e)})),rt.emit("observerIdChange",this.displayer.observerId)},this.displayerWritableListener=e=>{const t=!e,i=void 0===this.windowManger.readonly||!1===this.windowManger.readonly;void 0===this.windowManger.readonly?this.boxManager.setReadonly(e):this.boxManager.setReadonly(!(t&&i)),this.appProxies.forEach((e=>{e.emitAppIsWritableChange()})),!0===t?(this.store.focus||this.mainViewProxy.switchViewModeToWriter(),this.mainView.disableCameraTransform=!1):this.mainView.disableCameraTransform=!0},this.boxEventListener=(e,t)=>{switch(e){case"move":this.dispatchInternalEvent(p.AppMove,t),this.store.updateAppState(t.appId,I.Position,{x:t.x,y:t.y});break;case"focus":this.windowManger.safeSetAttributes({focus:t.appId});break;case"resize":t.width&&t.height&&(this.dispatchInternalEvent(p.AppResize,t),this.store.updateAppState(t.appId,I.Size,{width:t.width,height:t.height}));break;case"close":{const e=this.appProxies.get(t.appId);e&&e.destroy(!1,!0,t.error);break}case"boxStateChange":this.dispatchInternalEvent(p.AppBoxStateChange,t)}},this.displayer=e.displayer,this.cameraStore=new oe,this.mainViewProxy=new pe(this),this.viewManager=new he(this),this.boxManager=new ne(this,t),this.appListeners=new G(this),this.displayer.callbacks.on(this.eventName,this.displayerStateListener),this.appListeners.addListeners(),this.refresher=new me(this.room,this),rt.once("onCreated").then((()=>this.onCreated())),o.isPlayer(this.displayer)&&rt.on("seek",(e=>{this.appProxies.forEach((t=>{t.onSeek(e)})),this.attributesUpdateCallback(this.attributes.apps),this.onAppDelete(this.attributes.apps)}))}async onCreated(){var e,t,i,s,a;if(await this.attributesUpdateCallback(this.attributes.apps),this.boxManager.updateManagerRect(),rt.onAny(this.boxEventListener),null==(e=this.refresher)||e.add("apps",(()=>((e,t)=>{let i=null;const s=o.reaction(e,(()=>{i&&(i(),i=null);const s=e();i=()=>o.unlistenUpdated(s,t),o.listenUpdated(s,t)}),{fireImmediately:!0});return()=>{null==i||i(),s()}})((()=>this.attributes.apps),(()=>{this.attributesUpdateCallback(this.attributes.apps)})))),null==(t=this.refresher)||t.add("appsClose",(()=>ge(this.attributes.apps,(()=>{this.onAppDelete(this.attributes.apps)})))),null==(i=this.refresher)||i.add("maximized",(()=>o.autorun((()=>{const e=this.attributes.maximized;this.boxManager.maximized!==e&&this.boxManager.setMaximized(Boolean(e))})))),null==(s=this.refresher)||s.add("minimized",(()=>o.autorun((()=>{const e=this.attributes.minimized;this.boxManager.minimized!==e&&(!0===e&&this.boxManager.blurAllBox(),this.boxManager.setMinimized(Boolean(e)))})))),!this.attributes.apps||0===Object.keys(this.attributes.apps).length){const e=this.store.getMainViewScenePath();if(!e)return;this.displayer.state.sceneState.scenePath!==e&&O(this.room,e)}this.displayerWritableListener(!(null==(a=this.room)?void 0:a.isWritable)),this.displayer.callbacks.on("onEnableWriteNowChanged",this.displayerWritableListener)}async attributesUpdateCallback(e){if(e)for(const t in e)if(!this.appProxies.has(t)&&!this.appStatus.has(t)){const i=e[t];M.default((async()=>{this.appStatus.set(t,x.StartCreate);if(!this.attributes[t])throw new Error("appAttributes is undefined");await this.baseInsertApp({kind:i.kind,options:i.options,isDynamicPPT:i.isDynamicPPT},t,!1),this.focusByAttributes(e)}),{retries:3}).catch((e=>{console.warn("[WindowManager]: Insert App Error",e),this.appStatus.delete(t)}))}}bindMainView(e,t){const i=this.mainViewProxy.view;i.disableCameraTransform=t,i.divElement=e,i.focusScenePath||this.store.setMainViewFocusPath(),void 0===this.store.focus&&i.mode!==o.ViewVisionMode.Writable&&this.viewManager.switchMainViewToWriter(),this.mainViewProxy.addMainViewListener(),rt.emit("mainViewMounted")}async addApp(e,t){te("addApp",e);const{appId:i,needFocus:s}=await this.beforeAddApp(e,t),a=await this.baseInsertApp(e,i,!0,s);return this.afterAddApp(a),null==a?void 0:a.id}async beforeAddApp(e,t){var i;const s=await(async e=>{var t,i;const s=await(null==(t=U.appClasses.get(e))?void 0:t());return s&&(null==(i=s.config)?void 0:i.singleton)?e:`${e}-${n.v4().replace("-","").slice(0,8)}`})(e.kind);this.appStatus.set(s,x.StartCreate);const a=null!=(i=e.attributes)?i:{};this.safeUpdateAttributes([s],a),this.store.setupAppAttributes(e,s,t);const r=!this.boxManager.minimized;return r&&this.store.setAppFocus(s,!0),{appId:s,needFocus:r}}afterAddApp(e){if(e&&e.box){const t=e.box;rt.emit("move",{appId:e.id,x:null==t?void 0:t.intrinsicX,y:null==t?void 0:t.intrinsicY}),this.store.updateAppState(e.id,I.ZIndex,t.zIndex)}this.boxManager.minimized&&this.boxManager.setMinimized(!1,!1)}async closeApp(e){const t=this.appProxies.get(e);t&&t.destroy(!0,!0,!1)}async baseInsertApp(e,t,i,s){if(this.appProxies.has(t))return void console.warn("[WindowManager]: app duplicate exists and cannot be created again");const a=new re(e,this,t,i);if(a)return await a.baseInsertApp(s),this.appStatus.delete(t),a;throw this.appStatus.delete(t),new Error("[WindowManger]: initialize AppProxy failed")}get eventName(){return o.isRoom(this.displayer)?"onRoomStateChanged":"onPlayerStateChanged"}get attributes(){return this.windowManger.attributes}get canOperate(){return this.windowManger.canOperate}get room(){return o.isRoom(this.displayer)?this.displayer:void 0}get mainView(){return this.mainViewProxy.view}get focusApp(){if(this.store.focus)return this.appProxies.get(this.store.focus)}safeSetAttributes(e){this.windowManger.safeSetAttributes(e)}safeUpdateAttributes(e,t){this.windowManger.safeUpdateAttributes(e,t)}async setMainViewScenePath(e){if(this.room){const t=this.displayer.scenePathType(e);if(t===o.ScenePathType.None)throw new Error(`[WindowManager]: ${e} not valid scene`);if(t===o.ScenePathType.Page)await this._setMainViewScenePath(e);else if(t===o.ScenePathType.Dir){const t=((e,t)=>{const i=e.entireScenes()[t][0].name;return"/"===t?`/${i}`:`${t}/${i}`})(this.displayer,e);await this._setMainViewScenePath(t)}}}async _setMainViewScenePath(e){this.safeSetAttributes({_mainScenePath:e}),await this.viewManager.switchMainViewToWriter(),O(this.room,e),this.store.setMainViewFocusPath(),this.dispatchInternalEvent(p.SetMainViewScenePath,{nextScenePath:e})}async setMainViewSceneIndex(e){if(this.room){this.safeSetAttributes({_mainSceneIndex:e}),await this.viewManager.switchMainViewToWriter(),this.room.setSceneIndex(e);const t=this.room.state.sceneState.scenePath;this.store.setMainViewScenePath(t),this.store.setMainViewFocusPath(),this.dispatchInternalEvent(p.SetMainViewScenePath,{nextScenePath:t})}}getAppInitPath(e){var t;const i=this.store.getAppAttributes(e);if(i)return null==(t=null==i?void 0:i.options)?void 0:t.scenePath}safeDispatchMagixEvent(e,t){this.canOperate&&this.displayer.dispatchMagixEvent(e,t)}focusByAttributes(e){if(e&&Object.keys(e).length===this.boxManager.appBoxMap.size){const e=this.store.focus;e&&this.boxManager.focusBox({appId:e})}}async notifyReconnected(){const e=Array.from(this.appProxies.values()).map((e=>e.onReconnected()));await Promise.all(e)}notifyContainerRectUpdate(e){this.appProxies.forEach((t=>{t.appEmitter.emit("containerRectUpdate",e)}))}dispatchInternalEvent(e,t){this.safeDispatchMagixEvent(w,{eventName:e,payload:t})}destroy(){var e;this.displayer.callbacks.off(this.eventName,this.displayerStateListener),this.displayer.callbacks.off("onEnableWriteNowChanged",this.displayerWritableListener),this.appListeners.removeListeners(),rt.offAny(this.boxEventListener),rt.clearListeners(),this.appProxies.size&&this.appProxies.forEach((e=>{e.destroy(!0,!1,!0)})),this.viewManager.destroy(),this.boxManager.destroy(),null==(e=this.refresher)||e.destroy(),this.mainViewProxy.destroy(),nt.clearListeners()}}function we(){}function Ie(e){return e()}function Ae(){return Object.create(null)}function ye(e){e.forEach(Ie)}function Ce(e){return"function"==typeof e}function xe(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let be,ve;function Se(e,t){return be||(be=document.createElement("a")),be.href=t,e===be.href}function Ne(e,t){e.appendChild(t)}function De(e,t,i){e.insertBefore(t,i||null)}function Te(e){e.parentNode.removeChild(e)}function fe(e){return document.createElement(e)}function je(e){return document.createTextNode(e)}function Ve(){return je(" ")}function Le(e,t,i){null==i?e.removeAttribute(t):e.getAttribute(t)!==i&&e.setAttribute(t,i)}function Pe(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ee(e,t,i,s){e.style.setProperty(t,i,s?"important":"")}function ze(e){ve=e}const Be=[],Ue=[],ke=[],Oe=[],Re=Promise.resolve();let Ze=!1;function Qe(e){ke.push(e)}let We=!1;const Ge=new Set;function Ye(){if(!We){We=!0;do{for(let e=0;e<Be.length;e+=1){const t=Be[e];ze(t),Fe(t.$$)}for(ze(null),Be.length=0;Ue.length;)Ue.pop()();for(let e=0;e<ke.length;e+=1){const t=ke[e];Ge.has(t)||(Ge.add(t),t())}ke.length=0}while(Be.length);for(;Oe.length;)Oe.pop()();Ze=!1,We=!1,Ge.clear()}}function Fe(e){if(null!==e.fragment){e.update(),ye(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(Qe)}}const He=new Set;function Xe(e,t){-1===e.$$.dirty[0]&&(Be.push(e),Ze||(Ze=!0,Re.then(Ye)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Je(e,t,i,s,a,r,n,o=[-1]){const h=ve;ze(e);const c=e.$$={fragment:null,ctx:null,props:r,update:we,not_equal:a,bound:Ae(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(h?h.$$.context:t.context||[]),callbacks:Ae(),dirty:o,skip_bound:!1,root:t.target||h.$$.root};n&&n(c.root);let d=!1;if(c.ctx=i?i(e,t.props||{},((t,i,...s)=>{const r=s.length?s[0]:i;return c.ctx&&a(c.ctx[t],c.ctx[t]=r)&&(!c.skip_bound&&c.bound[t]&&c.bound[t](r),d&&Xe(e,t)),i})):[],c.update(),d=!0,ye(c.before_update),c.fragment=!!s&&s(c.ctx),t.target){if(t.hydrate){const e=(g=t.target,Array.from(g.childNodes));c.fragment&&c.fragment.l(e),e.forEach(Te)}else c.fragment&&c.fragment.c();t.intro&&((p=e.$$.fragment)&&p.i&&(He.delete(p),p.i(l))),function(e,t,i,s){const{fragment:a,on_mount:r,on_destroy:n,after_update:o}=e.$$;a&&a.m(t,i),s||Qe((()=>{const t=r.map(Ie).filter(Ce);n?n.push(...t):ye(t),e.$$.on_mount=[]})),o.forEach(Qe)}(e,t.target,t.anchor,t.customElement),Ye()}var p,l,g;ze(h)}function _e(e){let t,i,s;return{c(){t=fe("img"),Le(t,"class","netless-window-manager-cursor-selector-avatar"),Le(t,"style",i=e[15]()),Se(t.src,s=e[7])||Le(t,"src",s),Le(t,"alt","avatar")},m(e,i){De(e,t,i)},p(e,i){128&i&&!Se(t.src,s=e[7])&&Le(t,"src",s)},d(e){e&&Te(t)}}}function Ke(e){let t,i;return{c(){t=fe("span"),i=je(e[1]),Le(t,"class","netless-window-manager-cursor-tag-name"),Ee(t,"background-color",e[10])},m(e,s){De(e,t,s),Ne(t,i)},p(e,s){2&s&&Pe(i,e[1]),1024&s&&Ee(t,"background-color",e[10])},d(e){e&&Te(t)}}}function qe(e){let t,i,s,a,r,n,o,h,c,d,p,l,g=e[13]&&_e(e),u=e[14]&&Ke(e);return{c(){t=fe("div"),i=fe("div"),s=fe("div"),g&&g.c(),a=Ve(),r=fe("span"),n=je(e[0]),o=Ve(),u&&u.c(),h=Ve(),c=fe("div"),d=fe("img"),Ee(r,"overflow","hidden"),Ee(r,"white-space","nowrap"),Ee(r,"text-overflow","ellipsis"),Ee(r,"max-width","80px"),Le(s,"class",e[8]),Ee(s,"background-color",e[2]),Ee(s,"color",e[9]),Ee(s,"opacity",e[11]),Le(i,"class","netless-window-manager-cursor-name"),Le(d,"class",p="netless-window-manager-cursor-"+e[3]+"-image"),Se(d.src,l=e[6])||Le(d,"src",l),Le(d,"alt",e[3]),Le(c,"class","cursor-image-wrapper"),Le(t,"class","netless-window-manager-cursor-mid"),Ee(t,"transform","translateX("+e[4]+"px) translateY("+e[5]+"px)"),Ee(t,"display",e[12])},m(e,p){De(e,t,p),Ne(t,i),Ne(i,s),g&&g.m(s,null),Ne(s,a),Ne(s,r),Ne(r,n),Ne(s,o),u&&u.m(s,null),Ne(t,h),Ne(t,c),Ne(c,d)},p(e,[i]){e[13]?g?g.p(e,i):(g=_e(e),g.c(),g.m(s,a)):g&&(g.d(1),g=null),1&i&&Pe(n,e[0]),e[14]?u?u.p(e,i):(u=Ke(e),u.c(),u.m(s,null)):u&&(u.d(1),u=null),256&i&&Le(s,"class",e[8]),4&i&&Ee(s,"background-color",e[2]),512&i&&Ee(s,"color",e[9]),2048&i&&Ee(s,"opacity",e[11]),8&i&&p!==(p="netless-window-manager-cursor-"+e[3]+"-image")&&Le(d,"class",p),64&i&&!Se(d.src,l=e[6])&&Le(d,"src",l),8&i&&Le(d,"alt",e[3]),48&i&&Ee(t,"transform","translateX("+e[4]+"px) translateY("+e[5]+"px)"),4096&i&&Ee(t,"display",e[12])},i:we,o:we,d(e){e&&Te(t),g&&g.d(),u&&u.d()}}}function $e(e,t,i){let s,a,n,o,{cursorName:h}=t,{tagName:c}=t,{backgroundColor:d}=t,{appliance:p}=t,{x:l}=t,{y:g}=t,{src:u}=t,{visible:m}=t,{avatar:M}=t,{theme:w}=t,{color:I}=t,{cursorTagBackgroundColor:A}=t,{opacity:y}=t;return e.$$set=e=>{"cursorName"in e&&i(0,h=e.cursorName),"tagName"in e&&i(1,c=e.tagName),"backgroundColor"in e&&i(2,d=e.backgroundColor),"appliance"in e&&i(3,p=e.appliance),"x"in e&&i(4,l=e.x),"y"in e&&i(5,g=e.y),"src"in e&&i(6,u=e.src),"visible"in e&&i(16,m=e.visible),"avatar"in e&&i(7,M=e.avatar),"theme"in e&&i(8,w=e.theme),"color"in e&&i(9,I=e.color),"cursorTagBackgroundColor"in e&&i(10,A=e.cursorTagBackgroundColor),"opacity"in e&&i(11,y=e.opacity)},e.$$.update=()=>{1&e.$$.dirty&&(s=!r.isEmpty(h)),2&e.$$.dirty&&i(14,a=!r.isEmpty(c)),128&e.$$.dirty&&i(13,n=!r.isEmpty(M)),65536&e.$$.dirty&&i(12,o=m?"initial":"none")},[h,c,d,p,l,g,u,M,w,I,A,y,o,n,a,()=>Object.entries({width:(s?19:28)+"px",height:(s?19:28)+"px",position:s?"initial":"absolute","border-color":s?"white":d,"margin-right":(s?4:0)+"px"}).map((([e,t])=>`${e}: ${t}`)).join(";"),m]}class et extends class{$destroy(){!function(e,t){const i=e.$$;null!==i.fragment&&(ye(i.on_destroy),i.fragment&&i.fragment.d(t),i.on_destroy=i.fragment=null,i.ctx=[])}(this,1),this.$destroy=we}$on(e,t){const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}{constructor(e){super(),Je(this,e,$e,qe,xe,{cursorName:0,tagName:1,backgroundColor:2,appliance:3,x:4,y:5,src:6,visible:16,avatar:7,theme:8,color:9,cursorTagBackgroundColor:10,opacity:11})}}const tt={[o.ApplianceNames.pencil]:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0Iau7V1dX3BDA/P6/V1dVpzc3N2uLiIofK1c8VYHys/wRKBUN3/hGHqaysNOjc3FwMis6hc0FtLTHuvYLxCCZgci8uLn4wg5Gh6Fy8Jk+/NkcCAlAAuUkoW4g0B+d5tLS05O/r67O8eGxsDNra2uDy8nKsoKCAwCIQDxQa0yTxgrvCYXyTk5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I0LDI3IEwxNiwyNyBDMTUuNDQ3NzE1MywyNyAxNSwyNi41NTIyODQ3IDE1LDI2IEMxNSwyNS41MTQ1ODk3IDE1LjM0Nzk5OTMsMjUuMTAxOTE1IDE1Ljg2NTQ4NzcsMjUuMDEwMDUyMSBMMTYsMjUgTDE5LDI1IFoiIGZpbGw9IiMyMTIzMjQiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PC9wYXRoPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4="};class it extends ae{constructor(e,t,i,s,a){super(e),this.cursors=t,this.memberId=i,this.cursorManager=s,this.wrapper=a,this.setMember(),this.createCursor(),M.default((()=>{this.disposer&&this.disposer(),this.cursorPosition||console.warn(`${i} not exist`),this.startReaction()}),{retries:3}),this.autoHidden()}startReaction(){this.disposer=o.autorun((()=>{var e;const t=this.cursorPosition,i=this.cursorState;if(t){if("main"===t.type){const e=this.cursorManager.wrapperRect;this.component&&e&&(this.autoHidden(),this.moveCursor(t,e,this.manager.mainView))}else{const i=this.cursorManager.focusView,s=null==(e=null==i?void 0:i.divElement)?void 0:e.getBoundingClientRect(),a=null==i?void 0:i.camera;i&&s&&a&&this.component&&(this.autoHidden(),this.moveCursor(t,s,i))}i&&i===b.Leave&&this.hide()}}))}moveCursor(e,t,i){var s,a;const{x:r,y:n}=e,o=null==i?void 0:i.screen.convertPointToScreen(r,n);if(o){const e=o.x+t.x-2,i=o.y+t.y-18;o.x<0||o.x>t.width||o.y<0||o.y>t.height?null==(s=this.component)||s.$set({visible:!1}):null==(a=this.component)||a.$set({visible:!0,x:e,y:i})}}get memberApplianceName(){var e,t;return null==(t=null==(e=this.member)?void 0:e.memberState)?void 0:t.currentApplianceName}get memberColor(){var e,t;return`rgb(${null==(t=null==(e=this.member)?void 0:e.memberState)?void 0:t.strokeColor.join(",")})`}get payload(){var e;return null==(e=this.member)?void 0:e.payload}get memberCursorName(){var e,t;return(null==(e=this.payload)?void 0:e.nickName)||(null==(t=this.payload)?void 0:t.cursorName)||this.memberId}get memberTheme(){var e;return(null==(e=this.payload)?void 0:e.theme)?"netless-window-manager-cursor-inner-mellow":"netless-window-manager-cursor-inner"}get memberCursorTextColor(){var e;return(null==(e=this.payload)?void 0:e.cursorTextColor)||"#FFFFFF"}get memberCursorTagBackgroundColor(){var e;return(null==(e=this.payload)?void 0:e.cursorTagBackgroundColor)||this.memberColor}get memberAvatar(){var e;return null==(e=this.payload)?void 0:e.avatar}get memberOpacity(){return this.memberCursorName||this.memberAvatar?1:0}get cursorState(){return r.get(this.cursors,[this.memberId,q.CursorState])}get cursorPosition(){return r.get(this.cursors,[this.memberId,q.Position])}autoHidden(){this.timer&&clearTimeout(this.timer),this.timer=window.setTimeout((()=>{this.hide(),this.store.updateCursorState(this.memberId,b.Leave)}),1e4)}async createCursor(){this.member&&this.wrapper&&(this.component=new et({target:document.documentElement,props:this.initProps()}))}initProps(){return{x:0,y:0,appliance:this.memberApplianceName,avatar:this.memberAvatar,src:this.getIcon(),visible:!1,backgroundColor:this.memberColor,cursorName:this.memberCursorName,theme:this.memberTheme,color:this.memberCursorTextColor,cursorTagBackgroundColor:this.memberCursorTagBackgroundColor,opacity:this.memberOpacity}}getIcon(){if(this.member){return tt[this.memberApplianceName||o.ApplianceNames.shape]||tt[o.ApplianceNames.shape]}}setMember(){this.member=this.context.findMemberByUid(this.memberId),this.updateComponent()}updateComponent(){var e;null==(e=this.component)||e.$set(r.omit(this.initProps(),["x","y"]))}destroy(){this.disposer&&this.disposer(),this.component&&this.component.$destroy(),this.cursorManager.cursorInstances.delete(this.memberId)}hide(){this.component&&this.component.$set({visible:!1})}}class st extends ae{constructor(e){var t;super(e),this.appManager=e,this.cursorInstances=new Map,this.getUids=e=>r.compact(r.uniq(null==e?void 0:e.map((e=>{var t;return null==(t=e.payload)?void 0:t.uid})))),this.handleRoomMembersChange=r.debounce((e=>{const t=this.getUids(this.roomMembers),i=Object.keys(this.cursors);(null==t?void 0:t.length)&&i.map((i=>{if(t.includes(i)&&!this.cursorInstances.has(i)){if(i===this.context.uid)return;const t=new it(this.appManager,this.cursors,i,this,e);this.cursorInstances.set(i,t)}}))}),100),this.mouseMoveListener=r.debounce((e=>{this.updateCursor(this.getType(e),e.clientX,e.clientY)}),5),this.touchMoveListener=r.debounce((e=>{if(1===e.touches.length){const t=e.touches[0];this.updateCursor(this.getType(t),t.clientX,t.clientY)}}),5),this.getPoint=(e,t,i)=>{var s;const a=null==(s=null==e?void 0:e.divElement)?void 0:s.getBoundingClientRect();if(a){return null==e?void 0:e.convertToPointInWorld({x:t-a.x,y:i-a.y})}},this.getType=e=>{var t;const i=e.target,s=this.appManager.focusApp;switch(i.parentElement){case this.mainViewElement:return{type:"main"};case null==(t=null==s?void 0:s.view)?void 0:t.divElement:return{type:"app"};default:return{type:"main"}}},this.mouseLeaveListener=()=>{this.hideCursor(this.context.uid),this.store.updateCursorState(this.context.uid,b.Leave)},this.roomMembers=null==(t=this.appManager.room)?void 0:t.state.roomMembers;const i=ht.wrapper;i&&(i.addEventListener("mousemove",this.mouseMoveListener),i.addEventListener("touchstart",this.touchMoveListener),i.addEventListener("touchmove",this.touchMoveListener),i.addEventListener("mouseleave",this.mouseLeaveListener),i.addEventListener("touchend",this.mouseLeaveListener),this.initCursorAttributes(),this.wrapperRect=i.getBoundingClientRect(),this.startReaction(i))}setMainViewDivElement(e){this.mainViewElement=e}startReaction(e){var t;null==(t=this.manager.refresher)||t.add("cursors",(()=>ue(this.cursors,(()=>{this.handleRoomMembersChange(e)}))))}get cursors(){var e;return null==(e=this.manager.attributes)?void 0:e[q.Cursors]}get boxState(){return this.store.getBoxState()}get focusView(){var e;return null==(e=this.appManager.focusApp)?void 0:e.view}updateCursor(e,t,i){if(this.wrapperRect&&this.manager.canOperate){const s="main"===e.type?this.appManager.mainView:this.focusView,a=this.getPoint(s,t,i);a&&(this.setNormalCursorState(),this.store.updateCursor(this.context.uid,__spreadValues({x:a.x,y:a.y},e)))}}initCursorAttributes(){this.store.updateCursor(this.context.uid,{x:0,y:0,type:"main"}),this.store.updateCursorState(this.context.uid,b.Leave)}setNormalCursorState(){this.store.getCursorState(this.context.uid)!==b.Normal&&this.store.updateCursorState(this.context.uid,b.Normal)}updateContainerRect(){var e,t;this.containerRect=null==(e=ht.container)?void 0:e.getBoundingClientRect(),this.wrapperRect=null==(t=ht.wrapper)?void 0:t.getBoundingClientRect()}setRoomMembers(e){this.roomMembers=e,this.cursorInstances.forEach((e=>{e.setMember()})),ht.wrapper&&this.handleRoomMembersChange(ht.wrapper)}deleteCursor(e){this.store.cleanCursor(e);const t=this.cursorInstances.get(e);t&&t.destroy()}hideCursor(e){const t=this.cursorInstances.get(e);t&&t.hide()}cleanMemberAttributes(e){const t=this.getUids(e),i=[];Object.keys(this.cursors).map((e=>{-1===t.findIndex((t=>t===e))&&i.push(e)})),i.forEach((e=>{this.deleteCursor(e)}))}destroy(){var e;const t=ht.wrapper;t&&(t.removeEventListener("mousemove",this.mouseMoveListener),t.removeEventListener("touchstart",this.touchMoveListener),t.removeEventListener("touchmove",this.touchMoveListener),t.removeEventListener("mouseleave",this.mouseLeaveListener),t.removeEventListener("touchend",this.mouseLeaveListener)),this.cursorInstances.size&&(this.cursorInstances.forEach((e=>e.destroy())),this.cursorInstances.clear()),null==(e=this.manager.refresher)||e.remove("cursors")}}const at=window.ResizeObserver||h.ResizeObserver,rt=new m.default,nt=new m.default,ot=class extends o.InvisiblePlugin{constructor(e){super(e),this.version="0.3.17-canary.2",this.emitter=nt,this.viewMode=o.ViewMode.Broadcaster,this.isReplay=o.isPlayer(this.displayer)}static async mount(e,t,s,a){let r,n,h,c,d,p,l=!0,g=!1,u="light";if("room"in e?(r=e.room,t=e.container,s=e.collectorContainer,n=e.containerSizeRatio,h=e.collectorStyles,c=e.debug,null!=e.chessboard&&(l=e.chessboard),d=e.overwriteStyles,p=e.cursor,g=Boolean(null==e?void 0:e.disableCameraTransform),u=e.prefersColorScheme):(r=e,n=null==a?void 0:a.containerSizeRatio,h=null==a?void 0:a.collectorStyles,c=null==a?void 0:a.debug,null!=(null==a?void 0:a.chessboard)&&(l=a.chessboard),d=null==a?void 0:a.overwriteStyles),this.checkVersion(),o.isRoom(r)&&r.phase!==o.RoomPhase.Connected)throw new Error("[WindowManager]: Room only Connected can be mount");if(!t)throw new Error("[WindowManager]: Container must provide");if(ot.isCreated)throw new Error("[WindowManager]: Already created cannot be created again");let m=await this.initManager(r);if(this.debug=Boolean(c),this.debug&&i.setOptions({verbose:!0}),te("Already insert room",m),o.isRoom(this.displayer)){if(!m)throw new Error("[WindowManager]: init InvisiblePlugin failed")}else await M.default((async e=>{if(m=await this.initManager(r),!m)throw te(`manager is empty. retrying ${e}`),new Error}),{retries:10});n&&(ot.containerSizeRatio=n),ot.container=t;const{playground:w,wrapper:I,sizer:A,mainViewElement:y}=(e=>{const t=document.createElement("div");t.className="netless-window-manager-playground";const i=document.createElement("div");i.className="netless-window-manager-sizer";const s=document.createElement("div");s.className="netless-window-manager-wrapper";const a=document.createElement("div");return a.className="netless-window-manager-main-view",t.appendChild(i),i.appendChild(s),s.appendChild(a),e.appendChild(t),ht.wrapper=s,{playground:t,wrapper:s,sizer:i,mainViewElement:a}})(t);if(ot.playground=w,l&&A.classList.add("netless-window-manager-chess-sizer"),d){const e=document.createElement("style");e.textContent=d,w.appendChild(e)}await m.ensureAttributes(),m.appManager=new Me(m,{collectorContainer:s,collectorStyles:h,prefersColorScheme:u}),m.observePlaygroundSize(w,A,I),p&&(m.cursorManager=new st(m.appManager)),m.bindMainView(y,g),((e,t)=>{if(o.isPlayer(e)){const t=e,i=t.seekToProgressTime;async function s(e){const s=await i.call(t,e);return"success"===s&&rt.emit("seek",e),s}t.seekToProgressTime=s}else{if(Object.getOwnPropertyDescriptor(e,"disableCameraTransform"))return;Object.defineProperty(e,"disableCameraTransform",{get:()=>t.mainView.disableCameraTransform,set(e){t.mainView.disableCameraTransform=e}}),e.moveCamera=e=>t.mainView.moveCamera(e),e.moveCameraToContain=(...e)=>t.mainView.moveCameraToContain(...e),e.convertToPointInWorld=(...e)=>t.mainView.convertToPointInWorld(...e),e.setCameraBound=(...e)=>t.mainView.setCameraBound(...e),e.scenePreview=(...e)=>t.mainView.scenePreview(...e),e.fillSceneSnapshot=(...e)=>t.mainView.fillSceneSnapshot(...e),e.generateScreenshot=(...e)=>t.mainView.generateScreenshot(...e)}})(r,m.appManager),rt.emit("onCreated"),ot.isCreated=!0;try{await L()}catch(C){console.warn("[WindowManager]: indexedDB open failed"),console.log(C)}return m}static async initManager(e){let t=e.getInvisiblePlugin(ot.kind);if(!t&&o.isRoom(e))if(!1===e.isWritable){try{await e.setWritable(!0)}catch(i){throw new Error("[WindowManger]: room must be switched to be writable")}t=await e.createInvisiblePlugin(ot,{}),t.ensureAttributes(),await W(500),await e.setWritable(!1)}else t=await e.createInvisiblePlugin(ot,{});return t}static register(e){return U.register(e)}async addApp(e){var t,i,s,a;if(this.appManager){if(!e.kind||"string"!=typeof e.kind)throw new X;const r=await(null==(t=U.appClasses.get(e.kind))?void 0:t());if(r&&(null==(i=r.config)?void 0:i.singleton)&&this.appManager.appProxies.has(e.kind))throw new Y;const n=this.setupScenePath(e,this.appManager);if(void 0===n)return;(null==(s=null==e?void 0:e.options)?void 0:s.scenePath)&&(e.options.scenePath=(a=e.options.scenePath).endsWith("/")?a.slice(0,-1):a);return await this.appManager.addApp(e,Boolean(n))}throw new F}setupScenePath(e,t){var i,s,a;let r=!1;if(e.options){const{scenePath:n,scenes:o}=e.options;if(n){if(!(e=>e.startsWith("/"))(n))throw new _;const e=Object.keys(this.apps||{});for(const i of e){const e=t.store.getAppScenePath(i);if(e&&e===n)return void console.warn(`[WindowManager]: ScenePath ${n} Already opened`)}}n&&o&&o.length>0&&(this.isDynamicPPT(o)?(r=!0,this.displayer.entireScenes()[n]||null==(i=this.room)||i.putScenes(n,o)):this.displayer.entireScenes()[n]||null==(s=this.room)||s.putScenes(n,[{name:o[0].name}])),n&&void 0===o&&(null==(a=this.room)||a.putScenes(n,[{}]))}return r}async setMainViewScenePath(e){this.appManager&&await this.appManager.setMainViewScenePath(e)}async setMainViewSceneIndex(e){this.appManager&&await this.appManager.setMainViewSceneIndex(e)}getMainViewScenePath(){var e;return null==(e=this.appManager)?void 0:e.store.getMainViewScenePath()}getMainViewSceneIndex(){var e;return null==(e=this.appManager)?void 0:e.store.getMainViewSceneIndex()}setReadonly(e){var t,i;(null==(t=this.room)?void 0:t.isWritable)&&(this.readonly=e,null==(i=this.appManager)||i.boxManager.setReadonly(e))}switchMainViewToWriter(){var e;return null==(e=this.appManager)?void 0:e.mainViewProxy.mainViewClickHandler()}onAppDestroy(e,t){((e,t)=>{rt.once(e).then(t)})(`destroy-${e}`,t)}setViewMode(e){var t,i,s;this.canOperate&&(e===o.ViewMode.Broadcaster&&(null==(t=this.appManager)||t.mainViewProxy.setCameraAndSize(),null==(i=this.appManager)||i.mainViewProxy.start()),e===o.ViewMode.Freedom&&(null==(s=this.appManager)||s.mainViewProxy.stop()),this.viewMode=e)}get mainView(){if(this.appManager)return this.appManager.mainViewProxy.view;throw new F}get camera(){if(this.appManager)return this.appManager.mainViewProxy.view.camera;throw new F}get cameraState(){if(this.appManager)return this.appManager.mainViewProxy.cameraState;throw new F}get apps(){var e;return null==(e=this.appManager)?void 0:e.store.apps()}get boxState(){if(this.appManager)return this.appManager.boxManager.boxState;throw new F}get darkMode(){var e;return Boolean(null==(e=this.appManager)?void 0:e.boxManager.darkMode)}get prefersColorScheme(){if(this.appManager)return this.appManager.boxManager.prefersColorScheme;throw new F}queryAll(){var e;return Array.from((null==(e=this.appManager)?void 0:e.appProxies.values())||[])}queryOne(e){var t;return null==(t=this.appManager)?void 0:t.appProxies.get(e)}async closeApp(e){var t;return null==(t=this.appManager)?void 0:t.closeApp(e)}moveCamera(e){this.mainView.moveCamera(e)}moveCameraToContain(e){this.mainView.moveCameraToContain(e)}convertToPointInWorld(e){return this.mainView.convertToPointInWorld(e)}setCameraBound(e){this.mainView.setCameraBound(e)}onDestroy(){this._destroy()}destroy(){this._destroy()}_destroy(){var e,t,i,s;null==(e=this.containerResizeObserver)||e.disconnect(),null==(t=this.appManager)||t.destroy(),null==(i=this.cursorManager)||i.destroy(),ot.container=void 0,ot.wrapper=void 0,ot.isCreated=!1,ot.playground&&(null==(s=ot.playground.parentNode)||s.removeChild(ot.playground)),te("Destroyed")}bindMainView(e,t){var i;this.appManager&&(this.appManager.bindMainView(e,t),null==(i=this.cursorManager)||i.setMainViewDivElement(e))}get canOperate(){return!!o.isRoom(this.displayer)&&(this.displayer.isWritable&&this.displayer.phase===o.RoomPhase.Connected)}get room(){return this.displayer}safeSetAttributes(e){this.canOperate&&this.setAttributes(e)}safeUpdateAttributes(e,t){this.canOperate&&this.updateAttributes(e,t)}setPrefersColorScheme(e){var t;null==(t=this.appManager)||t.boxManager.setPrefersColorScheme(e)}isDynamicPPT(e){var t,i;const s=null==(i=null==(t=e[0])?void 0:t.ppt)?void 0:i.src;return null==s?void 0:s.startsWith("pptx://")}static checkVersion(){if(Q(o.WhiteVersion)<Q(S))throw new H(S)}async ensureAttributes(){if(r.isNull(this.attributes)&&await W(50),r.isObject(this.attributes)){this.attributes[q.Apps]||this.safeSetAttributes({[q.Apps]:{}}),this.attributes[q.Cursors]||this.safeSetAttributes({[q.Cursors]:{}});const e=this.displayer.state.sceneState;this.attributes._mainScenePath||this.safeSetAttributes({_mainScenePath:e.scenePath}),this.attributes._mainSceneIndex||this.safeSetAttributes({_mainSceneIndex:e.index})}}observePlaygroundSize(e,t,i){this.updateSizer(e.getBoundingClientRect(),t,i),this.containerResizeObserver=new at((e=>{var s,a,r;const n=null==(s=e[0])?void 0:s.contentRect;n&&(this.updateSizer(n,t,i),null==(a=this.cursorManager)||a.updateContainerRect(),null==(r=this.appManager)||r.boxManager.updateManagerRect(),rt.emit("playgroundSizeChange",n))})),this.containerResizeObserver.observe(e)}updateSizer({width:e,height:t},i,s){e&&t&&(t/e>ot.containerSizeRatio?(t=e*ot.containerSizeRatio,i.classList.toggle("netless-window-manager-sizer-horizontal",!0)):(e=t/ot.containerSizeRatio,i.classList.toggle("netless-window-manager-sizer-horizontal",!1)),s.style.width=`${e}px`,s.style.height=`${t}px`)}};let ht=ot;ht.kind="WindowManager",ht.debug=!1,ht.containerSizeRatio=9/16,ht.isCreated=!1,ht.register({kind:g.default.kind,src:g.default}),ht.register({kind:u.default.kind,src:u.default});const ct={DocsViewer:g.default.kind,MediaPlayer:u.default.kind};e.BuiltinApps=ct,e.WhiteWindowSDK=class{constructor(e){this.sdk=new o.WhiteWebSdk(__spreadProps(__spreadValues({},e),{useMobXState:!0}))}async mount(e){const t=e.joinRoomParams.invisiblePlugins||[],i=await this.sdk.joinRoom(__spreadProps(__spreadValues({},e.joinRoomParams),{useMultiViews:!0,invisiblePlugins:[...t,ht],disableMagixEventDispatchLimit:!0})),s=await ht.mount(__spreadValues({room:i},e.mountParams));return r.isBoolean(e.joinRoomParams.disableCameraTransform)&&(s.mainView.disableCameraTransform=e.joinRoomParams.disableCameraTransform),s}},e.WindowManager=ht,e.callbacks=nt,e.emitter=rt,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"}));
1
+ var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__spreadValues=(e,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(e,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(e,i,t[i]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@netless/app-docs-viewer"),require("@netless/app-media-player"),require("emittery"),require("p-retry"),require("lodash"),require("uuid"),require("white-web-sdk"),require("@juggle/resize-observer"),require("@netless/telebox-insider")):"function"==typeof define&&define.amd?define(["exports","@netless/app-docs-viewer","@netless/app-media-player","emittery","p-retry","lodash","uuid","white-web-sdk","@juggle/resize-observer","@netless/telebox-insider"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).WindowManager={},e.AppDocsViewer,e.AppMediaPlayer,e.Emittery,e.pRetry,e.lodash,e.uuid,e.whiteWebSdk,e.resizeObserver,e.teleboxInsider)}(this,(function(e,t,i,s,a,r,n,o,h,c){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p,l,g=d(t),u=d(i),m=d(s),M=d(a);(l=p||(p={})).AppMove="AppMove",l.AppFocus="AppFocus",l.AppResize="AppResize",l.AppBoxStateChange="AppBoxStateChange",l.GetAttributes="GetAttributes",l.UpdateWindowManagerWrapper="UpdateWindowManagerWrapper",l.InitReplay="InitReplay",l.WindowCreated="WindowCreated",l.SetMainViewScenePath="SetMainViewScenePath",l.SetMainViewSceneIndex="SetMainViewSceneIndex",l.SwitchViewsToFreedom="SwitchViewsToFreedom";const w="__WindowManger";var I,A,y,C,x,b,v;(A=I||(I={})).Size="size",A.Position="position",A.SceneIndex="SceneIndex",A.ZIndex="zIndex",(C=y||(y={})).setBoxSize="setBoxSize",C.setBoxMinSize="setBoxMinSize",C.destroy="destroy",(x||(x={})).StartCreate="StartCreate",(v=b||(b={})).Leave="leave",v.Normal="normal";const S="2.13.16",N=340/720,D=340/720,T={right:"10px",bottom:"15px",position:"absolute"},f="__WindowManagerAppCache";let j,V;const L=async()=>{j=await new Promise(((e,t)=>{const i=indexedDB.open(f,2);i.onerror=e=>{t(e)},i.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains("apps")||(V=t.createObjectStore("apps",{keyPath:"kind"}),V.createIndex("kind","kind",{unique:!0}))},i.onsuccess=()=>{const t=i.result;e(t)}}))},P=(e,t)=>{var i,s;if(j)return i=j,s={kind:e,sourceCode:t},new Promise(((e,t)=>{const a=i.transaction(["apps"],"readwrite").objectStore("apps").add(s);a.onsuccess=()=>e(),a.onerror=()=>t()}))},E=async e=>{return j?await(t=j,i=e,new Promise(((e,s)=>{const a=t.transaction(["apps"]).objectStore("apps").index("kind").get(i);a.onerror=e=>s(e),a.onsuccess=()=>{a.result?e(a.result):e(null)}}))):null;var t,i};const z=async e=>{const t=await E(e);if(t)return t;{const t=await async function(e,t){const{timeout:i=1e4}=t,s=new AbortController,a=setTimeout((()=>s.abort()),i),r=await fetch(e,__spreadProps(__spreadValues({},t),{signal:s.signal,headers:{"content-type":"text/plain"}}));return clearTimeout(a),r}(e,{timeout:1e4}),i=await t.text();return await P(e,i),i}},B=(e,t)=>{let i=Function(e+`;return ${t}`)();return void 0===i&&(i=window[t]),i};const U=new class{constructor(){this.kindEmitters=new Map,this.registered=new Map,this.appClassesCache=new Map,this.appClasses=new Map}async register(e){this.registered.set(e.kind,e);const t=e.src;let i;if(i="string"==typeof t?async()=>{const i=await(async(e,t,i)=>{const s=i||"NetlessApp"+t,a=await z(e);try{return B(a,s)}catch(r){if(r.message.includes("Can only have one anonymous define call per script file")){const e=window.define;return"function"==typeof e&&e.amd&&delete e.amd,B(a,s)}}})(t,e.kind);if(i)return i;throw new Error(`[WindowManager]: load remote script failed, ${t}`)}:"function"==typeof t?t:async()=>t,this.appClasses.set(e.kind,(async()=>{let t=this.appClassesCache.get(e.kind);return t||(t=i(),this.appClassesCache.set(e.kind,t)),t})),e.addHooks){const t=this.createKindEmitter(e.kind);t&&e.addHooks(t)}}async notifyApp(e,t,i){const s=this.kindEmitters.get(e);await(null==s?void 0:s.emit(t,i))}createKindEmitter(e){if(!this.kindEmitters.has(e)){const t=new m.default;this.kindEmitters.set(e,t)}return this.kindEmitters.get(e)}},k=(e,t)=>{e.focusScenePath!==t&&(e.focusScenePath=t)},O=(e,t)=>{e&&e.isWritable&&e.state.sceneState.scenePath!==t&&e.setScenePath(t)},R=(e,t)=>{e.didRelease||e.mode===t||(e.mode=t)},Z=r.debounce(((e,t)=>{e.emit("mainViewModeChange",t)}),200),Q=e=>{const t=e.split(".").map((e=>e.padStart(2,"0"))).join("");return parseInt(t)},W=e=>new Promise((t=>setTimeout(t,e)));class G{constructor(e){this.manager=e,this.displayer=this.manager.displayer,this.boxManager=this.manager.boxManager,this.mainMagixEventListener=e=>{if(e.authorId!==this.displayer.observerId){const t=e.payload;switch(t.eventName){case p.AppMove:this.appMoveHandler(t.payload);break;case p.AppResize:this.appResizeHandler(t.payload);break;case p.SwitchViewsToFreedom:this.switchViewsToFreedomHandler();break;case p.AppBoxStateChange:this.boxStateChangeHandler(t.payload);break;case p.SetMainViewScenePath:this.setMainViewScenePathHandler(t.payload)}}},this.appMoveHandler=e=>{this.boxManager.moveBox(e)},this.appResizeHandler=e=>{var t;this.boxManager.resizeBox(Object.assign(e,{skipUpdate:!0})),null==(t=this.manager.room)||t.refreshViewSize()},this.switchViewsToFreedomHandler=()=>{this.manager.viewManager.freedomAllViews()},this.boxStateChangeHandler=e=>{nt.emit("boxStateChange",e)},this.setMainViewScenePathHandler=({nextScenePath:e})=>{k(this.manager.mainView,e)}}addListeners(){this.displayer.addMagixEventListener(w,this.mainMagixEventListener)}removeListeners(){this.displayer.removeMagixEventListener(w,this.mainMagixEventListener)}}class Y extends Error{constructor(){super(...arguments),this.message="[WindowManager]: app duplicate exists and cannot be created again"}}class F extends Error{constructor(){super(...arguments),this.message="[WindowManager]: AppManager must be initialized"}}class H extends Error{constructor(e){super(`[WindowManager]: white-web-sdk version must large than ${e}`)}}class X extends Error{constructor(){super(...arguments),this.message="[WindowManager]: kind must be a valid string"}}class J extends Error{constructor(){super(...arguments),this.message="[WindowManager]: box need created"}}class _ extends Error{constructor(){super(...arguments),this.message='[WindowManager]: ScenePath should start with "/"'}}class K{constructor(e,t,i,s){this.manager=e,this.appId=t,this.appProxy=i,this.appOptions=s,this.mobxUtils={autorun:o.autorun,reaction:o.reaction,toJS:o.toJS},this.objectUtils={listenUpdated:o.listenUpdated,unlistenUpdated:o.unlistenUpdated,listenDisposed:o.listenDisposed,unlistenDisposed:o.unlistenDisposed},this.store=this.manager.store,this.isReplay=this.manager.isReplay,this.emitter=i.appEmitter,this.boxManager=this.manager.boxManager,this.isAddApp=i.isAddApp}getDisplayer(){return this.manager.displayer}getAttributes(){return this.appProxy.attributes}getScenes(){const e=this.store.getAppAttributes(this.appId);if(!(null==e?void 0:e.isDynamicPPT))return null==e?void 0:e.options.scenes;{const e=this.manager.appProxies.get(this.appId);if(e)return e.scenes}}getView(){return this.appProxy.view}getInitScenePath(){return this.manager.getAppInitPath(this.appId)}getIsWritable(){return this.manager.canOperate}getBox(){const e=this.boxManager.getBox(this.appId);if(e)return e;throw new J}getRoom(){return this.manager.room}setAttributes(e){this.manager.safeSetAttributes({[this.appId]:e})}updateAttributes(e,t){this.manager.attributes[this.appId]&&this.manager.safeUpdateAttributes([this.appId,...e],t)}async setScenePath(e){this.appProxy.box&&(this.appProxy.setFullPath(e),this.appProxy.context.switchAppToWriter(this.appId))}mountView(e){const t=this.getView();t&&(t.divElement=e,setTimeout((()=>{var e;null==(e=this.getRoom())||e.refreshViewSize()}),1e3))}getAppOptions(){return"function"==typeof this.appOptions?this.appOptions():this.appOptions}}var q,$;($=q||(q={})).Apps="apps",$.Focus="focus",$.State="state",$.BoxState="boxState",$.MainViewCamera="mainViewCamera",$.MainViewSize="mainViewSize",$.Broadcaster="broadcaster",$.Cursors="cursors",$.Position="position",$.CursorState="cursorState",$.FullPath="fullPath";class ee{constructor(e){this.manager=e}apps(){return r.get(this.manager.attributes,[q.Apps])}get focus(){return r.get(this.manager.attributes,[q.Focus])}getAppAttributes(e){return r.get(this.apps(),[e])}getAppState(e){return r.get(this.apps(),[e,q.State])}getMaximized(){return r.get(this.manager.attributes,["maximized"])}setupAppAttributes(e,t,i){this.manager.attributes.apps||this.manager.safeSetAttributes({apps:{}});const s=["scenePath","title"];i||s.push("scenes");const a=r.pick(e.options,s),n={kind:e.kind,options:a,isDynamicPPT:i};"string"==typeof e.src&&(n.src=e.src),this.manager.safeUpdateAttributes([q.Apps,t],n),this.manager.safeUpdateAttributes([q.Apps,t,q.State],{[I.Size]:{},[I.Position]:{},[I.SceneIndex]:0,[I.ZIndex]:100})}updateAppState(e,t,i){r.get(this.manager.attributes,[q.Apps,e,q.State])&&this.manager.safeUpdateAttributes([q.Apps,e,q.State,t],i)}cleanAppAttributes(e){this.manager.safeUpdateAttributes([q.Apps,e],void 0),this.manager.safeSetAttributes({[e]:void 0});this.manager.attributes[q.Focus]===e&&this.cleanFocus()}cleanFocus(){this.manager.safeSetAttributes({[q.Focus]:void 0})}getAppSceneIndex(e){var t;return null==(t=this.getAppState(e))?void 0:t[I.SceneIndex]}getAppScenePath(e){var t,i;return null==(i=null==(t=this.getAppAttributes(e))?void 0:t.options)?void 0:i.scenePath}getMainViewScenePath(){return this.manager.attributes._mainScenePath}getMainViewSceneIndex(){return this.manager.attributes._mainSceneIndex}getBoxState(){return this.manager.attributes[q.BoxState]}setMainViewScenePath(e){this.manager.safeSetAttributes({_mainScenePath:e})}setMainViewSceneIndex(e){this.manager.safeSetAttributes({_mainSceneIndex:e})}getMainViewCamera(){return r.get(this.manager.attributes,[q.MainViewCamera])}getMainViewSize(){return r.get(this.manager.attributes,[q.MainViewSize])}setMainViewCamera(e){this.manager.safeSetAttributes({[q.MainViewCamera]:__spreadValues({},e)})}setMainViewSize(e){this.manager.safeSetAttributes({[q.MainViewSize]:__spreadValues({},e)})}setAppFocus(e,t){t?this.manager.safeSetAttributes({[q.Focus]:e}):this.manager.safeSetAttributes({[q.Focus]:void 0})}updateCursor(e,t){r.get(this.manager.attributes,[q.Cursors])||this.manager.safeUpdateAttributes([q.Cursors],{}),r.get(this.manager.attributes,[q.Cursors,e])||this.manager.safeUpdateAttributes([q.Cursors,e],{}),this.manager.safeUpdateAttributes([q.Cursors,e,q.Position],t)}updateCursorState(e,t){r.get(this.manager.attributes,[q.Cursors,e])||this.manager.safeUpdateAttributes([q.Cursors,e],{}),this.manager.safeUpdateAttributes([q.Cursors,e,q.CursorState],t)}getCursorState(e){return r.get(this.manager.attributes,[q.Cursors,e,q.CursorState])}cleanCursor(e){this.manager.safeUpdateAttributes([q.Cursors,e],void 0)}setMainViewFocusPath(){const e=this.getMainViewScenePath();e&&k(this.manager.mainView,e)}}const te=(...e)=>{ht.debug&&console.log("[WindowManager]:",...e)};class ie{constructor(e){this.manager=e,this.findMember=e=>{var t;const i=null==(t=this.manager.room)?void 0:t.state.roomMembers;return null==i?void 0:i.find((t=>t.memberId===e))},this.findMemberByUid=e=>{var t;const i=null==(t=this.manager.room)?void 0:t.state.roomMembers;return null==i?void 0:i.find((t=>{var i;return(null==(i=t.payload)?void 0:i.uid)===e}))},this.observerId=e.displayer.observerId,rt.on("observerIdChange",(e=>{this.observerId=e}))}get uid(){var e;return(null==(e=this.manager.room)?void 0:e.uid)||""}updateManagerRect(){this.manager.boxManager.updateManagerRect()}blurFocusBox(){this.manager.boxManager.blurAllBox()}switchAppToWriter(e){this.manager.viewManager.switchAppToWriter(e)}}let se;class ae{constructor(e){this.manager=e,this.store=new ee(this.manager),this.context=(e=>(se||(se=new ie(e)),se))(this.manager)}}class re extends ae{constructor(e,t,i,s){var a;super(t),this.params=e,this.boxManager=this.manager.boxManager,this.appProxies=this.manager.appProxies,this.viewManager=this.manager.viewManager,this.cameraStore=this.manager.cameraStore,this.status="normal",this.getAppInitState=e=>{var t,i;const s=this.store.getAppState(e);if(!s)return;const a=null==s?void 0:s[I.Position],r=this.store.focus,n=null==s?void 0:s[I.Size],o=null==s?void 0:s[I.SceneIndex];let h={maximized:null==(t=this.attributes)?void 0:t.maximized,minimized:null==(i=this.attributes)?void 0:i.minimized,zIndex:null==s?void 0:s.zIndex};return a&&(h=__spreadProps(__spreadValues({},h),{id:e,x:a.x,y:a.y})),r===e&&(h=__spreadProps(__spreadValues({},h),{focus:!0})),n&&(h=__spreadProps(__spreadValues({},h),{width:n.width,height:n.height})),o&&(h=__spreadProps(__spreadValues({},h),{sceneIndex:o})),h},this.appAttributesUpdateListener=e=>{var t;null==(t=this.manager.refresher)||t.add(e,(()=>o.autorun((()=>{const t=this.manager.attributes[e];t&&this.appEmitter.emit("attributesUpdate",t)}))))},this.kind=e.kind,this.id=i,this.appProxies.set(this.id,this),this.appEmitter=new m.default,this.appListener=this.makeAppEventListener(this.id),this.isAddApp=s,this.initScenes(),(null==(a=this.params.options)?void 0:a.scenePath)&&this.createView()}initScenes(){var e;const t=this.params.options;t&&(this.scenePath=t.scenePath,(null==(e=this.appAttributes)?void 0:e.isDynamicPPT)&&this.scenePath?this.scenes=this.manager.displayer.entireScenes()[this.scenePath]:this.scenes=t.scenes)}get view(){return this.manager.viewManager.getView(this.id)}get isWritable(){var e;return this.manager.canOperate&&!(null==(e=this.box)?void 0:e.readonly)}get attributes(){return this.manager.attributes[this.id]}get appAttributes(){return this.store.getAppAttributes(this.id)}getFullScenePath(){if(this.scenePath)return r.get(this.appAttributes,[q.FullPath],this.scenePath)}setFullPath(e){this.manager.safeUpdateAttributes(["apps",this.id,q.FullPath],e)}async baseInsertApp(e=!1,t){var i;const s=this.params;if(!s.kind)throw new Error("[WindowManager]: kind require");const a=await(null==(i=U.appClasses.get(s.kind))?void 0:i()),r=U.registered.get(s.kind);if(!a)throw new Error(`[WindowManager]: app load failed ${s.kind} ${s.src}`);return await this.setupApp(this.id,e,a,s.options,null==r?void 0:r.appOptions),this.context.updateManagerRect(),t&&this.focusApp(),{appId:this.id,app:a}}focusApp(){this.focusBox(),this.context.switchAppToWriter(this.id),this.store.setMainViewFocusPath()}get box(){return this.boxManager.getBox(this.id)}focusBox(){this.boxManager.focusBox({appId:this.id})}async setupApp(e,t,i,s,a){te("setupApp",e,i,s);const r=new K(this.manager,e,this,a);try{rt.once(`${e}${p.WindowCreated}`).then((async()=>{let s;t||(s=this.getAppInitState(e),this.boxManager.updateBoxState(s)),this.appEmitter.onAny(this.appListener),this.appAttributesUpdateListener(e),this.setViewFocusScenePath(),setTimeout((async()=>{const t=await i.setup(r);U.notifyApp(i.kind,"created",{appId:e,result:t}),this.afterSetupApp(s),this.fixMobileSize()}),50)})),this.boxManager.createBox({appId:e,app:i,options:s,canOperate:this.manager.canOperate,smartPosition:this.isAddApp})}catch(n){throw console.error(n),new Error(`[WindowManager]: app setup error: ${n.message}`)}}fixMobileSize(){const e=this.boxManager.getBox(this.id);e&&this.boxManager.resizeBox({appId:this.id,width:e.intrinsicWidth+.001,height:e.intrinsicHeight+.001,skipUpdate:!0})}afterSetupApp(e){e&&(e.focus&&this.scenePath&&this.context.switchAppToWriter(this.id),(null==e?void 0:e.x)&&e.y||this.boxManager.setBoxInitState(this.id))}onSeek(e){this.appEmitter.emit("seek",e);const t=this.getAppInitState(this.id);this.boxManager.updateBoxState(t)}async onReconnected(){this.appEmitter.emit("reconnected",void 0);const e=this.getAppInitState(this.id);await this.destroy(!0,!1,!0);const t=this.params,i=new re(t,this.manager,this.id,this.isAddApp);await i.baseInsertApp(!0,this.store.focus===this.id),this.boxManager.updateBoxState(e)}switchToWritable(){U.notifyApp(this.kind,"focus",{appId:this.id}),this.cameraStore.switchView(this.id,this.view,(()=>{if(this.view){if(this.view.mode===o.ViewVisionMode.Writable)return;try{this.manager.mainView.mode===o.ViewVisionMode.Writable&&(this.store.setMainViewFocusPath(),Z(nt,o.ViewVisionMode.Freedom),R(this.manager.mainView,o.ViewVisionMode.Freedom)),R(this.view,o.ViewVisionMode.Writable)}catch(e){te("switch view failed",e)}}}))}emitAppSceneStateChange(e){this.appEmitter.emit("sceneStateChange",e)}emitAppIsWritableChange(){this.appEmitter.emit("writableChange",this.isWritable)}makeAppEventListener(e){return(t,i)=>{if(this.manager.canOperate)switch(t){case"setBoxSize":this.boxManager.resizeBox({appId:e,width:i.width,height:i.height,skipUpdate:!1});break;case"setBoxMinSize":this.boxManager.setBoxMinSize({appId:e,minWidth:i.minwidth,minHeight:i.minheight});break;case"setBoxTitle":this.boxManager.setBoxTitle({appId:e,title:i.title});break;case y.destroy:if("destroyed"===this.status)return;this.destroy(!0,!1,!0,null==i?void 0:i.error),(null==i?void 0:i.error)&&console.error(null==i?void 0:i.error);break;case"focus":this.boxManager.focusBox({appId:this.id}),rt.emit("focus",{appId:this.id})}}}setScenePath(){if(!this.manager.canOperate)return;const e=this.getFullScenePath();this.manager.room&&e&&this.view&&O(this.manager.room,e)}setViewFocusScenePath(){const e=this.getFullScenePath();e&&this.view&&k(this.view,e)}async createView(){const e=await this.viewManager.createView(this.id);return this.cameraStore.register(this.id,e),this.setViewFocusScenePath(),e}async destroy(e,t,i,s){var a;"destroyed"!==this.status&&(this.status="destroyed",await U.notifyApp(this.kind,"destroy",{appId:this.id}),await this.appEmitter.emit("destroy",{error:s}),this.appEmitter.clearListeners(),rt.emit(`destroy-${this.id}`,{error:s}),e&&this.boxManager.closeBox(this.id,i),t&&this.store.cleanAppAttributes(this.id),this.appProxies.delete(this.id),this.cameraStore.unregister(this.id,this.view),this.viewManager.destroyView(this.id),this.manager.appStatus.delete(this.id),null==(a=this.manager.refresher)||a.remove(this.id))}close(){return this.destroy(!0,!0,!1)}}class ne{constructor(e,t){this.manager=e,this.appBoxMap=new Map,this.mainView=this.manager.mainView,this.teleBoxManager=this.setupBoxManager(t),this.teleBoxManager.events.on(c.TELE_BOX_MANAGER_EVENT.State,(e=>{e&&(nt.emit("boxStateChange",e),rt.emit("boxStateChange",e))})),this.teleBoxManager.events.on("minimized",(e=>{this.manager.safeSetAttributes({minimized:e}),e&&(this.manager.store.cleanFocus(),this.blurAllBox())})),this.teleBoxManager.events.on("maximized",(e=>{this.manager.safeSetAttributes({maximized:e})})),this.teleBoxManager.events.on("removed",(e=>{e.forEach((e=>{rt.emit("close",{appId:e.id})}))})),this.teleBoxManager.events.on("intrinsic_move",r.debounce((e=>{rt.emit("move",{appId:e.id,x:e.intrinsicX,y:e.intrinsicY})}),50)),this.teleBoxManager.events.on("intrinsic_resize",r.debounce((e=>{rt.emit("resize",{appId:e.id,width:e.intrinsicWidth,height:e.intrinsicHeight})}),200)),this.teleBoxManager.events.on("focused",(e=>{e&&(this.manager.canOperate?rt.emit("focus",{appId:e.id}):this.teleBoxManager.blurBox(e.id))})),this.teleBoxManager.events.on("dark_mode",(e=>{nt.emit("darkModeChange",e)})),this.teleBoxManager.events.on("prefers_color_scheme",(e=>{nt.emit("prefersColorSchemeChange",e)})),this.teleBoxManager.events.on("z_index",(e=>{this.manager.store.updateAppState(e.id,I.ZIndex,e.zIndex)}))}get boxState(){return this.teleBoxManager.state}get maximized(){return this.teleBoxManager.maximized}get minimized(){return this.teleBoxManager.minimized}get darkMode(){return this.teleBoxManager.darkMode}get prefersColorScheme(){return this.teleBoxManager.prefersColorScheme}createBox(e){var t,i,s;if(!this.teleBoxManager)return;let{minwidth:a=N,minheight:r=D}=null!=(t=e.app.config)?t:{};const{width:n,height:o}=null!=(i=e.app.config)?i:{},h=(null==(s=e.options)?void 0:s.title)||e.appId,c=this.teleBoxManager.containerRect;a>1&&(a/=c.width),r>1&&(r/=c.height);const d={title:h,minWidth:a,minHeight:r,width:n,height:o,id:e.appId};this.teleBoxManager.create(d,e.smartPosition),rt.emit(`${e.appId}${p.WindowCreated}`)}setBoxInitState(e){const t=this.teleBoxManager.queryOne({id:e});t&&t.state===c.TELE_BOX_STATE.Maximized&&rt.emit("resize",{appId:e,x:t.x,y:t.y,width:t.intrinsicWidth,height:t.intrinsicHeight})}setupBoxManager(e){const t=ht.wrapper?ht.wrapper:document.body,i=t.getBoundingClientRect(),s={root:t,containerRect:{x:0,y:0,width:i.width,height:i.height},fence:!1,prefersColorScheme:null==e?void 0:e.prefersColorScheme},a=(null==e?void 0:e.collectorContainer)||ht.wrapper,r=__spreadValues(__spreadValues({},T),null==e?void 0:e.collectorStyles),n=new c.TeleBoxCollector({styles:r}).mount(a);s.collector=n;const o=new c.TeleBoxManager(s);return this.teleBoxManager&&this.teleBoxManager.destroy(),this.teleBoxManager=o,o}getBox(e){return this.teleBoxManager.queryOne({id:e})}closeBox(e,t=!1){return this.teleBoxManager.remove(e,t)}boxIsFocus(e){const t=this.getBox(e);return null==t?void 0:t.focus}getFocusBox(){return this.teleBoxManager.query({focus:!0})[0]}getTopBox(){const e=this.teleBoxManager.query();return r.maxBy(e,"zIndex")}updateBoxState(e){if(!e)return;const t=this.getBox(e.id);t&&(this.teleBoxManager.update(t.id,{x:e.x,y:e.y,width:e.width||.5,height:e.height||.5,zIndex:e.zIndex},!0),null!=e.maximized&&(this.teleBoxManager.setMaximized(Boolean(e.maximized),!0),this.teleBoxManager.setMinimized(Boolean(e.minimized),!0)),setTimeout((()=>{e.focus&&this.teleBoxManager.focusBox(t.id,!0)}),50),nt.emit("boxStateChange",this.teleBoxManager.state))}updateManagerRect(){var e;const t=null==(e=this.mainView.divElement)?void 0:e.getBoundingClientRect();if(t&&t.width>0&&t.height>0){const e={x:0,y:0,width:t.width,height:t.height};this.teleBoxManager.setContainerRect(e),this.manager.notifyContainerRectUpdate(this.teleBoxManager.containerRect)}}moveBox({appId:e,x:t,y:i}){this.teleBoxManager.update(e,{x:t,y:i},!0)}focusBox({appId:e},t=!0){this.teleBoxManager.focusBox(e,t)}resizeBox({appId:e,width:t,height:i,skipUpdate:s}){this.teleBoxManager.update(e,{width:t,height:i},s)}setBoxMinSize(e){this.teleBoxManager.update(e.appId,{minWidth:e.minWidth,minHeight:e.minHeight},!0)}setBoxTitle(e){this.teleBoxManager.update(e.appId,{title:e.title},!0)}blurAllBox(){this.teleBoxManager.blurAll()}updateAll(e){this.teleBoxManager.updateAll(e)}setMaximized(e){this.teleBoxManager.setMaximized(e,!0)}setMinimized(e,t=!0){this.teleBoxManager.setMinimized(e,t)}focusTopBox(){if(this.teleBoxManager.query().length>=1){const e=this.getTopBox();e&&this.focusBox({appId:e.id},!1)}}setReadonly(e){this.teleBoxManager.setReadonly(e)}setPrefersColorScheme(e){this.teleBoxManager.setPrefersColorScheme(e)}destroy(){this.teleBoxManager.destroy()}}class oe{constructor(){this.cameras=new Map,this.listeners=new Map,this.onListener=(e,t)=>{t.callbacks.on("onCameraUpdated",this.getOrCreateListener(e))},this.offListener=(e,t)=>{t.callbacks.off("onCameraUpdated",this.getOrCreateListener(e))}}setCamera(e,t){this.cameras.set(e,t)}getCamera(e){return this.cameras.get(e)}deleteCamera(e){this.cameras.delete(e)}recoverCamera(e,t){const i=this.cameras.get(e);i&&t&&t.moveCamera(__spreadProps(__spreadValues({},i),{animationMode:o.AnimationMode.Immediately}))}register(e,t){this.onListener(e,t),this.setCamera(e,t.camera)}unregister(e,t){t&&this.offListener(e,t),this.listeners.delete(e),this.deleteCamera(e)}async switchView(e,t,i){t&&(this.offListener(e,t),await i(),this.recoverCamera(e,t),this.onListener(e,t))}getOrCreateListener(e){let t=this.listeners.get(e);return t||(t=t=>{this.setCamera(e,t)},this.listeners.set(e,t),t)}}class he extends ae{constructor(e){super(e),this.views=new Map,this.mainViewProxy=this.manager.mainViewProxy,this.displayer=this.manager.displayer,setTimeout((()=>{var e;null==(e=this.manager.refresher)||e.add("focus",(()=>o.reaction((()=>this.store.focus),(e=>{e?this.switchAppToWriter(e):(this.switchMainViewToWriter(),this.context.blurFocusBox())}),{fireImmediately:!0})))}),100)}get currentScenePath(){return this.displayer.state.sceneState.scenePath}get mainView(){return this.mainViewProxy.view}createView(e){const t=ce(this.displayer);return R(t,o.ViewVisionMode.Freedom),this.views.set(e,t),t}destroyView(e){const t=this.views.get(e);t&&(this.releaseView(t),this.views.delete(e))}releaseView(e){e.didRelease||e.release()}getView(e){return this.views.get(e)}switchMainViewToWriter(){if(this.timer&&clearTimeout(this.timer),this.mainView.mode!==o.ViewVisionMode.Writable)return this.freedomAllViews(),new Promise(((e,t)=>{this.timer=window.setTimeout((()=>{try{const t=this.store.getMainViewScenePath();t&&(this.freedomAllViews(),O(this.manager.room,t),this.mainViewProxy.switchViewModeToWriter()),e(!0)}catch(i){t(i)}}),100)}))}freedomAllViews(){this.manager.appProxies.forEach((e=>{e.setViewFocusScenePath(),e.view&&R(e.view,o.ViewVisionMode.Freedom)})),this.mainView.mode===o.ViewVisionMode.Writable&&(Z(nt,o.ViewVisionMode.Freedom),R(this.mainView,o.ViewVisionMode.Freedom)),this.mainView.focusScenePath||this.store.setMainViewFocusPath()}switchAppToWriter(e){this.appTimer&&clearTimeout(this.appTimer),this.freedomAllViews(),this.appTimer=setTimeout((()=>{const t=this.manager.appProxies.get(e);if(t){if(this.manager.boxManager.minimized)return;t.setScenePath(),t.switchToWritable(),t.focusBox()}}),100)}destroy(){var e;this.mainViewProxy.removeMainViewListener(),ht.wrapper&&(null==(e=ht.wrapper.parentNode)||e.removeChild(ht.wrapper),ht.wrapper=void 0),this.releaseView(this.mainView)}}const ce=e=>{const t=e.views.createView();return de(t),t},de=e=>{e.setCameraBound({maxContentMode:()=>10,minContentMode:()=>.1})};class pe extends ae{constructor(e){super(e),this.cameraStore=this.manager.cameraStore,this.started=!1,this.mainViewIsAddListener=!1,this.viewId="mainView",this.cameraReaction=()=>o.reaction((()=>this.mainViewCamera),(e=>{e&&e.id!==this.context.uid&&(this.moveCameraToContian(this.mainViewSize),this.moveCamera(e))}),{fireImmediately:!0}),this.sizeChangeHandler=r.debounce((e=>{e&&(this.moveCameraToContian(e),this.moveCamera(this.mainViewCamera))}),30),this.onCameraUpdatedByDevice=e=>{this.store.setMainViewCamera(__spreadProps(__spreadValues({},e),{id:this.context.uid})),r.isEqual(this.mainViewSize,__spreadProps(__spreadValues({},this.mainView.size),{id:this.context.uid}))||this.setMainViewSize(this.view.size)},this.mainViewClickListener=()=>{this.mainViewClickHandler()},this.setMainViewSize=r.debounce((e=>{this.store.setMainViewSize(__spreadProps(__spreadValues({},e),{id:this.context.uid}))}),50),this.onCameraOrSizeUpdated=()=>{nt.emit("cameraStateChange",this.cameraState)},this.mainView=this.createMainView(),this.moveCameraSizeByAttributes(),this.cameraStore.register(this.viewId,this.mainView),rt.once("mainViewMounted").then((()=>{setTimeout((()=>{this.start(),this.mainViewCamera&&this.mainViewSize||this.setCameraAndSize()}),200)})),rt.on("playgroundSizeChange",(()=>{this.sizeChangeHandler(this.mainViewSize)}))}get mainViewCamera(){return this.store.getMainViewCamera()}get mainViewSize(){return this.store.getMainViewSize()}moveCameraSizeByAttributes(){this.moveCameraToContian(this.mainViewSize),this.moveCamera(this.mainViewCamera)}start(){var e;this.started||(this.sizeChangeHandler(this.mainViewSize),this.addCameraListener(),null==(e=this.manager.refresher)||e.add(q.MainViewCamera,this.cameraReaction),this.started=!0)}setCameraAndSize(){this.store.setMainViewCamera(__spreadProps(__spreadValues({},this.mainView.camera),{id:this.context.uid})),this.store.setMainViewSize(__spreadProps(__spreadValues({},this.mainView.size),{id:this.context.uid}))}get view(){return this.mainView}get cameraState(){return __spreadValues(__spreadValues({},this.view.camera),this.view.size)}createMainView(){const e=ce(this.manager.displayer),t=this.store.getMainViewScenePath();return t&&k(e,t),this.store.focus||this.switchViewModeToWriter(),e}addMainViewListener(){this.mainViewIsAddListener||this.view.divElement&&(this.view.divElement.addEventListener("click",this.mainViewClickListener),this.view.divElement.addEventListener("touchend",this.mainViewClickListener),this.mainViewIsAddListener=!0)}removeMainViewListener(){this.view.divElement&&(this.view.divElement.removeEventListener("click",this.mainViewClickListener),this.view.divElement.removeEventListener("touchend",this.mainViewClickListener))}async mainViewClickHandler(){this.manager.canOperate&&this.view.mode!==o.ViewVisionMode.Writable&&(this.store.cleanFocus(),this.context.blurFocusBox())}addCameraListener(){this.view.callbacks.on("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.on("onCameraUpdated",this.onCameraOrSizeUpdated),this.view.callbacks.on("onSizeUpdated",this.onCameraOrSizeUpdated)}removeCameraListener(){this.view.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),this.view.callbacks.off("onCameraUpdated",this.onCameraOrSizeUpdated),this.view.callbacks.off("onSizeUpdated",this.onCameraOrSizeUpdated)}switchViewModeToWriter(){if(this.manager.canOperate&&this.view){if(this.view.mode===o.ViewVisionMode.Writable)return;this.cameraStore.switchView(this.viewId,this.mainView,(()=>{Z(nt,o.ViewVisionMode.Writable),R(this.view,o.ViewVisionMode.Writable)}))}}moveCameraToContian(e){r.isEmpty(e)||(this.view.moveCameraToContain({width:e.width,height:e.height,originX:-e.width/2,originY:-e.height/2,animationMode:o.AnimationMode.Immediately}),this.scale=this.view.camera.scale)}moveCamera(e){if(!r.isEmpty(e)){if(r.isEqual(e,this.view.camera))return;const{centerX:t,centerY:i,scale:s}=e,a=s*(this.scale||1);this.view.moveCamera({centerX:t,centerY:i,scale:a,animationMode:o.AnimationMode.Immediately})}}stop(){var e,t;this.removeCameraListener(),null==(e=this.manager.refresher)||e.remove(q.MainViewCamera),null==(t=this.manager.refresher)||t.remove(q.MainViewSize),this.started=!1}destroy(){this.stop(),this.cameraStore.unregister(this.viewId,this.mainView)}}const le=e=>(t,i)=>{if(void 0!==t){if(o.listenUpdated){const s=t=>{t.map((e=>e.kind)).includes(e)&&i()};return o.listenUpdated(t,s),i(),()=>o.unlistenUpdated(t,s)}return o.reaction((()=>t),(()=>{i()}),{fireImmediately:!0})}},ge=le(o.UpdateEventKind.Removed),ue=le(o.UpdateEventKind.Inserted);class me{constructor(e,t){this.manager=t,this.reactors=new Map,this.disposers=new Map,this.onPhaseChanged=e=>{e===o.RoomPhase.Connected&&this.phase===o.RoomPhase.Reconnecting&&this.onReconnected(),this.phase=e},this.onReconnected=()=>{te("onReconnected refresh reactors"),this.releaseDisposers(),this.reactors.forEach(((e,t)=>{r.isFunction(e)&&this.disposers.set(t,e())})),this.manager.notifyReconnected()},this.room=e,this.phase=null==e?void 0:e.phase,null==e||e.callbacks.on("onPhaseChanged",this.onPhaseChanged)}releaseDisposers(){this.disposers.forEach((e=>{r.isFunction(e)&&e()})),this.disposers.clear()}add(e,t){r.isFunction(t)&&(this.reactors.set(e,t),this.disposers.set(e,t()))}remove(e){this.reactors.has(e)&&this.reactors.delete(e);const t=this.disposers.get(e);t&&(r.isFunction(t)&&t(),this.disposers.delete(e))}destroy(){var e;null==(e=this.room)||e.callbacks.off("onPhaseChanged",this.onPhaseChanged),this.releaseDisposers()}}class Me{constructor(e,t){this.windowManger=e,this.appProxies=new Map,this.appStatus=new Map,this.store=new ee(this),this.isReplay=this.windowManger.isReplay,this.onAppDelete=e=>{const t=Object.keys(e);this.appProxies.forEach(((e,i)=>{t.includes(i)||e.destroy(!0,!1,!0)}))},this.displayerStateListener=e=>{var t,i;const s=e.sceneState;if(s){const e=s.scenePath;this.appProxies.forEach((t=>{t.scenePath&&e.startsWith(t.scenePath)&&(t.emitAppSceneStateChange(s),t.setFullPath(e))}))}e.roomMembers&&(null==(t=this.windowManger.cursorManager)||t.setRoomMembers(e.roomMembers),null==(i=this.windowManger.cursorManager)||i.cleanMemberAttributes(e.roomMembers)),this.appProxies.forEach((t=>{t.appEmitter.emit("roomStateChange",e)})),rt.emit("observerIdChange",this.displayer.observerId)},this.displayerWritableListener=e=>{const t=!e,i=void 0===this.windowManger.readonly||!1===this.windowManger.readonly;void 0===this.windowManger.readonly?this.boxManager.setReadonly(e):this.boxManager.setReadonly(!(t&&i)),this.appProxies.forEach((e=>{e.emitAppIsWritableChange()})),!0===t?(this.store.focus||this.mainViewProxy.switchViewModeToWriter(),this.mainView.disableCameraTransform=!1):this.mainView.disableCameraTransform=!0},this.boxEventListener=(e,t)=>{switch(e){case"move":this.dispatchInternalEvent(p.AppMove,t),this.store.updateAppState(t.appId,I.Position,{x:t.x,y:t.y});break;case"focus":this.windowManger.safeSetAttributes({focus:t.appId});break;case"resize":t.width&&t.height&&(this.dispatchInternalEvent(p.AppResize,t),this.store.updateAppState(t.appId,I.Size,{width:t.width,height:t.height}));break;case"close":{const e=this.appProxies.get(t.appId);e&&e.destroy(!1,!0,t.error);break}case"boxStateChange":this.dispatchInternalEvent(p.AppBoxStateChange,t)}},this.displayer=e.displayer,this.cameraStore=new oe,this.mainViewProxy=new pe(this),this.viewManager=new he(this),this.boxManager=new ne(this,t),this.appListeners=new G(this),this.displayer.callbacks.on(this.eventName,this.displayerStateListener),this.appListeners.addListeners(),this.refresher=new me(this.room,this),rt.once("onCreated").then((()=>this.onCreated())),o.isPlayer(this.displayer)&&rt.on("seek",(e=>{this.appProxies.forEach((t=>{t.onSeek(e)})),this.attributesUpdateCallback(this.attributes.apps),this.onAppDelete(this.attributes.apps)}))}async onCreated(){var e,t,i,s,a;if(await this.attributesUpdateCallback(this.attributes.apps),this.boxManager.updateManagerRect(),rt.onAny(this.boxEventListener),null==(e=this.refresher)||e.add("apps",(()=>((e,t)=>{let i=null;const s=o.reaction(e,(()=>{i&&(i(),i=null);const s=e();i=()=>o.unlistenUpdated(s,t),o.listenUpdated(s,t)}),{fireImmediately:!0});return()=>{null==i||i(),s()}})((()=>this.attributes.apps),(()=>{this.attributesUpdateCallback(this.attributes.apps)})))),null==(t=this.refresher)||t.add("appsClose",(()=>ge(this.attributes.apps,(()=>{this.onAppDelete(this.attributes.apps)})))),null==(i=this.refresher)||i.add("maximized",(()=>o.autorun((()=>{const e=this.attributes.maximized;this.boxManager.maximized!==e&&this.boxManager.setMaximized(Boolean(e))})))),null==(s=this.refresher)||s.add("minimized",(()=>o.autorun((()=>{const e=this.attributes.minimized;this.boxManager.minimized!==e&&(!0===e&&this.boxManager.blurAllBox(),this.boxManager.setMinimized(Boolean(e)))})))),!this.attributes.apps||0===Object.keys(this.attributes.apps).length){const e=this.store.getMainViewScenePath();if(!e)return;this.displayer.state.sceneState.scenePath!==e&&O(this.room,e)}this.displayerWritableListener(!(null==(a=this.room)?void 0:a.isWritable)),this.displayer.callbacks.on("onEnableWriteNowChanged",this.displayerWritableListener)}async attributesUpdateCallback(e){if(e)for(const t in e)if(!this.appProxies.has(t)&&!this.appStatus.has(t)){const i=e[t];M.default((async()=>{this.appStatus.set(t,x.StartCreate);if(!this.attributes[t])throw new Error("appAttributes is undefined");await this.baseInsertApp({kind:i.kind,options:i.options,isDynamicPPT:i.isDynamicPPT},t,!1),this.focusByAttributes(e)}),{retries:3}).catch((e=>{console.warn("[WindowManager]: Insert App Error",e),this.appStatus.delete(t)}))}}bindMainView(e,t){const i=this.mainViewProxy.view;i.disableCameraTransform=t,i.divElement=e,i.focusScenePath||this.store.setMainViewFocusPath(),void 0===this.store.focus&&i.mode!==o.ViewVisionMode.Writable&&this.viewManager.switchMainViewToWriter(),this.mainViewProxy.addMainViewListener(),rt.emit("mainViewMounted")}async addApp(e,t){te("addApp",e);const{appId:i,needFocus:s}=await this.beforeAddApp(e,t),a=await this.baseInsertApp(e,i,!0,s);return this.afterAddApp(a),null==a?void 0:a.id}async beforeAddApp(e,t){var i;const s=await(async e=>{var t,i;const s=await(null==(t=U.appClasses.get(e))?void 0:t());return s&&(null==(i=s.config)?void 0:i.singleton)?e:`${e}-${n.v4().replace("-","").slice(0,8)}`})(e.kind);this.appStatus.set(s,x.StartCreate);const a=null!=(i=e.attributes)?i:{};this.safeUpdateAttributes([s],a),this.store.setupAppAttributes(e,s,t);const r=!this.boxManager.minimized;return r&&this.store.setAppFocus(s,!0),{appId:s,needFocus:r}}afterAddApp(e){if(e&&e.box){const t=e.box;rt.emit("move",{appId:e.id,x:null==t?void 0:t.intrinsicX,y:null==t?void 0:t.intrinsicY}),this.store.updateAppState(e.id,I.ZIndex,t.zIndex)}this.boxManager.minimized&&this.boxManager.setMinimized(!1,!1)}async closeApp(e){const t=this.appProxies.get(e);t&&t.destroy(!0,!0,!1)}async baseInsertApp(e,t,i,s){if(this.appProxies.has(t))return void console.warn("[WindowManager]: app duplicate exists and cannot be created again");const a=new re(e,this,t,i);if(a)return await a.baseInsertApp(s),this.appStatus.delete(t),a;throw this.appStatus.delete(t),new Error("[WindowManger]: initialize AppProxy failed")}get eventName(){return o.isRoom(this.displayer)?"onRoomStateChanged":"onPlayerStateChanged"}get attributes(){return this.windowManger.attributes}get canOperate(){return this.windowManger.canOperate}get room(){return o.isRoom(this.displayer)?this.displayer:void 0}get mainView(){return this.mainViewProxy.view}get focusApp(){if(this.store.focus)return this.appProxies.get(this.store.focus)}safeSetAttributes(e){this.windowManger.safeSetAttributes(e)}safeUpdateAttributes(e,t){this.windowManger.safeUpdateAttributes(e,t)}async setMainViewScenePath(e){if(this.room){const t=this.displayer.scenePathType(e);if(t===o.ScenePathType.None)throw new Error(`[WindowManager]: ${e} not valid scene`);if(t===o.ScenePathType.Page)await this._setMainViewScenePath(e);else if(t===o.ScenePathType.Dir){const t=((e,t)=>{const i=e.entireScenes()[t][0].name;return"/"===t?`/${i}`:`${t}/${i}`})(this.displayer,e);await this._setMainViewScenePath(t)}}}async _setMainViewScenePath(e){this.safeSetAttributes({_mainScenePath:e}),await this.viewManager.switchMainViewToWriter(),O(this.room,e),this.store.setMainViewFocusPath(),this.dispatchInternalEvent(p.SetMainViewScenePath,{nextScenePath:e})}async setMainViewSceneIndex(e){if(this.room){this.safeSetAttributes({_mainSceneIndex:e}),await this.viewManager.switchMainViewToWriter(),this.room.setSceneIndex(e);const t=this.room.state.sceneState.scenePath;this.store.setMainViewScenePath(t),this.store.setMainViewFocusPath(),this.dispatchInternalEvent(p.SetMainViewScenePath,{nextScenePath:t})}}getAppInitPath(e){var t;const i=this.store.getAppAttributes(e);if(i)return null==(t=null==i?void 0:i.options)?void 0:t.scenePath}safeDispatchMagixEvent(e,t){this.canOperate&&this.displayer.dispatchMagixEvent(e,t)}focusByAttributes(e){if(e&&Object.keys(e).length===this.boxManager.appBoxMap.size){const e=this.store.focus;e&&this.boxManager.focusBox({appId:e})}}async notifyReconnected(){const e=Array.from(this.appProxies.values()).map((e=>e.onReconnected()));await Promise.all(e)}notifyContainerRectUpdate(e){this.appProxies.forEach((t=>{t.appEmitter.emit("containerRectUpdate",e)}))}dispatchInternalEvent(e,t){this.safeDispatchMagixEvent(w,{eventName:e,payload:t})}destroy(){var e;this.displayer.callbacks.off(this.eventName,this.displayerStateListener),this.displayer.callbacks.off("onEnableWriteNowChanged",this.displayerWritableListener),this.appListeners.removeListeners(),rt.offAny(this.boxEventListener),rt.clearListeners(),this.appProxies.size&&this.appProxies.forEach((e=>{e.destroy(!0,!1,!0)})),this.viewManager.destroy(),this.boxManager.destroy(),null==(e=this.refresher)||e.destroy(),this.mainViewProxy.destroy(),nt.clearListeners()}}function we(){}function Ie(e){return e()}function Ae(){return Object.create(null)}function ye(e){e.forEach(Ie)}function Ce(e){return"function"==typeof e}function xe(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let be,ve;function Se(e,t){return be||(be=document.createElement("a")),be.href=t,e===be.href}function Ne(e,t){e.appendChild(t)}function De(e,t,i){e.insertBefore(t,i||null)}function Te(e){e.parentNode.removeChild(e)}function fe(e){return document.createElement(e)}function je(e){return document.createTextNode(e)}function Ve(){return je(" ")}function Le(e,t,i){null==i?e.removeAttribute(t):e.getAttribute(t)!==i&&e.setAttribute(t,i)}function Pe(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function Ee(e,t,i,s){e.style.setProperty(t,i,s?"important":"")}function ze(e){ve=e}const Be=[],Ue=[],ke=[],Oe=[],Re=Promise.resolve();let Ze=!1;function Qe(e){ke.push(e)}let We=!1;const Ge=new Set;function Ye(){if(!We){We=!0;do{for(let e=0;e<Be.length;e+=1){const t=Be[e];ze(t),Fe(t.$$)}for(ze(null),Be.length=0;Ue.length;)Ue.pop()();for(let e=0;e<ke.length;e+=1){const t=ke[e];Ge.has(t)||(Ge.add(t),t())}ke.length=0}while(Be.length);for(;Oe.length;)Oe.pop()();Ze=!1,We=!1,Ge.clear()}}function Fe(e){if(null!==e.fragment){e.update(),ye(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(Qe)}}const He=new Set;function Xe(e,t){-1===e.$$.dirty[0]&&(Be.push(e),Ze||(Ze=!0,Re.then(Ye)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Je(e,t,i,s,a,r,n,o=[-1]){const h=ve;ze(e);const c=e.$$={fragment:null,ctx:null,props:r,update:we,not_equal:a,bound:Ae(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(h?h.$$.context:t.context||[]),callbacks:Ae(),dirty:o,skip_bound:!1,root:t.target||h.$$.root};n&&n(c.root);let d=!1;if(c.ctx=i?i(e,t.props||{},((t,i,...s)=>{const r=s.length?s[0]:i;return c.ctx&&a(c.ctx[t],c.ctx[t]=r)&&(!c.skip_bound&&c.bound[t]&&c.bound[t](r),d&&Xe(e,t)),i})):[],c.update(),d=!0,ye(c.before_update),c.fragment=!!s&&s(c.ctx),t.target){if(t.hydrate){const e=(g=t.target,Array.from(g.childNodes));c.fragment&&c.fragment.l(e),e.forEach(Te)}else c.fragment&&c.fragment.c();t.intro&&((p=e.$$.fragment)&&p.i&&(He.delete(p),p.i(l))),function(e,t,i,s){const{fragment:a,on_mount:r,on_destroy:n,after_update:o}=e.$$;a&&a.m(t,i),s||Qe((()=>{const t=r.map(Ie).filter(Ce);n?n.push(...t):ye(t),e.$$.on_mount=[]})),o.forEach(Qe)}(e,t.target,t.anchor,t.customElement),Ye()}var p,l,g;ze(h)}function _e(e){let t,i,s;return{c(){t=fe("img"),Le(t,"class","netless-window-manager-cursor-selector-avatar"),Le(t,"style",i=e[15]()),Se(t.src,s=e[7])||Le(t,"src",s),Le(t,"alt","avatar")},m(e,i){De(e,t,i)},p(e,i){128&i&&!Se(t.src,s=e[7])&&Le(t,"src",s)},d(e){e&&Te(t)}}}function Ke(e){let t,i;return{c(){t=fe("span"),i=je(e[1]),Le(t,"class","netless-window-manager-cursor-tag-name"),Ee(t,"background-color",e[10])},m(e,s){De(e,t,s),Ne(t,i)},p(e,s){2&s&&Pe(i,e[1]),1024&s&&Ee(t,"background-color",e[10])},d(e){e&&Te(t)}}}function qe(e){let t,i,s,a,r,n,o,h,c,d,p,l,g=e[13]&&_e(e),u=e[14]&&Ke(e);return{c(){t=fe("div"),i=fe("div"),s=fe("div"),g&&g.c(),a=Ve(),r=fe("span"),n=je(e[0]),o=Ve(),u&&u.c(),h=Ve(),c=fe("div"),d=fe("img"),Ee(r,"overflow","hidden"),Ee(r,"white-space","nowrap"),Ee(r,"text-overflow","ellipsis"),Ee(r,"max-width","80px"),Le(s,"class",e[8]),Ee(s,"background-color",e[2]),Ee(s,"color",e[9]),Ee(s,"opacity",e[11]),Le(i,"class","netless-window-manager-cursor-name"),Le(d,"class",p="netless-window-manager-cursor-"+e[3]+"-image"),Se(d.src,l=e[6])||Le(d,"src",l),Le(d,"alt",e[3]),Le(c,"class","cursor-image-wrapper"),Le(t,"class","netless-window-manager-cursor-mid"),Ee(t,"transform","translateX("+e[4]+"px) translateY("+e[5]+"px)"),Ee(t,"display",e[12])},m(e,p){De(e,t,p),Ne(t,i),Ne(i,s),g&&g.m(s,null),Ne(s,a),Ne(s,r),Ne(r,n),Ne(s,o),u&&u.m(s,null),Ne(t,h),Ne(t,c),Ne(c,d)},p(e,[i]){e[13]?g?g.p(e,i):(g=_e(e),g.c(),g.m(s,a)):g&&(g.d(1),g=null),1&i&&Pe(n,e[0]),e[14]?u?u.p(e,i):(u=Ke(e),u.c(),u.m(s,null)):u&&(u.d(1),u=null),256&i&&Le(s,"class",e[8]),4&i&&Ee(s,"background-color",e[2]),512&i&&Ee(s,"color",e[9]),2048&i&&Ee(s,"opacity",e[11]),8&i&&p!==(p="netless-window-manager-cursor-"+e[3]+"-image")&&Le(d,"class",p),64&i&&!Se(d.src,l=e[6])&&Le(d,"src",l),8&i&&Le(d,"alt",e[3]),48&i&&Ee(t,"transform","translateX("+e[4]+"px) translateY("+e[5]+"px)"),4096&i&&Ee(t,"display",e[12])},i:we,o:we,d(e){e&&Te(t),g&&g.d(),u&&u.d()}}}function $e(e,t,i){let s,a,n,o,{cursorName:h}=t,{tagName:c}=t,{backgroundColor:d}=t,{appliance:p}=t,{x:l}=t,{y:g}=t,{src:u}=t,{visible:m}=t,{avatar:M}=t,{theme:w}=t,{color:I}=t,{cursorTagBackgroundColor:A}=t,{opacity:y}=t;return e.$$set=e=>{"cursorName"in e&&i(0,h=e.cursorName),"tagName"in e&&i(1,c=e.tagName),"backgroundColor"in e&&i(2,d=e.backgroundColor),"appliance"in e&&i(3,p=e.appliance),"x"in e&&i(4,l=e.x),"y"in e&&i(5,g=e.y),"src"in e&&i(6,u=e.src),"visible"in e&&i(16,m=e.visible),"avatar"in e&&i(7,M=e.avatar),"theme"in e&&i(8,w=e.theme),"color"in e&&i(9,I=e.color),"cursorTagBackgroundColor"in e&&i(10,A=e.cursorTagBackgroundColor),"opacity"in e&&i(11,y=e.opacity)},e.$$.update=()=>{1&e.$$.dirty&&(s=!r.isEmpty(h)),2&e.$$.dirty&&i(14,a=!r.isEmpty(c)),128&e.$$.dirty&&i(13,n=!r.isEmpty(M)),65536&e.$$.dirty&&i(12,o=m?"initial":"none")},[h,c,d,p,l,g,u,M,w,I,A,y,o,n,a,()=>Object.entries({width:(s?19:28)+"px",height:(s?19:28)+"px",position:s?"initial":"absolute","border-color":s?"white":d,"margin-right":(s?4:0)+"px"}).map((([e,t])=>`${e}: ${t}`)).join(";"),m]}class et extends class{$destroy(){!function(e,t){const i=e.$$;null!==i.fragment&&(ye(i.on_destroy),i.fragment&&i.fragment.d(t),i.on_destroy=i.fragment=null,i.ctx=[])}(this,1),this.$destroy=we}$on(e,t){const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}{constructor(e){super(),Je(this,e,$e,qe,xe,{cursorName:0,tagName:1,backgroundColor:2,appliance:3,x:4,y:5,src:6,visible:16,avatar:7,theme:8,color:9,cursorTagBackgroundColor:10,opacity:11})}}const tt={[o.ApplianceNames.pencil]:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACX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9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMSIgZD0iTTE5LDI1IEwxOSwxNSBMMTYsMTUgQzE1LjQ0NzcxNTMsMTUgMTUsMTQuNTUyMjg0NyAxNSwxNCBDMTUsMTMuNTE0NTg5NyAxNS4zNDc5OTkzLDEzLjEwMTkxNSAxNS44NjU0ODc3LDEzLjAxMDA1MjEgTDE2LDEzIEwyNCwxMyBDMjQuNTUyMjg0NywxMyAyNSwxMy40NDc3MTUzIDI1LDE0IEMyNSwxNC40ODU0MTAzIDI0LjY1MjAwMDcsMTQuODk4MDg1IDI0LjEzNDUxMjMsMTQuOTg5OTQ3OSBMMjQsMTUgTDIxLDE1IEwyMSwyNSBMMjQsMjUgQzI0LjU1MjI4NDcsMjUgMjUsMjUuNDQ3NzE1MyAyNSwyNiBDMjUsMjYuNDg1NDEwMyAyNC42NTIwMDA3LDI2Ljg5ODA4NSAyNC4xMzQ1MTIzLDI2Ljk4OTk0NzkgTDI0LDI3IEwxNiwyNyBDMTUuNDQ3NzE1MywyNyAxNSwyNi41NTIyODQ3IDE1LDI2IEMxNSwyNS41MTQ1ODk3IDE1LjM0Nzk5OTMsMjUuMTAxOTE1IDE1Ljg2NTQ4NzcsMjUuMDEwMDUyMSBMMTYsMjUgTDE5LDI1IFoiIGZpbGw9IiMyMTIzMjQiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PC9wYXRoPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4="};class it extends ae{constructor(e,t,i,s,a){super(e),this.cursors=t,this.memberId=i,this.cursorManager=s,this.wrapper=a,this.setMember(),this.createCursor(),M.default((()=>{this.disposer&&this.disposer(),this.cursorPosition||console.warn(`${i} not exist`),this.startReaction()}),{retries:3}),this.autoHidden()}startReaction(){this.disposer=o.autorun((()=>{var e;const t=this.cursorPosition,i=this.cursorState;if(t){if("main"===t.type){const e=this.cursorManager.wrapperRect;this.component&&e&&(this.autoHidden(),this.moveCursor(t,e,this.manager.mainView))}else{const i=this.cursorManager.focusView,s=null==(e=null==i?void 0:i.divElement)?void 0:e.getBoundingClientRect(),a=null==i?void 0:i.camera;i&&s&&a&&this.component&&(this.autoHidden(),this.moveCursor(t,s,i))}i&&i===b.Leave&&this.hide()}}))}moveCursor(e,t,i){var s,a;const{x:r,y:n}=e,o=null==i?void 0:i.screen.convertPointToScreen(r,n);if(o){const e=o.x+t.x-2,i=o.y+t.y-18;o.x<0||o.x>t.width||o.y<0||o.y>t.height?null==(s=this.component)||s.$set({visible:!1}):null==(a=this.component)||a.$set({visible:!0,x:e,y:i})}}get memberApplianceName(){var e,t;return null==(t=null==(e=this.member)?void 0:e.memberState)?void 0:t.currentApplianceName}get memberColor(){var e,t;return`rgb(${null==(t=null==(e=this.member)?void 0:e.memberState)?void 0:t.strokeColor.join(",")})`}get payload(){var e;return null==(e=this.member)?void 0:e.payload}get memberCursorName(){var e,t;return(null==(e=this.payload)?void 0:e.nickName)||(null==(t=this.payload)?void 0:t.cursorName)||this.memberId}get memberTheme(){var e;return(null==(e=this.payload)?void 0:e.theme)?"netless-window-manager-cursor-inner-mellow":"netless-window-manager-cursor-inner"}get memberCursorTextColor(){var e;return(null==(e=this.payload)?void 0:e.cursorTextColor)||"#FFFFFF"}get memberCursorTagBackgroundColor(){var e;return(null==(e=this.payload)?void 0:e.cursorTagBackgroundColor)||this.memberColor}get memberAvatar(){var e;return null==(e=this.payload)?void 0:e.avatar}get memberOpacity(){return this.memberCursorName||this.memberAvatar?1:0}get cursorState(){return r.get(this.cursors,[this.memberId,q.CursorState])}get cursorPosition(){return r.get(this.cursors,[this.memberId,q.Position])}autoHidden(){this.timer&&clearTimeout(this.timer),this.timer=window.setTimeout((()=>{this.hide(),this.store.updateCursorState(this.memberId,b.Leave)}),1e4)}async createCursor(){this.member&&this.wrapper&&(this.component=new et({target:document.documentElement,props:this.initProps()}))}initProps(){return{x:0,y:0,appliance:this.memberApplianceName,avatar:this.memberAvatar,src:this.getIcon(),visible:!1,backgroundColor:this.memberColor,cursorName:this.memberCursorName,theme:this.memberTheme,color:this.memberCursorTextColor,cursorTagBackgroundColor:this.memberCursorTagBackgroundColor,opacity:this.memberOpacity}}getIcon(){if(this.member){return tt[this.memberApplianceName||o.ApplianceNames.shape]||tt[o.ApplianceNames.shape]}}setMember(){this.member=this.context.findMemberByUid(this.memberId),this.updateComponent()}updateComponent(){var e;null==(e=this.component)||e.$set(r.omit(this.initProps(),["x","y"]))}destroy(){this.disposer&&this.disposer(),this.component&&this.component.$destroy(),this.cursorManager.cursorInstances.delete(this.memberId)}hide(){this.component&&this.component.$set({visible:!1})}}class st extends ae{constructor(e){var t;super(e),this.appManager=e,this.cursorInstances=new Map,this.getUids=e=>r.compact(r.uniq(null==e?void 0:e.map((e=>{var t;return null==(t=e.payload)?void 0:t.uid})))),this.handleRoomMembersChange=r.debounce((e=>{const t=this.getUids(this.roomMembers),i=Object.keys(this.cursors);(null==t?void 0:t.length)&&i.map((i=>{if(t.includes(i)&&!this.cursorInstances.has(i)){if(i===this.context.uid)return;const t=new it(this.appManager,this.cursors,i,this,e);this.cursorInstances.set(i,t)}}))}),100),this.mouseMoveListener=r.debounce((e=>{this.updateCursor(this.getType(e),e.clientX,e.clientY)}),5),this.touchMoveListener=r.debounce((e=>{if(1===e.touches.length){const t=e.touches[0];this.updateCursor(this.getType(t),t.clientX,t.clientY)}}),5),this.getPoint=(e,t,i)=>{var s;const a=null==(s=null==e?void 0:e.divElement)?void 0:s.getBoundingClientRect();if(a){return null==e?void 0:e.convertToPointInWorld({x:t-a.x,y:i-a.y})}},this.getType=e=>{var t;const i=e.target,s=this.appManager.focusApp;switch(i.parentElement){case this.mainViewElement:return{type:"main"};case null==(t=null==s?void 0:s.view)?void 0:t.divElement:return{type:"app"};default:return{type:"main"}}},this.mouseLeaveListener=()=>{this.hideCursor(this.context.uid),this.store.updateCursorState(this.context.uid,b.Leave)},this.roomMembers=null==(t=this.appManager.room)?void 0:t.state.roomMembers;const i=ht.wrapper;i&&(i.addEventListener("mousemove",this.mouseMoveListener),i.addEventListener("touchstart",this.touchMoveListener),i.addEventListener("touchmove",this.touchMoveListener),i.addEventListener("mouseleave",this.mouseLeaveListener),i.addEventListener("touchend",this.mouseLeaveListener),this.initCursorAttributes(),this.wrapperRect=i.getBoundingClientRect(),this.startReaction(i))}setMainViewDivElement(e){this.mainViewElement=e}startReaction(e){var t;null==(t=this.manager.refresher)||t.add("cursors",(()=>ue(this.cursors,(()=>{this.handleRoomMembersChange(e)}))))}get cursors(){var e;return null==(e=this.manager.attributes)?void 0:e[q.Cursors]}get boxState(){return this.store.getBoxState()}get focusView(){var e;return null==(e=this.appManager.focusApp)?void 0:e.view}updateCursor(e,t,i){if(this.wrapperRect&&this.manager.canOperate){const s="main"===e.type?this.appManager.mainView:this.focusView,a=this.getPoint(s,t,i);a&&(this.setNormalCursorState(),this.store.updateCursor(this.context.uid,__spreadValues({x:a.x,y:a.y},e)))}}initCursorAttributes(){this.store.updateCursor(this.context.uid,{x:0,y:0,type:"main"}),this.store.updateCursorState(this.context.uid,b.Leave)}setNormalCursorState(){this.store.getCursorState(this.context.uid)!==b.Normal&&this.store.updateCursorState(this.context.uid,b.Normal)}updateContainerRect(){var e,t;this.containerRect=null==(e=ht.container)?void 0:e.getBoundingClientRect(),this.wrapperRect=null==(t=ht.wrapper)?void 0:t.getBoundingClientRect()}setRoomMembers(e){this.roomMembers=e,this.cursorInstances.forEach((e=>{e.setMember()})),ht.wrapper&&this.handleRoomMembersChange(ht.wrapper)}deleteCursor(e){this.store.cleanCursor(e);const t=this.cursorInstances.get(e);t&&t.destroy()}hideCursor(e){const t=this.cursorInstances.get(e);t&&t.hide()}cleanMemberAttributes(e){const t=this.getUids(e),i=[];Object.keys(this.cursors).map((e=>{-1===t.findIndex((t=>t===e))&&i.push(e)})),i.forEach((e=>{this.deleteCursor(e)}))}destroy(){var e;const t=ht.wrapper;t&&(t.removeEventListener("mousemove",this.mouseMoveListener),t.removeEventListener("touchstart",this.touchMoveListener),t.removeEventListener("touchmove",this.touchMoveListener),t.removeEventListener("mouseleave",this.mouseLeaveListener),t.removeEventListener("touchend",this.mouseLeaveListener)),this.cursorInstances.size&&(this.cursorInstances.forEach((e=>e.destroy())),this.cursorInstances.clear()),null==(e=this.manager.refresher)||e.remove("cursors")}}const at=window.ResizeObserver||h.ResizeObserver,rt=new m.default,nt=new m.default,ot=class extends o.InvisiblePlugin{constructor(e){super(e),this.version="0.3.17",this.emitter=nt,this.viewMode=o.ViewMode.Broadcaster,this.isReplay=o.isPlayer(this.displayer)}static async mount(e,t,s,a){let r,n,h,c,d,p,l=!0,g=!1,u="light";if("room"in e?(r=e.room,t=e.container,s=e.collectorContainer,n=e.containerSizeRatio,h=e.collectorStyles,c=e.debug,null!=e.chessboard&&(l=e.chessboard),d=e.overwriteStyles,p=e.cursor,g=Boolean(null==e?void 0:e.disableCameraTransform),u=e.prefersColorScheme):(r=e,n=null==a?void 0:a.containerSizeRatio,h=null==a?void 0:a.collectorStyles,c=null==a?void 0:a.debug,null!=(null==a?void 0:a.chessboard)&&(l=a.chessboard),d=null==a?void 0:a.overwriteStyles),this.checkVersion(),o.isRoom(r)&&r.phase!==o.RoomPhase.Connected)throw new Error("[WindowManager]: Room only Connected can be mount");if(!t)throw new Error("[WindowManager]: Container must provide");if(ot.isCreated)throw new Error("[WindowManager]: Already created cannot be created again");let m=await this.initManager(r);if(this.debug=Boolean(c),this.debug&&i.setOptions({verbose:!0}),te("Already insert room",m),o.isRoom(this.displayer)){if(!m)throw new Error("[WindowManager]: init InvisiblePlugin failed")}else await M.default((async e=>{if(m=await this.initManager(r),!m)throw te(`manager is empty. retrying ${e}`),new Error}),{retries:10});n&&(ot.containerSizeRatio=n),ot.container=t;const{playground:w,wrapper:I,sizer:A,mainViewElement:y}=(e=>{const t=document.createElement("div");t.className="netless-window-manager-playground";const i=document.createElement("div");i.className="netless-window-manager-sizer";const s=document.createElement("div");s.className="netless-window-manager-wrapper";const a=document.createElement("div");return a.className="netless-window-manager-main-view",t.appendChild(i),i.appendChild(s),s.appendChild(a),e.appendChild(t),ht.wrapper=s,{playground:t,wrapper:s,sizer:i,mainViewElement:a}})(t);if(ot.playground=w,l&&A.classList.add("netless-window-manager-chess-sizer"),d){const e=document.createElement("style");e.textContent=d,w.appendChild(e)}await m.ensureAttributes(),m.appManager=new Me(m,{collectorContainer:s,collectorStyles:h,prefersColorScheme:u}),m.observePlaygroundSize(w,A,I),p&&(m.cursorManager=new st(m.appManager)),m.bindMainView(y,g),((e,t)=>{if(o.isPlayer(e)){const t=e,i=t.seekToProgressTime;async function s(e){const s=await i.call(t,e);return"success"===s&&rt.emit("seek",e),s}t.seekToProgressTime=s}else{if(Object.getOwnPropertyDescriptor(e,"disableCameraTransform"))return;Object.defineProperty(e,"disableCameraTransform",{get:()=>t.mainView.disableCameraTransform,set(e){t.mainView.disableCameraTransform=e}}),e.moveCamera=e=>t.mainView.moveCamera(e),e.moveCameraToContain=(...e)=>t.mainView.moveCameraToContain(...e),e.convertToPointInWorld=(...e)=>t.mainView.convertToPointInWorld(...e),e.setCameraBound=(...e)=>t.mainView.setCameraBound(...e),e.scenePreview=(...e)=>t.mainView.scenePreview(...e),e.fillSceneSnapshot=(...e)=>t.mainView.fillSceneSnapshot(...e),e.generateScreenshot=(...e)=>t.mainView.generateScreenshot(...e)}})(r,m.appManager),rt.emit("onCreated"),ot.isCreated=!0;try{await L()}catch(C){console.warn("[WindowManager]: indexedDB open failed"),console.log(C)}return m}static async initManager(e){let t=e.getInvisiblePlugin(ot.kind);if(!t&&o.isRoom(e))if(!1===e.isWritable){try{await e.setWritable(!0)}catch(i){throw new Error("[WindowManger]: room must be switched to be writable")}t=await e.createInvisiblePlugin(ot,{}),t.ensureAttributes(),await W(500),await e.setWritable(!1)}else t=await e.createInvisiblePlugin(ot,{});return t}static register(e){return U.register(e)}async addApp(e){var t,i,s,a;if(this.appManager){if(!e.kind||"string"!=typeof e.kind)throw new X;const r=await(null==(t=U.appClasses.get(e.kind))?void 0:t());if(r&&(null==(i=r.config)?void 0:i.singleton)&&this.appManager.appProxies.has(e.kind))throw new Y;const n=this.setupScenePath(e,this.appManager);if(void 0===n)return;(null==(s=null==e?void 0:e.options)?void 0:s.scenePath)&&(e.options.scenePath=(a=e.options.scenePath).endsWith("/")?a.slice(0,-1):a);return await this.appManager.addApp(e,Boolean(n))}throw new F}setupScenePath(e,t){var i,s,a;let r=!1;if(e.options){const{scenePath:n,scenes:o}=e.options;if(n){if(!(e=>e.startsWith("/"))(n))throw new _;const e=Object.keys(this.apps||{});for(const i of e){const e=t.store.getAppScenePath(i);if(e&&e===n)return void console.warn(`[WindowManager]: ScenePath ${n} Already opened`)}}n&&o&&o.length>0&&(this.isDynamicPPT(o)?(r=!0,this.displayer.entireScenes()[n]||null==(i=this.room)||i.putScenes(n,o)):this.displayer.entireScenes()[n]||null==(s=this.room)||s.putScenes(n,[{name:o[0].name}])),n&&void 0===o&&(null==(a=this.room)||a.putScenes(n,[{}]))}return r}async setMainViewScenePath(e){this.appManager&&await this.appManager.setMainViewScenePath(e)}async setMainViewSceneIndex(e){this.appManager&&await this.appManager.setMainViewSceneIndex(e)}getMainViewScenePath(){var e;return null==(e=this.appManager)?void 0:e.store.getMainViewScenePath()}getMainViewSceneIndex(){var e;return null==(e=this.appManager)?void 0:e.store.getMainViewSceneIndex()}setReadonly(e){var t,i;(null==(t=this.room)?void 0:t.isWritable)&&(this.readonly=e,null==(i=this.appManager)||i.boxManager.setReadonly(e))}switchMainViewToWriter(){var e;return null==(e=this.appManager)?void 0:e.mainViewProxy.mainViewClickHandler()}onAppDestroy(e,t){((e,t)=>{rt.once(e).then(t)})(`destroy-${e}`,t)}setViewMode(e){var t,i,s;this.canOperate&&(e===o.ViewMode.Broadcaster&&(null==(t=this.appManager)||t.mainViewProxy.setCameraAndSize(),null==(i=this.appManager)||i.mainViewProxy.start()),e===o.ViewMode.Freedom&&(null==(s=this.appManager)||s.mainViewProxy.stop()),this.viewMode=e)}get mainView(){if(this.appManager)return this.appManager.mainViewProxy.view;throw new F}get camera(){if(this.appManager)return this.appManager.mainViewProxy.view.camera;throw new F}get cameraState(){if(this.appManager)return this.appManager.mainViewProxy.cameraState;throw new F}get apps(){var e;return null==(e=this.appManager)?void 0:e.store.apps()}get boxState(){if(this.appManager)return this.appManager.boxManager.boxState;throw new F}get darkMode(){var e;return Boolean(null==(e=this.appManager)?void 0:e.boxManager.darkMode)}get prefersColorScheme(){if(this.appManager)return this.appManager.boxManager.prefersColorScheme;throw new F}queryAll(){var e;return Array.from((null==(e=this.appManager)?void 0:e.appProxies.values())||[])}queryOne(e){var t;return null==(t=this.appManager)?void 0:t.appProxies.get(e)}async closeApp(e){var t;return null==(t=this.appManager)?void 0:t.closeApp(e)}moveCamera(e){this.mainView.moveCamera(e)}moveCameraToContain(e){this.mainView.moveCameraToContain(e)}convertToPointInWorld(e){return this.mainView.convertToPointInWorld(e)}setCameraBound(e){this.mainView.setCameraBound(e)}onDestroy(){this._destroy()}destroy(){this._destroy()}_destroy(){var e,t,i,s;null==(e=this.containerResizeObserver)||e.disconnect(),null==(t=this.appManager)||t.destroy(),null==(i=this.cursorManager)||i.destroy(),ot.container=void 0,ot.wrapper=void 0,ot.isCreated=!1,ot.playground&&(null==(s=ot.playground.parentNode)||s.removeChild(ot.playground)),te("Destroyed")}bindMainView(e,t){var i;this.appManager&&(this.appManager.bindMainView(e,t),null==(i=this.cursorManager)||i.setMainViewDivElement(e))}get canOperate(){return!!o.isRoom(this.displayer)&&(this.displayer.isWritable&&this.displayer.phase===o.RoomPhase.Connected)}get room(){return this.displayer}safeSetAttributes(e){this.canOperate&&this.setAttributes(e)}safeUpdateAttributes(e,t){this.canOperate&&this.updateAttributes(e,t)}setPrefersColorScheme(e){var t;null==(t=this.appManager)||t.boxManager.setPrefersColorScheme(e)}isDynamicPPT(e){var t,i;const s=null==(i=null==(t=e[0])?void 0:t.ppt)?void 0:i.src;return null==s?void 0:s.startsWith("pptx://")}static checkVersion(){if(Q(o.WhiteVersion)<Q(S))throw new H(S)}async ensureAttributes(){if(r.isNull(this.attributes)&&await W(50),r.isObject(this.attributes)){this.attributes[q.Apps]||this.safeSetAttributes({[q.Apps]:{}}),this.attributes[q.Cursors]||this.safeSetAttributes({[q.Cursors]:{}});const e=this.displayer.state.sceneState;this.attributes._mainScenePath||this.safeSetAttributes({_mainScenePath:e.scenePath}),this.attributes._mainSceneIndex||this.safeSetAttributes({_mainSceneIndex:e.index})}}observePlaygroundSize(e,t,i){this.updateSizer(e.getBoundingClientRect(),t,i),this.containerResizeObserver=new at((e=>{var s,a,r;const n=null==(s=e[0])?void 0:s.contentRect;n&&(this.updateSizer(n,t,i),null==(a=this.cursorManager)||a.updateContainerRect(),null==(r=this.appManager)||r.boxManager.updateManagerRect(),rt.emit("playgroundSizeChange",n))})),this.containerResizeObserver.observe(e)}updateSizer({width:e,height:t},i,s){e&&t&&(t/e>ot.containerSizeRatio?(t=e*ot.containerSizeRatio,i.classList.toggle("netless-window-manager-sizer-horizontal",!0)):(e=t/ot.containerSizeRatio,i.classList.toggle("netless-window-manager-sizer-horizontal",!1)),s.style.width=`${e}px`,s.style.height=`${t}px`)}};let ht=ot;ht.kind="WindowManager",ht.debug=!1,ht.containerSizeRatio=9/16,ht.isCreated=!1,ht.register({kind:g.default.kind,src:g.default}),ht.register({kind:u.default.kind,src:u.default});const ct={DocsViewer:g.default.kind,MediaPlayer:u.default.kind};e.BuiltinApps=ct,e.WhiteWindowSDK=class{constructor(e){this.sdk=new o.WhiteWebSdk(__spreadProps(__spreadValues({},e),{useMobXState:!0}))}async mount(e){const t=e.joinRoomParams.invisiblePlugins||[],i=await this.sdk.joinRoom(__spreadProps(__spreadValues({},e.joinRoomParams),{useMultiViews:!0,invisiblePlugins:[...t,ht],disableMagixEventDispatchLimit:!0})),s=await ht.mount(__spreadValues({room:i},e.mountParams));return r.isBoolean(e.joinRoomParams.disableCameraTransform)&&(s.mainView.disableCameraTransform=e.joinRoomParams.disableCameraTransform),s}},e.WindowManager=ht,e.callbacks=nt,e.emitter=rt,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"}));
2
2
  //# sourceMappingURL=index.umd.js.map