@netless/window-manager 1.0.0-canary.4 → 1.0.0-canary.5

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.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";var ng=Object.defineProperty,rg=Object.defineProperties;var sg=Object.getOwnPropertyDescriptors;var hu=Object.getOwnPropertySymbols;var og=Object.prototype.hasOwnProperty,ag=Object.prototype.propertyIsEnumerable;var pu=(e,t,i)=>t in e?ng(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Q=(e,t)=>{for(var i in t||(t={}))og.call(t,i)&&pu(e,i,t[i]);if(hu)for(var i of hu(t))ag.call(t,i)&&pu(e,i,t[i]);return e},tt=(e,t)=>rg(e,sg(t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var lg=require("p-retry"),ug=require("emittery"),b=require("lodash"),E=require("white-web-sdk"),cg=require("uuid"),be=require("side-effect-manager"),A=require("value-enhancer"),wd=require("@juggle/resize-observer"),dg=require("video.js");function Ba(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var hg=Ba(lg),Qt=Ba(ug),fu=Ba(dg),Z=(e=>(e.AppMove="AppMove",e.AppFocus="AppFocus",e.AppResize="AppResize",e.AppBoxStateChange="AppBoxStateChange",e.GetAttributes="GetAttributes",e.UpdateWindowManagerWrapper="UpdateWindowManagerWrapper",e.InitReplay="InitReplay",e.WindowCreated="WindowCreated",e.SetMainViewScenePath="SetMainViewScenePath",e.SetMainViewSceneIndex="SetMainViewSceneIndex",e.SetAppFocusIndex="SetAppFocusIndex",e.SwitchViewsToFreedom="SwitchViewsToFreedom",e.MoveCamera="MoveCamera",e.MoveCameraToContain="MoveCameraToContain",e.CursorMove="CursorMove",e.RootDirRemoved="RootDirRemoved",e.Refresh="Refresh",e.InitMainViewCamera="InitMainViewCamera",e))(Z||{});const To="__WindowManger",Xs="__WindowMangerEnsureReconnected__";var Le=(e=>(e.Size="size",e.Position="position",e.SceneIndex="SceneIndex",e.ZIndex="zIndex",e))(Le||{}),yd=(e=>(e.setBoxSize="setBoxSize",e.setBoxMinSize="setBoxMinSize",e.destroy="destroy",e))(yd||{}),No=(e=>(e.StartCreate="StartCreate",e))(No||{}),xd=(e=>(e.Leave="leave",e.Normal="normal",e))(xd||{});const gu="2.16.1",pg=340/720,fg=340/720,gg=9/16,ze="/",Sd="/init",Cd=50,mu=500,ie=new Qt.default;class mg{constructor(){this.list=[],this.isEmit=!1,this.invoked=()=>{this.currentInvoker=void 0,this.list.length===0&&(this.clear(),this.emitReady())},this.clear=()=>{clearInterval(this.timer),this.timer=void 0}}initInterval(){return setInterval(()=>{this.invoke()},50)}push(t){this.list.push(t),this.invoke(),this.timer===void 0&&this.list.length>0&&(this.timer=this.initInterval())}invoke(){if(this.list.length===0||this.currentInvoker!==void 0)return;const t=this.list.shift();t&&(this.currentInvoker=t,t().then(()=>{this.invoked()}).catch(i=>{console.error(`[WindowManager]: create app error: ${i.message}`),this.invoked()}))}emitReady(){this.isEmit||setTimeout(()=>{ie.emit("ready")},Cd),this.isEmit=!0}empty(){this.list=[],this.clear()}destroy(){this.timer&&this.clear()}}const L=new Qt.default,vg="__WindowManagerAppCache";let jn,vu;const wg=async()=>{jn=await Sg()},yg=(e,t)=>{if(!!jn)return Mg(jn,{kind:e,sourceCode:t})},xg=async e=>jn?await Cg(jn,e):null;function Sg(){return new Promise((e,t)=>{const i=indexedDB.open(vg,2);i.onerror=n=>{t(n)},i.onupgradeneeded=n=>{const r=n.target.result;r.objectStoreNames.contains("apps")||(vu=r.createObjectStore("apps",{keyPath:"kind"}),vu.createIndex("kind","kind",{unique:!0}))},i.onsuccess=()=>{const n=i.result;e(n)}})}function Cg(e,t){return new Promise((i,n)=>{const s=e.transaction(["apps"]).objectStore("apps").index("kind").get(t);s.onerror=o=>n(o),s.onsuccess=()=>{s.result?i(s.result):i(null)}})}function Mg(e,t){return new Promise((i,n)=>{const r=e.transaction(["apps"],"readwrite").objectStore("apps").add(t);r.onsuccess=()=>i(),r.onerror=()=>n()})}const Ig="NetlessApp",bg=1e4,Eg=async e=>{const t=await xg(e);if(t)return t.sourceCode;{const n=await(await Tg(e,{timeout:bg})).text();return await yg(e,n),n}},wu=(e,t)=>{let i=Function(e+`
2
- ;return ${t}`)();return typeof i=="undefined"&&(i=window[t]),i},Ag=async(e,t,i)=>{const n=i||Ig+t;ie.emit("loadApp",{kind:t,status:"start"});try{const r=await Eg(e);if(!r||r.length===0){ie.emit("loadApp",{kind:t,status:"failed",reason:"script is empty."});return}try{const s=wu(r,n);return ie.emit("loadApp",{kind:t,status:"success"}),s}catch(s){if(s.message.includes("Can only have one anonymous define call per script file")){const o=window.define;typeof o=="function"&&o.amd&&delete o.amd;const a=wu(r,n);return ie.emit("loadApp",{kind:t,status:"success"}),a}ie.emit("loadApp",{kind:t,status:"failed",reason:s.message})}}catch(r){ie.emit("loadApp",{kind:t,status:"failed",reason:r.message})}};async function Tg(e,t){const{timeout:i=1e4}=t,n=new AbortController,r=setTimeout(()=>n.abort(),i),s=await fetch(e,tt(Q({},t),{signal:n.signal,headers:{"content-type":"text/plain"}}));return clearTimeout(r),s}class Ng{constructor(){this.kindEmitters=new Map,this.registered=new Map,this.appClassesCache=new Map,this.appClasses=new Map,this.syncRegisterApp=null,this.onSyncRegisterAppChange=t=>{this.register({kind:t.kind,src:t.src})}}setSyncRegisterApp(t){this.syncRegisterApp=t}async register(t){this.appClassesCache.delete(t.kind),this.registered.set(t.kind,t);const i=t.src;let n;if(typeof i=="string"?(n=async()=>{let r=await Ag(i,t.kind,t.name);if(r)return r.__esModule&&(r=r.default),r;throw new Error(`[WindowManager]: load remote script failed, ${i}`)},this.syncRegisterApp&&this.syncRegisterApp({kind:t.kind,src:i,name:t.name})):typeof i=="function"?n=i:n=async()=>i,this.appClasses.set(t.kind,async()=>{let r=this.appClassesCache.get(t.kind);return r||(r=n(),this.appClassesCache.set(t.kind,r)),r}),t.addHooks){const r=this.createKindEmitter(t.kind);r&&t.addHooks(r)}}unregister(t){this.appClasses.delete(t),this.appClassesCache.delete(t),this.registered.delete(t);const i=this.kindEmitters.get(t);i&&(i.clearListeners(),this.kindEmitters.delete(t))}async notifyApp(t,i,n){const r=this.kindEmitters.get(t);await(r==null?void 0:r.emit(i,n))}createKindEmitter(t){if(!this.kindEmitters.has(t)){const i=new Qt.default;this.kindEmitters.set(t,i)}return this.kindEmitters.get(t)}}const je=new Ng,kg=async e=>{var i,n;const t=await((i=je.appClasses.get(e))==null?void 0:i());return t&&((n=t.config)==null?void 0:n.singleton)?e:`${e}-${cg.v4().replace("-","").slice(0,8)}`},gi=(e,t)=>{if(e.focusScenePath!==t)return e.focusScenePath=t,e},yu=e=>{e.didRelease||e.release()},ko=(e,t)=>{if(e&&e.isWritable&&e.state.sceneState.scenePath!==t){const i=t==="/"?"":t;e.setScenePath(i)}},Pg=(e,t,i)=>{var n;if(e&&t){const s=(n=mi(e)[t])==null?void 0:n[i];if(s)return`${t}/${s.name}`}},Po=(e,t,i)=>{e&&e.scenePathType(t)!==E.ScenePathType.None&&e.removeScenes(t,i)},zg=(e,t)=>{L.once(e).then(t)};b.debounce((e,t)=>{e.emit("mainViewModeChange",t)},200);const Dg=(e,t,i=0)=>{const n=mi(e)[t];if(!n)return;const r=n[i];if(!r)return;const s=r.name;return t===ze?`/${s}`:`${t}/${s}`},mi=e=>e.entireScenes(),ai=(e,t,i,n)=>e==null?void 0:e.putScenes(t,i,n),Lg=e=>e.startsWith("/"),Js=e=>{const t=e.split("/");t.pop();let i=t.join("/");return i===""&&(i="/"),i},jg=e=>e.endsWith("/")?e.slice(0,-1):e,xu=e=>{const t=e.split(".").map(i=>i.padStart(2,"0")).join("");return parseInt(t)},Su=e=>new Promise(t=>setTimeout(t,e)),Rg=e=>e.split("").reduce((i,n)=>(n===ze&&(i+=1),i),0)===1;class Vg{constructor(t){this.manager=t,this.displayer=this.manager.displayer,this.mainMagixEventListener=i=>{if(i.authorId!==this.displayer.observerId){const n=i.payload;switch(n.eventName){case Z.AppMove:{this.appMoveHandler(n.payload);break}case Z.AppResize:{this.appResizeHandler(n.payload);break}case Z.AppBoxStateChange:{this.boxStateChangeHandler(n.payload);break}case Z.SetMainViewScenePath:{this.setMainViewScenePathHandler(n.payload);break}case Z.MoveCamera:{this.moveCameraHandler(n.payload);break}case Z.MoveCameraToContain:{this.moveCameraToContainHandler(n.payload);break}case Z.CursorMove:{this.cursorMoveHandler(n.payload);break}case Z.RootDirRemoved:{this.rootDirRemovedHandler();break}case Z.Refresh:{this.refreshHandler();break}case Z.InitMainViewCamera:{this.initMainViewCameraHandler();break}case Z.SetAppFocusIndex:{this.setAppFocusViewIndexHandler(n.payload);break}}}},this.appMoveHandler=i=>{var n;(n=this.boxManager)==null||n.moveBox(i)},this.appResizeHandler=i=>{var n,r;(n=this.boxManager)==null||n.resizeBox(Object.assign(i,{skipUpdate:!0})),(r=this.manager.room)==null||r.refreshViewSize()},this.boxStateChangeHandler=i=>{ie.emit("boxStateChange",i)},this.setMainViewScenePathHandler=({nextScenePath:i})=>{gi(this.manager.mainView,i),ie.emit("mainViewScenePathChange",i)},this.moveCameraHandler=i=>{b.isEqual(b.omit(i,["animationMode"]),Q({},this.manager.mainView.camera))||this.manager.mainView.moveCamera(i)},this.moveCameraToContainHandler=i=>{this.manager.mainView.moveCameraToContain(i)},this.cursorMoveHandler=i=>{L.emit("cursorMove",i)},this.rootDirRemovedHandler=()=>{this.manager.createRootDirScenesCallback(),this.manager.mainViewProxy.rebind(),L.emit("rootDirRemoved")},this.refreshHandler=()=>{this.manager.windowManger._refresh()},this.initMainViewCameraHandler=()=>{this.manager.mainViewProxy.addCameraReaction()},this.setAppFocusViewIndexHandler=i=>{if(i.type==="main")this.manager.setSceneIndexWithoutSync(i.index);else if(i.type==="app"&&i.appID){const n=this.manager.appProxies.get(i.appID);n&&n.setSceneIndexWithoutSync(i.index)}}}get boxManager(){return this.manager.boxManager}addListeners(){this.displayer.addMagixEventListener(To,this.mainMagixEventListener)}removeListeners(){this.displayer.removeMagixEventListener(To,this.mainMagixEventListener)}}class Md extends Error{constructor(){super(...arguments);this.message="[WindowManager]: app duplicate exists and cannot be created again"}}class Bg extends Error{constructor(t){super(`[WindowManager]: app ${t} need register or provide src`)}}class Ye extends Error{constructor(){super(...arguments);this.message="[WindowManager]: AppManager must be initialized"}}class Id extends Error{constructor(t){super(`[WindowManager]: white-web-sdk version must large than ${t}`)}}class bd extends Error{constructor(){super(...arguments);this.message="[WindowManager]: kind must be a valid string"}}class Ed extends Error{constructor(){super(...arguments);this.message="[WindowManager]: box need created"}}class Ad extends Error{constructor(){super(...arguments);this.message='[WindowManager]: ScenePath should start with "/"'}}class Td extends Error{constructor(){super(...arguments);this.message="[WindowManager]: boxManager not found"}}class Nd extends Error{constructor(){super(...arguments);this.message="[WindowManager]: room phase only Connected can be bindContainer"}}const kd=e=>(t,i)=>{if(t!==void 0)if(E.listenUpdated){const n=r=>{r.map(o=>o.kind).includes(e)&&i()};return E.listenUpdated(t,n),i(),()=>E.unlistenUpdated(t,n)}else return E.reaction(()=>t,()=>{i()},{fireImmediately:!0})},Pd=(e,t,i)=>{let n=null;const r=E.reaction(e,()=>{n&&(n(),n=null);const s=e();b.isObject(s)?(n=()=>E.unlistenUpdated(s,t),E.listenUpdated(s,t)):i==null||i(s)},{fireImmediately:!0});return()=>{n==null||n(),r()}},Og=kd(E.UpdateEventKind.Removed);kd(E.UpdateEventKind.Inserted);const Ks=Object.keys;function Cu(e){return Boolean(b.has(e,"__isRef"))}function _g(e){return{k:be.genUID(),v:e,__isRef:!0}}class Ug{constructor(){this.listeners=new Set}get length(){return this.listeners.size}dispatch(t){this.listeners.forEach(i=>i(t))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}}const Ge="_WM-STORAGE_";class Mu{constructor(t,i,n){if(this._sideEffect=new be.SideEffectManager,this._destroyed=!1,this._refMap=new WeakMap,this._lastValue=new Map,this.onStateChanged=new Ug,n&&!b.isObject(n))throw new Error(`Default state for Storage ${i} is not an object.`);this._context=t,this.id=i||null,this._state={};const r=this._getRawState(this._state);this._context.isWritable&&(this.id===null?t.isAddApp&&n&&this.setState(n):(r===this._state||!b.isObject(r))&&(b.get(this._context.getAttributes(),[Ge])||this._context.updateAttributes([Ge],{}),this._context.updateAttributes([Ge,this.id],this._state),n&&this.setState(n))),Ks(r).forEach(s=>{if(!(this.id===null&&s===Ge))try{const o=b.isObject(r[s])?JSON.parse(JSON.stringify(r[s])):r[s];Cu(o)?(this._state[s]=o.v,b.isObject(o.v)&&this._refMap.set(o.v,o)):this._state[s]=o}catch(o){console.error(o)}}),this._sideEffect.addDisposer(Pd(()=>this.id===null?t.getAttributes():b.get(t.getAttributes(),[Ge,this.id]),this._updateProperties.bind(this),this.destroy.bind(this)))}get state(){return this._destroyed&&console.warn(`Accessing state on destroyed Storage "${this.id}"`),this._state}addStateChangedListener(t){return this.onStateChanged.addListener(t),()=>this.onStateChanged.removeListener(t)}ensureState(t){return this.setState(Ks(t).reduce((i,n)=>(b.has(this._state,n)||(i[n]=t[n]),i),{}))}setState(t){if(this._destroyed){console.error(new Error(`Cannot call setState on destroyed Storage "${this.id}".`));return}if(!this._context.isWritable){console.error(new Error(`Cannot setState on Storage "${this.id}" without writable access`),t);return}const i=Ks(t);i.length>0&&i.forEach(n=>{const r=t[n];if(r!==this._state[n])if(r===void 0)this._lastValue.set(n,this._state[n]),delete this._state[n],this._setRawState(n,r);else{this._lastValue.set(n,this._state[n]),this._state[n]=r;let s=r;if(b.isObject(r)){let o=this._refMap.get(r);o||(o=_g(r),this._refMap.set(r,o)),s=o}this._setRawState(n,s)}})}emptyStorage(){if(!(b.size(this._state)<=0)){if(this._destroyed){console.error(new Error(`Cannot empty destroyed Storage "${this.id}".`));return}if(!this._context.isWritable){console.error(new Error(`Cannot empty Storage "${this.id}" without writable access.`));return}this.setState(b.mapValues(this._state,b.noop))}}deleteStorage(){if(this.id===null)throw new Error("Cannot delete main Storage");if(!this._context.isWritable){console.error(new Error(`Cannot delete Storage "${this.id}" without writable access.`));return}this.destroy(),this._context.updateAttributes([Ge,this.id],void 0)}get destroyed(){return this._destroyed}destroy(){this._destroyed=!0,this._sideEffect.flushAll()}_getRawState(t){var i;return this.id===null?(i=this._context.getAttributes())!=null?i:t:b.get(this._context.getAttributes(),[Ge,this.id],t)}_setRawState(t,i){if(this.id===null){if(t===Ge)throw new Error(`Cannot set attribute internal filed "${Ge}"`);return this._context.updateAttributes([t],i)}else return this._context.updateAttributes([Ge,this.id,t],i)}_updateProperties(t){var i;if(this._destroyed){console.error(new Error(`Cannot call _updateProperties on destroyed Storage "${this.id}".`));return}if(t.length>0){const n={};for(let r=0;r<t.length;r++)try{const s=t[r],o=s.key;if(this.id===null&&o===Ge)continue;const a=b.isObject(s.value)?JSON.parse(JSON.stringify(s.value)):s.value;let l;switch(this._lastValue.has(o)&&(l=this._lastValue.get(o),this._lastValue.delete(o)),s.kind){case 2:{b.has(this._state,o)&&(l=this._state[o],delete this._state[o]),n[o]={oldValue:l};break}default:{let u=a;if(Cu(a)){const{k:c,v:d}=a,m=this._state[o];b.isObject(m)&&((i=this._refMap.get(m))==null?void 0:i.k)===c?u=m:(u=d,b.isObject(d)&&this._refMap.set(d,a))}u!==this._state[o]&&(l=this._state[o],this._state[o]=u),n[o]={newValue:u,oldValue:l};break}}}catch(s){console.error(s)}this.onStateChanged.dispatch(n)}}}class $g{constructor(t,i,n){this.appContext=t,this.appProxy=i,this.removeViewWrapper=n,this.nextPage=async()=>{const s=this.pageState.index+1;return this.jumpPage(s)},this.prevPage=async()=>{const s=this.pageState.index-1;return this.jumpPage(s)},this.jumpPage=async s=>s<0||s>=this.pageState.length?(console.warn(`[WindowManager]: index ${s} out of range`),!1):(this.appProxy.setSceneIndex(s),!0),this.addPage=async s=>{const o=s==null?void 0:s.after,a=s==null?void 0:s.scene,l=this.appProxy.scenePath;if(!!l)if(o){const u=this.pageState.index+1;ai(this.appContext.room,l,[a||{}],u)}else ai(this.appContext.room,l,[a||{}])},this.removePage=async s=>{const o=s===void 0?this.pageState.index:s;return this.pageState.length===1?(console.warn("[WindowManager]: can not remove the last page"),!1):o<0||o>=this.pageState.length?(console.warn(`[WindowManager]: page index ${s} out of range`),!1):this.appProxy.removeSceneByIndex(o)};const r=new A.Val(i.pageState);this.pageState$=r,i.appEmitter.on("pageStateChange",s=>{r.setValue(s)})}get view(){return this.appContext.view}get pageState(){return this.pageState$.value}moveCamera(t){this.appProxy.moveCamera(t)}destroy(){this.removeViewWrapper()}}const Wg=e=>{const t=document.createElement("div");t.className="netless-window-manager-playground";const i=document.createElement("div");return i.className="netless-window-manager-main-view",t.appendChild(i),e.appendChild(t),{playground:t,mainViewElement:i}},Hg=()=>{if(xu(E.WhiteVersion)<xu(gu))throw new Id(gu)},zd=(e,t)=>{const i=e==null?void 0:e.state.roomMembers;return i==null?void 0:i.find(n=>{var r;return((r=n.payload)==null?void 0:r.uid)===t})},Fg=e=>e.map(t=>{var i;return Q({uid:((i=t.payload)==null?void 0:i.uid)||""},t)});class Qg{constructor(t,i,n,r,s){this.manager=t,this.boxManager=i,this.appId=n,this.appProxy=r,this.appOptions=s,this.mobxUtils={autorun:E.autorun,reaction:E.reaction,toJS:E.toJS},this.objectUtils={listenUpdated:E.listenUpdated,unlistenUpdated:E.unlistenUpdated,listenDisposed:E.listenDisposed,unlistenDisposed:E.unlistenDisposed},this.store=this.manager.store,this.isReplay=this.manager.isReplay,this.getAttributes=()=>this.appProxy.attributes,this.getScenes=()=>{const o=this.store.getAppAttributes(this.appId);return o!=null&&o.isDynamicPPT?this.appProxy.scenes:o==null?void 0:o.options.scenes},this.createWhiteBoardView=o=>{var c;if(this.whiteBoardView)return this.whiteBoardView;let a=this.view;a||(a=this.appProxy.createAppDir());const l=document.createElement("div");l.className="window-manager-view-wrapper",(c=this.box.$content.parentElement)==null||c.appendChild(l);const u=()=>{var d;(d=this.box.$content.parentElement)==null||d.removeChild(l)};return a.divElement=l,this.isAddApp&&this.initPageSize(o),this.whiteBoardView=new $g(this,this.appProxy,u),this.whiteBoardView},this.initPageSize=o=>{if(!b.isNumber(o)||!this.appProxy.scenePath||this.appProxy.pageState.length>=o)return;if(o<=0||o>=mu)throw Error(`[WindowManager]: size ${o} muse be in range [1, ${mu}]`);const a=o-this.appProxy.pageState.length,l=this.appProxy.pageState.length,u=new Array(a).fill({}).map((c,d)=>({name:`${l+d+1}`}));ai(this.room,this.appProxy.scenePath,u)},this.getInitScenePath=()=>this.manager.getAppInitPath(this.appId),this.setAttributes=o=>{this.manager.safeSetAttributes({[this.appId]:o})},this.updateAttributes=(o,a)=>{this.manager.attributes[this.appId]&&this.manager.safeUpdateAttributes([this.appId,...o],a)},this.setScenePath=async o=>{var a;!this.appProxy.box||(this.appProxy.setFullPath(o),(a=this.room)==null||a.setScenePath(o))},this.getAppOptions=()=>typeof this.appOptions=="function"?this.appOptions():this.appOptions,this.createStorage=(o,a)=>{const l=new Mu(this,o,a);return this.emitter.on("destroy",()=>{l.destroy()}),l},this.dispatchMagixEvent=(...o)=>{var l;const a=`${this.appId}:${o[0]}`;return(l=this.manager.room)==null?void 0:l.dispatchMagixEvent(a,o[1])},this.addMagixEventListener=(o,a,l)=>{const u=`${this.appId}:${o}`;return this.manager.displayer.addMagixEventListener(u,a,l),()=>this.manager.displayer.removeMagixEventListener(u,a)},this.removeMagixEventListener=this.manager.displayer.removeMagixEventListener.bind(this.manager.displayer),this.emitter=r.appEmitter,this.isAddApp=r.isAddApp}get displayer(){return this.manager.displayer}get view(){return this.appProxy.view}get isWritable(){return this.manager.canOperate}get box(){const t=this.boxManager.getBox(this.appId);if(t)return t;throw new Ed}get room(){return this.manager.room}get members(){return this.manager.members}get memberState(){const t=zd(this.room,this.manager.uid);if(!t)throw new Error(`Member ${this.manager.uid} not found.`);return Q({uid:this.manager.uid},t)}get storage(){return this._storage||(this._storage=new Mu(this)),this._storage}}class Zg{constructor(t){this.params=t,this.sceneNode=null,this.createSceneNode=r=>(this.scenePath=r,this.sceneNode&&this.sceneNode.dispose(),this.sceneNode=this.params.displayer.createScenesCallback(r,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}),this.sceneNode),this.onSceneChange=()=>{this.params.notifyPageStateChange()};const{displayer:i,scenePath:n}=this.params;this.view=this.params.view,n&&(this.scenePath=n,this.sceneNode=i.createScenesCallback(n,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}))}setView(t){this.view=t}getFullPath(t){var n;const i=(n=this.sceneNode)==null?void 0:n.scenes;if(this.scenePath&&i){const r=i[t];if(r)return`${this.scenePath}/${r}`}}toObject(){var t,i;return{index:((t=this.view)==null?void 0:t.focusSceneIndex)||0,length:((i=this.sceneNode)==null?void 0:i.scenes.length)||0}}destroy(){var t;(t=this.sceneNode)==null||t.dispose()}}class Dd{constructor(t){this.saveCamera=t,this.onRemoteUpdate=b.throttle((i,n)=>{if(this.remoteCamera=i,this.remoteSize=n,this.remoteSize&&this.rect){let r;n.width<n.height?r=this.rect.width/n.width:r=this.rect.height/n.height;const s=i.scale*r,o=()=>{var a;return(a=this.view)==null?void 0:a.moveCamera({centerX:i.centerX,centerY:i.centerY,scale:s,animationMode:E.AnimationMode.Immediately})};b.delay(o,50)}},50),this.onLocalSizeUpdate=i=>{if(this.rect&&this.view){let n;i.width<i.height?n=this.rect.width/i.width:n=this.rect.height/i.height;const r=this.view.camera.scale/n;console.log("onLocalSizeUpdate",r.toFixed(3),n.toFixed(3)),this.view.moveCamera({scale:r,animationMode:E.AnimationMode.Immediately})}}}setRect(t){this.rect=t,this.remoteCamera&&this.remoteSize&&this.onRemoteUpdate(this.remoteCamera,this.remoteSize)}setView(t){this.view=t}onLocalCameraUpdate(t){this.saveCamera(t),this.remoteCamera=t}}class Gg{constructor(t){this.appProxy=t,this.sem=new be.SideEffectManager,this.bindView=n=>{!n||(this.synchronizer.setView(n),this.sem.add(()=>(n.callbacks.on("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),()=>n.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice))))},this.onCameraUpdatedByDevice=n=>{var s;this.synchronizer.onLocalCameraUpdate(n);const r=(s=this.appProxy.box)==null?void 0:s.contentStageRect;if(r){const o={width:r.width,height:r.height,id:this.appProxy.uid};b.isEqual(o,this.appProxy.size$.value)||this.appProxy.storeSize(o)}},this.synchronizer=new Dd(n=>{this.appProxy.storeCamera(Q({id:this.appProxy.uid},n))}),this.bindView(t.view),this.sem.add(()=>this.appProxy.camera$.subscribe(n=>{const r=this.appProxy.size$.value;n&&r&&this.synchronizer.onRemoteUpdate(n,r)}));const i=this.appProxy.box;i&&i.contentStageRect&&(this.synchronizer.setRect(i.contentStageRect),this.sem.add(()=>i._contentStageRect$.subscribe(n=>{n&&this.synchronizer.setRect(n)})),this.appProxy.size$.value||this.appProxy.storeSize({id:this.appProxy.uid,width:i.contentStageRect.width,height:i.contentStageRect.height}))}destroy(){this.sem.flushAll()}}const wt=new Qt.default,Oa=(e,t)=>{let i=0;const n=t.length-1;return e===t.index?e===n?i=e-1:i=t.index+1:i=t.index,i};var me=(e=>(e.Apps="apps",e.Focus="focus",e.State="state",e.BoxState="boxState",e.MainViewCamera="mainViewCamera",e.MainViewSize="mainViewSize",e.Broadcaster="broadcaster",e.Cursors="cursors",e.Position="position",e.CursorState="cursorState",e.FullPath="fullPath",e.Registered="registered",e.Camera="camera",e.Size="size",e))(me||{});class Yg{constructor(t){this.context=t,this.setAppFocus=(i,n)=>{n?this.context.safeSetAttributes({focus:i}):this.context.safeSetAttributes({focus:void 0})}}setContext(t){this.context=t}get attributes(){return this.context.getAttributes()}apps(){return b.get(this.attributes,["apps"])}get focus(){return b.get(this.attributes,["focus"])}getAppAttributes(t){return b.get(this.apps(),[t])}getAppState(t){return b.get(this.apps(),[t,"state"])}getMaximized(){return b.get(this.attributes,["maximized"])}getMinimized(){return b.get(this.attributes,["minimized"])}setupAppAttributes(t,i,n){this.attributes.apps||this.context.safeSetAttributes({apps:{}});const s=["scenePath","title"];n||s.push("scenes");const o=b.pick(t.options,s),a={kind:t.kind,options:o,isDynamicPPT:n};typeof t.src=="string"&&(a.src=t.src),a.createdAt=Date.now(),this.context.safeUpdateAttributes(["apps",i],a),this.context.safeUpdateAttributes(["apps",i,"state"],{[Le.Size]:{},[Le.Position]:{},[Le.SceneIndex]:0})}updateAppState(t,i,n){b.get(this.attributes,["apps",t,"state"])&&this.context.safeUpdateAttributes(["apps",t,"state",i],n)}updateAppAttributes(t,i,n){this.context.safeUpdateAttributes(["apps",t,i],n)}cleanAppAttributes(t){this.context.safeUpdateAttributes(["apps",t],void 0),this.context.safeSetAttributes({[t]:void 0}),this.attributes.focus===t&&this.cleanFocus()}cleanFocus(){this.context.safeSetAttributes({focus:void 0})}getAppSceneIndex(t){var i;return(i=this.getAppState(t))==null?void 0:i[Le.SceneIndex]}getAppScenePath(t){var i,n;return(n=(i=this.getAppAttributes(t))==null?void 0:i.options)==null?void 0:n.scenePath}getMainViewScenePath(){return this.attributes._mainScenePath}getMainViewSceneIndex(){return this.attributes._mainSceneIndex}getBoxState(){return this.attributes.boxState}setMainViewScenePath(t){this.context.safeSetAttributes({_mainScenePath:t})}setMainViewSceneIndex(t){this.context.safeSetAttributes({_mainSceneIndex:t})}getMainViewCamera(){return b.get(this.attributes,["mainViewCamera"])}getMainViewSize(){return b.get(this.attributes,["mainViewSize"])}setMainViewCamera(t){this.context.safeSetAttributes({mainViewCamera:Q({},t)})}setMainViewSize(t){this.context.safeSetAttributes({mainViewSize:Q({},t)})}setMainViewCameraAndSize(t,i){this.context.safeSetAttributes({mainViewCamera:Q({},t),mainViewSize:Q({},i)})}updateCursor(t,i){b.get(this.attributes,["cursors"])||this.context.safeUpdateAttributes(["cursors"],{}),b.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"position"],i)}updateCursorState(t,i){b.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"cursorState"],i)}getCursorState(t){return b.get(this.attributes,["cursors",t,"cursorState"])}cleanCursor(t){this.context.safeUpdateAttributes(["cursors",t],void 0)}setMainViewFocusPath(t){const i=this.getMainViewScenePath();i&&gi(t,i)}}const Xg=new Yg({getAttributes:()=>{throw new Error("getAttributes not implemented")},safeSetAttributes:()=>{throw new Error("safeSetAttributes not implemented")},safeUpdateAttributes:()=>{throw new Error("safeUpdateAttributes not implemented")}}),Li=(...e)=>{ye.debug&&console.log("[WindowManager]:",...e)};class _a{constructor(t,i,n,r){var s;this.params=t,this.manager=i,this.boxManager=this.manager.boxManager,this.appProxies=this.manager.appProxies,this.viewManager=this.manager.viewManager,this.store=this.manager.store,this.uid=this.manager.uid,this.status="normal",this.sideEffectManager=new be.SideEffectManager,this.camera$=new A.Val(void 0),this.size$=new A.Val(void 0),this.box$=new A.Val(void 0),this.view$=new A.Val(void 0),this.getAppInitState=o=>{var p,h;const a=this.store.getAppState(o);if(!a)return;const l=a==null?void 0:a[Le.Position],u=this.store.focus,c=a==null?void 0:a[Le.Size],d=a==null?void 0:a[Le.SceneIndex],m=(p=this.attributes)==null?void 0:p.maximized,w=(h=this.attributes)==null?void 0:h.minimized,y=a==null?void 0:a.zIndex;let M={maximized:m,minimized:w,zIndex:y};return l&&(M=tt(Q({},M),{id:o,x:l.x,y:l.y})),u===o&&(M=tt(Q({},M),{focus:!0})),c&&(M=tt(Q({},M),{width:c.width,height:c.height})),d&&(M=tt(Q({},M),{sceneIndex:d})),M},this.appAttributesUpdateListener=o=>{var a,l,u;(a=this.manager.refresher)==null||a.add(o,()=>E.autorun(()=>{const c=this.manager.attributes[o];c&&this.appEmitter.emit("attributesUpdate",c)})),(l=this.manager.refresher)==null||l.add(this.stateKey,()=>E.autorun(()=>{var d,m,w;const c=(d=this.appAttributes)==null?void 0:d.state;(c==null?void 0:c.zIndex)>0&&c.zIndex!==((m=this.box)==null?void 0:m.zIndex)&&((w=this.boxManager)==null||w.setZIndex(o,c.zIndex))})),(u=this.manager.refresher)==null||u.add(`${o}-fullPath`,()=>E.autorun(()=>{var d;const c=(d=this.appAttributes)==null?void 0:d.fullPath;this.setFocusScenePathHandler(c),this._prevFullPath!==c&&(this.notifyPageStateChange(),this._prevFullPath=c)}))},this.setFocusScenePathHandler=b.debounce(o=>{var a;this.view&&o&&o!==((a=this.view)==null?void 0:a.focusScenePath)&&gi(this.view,o)},50),this.notifyPageStateChange=b.debounce(()=>{this.pageState&&this.appEmitter.emit("pageStateChange",this.pageState)},50),this.storeCamera=o=>{this.store.updateAppAttributes(this.id,me.Camera,o)},this.storeSize=o=>{this.store.updateAppAttributes(this.id,me.Size,o)},this.moveCamera=o=>{if(!this.camera$.value)return;const a=Q(Q({},this.camera$.value),o);this.storeCamera(a)},this.kind=t.kind,this.id=n,this.appScenePath=`/${this.id}-app-dir`,this.stateKey=`${this.id}_state`,this.appProxies.set(this.id,this),this.appEmitter=new Qt.default,this.appListener=this.makeAppEventListener(this.id),this.isAddApp=r,this.initScenes(),(s=this.params.options)!=null&&s.scenePath&&this.createView(),this.scenePath||(this.scenePath=this.appScenePath),this._pageState=new Zg({displayer:this.manager.displayer,scenePath:this.scenePath,view:this.view,notifyPageStateChange:this.notifyPageStateChange}),this.sideEffectManager.add(()=>()=>this._pageState.destroy()),this.sideEffectManager.add(()=>L.on("roomMembersChange",o=>{this.appEmitter.emit("roomMembersChange",o)})),this.camera$.setValue(E.toJS(this.appAttributes.camera)),this.size$.setValue(E.toJS(this.appAttributes.size)),this.sideEffectManager.add(()=>this.manager.refresher.add(`${this.id}-camera`,()=>E.reaction(()=>{var o;return(o=this.appAttributes)==null?void 0:o.camera},o=>{o&&o.id!==this.uid&&this.camera$.setValue(E.toJS(o))}))),this.sideEffectManager.add(()=>this.manager.refresher.add(`${this.id}-size`,()=>E.reaction(()=>{var o;return(o=this.appAttributes)==null?void 0:o.size},o=>{o&&o.id!==this.uid&&this.size$.setValue(E.toJS(o))}))),A.combine([this.box$,this.view$]).subscribe(([o,a])=>{if(o&&a){const l=new Gg(this);this.appViewSync=l,this.sideEffectManager.add(()=>()=>l.destroy())}})}createAppDir(){const t=this.scenePath||this.appScenePath;this._pageState.createSceneNode(t)||(ai(this.manager.room,t,[{name:"1"}]),this._pageState.createSceneNode(t),this.setSceneIndex(0)),this.scenes=mi(this.manager.displayer)[t];const n=this.createView();return this._pageState.setView(n),n}initScenes(){var i;const t=this.params.options;t&&(this.scenePath=t.scenePath,((i=this.appAttributes)==null?void 0:i.isDynamicPPT)&&this.scenePath?this.scenes=mi(this.manager.displayer)[this.scenePath]:this.scenes=t.scenes)}get view(){return this.manager.viewManager.getView(this.id)}get viewIndex(){var t;return(t=this.view)==null?void 0:t.focusSceneIndex}get isWritable(){var t;return this.manager.canOperate&&!((t=this.box)!=null&&t.readonly)}get attributes(){return this.manager.attributes[this.id]}get appAttributes(){return this.store.getAppAttributes(this.id)}getFullScenePath(){if(this.scenePath)return b.get(this.appAttributes,[me.FullPath])||this.getFullScenePathFromScenes()}getFullScenePathFromScenes(){const t=b.get(this.appAttributes,["state","SceneIndex"],0),i=Pg(this.manager.room,this.scenePath,t);return i&&this.setFullPath(i),i}setFullPath(t){this.store.updateAppAttributes(this.id,me.FullPath,t)}async baseInsertApp(t=!1){var s;const i=this.params;if(!i.kind)throw new Error("[WindowManager]: kind require");const n=await((s=je.appClasses.get(i.kind))==null?void 0:s()),r=je.registered.get(i.kind);if(n)await this.setupApp(this.id,t,n,i.options,r==null?void 0:r.appOptions);else throw new Error(`[WindowManager]: app load failed ${i.kind} ${i.src}`);return L.emit("updateManagerRect"),{appId:this.id,app:n}}get box(){return this.box$.value}async setupApp(t,i,n,r,s){var a;if(Li("setupApp",t,n,r),!this.boxManager)throw new Td;const o=new Qg(this.manager,this.boxManager,t,this,s);this.appContext=o;try{L.once(`${t}${Z.WindowCreated}`).then(async()=>{var c;let u;i||(u=this.getAppInitState(t),(c=this.boxManager)==null||c.updateBoxState(u)),this.appEmitter.onAny(this.appListener),this.appAttributesUpdateListener(t),this.setViewFocusScenePath(),setTimeout(async()=>{const d=await n.setup(o);this.appResult=d,je.notifyApp(this.kind,"created",{appId:t,result:d}),this.fixMobileSize()},Cd)});const l=(a=this.boxManager)==null?void 0:a.createBox({appId:t,app:n,options:r,canOperate:this.manager.canOperate,smartPosition:this.isAddApp});this.box$.setValue(l),this.isAddApp&&this.box&&(this.store.updateAppState(t,Le.ZIndex,this.box.zIndex),this.boxManager.focusBox({appId:t},!1))}catch(l){throw console.error(l),new Error(`[WindowManager]: app setup error: ${l.message}`)}}fixMobileSize(){var i,n;const t=(i=this.boxManager)==null?void 0:i.getBox(this.id);t&&((n=this.boxManager)==null||n.resizeBox({appId:this.id,width:t.intrinsicWidth+.001,height:t.intrinsicHeight+.001,skipUpdate:!0}))}async onSeek(t){var n;this.appEmitter.emit("seek",t).catch(r=>{console.log(`[WindowManager]: emit seek error: ${r.message}`)});const i=this.getAppInitState(this.id);(n=this.boxManager)==null||n.updateBoxState(i)}async onReconnected(){var s;if(!Boolean(this.manager.attributes.apps[this.id])){await this.destroy(!0,!1,!0);return}this.appEmitter.emit("reconnected",void 0);const i=this.getAppInitState(this.id);await this.destroy(!0,!1,!0);const n=this.params;await new _a(n,this.manager,this.id,this.isAddApp).baseInsertApp(!0),(s=this.boxManager)==null||s.updateBoxState(i)}async onRemoveScene(t){if(this.scenePath&&t.startsWith(this.scenePath+"/")){let i=this.pageState.index,n=this._pageState.getFullPath(i);n||(i=0,n=this._pageState.getFullPath(i)),n&&this.setFullPath(n),this.setViewFocusScenePath(),this.view&&(this.view.focusSceneIndex=i)}}emitAppSceneStateChange(t){this.appEmitter.emit("sceneStateChange",t)}emitAppIsWritableChange(){this.appEmitter.emit("writableChange",this.isWritable)}makeAppEventListener(t){return(i,n)=>{var r,s,o,a;if(!!this.manager.canOperate)switch(i){case"setBoxSize":{(r=this.boxManager)==null||r.resizeBox({appId:t,width:n.width,height:n.height,skipUpdate:!1});break}case"setBoxMinSize":{(s=this.boxManager)==null||s.setBoxMinSize({appId:t,minWidth:n.minwidth,minHeight:n.minheight});break}case"setBoxTitle":{(o=this.boxManager)==null||o.setBoxTitle({appId:t,title:n.title});break}case yd.destroy:{if(this.status==="destroyed")return;this.destroy(!0,!1,!0,n==null?void 0:n.error),n!=null&&n.error&&console.error(n==null?void 0:n.error);break}case"focus":{(a=this.boxManager)==null||a.focusBox({appId:this.id}),wt.emit("focus",{appId:this.id});break}}}}setScenePath(){if(!this.manager.canOperate)return;const t=this.getFullScenePath();this.manager.room&&t&&this.view&&ko(this.manager.room,t)}setViewFocusScenePath(){const t=this.getFullScenePath();return t&&this.view&&gi(this.view,t),t}createView(){const t=this.viewManager.createView(this.id);return this.view$.setValue(t),this.setViewFocusScenePath(),t}get pageState(){return this._pageState.toObject()}async removeSceneByIndex(t){const i=this._pageState.getFullPath(t);if(i&&this.pageState){const n=Oa(t,this.pageState);return this.setSceneIndexWithoutSync(n),this.manager.dispatchInternalEvent(Z.SetAppFocusIndex,{type:"app",appID:this.id,index:n}),setTimeout(()=>{Po(this.manager.room,i,t)},100),!0}else return!1}setSceneIndexWithoutSync(t){this.view&&(this.view.focusSceneIndex=t)}setSceneIndex(t){if(this.view){this.view.focusSceneIndex=t;const i=this._pageState.getFullPath(t);i&&this.setFullPath(i)}}async destroy(t,i,n,r){var s,o,a,l;if(this.status!=="destroyed"){this.status="destroyed";try{await je.notifyApp(this.kind,"destroy",{appId:this.id}),await this.appEmitter.emit("destroy",{error:r})}catch(u){console.error("[WindowManager]: notifyApp error",u.message,u.stack)}this.appEmitter.clearListeners(),this.sideEffectManager.flushAll(),L.emit(`destroy-${this.id}`,{error:r}),t&&((s=this.boxManager)==null||s.closeBox(this.id,n)),i&&(this.store.cleanAppAttributes(this.id),this.scenePath&&Po(this.manager.room,this.scenePath)),this.appProxies.delete(this.id),this.viewManager.destroyView(this.id),this.manager.appStatus.delete(this.id),(o=this.manager.refresher)==null||o.remove(this.id),(a=this.manager.refresher)==null||a.remove(this.stateKey),(l=this.manager.refresher)==null||l.remove(`${this.id}-fullPath`),this._prevFullPath=void 0,this.camera$.destroy(),this.size$.destroy(),this.box$.destroy()}}close(){return this.destroy(!0,!0,!1)}}class Jg{constructor(t){this.displayer=t,this.views=new Map}createView(t){const i=Ld(this.displayer);return this.views.set(t,i),i}getView(t){return this.views.get(t)}destroyView(t){const i=this.views.get(t);if(i){try{i.release()}catch{}this.views.delete(t)}}setViewScenePath(t,i){const n=this.views.get(t);n&&(n.focusScenePath=i)}destroy(){this.views.forEach(t=>{try{t.release()}catch{}}),this.views.clear()}}const Ld=e=>{const t=e.views.createView();return Kg(t),t},Kg=e=>{e.setCameraBound({maxContentMode:()=>10,minContentMode:()=>.1})};class qg{constructor(t){var n;this.manager=t,this.started=!1,this.mainViewIsAddListener=!1,this.store=this.manager.store,this.sideEffectManager=new be.SideEffectManager,this.startListenWritableChange=()=>{this.sideEffectManager.add(()=>L.on("writableChange",r=>{r&&this.ensureCameraAndSize()}))},this.addCameraReaction=()=>{var r;(r=this.manager.refresher)==null||r.add(me.MainViewCamera,this.cameraReaction)},this.cameraReaction=()=>E.reaction(()=>this.mainViewCamera,r=>{r&&r.id!==this.manager.uid&&this.synchronizer.onRemoteUpdate(r,this.mainViewSize)},{fireImmediately:!0}),this.sizeChangeHandler=b.debounce(r=>{},30),this.onUpdateContainerSizeRatio=()=>{const r=this.store.getMainViewSize();this.sizeChangeHandler(r),r.id===this.manager.uid&&this.setCameraAndSize()},this.onCameraUpdatedByDevice=r=>{this.synchronizer.onLocalCameraUpdate(r);const s=this.getStageSize();s&&!b.isEqual(s,this.mainViewSize)&&this.setMainViewSize(s)},this.mainViewClickListener=()=>{this.mainViewClickHandler()},this.setMainViewSize=b.debounce(r=>{this.store.setMainViewSize(tt(Q({},r),{id:this.manager.uid}))},50),this.onCameraOrSizeUpdated=()=>{ie.emit("cameraStateChange",this.cameraState)},this.synchronizer=new Dd(r=>this.store.setMainViewCamera(tt(Q({},r),{id:this.manager.uid}))),this.mainView=this.createMainView(),this.moveCameraSizeByAttributes(),L.once("mainViewMounted").then(()=>{this.addMainViewListener(),this.start(),this.ensureCameraAndSize(),this.startListenWritableChange()}),this.sideEffectManager.add(()=>L.on("containerSizeRatioUpdate",this.onUpdateContainerSizeRatio)),this.sideEffectManager.add(()=>L.on("startReconnect",()=>{yu(this.mainView)}));const i=(n=this.manager.boxManager)==null?void 0:n.stageRect;i&&this.synchronizer.setRect(i),this.sideEffectManager.add(()=>L.on("playgroundSizeChange",r=>{this.synchronizer.setRect(r)}))}ensureCameraAndSize(){(!this.mainViewCamera||!this.mainViewSize)&&(this.manager.dispatchInternalEvent(Z.InitMainViewCamera),this.setCameraAndSize())}get mainViewCamera(){return this.store.getMainViewCamera()}get mainViewSize(){return this.store.getMainViewSize()}get didRelease(){return b.get(this.view,["didRelease"])}moveCameraSizeByAttributes(){this.synchronizer.onRemoteUpdate(this.mainViewCamera,this.mainViewSize)}start(){this.started||(this.sizeChangeHandler(this.mainViewSize),this.addCameraListener(),this.addCameraReaction(),this.started=!0)}setCameraAndSize(){const t=this.getStageSize();if(t){const i=tt(Q({},this.mainView.camera),{id:this.manager.uid}),n=tt(Q({},t),{id:this.manager.uid});this.store.setMainViewCameraAndSize(i,n)}}get view(){return this.mainView}get cameraState(){return Q(Q({},this.view.camera),this.view.size)}createMainView(){const t=Ld(this.manager.displayer),i=this.store.getMainViewScenePath();return i&&gi(t,i),this.synchronizer.setView(t),t}onReconnect(){if(this.didRelease)this.rebind();else{const t=this.store.getMainViewScenePath();this.setFocusScenePath(t)}}setFocusScenePath(t){if(t)return gi(this.view,t)}rebind(){const t=this.mainView.divElement,i=this.mainView.disableCameraTransform;this.stop(),yu(this.mainView),this.removeMainViewListener(),this.mainView=this.createMainView(),this.mainView.disableCameraTransform=i,this.mainView.divElement=t,this.addMainViewListener(),this.start()}getStageSize(){var i;const t=(i=this.manager.boxManager)==null?void 0:i.stageRect;if(t)return{width:t.width,height:t.height}}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)),this.mainViewIsAddListener=!1}async mainViewClickHandler(){var t;!this.manager.canOperate||(this.store.cleanFocus(),(t=this.manager.boxManager)==null||t.blurAllBox())}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)}stop(){var t,i;this.removeCameraListener(),(t=this.manager.refresher)==null||t.remove(me.MainViewCamera),(i=this.manager.refresher)==null||i.remove(me.MainViewSize),this.started=!1}destroy(){this.removeMainViewListener(),this.stop(),this.sideEffectManager.flushAll()}}class em{constructor(t){this.context=t,this.addRedoUndoListeners=i=>{if(i===void 0)this.addViewCallbacks(this.context.mainView(),this.onCanRedoStepsUpdate,this.onCanUndoStepsUpdate);else{const n=this.context.getAppProxy(i);n&&n.view&&this.addViewCallbacks(n.view,this.onCanRedoStepsUpdate,this.onCanUndoStepsUpdate)}},this.addViewCallbacks=(i,n,r)=>{n(i.canRedoSteps),r(i.canUndoSteps),i.callbacks.on("onCanRedoStepsUpdate",n),i.callbacks.on("onCanUndoStepsUpdate",r)},this.disposeViewCallbacks=i=>{i.callbacks.off("onCanRedoStepsUpdate",this.onCanRedoStepsUpdate),i.callbacks.off("onCanUndoStepsUpdate",this.onCanUndoStepsUpdate)},this.onCanRedoStepsUpdate=i=>{ie.emit("canRedoStepsChange",i)},this.onCanUndoStepsUpdate=i=>{ie.emit("canUndoStepsChange",i)},this.disposePrevFocusViewRedoUndoListeners=i=>{let n;if(i===void 0)n=this.context.mainView();else{const r=this.context.getAppProxy(i);r&&r.view&&(n=r.view)}n&&this.disposeViewCallbacks(n)},L.on("focusedChange",i=>{this.disposePrevFocusViewRedoUndoListeners(i.prev),setTimeout(()=>{this.addRedoUndoListeners(i.focused)},0)}),L.on("rootDirRemoved",()=>{this.disposePrevFocusViewRedoUndoListeners(t.focus()),this.addRedoUndoListeners(t.focus())}),this.addRedoUndoListeners(t.focus())}destroy(){this.disposePrevFocusViewRedoUndoListeners(this.context.focus())}}class tm{constructor(t){this.windowManger=t,this.appProxies=new Map,this.appStatus=new Map,this.store=Xg,this.isReplay=this.windowManger.isReplay,this.mainViewScenesLength=0,this.callbacksNode=null,this.appCreateQueue=new mg,this.sideEffectManager=new be.SideEffectManager,this.sceneState=null,this.rootDirRemoving=!1,this.onRemoveScenes=async i=>{var r,s;const{scenePath:n}=i;if(n===ze){await this.onRootDirRemoved(),this.dispatchInternalEvent(Z.RootDirRemoved);return}if(Rg(n)){let o=this.mainView.focusSceneIndex||0,a=(r=this.callbacksNode)==null?void 0:r.scenes[o];a||(o=0,a=(s=this.callbacksNode)==null?void 0:s.scenes[o]),a&&this.setMainViewScenePath(`${ze}${a}`),await this.setMainViewSceneIndex(o)}else this.appProxies.forEach(o=>{o.onRemoveScene(n)})},this.onReadonlyChanged=()=>{this.appProxies.forEach(i=>{i.emitAppIsWritableChange()})},this.onPlayerSeekStart=async()=>{await this.closeAll()},this.onPlayerSeekDone=async i=>{await this.attributesUpdateCallback(this.attributes.apps),this.appProxies.forEach(n=>{n.onSeek(i)})},this.createRootDirScenesCallback=()=>{let i=!1;this.callbacksNode&&(this.callbacksNode.dispose(),i=!0),this.callbacksNode=this.displayer.createScenesCallback(ze,{onAddScene:this.onSceneChange,onRemoveScene:async(n,r)=>{await this.onSceneChange(n),L.emit("rootDirSceneRemoved",r)}}),this.callbacksNode&&(this.updateSceneState(this.callbacksNode),this.mainViewScenesLength=this.callbacksNode.scenes.length,i&&this.emitMainViewScenesChange(this.callbacksNode.scenes.length))},this.removeSceneByIndex=async i=>{var s;const n=Oa(i,this.windowManger.pageState);this.setSceneIndexWithoutSync(n),this.dispatchInternalEvent(Z.SetAppFocusIndex,{type:"main",index:n});const r=(s=this.callbacksNode)==null?void 0:s.scenes[i];return setTimeout(()=>{r&&Po(this.room,`${ze}${r}`,i)},100),new Promise((o,a)=>{L.once("rootDirSceneRemoved").then(l=>{l===r&&o(!0)}).catch(l=>{console.log(`[WindowManager]: removePage error: ${l}`),a(!1)})})},this.setSceneIndexWithoutSync=i=>{var r;const n=(r=this.callbacksNode)==null?void 0:r.scenes[i];n&&this.mainViewProxy.setFocusScenePath(`${ze}${n}`)},this.onSceneChange=i=>(this.mainViewScenesLength=i.scenes.length,this.updateSceneState(i),this.emitMainViewScenesChange(this.mainViewScenesLength)),this.emitMainViewScenesChange=i=>Promise.all([ie.emit("mainViewScenesLengthChange",i),L.emit("changePageState")]),this.updateSceneState=i=>{const n=this.store.getMainViewSceneIndex()||0;let r=i.scenes[n];r||(r=i.scenes[this.mainView.focusSceneIndex||0]),this.sceneState={scenePath:`${ze}${r}`,contextPath:i.path,index:n,scenes:i.scenes.map(s=>({name:s})),sceneName:r},ie.emit("sceneStateChange",this.sceneState)},this.onBoxMove=i=>{this.dispatchInternalEvent(Z.AppMove,i),this.store.updateAppState(i.appId,Le.Position,{x:i.x,y:i.y})},this.onBoxResize=i=>{i.width&&i.height&&(this.dispatchInternalEvent(Z.AppResize,i),this.store.updateAppState(i.appId,Le.Size,{width:i.width,height:i.height}))},this.onBoxFocus=i=>{this.windowManger.safeSetAttributes({focus:i.appId})},this.onBoxClose=i=>{const n=this.appProxies.get(i.appId);n&&n.destroy(!1,!0,!0,i.error)},this.onBoxStateChange=i=>{this.dispatchInternalEvent(Z.AppBoxStateChange,i)},this.addAppsChangeListener=()=>{var i;(i=this.refresher)==null||i.add("apps",()=>Pd(()=>this.attributes.apps,()=>{this.attributesUpdateCallback(this.attributes.apps)}))},this.addAppCloseListener=()=>{var i;(i=this.refresher)==null||i.add("appsClose",()=>Og(this.attributes.apps,()=>{this.onAppDelete(this.attributes.apps)}))},this.onMainViewIndexChange=i=>{i!==void 0&&this._prevSceneIndex!==i&&(ie.emit("mainViewSceneIndexChange",i),L.emit("changePageState"),this.callbacksNode&&this.updateSceneState(this.callbacksNode),this._prevSceneIndex=i)},this.onFocusChange=i=>{var n;this._prevFocused!==i&&(ie.emit("focusedChange",i),L.emit("focusedChange",{focused:i,prev:this._prevFocused}),this._prevFocused=i,i!==void 0&&((n=this.boxManager)==null||n.focusBox({appId:i}),setTimeout(()=>{const r=this.appProxies.get(i);r&&je.notifyApp(r.kind,"focus",{appId:i})},0)))},this.attributesUpdateCallback=b.debounce(i=>this._attributesUpdateCallback(i),100),this.onRegisteredChange=i=>{!i||Object.entries(i).forEach(([n,r])=>{je.appClasses.has(n)||je.register({kind:n,src:r.src,name:r.name})})},this.onMinimized=i=>{var n,r;((n=this.boxManager)==null?void 0:n.minimized)!==i&&(i===!0&&((r=this.boxManager)==null||r.blurAllBox()),setTimeout(()=>{var s;(s=this.boxManager)==null||s.setMinimized(Boolean(i))},0))},this.onAppDelete=async i=>{const n=Object.keys(i);for(const[r,s]of this.appProxies.entries())n.includes(r)||await s.destroy(!0,!1,!0)},this.closeAll=async()=>{for(const[i,n]of this.appProxies.entries())await n.destroy(!0,!1,!0)},this.displayerStateListener=i=>{const n=i.sceneState;if(n){const r=n.scenePath;this.appProxies.forEach(s=>{s.scenePath&&r.startsWith(s.scenePath)&&(s.emitAppSceneStateChange(n),s.setFullPath(r))})}this.appProxies.forEach(r=>{r.appEmitter.emit("roomStateChange",i)}),i.roomMembers&&L.emit("roomMembersChange",this.members),L.emit("observerIdChange",this.displayer.observerId)},this.displayerWritableListener=i=>{var s,o;const n=!i,r=this.windowManger.readonly===void 0||this.windowManger.readonly===!1;this.windowManger.readonly===void 0?(s=this.boxManager)==null||s.setReadonly(i):(o=this.boxManager)==null||o.setReadonly(!(n&&r)),this.appProxies.forEach(a=>{a.emitAppIsWritableChange()}),n===!0?(this.mainView.disableCameraTransform=!1,this.room&&this.room.disableSerialization===!0&&(this.room.disableSerialization=!1)):this.mainView.disableCameraTransform=!0,L.emit("writableChange",n)},this.updateSceneIndex=()=>{const i=this.store.getMainViewScenePath(),n=Js(i),r=mi(this.displayer)[n];if(r.length){const s=i.replace(n,"").replace("/",""),o=r.findIndex(a=>a.name===s);b.isInteger(o)&&o>=0&&this.safeSetAttributes({_mainSceneIndex:o})}},this.updateRootDirRemoving=i=>{this.rootDirRemoving=i},this.displayer=t.displayer,this.store.setContext({getAttributes:()=>this.attributes,safeSetAttributes:i=>this.safeSetAttributes(i),safeUpdateAttributes:(i,n)=>this.safeUpdateAttributes(i,n)}),this.mainViewProxy=new qg(this),this.viewManager=new Jg(this.displayer),this.appListeners=new Vg(this),this.displayer.callbacks.on(this.eventName,this.displayerStateListener),this.appListeners.addListeners(),this.refresher=qf,this.refresher.setRoom(this.room),this.refresher.setContext({emitter:L}),this.sideEffectManager.add(()=>()=>{var i,n,r;this.appCreateQueue.destroy(),this.mainViewProxy.destroy(),(i=this.refresher)==null||i.destroy(),this.viewManager.destroy(),(n=this.boxManager)==null||n.destroy(),(r=this.callbacksNode)==null||r.dispose()}),L.once("onCreated").then(()=>this.onCreated()),L.on("onReconnected",()=>this.onReconnected()),E.isPlayer(this.displayer)&&(L.on("seekStart",this.onPlayerSeekStart),L.on("seek",this.onPlayerSeekDone)),L.on("removeScenes",this.onRemoveScenes),L.on("setReadonly",this.onReadonlyChanged),this.createRootDirScenesCallback(),je.setSyncRegisterApp(i=>{this.safeUpdateAttributes([me.Registered,i.kind],i)})}async onRootDirRemoved(t=!0){this.setMainViewScenePath(Sd),this.createRootDirScenesCallback();for(const[i,n]of this.appProxies.entries())n.view&&await this.closeApp(i,t);this.mainViewProxy.rebind(),L.emit("rootDirRemoved"),this.updateRootDirRemoving(!1)}get eventName(){return E.isRoom(this.displayer)?"onRoomStateChanged":"onPlayerStateChanged"}get attributes(){return this.windowManger.attributes}get canOperate(){return this.windowManger.canOperate}get room(){return E.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)}get uid(){var t;return((t=this.room)==null?void 0:t.uid)||""}get members(){return Fg(this.displayer.state.roomMembers)}getMainViewSceneDir(){const t=this.store.getMainViewScenePath();if(t)return Js(t);throw new Error("[WindowManager]: mainViewSceneDir not found")}async onCreated(){var t,i,n,r,s,o;if(await this.attributesUpdateCallback(this.attributes.apps),L.emit("updateManagerRect"),wt.on("move",this.onBoxMove),wt.on("resize",this.onBoxResize),wt.on("focus",this.onBoxFocus),wt.on("close",this.onBoxClose),wt.on("boxStateChange",this.onBoxStateChange),this.addAppsChangeListener(),this.addAppCloseListener(),(t=this.refresher)==null||t.add("maximized",()=>E.autorun(()=>{var l;const a=this.attributes.maximized;(l=this.boxManager)==null||l.setMaximized(Boolean(a))})),(i=this.refresher)==null||i.add("minimized",()=>E.autorun(()=>{const a=this.attributes.minimized;this.onMinimized(a)})),(n=this.refresher)==null||n.add("mainViewIndex",()=>E.autorun(()=>{const a=b.get(this.attributes,"_mainSceneIndex");this.onMainViewIndexChange(a)})),(r=this.refresher)==null||r.add("focusedChange",()=>E.autorun(()=>{const a=b.get(this.attributes,"focus");this.onFocusChange(a)})),(s=this.refresher)==null||s.add("registeredChange",()=>E.autorun(()=>{const a=b.get(this.attributes,me.Registered);this.onRegisteredChange(a)})),!this.attributes.apps||Object.keys(this.attributes.apps).length===0){const a=this.store.getMainViewScenePath();if(!a)return;this.resetScenePath(a)}this.displayerWritableListener(!((o=this.room)!=null&&o.isWritable)),this.displayer.callbacks.on("onEnableWriteNowChanged",this.displayerWritableListener),this._prevFocused=this.attributes.focus,this.sideEffectManager.add(()=>{const a=new em({mainView:()=>this.mainViewProxy.view,focus:()=>this.attributes.focus,getAppProxy:l=>this.appProxies.get(l)});return()=>a.destroy()})}async _attributesUpdateCallback(t){if(t&&ye.container){const i=Object.keys(t);i.length===0&&this.appCreateQueue.emitReady();const n=i.map(r=>({id:r,createdAt:t[r].createdAt}));for(const{id:r}of b.orderBy(n,"createdAt","asc"))if(!this.appProxies.has(r)&&!this.appStatus.has(r)){const s=t[r];try{if(!this.attributes[r])throw new Error("appAttributes is undefined");this.appCreateQueue.push(()=>(this.appStatus.set(r,No.StartCreate),this.baseInsertApp({kind:s.kind,options:s.options,isDynamicPPT:s.isDynamicPPT},r,!1))),this.focusByAttributes(t)}catch(o){console.warn("[WindowManager]: Insert App Error",o)}}}}refresh(){this.attributesUpdateCallback(this.attributes.apps)}setBoxManager(t){this.boxManager=t}resetMaximized(){var t;(t=this.boxManager)==null||t.setMaximized(Boolean(this.store.getMaximized()))}resetMinimized(){var t;(t=this.boxManager)==null||t.setMinimized(Boolean(this.store.getMinimized()))}bindMainView(t,i){const n=this.mainViewProxy.view;n.disableCameraTransform=i,n.divElement=t,n.focusScenePath||this.setMainViewFocusPath(),L.emit("mainViewMounted")}setMainViewFocusPath(t){var n;const i=t||this.store.getMainViewScenePath();if(i)return gi(this.mainView,i),((n=this.mainView)==null?void 0:n.focusScenePath)===i}resetScenePath(t){this.displayer.state.sceneState.scenePath!==t&&ko(this.room,t)}async addApp(t,i){Li("addApp",t);const{appId:n,needFocus:r}=await this.beforeAddApp(t,i),s=await this.baseInsertApp(t,n,!0,r);return this.afterAddApp(s),s==null?void 0:s.id}async beforeAddApp(t,i){var o,a;const n=await kg(t.kind);this.appStatus.set(n,No.StartCreate);const r=(o=t.attributes)!=null?o:{};this.safeUpdateAttributes([n],r),this.store.setupAppAttributes(t,n,i);const s=!((a=this.boxManager)!=null&&a.minimized);return s&&this.store.setAppFocus(n,!0),{appId:n,needFocus:s}}afterAddApp(t){var i,n;if(t&&t.box){const r=t.box;wt.emit("move",{appId:t.id,x:r==null?void 0:r.intrinsicX,y:r==null?void 0:r.intrinsicY}),this.store.updateAppState(t.id,Le.ZIndex,r.zIndex)}(i=this.boxManager)!=null&&i.minimized&&((n=this.boxManager)==null||n.setMinimized(!1,!1))}async closeApp(t,i=!0){const n=this.appProxies.get(t);n&&n.destroy(!0,i,!1)}async baseInsertApp(t,i,n,r){if(this.appProxies.has(i)){console.warn("[WindowManager]: app duplicate exists and cannot be created again");return}const s=new _a(t,this,i,n);if(s)return await s.baseInsertApp(r),this.appStatus.delete(i),s;throw this.appStatus.delete(i),new Error("[WindowManger]: initialize AppProxy failed")}safeSetAttributes(t){this.windowManger.safeSetAttributes(t)}safeUpdateAttributes(t,i){this.windowManger.safeUpdateAttributes(t,i)}async setMainViewScenePath(t){if(this.room){const i=this.displayer.scenePathType(t);if(Js(t)!==ze)throw new Error('[WindowManager]: main view scenePath must in root dir "/"');if(i===E.ScenePathType.None)throw new Error(`[WindowManager]: ${t} not valid scene`);if(i===E.ScenePathType.Page)await this._setMainViewScenePath(t);else if(i===E.ScenePathType.Dir){const r=Dg(this.displayer,t);r&&await this._setMainViewScenePath(r)}}}async _setMainViewScenePath(t){this.setMainViewFocusPath(t)&&(this.safeSetAttributes({_mainScenePath:t}),this.store.setMainViewFocusPath(this.mainView),this.updateSceneIndex(),this.dispatchSetMainViewScenePath(t))}async setMainViewSceneIndex(t){var i;if(this.room){if(this.store.getMainViewSceneIndex()===t)return;const n=(i=this.callbacksNode)==null?void 0:i.scenes[t],r=`${ze}${n}`;if(n)this.setMainViewFocusPath(r)&&(this.store.setMainViewScenePath(r),this.safeSetAttributes({_mainSceneIndex:t}),this.dispatchSetMainViewScenePath(r));else throw new Error(`[WindowManager]: ${t} not valid index`)}}dispatchSetMainViewScenePath(t){this.dispatchInternalEvent(Z.SetMainViewScenePath,{nextScenePath:t}),ko(this.room,t)}getAppInitPath(t){var n;const i=this.store.getAppAttributes(t);if(i)return(n=i==null?void 0:i.options)==null?void 0:n.scenePath}safeDispatchMagixEvent(t,i){this.canOperate&&this.displayer.dispatchMagixEvent(t,i)}focusByAttributes(t){var i;if(t&&Object.keys(t).length===((i=this.boxManager)==null?void 0:i.boxSize)){const n=this.store.focus;n&&this.boxManager.focusBox({appId:n})}}async onReconnected(){const i=Array.from(this.appProxies.values()).map(n=>n.onReconnected());this.mainViewProxy.onReconnect(),await Promise.all(i)}notifyContainerRectUpdate(t){this.appProxies.forEach(i=>{i.appEmitter.emit("containerRectUpdate",t)})}dispatchInternalEvent(t,i){this.safeDispatchMagixEvent(To,{eventName:t,payload:i})}destroy(){this.displayer.callbacks.off(this.eventName,this.displayerStateListener),this.displayer.callbacks.off("onEnableWriteNowChanged",this.displayerWritableListener),this.appListeners.removeListeners(),wt.clearListeners(),L.clearListeners(),this.appProxies.size&&this.appProxies.forEach(t=>{t.destroy(!0,!1,!0)}),ie.clearListeners(),this.sideEffectManager.flushAll(),this._prevFocused=void 0,this._prevSceneIndex=void 0}}/*! *****************************************************************************
2
+ ;return ${t}`)();return typeof i=="undefined"&&(i=window[t]),i},Ag=async(e,t,i)=>{const n=i||Ig+t;ie.emit("loadApp",{kind:t,status:"start"});try{const r=await Eg(e);if(!r||r.length===0){ie.emit("loadApp",{kind:t,status:"failed",reason:"script is empty."});return}try{const s=wu(r,n);return ie.emit("loadApp",{kind:t,status:"success"}),s}catch(s){if(s.message.includes("Can only have one anonymous define call per script file")){const o=window.define;typeof o=="function"&&o.amd&&delete o.amd;const a=wu(r,n);return ie.emit("loadApp",{kind:t,status:"success"}),a}ie.emit("loadApp",{kind:t,status:"failed",reason:s.message})}}catch(r){ie.emit("loadApp",{kind:t,status:"failed",reason:r.message})}};async function Tg(e,t){const{timeout:i=1e4}=t,n=new AbortController,r=setTimeout(()=>n.abort(),i),s=await fetch(e,tt(Q({},t),{signal:n.signal,headers:{"content-type":"text/plain"}}));return clearTimeout(r),s}class Ng{constructor(){this.kindEmitters=new Map,this.registered=new Map,this.appClassesCache=new Map,this.appClasses=new Map,this.syncRegisterApp=null,this.onSyncRegisterAppChange=t=>{this.register({kind:t.kind,src:t.src})}}setSyncRegisterApp(t){this.syncRegisterApp=t}async register(t){this.appClassesCache.delete(t.kind),this.registered.set(t.kind,t);const i=t.src;let n;if(typeof i=="string"?(n=async()=>{let r=await Ag(i,t.kind,t.name);if(r)return r.__esModule&&(r=r.default),r;throw new Error(`[WindowManager]: load remote script failed, ${i}`)},this.syncRegisterApp&&this.syncRegisterApp({kind:t.kind,src:i,name:t.name})):typeof i=="function"?n=i:n=async()=>i,this.appClasses.set(t.kind,async()=>{let r=this.appClassesCache.get(t.kind);return r||(r=n(),this.appClassesCache.set(t.kind,r)),r}),t.addHooks){const r=this.createKindEmitter(t.kind);r&&t.addHooks(r)}}unregister(t){this.appClasses.delete(t),this.appClassesCache.delete(t),this.registered.delete(t);const i=this.kindEmitters.get(t);i&&(i.clearListeners(),this.kindEmitters.delete(t))}async notifyApp(t,i,n){const r=this.kindEmitters.get(t);await(r==null?void 0:r.emit(i,n))}createKindEmitter(t){if(!this.kindEmitters.has(t)){const i=new Qt.default;this.kindEmitters.set(t,i)}return this.kindEmitters.get(t)}}const je=new Ng,kg=async e=>{var i,n;const t=await((i=je.appClasses.get(e))==null?void 0:i());return t&&((n=t.config)==null?void 0:n.singleton)?e:`${e}-${cg.v4().replace("-","").slice(0,8)}`},gi=(e,t)=>{if(e.focusScenePath!==t)return e.focusScenePath=t,e},yu=e=>{e.didRelease||e.release()},ko=(e,t)=>{if(e&&e.isWritable&&e.state.sceneState.scenePath!==t){const i=t==="/"?"":t;e.setScenePath(i)}},Pg=(e,t,i)=>{var n;if(e&&t){const s=(n=mi(e)[t])==null?void 0:n[i];if(s)return`${t}/${s.name}`}},Po=(e,t,i)=>{e&&e.scenePathType(t)!==E.ScenePathType.None&&e.removeScenes(t,i)},zg=(e,t)=>{L.once(e).then(t)};b.debounce((e,t)=>{e.emit("mainViewModeChange",t)},200);const Dg=(e,t,i=0)=>{const n=mi(e)[t];if(!n)return;const r=n[i];if(!r)return;const s=r.name;return t===ze?`/${s}`:`${t}/${s}`},mi=e=>e.entireScenes(),ai=(e,t,i,n)=>e==null?void 0:e.putScenes(t,i,n),Lg=e=>e.startsWith("/"),Js=e=>{const t=e.split("/");t.pop();let i=t.join("/");return i===""&&(i="/"),i},jg=e=>e.endsWith("/")?e.slice(0,-1):e,xu=e=>{const t=e.split(".").map(i=>i.padStart(2,"0")).join("");return parseInt(t)},Su=e=>new Promise(t=>setTimeout(t,e)),Rg=e=>e.split("").reduce((i,n)=>(n===ze&&(i+=1),i),0)===1;class Vg{constructor(t){this.manager=t,this.displayer=this.manager.displayer,this.mainMagixEventListener=i=>{if(i.authorId!==this.displayer.observerId){const n=i.payload;switch(n.eventName){case Z.AppMove:{this.appMoveHandler(n.payload);break}case Z.AppResize:{this.appResizeHandler(n.payload);break}case Z.AppBoxStateChange:{this.boxStateChangeHandler(n.payload);break}case Z.SetMainViewScenePath:{this.setMainViewScenePathHandler(n.payload);break}case Z.MoveCamera:{this.moveCameraHandler(n.payload);break}case Z.MoveCameraToContain:{this.moveCameraToContainHandler(n.payload);break}case Z.CursorMove:{this.cursorMoveHandler(n.payload);break}case Z.RootDirRemoved:{this.rootDirRemovedHandler();break}case Z.Refresh:{this.refreshHandler();break}case Z.InitMainViewCamera:{this.initMainViewCameraHandler();break}case Z.SetAppFocusIndex:{this.setAppFocusViewIndexHandler(n.payload);break}}}},this.appMoveHandler=i=>{var n;(n=this.boxManager)==null||n.moveBox(i)},this.appResizeHandler=i=>{var n,r;(n=this.boxManager)==null||n.resizeBox(Object.assign(i,{skipUpdate:!0})),(r=this.manager.room)==null||r.refreshViewSize()},this.boxStateChangeHandler=i=>{ie.emit("boxStateChange",i)},this.setMainViewScenePathHandler=({nextScenePath:i})=>{gi(this.manager.mainView,i),ie.emit("mainViewScenePathChange",i)},this.moveCameraHandler=i=>{b.isEqual(b.omit(i,["animationMode"]),Q({},this.manager.mainView.camera))||this.manager.mainView.moveCamera(i)},this.moveCameraToContainHandler=i=>{this.manager.mainView.moveCameraToContain(i)},this.cursorMoveHandler=i=>{L.emit("cursorMove",i)},this.rootDirRemovedHandler=()=>{this.manager.createRootDirScenesCallback(),this.manager.mainViewProxy.rebind(),L.emit("rootDirRemoved")},this.refreshHandler=()=>{this.manager.windowManger._refresh()},this.initMainViewCameraHandler=()=>{this.manager.mainViewProxy.addCameraReaction()},this.setAppFocusViewIndexHandler=i=>{if(i.type==="main")this.manager.setSceneIndexWithoutSync(i.index);else if(i.type==="app"&&i.appID){const n=this.manager.appProxies.get(i.appID);n&&n.setSceneIndexWithoutSync(i.index)}}}get boxManager(){return this.manager.boxManager}addListeners(){this.displayer.addMagixEventListener(To,this.mainMagixEventListener)}removeListeners(){this.displayer.removeMagixEventListener(To,this.mainMagixEventListener)}}class Md extends Error{constructor(){super(...arguments);this.message="[WindowManager]: app duplicate exists and cannot be created again"}}class Bg extends Error{constructor(t){super(`[WindowManager]: app ${t} need register or provide src`)}}class Ye extends Error{constructor(){super(...arguments);this.message="[WindowManager]: AppManager must be initialized"}}class Id extends Error{constructor(t){super(`[WindowManager]: white-web-sdk version must large than ${t}`)}}class bd extends Error{constructor(){super(...arguments);this.message="[WindowManager]: kind must be a valid string"}}class Ed extends Error{constructor(){super(...arguments);this.message="[WindowManager]: box need created"}}class Ad extends Error{constructor(){super(...arguments);this.message='[WindowManager]: ScenePath should start with "/"'}}class Td extends Error{constructor(){super(...arguments);this.message="[WindowManager]: boxManager not found"}}class Nd extends Error{constructor(){super(...arguments);this.message="[WindowManager]: room phase only Connected can be bindContainer"}}const kd=e=>(t,i)=>{if(t!==void 0)if(E.listenUpdated){const n=r=>{r.map(o=>o.kind).includes(e)&&i()};return E.listenUpdated(t,n),i(),()=>E.unlistenUpdated(t,n)}else return E.reaction(()=>t,()=>{i()},{fireImmediately:!0})},Pd=(e,t,i)=>{let n=null;const r=E.reaction(e,()=>{n&&(n(),n=null);const s=e();b.isObject(s)?(n=()=>E.unlistenUpdated(s,t),E.listenUpdated(s,t)):i==null||i(s)},{fireImmediately:!0});return()=>{n==null||n(),r()}},Og=kd(E.UpdateEventKind.Removed);kd(E.UpdateEventKind.Inserted);const Ks=Object.keys;function Cu(e){return Boolean(b.has(e,"__isRef"))}function _g(e){return{k:be.genUID(),v:e,__isRef:!0}}class Ug{constructor(){this.listeners=new Set}get length(){return this.listeners.size}dispatch(t){this.listeners.forEach(i=>i(t))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}}const Ge="_WM-STORAGE_";class Mu{constructor(t,i,n){if(this._sideEffect=new be.SideEffectManager,this._destroyed=!1,this._refMap=new WeakMap,this._lastValue=new Map,this.onStateChanged=new Ug,n&&!b.isObject(n))throw new Error(`Default state for Storage ${i} is not an object.`);this._context=t,this.id=i||null,this._state={};const r=this._getRawState(this._state);this._context.isWritable&&(this.id===null?t.isAddApp&&n&&this.setState(n):(r===this._state||!b.isObject(r))&&(b.get(this._context.getAttributes(),[Ge])||this._context.updateAttributes([Ge],{}),this._context.updateAttributes([Ge,this.id],this._state),n&&this.setState(n))),Ks(r).forEach(s=>{if(!(this.id===null&&s===Ge))try{const o=b.isObject(r[s])?JSON.parse(JSON.stringify(r[s])):r[s];Cu(o)?(this._state[s]=o.v,b.isObject(o.v)&&this._refMap.set(o.v,o)):this._state[s]=o}catch(o){console.error(o)}}),this._sideEffect.addDisposer(Pd(()=>this.id===null?t.getAttributes():b.get(t.getAttributes(),[Ge,this.id]),this._updateProperties.bind(this),this.destroy.bind(this)))}get state(){return this._destroyed&&console.warn(`Accessing state on destroyed Storage "${this.id}"`),this._state}addStateChangedListener(t){return this.onStateChanged.addListener(t),()=>this.onStateChanged.removeListener(t)}ensureState(t){return this.setState(Ks(t).reduce((i,n)=>(b.has(this._state,n)||(i[n]=t[n]),i),{}))}setState(t){if(this._destroyed){console.error(new Error(`Cannot call setState on destroyed Storage "${this.id}".`));return}if(!this._context.isWritable){console.error(new Error(`Cannot setState on Storage "${this.id}" without writable access`),t);return}const i=Ks(t);i.length>0&&i.forEach(n=>{const r=t[n];if(r!==this._state[n])if(r===void 0)this._lastValue.set(n,this._state[n]),delete this._state[n],this._setRawState(n,r);else{this._lastValue.set(n,this._state[n]),this._state[n]=r;let s=r;if(b.isObject(r)){let o=this._refMap.get(r);o||(o=_g(r),this._refMap.set(r,o)),s=o}this._setRawState(n,s)}})}emptyStorage(){if(!(b.size(this._state)<=0)){if(this._destroyed){console.error(new Error(`Cannot empty destroyed Storage "${this.id}".`));return}if(!this._context.isWritable){console.error(new Error(`Cannot empty Storage "${this.id}" without writable access.`));return}this.setState(b.mapValues(this._state,b.noop))}}deleteStorage(){if(this.id===null)throw new Error("Cannot delete main Storage");if(!this._context.isWritable){console.error(new Error(`Cannot delete Storage "${this.id}" without writable access.`));return}this.destroy(),this._context.updateAttributes([Ge,this.id],void 0)}get destroyed(){return this._destroyed}destroy(){this._destroyed=!0,this._sideEffect.flushAll()}_getRawState(t){var i;return this.id===null?(i=this._context.getAttributes())!=null?i:t:b.get(this._context.getAttributes(),[Ge,this.id],t)}_setRawState(t,i){if(this.id===null){if(t===Ge)throw new Error(`Cannot set attribute internal filed "${Ge}"`);return this._context.updateAttributes([t],i)}else return this._context.updateAttributes([Ge,this.id,t],i)}_updateProperties(t){var i;if(this._destroyed){console.error(new Error(`Cannot call _updateProperties on destroyed Storage "${this.id}".`));return}if(t.length>0){const n={};for(let r=0;r<t.length;r++)try{const s=t[r],o=s.key;if(this.id===null&&o===Ge)continue;const a=b.isObject(s.value)?JSON.parse(JSON.stringify(s.value)):s.value;let l;switch(this._lastValue.has(o)&&(l=this._lastValue.get(o),this._lastValue.delete(o)),s.kind){case 2:{b.has(this._state,o)&&(l=this._state[o],delete this._state[o]),n[o]={oldValue:l};break}default:{let u=a;if(Cu(a)){const{k:c,v:d}=a,m=this._state[o];b.isObject(m)&&((i=this._refMap.get(m))==null?void 0:i.k)===c?u=m:(u=d,b.isObject(d)&&this._refMap.set(d,a))}u!==this._state[o]&&(l=this._state[o],this._state[o]=u),n[o]={newValue:u,oldValue:l};break}}}catch(s){console.error(s)}this.onStateChanged.dispatch(n)}}}class $g{constructor(t,i,n){this.appContext=t,this.appProxy=i,this.removeViewWrapper=n,this.nextPage=async()=>{const s=this.pageState.index+1;return this.jumpPage(s)},this.prevPage=async()=>{const s=this.pageState.index-1;return this.jumpPage(s)},this.jumpPage=async s=>s<0||s>=this.pageState.length?(console.warn(`[WindowManager]: index ${s} out of range`),!1):(this.appProxy.setSceneIndex(s),!0),this.addPage=async s=>{const o=s==null?void 0:s.after,a=s==null?void 0:s.scene,l=this.appProxy.scenePath;if(!!l)if(o){const u=this.pageState.index+1;ai(this.appContext.room,l,[a||{}],u)}else ai(this.appContext.room,l,[a||{}])},this.removePage=async s=>{const o=s===void 0?this.pageState.index:s;return this.pageState.length===1?(console.warn("[WindowManager]: can not remove the last page"),!1):o<0||o>=this.pageState.length?(console.warn(`[WindowManager]: page index ${s} out of range`),!1):this.appProxy.removeSceneByIndex(o)};const r=new A.Val(i.pageState);this.pageState$=r,i.appEmitter.on("pageStateChange",s=>{r.setValue(s)})}get view(){return this.appContext.view}get pageState(){return this.pageState$.value}moveCamera(t){this.appProxy.moveCamera(t)}destroy(){this.removeViewWrapper()}}const Wg=e=>{const t=document.createElement("div");t.className="netless-window-manager-playground";const i=document.createElement("div");return i.className="netless-window-manager-main-view",t.appendChild(i),e.appendChild(t),{playground:t,mainViewElement:i}},Hg=()=>{if(xu(E.WhiteVersion)<xu(gu))throw new Id(gu)},zd=(e,t)=>{const i=e==null?void 0:e.state.roomMembers;return i==null?void 0:i.find(n=>{var r;return((r=n.payload)==null?void 0:r.uid)===t})},Fg=e=>e.map(t=>{var i;return Q({uid:((i=t.payload)==null?void 0:i.uid)||""},t)});class Qg{constructor(t,i,n,r,s){this.manager=t,this.boxManager=i,this.appId=n,this.appProxy=r,this.appOptions=s,this.mobxUtils={autorun:E.autorun,reaction:E.reaction,toJS:E.toJS},this.objectUtils={listenUpdated:E.listenUpdated,unlistenUpdated:E.unlistenUpdated,listenDisposed:E.listenDisposed,unlistenDisposed:E.unlistenDisposed},this.store=this.manager.store,this.isReplay=this.manager.isReplay,this.getAttributes=()=>this.appProxy.attributes,this.getScenes=()=>{const o=this.store.getAppAttributes(this.appId);return o!=null&&o.isDynamicPPT?this.appProxy.scenes:o==null?void 0:o.options.scenes},this.createWhiteBoardView=o=>{var c;if(this.whiteBoardView)return this.whiteBoardView;let a=this.view;a||(a=this.appProxy.createAppDir());const l=document.createElement("div");l.className="window-manager-view-wrapper",(c=this.box.$content.parentElement)==null||c.appendChild(l);const u=()=>{var d;(d=this.box.$content.parentElement)==null||d.removeChild(l)};return a.divElement=l,this.isAddApp&&this.initPageSize(o),this.whiteBoardView=new $g(this,this.appProxy,u),this.whiteBoardView},this.initPageSize=o=>{if(!b.isNumber(o)||!this.appProxy.scenePath||this.appProxy.pageState.length>=o)return;if(o<=0||o>=mu)throw Error(`[WindowManager]: size ${o} muse be in range [1, ${mu}]`);const a=o-this.appProxy.pageState.length,l=this.appProxy.pageState.length,u=new Array(a).fill({}).map((c,d)=>({name:`${l+d+1}`}));ai(this.room,this.appProxy.scenePath,u)},this.getInitScenePath=()=>this.manager.getAppInitPath(this.appId),this.setAttributes=o=>{this.manager.safeSetAttributes({[this.appId]:o})},this.updateAttributes=(o,a)=>{this.manager.attributes[this.appId]&&this.manager.safeUpdateAttributes([this.appId,...o],a)},this.setScenePath=async o=>{var a;!this.appProxy.box||(this.appProxy.setFullPath(o),(a=this.room)==null||a.setScenePath(o))},this.getAppOptions=()=>typeof this.appOptions=="function"?this.appOptions():this.appOptions,this.createStorage=(o,a)=>{const l=new Mu(this,o,a);return this.emitter.on("destroy",()=>{l.destroy()}),l},this.dispatchMagixEvent=(...o)=>{var l;const a=`${this.appId}:${o[0]}`;return(l=this.manager.room)==null?void 0:l.dispatchMagixEvent(a,o[1])},this.addMagixEventListener=(o,a,l)=>{const u=`${this.appId}:${o}`;return this.manager.displayer.addMagixEventListener(u,a,l),()=>this.manager.displayer.removeMagixEventListener(u,a)},this.removeMagixEventListener=this.manager.displayer.removeMagixEventListener.bind(this.manager.displayer),this.emitter=r.appEmitter,this.isAddApp=r.isAddApp}get displayer(){return this.manager.displayer}get view(){return this.appProxy.view}get isWritable(){return this.manager.canOperate}get box(){const t=this.boxManager.getBox(this.appId);if(t)return t;throw new Ed}get room(){return this.manager.room}get members(){return this.manager.members}get memberState(){const t=zd(this.room,this.manager.uid);if(!t)throw new Error(`Member ${this.manager.uid} not found.`);return Q({uid:this.manager.uid},t)}get storage(){return this._storage||(this._storage=new Mu(this)),this._storage}}class Zg{constructor(t){this.params=t,this.sceneNode=null,this.createSceneNode=r=>(this.scenePath=r,this.sceneNode&&this.sceneNode.dispose(),this.sceneNode=this.params.displayer.createScenesCallback(r,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}),this.sceneNode),this.onSceneChange=()=>{this.params.notifyPageStateChange()};const{displayer:i,scenePath:n}=this.params;this.view=this.params.view,n&&(this.scenePath=n,this.sceneNode=i.createScenesCallback(n,{onAddScene:this.onSceneChange,onRemoveScene:this.onSceneChange}))}setView(t){this.view=t}getFullPath(t){var n;const i=(n=this.sceneNode)==null?void 0:n.scenes;if(this.scenePath&&i){const r=i[t];if(r)return`${this.scenePath}/${r}`}}toObject(){var t,i;return{index:((t=this.view)==null?void 0:t.focusSceneIndex)||0,length:((i=this.sceneNode)==null?void 0:i.scenes.length)||0}}destroy(){var t;(t=this.sceneNode)==null||t.dispose()}}class Dd{constructor(t){this.saveCamera=t,this.onRemoteUpdate=b.throttle((i,n)=>{if(this.remoteCamera=i,this.remoteSize=n,this.remoteSize&&this.rect){let r;n.width<n.height?r=this.rect.width/n.width:r=this.rect.height/n.height;const s=i.scale*r,o=()=>{var a;return(a=this.view)==null?void 0:a.moveCamera({centerX:i.centerX,centerY:i.centerY,scale:s,animationMode:E.AnimationMode.Immediately})};b.delay(o,50)}},50),this.onLocalSizeUpdate=i=>{if(this.rect&&this.view){let n;i.width<i.height?n=this.rect.width/i.width:n=this.rect.height/i.height;const r=this.view.camera.scale/n;this.view.moveCamera({scale:r,animationMode:E.AnimationMode.Immediately})}}}setRect(t){this.rect=t,this.remoteCamera&&this.remoteSize&&this.onRemoteUpdate(this.remoteCamera,this.remoteSize)}setView(t){this.view=t}onLocalCameraUpdate(t){this.saveCamera(t),this.remoteCamera=t}}class Gg{constructor(t){this.appProxy=t,this.sem=new be.SideEffectManager,this.bindView=n=>{!n||(this.synchronizer.setView(n),this.sem.add(()=>(n.callbacks.on("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice),()=>n.callbacks.off("onCameraUpdatedByDevice",this.onCameraUpdatedByDevice))))},this.onCameraUpdatedByDevice=n=>{var s;this.synchronizer.onLocalCameraUpdate(n);const r=(s=this.appProxy.box)==null?void 0:s.contentStageRect;if(r){const o={width:r.width,height:r.height,id:this.appProxy.uid};b.isEqual(o,this.appProxy.size$.value)||this.appProxy.storeSize(o)}},this.synchronizer=new Dd(n=>{this.appProxy.storeCamera(Q({id:this.appProxy.uid},n))}),this.bindView(t.view),this.sem.add(()=>this.appProxy.camera$.subscribe(n=>{const r=this.appProxy.size$.value;n&&r&&this.synchronizer.onRemoteUpdate(n,r)}));const i=this.appProxy.box;i&&i.contentStageRect&&(this.synchronizer.setRect(i.contentStageRect),this.sem.add(()=>i._contentStageRect$.subscribe(n=>{n&&this.synchronizer.setRect(n)})),this.appProxy.size$.value||this.appProxy.storeSize({id:this.appProxy.uid,width:i.contentStageRect.width,height:i.contentStageRect.height}))}destroy(){this.sem.flushAll()}}const wt=new Qt.default,Oa=(e,t)=>{let i=0;const n=t.length-1;return e===t.index?e===n?i=e-1:i=t.index+1:i=t.index,i};var me=(e=>(e.Apps="apps",e.Focus="focus",e.State="state",e.BoxState="boxState",e.MainViewCamera="mainViewCamera",e.MainViewSize="mainViewSize",e.Broadcaster="broadcaster",e.Cursors="cursors",e.Position="position",e.CursorState="cursorState",e.FullPath="fullPath",e.Registered="registered",e.Camera="camera",e.Size="size",e))(me||{});class Yg{constructor(t){this.context=t,this.setAppFocus=(i,n)=>{n?this.context.safeSetAttributes({focus:i}):this.context.safeSetAttributes({focus:void 0})}}setContext(t){this.context=t}get attributes(){return this.context.getAttributes()}apps(){return b.get(this.attributes,["apps"])}get focus(){return b.get(this.attributes,["focus"])}getAppAttributes(t){return b.get(this.apps(),[t])}getAppState(t){return b.get(this.apps(),[t,"state"])}getMaximized(){return b.get(this.attributes,["maximized"])}getMinimized(){return b.get(this.attributes,["minimized"])}setupAppAttributes(t,i,n){this.attributes.apps||this.context.safeSetAttributes({apps:{}});const s=["scenePath","title"];n||s.push("scenes");const o=b.pick(t.options,s),a={kind:t.kind,options:o,isDynamicPPT:n};typeof t.src=="string"&&(a.src=t.src),a.createdAt=Date.now(),this.context.safeUpdateAttributes(["apps",i],a),this.context.safeUpdateAttributes(["apps",i,"state"],{[Le.Size]:{},[Le.Position]:{},[Le.SceneIndex]:0})}updateAppState(t,i,n){b.get(this.attributes,["apps",t,"state"])&&this.context.safeUpdateAttributes(["apps",t,"state",i],n)}updateAppAttributes(t,i,n){this.context.safeUpdateAttributes(["apps",t,i],n)}cleanAppAttributes(t){this.context.safeUpdateAttributes(["apps",t],void 0),this.context.safeSetAttributes({[t]:void 0}),this.attributes.focus===t&&this.cleanFocus()}cleanFocus(){this.context.safeSetAttributes({focus:void 0})}getAppSceneIndex(t){var i;return(i=this.getAppState(t))==null?void 0:i[Le.SceneIndex]}getAppScenePath(t){var i,n;return(n=(i=this.getAppAttributes(t))==null?void 0:i.options)==null?void 0:n.scenePath}getMainViewScenePath(){return this.attributes._mainScenePath}getMainViewSceneIndex(){return this.attributes._mainSceneIndex}getBoxState(){return this.attributes.boxState}setMainViewScenePath(t){this.context.safeSetAttributes({_mainScenePath:t})}setMainViewSceneIndex(t){this.context.safeSetAttributes({_mainSceneIndex:t})}getMainViewCamera(){return b.get(this.attributes,["mainViewCamera"])}getMainViewSize(){return b.get(this.attributes,["mainViewSize"])}setMainViewCamera(t){this.context.safeSetAttributes({mainViewCamera:Q({},t)})}setMainViewSize(t){this.context.safeSetAttributes({mainViewSize:Q({},t)})}setMainViewCameraAndSize(t,i){this.context.safeSetAttributes({mainViewCamera:Q({},t),mainViewSize:Q({},i)})}updateCursor(t,i){b.get(this.attributes,["cursors"])||this.context.safeUpdateAttributes(["cursors"],{}),b.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"position"],i)}updateCursorState(t,i){b.get(this.attributes,["cursors",t])||this.context.safeUpdateAttributes(["cursors",t],{}),this.context.safeUpdateAttributes(["cursors",t,"cursorState"],i)}getCursorState(t){return b.get(this.attributes,["cursors",t,"cursorState"])}cleanCursor(t){this.context.safeUpdateAttributes(["cursors",t],void 0)}setMainViewFocusPath(t){const i=this.getMainViewScenePath();i&&gi(t,i)}}const Xg=new Yg({getAttributes:()=>{throw new Error("getAttributes not implemented")},safeSetAttributes:()=>{throw new Error("safeSetAttributes not implemented")},safeUpdateAttributes:()=>{throw new Error("safeUpdateAttributes not implemented")}}),Li=(...e)=>{ye.debug&&console.log("[WindowManager]:",...e)};class _a{constructor(t,i,n,r){var s;this.params=t,this.manager=i,this.boxManager=this.manager.boxManager,this.appProxies=this.manager.appProxies,this.viewManager=this.manager.viewManager,this.store=this.manager.store,this.uid=this.manager.uid,this.status="normal",this.sideEffectManager=new be.SideEffectManager,this.camera$=new A.Val(void 0),this.size$=new A.Val(void 0),this.box$=new A.Val(void 0),this.view$=new A.Val(void 0),this.getAppInitState=o=>{var p,h;const a=this.store.getAppState(o);if(!a)return;const l=a==null?void 0:a[Le.Position],u=this.store.focus,c=a==null?void 0:a[Le.Size],d=a==null?void 0:a[Le.SceneIndex],m=(p=this.attributes)==null?void 0:p.maximized,w=(h=this.attributes)==null?void 0:h.minimized,y=a==null?void 0:a.zIndex;let M={maximized:m,minimized:w,zIndex:y};return l&&(M=tt(Q({},M),{id:o,x:l.x,y:l.y})),u===o&&(M=tt(Q({},M),{focus:!0})),c&&(M=tt(Q({},M),{width:c.width,height:c.height})),d&&(M=tt(Q({},M),{sceneIndex:d})),M},this.appAttributesUpdateListener=o=>{var a,l,u;(a=this.manager.refresher)==null||a.add(o,()=>E.autorun(()=>{const c=this.manager.attributes[o];c&&this.appEmitter.emit("attributesUpdate",c)})),(l=this.manager.refresher)==null||l.add(this.stateKey,()=>E.autorun(()=>{var d,m,w;const c=(d=this.appAttributes)==null?void 0:d.state;(c==null?void 0:c.zIndex)>0&&c.zIndex!==((m=this.box)==null?void 0:m.zIndex)&&((w=this.boxManager)==null||w.setZIndex(o,c.zIndex))})),(u=this.manager.refresher)==null||u.add(`${o}-fullPath`,()=>E.autorun(()=>{var d;const c=(d=this.appAttributes)==null?void 0:d.fullPath;this.setFocusScenePathHandler(c),this._prevFullPath!==c&&(this.notifyPageStateChange(),this._prevFullPath=c)}))},this.setFocusScenePathHandler=b.debounce(o=>{var a;this.view&&o&&o!==((a=this.view)==null?void 0:a.focusScenePath)&&gi(this.view,o)},50),this.notifyPageStateChange=b.debounce(()=>{this.pageState&&this.appEmitter.emit("pageStateChange",this.pageState)},50),this.storeCamera=o=>{this.store.updateAppAttributes(this.id,me.Camera,o)},this.storeSize=o=>{this.store.updateAppAttributes(this.id,me.Size,o)},this.moveCamera=o=>{if(!this.camera$.value)return;const a=Q(Q({},this.camera$.value),o);this.storeCamera(a)},this.kind=t.kind,this.id=n,this.appScenePath=`/${this.id}-app-dir`,this.stateKey=`${this.id}_state`,this.appProxies.set(this.id,this),this.appEmitter=new Qt.default,this.appListener=this.makeAppEventListener(this.id),this.isAddApp=r,this.initScenes(),(s=this.params.options)!=null&&s.scenePath&&this.createView(),this.scenePath||(this.scenePath=this.appScenePath),this._pageState=new Zg({displayer:this.manager.displayer,scenePath:this.scenePath,view:this.view,notifyPageStateChange:this.notifyPageStateChange}),this.sideEffectManager.add(()=>()=>this._pageState.destroy()),this.sideEffectManager.add(()=>L.on("roomMembersChange",o=>{this.appEmitter.emit("roomMembersChange",o)})),this.camera$.setValue(E.toJS(this.appAttributes.camera)),this.size$.setValue(E.toJS(this.appAttributes.size)),this.sideEffectManager.add(()=>this.manager.refresher.add(`${this.id}-camera`,()=>E.reaction(()=>{var o;return(o=this.appAttributes)==null?void 0:o.camera},o=>{o&&o.id!==this.uid&&this.camera$.setValue(E.toJS(o))}))),this.sideEffectManager.add(()=>this.manager.refresher.add(`${this.id}-size`,()=>E.reaction(()=>{var o;return(o=this.appAttributes)==null?void 0:o.size},o=>{o&&o.id!==this.uid&&this.size$.setValue(E.toJS(o))}))),A.combine([this.box$,this.view$]).subscribe(([o,a])=>{if(o&&a){const l=new Gg(this);this.appViewSync=l,this.sideEffectManager.add(()=>()=>l.destroy())}})}createAppDir(){const t=this.scenePath||this.appScenePath;this._pageState.createSceneNode(t)||(ai(this.manager.room,t,[{name:"1"}]),this._pageState.createSceneNode(t),this.setSceneIndex(0)),this.scenes=mi(this.manager.displayer)[t];const n=this.createView();return this._pageState.setView(n),n}initScenes(){var i;const t=this.params.options;t&&(this.scenePath=t.scenePath,((i=this.appAttributes)==null?void 0:i.isDynamicPPT)&&this.scenePath?this.scenes=mi(this.manager.displayer)[this.scenePath]:this.scenes=t.scenes)}get view(){return this.manager.viewManager.getView(this.id)}get viewIndex(){var t;return(t=this.view)==null?void 0:t.focusSceneIndex}get isWritable(){var t;return this.manager.canOperate&&!((t=this.box)!=null&&t.readonly)}get attributes(){return this.manager.attributes[this.id]}get appAttributes(){return this.store.getAppAttributes(this.id)}getFullScenePath(){if(this.scenePath)return b.get(this.appAttributes,[me.FullPath])||this.getFullScenePathFromScenes()}getFullScenePathFromScenes(){const t=b.get(this.appAttributes,["state","SceneIndex"],0),i=Pg(this.manager.room,this.scenePath,t);return i&&this.setFullPath(i),i}setFullPath(t){this.store.updateAppAttributes(this.id,me.FullPath,t)}async baseInsertApp(t=!1){var s;const i=this.params;if(!i.kind)throw new Error("[WindowManager]: kind require");const n=await((s=je.appClasses.get(i.kind))==null?void 0:s()),r=je.registered.get(i.kind);if(n)await this.setupApp(this.id,t,n,i.options,r==null?void 0:r.appOptions);else throw new Error(`[WindowManager]: app load failed ${i.kind} ${i.src}`);return L.emit("updateManagerRect"),{appId:this.id,app:n}}get box(){return this.box$.value}async setupApp(t,i,n,r,s){var a;if(Li("setupApp",t,n,r),!this.boxManager)throw new Td;const o=new Qg(this.manager,this.boxManager,t,this,s);this.appContext=o;try{L.once(`${t}${Z.WindowCreated}`).then(async()=>{var c;let u;i||(u=this.getAppInitState(t),(c=this.boxManager)==null||c.updateBoxState(u)),this.appEmitter.onAny(this.appListener),this.appAttributesUpdateListener(t),this.setViewFocusScenePath(),setTimeout(async()=>{const d=await n.setup(o);this.appResult=d,je.notifyApp(this.kind,"created",{appId:t,result:d}),this.fixMobileSize()},Cd)});const l=(a=this.boxManager)==null?void 0:a.createBox({appId:t,app:n,options:r,canOperate:this.manager.canOperate,smartPosition:this.isAddApp});this.box$.setValue(l),this.isAddApp&&this.box&&(this.store.updateAppState(t,Le.ZIndex,this.box.zIndex),this.boxManager.focusBox({appId:t},!1))}catch(l){throw console.error(l),new Error(`[WindowManager]: app setup error: ${l.message}`)}}fixMobileSize(){var i,n;const t=(i=this.boxManager)==null?void 0:i.getBox(this.id);t&&((n=this.boxManager)==null||n.resizeBox({appId:this.id,width:t.intrinsicWidth+.001,height:t.intrinsicHeight+.001,skipUpdate:!0}))}async onSeek(t){var n;this.appEmitter.emit("seek",t).catch(r=>{console.log(`[WindowManager]: emit seek error: ${r.message}`)});const i=this.getAppInitState(this.id);(n=this.boxManager)==null||n.updateBoxState(i)}async onReconnected(){var s;if(!Boolean(this.manager.attributes.apps[this.id])){await this.destroy(!0,!1,!0);return}this.appEmitter.emit("reconnected",void 0);const i=this.getAppInitState(this.id);await this.destroy(!0,!1,!0);const n=this.params;await new _a(n,this.manager,this.id,this.isAddApp).baseInsertApp(!0),(s=this.boxManager)==null||s.updateBoxState(i)}async onRemoveScene(t){if(this.scenePath&&t.startsWith(this.scenePath+"/")){let i=this.pageState.index,n=this._pageState.getFullPath(i);n||(i=0,n=this._pageState.getFullPath(i)),n&&this.setFullPath(n),this.setViewFocusScenePath(),this.view&&(this.view.focusSceneIndex=i)}}emitAppSceneStateChange(t){this.appEmitter.emit("sceneStateChange",t)}emitAppIsWritableChange(){this.appEmitter.emit("writableChange",this.isWritable)}makeAppEventListener(t){return(i,n)=>{var r,s,o,a;if(!!this.manager.canOperate)switch(i){case"setBoxSize":{(r=this.boxManager)==null||r.resizeBox({appId:t,width:n.width,height:n.height,skipUpdate:!1});break}case"setBoxMinSize":{(s=this.boxManager)==null||s.setBoxMinSize({appId:t,minWidth:n.minwidth,minHeight:n.minheight});break}case"setBoxTitle":{(o=this.boxManager)==null||o.setBoxTitle({appId:t,title:n.title});break}case yd.destroy:{if(this.status==="destroyed")return;this.destroy(!0,!1,!0,n==null?void 0:n.error),n!=null&&n.error&&console.error(n==null?void 0:n.error);break}case"focus":{(a=this.boxManager)==null||a.focusBox({appId:this.id}),wt.emit("focus",{appId:this.id});break}}}}setScenePath(){if(!this.manager.canOperate)return;const t=this.getFullScenePath();this.manager.room&&t&&this.view&&ko(this.manager.room,t)}setViewFocusScenePath(){const t=this.getFullScenePath();return t&&this.view&&gi(this.view,t),t}createView(){const t=this.viewManager.createView(this.id);return this.view$.setValue(t),this.setViewFocusScenePath(),t}get pageState(){return this._pageState.toObject()}async removeSceneByIndex(t){const i=this._pageState.getFullPath(t);if(i&&this.pageState){const n=Oa(t,this.pageState);return this.setSceneIndexWithoutSync(n),this.manager.dispatchInternalEvent(Z.SetAppFocusIndex,{type:"app",appID:this.id,index:n}),setTimeout(()=>{Po(this.manager.room,i,t)},100),!0}else return!1}setSceneIndexWithoutSync(t){this.view&&(this.view.focusSceneIndex=t)}setSceneIndex(t){if(this.view){this.view.focusSceneIndex=t;const i=this._pageState.getFullPath(t);i&&this.setFullPath(i)}}async destroy(t,i,n,r){var s,o,a,l;if(this.status!=="destroyed"){this.status="destroyed";try{await je.notifyApp(this.kind,"destroy",{appId:this.id}),await this.appEmitter.emit("destroy",{error:r})}catch(u){console.error("[WindowManager]: notifyApp error",u.message,u.stack)}this.appEmitter.clearListeners(),this.sideEffectManager.flushAll(),L.emit(`destroy-${this.id}`,{error:r}),t&&((s=this.boxManager)==null||s.closeBox(this.id,n)),i&&(this.store.cleanAppAttributes(this.id),this.scenePath&&Po(this.manager.room,this.scenePath)),this.appProxies.delete(this.id),this.viewManager.destroyView(this.id),this.manager.appStatus.delete(this.id),(o=this.manager.refresher)==null||o.remove(this.id),(a=this.manager.refresher)==null||a.remove(this.stateKey),(l=this.manager.refresher)==null||l.remove(`${this.id}-fullPath`),this._prevFullPath=void 0,this.camera$.destroy(),this.size$.destroy(),this.box$.destroy()}}close(){return this.destroy(!0,!0,!1)}}class Jg{constructor(t){this.displayer=t,this.views=new Map}createView(t){const i=Ld(this.displayer);return this.views.set(t,i),i}getView(t){return this.views.get(t)}destroyView(t){const i=this.views.get(t);if(i){try{i.release()}catch{}this.views.delete(t)}}setViewScenePath(t,i){const n=this.views.get(t);n&&(n.focusScenePath=i)}destroy(){this.views.forEach(t=>{try{t.release()}catch{}}),this.views.clear()}}const Ld=e=>{const t=e.views.createView();return Kg(t),t},Kg=e=>{e.setCameraBound({maxContentMode:()=>10,minContentMode:()=>.1})};class qg{constructor(t){var n;this.manager=t,this.started=!1,this.mainViewIsAddListener=!1,this.store=this.manager.store,this.sideEffectManager=new be.SideEffectManager,this.startListenWritableChange=()=>{this.sideEffectManager.add(()=>L.on("writableChange",r=>{r&&this.ensureCameraAndSize()}))},this.addCameraReaction=()=>{var r;(r=this.manager.refresher)==null||r.add(me.MainViewCamera,this.cameraReaction)},this.cameraReaction=()=>E.reaction(()=>this.mainViewCamera,r=>{r&&r.id!==this.manager.uid&&this.synchronizer.onRemoteUpdate(r,this.mainViewSize)},{fireImmediately:!0}),this.sizeChangeHandler=b.debounce(r=>{},30),this.onUpdateContainerSizeRatio=()=>{const r=this.store.getMainViewSize();this.sizeChangeHandler(r),r.id===this.manager.uid&&this.setCameraAndSize()},this.onCameraUpdatedByDevice=r=>{this.synchronizer.onLocalCameraUpdate(r);const s=this.getStageSize();s&&!b.isEqual(s,this.mainViewSize)&&this.setMainViewSize(s)},this.mainViewClickListener=()=>{this.mainViewClickHandler()},this.setMainViewSize=b.debounce(r=>{this.store.setMainViewSize(tt(Q({},r),{id:this.manager.uid}))},50),this.onCameraOrSizeUpdated=()=>{ie.emit("cameraStateChange",this.cameraState)},this.synchronizer=new Dd(r=>this.store.setMainViewCamera(tt(Q({},r),{id:this.manager.uid}))),this.mainView=this.createMainView(),this.moveCameraSizeByAttributes(),L.once("mainViewMounted").then(()=>{this.addMainViewListener(),this.start(),this.ensureCameraAndSize(),this.startListenWritableChange()}),this.sideEffectManager.add(()=>L.on("containerSizeRatioUpdate",this.onUpdateContainerSizeRatio)),this.sideEffectManager.add(()=>L.on("startReconnect",()=>{yu(this.mainView)}));const i=(n=this.manager.boxManager)==null?void 0:n.stageRect;i&&this.synchronizer.setRect(i),this.sideEffectManager.add(()=>L.on("playgroundSizeChange",r=>{this.synchronizer.setRect(r)}))}ensureCameraAndSize(){(!this.mainViewCamera||!this.mainViewSize)&&(this.manager.dispatchInternalEvent(Z.InitMainViewCamera),this.setCameraAndSize())}get mainViewCamera(){return this.store.getMainViewCamera()}get mainViewSize(){return this.store.getMainViewSize()}get didRelease(){return b.get(this.view,["didRelease"])}moveCameraSizeByAttributes(){this.synchronizer.onRemoteUpdate(this.mainViewCamera,this.mainViewSize)}start(){this.started||(this.sizeChangeHandler(this.mainViewSize),this.addCameraListener(),this.addCameraReaction(),this.started=!0)}setCameraAndSize(){const t=this.getStageSize();if(t){const i=tt(Q({},this.mainView.camera),{id:this.manager.uid}),n=tt(Q({},t),{id:this.manager.uid});this.store.setMainViewCameraAndSize(i,n)}}get view(){return this.mainView}get cameraState(){return Q(Q({},this.view.camera),this.view.size)}createMainView(){const t=Ld(this.manager.displayer),i=this.store.getMainViewScenePath();return i&&gi(t,i),this.synchronizer.setView(t),t}onReconnect(){if(this.didRelease)this.rebind();else{const t=this.store.getMainViewScenePath();this.setFocusScenePath(t)}}setFocusScenePath(t){if(t)return gi(this.view,t)}rebind(){const t=this.mainView.divElement,i=this.mainView.disableCameraTransform;this.stop(),yu(this.mainView),this.removeMainViewListener(),this.mainView=this.createMainView(),this.mainView.disableCameraTransform=i,this.mainView.divElement=t,this.addMainViewListener(),this.start()}getStageSize(){var i;const t=(i=this.manager.boxManager)==null?void 0:i.stageRect;if(t)return{width:t.width,height:t.height}}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)),this.mainViewIsAddListener=!1}async mainViewClickHandler(){var t;!this.manager.canOperate||(this.store.cleanFocus(),(t=this.manager.boxManager)==null||t.blurAllBox())}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)}stop(){var t,i;this.removeCameraListener(),(t=this.manager.refresher)==null||t.remove(me.MainViewCamera),(i=this.manager.refresher)==null||i.remove(me.MainViewSize),this.started=!1}destroy(){this.removeMainViewListener(),this.stop(),this.sideEffectManager.flushAll()}}class em{constructor(t){this.context=t,this.addRedoUndoListeners=i=>{if(i===void 0)this.addViewCallbacks(this.context.mainView(),this.onCanRedoStepsUpdate,this.onCanUndoStepsUpdate);else{const n=this.context.getAppProxy(i);n&&n.view&&this.addViewCallbacks(n.view,this.onCanRedoStepsUpdate,this.onCanUndoStepsUpdate)}},this.addViewCallbacks=(i,n,r)=>{n(i.canRedoSteps),r(i.canUndoSteps),i.callbacks.on("onCanRedoStepsUpdate",n),i.callbacks.on("onCanUndoStepsUpdate",r)},this.disposeViewCallbacks=i=>{i.callbacks.off("onCanRedoStepsUpdate",this.onCanRedoStepsUpdate),i.callbacks.off("onCanUndoStepsUpdate",this.onCanUndoStepsUpdate)},this.onCanRedoStepsUpdate=i=>{ie.emit("canRedoStepsChange",i)},this.onCanUndoStepsUpdate=i=>{ie.emit("canUndoStepsChange",i)},this.disposePrevFocusViewRedoUndoListeners=i=>{let n;if(i===void 0)n=this.context.mainView();else{const r=this.context.getAppProxy(i);r&&r.view&&(n=r.view)}n&&this.disposeViewCallbacks(n)},L.on("focusedChange",i=>{this.disposePrevFocusViewRedoUndoListeners(i.prev),setTimeout(()=>{this.addRedoUndoListeners(i.focused)},0)}),L.on("rootDirRemoved",()=>{this.disposePrevFocusViewRedoUndoListeners(t.focus()),this.addRedoUndoListeners(t.focus())}),this.addRedoUndoListeners(t.focus())}destroy(){this.disposePrevFocusViewRedoUndoListeners(this.context.focus())}}class tm{constructor(t){this.windowManger=t,this.appProxies=new Map,this.appStatus=new Map,this.store=Xg,this.isReplay=this.windowManger.isReplay,this.mainViewScenesLength=0,this.callbacksNode=null,this.appCreateQueue=new mg,this.sideEffectManager=new be.SideEffectManager,this.sceneState=null,this.rootDirRemoving=!1,this.onRemoveScenes=async i=>{var r,s;const{scenePath:n}=i;if(n===ze){await this.onRootDirRemoved(),this.dispatchInternalEvent(Z.RootDirRemoved);return}if(Rg(n)){let o=this.mainView.focusSceneIndex||0,a=(r=this.callbacksNode)==null?void 0:r.scenes[o];a||(o=0,a=(s=this.callbacksNode)==null?void 0:s.scenes[o]),a&&this.setMainViewScenePath(`${ze}${a}`),await this.setMainViewSceneIndex(o)}else this.appProxies.forEach(o=>{o.onRemoveScene(n)})},this.onReadonlyChanged=()=>{this.appProxies.forEach(i=>{i.emitAppIsWritableChange()})},this.onPlayerSeekStart=async()=>{await this.closeAll()},this.onPlayerSeekDone=async i=>{await this.attributesUpdateCallback(this.attributes.apps),this.appProxies.forEach(n=>{n.onSeek(i)})},this.createRootDirScenesCallback=()=>{let i=!1;this.callbacksNode&&(this.callbacksNode.dispose(),i=!0),this.callbacksNode=this.displayer.createScenesCallback(ze,{onAddScene:this.onSceneChange,onRemoveScene:async(n,r)=>{await this.onSceneChange(n),L.emit("rootDirSceneRemoved",r)}}),this.callbacksNode&&(this.updateSceneState(this.callbacksNode),this.mainViewScenesLength=this.callbacksNode.scenes.length,i&&this.emitMainViewScenesChange(this.callbacksNode.scenes.length))},this.removeSceneByIndex=async i=>{var s;const n=Oa(i,this.windowManger.pageState);this.setSceneIndexWithoutSync(n),this.dispatchInternalEvent(Z.SetAppFocusIndex,{type:"main",index:n});const r=(s=this.callbacksNode)==null?void 0:s.scenes[i];return setTimeout(()=>{r&&Po(this.room,`${ze}${r}`,i)},100),new Promise((o,a)=>{L.once("rootDirSceneRemoved").then(l=>{l===r&&o(!0)}).catch(l=>{console.log(`[WindowManager]: removePage error: ${l}`),a(!1)})})},this.setSceneIndexWithoutSync=i=>{var r;const n=(r=this.callbacksNode)==null?void 0:r.scenes[i];n&&this.mainViewProxy.setFocusScenePath(`${ze}${n}`)},this.onSceneChange=i=>(this.mainViewScenesLength=i.scenes.length,this.updateSceneState(i),this.emitMainViewScenesChange(this.mainViewScenesLength)),this.emitMainViewScenesChange=i=>Promise.all([ie.emit("mainViewScenesLengthChange",i),L.emit("changePageState")]),this.updateSceneState=i=>{const n=this.store.getMainViewSceneIndex()||0;let r=i.scenes[n];r||(r=i.scenes[this.mainView.focusSceneIndex||0]),this.sceneState={scenePath:`${ze}${r}`,contextPath:i.path,index:n,scenes:i.scenes.map(s=>({name:s})),sceneName:r},ie.emit("sceneStateChange",this.sceneState)},this.onBoxMove=i=>{this.dispatchInternalEvent(Z.AppMove,i),this.store.updateAppState(i.appId,Le.Position,{x:i.x,y:i.y})},this.onBoxResize=i=>{i.width&&i.height&&(this.dispatchInternalEvent(Z.AppResize,i),this.store.updateAppState(i.appId,Le.Size,{width:i.width,height:i.height}))},this.onBoxFocus=i=>{this.windowManger.safeSetAttributes({focus:i.appId})},this.onBoxClose=i=>{const n=this.appProxies.get(i.appId);n&&n.destroy(!1,!0,!0,i.error)},this.onBoxStateChange=i=>{this.dispatchInternalEvent(Z.AppBoxStateChange,i)},this.addAppsChangeListener=()=>{var i;(i=this.refresher)==null||i.add("apps",()=>Pd(()=>this.attributes.apps,()=>{this.attributesUpdateCallback(this.attributes.apps)}))},this.addAppCloseListener=()=>{var i;(i=this.refresher)==null||i.add("appsClose",()=>Og(this.attributes.apps,()=>{this.onAppDelete(this.attributes.apps)}))},this.onMainViewIndexChange=i=>{i!==void 0&&this._prevSceneIndex!==i&&(ie.emit("mainViewSceneIndexChange",i),L.emit("changePageState"),this.callbacksNode&&this.updateSceneState(this.callbacksNode),this._prevSceneIndex=i)},this.onFocusChange=i=>{var n;this._prevFocused!==i&&(ie.emit("focusedChange",i),L.emit("focusedChange",{focused:i,prev:this._prevFocused}),this._prevFocused=i,i!==void 0&&((n=this.boxManager)==null||n.focusBox({appId:i}),setTimeout(()=>{const r=this.appProxies.get(i);r&&je.notifyApp(r.kind,"focus",{appId:i})},0)))},this.attributesUpdateCallback=b.debounce(i=>this._attributesUpdateCallback(i),100),this.onRegisteredChange=i=>{!i||Object.entries(i).forEach(([n,r])=>{je.appClasses.has(n)||je.register({kind:n,src:r.src,name:r.name})})},this.onMinimized=i=>{var n,r;((n=this.boxManager)==null?void 0:n.minimized)!==i&&(i===!0&&((r=this.boxManager)==null||r.blurAllBox()),setTimeout(()=>{var s;(s=this.boxManager)==null||s.setMinimized(Boolean(i))},0))},this.onAppDelete=async i=>{const n=Object.keys(i);for(const[r,s]of this.appProxies.entries())n.includes(r)||await s.destroy(!0,!1,!0)},this.closeAll=async()=>{for(const[i,n]of this.appProxies.entries())await n.destroy(!0,!1,!0)},this.displayerStateListener=i=>{const n=i.sceneState;if(n){const r=n.scenePath;this.appProxies.forEach(s=>{s.scenePath&&r.startsWith(s.scenePath)&&(s.emitAppSceneStateChange(n),s.setFullPath(r))})}this.appProxies.forEach(r=>{r.appEmitter.emit("roomStateChange",i)}),i.roomMembers&&L.emit("roomMembersChange",this.members),L.emit("observerIdChange",this.displayer.observerId)},this.displayerWritableListener=i=>{var s,o;const n=!i,r=this.windowManger.readonly===void 0||this.windowManger.readonly===!1;this.windowManger.readonly===void 0?(s=this.boxManager)==null||s.setReadonly(i):(o=this.boxManager)==null||o.setReadonly(!(n&&r)),this.appProxies.forEach(a=>{a.emitAppIsWritableChange()}),n===!0?(this.mainView.disableCameraTransform=!1,this.room&&this.room.disableSerialization===!0&&(this.room.disableSerialization=!1)):this.mainView.disableCameraTransform=!0,L.emit("writableChange",n)},this.updateSceneIndex=()=>{const i=this.store.getMainViewScenePath(),n=Js(i),r=mi(this.displayer)[n];if(r.length){const s=i.replace(n,"").replace("/",""),o=r.findIndex(a=>a.name===s);b.isInteger(o)&&o>=0&&this.safeSetAttributes({_mainSceneIndex:o})}},this.updateRootDirRemoving=i=>{this.rootDirRemoving=i},this.displayer=t.displayer,this.store.setContext({getAttributes:()=>this.attributes,safeSetAttributes:i=>this.safeSetAttributes(i),safeUpdateAttributes:(i,n)=>this.safeUpdateAttributes(i,n)}),this.mainViewProxy=new qg(this),this.viewManager=new Jg(this.displayer),this.appListeners=new Vg(this),this.displayer.callbacks.on(this.eventName,this.displayerStateListener),this.appListeners.addListeners(),this.refresher=qf,this.refresher.setRoom(this.room),this.refresher.setContext({emitter:L}),this.sideEffectManager.add(()=>()=>{var i,n,r;this.appCreateQueue.destroy(),this.mainViewProxy.destroy(),(i=this.refresher)==null||i.destroy(),this.viewManager.destroy(),(n=this.boxManager)==null||n.destroy(),(r=this.callbacksNode)==null||r.dispose()}),L.once("onCreated").then(()=>this.onCreated()),L.on("onReconnected",()=>this.onReconnected()),E.isPlayer(this.displayer)&&(L.on("seekStart",this.onPlayerSeekStart),L.on("seek",this.onPlayerSeekDone)),L.on("removeScenes",this.onRemoveScenes),L.on("setReadonly",this.onReadonlyChanged),this.createRootDirScenesCallback(),je.setSyncRegisterApp(i=>{this.safeUpdateAttributes([me.Registered,i.kind],i)})}async onRootDirRemoved(t=!0){this.setMainViewScenePath(Sd),this.createRootDirScenesCallback();for(const[i,n]of this.appProxies.entries())n.view&&await this.closeApp(i,t);this.mainViewProxy.rebind(),L.emit("rootDirRemoved"),this.updateRootDirRemoving(!1)}get eventName(){return E.isRoom(this.displayer)?"onRoomStateChanged":"onPlayerStateChanged"}get attributes(){return this.windowManger.attributes}get canOperate(){return this.windowManger.canOperate}get room(){return E.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)}get uid(){var t;return((t=this.room)==null?void 0:t.uid)||""}get members(){return Fg(this.displayer.state.roomMembers)}getMainViewSceneDir(){const t=this.store.getMainViewScenePath();if(t)return Js(t);throw new Error("[WindowManager]: mainViewSceneDir not found")}async onCreated(){var t,i,n,r,s,o;if(await this.attributesUpdateCallback(this.attributes.apps),L.emit("updateManagerRect"),wt.on("move",this.onBoxMove),wt.on("resize",this.onBoxResize),wt.on("focus",this.onBoxFocus),wt.on("close",this.onBoxClose),wt.on("boxStateChange",this.onBoxStateChange),this.addAppsChangeListener(),this.addAppCloseListener(),(t=this.refresher)==null||t.add("maximized",()=>E.autorun(()=>{var l;const a=this.attributes.maximized;(l=this.boxManager)==null||l.setMaximized(Boolean(a))})),(i=this.refresher)==null||i.add("minimized",()=>E.autorun(()=>{const a=this.attributes.minimized;this.onMinimized(a)})),(n=this.refresher)==null||n.add("mainViewIndex",()=>E.autorun(()=>{const a=b.get(this.attributes,"_mainSceneIndex");this.onMainViewIndexChange(a)})),(r=this.refresher)==null||r.add("focusedChange",()=>E.autorun(()=>{const a=b.get(this.attributes,"focus");this.onFocusChange(a)})),(s=this.refresher)==null||s.add("registeredChange",()=>E.autorun(()=>{const a=b.get(this.attributes,me.Registered);this.onRegisteredChange(a)})),!this.attributes.apps||Object.keys(this.attributes.apps).length===0){const a=this.store.getMainViewScenePath();if(!a)return;this.resetScenePath(a)}this.displayerWritableListener(!((o=this.room)!=null&&o.isWritable)),this.displayer.callbacks.on("onEnableWriteNowChanged",this.displayerWritableListener),this._prevFocused=this.attributes.focus,this.sideEffectManager.add(()=>{const a=new em({mainView:()=>this.mainViewProxy.view,focus:()=>this.attributes.focus,getAppProxy:l=>this.appProxies.get(l)});return()=>a.destroy()})}async _attributesUpdateCallback(t){if(t&&ye.container){const i=Object.keys(t);i.length===0&&this.appCreateQueue.emitReady();const n=i.map(r=>({id:r,createdAt:t[r].createdAt}));for(const{id:r}of b.orderBy(n,"createdAt","asc"))if(!this.appProxies.has(r)&&!this.appStatus.has(r)){const s=t[r];try{if(!this.attributes[r])throw new Error("appAttributes is undefined");this.appCreateQueue.push(()=>(this.appStatus.set(r,No.StartCreate),this.baseInsertApp({kind:s.kind,options:s.options,isDynamicPPT:s.isDynamicPPT},r,!1))),this.focusByAttributes(t)}catch(o){console.warn("[WindowManager]: Insert App Error",o)}}}}refresh(){this.attributesUpdateCallback(this.attributes.apps)}setBoxManager(t){this.boxManager=t}resetMaximized(){var t;(t=this.boxManager)==null||t.setMaximized(Boolean(this.store.getMaximized()))}resetMinimized(){var t;(t=this.boxManager)==null||t.setMinimized(Boolean(this.store.getMinimized()))}bindMainView(t,i){const n=this.mainViewProxy.view;n.disableCameraTransform=i,n.divElement=t,n.focusScenePath||this.setMainViewFocusPath(),L.emit("mainViewMounted")}setMainViewFocusPath(t){var n;const i=t||this.store.getMainViewScenePath();if(i)return gi(this.mainView,i),((n=this.mainView)==null?void 0:n.focusScenePath)===i}resetScenePath(t){this.displayer.state.sceneState.scenePath!==t&&ko(this.room,t)}async addApp(t,i){Li("addApp",t);const{appId:n,needFocus:r}=await this.beforeAddApp(t,i),s=await this.baseInsertApp(t,n,!0,r);return this.afterAddApp(s),s==null?void 0:s.id}async beforeAddApp(t,i){var o,a;const n=await kg(t.kind);this.appStatus.set(n,No.StartCreate);const r=(o=t.attributes)!=null?o:{};this.safeUpdateAttributes([n],r),this.store.setupAppAttributes(t,n,i);const s=!((a=this.boxManager)!=null&&a.minimized);return s&&this.store.setAppFocus(n,!0),{appId:n,needFocus:s}}afterAddApp(t){var i,n;if(t&&t.box){const r=t.box;wt.emit("move",{appId:t.id,x:r==null?void 0:r.intrinsicX,y:r==null?void 0:r.intrinsicY}),this.store.updateAppState(t.id,Le.ZIndex,r.zIndex)}(i=this.boxManager)!=null&&i.minimized&&((n=this.boxManager)==null||n.setMinimized(!1,!1))}async closeApp(t,i=!0){const n=this.appProxies.get(t);n&&n.destroy(!0,i,!1)}async baseInsertApp(t,i,n,r){if(this.appProxies.has(i)){console.warn("[WindowManager]: app duplicate exists and cannot be created again");return}const s=new _a(t,this,i,n);if(s)return await s.baseInsertApp(r),this.appStatus.delete(i),s;throw this.appStatus.delete(i),new Error("[WindowManger]: initialize AppProxy failed")}safeSetAttributes(t){this.windowManger.safeSetAttributes(t)}safeUpdateAttributes(t,i){this.windowManger.safeUpdateAttributes(t,i)}async setMainViewScenePath(t){if(this.room){const i=this.displayer.scenePathType(t);if(Js(t)!==ze)throw new Error('[WindowManager]: main view scenePath must in root dir "/"');if(i===E.ScenePathType.None)throw new Error(`[WindowManager]: ${t} not valid scene`);if(i===E.ScenePathType.Page)await this._setMainViewScenePath(t);else if(i===E.ScenePathType.Dir){const r=Dg(this.displayer,t);r&&await this._setMainViewScenePath(r)}}}async _setMainViewScenePath(t){this.setMainViewFocusPath(t)&&(this.safeSetAttributes({_mainScenePath:t}),this.store.setMainViewFocusPath(this.mainView),this.updateSceneIndex(),this.dispatchSetMainViewScenePath(t))}async setMainViewSceneIndex(t){var i;if(this.room){if(this.store.getMainViewSceneIndex()===t)return;const n=(i=this.callbacksNode)==null?void 0:i.scenes[t],r=`${ze}${n}`;if(n)this.setMainViewFocusPath(r)&&(this.store.setMainViewScenePath(r),this.safeSetAttributes({_mainSceneIndex:t}),this.dispatchSetMainViewScenePath(r));else throw new Error(`[WindowManager]: ${t} not valid index`)}}dispatchSetMainViewScenePath(t){this.dispatchInternalEvent(Z.SetMainViewScenePath,{nextScenePath:t}),ko(this.room,t)}getAppInitPath(t){var n;const i=this.store.getAppAttributes(t);if(i)return(n=i==null?void 0:i.options)==null?void 0:n.scenePath}safeDispatchMagixEvent(t,i){this.canOperate&&this.displayer.dispatchMagixEvent(t,i)}focusByAttributes(t){var i;if(t&&Object.keys(t).length===((i=this.boxManager)==null?void 0:i.boxSize)){const n=this.store.focus;n&&this.boxManager.focusBox({appId:n})}}async onReconnected(){const i=Array.from(this.appProxies.values()).map(n=>n.onReconnected());this.mainViewProxy.onReconnect(),await Promise.all(i)}notifyContainerRectUpdate(t){this.appProxies.forEach(i=>{i.appEmitter.emit("containerRectUpdate",t)})}dispatchInternalEvent(t,i){this.safeDispatchMagixEvent(To,{eventName:t,payload:i})}destroy(){this.displayer.callbacks.off(this.eventName,this.displayerStateListener),this.displayer.callbacks.off("onEnableWriteNowChanged",this.displayerWritableListener),this.appListeners.removeListeners(),wt.clearListeners(),L.clearListeners(),this.appProxies.size&&this.appProxies.forEach(t=>{t.destroy(!0,!1,!0)}),ie.clearListeners(),this.sideEffectManager.flushAll(),this._prevFocused=void 0,this._prevSceneIndex=void 0}}/*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
@@ -43,4 +43,4 @@ object-assign
43
43
  in `+(n||"Unknown")+s}t+=i,e=e.return}while(e);return t}function Zt(e){switch(typeof e){case"boolean":case"number":case"object":case"string":case"undefined":return e;default:return""}}function pp(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function E0(e){var t=pp(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),n=""+e[t];if(!e.hasOwnProperty(t)&&typeof i!="undefined"&&typeof i.get=="function"&&typeof i.set=="function"){var r=i.get,s=i.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(o){n=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:i.enumerable}),{getValue:function(){return n},setValue:function(o){n=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wr(e){e._valueTracker||(e._valueTracker=E0(e))}function fp(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var i=t.getValue(),n="";return e&&(n=pp(e)?e.checked?"true":"false":e.value),e=n,e!==i?(t.setValue(e),!0):!1}function Jo(e,t){var i=t.checked;return Se({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i!=null?i:e._wrapperState.initialChecked})}function fc(e,t){var i=t.defaultValue==null?"":t.defaultValue,n=t.checked!=null?t.checked:t.defaultChecked;i=Zt(t.value!=null?t.value:i),e._wrapperState={initialChecked:n,initialValue:i,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function gp(e,t){t=t.checked,t!=null&&Cl(e,"checked",t,!1)}function Ko(e,t){gp(e,t);var i=Zt(t.value),n=t.type;if(i!=null)n==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(n==="submit"||n==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?qo(e,t.type,i):t.hasOwnProperty("defaultValue")&&qo(e,t.type,Zt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function gc(e,t,i){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var n=t.type;if(!(n!=="submit"&&n!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,i||t===e.value||(e.value=t),e.defaultValue=t}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function qo(e,t,i){(t!=="number"||e.ownerDocument.activeElement!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}function A0(e){var t="";return js.Children.forEach(e,function(i){i!=null&&(t+=i)}),t}function ea(e,t){return e=Se({children:void 0},t),(t=A0(t.children))&&(e.children=t),e}function Oi(e,t,i,n){if(e=e.options,t){t={};for(var r=0;r<i.length;r++)t["$"+i[r]]=!0;for(i=0;i<e.length;i++)r=t.hasOwnProperty("$"+e[i].value),e[i].selected!==r&&(e[i].selected=r),r&&n&&(e[i].defaultSelected=!0)}else{for(i=""+Zt(i),t=null,r=0;r<e.length;r++){if(e[r].value===i){e[r].selected=!0,n&&(e[r].defaultSelected=!0);return}t!==null||e[r].disabled||(t=e[r])}t!==null&&(t.selected=!0)}}function ta(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(S(91));return Se({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function mc(e,t){var i=t.value;if(i==null){if(i=t.children,t=t.defaultValue,i!=null){if(t!=null)throw Error(S(92));if(Array.isArray(i)){if(!(1>=i.length))throw Error(S(93));i=i[0]}t=i}t==null&&(t=""),i=t}e._wrapperState={initialValue:Zt(i)}}function mp(e,t){var i=Zt(t.value),n=Zt(t.defaultValue);i!=null&&(i=""+i,i!==e.value&&(e.value=i),t.defaultValue==null&&e.defaultValue!==i&&(e.defaultValue=i)),n!=null&&(e.defaultValue=""+n)}function vc(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}var vp={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};function wp(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ia(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?wp(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var yr,yp=function(e){return typeof MSApp!="undefined"&&MSApp.execUnsafeLocalFunction?function(t,i,n,r){MSApp.execUnsafeLocalFunction(function(){return e(t,i,n,r)})}:e}(function(e,t){if(e.namespaceURI!==vp.svg||"innerHTML"in e)e.innerHTML=t;else{for(yr=yr||document.createElement("div"),yr.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=yr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Bn(e,t){if(t){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=t;return}}e.textContent=t}function xr(e,t){var i={};return i[e.toLowerCase()]=t.toLowerCase(),i["Webkit"+e]="webkit"+t,i["Moz"+e]="moz"+t,i}var Ni={animationend:xr("Animation","AnimationEnd"),animationiteration:xr("Animation","AnimationIteration"),animationstart:xr("Animation","AnimationStart"),transitionend:xr("Transition","TransitionEnd")},po={},xp={};Jt&&(xp=document.createElement("div").style,"AnimationEvent"in window||(delete Ni.animationend.animation,delete Ni.animationiteration.animation,delete Ni.animationstart.animation),"TransitionEvent"in window||delete Ni.transitionend.transition);function Rs(e){if(po[e])return po[e];if(!Ni[e])return e;var t=Ni[e],i;for(i in t)if(t.hasOwnProperty(i)&&i in xp)return po[e]=t[i];return e}var Sp=Rs("animationend"),Cp=Rs("animationiteration"),Mp=Rs("animationstart"),Ip=Rs("transitionend"),wn="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),wc=new(typeof WeakMap=="function"?WeakMap:Map);function El(e){var t=wc.get(e);return t===void 0&&(t=new Map,wc.set(e,t)),t}function Ii(e){var t=e,i=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.effectTag&1026)!==0&&(i=t.return),e=t.return;while(e)}return t.tag===3?i:null}function bp(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function yc(e){if(Ii(e)!==e)throw Error(S(188))}function T0(e){var t=e.alternate;if(!t){if(t=Ii(e),t===null)throw Error(S(188));return t!==e?null:e}for(var i=e,n=t;;){var r=i.return;if(r===null)break;var s=r.alternate;if(s===null){if(n=r.return,n!==null){i=n;continue}break}if(r.child===s.child){for(s=r.child;s;){if(s===i)return yc(r),e;if(s===n)return yc(r),t;s=s.sibling}throw Error(S(188))}if(i.return!==n.return)i=r,n=s;else{for(var o=!1,a=r.child;a;){if(a===i){o=!0,i=r,n=s;break}if(a===n){o=!0,n=r,i=s;break}a=a.sibling}if(!o){for(a=s.child;a;){if(a===i){o=!0,i=s,n=r;break}if(a===n){o=!0,n=s,i=r;break}a=a.sibling}if(!o)throw Error(S(189))}}if(i.alternate!==n)throw Error(S(190))}if(i.tag!==3)throw Error(S(188));return i.stateNode.current===i?e:t}function Ep(e){if(e=T0(e),!e)return null;for(var t=e;;){if(t.tag===5||t.tag===6)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}function Zi(e,t){if(t==null)throw Error(S(30));return e==null?t:Array.isArray(e)?Array.isArray(t)?(e.push.apply(e,t),e):(e.push(t),e):Array.isArray(t)?[e].concat(t):[e,t]}function Al(e,t,i){Array.isArray(e)?e.forEach(t,i):e&&t.call(i,e)}var ln=null;function N0(e){if(e){var t=e._dispatchListeners,i=e._dispatchInstances;if(Array.isArray(t))for(var n=0;n<t.length&&!e.isPropagationStopped();n++)ac(e,t[n],i[n]);else t&&ac(e,t,i);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}function Vs(e){if(e!==null&&(ln=Zi(ln,e)),e=ln,ln=null,e){if(Al(e,N0),ln)throw Error(S(95));if(es)throw e=Zo,es=!1,Zo=null,e}}function Tl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}function Ap(e){if(!Jt)return!1;e="on"+e;var t=e in document;return t||(t=document.createElement("div"),t.setAttribute(e,"return;"),t=typeof t[e]=="function"),t}var ns=[];function Tp(e){e.topLevelType=null,e.nativeEvent=null,e.targetInst=null,e.ancestors.length=0,10>ns.length&&ns.push(e)}function Np(e,t,i,n){if(ns.length){var r=ns.pop();return r.topLevelType=e,r.eventSystemFlags=n,r.nativeEvent=t,r.targetInst=i,r}return{topLevelType:e,eventSystemFlags:n,nativeEvent:t,targetInst:i,ancestors:[]}}function kp(e){var t=e.targetInst,i=t;do{if(!i){e.ancestors.push(i);break}var n=i;if(n.tag===3)n=n.stateNode.containerInfo;else{for(;n.return;)n=n.return;n=n.tag!==3?null:n.stateNode.containerInfo}if(!n)break;t=i.tag,t!==5&&t!==6||e.ancestors.push(i),i=tr(n)}while(i);for(i=0;i<e.ancestors.length;i++){t=e.ancestors[i];var r=Tl(e.nativeEvent);n=e.topLevelType;var s=e.nativeEvent,o=e.eventSystemFlags;i===0&&(o|=64);for(var a=null,l=0;l<is.length;l++){var u=is[l];u&&(u=u.extractEvents(n,t,s,r,o))&&(a=Zi(a,u))}Vs(a)}}function na(e,t,i){if(!i.has(e)){switch(e){case"scroll":yn(t,"scroll",!0);break;case"focus":case"blur":yn(t,"focus",!0),yn(t,"blur",!0),i.set("blur",null),i.set("focus",null);break;case"cancel":case"close":Ap(e)&&yn(t,e,!0);break;case"invalid":case"submit":case"reset":break;default:wn.indexOf(e)===-1&&X(e,t)}i.set(e,null)}}var Pp,Nl,zp,ra=!1,ot=[],Ot=null,_t=null,Ut=null,On=new Map,_n=new Map,un=[],sa="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput close cancel copy cut paste click change contextmenu reset submit".split(" "),k0="focus blur dragenter dragleave mouseover mouseout pointerover pointerout gotpointercapture lostpointercapture".split(" ");function P0(e,t){var i=El(t);sa.forEach(function(n){na(n,t,i)}),k0.forEach(function(n){na(n,t,i)})}function oa(e,t,i,n,r){return{blockedOn:e,topLevelType:t,eventSystemFlags:i|32,nativeEvent:r,container:n}}function xc(e,t){switch(e){case"focus":case"blur":Ot=null;break;case"dragenter":case"dragleave":_t=null;break;case"mouseover":case"mouseout":Ut=null;break;case"pointerover":case"pointerout":On.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":_n.delete(t.pointerId)}}function cn(e,t,i,n,r,s){return e===null||e.nativeEvent!==s?(e=oa(t,i,n,r,s),t!==null&&(t=ir(t),t!==null&&Nl(t)),e):(e.eventSystemFlags|=n,e)}function z0(e,t,i,n,r){switch(t){case"focus":return Ot=cn(Ot,e,t,i,n,r),!0;case"dragenter":return _t=cn(_t,e,t,i,n,r),!0;case"mouseover":return Ut=cn(Ut,e,t,i,n,r),!0;case"pointerover":var s=r.pointerId;return On.set(s,cn(On.get(s)||null,e,t,i,n,r)),!0;case"gotpointercapture":return s=r.pointerId,_n.set(s,cn(_n.get(s)||null,e,t,i,n,r)),!0}return!1}function D0(e){var t=tr(e.target);if(t!==null){var i=Ii(t);if(i!==null){if(t=i.tag,t===13){if(t=bp(i),t!==null){e.blockedOn=t,le.unstable_runWithPriority(e.priority,function(){zp(i)});return}}else if(t===3&&i.stateNode.hydrate){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rr(e){if(e.blockedOn!==null)return!1;var t=zl(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);if(t!==null){var i=ir(t);return i!==null&&Nl(i),e.blockedOn=t,!1}return!0}function Sc(e,t,i){Rr(e)&&i.delete(t)}function L0(){for(ra=!1;0<ot.length;){var e=ot[0];if(e.blockedOn!==null){e=ir(e.blockedOn),e!==null&&Pp(e);break}var t=zl(e.topLevelType,e.eventSystemFlags,e.container,e.nativeEvent);t!==null?e.blockedOn=t:ot.shift()}Ot!==null&&Rr(Ot)&&(Ot=null),_t!==null&&Rr(_t)&&(_t=null),Ut!==null&&Rr(Ut)&&(Ut=null),On.forEach(Sc),_n.forEach(Sc)}function dn(e,t){e.blockedOn===t&&(e.blockedOn=null,ra||(ra=!0,le.unstable_scheduleCallback(le.unstable_NormalPriority,L0)))}function Dp(e){function t(r){return dn(r,e)}if(0<ot.length){dn(ot[0],e);for(var i=1;i<ot.length;i++){var n=ot[i];n.blockedOn===e&&(n.blockedOn=null)}}for(Ot!==null&&dn(Ot,e),_t!==null&&dn(_t,e),Ut!==null&&dn(Ut,e),On.forEach(t),_n.forEach(t),i=0;i<un.length;i++)n=un[i],n.blockedOn===e&&(n.blockedOn=null);for(;0<un.length&&(i=un[0],i.blockedOn===null);)D0(i),i.blockedOn===null&&un.shift()}var Lp={},jp=new Map,kl=new Map,j0=["abort","abort",Sp,"animationEnd",Cp,"animationIteration",Mp,"animationStart","canplay","canPlay","canplaythrough","canPlayThrough","durationchange","durationChange","emptied","emptied","encrypted","encrypted","ended","ended","error","error","gotpointercapture","gotPointerCapture","load","load","loadeddata","loadedData","loadedmetadata","loadedMetadata","loadstart","loadStart","lostpointercapture","lostPointerCapture","playing","playing","progress","progress","seeking","seeking","stalled","stalled","suspend","suspend","timeupdate","timeUpdate",Ip,"transitionEnd","waiting","waiting"];function Pl(e,t){for(var i=0;i<e.length;i+=2){var n=e[i],r=e[i+1],s="on"+(r[0].toUpperCase()+r.slice(1));s={phasedRegistrationNames:{bubbled:s,captured:s+"Capture"},dependencies:[n],eventPriority:t},kl.set(n,t),jp.set(n,s),Lp[r]=s}}Pl("blur blur cancel cancel click click close close contextmenu contextMenu copy copy cut cut auxclick auxClick dblclick doubleClick dragend dragEnd dragstart dragStart drop drop focus focus input input invalid invalid keydown keyDown keypress keyPress keyup keyUp mousedown mouseDown mouseup mouseUp paste paste pause pause play play pointercancel pointerCancel pointerdown pointerDown pointerup pointerUp ratechange rateChange reset reset seeked seeked submit submit touchcancel touchCancel touchend touchEnd touchstart touchStart volumechange volumeChange".split(" "),0);Pl("drag drag dragenter dragEnter dragexit dragExit dragleave dragLeave dragover dragOver mousemove mouseMove mouseout mouseOut mouseover mouseOver pointermove pointerMove pointerout pointerOut pointerover pointerOver scroll scroll toggle toggle touchmove touchMove wheel wheel".split(" "),1);Pl(j0,2);for(var Cc="change selectionchange textInput compositionstart compositionend compositionupdate".split(" "),fo=0;fo<Cc.length;fo++)kl.set(Cc[fo],0);var R0=le.unstable_UserBlockingPriority,V0=le.unstable_runWithPriority,Vr=!0;function X(e,t){yn(t,e,!1)}function yn(e,t,i){var n=kl.get(t);switch(n===void 0?2:n){case 0:n=B0.bind(null,t,1,e);break;case 1:n=O0.bind(null,t,1,e);break;default:n=Bs.bind(null,t,1,e)}i?e.addEventListener(t,n,!0):e.addEventListener(t,n,!1)}function B0(e,t,i,n){ii||wl();var r=Bs,s=ii;ii=!0;try{sp(r,e,t,i,n)}finally{(ii=s)||yl()}}function O0(e,t,i,n){V0(R0,Bs.bind(null,e,t,i,n))}function Bs(e,t,i,n){if(Vr)if(0<ot.length&&-1<sa.indexOf(e))e=oa(null,e,t,i,n),ot.push(e);else{var r=zl(e,t,i,n);if(r===null)xc(e,n);else if(-1<sa.indexOf(e))e=oa(r,e,t,i,n),ot.push(e);else if(!z0(r,e,t,i,n)){xc(e,n),e=Np(e,n,null,t);try{ap(kp,e)}finally{Tp(e)}}}}function zl(e,t,i,n){if(i=Tl(n),i=tr(i),i!==null){var r=Ii(i);if(r===null)i=null;else{var s=r.tag;if(s===13){if(i=bp(r),i!==null)return i;i=null}else if(s===3){if(r.stateNode.hydrate)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null)}}e=Np(e,n,i,t);try{ap(kp,e)}finally{Tp(e)}return null}var Tn={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},_0=["Webkit","ms","Moz","O"];Object.keys(Tn).forEach(function(e){_0.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Tn[t]=Tn[e]})});function Rp(e,t,i){return t==null||typeof t=="boolean"||t===""?"":i||typeof t!="number"||t===0||Tn.hasOwnProperty(e)&&Tn[e]?(""+t).trim():t+"px"}function Vp(e,t){e=e.style;for(var i in t)if(t.hasOwnProperty(i)){var n=i.indexOf("--")===0,r=Rp(i,t[i],n);i==="float"&&(i="cssFloat"),n?e.setProperty(i,r):e[i]=r}}var U0=Se({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function aa(e,t){if(t){if(U0[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(S(137,e,""));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(S(60));if(!(typeof t.dangerouslySetInnerHTML=="object"&&"__html"in t.dangerouslySetInnerHTML))throw Error(S(61))}if(t.style!=null&&typeof t.style!="object")throw Error(S(62,""))}}function la(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Mc=vp.html;function mt(e,t){e=e.nodeType===9||e.nodeType===11?e:e.ownerDocument;var i=El(e);t=ml[t];for(var n=0;n<t.length;n++)na(t[n],e,i)}function rs(){}function ua(e){if(e=e||(typeof document!="undefined"?document:void 0),typeof e=="undefined")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ic(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function bc(e,t){var i=Ic(e);e=0;for(var n;i;){if(i.nodeType===3){if(n=e+i.textContent.length,e<=t&&n>=t)return{node:i,offset:t-e};e=n}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Ic(i)}}function Bp(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Bp(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ec(){for(var e=window,t=ua();t instanceof e.HTMLIFrameElement;){try{var i=typeof t.contentWindow.location.href=="string"}catch{i=!1}if(i)e=t.contentWindow;else break;t=ua(e.document)}return t}function ca(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Op="$",_p="/$",Dl="$?",Ll="$!",go=null,mo=null;function Up(e,t){switch(e){case"button":case"input":case"select":case"textarea":return!!t.autoFocus}return!1}function da(e,t){return e==="textarea"||e==="option"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var vo=typeof setTimeout=="function"?setTimeout:void 0,$0=typeof clearTimeout=="function"?clearTimeout:void 0;function _i(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break}return e}function Ac(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i===Op||i===Ll||i===Dl){if(t===0)return e;t--}else i===_p&&t++}e=e.previousSibling}return null}var jl=Math.random().toString(36).slice(2),zt="__reactInternalInstance$"+jl,ss="__reactEventHandlers$"+jl,er="__reactContainere$"+jl;function tr(e){var t=e[zt];if(t)return t;for(var i=e.parentNode;i;){if(t=i[er]||i[zt]){if(i=t.alternate,t.child!==null||i!==null&&i.child!==null)for(e=Ac(e);e!==null;){if(i=e[zt])return i;e=Ac(e)}return t}e=i,i=e.parentNode}return null}function ir(e){return e=e[zt]||e[er],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function vi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(S(33))}function Rl(e){return e[ss]||null}function vt(e){do e=e.return;while(e&&e.tag!==5);return e||null}function $p(e,t){var i=e.stateNode;if(!i)return null;var n=gl(i);if(!n)return null;i=n[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(e=e.type,n=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!n;break e;default:e=!1}if(e)return null;if(i&&typeof i!="function")throw Error(S(231,t,typeof i));return i}function Tc(e,t,i){(t=$p(e,i.dispatchConfig.phasedRegistrationNames[t]))&&(i._dispatchListeners=Zi(i._dispatchListeners,t),i._dispatchInstances=Zi(i._dispatchInstances,e))}function W0(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var t=e._targetInst,i=[];t;)i.push(t),t=vt(t);for(t=i.length;0<t--;)Tc(i[t],"captured",e);for(t=0;t<i.length;t++)Tc(i[t],"bubbled",e)}}function ha(e,t,i){e&&i&&i.dispatchConfig.registrationName&&(t=$p(e,i.dispatchConfig.registrationName))&&(i._dispatchListeners=Zi(i._dispatchListeners,t),i._dispatchInstances=Zi(i._dispatchInstances,e))}function H0(e){e&&e.dispatchConfig.registrationName&&ha(e._targetInst,null,e)}function Gi(e){Al(e,W0)}var Dt=null,Vl=null,Br=null;function Wp(){if(Br)return Br;var e,t=Vl,i=t.length,n,r="value"in Dt?Dt.value:Dt.textContent,s=r.length;for(e=0;e<i&&t[e]===r[e];e++);var o=i-e;for(n=1;n<=o&&t[i-n]===r[s-n];n++);return Br=r.slice(e,1<n?1-n:void 0)}function Or(){return!0}function os(){return!1}function Oe(e,t,i,n){this.dispatchConfig=e,this._targetInst=t,this.nativeEvent=i,e=this.constructor.Interface;for(var r in e)e.hasOwnProperty(r)&&((t=e[r])?this[r]=t(i):r==="target"?this.target=n:this[r]=i[r]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Or:os,this.isPropagationStopped=os,this}Se(Oe.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!="unknown"&&(e.returnValue=!1),this.isDefaultPrevented=Or)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!="unknown"&&(e.cancelBubble=!0),this.isPropagationStopped=Or)},persist:function(){this.isPersistent=Or},isPersistent:os,destructor:function(){var e=this.constructor.Interface,t;for(t in e)this[t]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=os,this._dispatchInstances=this._dispatchListeners=null}});Oe.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null};Oe.extend=function(e){function t(){}function i(){return n.apply(this,arguments)}var n=this;t.prototype=n.prototype;var r=new t;return Se(r,i.prototype),i.prototype=r,i.prototype.constructor=i,i.Interface=Se({},n.Interface,e),i.extend=n.extend,Hp(i),i};Hp(Oe);function F0(e,t,i,n){if(this.eventPool.length){var r=this.eventPool.pop();return this.call(r,e,t,i,n),r}return new this(e,t,i,n)}function Q0(e){if(!(e instanceof this))throw Error(S(279));e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function Hp(e){e.eventPool=[],e.getPooled=F0,e.release=Q0}var Z0=Oe.extend({data:null}),G0=Oe.extend({data:null}),Y0=[9,13,27,32],Bl=Jt&&"CompositionEvent"in window,Nn=null;Jt&&"documentMode"in document&&(Nn=document.documentMode);var X0=Jt&&"TextEvent"in window&&!Nn,Fp=Jt&&(!Bl||Nn&&8<Nn&&11>=Nn),Nc=String.fromCharCode(32),gt={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["compositionend","keypress","textInput","paste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"blur compositionend keydown keypress keyup mousedown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:"blur compositionstart keydown keypress keyup mousedown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"blur compositionupdate keydown keypress keyup mousedown".split(" ")}},kc=!1;function Qp(e,t){switch(e){case"keyup":return Y0.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"blur":return!0;default:return!1}}function Zp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ki=!1;function J0(e,t){switch(e){case"compositionend":return Zp(t);case"keypress":return t.which!==32?null:(kc=!0,Nc);case"textInput":return e=t.data,e===Nc&&kc?null:e;default:return null}}function K0(e,t){if(ki)return e==="compositionend"||!Bl&&Qp(e,t)?(e=Wp(),Br=Vl=Dt=null,ki=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Fp&&t.locale!=="ko"?null:t.data;default:return null}}var q0={eventTypes:gt,extractEvents:function(e,t,i,n){var r;if(Bl)e:{switch(e){case"compositionstart":var s=gt.compositionStart;break e;case"compositionend":s=gt.compositionEnd;break e;case"compositionupdate":s=gt.compositionUpdate;break e}s=void 0}else ki?Qp(e,i)&&(s=gt.compositionEnd):e==="keydown"&&i.keyCode===229&&(s=gt.compositionStart);return s?(Fp&&i.locale!=="ko"&&(ki||s!==gt.compositionStart?s===gt.compositionEnd&&ki&&(r=Wp()):(Dt=n,Vl="value"in Dt?Dt.value:Dt.textContent,ki=!0)),s=Z0.getPooled(s,t,i,n),r?s.data=r:(r=Zp(i),r!==null&&(s.data=r)),Gi(s),r=s):r=null,(e=X0?J0(e,i):K0(e,i))?(t=G0.getPooled(gt.beforeInput,t,i,n),t.data=e,Gi(t)):t=null,r===null?t:t===null?r:[r,t]}},ex={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Gp(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!ex[e.type]:t==="textarea"}var Yp={change:{phasedRegistrationNames:{bubbled:"onChange",captured:"onChangeCapture"},dependencies:"blur change click focus input keydown keyup selectionchange".split(" ")}};function Xp(e,t,i){return e=Oe.getPooled(Yp.change,e,t,i),e.type="change",np(i),Gi(e),e}var kn=null,Un=null;function tx(e){Vs(e)}function Os(e){var t=vi(e);if(fp(t))return e}function ix(e,t){if(e==="change")return t}var pa=!1;Jt&&(pa=Ap("input")&&(!document.documentMode||9<document.documentMode));function Pc(){kn&&(kn.detachEvent("onpropertychange",Jp),Un=kn=null)}function Jp(e){if(e.propertyName==="value"&&Os(Un))if(e=Xp(Un,e,Tl(e)),ii)Vs(e);else{ii=!0;try{vl(tx,e)}finally{ii=!1,yl()}}}function nx(e,t,i){e==="focus"?(Pc(),kn=t,Un=i,kn.attachEvent("onpropertychange",Jp)):e==="blur"&&Pc()}function rx(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Os(Un)}function sx(e,t){if(e==="click")return Os(t)}function ox(e,t){if(e==="input"||e==="change")return Os(t)}var ax={eventTypes:Yp,_isInputEventSupported:pa,extractEvents:function(e,t,i,n){var r=t?vi(t):window,s=r.nodeName&&r.nodeName.toLowerCase();if(s==="select"||s==="input"&&r.type==="file")var o=ix;else if(Gp(r))if(pa)o=ox;else{o=rx;var a=nx}else(s=r.nodeName)&&s.toLowerCase()==="input"&&(r.type==="checkbox"||r.type==="radio")&&(o=sx);if(o&&(o=o(e,t)))return Xp(o,i,n);a&&a(e,r,t),e==="blur"&&(e=r._wrapperState)&&e.controlled&&r.type==="number"&&qo(r,"number",r.value)}},nr=Oe.extend({view:null,detail:null}),lx={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ux(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=lx[e])?!!t[e]:!1}function Ol(){return ux}var zc=0,Dc=0,Lc=!1,jc=!1,rr=nr.extend({screenX:null,screenY:null,clientX:null,clientY:null,pageX:null,pageY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:Ol,button:null,buttons:null,relatedTarget:function(e){return e.relatedTarget||(e.fromElement===e.srcElement?e.toElement:e.fromElement)},movementX:function(e){if("movementX"in e)return e.movementX;var t=zc;return zc=e.screenX,Lc?e.type==="mousemove"?e.screenX-t:0:(Lc=!0,0)},movementY:function(e){if("movementY"in e)return e.movementY;var t=Dc;return Dc=e.screenY,jc?e.type==="mousemove"?e.screenY-t:0:(jc=!0,0)}}),Kp=rr.extend({pointerId:null,width:null,height:null,pressure:null,tangentialPressure:null,tiltX:null,tiltY:null,twist:null,pointerType:null,isPrimary:null}),hn={mouseEnter:{registrationName:"onMouseEnter",dependencies:["mouseout","mouseover"]},mouseLeave:{registrationName:"onMouseLeave",dependencies:["mouseout","mouseover"]},pointerEnter:{registrationName:"onPointerEnter",dependencies:["pointerout","pointerover"]},pointerLeave:{registrationName:"onPointerLeave",dependencies:["pointerout","pointerover"]}},cx={eventTypes:hn,extractEvents:function(e,t,i,n,r){var s=e==="mouseover"||e==="pointerover",o=e==="mouseout"||e==="pointerout";if(s&&(r&32)===0&&(i.relatedTarget||i.fromElement)||!o&&!s)return null;if(s=n.window===n?n:(s=n.ownerDocument)?s.defaultView||s.parentWindow:window,o){if(o=t,t=(t=i.relatedTarget||i.toElement)?tr(t):null,t!==null){var a=Ii(t);(t!==a||t.tag!==5&&t.tag!==6)&&(t=null)}}else o=null;if(o===t)return null;if(e==="mouseout"||e==="mouseover")var l=rr,u=hn.mouseLeave,c=hn.mouseEnter,d="mouse";else(e==="pointerout"||e==="pointerover")&&(l=Kp,u=hn.pointerLeave,c=hn.pointerEnter,d="pointer");if(e=o==null?s:vi(o),s=t==null?s:vi(t),u=l.getPooled(u,o,i,n),u.type=d+"leave",u.target=e,u.relatedTarget=s,i=l.getPooled(c,t,i,n),i.type=d+"enter",i.target=s,i.relatedTarget=e,n=o,d=t,n&&d)e:{for(l=n,c=d,o=0,e=l;e;e=vt(e))o++;for(e=0,t=c;t;t=vt(t))e++;for(;0<o-e;)l=vt(l),o--;for(;0<e-o;)c=vt(c),e--;for(;o--;){if(l===c||l===c.alternate)break e;l=vt(l),c=vt(c)}l=null}else l=null;for(c=l,l=[];n&&n!==c&&(o=n.alternate,!(o!==null&&o===c));)l.push(n),n=vt(n);for(n=[];d&&d!==c&&(o=d.alternate,!(o!==null&&o===c));)n.push(d),d=vt(d);for(d=0;d<l.length;d++)ha(l[d],"bubbled",u);for(d=n.length;0<d--;)ha(n[d],"captured",i);return(r&64)===0?[u]:[u,i]}};function dx(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var wi=typeof Object.is=="function"?Object.is:dx,hx=Object.prototype.hasOwnProperty;function $n(e,t){if(wi(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var i=Object.keys(e),n=Object.keys(t);if(i.length!==n.length)return!1;for(n=0;n<i.length;n++)if(!hx.call(t,i[n])||!wi(e[i[n]],t[i[n]]))return!1;return!0}var px=Jt&&"documentMode"in document&&11>=document.documentMode,qp={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"blur contextmenu dragend focus keydown keyup mousedown mouseup selectionchange".split(" ")}},Pi=null,fa=null,Pn=null,ga=!1;function Rc(e,t){var i=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;return ga||Pi==null||Pi!==ua(i)?null:(i=Pi,"selectionStart"in i&&ca(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Pn&&$n(Pn,i)?null:(Pn=i,e=Oe.getPooled(qp.select,fa,e,t),e.type="select",e.target=Pi,Gi(e),e))}var fx={eventTypes:qp,extractEvents:function(e,t,i,n,r,s){if(r=s||(n.window===n?n.document:n.nodeType===9?n:n.ownerDocument),!(s=!r)){e:{r=El(r),s=ml.onSelect;for(var o=0;o<s.length;o++)if(!r.has(s[o])){r=!1;break e}r=!0}s=!r}if(s)return null;switch(r=t?vi(t):window,e){case"focus":(Gp(r)||r.contentEditable==="true")&&(Pi=r,fa=t,Pn=null);break;case"blur":Pn=fa=Pi=null;break;case"mousedown":ga=!0;break;case"contextmenu":case"mouseup":case"dragend":return ga=!1,Rc(i,n);case"selectionchange":if(px)break;case"keydown":case"keyup":return Rc(i,n)}return null}},gx=Oe.extend({animationName:null,elapsedTime:null,pseudoElement:null}),mx=Oe.extend({clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),vx=nr.extend({relatedTarget:null});function _r(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}var wx={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yx={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},xx=nr.extend({key:function(e){if(e.key){var t=wx[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=_r(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?yx[e.keyCode]||"Unidentified":""},location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:Ol,charCode:function(e){return e.type==="keypress"?_r(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?_r(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Sx=rr.extend({dataTransfer:null}),Cx=nr.extend({touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:Ol}),Mx=Oe.extend({propertyName:null,elapsedTime:null,pseudoElement:null}),Ix=rr.extend({deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:null,deltaMode:null}),bx={eventTypes:Lp,extractEvents:function(e,t,i,n){var r=jp.get(e);if(!r)return null;switch(e){case"keypress":if(_r(i)===0)return null;case"keydown":case"keyup":e=xx;break;case"blur":case"focus":e=vx;break;case"click":if(i.button===2)return null;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":e=rr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":e=Sx;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":e=Cx;break;case Sp:case Cp:case Mp:e=gx;break;case Ip:e=Mx;break;case"scroll":e=nr;break;case"wheel":e=Ix;break;case"copy":case"cut":case"paste":e=mx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":e=Kp;break;default:e=Oe}return t=e.getPooled(r,t,i,n),Gi(t),t}};if(ts)throw Error(S(101));ts=Array.prototype.slice.call("ResponderEventPlugin SimpleEventPlugin EnterLeaveEventPlugin ChangeEventPlugin SelectEventPlugin BeforeInputEventPlugin".split(" "));tp();var Ex=ir;gl=Rl;qh=Ex;ep=vi;ip({SimpleEventPlugin:bx,EnterLeaveEventPlugin:cx,ChangeEventPlugin:ax,SelectEventPlugin:fx,BeforeInputEventPlugin:q0});var ma=[],zi=-1;function G(e){0>zi||(e.current=ma[zi],ma[zi]=null,zi--)}function te(e,t){zi++,ma[zi]=e.current,e.current=t}var Gt={},ve={current:Gt},Me={current:!1},yi=Gt;function Yi(e,t){var i=e.type.contextTypes;if(!i)return Gt;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in i)r[s]=t[s];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=r),r}function Ie(e){return e=e.childContextTypes,e!=null}function as(){G(Me),G(ve)}function Vc(e,t,i){if(ve.current!==Gt)throw Error(S(168));te(ve,t),te(Me,i)}function ef(e,t,i){var n=e.stateNode;if(e=t.childContextTypes,typeof n.getChildContext!="function")return i;n=n.getChildContext();for(var r in n)if(!(r in e))throw Error(S(108,It(t)||"Unknown",r));return Se({},i,{},n)}function Ur(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Gt,yi=ve.current,te(ve,e),te(Me,Me.current),!0}function Bc(e,t,i){var n=e.stateNode;if(!n)throw Error(S(169));i?(e=ef(e,t,yi),n.__reactInternalMemoizedMergedChildContext=e,G(Me),G(ve),te(ve,e)):G(Me),te(Me,i)}var Ax=le.unstable_runWithPriority,_l=le.unstable_scheduleCallback,tf=le.unstable_cancelCallback,Oc=le.unstable_requestPaint,va=le.unstable_now,Tx=le.unstable_getCurrentPriorityLevel,_s=le.unstable_ImmediatePriority,nf=le.unstable_UserBlockingPriority,rf=le.unstable_NormalPriority,sf=le.unstable_LowPriority,of=le.unstable_IdlePriority,af={},Nx=le.unstable_shouldYield,kx=Oc!==void 0?Oc:function(){},yt=null,$r=null,wo=!1,_c=va(),We=1e4>_c?va:function(){return va()-_c};function Us(){switch(Tx()){case _s:return 99;case nf:return 98;case rf:return 97;case sf:return 96;case of:return 95;default:throw Error(S(332))}}function lf(e){switch(e){case 99:return _s;case 98:return nf;case 97:return rf;case 96:return sf;case 95:return of;default:throw Error(S(332))}}function Yt(e,t){return e=lf(e),Ax(e,t)}function uf(e,t,i){return e=lf(e),_l(e,t,i)}function Uc(e){return yt===null?(yt=[e],$r=_l(_s,cf)):yt.push(e),af}function ht(){if($r!==null){var e=$r;$r=null,tf(e)}cf()}function cf(){if(!wo&&yt!==null){wo=!0;var e=0;try{var t=yt;Yt(99,function(){for(;e<t.length;e++){var i=t[e];do i=i(!0);while(i!==null)}}),yt=null}catch(i){throw yt!==null&&(yt=yt.slice(e+1)),_l(_s,ht),i}finally{wo=!1}}}function Wr(e,t,i){return i/=10,1073741821-(((1073741821-e+t/10)/i|0)+1)*i}function Je(e,t){if(e&&e.defaultProps){t=Se({},t),e=e.defaultProps;for(var i in e)t[i]===void 0&&(t[i]=e[i])}return t}var ls={current:null},us=null,Di=null,cs=null;function Ul(){cs=Di=us=null}function $l(e){var t=ls.current;G(ls),e.type._context._currentValue=t}function df(e,t){for(;e!==null;){var i=e.alternate;if(e.childExpirationTime<t)e.childExpirationTime=t,i!==null&&i.childExpirationTime<t&&(i.childExpirationTime=t);else if(i!==null&&i.childExpirationTime<t)i.childExpirationTime=t;else break;e=e.return}}function Ui(e,t){us=e,cs=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.expirationTime>=t&&(at=!0),e.firstContext=null)}function Fe(e,t){if(cs!==e&&t!==!1&&t!==0)if((typeof t!="number"||t===1073741823)&&(cs=e,t=1073741823),t={context:e,observedBits:t,next:null},Di===null){if(us===null)throw Error(S(308));Di=t,us.dependencies={expirationTime:0,firstContext:t,responders:null}}else Di=Di.next=t;return e._currentValue}var Pt=!1;function Wl(e){e.updateQueue={baseState:e.memoizedState,baseQueue:null,shared:{pending:null},effects:null}}function Hl(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,baseQueue:e.baseQueue,shared:e.shared,effects:e.effects})}function $t(e,t){return e={expirationTime:e,suspenseConfig:t,tag:0,payload:null,callback:null,next:null},e.next=e}function Wt(e,t){if(e=e.updateQueue,e!==null){e=e.shared;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}}function $c(e,t){var i=e.alternate;i!==null&&Hl(i,e),e=e.updateQueue,i=e.baseQueue,i===null?(e.baseQueue=t.next=t,t.next=t):(t.next=i.next,i.next=t)}function Wn(e,t,i,n){var r=e.updateQueue;Pt=!1;var s=r.baseQueue,o=r.shared.pending;if(o!==null){if(s!==null){var a=s.next;s.next=o.next,o.next=a}s=o,r.shared.pending=null,a=e.alternate,a!==null&&(a=a.updateQueue,a!==null&&(a.baseQueue=o))}if(s!==null){a=s.next;var l=r.baseState,u=0,c=null,d=null,m=null;if(a!==null){var w=a;do{if(o=w.expirationTime,o<n){var y={expirationTime:w.expirationTime,suspenseConfig:w.suspenseConfig,tag:w.tag,payload:w.payload,callback:w.callback,next:null};m===null?(d=m=y,c=l):m=m.next=y,o>u&&(u=o)}else{m!==null&&(m=m.next={expirationTime:1073741823,suspenseConfig:w.suspenseConfig,tag:w.tag,payload:w.payload,callback:w.callback,next:null}),Uf(o,w.suspenseConfig);e:{var M=e,p=w;switch(o=t,y=i,p.tag){case 1:if(M=p.payload,typeof M=="function"){l=M.call(y,l,o);break e}l=M;break e;case 3:M.effectTag=M.effectTag&-4097|64;case 0:if(M=p.payload,o=typeof M=="function"?M.call(y,l,o):M,o==null)break e;l=Se({},l,o);break e;case 2:Pt=!0}}w.callback!==null&&(e.effectTag|=32,o=r.effects,o===null?r.effects=[w]:o.push(w))}if(w=w.next,w===null||w===a){if(o=r.shared.pending,o===null)break;w=s.next=o.next,o.next=a,r.baseQueue=s=o,r.shared.pending=null}}while(1)}m===null?c=l:m.next=d,r.baseState=c,r.baseQueue=m,Qs(u),e.expirationTime=u,e.memoizedState=l}}function Wc(e,t,i){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var n=e[t],r=n.callback;if(r!==null){if(n.callback=null,n=r,r=i,typeof n!="function")throw Error(S(191,n));n.call(r)}}}var zn=Ke.ReactCurrentBatchConfig,hf=new js.Component().refs;function ds(e,t,i,n){t=e.memoizedState,i=i(n,t),i=i==null?t:Se({},t,i),e.memoizedState=i,e.expirationTime===0&&(e.updateQueue.baseState=i)}var $s={isMounted:function(e){return(e=e._reactInternalFiber)?Ii(e)===e:!1},enqueueSetState:function(e,t,i){e=e._reactInternalFiber;var n=ct(),r=zn.suspense;n=pi(n,e,r),r=$t(n,r),r.payload=t,i!=null&&(r.callback=i),Wt(e,r),Ft(e,n)},enqueueReplaceState:function(e,t,i){e=e._reactInternalFiber;var n=ct(),r=zn.suspense;n=pi(n,e,r),r=$t(n,r),r.tag=1,r.payload=t,i!=null&&(r.callback=i),Wt(e,r),Ft(e,n)},enqueueForceUpdate:function(e,t){e=e._reactInternalFiber;var i=ct(),n=zn.suspense;i=pi(i,e,n),n=$t(i,n),n.tag=2,t!=null&&(n.callback=t),Wt(e,n),Ft(e,i)}};function Hc(e,t,i,n,r,s,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(n,s,o):t.prototype&&t.prototype.isPureReactComponent?!$n(i,n)||!$n(r,s):!0}function pf(e,t,i){var n=!1,r=Gt,s=t.contextType;return typeof s=="object"&&s!==null?s=Fe(s):(r=Ie(t)?yi:ve.current,n=t.contextTypes,s=(n=n!=null)?Yi(e,r):Gt),t=new t(i,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=$s,e.stateNode=t,t._reactInternalFiber=e,n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=s),t}function Fc(e,t,i,n){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(i,n),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(i,n),t.state!==e&&$s.enqueueReplaceState(t,t.state,null)}function wa(e,t,i,n){var r=e.stateNode;r.props=i,r.state=e.memoizedState,r.refs=hf,Wl(e);var s=t.contextType;typeof s=="object"&&s!==null?r.context=Fe(s):(s=Ie(t)?yi:ve.current,r.context=Yi(e,s)),Wn(e,i,r,n),r.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(ds(e,t,s,i),r.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(t=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),t!==r.state&&$s.enqueueReplaceState(r,r.state,null),Wn(e,i,r,n),r.state=e.memoizedState),typeof r.componentDidMount=="function"&&(e.effectTag|=4)}var Sr=Array.isArray;function pn(e,t,i){if(e=i.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(S(309));var n=i.stateNode}if(!n)throw Error(S(147,e));var r=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===r?t.ref:(t=function(s){var o=n.refs;o===hf&&(o=n.refs={}),s===null?delete o[r]:o[r]=s},t._stringRef=r,t)}if(typeof e!="string")throw Error(S(284));if(!i._owner)throw Error(S(290,e))}return e}function Cr(e,t){if(e.type!=="textarea")throw Error(S(31,Object.prototype.toString.call(t)==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":t,""))}function ff(e){function t(p,h){if(e){var f=p.lastEffect;f!==null?(f.nextEffect=h,p.lastEffect=h):p.firstEffect=p.lastEffect=h,h.nextEffect=null,h.effectTag=8}}function i(p,h){if(!e)return null;for(;h!==null;)t(p,h),h=h.sibling;return null}function n(p,h){for(p=new Map;h!==null;)h.key!==null?p.set(h.key,h):p.set(h.index,h),h=h.sibling;return p}function r(p,h){return p=xi(p,h),p.index=0,p.sibling=null,p}function s(p,h,f){return p.index=f,e?(f=p.alternate,f!==null?(f=f.index,f<h?(p.effectTag=2,h):f):(p.effectTag=2,h)):h}function o(p){return e&&p.alternate===null&&(p.effectTag=2),p}function a(p,h,f,g){return h===null||h.tag!==6?(h=Io(f,p.mode,g),h.return=p,h):(h=r(h,f),h.return=p,h)}function l(p,h,f,g){return h!==null&&h.elementType===f.type?(g=r(h,f.props),g.ref=pn(p,h,f),g.return=p,g):(g=Zr(f.type,f.key,f.props,null,p.mode,g),g.ref=pn(p,h,f),g.return=p,g)}function u(p,h,f,g){return h===null||h.tag!==4||h.stateNode.containerInfo!==f.containerInfo||h.stateNode.implementation!==f.implementation?(h=bo(f,p.mode,g),h.return=p,h):(h=r(h,f.children||[]),h.return=p,h)}function c(p,h,f,g,v){return h===null||h.tag!==7?(h=Rt(f,p.mode,g,v),h.return=p,h):(h=r(h,f),h.return=p,h)}function d(p,h,f){if(typeof h=="string"||typeof h=="number")return h=Io(""+h,p.mode,f),h.return=p,h;if(typeof h=="object"&&h!==null){switch(h.$$typeof){case vr:return f=Zr(h.type,h.key,h.props,null,p.mode,f),f.ref=pn(p,null,h),f.return=p,f;case Ti:return h=bo(h,p.mode,f),h.return=p,h}if(Sr(h)||an(h))return h=Rt(h,p.mode,f,null),h.return=p,h;Cr(p,h)}return null}function m(p,h,f,g){var v=h!==null?h.key:null;if(typeof f=="string"||typeof f=="number")return v!==null?null:a(p,h,""+f,g);if(typeof f=="object"&&f!==null){switch(f.$$typeof){case vr:return f.key===v?f.type===ti?c(p,h,f.props.children,g,v):l(p,h,f,g):null;case Ti:return f.key===v?u(p,h,f,g):null}if(Sr(f)||an(f))return v!==null?null:c(p,h,f,g,null);Cr(p,f)}return null}function w(p,h,f,g,v){if(typeof g=="string"||typeof g=="number")return p=p.get(f)||null,a(h,p,""+g,v);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case vr:return p=p.get(g.key===null?f:g.key)||null,g.type===ti?c(h,p,g.props.children,v,g.key):l(h,p,g,v);case Ti:return p=p.get(g.key===null?f:g.key)||null,u(h,p,g,v)}if(Sr(g)||an(g))return p=p.get(f)||null,c(h,p,g,v,null);Cr(h,g)}return null}function y(p,h,f,g){for(var v=null,C=null,x=h,N=h=0,z=null;x!==null&&N<f.length;N++){x.index>N?(z=x,x=null):z=x.sibling;var k=m(p,x,f[N],g);if(k===null){x===null&&(x=z);break}e&&x&&k.alternate===null&&t(p,x),h=s(k,h,N),C===null?v=k:C.sibling=k,C=k,x=z}if(N===f.length)return i(p,x),v;if(x===null){for(;N<f.length;N++)x=d(p,f[N],g),x!==null&&(h=s(x,h,N),C===null?v=x:C.sibling=x,C=x);return v}for(x=n(p,x);N<f.length;N++)z=w(x,p,N,f[N],g),z!==null&&(e&&z.alternate!==null&&x.delete(z.key===null?N:z.key),h=s(z,h,N),C===null?v=z:C.sibling=z,C=z);return e&&x.forEach(function(K){return t(p,K)}),v}function M(p,h,f,g){var v=an(f);if(typeof v!="function")throw Error(S(150));if(f=v.call(f),f==null)throw Error(S(151));for(var C=v=null,x=h,N=h=0,z=null,k=f.next();x!==null&&!k.done;N++,k=f.next()){x.index>N?(z=x,x=null):z=x.sibling;var K=m(p,x,k.value,g);if(K===null){x===null&&(x=z);break}e&&x&&K.alternate===null&&t(p,x),h=s(K,h,N),C===null?v=K:C.sibling=K,C=K,x=z}if(k.done)return i(p,x),v;if(x===null){for(;!k.done;N++,k=f.next())k=d(p,k.value,g),k!==null&&(h=s(k,h,N),C===null?v=k:C.sibling=k,C=k);return v}for(x=n(p,x);!k.done;N++,k=f.next())k=w(x,p,N,k.value,g),k!==null&&(e&&k.alternate!==null&&x.delete(k.key===null?N:k.key),h=s(k,h,N),C===null?v=k:C.sibling=k,C=k);return e&&x.forEach(function(q){return t(p,q)}),v}return function(p,h,f,g){var v=typeof f=="object"&&f!==null&&f.type===ti&&f.key===null;v&&(f=f.props.children);var C=typeof f=="object"&&f!==null;if(C)switch(f.$$typeof){case vr:e:{for(C=f.key,v=h;v!==null;){if(v.key===C){switch(v.tag){case 7:if(f.type===ti){i(p,v.sibling),h=r(v,f.props.children),h.return=p,p=h;break e}break;default:if(v.elementType===f.type){i(p,v.sibling),h=r(v,f.props),h.ref=pn(p,v,f),h.return=p,p=h;break e}}i(p,v);break}else t(p,v);v=v.sibling}f.type===ti?(h=Rt(f.props.children,p.mode,g,f.key),h.return=p,p=h):(g=Zr(f.type,f.key,f.props,null,p.mode,g),g.ref=pn(p,h,f),g.return=p,p=g)}return o(p);case Ti:e:{for(v=f.key;h!==null;){if(h.key===v)if(h.tag===4&&h.stateNode.containerInfo===f.containerInfo&&h.stateNode.implementation===f.implementation){i(p,h.sibling),h=r(h,f.children||[]),h.return=p,p=h;break e}else{i(p,h);break}else t(p,h);h=h.sibling}h=bo(f,p.mode,g),h.return=p,p=h}return o(p)}if(typeof f=="string"||typeof f=="number")return f=""+f,h!==null&&h.tag===6?(i(p,h.sibling),h=r(h,f),h.return=p,p=h):(i(p,h),h=Io(f,p.mode,g),h.return=p,p=h),o(p);if(Sr(f))return y(p,h,f,g);if(an(f))return M(p,h,f,g);if(C&&Cr(p,f),typeof f=="undefined"&&!v)switch(p.tag){case 1:case 0:throw p=p.type,Error(S(152,p.displayName||p.name||"Component"))}return i(p,h)}}var Xi=ff(!0),Fl=ff(!1),sr={},ut={current:sr},Hn={current:sr},Fn={current:sr};function ni(e){if(e===sr)throw Error(S(174));return e}function ya(e,t){switch(te(Fn,t),te(Hn,e),te(ut,sr),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:ia(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=ia(t,e)}G(ut),te(ut,t)}function Ji(){G(ut),G(Hn),G(Fn)}function Qc(e){ni(Fn.current);var t=ni(ut.current),i=ia(t,e.type);t!==i&&(te(Hn,e),te(ut,i))}function Ql(e){Hn.current===e&&(G(ut),G(Hn))}var J={current:0};function hs(e){for(var t=e;t!==null;){if(t.tag===13){var i=t.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data===Dl||i.data===Ll))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if((t.effectTag&64)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Zl(e,t){return{responder:e,props:t}}var Hr=Ke.ReactCurrentDispatcher,He=Ke.ReactCurrentBatchConfig,Lt=0,ne=null,fe=null,ge=null,ps=!1;function ke(){throw Error(S(321))}function Gl(e,t){if(t===null)return!1;for(var i=0;i<t.length&&i<e.length;i++)if(!wi(e[i],t[i]))return!1;return!0}function Yl(e,t,i,n,r,s){if(Lt=s,ne=t,t.memoizedState=null,t.updateQueue=null,t.expirationTime=0,Hr.current=e===null||e.memoizedState===null?Px:zx,e=i(n,r),t.expirationTime===Lt){s=0;do{if(t.expirationTime=0,!(25>s))throw Error(S(301));s+=1,ge=fe=null,t.updateQueue=null,Hr.current=Dx,e=i(n,r)}while(t.expirationTime===Lt)}if(Hr.current=ms,t=fe!==null&&fe.next!==null,Lt=0,ge=fe=ne=null,ps=!1,t)throw Error(S(300));return e}function $i(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ge===null?ne.memoizedState=ge=e:ge=ge.next=e,ge}function en(){if(fe===null){var e=ne.alternate;e=e!==null?e.memoizedState:null}else e=fe.next;var t=ge===null?ne.memoizedState:ge.next;if(t!==null)ge=t,fe=e;else{if(e===null)throw Error(S(310));fe=e,e={memoizedState:fe.memoizedState,baseState:fe.baseState,baseQueue:fe.baseQueue,queue:fe.queue,next:null},ge===null?ne.memoizedState=ge=e:ge=ge.next=e}return ge}function ci(e,t){return typeof t=="function"?t(e):t}function Mr(e){var t=en(),i=t.queue;if(i===null)throw Error(S(311));i.lastRenderedReducer=e;var n=fe,r=n.baseQueue,s=i.pending;if(s!==null){if(r!==null){var o=r.next;r.next=s.next,s.next=o}n.baseQueue=r=s,i.pending=null}if(r!==null){r=r.next,n=n.baseState;var a=o=s=null,l=r;do{var u=l.expirationTime;if(u<Lt){var c={expirationTime:l.expirationTime,suspenseConfig:l.suspenseConfig,action:l.action,eagerReducer:l.eagerReducer,eagerState:l.eagerState,next:null};a===null?(o=a=c,s=n):a=a.next=c,u>ne.expirationTime&&(ne.expirationTime=u,Qs(u))}else a!==null&&(a=a.next={expirationTime:1073741823,suspenseConfig:l.suspenseConfig,action:l.action,eagerReducer:l.eagerReducer,eagerState:l.eagerState,next:null}),Uf(u,l.suspenseConfig),n=l.eagerReducer===e?l.eagerState:e(n,l.action);l=l.next}while(l!==null&&l!==r);a===null?s=n:a.next=o,wi(n,t.memoizedState)||(at=!0),t.memoizedState=n,t.baseState=s,t.baseQueue=a,i.lastRenderedState=n}return[t.memoizedState,i.dispatch]}function Ir(e){var t=en(),i=t.queue;if(i===null)throw Error(S(311));i.lastRenderedReducer=e;var n=i.dispatch,r=i.pending,s=t.memoizedState;if(r!==null){i.pending=null;var o=r=r.next;do s=e(s,o.action),o=o.next;while(o!==r);wi(s,t.memoizedState)||(at=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),i.lastRenderedState=s}return[s,n]}function yo(e){var t=$i();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e=t.queue={pending:null,dispatch:null,lastRenderedReducer:ci,lastRenderedState:e},e=e.dispatch=xf.bind(null,ne,e),[t.memoizedState,e]}function xa(e,t,i,n){return e={tag:e,create:t,destroy:i,deps:n,next:null},t=ne.updateQueue,t===null?(t={lastEffect:null},ne.updateQueue=t,t.lastEffect=e.next=e):(i=t.lastEffect,i===null?t.lastEffect=e.next=e:(n=i.next,i.next=e,e.next=n,t.lastEffect=e)),e}function gf(){return en().memoizedState}function Sa(e,t,i,n){var r=$i();ne.effectTag|=e,r.memoizedState=xa(1|t,i,void 0,n===void 0?null:n)}function Xl(e,t,i,n){var r=en();n=n===void 0?null:n;var s=void 0;if(fe!==null){var o=fe.memoizedState;if(s=o.destroy,n!==null&&Gl(n,o.deps)){xa(t,i,s,n);return}}ne.effectTag|=e,r.memoizedState=xa(1|t,i,s,n)}function Zc(e,t){return Sa(516,4,e,t)}function fs(e,t){return Xl(516,4,e,t)}function mf(e,t){return Xl(4,2,e,t)}function vf(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function wf(e,t,i){return i=i!=null?i.concat([e]):null,Xl(4,2,vf.bind(null,t,e),i)}function Jl(){}function Gc(e,t){return $i().memoizedState=[e,t===void 0?null:t],e}function gs(e,t){var i=en();t=t===void 0?null:t;var n=i.memoizedState;return n!==null&&t!==null&&Gl(t,n[1])?n[0]:(i.memoizedState=[e,t],e)}function yf(e,t){var i=en();t=t===void 0?null:t;var n=i.memoizedState;return n!==null&&t!==null&&Gl(t,n[1])?n[0]:(e=e(),i.memoizedState=[e,t],e)}function Kl(e,t,i){var n=Us();Yt(98>n?98:n,function(){e(!0)}),Yt(97<n?97:n,function(){var r=He.suspense;He.suspense=t===void 0?null:t;try{e(!1),i()}finally{He.suspense=r}})}function xf(e,t,i){var n=ct(),r=zn.suspense;n=pi(n,e,r),r={expirationTime:n,suspenseConfig:r,action:i,eagerReducer:null,eagerState:null,next:null};var s=t.pending;if(s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r,s=e.alternate,e===ne||s!==null&&s===ne)ps=!0,r.expirationTime=Lt,ne.expirationTime=Lt;else{if(e.expirationTime===0&&(s===null||s.expirationTime===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,i);if(r.eagerReducer=s,r.eagerState=a,wi(a,o))return}catch{}finally{}Ft(e,n)}}var ms={readContext:Fe,useCallback:ke,useContext:ke,useEffect:ke,useImperativeHandle:ke,useLayoutEffect:ke,useMemo:ke,useReducer:ke,useRef:ke,useState:ke,useDebugValue:ke,useResponder:ke,useDeferredValue:ke,useTransition:ke},Px={readContext:Fe,useCallback:Gc,useContext:Fe,useEffect:Zc,useImperativeHandle:function(e,t,i){return i=i!=null?i.concat([e]):null,Sa(4,2,vf.bind(null,t,e),i)},useLayoutEffect:function(e,t){return Sa(4,2,e,t)},useMemo:function(e,t){var i=$i();return t=t===void 0?null:t,e=e(),i.memoizedState=[e,t],e},useReducer:function(e,t,i){var n=$i();return t=i!==void 0?i(t):t,n.memoizedState=n.baseState=t,e=n.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},e=e.dispatch=xf.bind(null,ne,e),[n.memoizedState,e]},useRef:function(e){var t=$i();return e={current:e},t.memoizedState=e},useState:yo,useDebugValue:Jl,useResponder:Zl,useDeferredValue:function(e,t){var i=yo(e),n=i[0],r=i[1];return Zc(function(){var s=He.suspense;He.suspense=t===void 0?null:t;try{r(e)}finally{He.suspense=s}},[e,t]),n},useTransition:function(e){var t=yo(!1),i=t[0];return t=t[1],[Gc(Kl.bind(null,t,e),[t,e]),i]}},zx={readContext:Fe,useCallback:gs,useContext:Fe,useEffect:fs,useImperativeHandle:wf,useLayoutEffect:mf,useMemo:yf,useReducer:Mr,useRef:gf,useState:function(){return Mr(ci)},useDebugValue:Jl,useResponder:Zl,useDeferredValue:function(e,t){var i=Mr(ci),n=i[0],r=i[1];return fs(function(){var s=He.suspense;He.suspense=t===void 0?null:t;try{r(e)}finally{He.suspense=s}},[e,t]),n},useTransition:function(e){var t=Mr(ci),i=t[0];return t=t[1],[gs(Kl.bind(null,t,e),[t,e]),i]}},Dx={readContext:Fe,useCallback:gs,useContext:Fe,useEffect:fs,useImperativeHandle:wf,useLayoutEffect:mf,useMemo:yf,useReducer:Ir,useRef:gf,useState:function(){return Ir(ci)},useDebugValue:Jl,useResponder:Zl,useDeferredValue:function(e,t){var i=Ir(ci),n=i[0],r=i[1];return fs(function(){var s=He.suspense;He.suspense=t===void 0?null:t;try{r(e)}finally{He.suspense=s}},[e,t]),n},useTransition:function(e){var t=Ir(ci),i=t[0];return t=t[1],[gs(Kl.bind(null,t,e),[t,e]),i]}},Ct=null,jt=null,di=!1;function Sf(e,t){var i=lt(5,null,null,0);i.elementType="DELETED",i.type="DELETED",i.stateNode=t,i.return=e,i.effectTag=8,e.lastEffect!==null?(e.lastEffect.nextEffect=i,e.lastEffect=i):e.firstEffect=e.lastEffect=i}function Yc(e,t){switch(e.tag){case 5:var i=e.type;return t=t.nodeType!==1||i.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,!0):!1;case 13:return!1;default:return!1}}function Ca(e){if(di){var t=jt;if(t){var i=t;if(!Yc(e,t)){if(t=_i(i.nextSibling),!t||!Yc(e,t)){e.effectTag=e.effectTag&-1025|2,di=!1,Ct=e;return}Sf(Ct,i)}Ct=e,jt=_i(t.firstChild)}else e.effectTag=e.effectTag&-1025|2,di=!1,Ct=e}}function Xc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Ct=e}function br(e){if(e!==Ct)return!1;if(!di)return Xc(e),di=!0,!1;var t=e.type;if(e.tag!==5||t!=="head"&&t!=="body"&&!da(t,e.memoizedProps))for(t=jt;t;)Sf(e,t),t=_i(t.nextSibling);if(Xc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(S(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var i=e.data;if(i===_p){if(t===0){jt=_i(e.nextSibling);break e}t--}else i!==Op&&i!==Ll&&i!==Dl||t++}e=e.nextSibling}jt=null}}else jt=Ct?_i(e.stateNode.nextSibling):null;return!0}function xo(){jt=Ct=null,di=!1}var Lx=Ke.ReactCurrentOwner,at=!1;function Pe(e,t,i,n){t.child=e===null?Fl(t,null,i,n):Xi(t,e.child,i,n)}function Jc(e,t,i,n,r){i=i.render;var s=t.ref;return Ui(t,r),n=Yl(e,t,i,n,s,r),e!==null&&!at?(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=r&&(e.expirationTime=0),Mt(e,t,r)):(t.effectTag|=1,Pe(e,t,n,r),t.child)}function Kc(e,t,i,n,r,s){if(e===null){var o=i.type;return typeof o=="function"&&!nu(o)&&o.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(t.tag=15,t.type=o,Cf(e,t,o,n,r,s)):(e=Zr(i.type,null,n,null,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}return o=e.child,r<s&&(r=o.memoizedProps,i=i.compare,i=i!==null?i:$n,i(r,n)&&e.ref===t.ref)?Mt(e,t,s):(t.effectTag|=1,e=xi(o,n),e.ref=t.ref,e.return=t,t.child=e)}function Cf(e,t,i,n,r,s){return e!==null&&$n(e.memoizedProps,n)&&e.ref===t.ref&&(at=!1,r<s)?(t.expirationTime=e.expirationTime,Mt(e,t,s)):Ma(e,t,i,n,s)}function Mf(e,t){var i=t.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(t.effectTag|=128)}function Ma(e,t,i,n,r){var s=Ie(i)?yi:ve.current;return s=Yi(t,s),Ui(t,r),i=Yl(e,t,i,n,s,r),e!==null&&!at?(t.updateQueue=e.updateQueue,t.effectTag&=-517,e.expirationTime<=r&&(e.expirationTime=0),Mt(e,t,r)):(t.effectTag|=1,Pe(e,t,i,r),t.child)}function qc(e,t,i,n,r){if(Ie(i)){var s=!0;Ur(t)}else s=!1;if(Ui(t,r),t.stateNode===null)e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),pf(t,i,n),wa(t,i,n,r),n=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var l=o.context,u=i.contextType;typeof u=="object"&&u!==null?u=Fe(u):(u=Ie(i)?yi:ve.current,u=Yi(t,u));var c=i.getDerivedStateFromProps,d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";d||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==n||l!==u)&&Fc(t,o,n,u),Pt=!1;var m=t.memoizedState;o.state=m,Wn(t,n,o,r),l=t.memoizedState,a!==n||m!==l||Me.current||Pt?(typeof c=="function"&&(ds(t,i,c,n),l=t.memoizedState),(a=Pt||Hc(t,i,a,n,m,l,u))?(d||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.effectTag|=4)):(typeof o.componentDidMount=="function"&&(t.effectTag|=4),t.memoizedProps=n,t.memoizedState=l),o.props=n,o.state=l,o.context=u,n=a):(typeof o.componentDidMount=="function"&&(t.effectTag|=4),n=!1)}else o=t.stateNode,Hl(e,t),a=t.memoizedProps,o.props=t.type===t.elementType?a:Je(t.type,a),l=o.context,u=i.contextType,typeof u=="object"&&u!==null?u=Fe(u):(u=Ie(i)?yi:ve.current,u=Yi(t,u)),c=i.getDerivedStateFromProps,(d=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==n||l!==u)&&Fc(t,o,n,u),Pt=!1,l=t.memoizedState,o.state=l,Wn(t,n,o,r),m=t.memoizedState,a!==n||l!==m||Me.current||Pt?(typeof c=="function"&&(ds(t,i,c,n),m=t.memoizedState),(c=Pt||Hc(t,i,a,n,l,m,u))?(d||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(n,m,u),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(n,m,u)),typeof o.componentDidUpdate=="function"&&(t.effectTag|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.effectTag|=256)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=256),t.memoizedProps=n,t.memoizedState=m),o.props=n,o.state=m,o.context=u,n=c):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&l===e.memoizedState||(t.effectTag|=256),n=!1);return Ia(e,t,i,n,s,r)}function Ia(e,t,i,n,r,s){Mf(e,t);var o=(t.effectTag&64)!==0;if(!n&&!o)return r&&Bc(t,i,!1),Mt(e,t,s);n=t.stateNode,Lx.current=t;var a=o&&typeof i.getDerivedStateFromError!="function"?null:n.render();return t.effectTag|=1,e!==null&&o?(t.child=Xi(t,e.child,null,s),t.child=Xi(t,null,a,s)):Pe(e,t,a,s),t.memoizedState=n.state,r&&Bc(t,i,!0),t.child}function ed(e){var t=e.stateNode;t.pendingContext?Vc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Vc(e,t.context,!1),ya(e,t.containerInfo)}var So={dehydrated:null,retryTime:0};function td(e,t,i){var n=t.mode,r=t.pendingProps,s=J.current,o=!1,a;if((a=(t.effectTag&64)!==0)||(a=(s&2)!==0&&(e===null||e.memoizedState!==null)),a?(o=!0,t.effectTag&=-65):e!==null&&e.memoizedState===null||r.fallback===void 0||r.unstable_avoidThisFallback===!0||(s|=1),te(J,s&1),e===null){if(r.fallback!==void 0&&Ca(t),o){if(o=r.fallback,r=Rt(null,n,0,null),r.return=t,(t.mode&2)===0)for(e=t.memoizedState!==null?t.child.child:t.child,r.child=e;e!==null;)e.return=r,e=e.sibling;return i=Rt(o,n,i,null),i.return=t,r.sibling=i,t.memoizedState=So,t.child=r,i}return n=r.children,t.memoizedState=null,t.child=Fl(t,null,n,i)}if(e.memoizedState!==null){if(e=e.child,n=e.sibling,o){if(r=r.fallback,i=xi(e,e.pendingProps),i.return=t,(t.mode&2)===0&&(o=t.memoizedState!==null?t.child.child:t.child,o!==e.child))for(i.child=o;o!==null;)o.return=i,o=o.sibling;return n=xi(n,r),n.return=t,i.sibling=n,i.childExpirationTime=0,t.memoizedState=So,t.child=i,n}return i=Xi(t,e.child,r.children,i),t.memoizedState=null,t.child=i}if(e=e.child,o){if(o=r.fallback,r=Rt(null,n,0,null),r.return=t,r.child=e,e!==null&&(e.return=r),(t.mode&2)===0)for(e=t.memoizedState!==null?t.child.child:t.child,r.child=e;e!==null;)e.return=r,e=e.sibling;return i=Rt(o,n,i,null),i.return=t,r.sibling=i,i.effectTag|=2,r.childExpirationTime=0,t.memoizedState=So,t.child=r,i}return t.memoizedState=null,t.child=Xi(t,e,r.children,i)}function id(e,t){e.expirationTime<t&&(e.expirationTime=t);var i=e.alternate;i!==null&&i.expirationTime<t&&(i.expirationTime=t),df(e.return,t)}function Co(e,t,i,n,r,s){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:i,tailExpiration:0,tailMode:r,lastEffect:s}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=n,o.tail=i,o.tailExpiration=0,o.tailMode=r,o.lastEffect=s)}function nd(e,t,i){var n=t.pendingProps,r=n.revealOrder,s=n.tail;if(Pe(e,t,n.children,i),n=J.current,(n&2)!==0)n=n&1|2,t.effectTag|=64;else{if(e!==null&&(e.effectTag&64)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&id(e,i);else if(e.tag===19)id(e,i);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}n&=1}if(te(J,n),(t.mode&2)===0)t.memoizedState=null;else switch(r){case"forwards":for(i=t.child,r=null;i!==null;)e=i.alternate,e!==null&&hs(e)===null&&(r=i),i=i.sibling;i=r,i===null?(r=t.child,t.child=null):(r=i.sibling,i.sibling=null),Co(t,!1,r,i,s,t.lastEffect);break;case"backwards":for(i=null,r=t.child,t.child=null;r!==null;){if(e=r.alternate,e!==null&&hs(e)===null){t.child=r;break}e=r.sibling,r.sibling=i,i=r,r=e}Co(t,!0,i,null,s,t.lastEffect);break;case"together":Co(t,!1,null,null,void 0,t.lastEffect);break;default:t.memoizedState=null}return t.child}function Mt(e,t,i){e!==null&&(t.dependencies=e.dependencies);var n=t.expirationTime;if(n!==0&&Qs(n),t.childExpirationTime<i)return null;if(e!==null&&t.child!==e.child)throw Error(S(153));if(t.child!==null){for(e=t.child,i=xi(e,e.pendingProps),t.child=i,i.return=t;e.sibling!==null;)e=e.sibling,i=i.sibling=xi(e,e.pendingProps),i.return=t;i.sibling=null}return t.child}var If,ba,bf,Ef;If=function(e,t){for(var i=t.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}};ba=function(){};bf=function(e,t,i,n,r){var s=e.memoizedProps;if(s!==n){var o=t.stateNode;switch(ni(ut.current),e=null,i){case"input":s=Jo(o,s),n=Jo(o,n),e=[];break;case"option":s=ea(o,s),n=ea(o,n),e=[];break;case"select":s=Se({},s,{value:void 0}),n=Se({},n,{value:void 0}),e=[];break;case"textarea":s=ta(o,s),n=ta(o,n),e=[];break;default:typeof s.onClick!="function"&&typeof n.onClick=="function"&&(o.onclick=rs)}aa(i,n);var a,l;i=null;for(a in s)if(!n.hasOwnProperty(a)&&s.hasOwnProperty(a)&&s[a]!=null)if(a==="style")for(l in o=s[a],o)o.hasOwnProperty(l)&&(i||(i={}),i[l]="");else a!=="dangerouslySetInnerHTML"&&a!=="children"&&a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(Qi.hasOwnProperty(a)?e||(e=[]):(e=e||[]).push(a,null));for(a in n){var u=n[a];if(o=s!=null?s[a]:void 0,n.hasOwnProperty(a)&&u!==o&&(u!=null||o!=null))if(a==="style")if(o){for(l in o)!o.hasOwnProperty(l)||u&&u.hasOwnProperty(l)||(i||(i={}),i[l]="");for(l in u)u.hasOwnProperty(l)&&o[l]!==u[l]&&(i||(i={}),i[l]=u[l])}else i||(e||(e=[]),e.push(a,i)),i=u;else a==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,o=o?o.__html:void 0,u!=null&&o!==u&&(e=e||[]).push(a,u)):a==="children"?o===u||typeof u!="string"&&typeof u!="number"||(e=e||[]).push(a,""+u):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&(Qi.hasOwnProperty(a)?(u!=null&&mt(r,a),e||o===u||(e=[])):(e=e||[]).push(a,u))}i&&(e=e||[]).push("style",i),r=e,(t.updateQueue=r)&&(t.effectTag|=4)}};Ef=function(e,t,i,n){i!==n&&(t.effectTag|=4)};function Er(e,t){switch(e.tailMode){case"hidden":t=e.tail;for(var i=null;t!==null;)t.alternate!==null&&(i=t),t=t.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var n=null;i!==null;)i.alternate!==null&&(n=i),i=i.sibling;n===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:n.sibling=null}}function jx(e,t,i){var n=t.pendingProps;switch(t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return Ie(t.type)&&as(),null;case 3:return Ji(),G(Me),G(ve),i=t.stateNode,i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),e!==null&&e.child!==null||!br(t)||(t.effectTag|=4),ba(t),null;case 5:Ql(t),i=ni(Fn.current);var r=t.type;if(e!==null&&t.stateNode!=null)bf(e,t,r,n,i),e.ref!==t.ref&&(t.effectTag|=128);else{if(!n){if(t.stateNode===null)throw Error(S(166));return null}if(e=ni(ut.current),br(t)){n=t.stateNode,r=t.type;var s=t.memoizedProps;switch(n[zt]=t,n[ss]=s,r){case"iframe":case"object":case"embed":X("load",n);break;case"video":case"audio":for(e=0;e<wn.length;e++)X(wn[e],n);break;case"source":X("error",n);break;case"img":case"image":case"link":X("error",n),X("load",n);break;case"form":X("reset",n),X("submit",n);break;case"details":X("toggle",n);break;case"input":fc(n,s),X("invalid",n),mt(i,"onChange");break;case"select":n._wrapperState={wasMultiple:!!s.multiple},X("invalid",n),mt(i,"onChange");break;case"textarea":mc(n,s),X("invalid",n),mt(i,"onChange")}aa(r,s),e=null;for(var o in s)if(s.hasOwnProperty(o)){var a=s[o];o==="children"?typeof a=="string"?n.textContent!==a&&(e=["children",a]):typeof a=="number"&&n.textContent!==""+a&&(e=["children",""+a]):Qi.hasOwnProperty(o)&&a!=null&&mt(i,o)}switch(r){case"input":wr(n),gc(n,s,!0);break;case"textarea":wr(n),vc(n);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(n.onclick=rs)}i=e,t.updateQueue=i,i!==null&&(t.effectTag|=4)}else{switch(o=i.nodeType===9?i:i.ownerDocument,e===Mc&&(e=wp(r)),e===Mc?r==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof n.is=="string"?e=o.createElement(r,{is:n.is}):(e=o.createElement(r),r==="select"&&(o=e,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):e=o.createElementNS(e,r),e[zt]=t,e[ss]=n,If(e,t,!1,!1),t.stateNode=e,o=la(r,n),r){case"iframe":case"object":case"embed":X("load",e),a=n;break;case"video":case"audio":for(a=0;a<wn.length;a++)X(wn[a],e);a=n;break;case"source":X("error",e),a=n;break;case"img":case"image":case"link":X("error",e),X("load",e),a=n;break;case"form":X("reset",e),X("submit",e),a=n;break;case"details":X("toggle",e),a=n;break;case"input":fc(e,n),a=Jo(e,n),X("invalid",e),mt(i,"onChange");break;case"option":a=ea(e,n);break;case"select":e._wrapperState={wasMultiple:!!n.multiple},a=Se({},n,{value:void 0}),X("invalid",e),mt(i,"onChange");break;case"textarea":mc(e,n),a=ta(e,n),X("invalid",e),mt(i,"onChange");break;default:a=n}aa(r,a);var l=a;for(s in l)if(l.hasOwnProperty(s)){var u=l[s];s==="style"?Vp(e,u):s==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&yp(e,u)):s==="children"?typeof u=="string"?(r!=="textarea"||u!=="")&&Bn(e,u):typeof u=="number"&&Bn(e,""+u):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Qi.hasOwnProperty(s)?u!=null&&mt(i,s):u!=null&&Cl(e,s,u,o))}switch(r){case"input":wr(e),gc(e,n,!1);break;case"textarea":wr(e),vc(e);break;case"option":n.value!=null&&e.setAttribute("value",""+Zt(n.value));break;case"select":e.multiple=!!n.multiple,i=n.value,i!=null?Oi(e,!!n.multiple,i,!1):n.defaultValue!=null&&Oi(e,!!n.multiple,n.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=rs)}Up(r,n)&&(t.effectTag|=4)}t.ref!==null&&(t.effectTag|=128)}return null;case 6:if(e&&t.stateNode!=null)Ef(e,t,e.memoizedProps,n);else{if(typeof n!="string"&&t.stateNode===null)throw Error(S(166));i=ni(Fn.current),ni(ut.current),br(t)?(i=t.stateNode,n=t.memoizedProps,i[zt]=t,i.nodeValue!==n&&(t.effectTag|=4)):(i=(i.nodeType===9?i:i.ownerDocument).createTextNode(n),i[zt]=t,t.stateNode=i)}return null;case 13:return G(J),n=t.memoizedState,(t.effectTag&64)!==0?(t.expirationTime=i,t):(i=n!==null,n=!1,e===null?t.memoizedProps.fallback!==void 0&&br(t):(r=e.memoizedState,n=r!==null,i||r===null||(r=e.child.sibling,r!==null&&(s=t.firstEffect,s!==null?(t.firstEffect=r,r.nextEffect=s):(t.firstEffect=t.lastEffect=r,r.nextEffect=null),r.effectTag=8))),i&&!n&&(t.mode&2)!==0&&(e===null&&t.memoizedProps.unstable_avoidThisFallback!==!0||(J.current&1)!==0?se===hi&&(se=ys):((se===hi||se===ys)&&(se=Ws),Zn!==0&&Ve!==null&&(oi(Ve,Ee),Qf(Ve,Zn)))),(i||n)&&(t.effectTag|=4),null);case 4:return Ji(),ba(t),null;case 10:return $l(t),null;case 17:return Ie(t.type)&&as(),null;case 19:if(G(J),n=t.memoizedState,n===null)return null;if(r=(t.effectTag&64)!==0,s=n.rendering,s===null){if(r)Er(n,!1);else if(se!==hi||e!==null&&(e.effectTag&64)!==0)for(s=t.child;s!==null;){if(e=hs(s),e!==null){for(t.effectTag|=64,Er(n,!1),r=e.updateQueue,r!==null&&(t.updateQueue=r,t.effectTag|=4),n.lastEffect===null&&(t.firstEffect=null),t.lastEffect=n.lastEffect,n=t.child;n!==null;)r=n,s=i,r.effectTag&=2,r.nextEffect=null,r.firstEffect=null,r.lastEffect=null,e=r.alternate,e===null?(r.childExpirationTime=0,r.expirationTime=s,r.child=null,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null):(r.childExpirationTime=e.childExpirationTime,r.expirationTime=e.expirationTime,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,s=e.dependencies,r.dependencies=s===null?null:{expirationTime:s.expirationTime,firstContext:s.firstContext,responders:s.responders}),n=n.sibling;return te(J,J.current&1|2),t.child}s=s.sibling}}else{if(!r)if(e=hs(s),e!==null){if(t.effectTag|=64,r=!0,i=e.updateQueue,i!==null&&(t.updateQueue=i,t.effectTag|=4),Er(n,!0),n.tail===null&&n.tailMode==="hidden"&&!s.alternate)return t=t.lastEffect=n.lastEffect,t!==null&&(t.nextEffect=null),null}else 2*We()-n.renderingStartTime>n.tailExpiration&&1<i&&(t.effectTag|=64,r=!0,Er(n,!1),t.expirationTime=t.childExpirationTime=i-1);n.isBackwards?(s.sibling=t.child,t.child=s):(i=n.last,i!==null?i.sibling=s:t.child=s,n.last=s)}return n.tail!==null?(n.tailExpiration===0&&(n.tailExpiration=We()+500),i=n.tail,n.rendering=i,n.tail=i.sibling,n.lastEffect=t.lastEffect,n.renderingStartTime=We(),i.sibling=null,t=J.current,te(J,r?t&1|2:t&1),i):null}throw Error(S(156,t.tag))}function Rx(e){switch(e.tag){case 1:Ie(e.type)&&as();var t=e.effectTag;return t&4096?(e.effectTag=t&-4097|64,e):null;case 3:if(Ji(),G(Me),G(ve),t=e.effectTag,(t&64)!==0)throw Error(S(285));return e.effectTag=t&-4097|64,e;case 5:return Ql(e),null;case 13:return G(J),t=e.effectTag,t&4096?(e.effectTag=t&-4097|64,e):null;case 19:return G(J),null;case 4:return Ji(),null;case 10:return $l(e),null;default:return null}}function ql(e,t){return{value:e,source:t,stack:bl(t)}}var Vx=typeof WeakSet=="function"?WeakSet:Set;function Ea(e,t){var i=t.source,n=t.stack;n===null&&i!==null&&(n=bl(i)),i!==null&&It(i.type),t=t.value,e!==null&&e.tag===1&&It(e.type);try{console.error(t)}catch(r){setTimeout(function(){throw r})}}function Bx(e,t){try{t.props=e.memoizedProps,t.state=e.memoizedState,t.componentWillUnmount()}catch(i){fi(e,i)}}function rd(e){var t=e.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(i){fi(e,i)}else t.current=null}function Ox(e,t){switch(t.tag){case 0:case 11:case 15:case 22:return;case 1:if(t.effectTag&256&&e!==null){var i=e.memoizedProps,n=e.memoizedState;e=t.stateNode,t=e.getSnapshotBeforeUpdate(t.elementType===t.type?i:Je(t.type,i),n),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:case 5:case 6:case 4:case 17:return}throw Error(S(163))}function Af(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var i=t=t.next;do{if((i.tag&e)===e){var n=i.destroy;i.destroy=void 0,n!==void 0&&n()}i=i.next}while(i!==t)}}function Tf(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var i=t=t.next;do{if((i.tag&e)===e){var n=i.create;i.destroy=n()}i=i.next}while(i!==t)}}function _x(e,t,i){switch(i.tag){case 0:case 11:case 15:case 22:Tf(3,i);return;case 1:if(e=i.stateNode,i.effectTag&4)if(t===null)e.componentDidMount();else{var n=i.elementType===i.type?t.memoizedProps:Je(i.type,t.memoizedProps);e.componentDidUpdate(n,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate)}t=i.updateQueue,t!==null&&Wc(i,t,e);return;case 3:if(t=i.updateQueue,t!==null){if(e=null,i.child!==null)switch(i.child.tag){case 5:e=i.child.stateNode;break;case 1:e=i.child.stateNode}Wc(i,t,e)}return;case 5:e=i.stateNode,t===null&&i.effectTag&4&&Up(i.type,i.memoizedProps)&&e.focus();return;case 6:return;case 4:return;case 12:return;case 13:i.memoizedState===null&&(i=i.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&Dp(i))));return;case 19:case 17:case 20:case 21:return}throw Error(S(163))}function sd(e,t,i){switch(typeof La=="function"&&La(t),t.tag){case 0:case 11:case 14:case 15:case 22:if(e=t.updateQueue,e!==null&&(e=e.lastEffect,e!==null)){var n=e.next;Yt(97<i?97:i,function(){var r=n;do{var s=r.destroy;if(s!==void 0){var o=t;try{s()}catch(a){fi(o,a)}}r=r.next}while(r!==n)})}break;case 1:rd(t),i=t.stateNode,typeof i.componentWillUnmount=="function"&&Bx(t,i);break;case 5:rd(t);break;case 4:kf(e,t,i)}}function Nf(e){var t=e.alternate;e.return=null,e.child=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.alternate=null,e.firstEffect=null,e.lastEffect=null,e.pendingProps=null,e.memoizedProps=null,e.stateNode=null,t!==null&&Nf(t)}function od(e){return e.tag===5||e.tag===3||e.tag===4}function ad(e){e:{for(var t=e.return;t!==null;){if(od(t)){var i=t;break e}t=t.return}throw Error(S(160))}switch(t=i.stateNode,i.tag){case 5:var n=!1;break;case 3:t=t.containerInfo,n=!0;break;case 4:t=t.containerInfo,n=!0;break;default:throw Error(S(161))}i.effectTag&16&&(Bn(t,""),i.effectTag&=-17);e:t:for(i=e;;){for(;i.sibling===null;){if(i.return===null||od(i.return)){i=null;break e}i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.effectTag&2||i.child===null||i.tag===4)continue t;i.child.return=i,i=i.child}if(!(i.effectTag&2)){i=i.stateNode;break e}}n?Aa(e,i,t):Ta(e,i,t)}function Aa(e,t,i){var n=e.tag,r=n===5||n===6;if(r)e=r?e.stateNode:e.stateNode.instance,t?i.nodeType===8?i.parentNode.insertBefore(e,t):i.insertBefore(e,t):(i.nodeType===8?(t=i.parentNode,t.insertBefore(e,i)):(t=i,t.appendChild(e)),i=i._reactRootContainer,i!=null||t.onclick!==null||(t.onclick=rs));else if(n!==4&&(e=e.child,e!==null))for(Aa(e,t,i),e=e.sibling;e!==null;)Aa(e,t,i),e=e.sibling}function Ta(e,t,i){var n=e.tag,r=n===5||n===6;if(r)e=r?e.stateNode:e.stateNode.instance,t?i.insertBefore(e,t):i.appendChild(e);else if(n!==4&&(e=e.child,e!==null))for(Ta(e,t,i),e=e.sibling;e!==null;)Ta(e,t,i),e=e.sibling}function kf(e,t,i){for(var n=t,r=!1,s,o;;){if(!r){r=n.return;e:for(;;){if(r===null)throw Error(S(160));switch(s=r.stateNode,r.tag){case 5:o=!1;break e;case 3:s=s.containerInfo,o=!0;break e;case 4:s=s.containerInfo,o=!0;break e}r=r.return}r=!0}if(n.tag===5||n.tag===6){e:for(var a=e,l=n,u=i,c=l;;)if(sd(a,c,u),c.child!==null&&c.tag!==4)c.child.return=c,c=c.child;else{if(c===l)break e;for(;c.sibling===null;){if(c.return===null||c.return===l)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}o?(a=s,l=n.stateNode,a.nodeType===8?a.parentNode.removeChild(l):a.removeChild(l)):s.removeChild(n.stateNode)}else if(n.tag===4){if(n.child!==null){s=n.stateNode.containerInfo,o=!0,n.child.return=n,n=n.child;continue}}else if(sd(e,n,i),n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return,n.tag===4&&(r=!1)}n.sibling.return=n.return,n=n.sibling}}function Mo(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:Af(3,t);return;case 1:return;case 5:var i=t.stateNode;if(i!=null){var n=t.memoizedProps,r=e!==null?e.memoizedProps:n;e=t.type;var s=t.updateQueue;if(t.updateQueue=null,s!==null){for(i[ss]=n,e==="input"&&n.type==="radio"&&n.name!=null&&gp(i,n),la(e,r),t=la(e,n),r=0;r<s.length;r+=2){var o=s[r],a=s[r+1];o==="style"?Vp(i,a):o==="dangerouslySetInnerHTML"?yp(i,a):o==="children"?Bn(i,a):Cl(i,o,a,t)}switch(e){case"input":Ko(i,n);break;case"textarea":mp(i,n);break;case"select":t=i._wrapperState.wasMultiple,i._wrapperState.wasMultiple=!!n.multiple,e=n.value,e!=null?Oi(i,!!n.multiple,e,!1):t!==!!n.multiple&&(n.defaultValue!=null?Oi(i,!!n.multiple,n.defaultValue,!0):Oi(i,!!n.multiple,n.multiple?[]:"",!1))}}}return;case 6:if(t.stateNode===null)throw Error(S(162));t.stateNode.nodeValue=t.memoizedProps;return;case 3:t=t.stateNode,t.hydrate&&(t.hydrate=!1,Dp(t.containerInfo));return;case 12:return;case 13:if(i=t,t.memoizedState===null?n=!1:(n=!0,i=t.child,iu=We()),i!==null)e:for(e=i;;){if(e.tag===5)s=e.stateNode,n?(s=s.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(s=e.stateNode,r=e.memoizedProps.style,r=r!=null&&r.hasOwnProperty("display")?r.display:null,s.style.display=Rp("display",r));else if(e.tag===6)e.stateNode.nodeValue=n?"":e.memoizedProps;else if(e.tag===13&&e.memoizedState!==null&&e.memoizedState.dehydrated===null){s=e.child.sibling,s.return=e,e=s;continue}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===i)break;for(;e.sibling===null;){if(e.return===null||e.return===i)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}ld(t);return;case 19:ld(t);return;case 17:return}throw Error(S(163))}function ld(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Vx),t.forEach(function(n){var r=Xx.bind(null,e,n);i.has(n)||(i.add(n),n.then(r,r))})}}var Ux=typeof WeakMap=="function"?WeakMap:Map;function Pf(e,t,i){i=$t(i,null),i.tag=3,i.payload={element:null};var n=t.value;return i.callback=function(){Cs||(Cs=!0,Na=n),Ea(e,t)},i}function zf(e,t,i){i=$t(i,null),i.tag=3;var n=e.type.getDerivedStateFromError;if(typeof n=="function"){var r=t.value;i.payload=function(){return Ea(e,t),n(r)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(i.callback=function(){typeof n!="function"&&(Ht===null?Ht=new Set([this]):Ht.add(this),Ea(e,t));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),i}var $x=Math.ceil,vs=Ke.ReactCurrentDispatcher,Df=Ke.ReactCurrentOwner,oe=0,eu=8,qe=16,dt=32,hi=0,ws=1,Lf=2,ys=3,Ws=4,tu=5,j=oe,Ve=null,V=null,Ee=0,se=hi,Hs=null,St=1073741823,Qn=1073741823,xs=null,Zn=0,Ss=!1,iu=0,jf=500,T=null,Cs=!1,Na=null,Ht=null,Ms=!1,Dn=null,xn=90,ri=null,Ln=0,ka=null,Fr=0;function ct(){return(j&(qe|dt))!==oe?1073741821-(We()/10|0):Fr!==0?Fr:Fr=1073741821-(We()/10|0)}function pi(e,t,i){if(t=t.mode,(t&2)===0)return 1073741823;var n=Us();if((t&4)===0)return n===99?1073741823:1073741822;if((j&qe)!==oe)return Ee;if(i!==null)e=Wr(e,i.timeoutMs|0||5e3,250);else switch(n){case 99:e=1073741823;break;case 98:e=Wr(e,150,100);break;case 97:case 96:e=Wr(e,5e3,250);break;case 95:e=2;break;default:throw Error(S(326))}return Ve!==null&&e===Ee&&--e,e}function Ft(e,t){if(50<Ln)throw Ln=0,ka=null,Error(S(185));if(e=Fs(e,t),e!==null){var i=Us();t===1073741823?(j&eu)!==oe&&(j&(qe|dt))===oe?Pa(e):(Be(e),j===oe&&ht()):Be(e),(j&4)===oe||i!==98&&i!==99||(ri===null?ri=new Map([[e,t]]):(i=ri.get(e),(i===void 0||i>t)&&ri.set(e,t)))}}function Fs(e,t){e.expirationTime<t&&(e.expirationTime=t);var i=e.alternate;i!==null&&i.expirationTime<t&&(i.expirationTime=t);var n=e.return,r=null;if(n===null&&e.tag===3)r=e.stateNode;else for(;n!==null;){if(i=n.alternate,n.childExpirationTime<t&&(n.childExpirationTime=t),i!==null&&i.childExpirationTime<t&&(i.childExpirationTime=t),n.return===null&&n.tag===3){r=n.stateNode;break}n=n.return}return r!==null&&(Ve===r&&(Qs(t),se===Ws&&oi(r,Ee)),Qf(r,t)),r}function Qr(e){var t=e.lastExpiredTime;if(t!==0||(t=e.firstPendingTime,!Ff(e,t)))return t;var i=e.lastPingedTime;return e=e.nextKnownPendingLevel,e=i>e?i:e,2>=e&&t!==e?0:e}function Be(e){if(e.lastExpiredTime!==0)e.callbackExpirationTime=1073741823,e.callbackPriority=99,e.callbackNode=Uc(Pa.bind(null,e));else{var t=Qr(e),i=e.callbackNode;if(t===0)i!==null&&(e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90);else{var n=ct();if(t===1073741823?n=99:t===1||t===2?n=95:(n=10*(1073741821-t)-10*(1073741821-n),n=0>=n?99:250>=n?98:5250>=n?97:95),i!==null){var r=e.callbackPriority;if(e.callbackExpirationTime===t&&r>=n)return;i!==af&&tf(i)}e.callbackExpirationTime=t,e.callbackPriority=n,t=t===1073741823?Uc(Pa.bind(null,e)):uf(n,Rf.bind(null,e),{timeout:10*(1073741821-t)-We()}),e.callbackNode=t}}}function Rf(e,t){if(Fr=0,t)return t=ct(),ja(e,t),Be(e),null;var i=Qr(e);if(i!==0){if(t=e.callbackNode,(j&(qe|dt))!==oe)throw Error(S(327));if(tn(),e===Ve&&i===Ee||si(e,i),V!==null){var n=j;j|=qe;var r=_f();do try{Fx();break}catch(a){Of(e,a)}while(1);if(Ul(),j=n,vs.current=r,se===ws)throw t=Hs,si(e,i),oi(e,i),Be(e),t;if(V===null)switch(r=e.finishedWork=e.current.alternate,e.finishedExpirationTime=i,n=se,Ve=null,n){case hi:case ws:throw Error(S(345));case Lf:ja(e,2<i?2:i);break;case ys:if(oi(e,i),n=e.lastSuspendedTime,i===n&&(e.nextKnownPendingLevel=za(r)),St===1073741823&&(r=iu+jf-We(),10<r)){if(Ss){var s=e.lastPingedTime;if(s===0||s>=i){e.lastPingedTime=i,si(e,i);break}}if(s=Qr(e),s!==0&&s!==i)break;if(n!==0&&n!==i){e.lastPingedTime=n;break}e.timeoutHandle=vo(ei.bind(null,e),r);break}ei(e);break;case Ws:if(oi(e,i),n=e.lastSuspendedTime,i===n&&(e.nextKnownPendingLevel=za(r)),Ss&&(r=e.lastPingedTime,r===0||r>=i)){e.lastPingedTime=i,si(e,i);break}if(r=Qr(e),r!==0&&r!==i)break;if(n!==0&&n!==i){e.lastPingedTime=n;break}if(Qn!==1073741823?n=10*(1073741821-Qn)-We():St===1073741823?n=0:(n=10*(1073741821-St)-5e3,r=We(),i=10*(1073741821-i)-r,n=r-n,0>n&&(n=0),n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*$x(n/1960))-n,i<n&&(n=i)),10<n){e.timeoutHandle=vo(ei.bind(null,e),n);break}ei(e);break;case tu:if(St!==1073741823&&xs!==null){s=St;var o=xs;if(n=o.busyMinDurationMs|0,0>=n?n=0:(r=o.busyDelayMs|0,s=We()-(10*(1073741821-s)-(o.timeoutMs|0||5e3)),n=s<=r?0:r+n-s),10<n){oi(e,i),e.timeoutHandle=vo(ei.bind(null,e),n);break}}ei(e);break;default:throw Error(S(329))}if(Be(e),e.callbackNode===t)return Rf.bind(null,e)}}return null}function Pa(e){var t=e.lastExpiredTime;if(t=t!==0?t:1073741823,(j&(qe|dt))!==oe)throw Error(S(327));if(tn(),e===Ve&&t===Ee||si(e,t),V!==null){var i=j;j|=qe;var n=_f();do try{Hx();break}catch(r){Of(e,r)}while(1);if(Ul(),j=i,vs.current=n,se===ws)throw i=Hs,si(e,t),oi(e,t),Be(e),i;if(V!==null)throw Error(S(261));e.finishedWork=e.current.alternate,e.finishedExpirationTime=t,Ve=null,ei(e),Be(e)}return null}function Wx(){if(ri!==null){var e=ri;ri=null,e.forEach(function(t,i){ja(i,t),Be(i)}),ht()}}function Vf(e,t){var i=j;j|=1;try{return e(t)}finally{j=i,j===oe&&ht()}}function Bf(e,t){var i=j;j&=-2,j|=eu;try{return e(t)}finally{j=i,j===oe&&ht()}}function si(e,t){e.finishedWork=null,e.finishedExpirationTime=0;var i=e.timeoutHandle;if(i!==-1&&(e.timeoutHandle=-1,$0(i)),V!==null)for(i=V.return;i!==null;){var n=i;switch(n.tag){case 1:n=n.type.childContextTypes,n!=null&&as();break;case 3:Ji(),G(Me),G(ve);break;case 5:Ql(n);break;case 4:Ji();break;case 13:G(J);break;case 19:G(J);break;case 10:$l(n)}i=i.return}Ve=e,V=xi(e.current,null),Ee=t,se=hi,Hs=null,Qn=St=1073741823,xs=null,Zn=0,Ss=!1}function Of(e,t){do{try{if(Ul(),Hr.current=ms,ps)for(var i=ne.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}if(Lt=0,ge=fe=ne=null,ps=!1,V===null||V.return===null)return se=ws,Hs=t,V=null;e:{var r=e,s=V.return,o=V,a=t;if(t=Ee,o.effectTag|=2048,o.firstEffect=o.lastEffect=null,a!==null&&typeof a=="object"&&typeof a.then=="function"){var l=a;if((o.mode&2)===0){var u=o.alternate;u?(o.updateQueue=u.updateQueue,o.memoizedState=u.memoizedState,o.expirationTime=u.expirationTime):(o.updateQueue=null,o.memoizedState=null)}var c=(J.current&1)!==0,d=s;do{var m;if(m=d.tag===13){var w=d.memoizedState;if(w!==null)m=w.dehydrated!==null;else{var y=d.memoizedProps;m=y.fallback===void 0?!1:y.unstable_avoidThisFallback!==!0?!0:!c}}if(m){var M=d.updateQueue;if(M===null){var p=new Set;p.add(l),d.updateQueue=p}else M.add(l);if((d.mode&2)===0){if(d.effectTag|=64,o.effectTag&=-2981,o.tag===1)if(o.alternate===null)o.tag=17;else{var h=$t(1073741823,null);h.tag=2,Wt(o,h)}o.expirationTime=1073741823;break e}a=void 0,o=t;var f=r.pingCache;if(f===null?(f=r.pingCache=new Ux,a=new Set,f.set(l,a)):(a=f.get(l),a===void 0&&(a=new Set,f.set(l,a))),!a.has(o)){a.add(o);var g=Yx.bind(null,r,l,o);l.then(g,g)}d.effectTag|=4096,d.expirationTime=t;break e}d=d.return}while(d!==null);a=Error((It(o.type)||"A React component")+` suspended while rendering, but no fallback UI was specified.
44
44
 
45
45
  Add a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.`+bl(o))}se!==tu&&(se=Lf),a=ql(a,o),d=s;do{switch(d.tag){case 3:l=a,d.effectTag|=4096,d.expirationTime=t;var v=Pf(d,l,t);$c(d,v);break e;case 1:l=a;var C=d.type,x=d.stateNode;if((d.effectTag&64)===0&&(typeof C.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Ht===null||!Ht.has(x)))){d.effectTag|=4096,d.expirationTime=t;var N=zf(d,l,t);$c(d,N);break e}}d=d.return}while(d!==null)}V=Wf(V)}catch(z){t=z;continue}break}while(1)}function _f(){var e=vs.current;return vs.current=ms,e===null?ms:e}function Uf(e,t){e<St&&2<e&&(St=e),t!==null&&e<Qn&&2<e&&(Qn=e,xs=t)}function Qs(e){e>Zn&&(Zn=e)}function Hx(){for(;V!==null;)V=$f(V)}function Fx(){for(;V!==null&&!Nx();)V=$f(V)}function $f(e){var t=Hf(e.alternate,e,Ee);return e.memoizedProps=e.pendingProps,t===null&&(t=Wf(e)),Df.current=null,t}function Wf(e){V=e;do{var t=V.alternate;if(e=V.return,(V.effectTag&2048)===0){if(t=jx(t,V,Ee),Ee===1||V.childExpirationTime!==1){for(var i=0,n=V.child;n!==null;){var r=n.expirationTime,s=n.childExpirationTime;r>i&&(i=r),s>i&&(i=s),n=n.sibling}V.childExpirationTime=i}if(t!==null)return t;e!==null&&(e.effectTag&2048)===0&&(e.firstEffect===null&&(e.firstEffect=V.firstEffect),V.lastEffect!==null&&(e.lastEffect!==null&&(e.lastEffect.nextEffect=V.firstEffect),e.lastEffect=V.lastEffect),1<V.effectTag&&(e.lastEffect!==null?e.lastEffect.nextEffect=V:e.firstEffect=V,e.lastEffect=V))}else{if(t=Rx(V),t!==null)return t.effectTag&=2047,t;e!==null&&(e.firstEffect=e.lastEffect=null,e.effectTag|=2048)}if(t=V.sibling,t!==null)return t;V=e}while(V!==null);return se===hi&&(se=tu),null}function za(e){var t=e.expirationTime;return e=e.childExpirationTime,t>e?t:e}function ei(e){var t=Us();return Yt(99,Qx.bind(null,e,t)),null}function Qx(e,t){do tn();while(Dn!==null);if((j&(qe|dt))!==oe)throw Error(S(327));var i=e.finishedWork,n=e.finishedExpirationTime;if(i===null)return null;if(e.finishedWork=null,e.finishedExpirationTime=0,i===e.current)throw Error(S(177));e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90,e.nextKnownPendingLevel=0;var r=za(i);if(e.firstPendingTime=r,n<=e.lastSuspendedTime?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:n<=e.firstSuspendedTime&&(e.firstSuspendedTime=n-1),n<=e.lastPingedTime&&(e.lastPingedTime=0),n<=e.lastExpiredTime&&(e.lastExpiredTime=0),e===Ve&&(V=Ve=null,Ee=0),1<i.effectTag?i.lastEffect!==null?(i.lastEffect.nextEffect=i,r=i.firstEffect):r=i:r=i.firstEffect,r!==null){var s=j;j|=dt,Df.current=null,go=Vr;var o=Ec();if(ca(o)){if("selectionStart"in o)var a={start:o.selectionStart,end:o.selectionEnd};else e:{a=(a=o.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,c=l.focusNode;l=l.focusOffset;try{a.nodeType,c.nodeType}catch{a=null;break e}var d=0,m=-1,w=-1,y=0,M=0,p=o,h=null;t:for(;;){for(var f;p!==a||u!==0&&p.nodeType!==3||(m=d+u),p!==c||l!==0&&p.nodeType!==3||(w=d+l),p.nodeType===3&&(d+=p.nodeValue.length),(f=p.firstChild)!==null;)h=p,p=f;for(;;){if(p===o)break t;if(h===a&&++y===u&&(m=d),h===c&&++M===l&&(w=d),(f=p.nextSibling)!==null)break;p=h,h=p.parentNode}p=f}a=m===-1||w===-1?null:{start:m,end:w}}else a=null}a=a||{start:0,end:0}}else a=null;mo={activeElementDetached:null,focusedElem:o,selectionRange:a},Vr=!1,T=r;do try{Zx()}catch(k){if(T===null)throw Error(S(330));fi(T,k),T=T.nextEffect}while(T!==null);T=r;do try{for(o=e,a=t;T!==null;){var g=T.effectTag;if(g&16&&Bn(T.stateNode,""),g&128){var v=T.alternate;if(v!==null){var C=v.ref;C!==null&&(typeof C=="function"?C(null):C.current=null)}}switch(g&1038){case 2:ad(T),T.effectTag&=-3;break;case 6:ad(T),T.effectTag&=-3,Mo(T.alternate,T);break;case 1024:T.effectTag&=-1025;break;case 1028:T.effectTag&=-1025,Mo(T.alternate,T);break;case 4:Mo(T.alternate,T);break;case 8:u=T,kf(o,u,a),Nf(u)}T=T.nextEffect}}catch(k){if(T===null)throw Error(S(330));fi(T,k),T=T.nextEffect}while(T!==null);if(C=mo,v=Ec(),g=C.focusedElem,a=C.selectionRange,v!==g&&g&&g.ownerDocument&&Bp(g.ownerDocument.documentElement,g)){for(a!==null&&ca(g)&&(v=a.start,C=a.end,C===void 0&&(C=v),"selectionStart"in g?(g.selectionStart=v,g.selectionEnd=Math.min(C,g.value.length)):(C=(v=g.ownerDocument||document)&&v.defaultView||window,C.getSelection&&(C=C.getSelection(),u=g.textContent.length,o=Math.min(a.start,u),a=a.end===void 0?o:Math.min(a.end,u),!C.extend&&o>a&&(u=a,a=o,o=u),u=bc(g,o),c=bc(g,a),u&&c&&(C.rangeCount!==1||C.anchorNode!==u.node||C.anchorOffset!==u.offset||C.focusNode!==c.node||C.focusOffset!==c.offset)&&(v=v.createRange(),v.setStart(u.node,u.offset),C.removeAllRanges(),o>a?(C.addRange(v),C.extend(c.node,c.offset)):(v.setEnd(c.node,c.offset),C.addRange(v)))))),v=[],C=g;C=C.parentNode;)C.nodeType===1&&v.push({element:C,left:C.scrollLeft,top:C.scrollTop});for(typeof g.focus=="function"&&g.focus(),g=0;g<v.length;g++)C=v[g],C.element.scrollLeft=C.left,C.element.scrollTop=C.top}Vr=!!go,mo=go=null,e.current=i,T=r;do try{for(g=e;T!==null;){var x=T.effectTag;if(x&36&&_x(g,T.alternate,T),x&128){v=void 0;var N=T.ref;if(N!==null){var z=T.stateNode;switch(T.tag){case 5:v=z;break;default:v=z}typeof N=="function"?N(v):N.current=v}}T=T.nextEffect}}catch(k){if(T===null)throw Error(S(330));fi(T,k),T=T.nextEffect}while(T!==null);T=null,kx(),j=s}else e.current=i;if(Ms)Ms=!1,Dn=e,xn=t;else for(T=r;T!==null;)t=T.nextEffect,T.nextEffect=null,T=t;if(t=e.firstPendingTime,t===0&&(Ht=null),t===1073741823?e===ka?Ln++:(Ln=0,ka=e):Ln=0,typeof Da=="function"&&Da(i.stateNode,n),Be(e),Cs)throw Cs=!1,e=Na,Na=null,e;return(j&eu)!==oe||ht(),null}function Zx(){for(;T!==null;){var e=T.effectTag;(e&256)!==0&&Ox(T.alternate,T),(e&512)===0||Ms||(Ms=!0,uf(97,function(){return tn(),null})),T=T.nextEffect}}function tn(){if(xn!==90){var e=97<xn?97:xn;return xn=90,Yt(e,Gx)}}function Gx(){if(Dn===null)return!1;var e=Dn;if(Dn=null,(j&(qe|dt))!==oe)throw Error(S(331));var t=j;for(j|=dt,e=e.current.firstEffect;e!==null;){try{var i=e;if((i.effectTag&512)!==0)switch(i.tag){case 0:case 11:case 15:case 22:Af(5,i),Tf(5,i)}}catch(n){if(e===null)throw Error(S(330));fi(e,n)}i=e.nextEffect,e.nextEffect=null,e=i}return j=t,ht(),!0}function ud(e,t,i){t=ql(i,t),t=Pf(e,t,1073741823),Wt(e,t),e=Fs(e,1073741823),e!==null&&Be(e)}function fi(e,t){if(e.tag===3)ud(e,e,t);else for(var i=e.return;i!==null;){if(i.tag===3){ud(i,e,t);break}else if(i.tag===1){var n=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Ht===null||!Ht.has(n))){e=ql(t,e),e=zf(i,e,1073741823),Wt(i,e),i=Fs(i,1073741823),i!==null&&Be(i);break}}i=i.return}}function Yx(e,t,i){var n=e.pingCache;n!==null&&n.delete(t),Ve===e&&Ee===i?se===Ws||se===ys&&St===1073741823&&We()-iu<jf?si(e,Ee):Ss=!0:Ff(e,i)&&(t=e.lastPingedTime,t!==0&&t<i||(e.lastPingedTime=i,Be(e)))}function Xx(e,t){var i=e.stateNode;i!==null&&i.delete(t),t=0,t===0&&(t=ct(),t=pi(t,e,null)),e=Fs(e,t),e!==null&&Be(e)}var Hf;Hf=function(e,t,i){var n=t.expirationTime;if(e!==null){var r=t.pendingProps;if(e.memoizedProps!==r||Me.current)at=!0;else{if(n<i){switch(at=!1,t.tag){case 3:ed(t),xo();break;case 5:if(Qc(t),t.mode&4&&i!==1&&r.hidden)return t.expirationTime=t.childExpirationTime=1,null;break;case 1:Ie(t.type)&&Ur(t);break;case 4:ya(t,t.stateNode.containerInfo);break;case 10:n=t.memoizedProps.value,r=t.type._context,te(ls,r._currentValue),r._currentValue=n;break;case 13:if(t.memoizedState!==null)return n=t.child.childExpirationTime,n!==0&&n>=i?td(e,t,i):(te(J,J.current&1),t=Mt(e,t,i),t!==null?t.sibling:null);te(J,J.current&1);break;case 19:if(n=t.childExpirationTime>=i,(e.effectTag&64)!==0){if(n)return nd(e,t,i);t.effectTag|=64}if(r=t.memoizedState,r!==null&&(r.rendering=null,r.tail=null),te(J,J.current),!n)return null}return Mt(e,t,i)}at=!1}}else at=!1;switch(t.expirationTime=0,t.tag){case 2:if(n=t.type,e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,r=Yi(t,ve.current),Ui(t,i),r=Yl(null,t,n,e,r,i),t.effectTag|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ie(n)){var s=!0;Ur(t)}else s=!1;t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,Wl(t);var o=n.getDerivedStateFromProps;typeof o=="function"&&ds(t,n,o,e),r.updater=$s,t.stateNode=r,r._reactInternalFiber=t,wa(t,n,e,i),t=Ia(null,t,n,!0,s,i)}else t.tag=0,Pe(null,t,r,i),t=t.child;return t;case 16:e:{if(r=t.elementType,e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),e=t.pendingProps,b0(r),r._status!==1)throw r._result;switch(r=r._result,t.type=r,s=t.tag=qx(r),e=Je(r,e),s){case 0:t=Ma(null,t,r,e,i);break e;case 1:t=qc(null,t,r,e,i);break e;case 11:t=Jc(null,t,r,e,i);break e;case 14:t=Kc(null,t,r,Je(r.type,e),n,i);break e}throw Error(S(306,r,""))}return t;case 0:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:Je(n,r),Ma(e,t,n,r,i);case 1:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:Je(n,r),qc(e,t,n,r,i);case 3:if(ed(t),n=t.updateQueue,e===null||n===null)throw Error(S(282));if(n=t.pendingProps,r=t.memoizedState,r=r!==null?r.element:null,Hl(e,t),Wn(t,n,null,i),n=t.memoizedState.element,n===r)xo(),t=Mt(e,t,i);else{if((r=t.stateNode.hydrate)&&(jt=_i(t.stateNode.containerInfo.firstChild),Ct=t,r=di=!0),r)for(i=Fl(t,null,n,i),t.child=i;i;)i.effectTag=i.effectTag&-3|1024,i=i.sibling;else Pe(e,t,n,i),xo();t=t.child}return t;case 5:return Qc(t),e===null&&Ca(t),n=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,da(n,r)?o=null:s!==null&&da(n,s)&&(t.effectTag|=16),Mf(e,t),t.mode&4&&i!==1&&r.hidden?(t.expirationTime=t.childExpirationTime=1,t=null):(Pe(e,t,o,i),t=t.child),t;case 6:return e===null&&Ca(t),null;case 13:return td(e,t,i);case 4:return ya(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=Xi(t,null,n,i):Pe(e,t,n,i),t.child;case 11:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:Je(n,r),Jc(e,t,n,r,i);case 7:return Pe(e,t,t.pendingProps,i),t.child;case 8:return Pe(e,t,t.pendingProps.children,i),t.child;case 12:return Pe(e,t,t.pendingProps.children,i),t.child;case 10:e:{n=t.type._context,r=t.pendingProps,o=t.memoizedProps,s=r.value;var a=t.type._context;if(te(ls,a._currentValue),a._currentValue=s,o!==null)if(a=o.value,s=wi(a,s)?0:(typeof n._calculateChangedBits=="function"?n._calculateChangedBits(a,s):1073741823)|0,s===0){if(o.children===r.children&&!Me.current){t=Mt(e,t,i);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var l=a.dependencies;if(l!==null){o=a.child;for(var u=l.firstContext;u!==null;){if(u.context===n&&(u.observedBits&s)!==0){a.tag===1&&(u=$t(i,null),u.tag=2,Wt(a,u)),a.expirationTime<i&&(a.expirationTime=i),u=a.alternate,u!==null&&u.expirationTime<i&&(u.expirationTime=i),df(a.return,i),l.expirationTime<i&&(l.expirationTime=i);break}u=u.next}}else o=a.tag===10&&a.type===t.type?null:a.child;if(o!==null)o.return=a;else for(o=a;o!==null;){if(o===t){o=null;break}if(a=o.sibling,a!==null){a.return=o.return,o=a;break}o=o.return}a=o}Pe(e,t,r.children,i),t=t.child}return t;case 9:return r=t.type,s=t.pendingProps,n=s.children,Ui(t,i),r=Fe(r,s.unstable_observedBits),n=n(r),t.effectTag|=1,Pe(e,t,n,i),t.child;case 14:return r=t.type,s=Je(r,t.pendingProps),s=Je(r.type,s),Kc(e,t,r,s,n,i);case 15:return Cf(e,t,t.type,t.pendingProps,n,i);case 17:return n=t.type,r=t.pendingProps,r=t.elementType===n?r:Je(n,r),e!==null&&(e.alternate=null,t.alternate=null,t.effectTag|=2),t.tag=1,Ie(n)?(e=!0,Ur(t)):e=!1,Ui(t,i),pf(t,n,r),wa(t,n,r,i),Ia(null,t,n,!0,e,i);case 19:return nd(e,t,i)}throw Error(S(156,t.tag))};var Da=null,La=null;function Jx(e){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined")return!1;var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)return!0;try{var i=t.inject(e);Da=function(n){try{t.onCommitFiberRoot(i,n,void 0,(n.current.effectTag&64)===64)}catch{}},La=function(n){try{t.onCommitFiberUnmount(i,n)}catch{}}}catch{}return!0}function Kx(e,t,i,n){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.effectTag=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childExpirationTime=this.expirationTime=0,this.alternate=null}function lt(e,t,i,n){return new Kx(e,t,i,n)}function nu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qx(e){if(typeof e=="function")return nu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Ml)return 11;if(e===Il)return 14}return 2}function xi(e,t){var i=e.alternate;return i===null?(i=lt(e.tag,t,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=t,i.effectTag=0,i.nextEffect=null,i.firstEffect=null,i.lastEffect=null),i.childExpirationTime=e.childExpirationTime,i.expirationTime=e.expirationTime,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,t=e.dependencies,i.dependencies=t===null?null:{expirationTime:t.expirationTime,firstContext:t.firstContext,responders:t.responders},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function Zr(e,t,i,n,r,s){var o=2;if(n=e,typeof e=="function")nu(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case ti:return Rt(i.children,r,s,t);case I0:o=8,r|=7;break;case lp:o=8,r|=1;break;case Lr:return e=lt(12,i,t,r|8),e.elementType=Lr,e.type=Lr,e.expirationTime=s,e;case jr:return e=lt(13,i,t,r),e.type=jr,e.elementType=jr,e.expirationTime=s,e;case Xo:return e=lt(19,i,t,r),e.elementType=Xo,e.expirationTime=s,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case up:o=10;break e;case cp:o=9;break e;case Ml:o=11;break e;case Il:o=14;break e;case dp:o=16,n=null;break e;case hp:o=22;break e}throw Error(S(130,e==null?e:typeof e,""))}return t=lt(o,i,t,r),t.elementType=e,t.type=n,t.expirationTime=s,t}function Rt(e,t,i,n){return e=lt(7,e,n,t),e.expirationTime=i,e}function Io(e,t,i){return e=lt(6,e,null,t),e.expirationTime=i,e}function bo(e,t,i){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.expirationTime=i,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function eS(e,t,i){this.tag=t,this.current=null,this.containerInfo=e,this.pingCache=this.pendingChildren=null,this.finishedExpirationTime=0,this.finishedWork=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=i,this.callbackNode=null,this.callbackPriority=90,this.lastExpiredTime=this.lastPingedTime=this.nextKnownPendingLevel=this.lastSuspendedTime=this.firstSuspendedTime=this.firstPendingTime=0}function Ff(e,t){var i=e.firstSuspendedTime;return e=e.lastSuspendedTime,i!==0&&i>=t&&e<=t}function oi(e,t){var i=e.firstSuspendedTime,n=e.lastSuspendedTime;i<t&&(e.firstSuspendedTime=t),(n>t||i===0)&&(e.lastSuspendedTime=t),t<=e.lastPingedTime&&(e.lastPingedTime=0),t<=e.lastExpiredTime&&(e.lastExpiredTime=0)}function Qf(e,t){t>e.firstPendingTime&&(e.firstPendingTime=t);var i=e.firstSuspendedTime;i!==0&&(t>=i?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:t>=e.lastSuspendedTime&&(e.lastSuspendedTime=t+1),t>e.nextKnownPendingLevel&&(e.nextKnownPendingLevel=t))}function ja(e,t){var i=e.lastExpiredTime;(i===0||i>t)&&(e.lastExpiredTime=t)}function Is(e,t,i,n){var r=t.current,s=ct(),o=zn.suspense;s=pi(s,r,o);e:if(i){i=i._reactInternalFiber;t:{if(Ii(i)!==i||i.tag!==1)throw Error(S(170));var a=i;do{switch(a.tag){case 3:a=a.stateNode.context;break t;case 1:if(Ie(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break t}}a=a.return}while(a!==null);throw Error(S(171))}if(i.tag===1){var l=i.type;if(Ie(l)){i=ef(i,l,a);break e}}i=a}else i=Gt;return t.context===null?t.context=i:t.pendingContext=i,t=$t(s,o),t.payload={element:e},n=n===void 0?null:n,n!==null&&(t.callback=n),Wt(r,t),Ft(r,s),s}function Eo(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function cd(e,t){e=e.memoizedState,e!==null&&e.dehydrated!==null&&e.retryTime<t&&(e.retryTime=t)}function ru(e,t){cd(e,t),(e=e.alternate)&&cd(e,t)}function su(e,t,i){i=i!=null&&i.hydrate===!0;var n=new eS(e,t,i),r=lt(3,null,null,t===2?7:t===1?3:0);n.current=r,r.stateNode=n,Wl(r),e[er]=n.current,i&&t!==0&&P0(e,e.nodeType===9?e:e.ownerDocument),this._internalRoot=n}su.prototype.render=function(e){Is(e,this._internalRoot,null,null)};su.prototype.unmount=function(){var e=this._internalRoot,t=e.containerInfo;Is(null,e,null,function(){t[er]=null})};function or(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function tS(e,t){if(t||(t=e?e.nodeType===9?e.documentElement:e.firstChild:null,t=!(!t||t.nodeType!==1||!t.hasAttribute("data-reactroot"))),!t)for(var i;i=e.lastChild;)e.removeChild(i);return new su(e,0,t?{hydrate:!0}:void 0)}function Zs(e,t,i,n,r){var s=i._reactRootContainer;if(s){var o=s._internalRoot;if(typeof r=="function"){var a=r;r=function(){var u=Eo(o);a.call(u)}}Is(t,o,e,r)}else{if(s=i._reactRootContainer=tS(i,n),o=s._internalRoot,typeof r=="function"){var l=r;r=function(){var u=Eo(o);l.call(u)}}Bf(function(){Is(t,o,e,r)})}return Eo(o)}function iS(e,t,i){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ti,key:n==null?null:""+n,children:e,containerInfo:t,implementation:i}}Pp=function(e){if(e.tag===13){var t=Wr(ct(),150,100);Ft(e,t),ru(e,t)}};Nl=function(e){e.tag===13&&(Ft(e,3),ru(e,3))};zp=function(e){if(e.tag===13){var t=ct();t=pi(t,e,null),Ft(e,t),ru(e,t)}};Yo=function(e,t,i){switch(t){case"input":if(Ko(e,i),t=i.name,i.type==="radio"&&t!=null){for(i=e;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<i.length;t++){var n=i[t];if(n!==e&&n.form===e.form){var r=Rl(n);if(!r)throw Error(S(90));fp(n),Ko(n,r)}}}break;case"textarea":mp(e,i);break;case"select":t=i.value,t!=null&&Oi(e,!!i.multiple,t,!1)}};vl=Vf;sp=function(e,t,i,n,r){var s=j;j|=4;try{return Yt(98,e.bind(null,t,i,n,r))}finally{j=s,j===oe&&ht()}};wl=function(){(j&(1|qe|dt))===oe&&(Wx(),tn())};op=function(e,t){var i=j;j|=2;try{return e(t)}finally{j=i,j===oe&&ht()}};function Zf(e,t){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!or(t))throw Error(S(200));return iS(e,t,null,i)}var nS={Events:[ir,vi,Rl,ip,Go,Gi,function(e){Al(e,H0)},np,rp,Bs,Vs,tn,{current:!1}]};(function(e){var t=e.findFiberByHostInstance;return Jx(Se({},e,{overrideHookState:null,overrideProps:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ke.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Ep(i),i===null?null:i.stateNode},findFiberByHostInstance:function(i){return t?t(i):null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null}))})({findFiberByHostInstance:tr,bundleType:0,version:"16.14.0",rendererPackageName:"react-dom"});Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=nS;Qe.createPortal=Zf;Qe.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternalFiber;if(t===void 0)throw typeof e.render=="function"?Error(S(188)):Error(S(268,Object.keys(e)));return e=Ep(t),e=e===null?null:e.stateNode,e};Qe.flushSync=function(e,t){if((j&(qe|dt))!==oe)throw Error(S(187));var i=j;j|=1;try{return Yt(99,e.bind(null,t))}finally{j=i,ht()}};Qe.hydrate=function(e,t,i){if(!or(t))throw Error(S(200));return Zs(null,e,t,!0,i)};Qe.render=function(e,t,i){if(!or(t))throw Error(S(200));return Zs(null,e,t,!1,i)};Qe.unmountComponentAtNode=function(e){if(!or(e))throw Error(S(40));return e._reactRootContainer?(Bf(function(){Zs(null,null,e,!1,function(){e._reactRootContainer=null,e[er]=null})}),!0):!1};Qe.unstable_batchedUpdates=Vf;Qe.unstable_createPortal=function(e,t){return Zf(e,t,2<arguments.length&&arguments[2]!==void 0?arguments[2]:null)};Qe.unstable_renderSubtreeIntoContainer=function(e,t,i,n){if(!or(i))throw Error(S(200));if(e==null||e._reactInternalFiber===void 0)throw Error(S(38));return Zs(e,t,i,!1,n)};Qe.version="16.14.0";function Gf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Gf)}catch(e){console.error(e)}}Gf(),Xh.exports=Qe;var dd=Xh.exports,rS=Object.defineProperty,sS=Object.defineProperties,oS=Object.getOwnPropertyDescriptors,hd=Object.getOwnPropertySymbols,aS=Object.prototype.hasOwnProperty,lS=Object.prototype.propertyIsEnumerable,pd=(e,t,i)=>t in e?rS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,De=(e,t)=>{for(var i in t||(t={}))aS.call(t,i)&&pd(e,i,t[i]);if(hd)for(var i of hd(t))lS.call(t,i)&&pd(e,i,t[i]);return e};const Yf={src:"",currentTime:0,hostTime:0,muted:!1,paused:!0,volume:1},Xf={currentTimeMaxError:1,syncInterval:1e3,retryInterval:15e3,verbose:!1,log:console.log.bind(console)};let kt=Xf;function uS(e){kt=De(De({},Xf),e)}function Ar(e,t){if(e.paused)return e.currentTime;const i=function(n){if(n.player)return n.player.beginTimestamp+n.player.progressTime;if(n.room)return n.room.calibrationTimestamp}(t);return i?e.currentTime+(i-e.hostTime)/1e3:e.currentTime}const cS=navigator.userAgent.includes("Safari"),dS=[".aac",".mid",".midi",".mp3",".ogg",".oga",".wav",".weba"];var hS=typeof global=="object"&&global&&global.Object===Object&&global,pS=typeof self=="object"&&self&&self.Object===Object&&self,Jf=hS||pS||Function("return this")(),bs=Jf.Symbol,Kf=Object.prototype,fS=Kf.hasOwnProperty,gS=Kf.toString,fn=bs?bs.toStringTag:void 0,mS=Object.prototype.toString,fd=bs?bs.toStringTag:void 0;function vS(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":fd&&fd in Object(e)?function(t){var i=fS.call(t,fn),n=t[fn];try{t[fn]=void 0;var r=!0}catch{}var s=gS.call(t);return r&&(i?t[fn]=n:delete t[fn]),s}(e):function(t){return mS.call(t)}(e)}var wS=/\s/,yS=/^\s+/;function xS(e){return e&&e.slice(0,function(t){for(var i=t.length;i--&&wS.test(t.charAt(i)););return i}(e)+1).replace(yS,"")}function Ra(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var SS=/^[-+]0x[0-9a-f]+$/i,CS=/^0b[01]+$/i,MS=/^0o[0-7]+$/i,IS=parseInt;function gd(e){if(typeof e=="number")return e;if(function(n){return typeof n=="symbol"||function(r){return r!=null&&typeof r=="object"}(n)&&vS(n)=="[object Symbol]"}(e))return NaN;if(Ra(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ra(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=xS(e);var i=CS.test(e);return i||MS.test(e)?IS(e.slice(2),i?2:8):SS.test(e)?NaN:+e}var Ao=function(){return Jf.Date.now()},bS=Math.max,ES=Math.min;function Tr(e,t,i){var n,r,s,o,a,l,u=0,c=!1,d=!1,m=!0;if(typeof e!="function")throw new TypeError("Expected a function");function w(g){var v=n,C=r;return n=r=void 0,u=g,o=e.apply(C,v)}function y(g){return u=g,a=setTimeout(p,t),c?w(g):o}function M(g){var v=g-l;return l===void 0||v>=t||v<0||d&&g-u>=s}function p(){var g=Ao();if(M(g))return h(g);a=setTimeout(p,function(v){var C=t-(v-l);return d?ES(C,s-(v-u)):C}(g))}function h(g){return a=void 0,m&&n?w(g):(n=r=void 0,o)}function f(){var g=Ao(),v=M(g);if(n=arguments,r=this,l=g,v){if(a===void 0)return y(l);if(d)return clearTimeout(a),a=setTimeout(p,t),w(l)}return a===void 0&&(a=setTimeout(p,t)),o}return t=gd(t)||0,Ra(i)&&(c=!!i.leading,s=(d="maxWait"in i)?bS(gd(i.maxWait)||0,t):s,m="trailing"in i?!!i.trailing:m),f.cancel=function(){a!==void 0&&clearTimeout(a),u=0,n=l=r=a=void 0},f.flush=function(){return a===void 0?o:h(Ao())},f}class md extends Mi.exports.Component{constructor(t){super(t),this.seeking=!1,this.mobileSeeking=!1,this.track=null,this.hoverTime=null,this.offset=0,this.secondsPrefix="00:00:",this.minutesPrefix="00:",this.seekPause=!1,this.handleTouchSeeking=i=>{let n=0;for(let r=0;r<i.changedTouches.length;r++)n=i.changedTouches[r].pageX;n=n<0?0:n,this.mobileSeeking&&this.changeCurrentTimePosition(n)},this.handleSeeking=i=>{this.seeking&&this.changeCurrentTimePosition(i.pageX)},this.setTrackWidthState=()=>{this.track&&this.setState({trackWidth:this.track.offsetWidth})},this.handleTrackHover=(i,n)=>{if(this.track){const r=this.props.scale||1;let s;s=i?0:(n.pageX-this.track.getBoundingClientRect().left)/r,this.setState({seekHoverPosition:s,trackWidth:this.track.offsetWidth})}},this.mouseSeekingHandler=i=>{this.setSeeking(!1,i),this.onMouseUp()},this.setSeeking=(i,n)=>{n.preventDefault(),this.handleSeeking(n),this.seeking=i,this.setState({seekHoverPosition:i?this.state.seekHoverPosition:0})},this.mobileTouchSeekingHandler=()=>{this.setMobileSeeking(!1)},this.setMobileSeeking=i=>{this.mobileSeeking=i,this.setState({seekHoverPosition:i?this.state.seekHoverPosition:0})},this.renderBufferProgress=()=>{if(this.props.buffered){const i=De(De({},this.getPositionStyle(this.props.buffered)),this.props.bufferColor&&{backgroundColor:this.props.bufferColor});return $.createElement("div",{className:"buffered",style:i})}return null},this.renderProgress=()=>{const i=De(De({},this.getPositionStyle(this.props.current)),this.props.sliderColor&&{backgroundColor:this.props.sliderColor});return $.createElement("div",{className:"connect",style:i})},this.renderHoverProgress=()=>{const i=De(De({},this.getSeekHoverPosition()),this.props.sliderHoverColor&&{backgroundColor:this.props.sliderHoverColor});return $.createElement("div",{className:"seek-hover",style:i})},this.renderThumb=()=>$.createElement("div",{className:this.isThumbActive()?"thumb active":"thumb",style:this.getThumbHandlerPosition()},$.createElement("div",{style:{backgroundColor:this.props.thumbColor},className:"handler"})),this.onMouseDown=i=>{var n,r;this.props.pause&&!this.props.paused&&(this.props.pause(),this.seekPause=!0),this.setSeeking(!0,i),(r=(n=this.props).onSeekStart)==null||r.call(n)},this.onMouseUp=()=>{var i,n;this.props.play&&this.seekPause&&(this.props.play(),this.seekPause=!1),(n=(i=this.props).onSeekEnd)==null||n.call(i)},this.props.secondsPrefix&&(this.secondsPrefix=this.props.secondsPrefix),this.props.minutesPrefix&&(this.minutesPrefix=this.props.minutesPrefix),this.state={ready:!1,trackWidth:0,seekHoverPosition:0}}componentDidMount(){this.setTrackWidthState(),window.addEventListener("resize",this.setTrackWidthState),window.addEventListener("mousemove",this.handleSeeking),window.addEventListener("mouseup",this.mouseSeekingHandler),window.addEventListener("touchmove",this.handleTouchSeeking),window.addEventListener("touchend",this.mobileTouchSeekingHandler)}componentWillUnmount(){window.removeEventListener("resize",this.setTrackWidthState),window.removeEventListener("mousemove",this.handleSeeking),window.removeEventListener("mouseup",this.mouseSeekingHandler),window.removeEventListener("touchmove",this.handleTouchSeeking),window.removeEventListener("touchend",this.mobileTouchSeekingHandler)}changeCurrentTimePosition(t){if(this.track){const i=this.props.scale||1;let n=(t-this.track.getBoundingClientRect().left)/i;n=Math.min(this.state.trackWidth,Math.max(0,n)),this.setState({seekHoverPosition:n});const r=+(n/this.state.trackWidth*this.props.total).toFixed(0);this.props.onChange(r)}}getPositionStyle(t){return{transform:`scaleX(${100*t/this.props.total/100})`}}getThumbHandlerPosition(){return{transform:`translateX(${this.state.trackWidth/(this.props.total/this.props.current)}px)`}}getSeekHoverPosition(){return{transform:`scaleX(${100*this.state.seekHoverPosition/this.state.trackWidth/100})`}}getHoverTimePosition(){let t=0;return this.hoverTime&&(t=this.state.seekHoverPosition-this.hoverTime.offsetWidth/2,this.props.limitTimeTooltipBySides&&(t<0?t=0:t+this.hoverTime.offsetWidth>this.state.trackWidth&&(t=this.state.trackWidth-this.hoverTime.offsetWidth))),{transform:`translateX(${t}px)`}}secondsToTime(t){t=Math.round(t+this.offset);const i=Math.floor(t/3600),n=t%3600,r=Math.floor(n/60),s=Math.ceil(n%60);return{hh:i.toString(),mm:r<10?"0"+r:r.toString(),ss:s<10?"0"+s:s.toString()}}getHoverTime(){const t=100*this.state.seekHoverPosition/this.state.trackWidth,i=Math.floor(+t*(this.props.total/100)),n=this.secondsToTime(i);return this.props.total+this.offset<60?this.secondsPrefix+n.ss:this.props.total+this.offset<3600?this.minutesPrefix+n.mm+":"+n.ss:n.hh+":"+n.mm+":"+n.ss}isThumbActive(){return this.state.seekHoverPosition>0||this.seeking}drawHoverTime(){return this.props.hideHoverTime?null:$.createElement("div",{className:this.isThumbActive()?"hover-time active":"hover-time",style:this.getHoverTimePosition(),ref:t=>this.hoverTime=t},this.getHoverTime())}render(){return $.createElement("div",{className:"seek-slider"},$.createElement("div",{className:"track",ref:t=>this.track=t,onMouseMove:t=>this.handleTrackHover(!1,t),onMouseLeave:t=>this.handleTrackHover(!0,t),onMouseDown:this.onMouseDown,onTouchStart:t=>{this.setMobileSeeking(!0),this.onMouseDown(t)},onMouseUp:this.onMouseUp,onTouchEnd:this.onMouseUp},$.createElement("div",{className:"main"},this.renderBufferProgress(),this.renderHoverProgress(),this.renderProgress())),this.drawHoverTime(),this.renderThumb())}}class AS extends Mi.exports.Component{constructor(t){super(t),this.stageVolume=0,this.updateVolumeTimer=0,this.onVolumeSeeking=!1,this.onClickOperationButton=()=>{const{paused:i}=this.props;i?this.props.play():this.props.pause()},this.operationButton=()=>{const{paused:i}=this.props;return i?$.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNOCA1LjE0djE0bDExLTdsLTExLTd6IiBmaWxsPSIjZmZmIj48L3BhdGg+PC9zdmc+Cg=="}):$.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTQgMTloNFY1aC00TTYgMTloNFY1SDZ2MTR6IiBmaWxsPSIjZmZmIj48L3BhdGg+PC9zdmc+Cg=="})},this.operationVolumeButton=()=>this.props.volume>.9?$.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTQgMy4yM3YyLjA2YzIuODkuODYgNSAzLjU0IDUgNi43MXMtMi4xMSA1Ljg0LTUgNi43djIuMDdjNC0uOTEgNy00LjQ5IDctOC43N2MwLTQuMjgtMy03Ljg2LTctOC43N00xNi41IDEyYzAtMS43Ny0xLTMuMjktMi41LTQuMDNWMTZjMS41LS43MSAyLjUtMi4yNCAyLjUtNE0zIDl2Nmg0bDUgNVY0TDcgOUgzeiIgZmlsbD0iI2ZmZiI+PC9wYXRoPjwvc3ZnPgo="}):this.props.volume===0?$.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNNyA5djZoNGw1IDVWNGwtNSA1SDd6IiBmaWxsPSIjZmZmIj48L3BhdGg+PC9zdmc+Cg=="}):$.createElement("img",{src:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBhcmlhLWhpZGRlbj0idHJ1ZSIgcm9sZT0iaW1nIiBjbGFzcz0iaWNvbmlmeSBpY29uaWZ5LS1tZGkiIHdpZHRoPSIyMiIgaGVpZ2h0PSIyMiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNNSA5djZoNGw1IDVWNEw5IDltOS41IDNjMC0xLjc3LTEtMy4yOS0yLjUtNC4wM1YxNmMxLjUtLjcxIDIuNS0yLjI0IDIuNS00eiIgZmlsbD0iI2ZmZiI+PC9wYXRoPjwvc3ZnPgo="}),this.handleClickVolume=()=>{this.props.volume===0?this.stageVolume!==0?this.props.setVolume(this.stageVolume):this.props.setVolume(1):(this.stageVolume=this.props.volume,this.props.setVolume(0))},this.onChange=i=>{this.setState({currentTime:i}),i&&this.changeTime(i)},this.changeTime=Tr(i=>{this.props.setCurrentTime(i)},50),this.onVolumeChange=i=>{this.changeVolume(i),this.setState({seekVolume:i/100})},this.changeVolume=Tr(i=>{this.props.setVolume(i/100)},50),this.onVolumeSeekStart=()=>{this.onVolumeSeeking=!0},this.onVolumeSeekEnd=Tr(()=>{this.onVolumeSeeking=!1},500),this.onProgressSeekStart=()=>this.setState({isPlayerSeeking:!0}),this.onProgressSeekEnd=Tr(()=>{this.setState({isPlayerSeeking:!1})},500),this.state={isPlayerSeeking:!1,isVolumeHover:!1,seekVolume:1,visible:!0,currentTime:0},this.stageVolume=t.volume}componentDidMount(){this.updateVolumeTimer=setInterval(()=>{this.onVolumeSeeking||this.setState({seekVolume:this.props.volume}),this.state.isPlayerSeeking||this.setState({currentTime:this.props.currentTime})},100)}componentWillUnmount(){this.updateVolumeTimer&&clearInterval(this.updateVolumeTimer)}render(){const{duration:t,currentTime:i}=this.props;return $.createElement("div",{className:"player-controller",style:{opacity:this.props.visible?"1":"0"}},$.createElement("div",{className:"player-controller-progress"},$.createElement(md,{total:t,current:this.state.currentTime,onChange:this.onChange,buffered:this.props.buffered,bufferColor:"rgba(255,255,255,0.3)",hideHoverTime:!0,limitTimeTooltipBySides:!0,onSeekStart:this.onProgressSeekStart,onSeekEnd:this.onProgressSeekEnd,play:this.props.play,pause:this.props.pause,paused:this.props.paused,scale:this.props.scale})),$.createElement("div",{className:"player-controller-actions"},$.createElement("div",{className:"player-controller-actions-left"},$.createElement("div",{onClick:this.onClickOperationButton,className:"player-controller-play"},this.operationButton()),$.createElement("div",{className:"player-volume-box",onMouseEnter:()=>this.setState({isVolumeHover:!0}),onMouseLeave:()=>this.setState({isVolumeHover:!1})},$.createElement("div",{onClick:this.handleClickVolume,className:"player-volume"},this.operationVolumeButton()),$.createElement("div",{className:"player-volume-slider"},$.createElement(md,{total:100,current:100*this.state.seekVolume,onChange:this.onVolumeChange,onSeekStart:this.onVolumeSeekStart,onSeekEnd:this.onVolumeSeekEnd,scale:this.props.scale,limitTimeTooltipBySides:!0,hideHoverTime:!0})))),$.createElement("div",{className:"player-mid-box-time"},vd(Math.floor(i/1e3))," /"," ",vd(Math.floor(t/1e3)))))}}function vd(e){const t=e%60,i=(e-t)/60;if(i>=60){const n=i%60;return`${gn((i-n)/60)}:${gn(n)}:${gn(t)}`}return`${gn(i)}:${gn(t)}`}function gn(e){return e<=9?`0${e}`:`${e}`}class TS extends Mi.exports.Component{constructor(){super(...arguments),this.putAttributes=t=>{const{context:i}=this.props,n=i.getAttributes()||{};for(const r in t)n[r]!==t[r]&&i.updateAttributes([r],t[r])}}render(){const{context:t}=this.props,i=t.getRoom(),n=i?void 0:t.getDisplayer(),r=this.putAttributes;return $.createElement(NS,{room:i,player:n,context:t,plugin:{putAttributes:r}})}}class NS extends Mi.exports.Component{constructor(t){super(t),this.alertMask=null,this.container=$.createRef(),this.controllerHiddenTimer=0,this.syncPlayerTimer=0,this.retryCount=0,this.decreaseRetryTimer=0,this.noSoundSyncCount=0,this.showController=()=>{this.setState({controllerVisible:!0}),this.debounceHidingController()},this.play=()=>{var i;const n=(i=this.props.room)==null?void 0:i.calibrationTimestamp;this.debug(">>> play",{paused:!1,hostTime:n}),this.isEnabled()&&this.props.plugin.putAttributes({paused:!1,hostTime:n})},this.pause=()=>{const i=Ar(this.getAttributes(),this.props);this.debug(">>> pause",{paused:!0,currentTime:i}),this.isEnabled()&&this.props.plugin.putAttributes({paused:!0,currentTime:i})},this.setVolume=i=>{this.debug(">>> volume",{volume:i}),this.isEnabled()&&this.props.plugin.putAttributes({volume:i}),this.isEnabled()&&this.props.plugin.putAttributes({volume:i,muted:i===0})},this.setCurrentTime=i=>{var n;const r=(n=this.props.room)==null?void 0:n.calibrationTimestamp;this.debug(">>> seek",{currentTime:i/1e3,hostTime:r}),this.isEnabled()&&this.props.plugin.putAttributes({currentTime:i/1e3,hostTime:r})},this.resetPlayer=()=>{var i;(i=this.player)==null||i.autoplay(!1),this.state.NoSound||(this.debug(">>> ended",{paused:!0,currentTime:0}),this.isEnabled()&&this.props.plugin.putAttributes({paused:!0,currentTime:0}))},this.syncPlayerWithAttributes=()=>{var i;const n=this.getAttributes();if(!n)return;const r=this.player;if(!r||this.state.NoSound&&(this.noSoundSyncCount+=1)%8!=0)return;r.paused()!==n.paused&&(this.debug("<<< paused -> %o",n.paused),n.paused?r.pause():(i=r.play())==null||i.catch(this.catchPlayFail)),r.muted()!==n.muted&&(this.debug("<<< muted -> %o",n.muted),r.muted(n.muted)),r.volume()!==n.volume&&(this.debug("<<< volume -> %o",n.volume),r.volume(n.volume));const s=Ar(n,this.props);let o=kt.currentTimeMaxError;this.state.NoSound&&(o*=3),s>r.duration()?this.resetPlayer():Math.abs(r.currentTime()-s)>o&&(this.debug("<<< currentTime -> %o",s),r.currentTime(s))},this.debounceHidingController=()=>{this.controllerHiddenTimer&&(clearTimeout(this.controllerHiddenTimer),this.controllerHiddenTimer=0),this.controllerHiddenTimer=setTimeout(()=>{this.setState({controllerVisible:!1}),this.controllerHiddenTimer=0},3e3)},this.decreaseRetryCount=()=>{this.player&&this.retryCount>0&&(this.retryCount=this.retryCount-1)},this.catchPlayFail=i=>{var n,r;const s=String(i);if(cS&&s.includes("NotAllowedError")||s.includes("interact"))(n=this.player)==null||n.autoplay("any"),this.setState({NoSound:!0});else{const o=(r=this.player)==null?void 0:r.error();o&&(this.retryCount<=3?(this.initPlayer(),this.retryCount=this.retryCount+1):(this.debug("catch videojs media error",o),this.setState({MediaError:!0}))),this.debug("catch error",i)}},this.fixPlayFail=()=>{this.debug("try to fix play state"),this.setState({NoSound:!1});const{muted:i,volume:n}=this.getAttributes();this.player&&(this.player.muted(i),this.player.volume(n))},this.initPlayer=async()=>{var i;(i=this.player)==null||i.dispose(),this.player=void 0,this.debug("creating elements ...");const{type:n,src:r,poster:s}=this.getAttributes(),o=document.createElement("div");o.setAttribute("data-vjs-player","");const a=document.createElement("video");a.className="video-js",s&&(a.poster=s),a.setAttribute("playsInline",""),a.setAttribute("webkit-playsinline","");const l=document.createElement("source");new URL(r).pathname.endsWith(".m3u8")?l.type="application/x-mpegURL":a.src=r,l.src=r,n&&(l.type=n),a.appendChild(l),o.appendChild(a),this.container.current.appendChild(o),await new Promise(c=>(window.requestAnimationFrame||window.setTimeout)(c)),this.debug("initializing videojs() ...");const u=fu.default(a);this.player=u,window.player=u,u.one("loadedmetadata",this.gracefullyUpdate),u.on("ready",()=>{var c;(c=kt.onPlayer)==null||c.call(kt,u),u.on("timeupdate",this.gracefullyUpdate),u.on("volumechange",this.gracefullyUpdate),u.on("seeked",this.gracefullyUpdate),u.on("play",this.gracefullyUpdate),u.on("pause",this.gracefullyUpdate),u.on("ended",this.resetPlayer)}),u.on("error",this.catchPlayFail),this.setState({MediaError:!1})},this.gracefullyUpdate=()=>this.setState({updater:!this.state.updater}),this.setupAlert=i=>{i&&(i.addEventListener("touchstart",this.fixPlayFail),i.addEventListener("click",this.fixPlayFail)),this.alertMask=i},this.setupReload=i=>{i&&(i.addEventListener("touchstart",this.initPlayer),i.addEventListener("click",this.initPlayer))},this.state={NoSound:!1,MediaError:!1,updater:!1,controllerVisible:!1},t.room&&function(i){if(!i.calibrationTimestamp)throw new Error("@netless/app-media-player@0.1.0-alpha.5 requires white-web-sdk@^2.13.8 to work properly.")}(t.room)}getAttributes(){const{context:t}=this.props;let i=t.getAttributes();if(i){if(i=De(De({},Yf),i),this.player){let r=Ar(i,this.props),s=this.player.duration();!i.paused&&r>s&&(n=De({},i),i=sS(n,oS({currentTime:0,paused:!0})),this.resetPlayer())}var n;return i}}isShowingPoster(){const t=this.getAttributes();return!(t!=null&&t.src)||dS.some(i=>t.src.endsWith(i))}render(){var t,i;if(!this.props.room&&!this.props.player)return null;const n=this.getAttributes();if(!n)return null;const r=1e3*(((t=this.player)==null?void 0:t.duration())||1e3),s=((i=this.player)==null?void 0:i.bufferedPercent())||0;return $.createElement("div",{className:this.isEnabled()?"vjs-p":"vjs-p disabled",onMouseEnter:this.showController,onMouseMove:this.showController},$.createElement("div",{className:"video-js-plugin-player",ref:this.container}),this.isShowingPoster()&&$.createElement("div",{className:"video-js-plugin-poster"},n.poster&&$.createElement("img",{src:n.poster,alt:"",draggable:!1})),$.createElement(AS,{duration:r,volume:n.volume,setVolume:this.setVolume,paused:n.paused,play:this.play,pause:this.pause,currentTime:1e3*Ar(n,this.props),setCurrentTime:this.setCurrentTime,buffered:r*s,visible:!0}),this.state.NoSound&&$.createElement("div",{ref:this.setupAlert,className:"videojs-plugin-muted-alert"}),this.state.MediaError&&$.createElement("div",{className:"videojs-plugin-recovery-mode"},$.createElement("button",{ref:this.setupReload},"Reload Player")))}debug(t,...i){kt.verbose&&kt.log(`[MediaPlayer] ${t}`,...i)}componentDidMount(){this.debug("app version =","0.1.0-alpha.5"),this.debug("video.js version =",fu.default.VERSION),this.initPlayer(),this.props.context.emitter.on("attributesUpdate",this.syncPlayerWithAttributes),this.syncPlayerTimer=setInterval(this.syncPlayerWithAttributes,kt.syncInterval),this.decreaseRetryTimer=setInterval(this.decreaseRetryCount,kt.retryInterval)}componentWillUnmount(){var t;this.debug("unmount"),this.props.context.emitter.off("attributesUpdate",this.syncPlayerWithAttributes),(t=this.player)==null||t.dispose(),clearInterval(this.syncPlayerTimer),clearInterval(this.decreaseRetryTimer)}isEnabled(){return this.props.context.getIsWritable()}}const Va={kind:"MediaPlayer",setup(e){let t=e.getAttributes();if(!t||!t.src)return e.emitter.emit("destroy",{error:new Error("[MediaPlayer]: Missing 'attributes'.'src'.")});t=De(De({},Yf),t);const i=e.getBox();i.mountStyles(`.vjs-p{display:flex;flex-grow:1}.vjs-p *{pointer-events:auto}.vjs-p.disabled *{pointer-events:none}.vjs-p .video-js-plugin-poster{position:absolute;top:0;left:0;right:0;bottom:0;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgQAAACACAYAAAB0vHFxAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAACBKADAAQAAAABAAAAgAAAAACE3oPTAAAKXUlEQVR4Ae3dYW4ktxEG0LW9FwkC2McycokAOUGAXMLwtQwYvomdP4akHUnNnm6SVUU+/xqpe8ji+yiDWz3a/e7L5v/98se//3pL8K9//O+7t19Hv85eX7RP9vnllz2h4/rkd+wz+ir/0cLfjv/9t1/6igABAgQIENhRwIFgx9StmQABAgQIPAg4EDyA+JIAAQIECOwo8HXHRVvzPIHRzwBHjz9PKudMo31Hj59TdZ2qsueXvb5sO0GHIFsi6iFAgAABAgECOgQB6KbsJ5Dtt0L6rWyPkeRXO+fs+WWvL1v6OgTZElEPAQIECBAIENAhCEA3ZT8Bzwj7WUaMJL8I9X5zZs8ve339kugzkg5BH0ejECBAgACB0gIOBKXjUzwBAgQIEOgj4EDQx9EoBAgQIECgtIADQen4FE+AAAECBPoIOBD0cTQKAQIECBAoLeC3DErHp/iWgE8Zt4RyX5df7nxa1Y3Ob/T4rfWtdl2HYLVErYcAAQIECFwQWL5DsPoJcvX1XdjTpd4iv1JxvStWfu9IfCORwLP7U4cgUXhKIUCAAAECUQIOBFHy5iVAgAABAokEHAgShaEUAgQIECAQJXD7MwTPPqOIWujVeUevb/T4V9ftfecE5HfOKetd8suajLoiBHQIItTNSYAAAQIEkgnc7hAkW0/3ckb/e9qjx+8OYsBvBOT3DUe5L+RXLjIFDxTQIRiIa2gCBAgQIFBFoNkh2P0Z2+j1jx4/+0asvv7q9d/dH9XXX73+3fO7u/7W+3fbHzoErR3hOgECBAgQ2ECg2SHwjG2DXRC4xOj9tdufAHpHLb/eonPHk9+xd7TPcXX9r+oQ9Dc1IgECBAgQKCfgQFAuMgUTIECAAIH+Ag4E/U2NSIAAAQIEygk0P0MQvaLsz3hb9bWu840WOJ5ffsc+2a/KL3tC6jsSmL1/dQiO0nCNAAECBAhsItDsEMw+oTzrHl1f61OorevPrvfZ+6N9WvVmr09+xwnKr7ZP9vyOdcdfze7Tuz4dgvF7ygwECBAgQCC9QLNDkH0F0X+C45NdoHZ99rf8aguofqRA7/8/6BCMTMvYBAgQIECgiED5DkHvZyhFcjtdJp/TVClvlF/KWE4XJb/TVG68INB7f+kQXAjBWwgQIECAwGoCDgSrJWo9BAgQIEDggoADwQU0byFAgAABAqsJfO39DGI1IOuJFbA/Y/3vzi6/u4Kx7189v7vru/v+2HTfz65D8N7EdwgQIECAwHYCw3/LYLUT1HY7pLFg+TaAkl+WX/KAGuXJrwEUfLlaPjoEwRvG9AQIECBAIIPA8A5B779JKQOaGl4F5PtqUfGV/Cqm9lqz/F4tMr6qlo8OQcZdpCYCBAgQIDBZYHiHoNozlMn+5aeTb+0I5Se/2gK5q6/286VDkHs/qY4AAQIECEwRcCCYwmwSAgQIECCQW8CBIHc+qiNAgAABAlMEhn+GYMoqTEKAAAEC7wSqPcN+twDfmCqgQzCV22QECBAgQCCnQHiHoPoJtlV/63rObfFaVfX6X1dy7VX19Vev/1pqr++qvv7q9b8m4dVHAtny1SH4KCXfI0CAAAECmwmEdwiq/U1Om+2PL/Kpnbj85FdbYO3qs/186hCsvd+sjgABAgQInBJwIDjF5CYCBAgQILC2gAPB2vlaHQECBAgQOCUQ/hmCbJ+yPKW20U3yqR22/ORXW2Dt6qN/Ph/n1yFYe79ZHQECBAgQOCXgQHCKyU0ECBAgQGBtAQeCtfO1OgIECBAgcErAgeAUk5sIECBAgMDaAg4Ea+drdQQIECBA4JTA1+///OGnoztd52N/fC7g58PPx+e748sX+8P+qLQ/dAiO0nKNAAECBAhsIuBAsEnQlkmAAAECBI4EHAiOdFwjQIAAAQKbCDgQbBK0ZRIgQIAAgSMBB4IjHdcIECBAgMAmAuH/lsHP//zvb5tYl1ymfErG9lK0/F4oSr6QX8nYThcdne/j/DoEp6NzIwECBAgQWFfAgWDdbK2MAAECBAicFnAgOE3lRgIECBAgsK5A+GcIfv39Pz++5X18pvH2mtfzBeQz37znjPLrqTl/LPnNN585Y7Z8dQhmpm8uAgQIECCQVCC8Q1C9I9Cqv3U96b54Kat6/S8Lufii+vqr138xtpe3VV9/9fpfgvDiQ4Fs+eoQfBiTbxIgQIAAgb0EwjsEe3FbLQECBOYJZPsT6LyVm+mKgA7BFTXvIUCAAAECiwk4ECwWqOUQIECAAIErAg4EV9S8hwABAgQILCYw/DMEnmEttmMeliPfB5BiX8qvWGAP5crvASTZl9Xy0SFItoGUQ4AAAQIEIgSGdwiy/U1MEcgrzynf2unKT361BXJXX+3nS4cg935SHQECBAgQmCIwvENQ7RnKFPWFJpFv7TDlJ7/aArmrr/bzpUOQez+pjgABAgQITBH4Wu0EM0XFJGkE7M80UVwqRH6X2NK8afX87q7v7vvTBP13IToE2RJRDwECBAgQCBBwIAhANyUBAgQIEMgm4ECQLRH1ECBAgACBAIHhv2Uwek2rPcPp7cWnt+jc8eQ317v3bPLrLWq8twK995cOwVtdrwkQIECAwKYC5TsE1f4mqNn7jM9s8b7zya+v5+zR5DdbfK/5eu8vHYK99o/VEiBAgACBDwWaHYLezyg+rOLGN6Pra53QWtdvLP3UW6N9WkVmr09+xwnKr7ZP9vyOdcdfze7Tuz4dgvF7ygwECBAgQCC9QLNDEL2C3ieg3utp1de63rueZ8fLXt+z6+l9f3af7PX1zuPZ8bL7ZK/vWW/39xWYvT90CPrmZzQCBAgQIFBSwIGgZGyKJkCAAAECfQUcCPp6Go0AAQIECJQUaH6GIPpT1iVVFX1aIHp/zX5GdxqmyI3yKxLUJ2XK7xOYv78d7XNcXf+rOgT9TY1IgAABAgTKCTQ7BLv/CWr0+kePn31HVl9/9frv7o/q669e/+753V1/6/277Q8dgtaOcJ0AAQIECGwg0OwQbGBwuMTRz5BGj3+4OBdvC8jvNmHoAPIL5Td5MgEdgmSBKIcAAQIECEQI3O4QrP6MZfT6Ro8fsal2mlN+tdOWX+38VN9XQIegr6fRCBAgQIBASQEHgpKxKZoAAQIECPQVcCDo62k0AgQIECBQUuD2Zwiyr3r1Z4Srry/7/rpbn/zuCsa+X36x/mY/Fnh2f+oQHHu6SoAAAQIEthBYvkOwRYoW+anAsyfkTwdyIURAfiHs3SYdnd/o8btBFBlIh6BIUMokQIAAAQIjBRwIRuoamwABAgQIFBFwICgSlDIJECBAgMBIAQeCkbrGJkCAAAECRQQcCIoEpUwCBAgQIDBSwG8ZjNQ19nABnzIeTjx0AvkN5R0+ePb8stc3PKAnJ9AheBLM7QQIECBAYEUBHYIVU91oTf49+9phy09+IwXsr+d0dQie83I3AQIECBBYUkCHYMlY8yxq9DO80ePnkYypZLTv6PFj1PaZNXt+2evLtlN0CLIloh4CBAgQIBAg4EAQgG5KAgQIECCQTcCBIFsi6iFAgAABAgEC/wdVfx9UuC8B6AAAAABJRU5ErkJggg==);background-repeat:repeat-x;background-position:0 50%;display:flex;align-items:center;justify-content:center}.vjs-p .video-js-plugin-poster img{box-shadow:0 0 5px 10px #0006}.vjs-p .player-controller,.vjs-p .videojs-plugin-muted-alert{pointer-events:auto}.vjs-p.disabled .videojs-plugin-close-icon,.vjs-p.disabled .player-controller{pointer-events:none}.vjs-p .video-js-plugin-player{position:absolute;top:0;left:0;right:0;bottom:0}.video-js,[data-vjs-player]{width:100%;height:100%}.vjs-p .videojs-plugin-muted-alert{pointer-events:auto;cursor:pointer;position:absolute;top:0;left:0;right:0;bottom:0;z-index:43}.vjs-p .videojs-plugin-muted-alert:before{pointer-events:auto;cursor:pointer;position:absolute;top:0;left:0;right:0;bottom:0;z-index:43;content:"\\f104";background:rgba(0,0,0,.3);font-family:VideoJS;font-size:2em;display:flex;align-items:center;justify-content:center;color:#fff}.vjs-p .videojs-plugin-recovery-mode{pointer-events:auto;cursor:pointer;position:absolute;top:0;left:0;right:0;bottom:0;z-index:44}.vjs-p .videojs-plugin-recovery-mode button{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.vjs-p .seek-slider{position:relative;width:100%}.vjs-p .seek-slider:focus{outline:none}.vjs-p .seek-slider .track{padding:10px 0;cursor:pointer;outline:none}.vjs-p .seek-slider .track:focus{border:0;outline:none}.vjs-p .seek-slider .track .main{width:100%;height:3px;background-color:#ffffff4d;border-radius:30px;position:absolute;left:0;top:8.5px;transition:transform .4s;outline:none}.vjs-p .seek-slider .track .main:focus{border:0;outline:none}.vjs-p .seek-slider .track .main .buffered{position:absolute;background-color:#ffffff4d;width:100%;height:100%;transform:scaleX(.8);z-index:2;transform-origin:0 0}.vjs-p .seek-slider .track .main .seek-hover{position:absolute;background-color:#ffffff80;width:100%;height:100%;z-index:1;transform:scaleX(.6);transform-origin:0 0;opacity:0;transition:opacity .4s}.vjs-p .seek-slider .track .main .connect{position:absolute;background-color:#fff;width:100%;height:100%;z-index:3;left:0;transform:scaleX(.13);transform-origin:0 0}.vjs-p .seek-slider .track.active .main{transform:scaleY(2)}.vjs-p .seek-slider .thumb{pointer-events:none;position:absolute;width:12px;height:12px;left:-6px;top:4px;z-index:4;transform:translate(100px)}.vjs-p .seek-slider .thumb .handler{border-radius:100%;width:100%;height:100%;background-color:#fff;opacity:0;transform:scale(.4);cursor:pointer;transition:transform .2s;pointer-events:none}.vjs-p .seek-slider .thumb.active .handler{opacity:1;transform:scale(1)}.vjs-p .seek-slider .hover-time{position:absolute;background-color:#0000004d;line-height:18px;font-size:16px;color:#ddd;top:-25px;left:0;padding:5px 10px;border-radius:5px;box-shadow:0 0 5px #0000004d;opacity:0;transform:translate(150px);pointer-events:none}.vjs-p .seek-slider .hover-time.active{opacity:1}.vjs-p .seek-slider:hover .track .main .seek-hover{opacity:1}.vjs-p .player-controller{position:absolute;z-index:100;bottom:0px;left:0;width:100%;display:flex;flex-direction:column;justify-content:center;align-items:stretch;height:64px;background-image:linear-gradient(0deg,#000,transparent);transition:opacity .2s;color:#fff}.vjs-p .player-menu-box{display:flex;align-items:center;justify-content:center;flex-direction:column;margin-bottom:40px}.vjs-p .player-menu-cell{width:100%;text-align:center;font-size:12px;color:#7a7b7c}.vjs-p .player-multiple-play{width:64px;height:120px}.vjs-p .player-controller-actions-left{display:flex;justify-content:center;align-items:center;flex-shrink:0}.vjs-p .player-right-box{font-size:14px;color:#7a7b7c;cursor:pointer;margin-right:12px}.vjs-p .player-controller-actions{display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-left:8px;padding-right:8px;margin-top:2px}.vjs-p .player-mid-box-time{font-size:9px;display:flex;justify-content:center;align-items:center;color:#fff;flex-shrink:0;margin-right:8px;font-family:monospace}.vjs-p .player-controller-play{display:flex;align-items:center;justify-content:center;cursor:pointer;padding-right:4px}.vjs-p .player-controller-progress{width:calc(100% - 28px);margin-left:14px;display:flex;align-items:center;justify-content:center;margin-top:8px}.vjs-p .player-volume{display:flex;align-items:center;justify-content:center;cursor:pointer;margin-right:16px;margin-left:8px}.vjs-p .player-volume-slider{width:60px;margin-right:12px;display:flex;align-items:center}.vjs-p .player-volume-box{display:flex;flex-direction:row}.netless-app-media-player-container{display:flex;position:relative;height:100%}
46
- `);const n=document.createElement("div");n.classList.add("netless-app-media-player-container"),dd.render($.createElement(TS,{context:e}),n),i.mountContent(n),e.emitter.on("destroy",()=>{console.log("[MediaPlayer]: destroy"),dd.unmountComponentAtNode(n)})}},kS=()=>{ye.debug&&uS({verbose:!0}),ye.register({kind:Wo.kind,src:Wo}),ye.register({kind:Va.kind,src:Va})},PS={DocsViewer:Wo.kind,MediaPlayer:Va.kind};const qf=new Bv({emitter:L}),B=class extends E.InvisiblePlugin{constructor(e){super(e);this.version="1.0.0-canary.4",this.dependencies={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"1.0.0-alpha.12",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1","side-effect-manager":"^1.1.0",uuid:"^7.0.3","value-enhancer":"^1.2.1","video.js":">=7"},peerDependencies:{"white-web-sdk":"^2.16.0"},devDependencies:{"@netless/app-docs-viewer":"^0.2.9","@netless/app-media-player":"0.1.0-beta.5","@rollup/plugin-commonjs":"^20.0.0","@rollup/plugin-node-resolve":"^13.0.4","@rollup/plugin-url":"^6.1.0","@sveltejs/vite-plugin-svelte":"^1.0.0-next.22","@tsconfig/svelte":"^2.0.1","@types/debug":"^4.1.7","@types/lodash":"^4.14.182","@types/lodash-es":"^4.17.4","@types/uuid":"^8.3.1","@typescript-eslint/eslint-plugin":"^4.30.0","@typescript-eslint/parser":"^4.30.0","@vitest/ui":"^0.14.1",cypress:"^8.7.0",dotenv:"^10.0.0",eslint:"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-svelte3":"^3.2.0",jsdom:"^19.0.0",less:"^4.1.1",prettier:"^2.3.2","prettier-plugin-svelte":"^2.4.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-styles":"^3.14.1",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.5.3",vitest:"^0.14.1","white-web-sdk":"2.16.10"}},this.emitter=ie,this.viewMode=E.ViewMode.Broadcaster,this.isReplay=E.isPlayer(this.displayer),this.containerSizeRatio=B.containerSizeRatio,B.displayer=e.displayer,window.NETLESS_DEPS={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"1.0.0-alpha.12",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1","side-effect-manager":"^1.1.0",uuid:"^7.0.3","value-enhancer":"^1.2.1","video.js":">=7"},peerDependencies:{"white-web-sdk":"^2.16.0"},devDependencies:{"@netless/app-docs-viewer":"^0.2.9","@netless/app-media-player":"0.1.0-beta.5","@rollup/plugin-commonjs":"^20.0.0","@rollup/plugin-node-resolve":"^13.0.4","@rollup/plugin-url":"^6.1.0","@sveltejs/vite-plugin-svelte":"^1.0.0-next.22","@tsconfig/svelte":"^2.0.1","@types/debug":"^4.1.7","@types/lodash":"^4.14.182","@types/lodash-es":"^4.17.4","@types/uuid":"^8.3.1","@typescript-eslint/eslint-plugin":"^4.30.0","@typescript-eslint/parser":"^4.30.0","@vitest/ui":"^0.14.1",cypress:"^8.7.0",dotenv:"^10.0.0",eslint:"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-svelte3":"^3.2.0",jsdom:"^19.0.0",less:"^4.1.1",prettier:"^2.3.2","prettier-plugin-svelte":"^2.4.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-styles":"^3.14.1",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.5.3",vitest:"^0.14.1","white-web-sdk":"2.16.10"}}}static async mount(e){var o;const t=e.room;B.container=e.container;const i=e.containerSizeRatio,n=e.debug,r=e.cursor;B.params=e,B.displayer=e.room,Hg();let s;if(E.isRoom(t)){if(t.phase!==E.RoomPhase.Connected)throw new Error("[WindowManager]: Room only Connected can be mount");t.phase===E.RoomPhase.Connected&&t.isWritable&&(t.disableSerialization=!1),s=await this.initManager(t)}if(B.isCreated)throw new Error("[WindowManager]: Already created cannot be created again");if(this.debug=Boolean(n),Li("Already insert room",s),E.isRoom(this.displayer)){if(!s)throw new Error("[WindowManager]: init InvisiblePlugin failed")}else await hg.default(async a=>{if(s=await t.getInvisiblePlugin(B.kind),!s)throw Li(`manager is empty. retrying ${a}`),new Error},{retries:10});if(!s)throw new Error("[WindowManager]: create manager failed");i&&(B.containerSizeRatio=i),await s.ensureAttributes(),s.appManager=new tm(s),s._pageState=new Vv(s.appManager),s.cursorManager=new Rv(s.appManager,Boolean(r),e.applianceIcons),i&&(s.containerSizeRatio=i),s.boxManager=cv(s,ie,L,wt,{collectorContainer:e.collectorContainer,collectorStyles:e.collectorStyles,prefersColorScheme:e.prefersColorScheme,stageRatio:e.containerSizeRatio}),(o=s.appManager)==null||o.setBoxManager(s.boxManager),e.container&&s.bindContainer(e.container),Ov(t,s),L.emit("onCreated"),B.isCreated=!0;try{await wg()}catch(a){console.warn("[WindowManager]: indexedDB open failed"),console.log(a)}return s}static async initManager(e){let t=e.getInvisiblePlugin(B.kind);if(!t&&E.isRoom(e))if(e.isWritable===!1){try{await e.setWritable(!0)}catch{throw new Error("[WindowManger]: room must be switched to be writable")}t=await e.createInvisiblePlugin(B,{}),t.ensureAttributes(),await Su(500),await e.setWritable(!1)}else t=await e.createInvisiblePlugin(B,{});return t}static initContainer(e,t){B.container||(B.container=e);const{playground:i,mainViewElement:n}=Wg(e);if(B.playground=i,t){const r=document.createElement("style");r.textContent=t,i.appendChild(r)}return n}static get registered(){return je.registered}bindContainer(e){var t,i,n,r,s;if(E.isRoom(this.displayer)&&this.room.phase!==E.RoomPhase.Connected)throw new Nd;if(B.isCreated&&B.container)B.container.firstChild&&e.appendChild(B.container.firstChild);else if(B.params){const o=B.params,a=B.initContainer(e,o.overwriteStyles);this.boxManager&&B.playground&&this.boxManager.setRoot(B.playground),this.bindMainView(a,o.disableCameraTransform),B.playground&&((t=this.cursorManager)==null||t.setupWrapper(B.playground))}L.emit("updateManagerRect"),(i=this.appManager)==null||i.refresh(),(n=this.appManager)==null||n.resetMaximized(),(r=this.appManager)==null||r.resetMinimized(),(s=this.appManager)==null||s.displayerWritableListener(!this.room.isWritable),B.container=e}bindCollectorContainer(e){B.isCreated&&this.boxManager?this.boxManager.setCollector(e):B.params&&(B.params.collectorContainer=e)}static register(e){return je.register(e)}static unregister(e){return je.unregister(e)}async addApp(e){if(this.appManager)return this.appManager.rootDirRemoving?new Promise((t,i)=>{L.once("rootDirRemoved").then(async()=>{try{const n=await this._addApp(e);t(n)}catch(n){i(n.message)}})}):this._addApp(e);throw new Ye}async _addApp(e){var t,i,n;if(this.appManager){if(!e.kind||typeof e.kind!="string")throw new bd;const r=await((t=je.appClasses.get(e.kind))==null?void 0:t());if(r&&((i=r.config)==null?void 0:i.singleton)&&this.appManager.appProxies.has(e.kind))throw new Md;const s=this.setupScenePath(e,this.appManager);return s===void 0?void 0:((n=e==null?void 0:e.options)!=null&&n.scenePath&&(e.options.scenePath=jg(e.options.scenePath)),await this.appManager.addApp(e,Boolean(s)))}else throw new Ye}setupScenePath(e,t){let i=!1;if(e.options){const{scenePath:n,scenes:r}=e.options;if(n){if(!Lg(n))throw new Ad;const s=Object.keys(this.apps||{});for(const o of s){const a=t.store.getAppScenePath(o);if(a&&a===n){if(console.warn(`[WindowManager]: ScenePath ${n} Already opened`),this.boxManager){const l=this.boxManager.getTopBox();l&&this.boxManager.setZIndex(o,l.zIndex+1,!1)}return}}}n&&r&&r.length>0&&(this.isDynamicPPT(r)?(i=!0,mi(this.displayer)[n]||ai(this.room,n,r)):mi(this.displayer)[n]||ai(this.room,n,[{name:r[0].name}])),n&&r===void 0&&ai(this.room,n,[{}])}return i}async setMainViewScenePath(e){this.appManager&&await this.appManager.setMainViewScenePath(e)}async setMainViewSceneIndex(e){this.appManager&&await this.appManager.setMainViewSceneIndex(e)}async nextPage(){if(this.appManager){const e=this.mainViewSceneIndex+1;return e>=this.mainViewScenesLength?(console.warn("[WindowManager]: current page is the last page"),!1):(await this.appManager.setMainViewSceneIndex(e),!0)}else return!1}async prevPage(){if(this.appManager){const e=this.mainViewSceneIndex-1;return e<0?(console.warn("[WindowManager]: current page is the first page"),!1):(await this.appManager.setMainViewSceneIndex(e),!0)}else return!1}async addPage(e){if(this.appManager){const t=e==null?void 0:e.after,i=e==null?void 0:e.scene;if(t){const n=this.mainViewSceneIndex+1;this.room.putScenes(ze,[i||{}],n)}else this.room.putScenes(ze,[i||{}])}}async removePage(e){if(this.appManager){const t=e===void 0?this.pageState.index:e;return this.pageState.length===1?(console.warn("[WindowManager]: can not remove the last page"),!1):t<0||t>=this.pageState.length?(console.warn(`[WindowManager]: index ${e} out of range`),!1):this.appManager.removeSceneByIndex(t)}else return!1}getMainViewScenePath(){var e;return(e=this.appManager)==null?void 0:e.store.getMainViewScenePath()}getMainViewSceneIndex(){var e;return(e=this.appManager)==null?void 0:e.store.getMainViewSceneIndex()}setReadonly(e){var t;this.readonly=e,(t=this.boxManager)==null||t.setReadonly(e),L.emit("setReadonly",e)}switchMainViewToWriter(){var e;return(e=this.appManager)==null?void 0:e.mainViewProxy.mainViewClickHandler()}onAppDestroy(e,t){zg(`destroy-${e}`,t)}setViewMode(e){var t,i,n;e===E.ViewMode.Broadcaster&&(this.canOperate&&((t=this.appManager)==null||t.mainViewProxy.setCameraAndSize()),(i=this.appManager)==null||i.mainViewProxy.start()),e===E.ViewMode.Freedom&&((n=this.appManager)==null||n.mainViewProxy.stop()),this.viewMode=e}setBoxState(e){if(!!this.canOperate)switch(e){case"normal":this.setMaximized(!1),this.setMinimized(!1);break;case"maximized":this.setMaximized(!0),this.setMinimized(!1);break;case"minimized":this.setMinimized(!0);break}}setMaximized(e){var t;!this.canOperate||(t=this.boxManager)==null||t.setMaximized(e,!1)}setMinimized(e){var t;!this.canOperate||(t=this.boxManager)==null||t.setMinimized(e,!1)}get mainView(){if(this.appManager)return this.appManager.mainViewProxy.view;throw new Ye}get camera(){if(this.appManager)return this.appManager.mainViewProxy.view.camera;throw new Ye}get cameraState(){if(this.appManager)return this.appManager.mainViewProxy.cameraState;throw new Ye}get apps(){var e;return(e=this.appManager)==null?void 0:e.store.apps()}get boxState(){var e;if(this.appManager)return(e=this.appManager.boxManager)==null?void 0:e.boxState;throw new Ye}get darkMode(){var e,t;return Boolean((t=(e=this.appManager)==null?void 0:e.boxManager)==null?void 0:t.darkMode)}get prefersColorScheme(){var e;if(this.appManager)return(e=this.appManager.boxManager)==null?void 0:e.prefersColorScheme;throw new Ye}get focused(){return this.attributes.focus}get focusedView(){var e,t;return((t=(e=this.appManager)==null?void 0:e.focusApp)==null?void 0:t.view)||this.mainView}get mainViewSceneIndex(){var e;return((e=this._pageState)==null?void 0:e.index)||0}get mainViewSceneDir(){var e;if(this.appManager)return(e=this.appManager)==null?void 0:e.getMainViewSceneDir();throw new Ye}get topApp(){var e,t;return(t=(e=this.boxManager)==null?void 0:e.getTopBox())==null?void 0:t.id}get mainViewScenesLength(){var e;return((e=this._pageState)==null?void 0:e.length)||0}get canRedoSteps(){var e;return((e=this.focusedView)==null?void 0:e.canRedoSteps)||0}get canUndoSteps(){var e;return((e=this.focusedView)==null?void 0:e.canUndoSteps)||0}get sceneState(){if(this.appManager)return this.appManager.sceneState;throw new Ye}get pageState(){if(this._pageState)return this._pageState.toObject();throw new Ye}queryAll(){var e;return Array.from(((e=this.appManager)==null?void 0:e.appProxies.values())||[])}queryOne(e){var t;return(t=this.appManager)==null?void 0:t.appProxies.get(e)}async closeApp(e){var t;return(t=this.appManager)==null?void 0:t.closeApp(e)}moveCamera(e){var n;const t=b.omit(e,["animationMode"]),i=Q({},this.mainView.camera);b.isEqual(Q(Q({},i),t),i)||(this.mainView.moveCamera(e),(n=this.appManager)==null||n.dispatchInternalEvent(Z.MoveCamera,e),setTimeout(()=>{var r;(r=this.appManager)==null||r.mainViewProxy.setCameraAndSize()},500))}moveCameraToContain(e){var t;this.mainView.moveCameraToContain(e),(t=this.appManager)==null||t.dispatchInternalEvent(Z.MoveCameraToContain,e),setTimeout(()=>{var i;(i=this.appManager)==null||i.mainViewProxy.setCameraAndSize()},500)}convertToPointInWorld(e){return this.mainView.convertToPointInWorld(e)}setCameraBound(e){this.mainView.setCameraBound(e)}onDestroy(){this._destroy()}destroy(){this._destroy()}_destroy(){var e,t,i;(e=this.appManager)==null||e.destroy(),(t=this.cursorManager)==null||t.destroy(),B.container=void 0,B.isCreated=!1,B.playground&&((i=B.playground.parentNode)==null||i.removeChild(B.playground)),B.params=void 0,Li("Destroyed")}bindMainView(e,t){var i;this.appManager&&(this.appManager.bindMainView(e,Boolean(t)),(i=this.cursorManager)==null||i.setMainViewDivElement(e))}get canOperate(){return E.isRoom(this.displayer)?this.displayer.isWritable&&this.displayer.phase===E.RoomPhase.Connected:!1}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,i;(i=(t=this.appManager)==null?void 0:t.boxManager)==null||i.setPrefersColorScheme(e)}cleanCurrentScene(){var e;(e=this.focusedView)==null||e.cleanCurrentScene()}redo(){var e;return((e=this.focusedView)==null?void 0:e.redo())||0}undo(){var e;return((e=this.focusedView)==null?void 0:e.undo())||0}delete(){var e;(e=this.focusedView)==null||e.delete()}copy(){var e;(e=this.focusedView)==null||e.copy()}paste(){var e;(e=this.focusedView)==null||e.paste()}duplicate(){var e;(e=this.focusedView)==null||e.duplicate()}insertText(e,t,i){var n;return((n=this.focusedView)==null?void 0:n.insertText(e,t,i))||""}insertImage(e){var t;return(t=this.focusedView)==null?void 0:t.insertImage(e)}completeImageUpload(e,t){var i;return(i=this.focusedView)==null?void 0:i.completeImageUpload(e,t)}lockImage(e,t){var i;return(i=this.focusedView)==null?void 0:i.lockImage(e,t)}lockImages(e){var t;return(t=this.focusedView)==null?void 0:t.lockImages(e)}refresh(){var e;this._refresh(),(e=this.appManager)==null||e.dispatchInternalEvent(Z.Refresh)}_refresh(){var e,t,i;(e=this.appManager)==null||e.mainViewProxy.rebind(),B.container&&this.bindContainer(B.container),(i=(t=this.appManager)==null?void 0:t.refresher)==null||i.refresh()}setContainerSizeRatio(e){if(!b.isNumber(e))throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a number. but got ${e}`);B.containerSizeRatio=e,this.containerSizeRatio=e,L.emit("containerSizeRatioUpdate",e)}isDynamicPPT(e){var i,n;const t=(n=(i=e[0])==null?void 0:i.ppt)==null?void 0:n.src;return t==null?void 0:t.startsWith("pptx://")}async ensureAttributes(){b.isNull(this.attributes)&&await Su(50),b.isObject(this.attributes)&&(this.attributes[me.Apps]||this.safeSetAttributes({[me.Apps]:{}}),this.attributes[me.Cursors]||this.safeSetAttributes({[me.Cursors]:{}}),this.attributes._mainScenePath||this.safeSetAttributes({_mainScenePath:Sd}),this.attributes._mainSceneIndex||this.safeSetAttributes({_mainSceneIndex:0}),this.attributes[me.Registered]||this.safeSetAttributes({[me.Registered]:{}}))}};let ye=B;ye.kind="WindowManager";ye.debug=!1;ye.containerSizeRatio=gg;ye.isCreated=!1;kS();exports.AppCreateError=Md;exports.AppManagerNotInitError=Ye;exports.AppNotRegisterError=Bg;exports.BindContainerRoomPhaseInvalidError=Nd;exports.BoxManagerNotFoundError=Td;exports.BoxNotCreatedError=Ed;exports.BuiltinApps=PS;exports.InvalidScenePath=Ad;exports.ParamsInvalidError=bd;exports.WhiteWebSDKInvalidError=Id;exports.WindowManager=ye;exports.calculateNextIndex=Oa;exports.reconnectRefresher=qf;
46
+ `);const n=document.createElement("div");n.classList.add("netless-app-media-player-container"),dd.render($.createElement(TS,{context:e}),n),i.mountContent(n),e.emitter.on("destroy",()=>{console.log("[MediaPlayer]: destroy"),dd.unmountComponentAtNode(n)})}},kS=()=>{ye.debug&&uS({verbose:!0}),ye.register({kind:Wo.kind,src:Wo}),ye.register({kind:Va.kind,src:Va})},PS={DocsViewer:Wo.kind,MediaPlayer:Va.kind};const qf=new Bv({emitter:L}),B=class extends E.InvisiblePlugin{constructor(e){super(e);this.version="1.0.0-canary.5",this.dependencies={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"1.0.0-alpha.13",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1","side-effect-manager":"^1.1.0",uuid:"^7.0.3","value-enhancer":"^1.2.1","video.js":">=7"},peerDependencies:{"white-web-sdk":"^2.16.0"},devDependencies:{"@netless/app-docs-viewer":"^0.2.9","@netless/app-media-player":"0.1.0-beta.5","@rollup/plugin-commonjs":"^20.0.0","@rollup/plugin-node-resolve":"^13.0.4","@rollup/plugin-url":"^6.1.0","@sveltejs/vite-plugin-svelte":"^1.0.0-next.22","@tsconfig/svelte":"^2.0.1","@types/debug":"^4.1.7","@types/lodash":"^4.14.182","@types/lodash-es":"^4.17.4","@types/uuid":"^8.3.1","@typescript-eslint/eslint-plugin":"^4.30.0","@typescript-eslint/parser":"^4.30.0","@vitest/ui":"^0.14.1",cypress:"^8.7.0",dotenv:"^10.0.0",eslint:"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-svelte3":"^3.2.0",jsdom:"^19.0.0",less:"^4.1.1",prettier:"^2.3.2","prettier-plugin-svelte":"^2.4.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-styles":"^3.14.1",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.5.3",vitest:"^0.14.1","white-web-sdk":"2.16.10"}},this.emitter=ie,this.viewMode=E.ViewMode.Broadcaster,this.isReplay=E.isPlayer(this.displayer),this.containerSizeRatio=B.containerSizeRatio,B.displayer=e.displayer,window.NETLESS_DEPS={dependencies:{"@juggle/resize-observer":"^3.3.1","@netless/telebox-insider":"1.0.0-alpha.13",emittery:"^0.9.2",lodash:"^4.17.21","p-retry":"^4.6.1","side-effect-manager":"^1.1.0",uuid:"^7.0.3","value-enhancer":"^1.2.1","video.js":">=7"},peerDependencies:{"white-web-sdk":"^2.16.0"},devDependencies:{"@netless/app-docs-viewer":"^0.2.9","@netless/app-media-player":"0.1.0-beta.5","@rollup/plugin-commonjs":"^20.0.0","@rollup/plugin-node-resolve":"^13.0.4","@rollup/plugin-url":"^6.1.0","@sveltejs/vite-plugin-svelte":"^1.0.0-next.22","@tsconfig/svelte":"^2.0.1","@types/debug":"^4.1.7","@types/lodash":"^4.14.182","@types/lodash-es":"^4.17.4","@types/uuid":"^8.3.1","@typescript-eslint/eslint-plugin":"^4.30.0","@typescript-eslint/parser":"^4.30.0","@vitest/ui":"^0.14.1",cypress:"^8.7.0",dotenv:"^10.0.0",eslint:"^7.32.0","eslint-config-prettier":"^8.3.0","eslint-plugin-svelte3":"^3.2.0",jsdom:"^19.0.0",less:"^4.1.1",prettier:"^2.3.2","prettier-plugin-svelte":"^2.4.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-styles":"^3.14.1",svelte:"^3.42.4",typescript:"^4.5.5",vite:"^2.5.3",vitest:"^0.14.1","white-web-sdk":"2.16.10"}}}static async mount(e){var o;const t=e.room;B.container=e.container;const i=e.containerSizeRatio,n=e.debug,r=e.cursor;B.params=e,B.displayer=e.room,Hg();let s;if(E.isRoom(t)){if(t.phase!==E.RoomPhase.Connected)throw new Error("[WindowManager]: Room only Connected can be mount");t.phase===E.RoomPhase.Connected&&t.isWritable&&(t.disableSerialization=!1),s=await this.initManager(t)}if(B.isCreated)throw new Error("[WindowManager]: Already created cannot be created again");if(this.debug=Boolean(n),Li("Already insert room",s),E.isRoom(this.displayer)){if(!s)throw new Error("[WindowManager]: init InvisiblePlugin failed")}else await hg.default(async a=>{if(s=await t.getInvisiblePlugin(B.kind),!s)throw Li(`manager is empty. retrying ${a}`),new Error},{retries:10});if(!s)throw new Error("[WindowManager]: create manager failed");i&&(B.containerSizeRatio=i),await s.ensureAttributes(),s.appManager=new tm(s),s._pageState=new Vv(s.appManager),s.cursorManager=new Rv(s.appManager,Boolean(r),e.applianceIcons),i&&(s.containerSizeRatio=i),s.boxManager=cv(s,ie,L,wt,{collectorContainer:e.collectorContainer,collectorStyles:e.collectorStyles,prefersColorScheme:e.prefersColorScheme,stageRatio:e.containerSizeRatio}),(o=s.appManager)==null||o.setBoxManager(s.boxManager),e.container&&s.bindContainer(e.container),Ov(t,s),L.emit("onCreated"),B.isCreated=!0;try{await wg()}catch(a){console.warn("[WindowManager]: indexedDB open failed"),console.log(a)}return s}static async initManager(e){let t=e.getInvisiblePlugin(B.kind);if(!t&&E.isRoom(e))if(e.isWritable===!1){try{await e.setWritable(!0)}catch{throw new Error("[WindowManger]: room must be switched to be writable")}t=await e.createInvisiblePlugin(B,{}),t.ensureAttributes(),await Su(500),await e.setWritable(!1)}else t=await e.createInvisiblePlugin(B,{});return t}static initContainer(e,t){B.container||(B.container=e);const{playground:i,mainViewElement:n}=Wg(e);if(B.playground=i,t){const r=document.createElement("style");r.textContent=t,i.appendChild(r)}return n}static get registered(){return je.registered}bindContainer(e){var t,i,n,r,s;if(E.isRoom(this.displayer)&&this.room.phase!==E.RoomPhase.Connected)throw new Nd;if(B.isCreated&&B.container)B.container.firstChild&&e.appendChild(B.container.firstChild);else if(B.params){const o=B.params,a=B.initContainer(e,o.overwriteStyles);this.boxManager&&B.playground&&this.boxManager.setRoot(B.playground),this.bindMainView(a,o.disableCameraTransform),B.playground&&((t=this.cursorManager)==null||t.setupWrapper(B.playground))}L.emit("updateManagerRect"),(i=this.appManager)==null||i.refresh(),(n=this.appManager)==null||n.resetMaximized(),(r=this.appManager)==null||r.resetMinimized(),(s=this.appManager)==null||s.displayerWritableListener(!this.room.isWritable),B.container=e}bindCollectorContainer(e){B.isCreated&&this.boxManager?this.boxManager.setCollector(e):B.params&&(B.params.collectorContainer=e)}static register(e){return je.register(e)}static unregister(e){return je.unregister(e)}async addApp(e){if(this.appManager)return this.appManager.rootDirRemoving?new Promise((t,i)=>{L.once("rootDirRemoved").then(async()=>{try{const n=await this._addApp(e);t(n)}catch(n){i(n.message)}})}):this._addApp(e);throw new Ye}async _addApp(e){var t,i,n;if(this.appManager){if(!e.kind||typeof e.kind!="string")throw new bd;const r=await((t=je.appClasses.get(e.kind))==null?void 0:t());if(r&&((i=r.config)==null?void 0:i.singleton)&&this.appManager.appProxies.has(e.kind))throw new Md;const s=this.setupScenePath(e,this.appManager);return s===void 0?void 0:((n=e==null?void 0:e.options)!=null&&n.scenePath&&(e.options.scenePath=jg(e.options.scenePath)),await this.appManager.addApp(e,Boolean(s)))}else throw new Ye}setupScenePath(e,t){let i=!1;if(e.options){const{scenePath:n,scenes:r}=e.options;if(n){if(!Lg(n))throw new Ad;const s=Object.keys(this.apps||{});for(const o of s){const a=t.store.getAppScenePath(o);if(a&&a===n){if(console.warn(`[WindowManager]: ScenePath ${n} Already opened`),this.boxManager){const l=this.boxManager.getTopBox();l&&this.boxManager.setZIndex(o,l.zIndex+1,!1)}return}}}n&&r&&r.length>0&&(this.isDynamicPPT(r)?(i=!0,mi(this.displayer)[n]||ai(this.room,n,r)):mi(this.displayer)[n]||ai(this.room,n,[{name:r[0].name}])),n&&r===void 0&&ai(this.room,n,[{}])}return i}async setMainViewScenePath(e){this.appManager&&await this.appManager.setMainViewScenePath(e)}async setMainViewSceneIndex(e){this.appManager&&await this.appManager.setMainViewSceneIndex(e)}async nextPage(){if(this.appManager){const e=this.mainViewSceneIndex+1;return e>=this.mainViewScenesLength?(console.warn("[WindowManager]: current page is the last page"),!1):(await this.appManager.setMainViewSceneIndex(e),!0)}else return!1}async prevPage(){if(this.appManager){const e=this.mainViewSceneIndex-1;return e<0?(console.warn("[WindowManager]: current page is the first page"),!1):(await this.appManager.setMainViewSceneIndex(e),!0)}else return!1}async addPage(e){if(this.appManager){const t=e==null?void 0:e.after,i=e==null?void 0:e.scene;if(t){const n=this.mainViewSceneIndex+1;this.room.putScenes(ze,[i||{}],n)}else this.room.putScenes(ze,[i||{}])}}async removePage(e){if(this.appManager){const t=e===void 0?this.pageState.index:e;return this.pageState.length===1?(console.warn("[WindowManager]: can not remove the last page"),!1):t<0||t>=this.pageState.length?(console.warn(`[WindowManager]: index ${e} out of range`),!1):this.appManager.removeSceneByIndex(t)}else return!1}getMainViewScenePath(){var e;return(e=this.appManager)==null?void 0:e.store.getMainViewScenePath()}getMainViewSceneIndex(){var e;return(e=this.appManager)==null?void 0:e.store.getMainViewSceneIndex()}setReadonly(e){var t;this.readonly=e,(t=this.boxManager)==null||t.setReadonly(e),L.emit("setReadonly",e)}switchMainViewToWriter(){var e;return(e=this.appManager)==null?void 0:e.mainViewProxy.mainViewClickHandler()}onAppDestroy(e,t){zg(`destroy-${e}`,t)}setViewMode(e){var t,i,n;e===E.ViewMode.Broadcaster&&(this.canOperate&&((t=this.appManager)==null||t.mainViewProxy.setCameraAndSize()),(i=this.appManager)==null||i.mainViewProxy.start()),e===E.ViewMode.Freedom&&((n=this.appManager)==null||n.mainViewProxy.stop()),this.viewMode=e}setBoxState(e){if(!!this.canOperate)switch(e){case"normal":this.setMaximized(!1),this.setMinimized(!1);break;case"maximized":this.setMaximized(!0),this.setMinimized(!1);break;case"minimized":this.setMinimized(!0);break}}setMaximized(e){var t;!this.canOperate||(t=this.boxManager)==null||t.setMaximized(e,!1)}setMinimized(e){var t;!this.canOperate||(t=this.boxManager)==null||t.setMinimized(e,!1)}get mainView(){if(this.appManager)return this.appManager.mainViewProxy.view;throw new Ye}get camera(){if(this.appManager)return this.appManager.mainViewProxy.view.camera;throw new Ye}get cameraState(){if(this.appManager)return this.appManager.mainViewProxy.cameraState;throw new Ye}get apps(){var e;return(e=this.appManager)==null?void 0:e.store.apps()}get boxState(){var e;if(this.appManager)return(e=this.appManager.boxManager)==null?void 0:e.boxState;throw new Ye}get darkMode(){var e,t;return Boolean((t=(e=this.appManager)==null?void 0:e.boxManager)==null?void 0:t.darkMode)}get prefersColorScheme(){var e;if(this.appManager)return(e=this.appManager.boxManager)==null?void 0:e.prefersColorScheme;throw new Ye}get focused(){return this.attributes.focus}get focusedView(){var e,t;return((t=(e=this.appManager)==null?void 0:e.focusApp)==null?void 0:t.view)||this.mainView}get mainViewSceneIndex(){var e;return((e=this._pageState)==null?void 0:e.index)||0}get mainViewSceneDir(){var e;if(this.appManager)return(e=this.appManager)==null?void 0:e.getMainViewSceneDir();throw new Ye}get topApp(){var e,t;return(t=(e=this.boxManager)==null?void 0:e.getTopBox())==null?void 0:t.id}get mainViewScenesLength(){var e;return((e=this._pageState)==null?void 0:e.length)||0}get canRedoSteps(){var e;return((e=this.focusedView)==null?void 0:e.canRedoSteps)||0}get canUndoSteps(){var e;return((e=this.focusedView)==null?void 0:e.canUndoSteps)||0}get sceneState(){if(this.appManager)return this.appManager.sceneState;throw new Ye}get pageState(){if(this._pageState)return this._pageState.toObject();throw new Ye}queryAll(){var e;return Array.from(((e=this.appManager)==null?void 0:e.appProxies.values())||[])}queryOne(e){var t;return(t=this.appManager)==null?void 0:t.appProxies.get(e)}async closeApp(e){var t;return(t=this.appManager)==null?void 0:t.closeApp(e)}moveCamera(e){var n;const t=b.omit(e,["animationMode"]),i=Q({},this.mainView.camera);b.isEqual(Q(Q({},i),t),i)||(this.mainView.moveCamera(e),(n=this.appManager)==null||n.dispatchInternalEvent(Z.MoveCamera,e),setTimeout(()=>{var r;(r=this.appManager)==null||r.mainViewProxy.setCameraAndSize()},500))}moveCameraToContain(e){var t;this.mainView.moveCameraToContain(e),(t=this.appManager)==null||t.dispatchInternalEvent(Z.MoveCameraToContain,e),setTimeout(()=>{var i;(i=this.appManager)==null||i.mainViewProxy.setCameraAndSize()},500)}convertToPointInWorld(e){return this.mainView.convertToPointInWorld(e)}setCameraBound(e){this.mainView.setCameraBound(e)}onDestroy(){this._destroy()}destroy(){this._destroy()}_destroy(){var e,t,i;(e=this.appManager)==null||e.destroy(),(t=this.cursorManager)==null||t.destroy(),B.container=void 0,B.isCreated=!1,B.playground&&((i=B.playground.parentNode)==null||i.removeChild(B.playground)),B.params=void 0,Li("Destroyed")}bindMainView(e,t){var i;this.appManager&&(this.appManager.bindMainView(e,Boolean(t)),(i=this.cursorManager)==null||i.setMainViewDivElement(e))}get canOperate(){return E.isRoom(this.displayer)?this.displayer.isWritable&&this.displayer.phase===E.RoomPhase.Connected:!1}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,i;(i=(t=this.appManager)==null?void 0:t.boxManager)==null||i.setPrefersColorScheme(e)}cleanCurrentScene(){var e;(e=this.focusedView)==null||e.cleanCurrentScene()}redo(){var e;return((e=this.focusedView)==null?void 0:e.redo())||0}undo(){var e;return((e=this.focusedView)==null?void 0:e.undo())||0}delete(){var e;(e=this.focusedView)==null||e.delete()}copy(){var e;(e=this.focusedView)==null||e.copy()}paste(){var e;(e=this.focusedView)==null||e.paste()}duplicate(){var e;(e=this.focusedView)==null||e.duplicate()}insertText(e,t,i){var n;return((n=this.focusedView)==null?void 0:n.insertText(e,t,i))||""}insertImage(e){var t;return(t=this.focusedView)==null?void 0:t.insertImage(e)}completeImageUpload(e,t){var i;return(i=this.focusedView)==null?void 0:i.completeImageUpload(e,t)}lockImage(e,t){var i;return(i=this.focusedView)==null?void 0:i.lockImage(e,t)}lockImages(e){var t;return(t=this.focusedView)==null?void 0:t.lockImages(e)}refresh(){var e;this._refresh(),(e=this.appManager)==null||e.dispatchInternalEvent(Z.Refresh)}_refresh(){var e,t,i;(e=this.appManager)==null||e.mainViewProxy.rebind(),B.container&&this.bindContainer(B.container),(i=(t=this.appManager)==null?void 0:t.refresher)==null||i.refresh()}setContainerSizeRatio(e){if(!b.isNumber(e))throw new Error(`[WindowManager]: updateContainerSizeRatio error, ratio must be a number. but got ${e}`);B.containerSizeRatio=e,this.containerSizeRatio=e,L.emit("containerSizeRatioUpdate",e)}isDynamicPPT(e){var i,n;const t=(n=(i=e[0])==null?void 0:i.ppt)==null?void 0:n.src;return t==null?void 0:t.startsWith("pptx://")}async ensureAttributes(){b.isNull(this.attributes)&&await Su(50),b.isObject(this.attributes)&&(this.attributes[me.Apps]||this.safeSetAttributes({[me.Apps]:{}}),this.attributes[me.Cursors]||this.safeSetAttributes({[me.Cursors]:{}}),this.attributes._mainScenePath||this.safeSetAttributes({_mainScenePath:Sd}),this.attributes._mainSceneIndex||this.safeSetAttributes({_mainSceneIndex:0}),this.attributes[me.Registered]||this.safeSetAttributes({[me.Registered]:{}}))}};let ye=B;ye.kind="WindowManager";ye.debug=!1;ye.containerSizeRatio=gg;ye.isCreated=!1;kS();exports.AppCreateError=Md;exports.AppManagerNotInitError=Ye;exports.AppNotRegisterError=Bg;exports.BindContainerRoomPhaseInvalidError=Nd;exports.BoxManagerNotFoundError=Td;exports.BoxNotCreatedError=Ed;exports.BuiltinApps=PS;exports.InvalidScenePath=Ad;exports.ParamsInvalidError=bd;exports.WhiteWebSDKInvalidError=Id;exports.WindowManager=ye;exports.calculateNextIndex=Oa;exports.reconnectRefresher=qf;