gaesup-world 1.3.2 → 1.4.0
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/{ControllerWrapper-C6mzwejv.cjs → ControllerWrapper-DIZhLWzV.cjs} +1 -1
- package/dist/{ControllerWrapper-Bc_pRQSv.js → ControllerWrapper-guCfO0a-.js} +3 -3
- package/dist/{CoreBridge-DdJBUxmY.js → CoreBridge-CoU_vJOo.js} +1 -0
- package/dist/CoreBridge-L4l4UNtR.cjs +1 -0
- package/dist/{Gamepad-DpCgazVm.js → Gamepad-DuJ8qWlv.js} +4 -4
- package/dist/{Gamepad-BVhh5IfO.cjs → Gamepad-Xvf4z0S2.cjs} +1 -1
- package/dist/{NodeGpuSnow-lWPqrcUV.js → NodeGpuSnow-BvYQIWMj.js} +1 -1
- package/dist/{NodeGpuSnow-C3MwTvnW.cjs → NodeGpuSnow-By8_DPWF.cjs} +1 -1
- package/dist/{NodeGrassMaterial-BMwfsBMP.cjs → NodeGrassMaterial-CbcGJsx_.cjs} +1 -1
- package/dist/{NodeGrassMaterial-W9H9z72i.js → NodeGrassMaterial-DZSpsEzt.js} +1 -1
- package/dist/{NodeTreeParticles-DDpwPxpE.cjs → NodeTreeParticles-BbFBoQik.cjs} +1 -1
- package/dist/{NodeTreeParticles-DPjRQ0wj.js → NodeTreeParticles-CWqWgN2w.js} +1 -1
- package/dist/{NodeWaterMaterial-C5fHPHUG.cjs → NodeWaterMaterial-B1rA9DRv.cjs} +1 -1
- package/dist/{NodeWaterMaterial-Bc1nkYSw.js → NodeWaterMaterial-BKvyycqz.js} +2 -2
- package/dist/{Rideable-DTSh5xu3.js → Rideable-4ECPOR3x.js} +7 -7
- package/dist/{Rideable-CWddzOkn.cjs → Rideable-CNgjDUBh.cjs} +1 -1
- package/dist/{SaveSystem-DF5zSnEj.js → SaveSystem-B9TrEpWU.js} +2 -2
- package/dist/{SaveSystem-DwfckGGo.cjs → SaveSystem-Bj41IbmF.cjs} +1 -1
- package/dist/{WorldBridge-DmvFhm9b.cjs → WorldBridge-CBEkEehK.cjs} +1 -1
- package/dist/{WorldBridge-m64VREYb.js → WorldBridge-DtqzMddm.js} +1 -1
- package/dist/{WorldContainer-BjZj0uvZ.cjs → WorldContainer-CDC2nj9-.cjs} +1 -1
- package/dist/{WorldContainer-Ce5PVxSF.js → WorldContainer-DdHlM9IG.js} +7 -7
- package/dist/{WorldPhysics-CueqwH91.cjs → WorldPhysics-CQAfZYGi.cjs} +1 -1
- package/dist/{WorldPhysics-oZdWret8.js → WorldPhysics-Dry82NpQ.js} +1 -1
- package/dist/WorldPostProcessing-C40JqbKO.js +234 -0
- package/dist/WorldPostProcessing-C9qqKrpI.cjs +1 -0
- package/dist/{WorldProps-L3Izutxz.cjs → WorldProps-C0JF5fFD.cjs} +1 -1
- package/dist/{WorldProps-CQrtF4CO.js → WorldProps-Du0EDzmt.js} +6 -7
- package/dist/{blueprints-BHfyy363.cjs → blueprints-BRMf59iu.cjs} +1 -1
- package/dist/{blueprints-BlhgrXDo.js → blueprints-BzU37Tjs.js} +2 -2
- package/dist/blueprints-editor.cjs +1 -1
- package/dist/blueprints-editor.js +7 -7
- package/dist/blueprints.cjs +1 -1
- package/dist/blueprints.js +1 -1
- package/dist/building.cjs +1 -1
- package/dist/building.js +3 -3
- package/dist/core/building/components/mesh/model/merge.d.cts +2 -1
- package/dist/core/building/components/mesh/model/merge.d.ts +2 -1
- package/dist/core/camera/bridge/types.d.cts +3 -1
- package/dist/core/camera/bridge/types.d.ts +3 -1
- package/dist/core/camera/components/CameraController/defaults.d.cts +2 -1
- package/dist/core/camera/components/CameraController/defaults.d.ts +2 -1
- package/dist/core/camera/components/CameraController/index.d.cts +4 -4
- package/dist/core/camera/components/CameraController/index.d.ts +4 -4
- package/dist/core/camera/components/CameraController/types.d.cts +16 -1
- package/dist/core/camera/components/CameraController/types.d.ts +16 -1
- package/dist/core/camera/components/index.d.cts +2 -2
- package/dist/core/camera/components/index.d.ts +2 -2
- package/dist/core/camera/controllers/BaseController.d.cts +4 -0
- package/dist/core/camera/controllers/BaseController.d.ts +4 -0
- package/dist/core/camera/core/CameraOcclusion.d.cts +60 -0
- package/dist/core/camera/core/CameraOcclusion.d.ts +60 -0
- package/dist/core/camera/core/CameraSystem.d.cts +2 -0
- package/dist/core/camera/core/CameraSystem.d.ts +2 -0
- package/dist/core/camera/core/constants.d.cts +1 -0
- package/dist/core/camera/core/constants.d.ts +1 -0
- package/dist/core/camera/core/seeThrough.d.cts +64 -0
- package/dist/core/camera/core/seeThrough.d.ts +64 -0
- package/dist/core/camera/core/types.d.cts +17 -0
- package/dist/core/camera/core/types.d.ts +17 -0
- package/dist/core/camera/utils/camera.d.cts +6 -3
- package/dist/core/camera/utils/camera.d.ts +6 -3
- package/dist/core/camera/utils/sphereSweep.d.cts +8 -1
- package/dist/core/camera/utils/sphereSweep.d.ts +8 -1
- package/dist/core/editor/components/panels/CameraSettingsTab/types.d.cts +1 -1
- package/dist/core/editor/components/panels/CameraSettingsTab/types.d.ts +1 -1
- package/dist/core/rendering/postprocess/WorldPostProcessing.d.cts +26 -1
- package/dist/core/rendering/postprocess/WorldPostProcessing.d.ts +26 -1
- package/dist/core/rendering/postprocess/screenSpaceLighting.d.cts +51 -0
- package/dist/core/rendering/postprocess/screenSpaceLighting.d.ts +51 -0
- package/dist/core/rendering/webgpu.d.cts +2 -0
- package/dist/core/rendering/webgpu.d.ts +2 -0
- package/dist/core/world/components/WorldContainer/types.d.cts +1 -1
- package/dist/core/world/components/WorldContainer/types.d.ts +1 -1
- package/dist/{defaults-jVT3EUVe.js → defaults-BmnFvrSk.js} +13 -4
- package/dist/defaults-Y3XGbDmo.cjs +1 -0
- package/dist/editor.cjs +1 -1
- package/dist/editor.js +4 -4
- package/dist/{flow-DJRTbNvJ.js → flow-B_5Jtrhv.js} +1 -1
- package/dist/{flow-BnFTzumT.cjs → flow-CY0am38O.cjs} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.css +1 -1
- package/dist/index.js +906 -904
- package/dist/network.cjs +1 -1
- package/dist/network.js +1 -1
- package/dist/{plugin-BUKo4q0N.cjs → plugin-BY3uYoSx.cjs} +32 -32
- package/dist/{plugin-Dsf9EwPP.js → plugin-uKCTitER.js} +907 -905
- package/dist/postprocessing.cjs +1 -1
- package/dist/postprocessing.js +1 -1
- package/dist/{quality-BLE1xXFm.js → quality--izFMxKn.js} +2 -2
- package/dist/{quality-0VukPLnv.cjs → quality-CxseVZ9x.cjs} +1 -1
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +7 -7
- package/dist/sceneCompile-CWcdcntc.cjs +1 -0
- package/dist/{sceneCompile-BWpSal9S.js → sceneCompile-CuCsjsKm.js} +99 -91
- package/dist/{sfe-DnOKmvUM.cjs → sfe-BUv2sneT.cjs} +1 -1
- package/dist/{sfe-BAXSr5BB.js → sfe-DhJQcjMq.js} +1 -1
- package/dist/shell-C82J4LTq.cjs +1 -0
- package/dist/{shell-aiiC8SLL.js → shell-Ct-ZE2ZM.js} +2565 -2515
- package/dist/{useClicker-0Ln5ZSz0.cjs → useClicker-B-fGashd.cjs} +1 -1
- package/dist/{useClicker-DZrb1I0b.js → useClicker-ChI9FA0J.js} +1 -1
- package/dist/useGenericRefs-DzuTNaAX.cjs +1 -0
- package/dist/{useGenericRefs-D0cOKidj.js → useGenericRefs-PVX2F3On.js} +553 -270
- package/dist/{useVisitRoom-GXR8KyFN.cjs → useVisitRoom-BWf5YBiG.cjs} +1 -1
- package/dist/{useVisitRoom-C_UX2avV.js → useVisitRoom-qRZdBGlH.js} +6 -6
- package/package.json +3 -3
- package/dist/CoreBridge-CnLqWZNv.cjs +0 -1
- package/dist/WorldPostProcessing-C80qMk1k.cjs +0 -1
- package/dist/WorldPostProcessing-Dfq_RW-t.js +0 -158
- package/dist/defaults-BLDQhn77.cjs +0 -1
- package/dist/sceneCompile-D9xft0op.cjs +0 -1
- package/dist/shell-BRQStYy9.cjs +0 -1
- package/dist/useGenericRefs-CZ_HIQG_.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./useEngineFrame-ujTlLQfa.cjs"),n=require("./logger-B9OaKOPw.cjs"),r=require("./runtimeContext-zx_GnKx4.cjs"),i=require("./scopedStore-Px5jL718.cjs"),a=require("./assetStore-DbqlOBWB.cjs"),o=require("./reportError-CkJ7vZsX.cjs"),s=require("./useClicker-0Ln5ZSz0.cjs"),c=require("./CoreBridge-CnLqWZNv.cjs"),l=require("./id-DWiNl1ym.cjs"),u=require("./serviceKey-DwHFFFAA.cjs"),d=require("./weatherStore-DwLl0Jjo.cjs"),f=require("./WorldProps-L3Izutxz.cjs"),p=require("./SaveSystem-DwfckGGo.cjs"),m=require("./clientServices-Bs-PZVqS.cjs"),h=require("./guards-FnxbNibY.cjs"),g=require("./areas-CnRl22N4.cjs"),ee=require("./engine-DLNEnn0R.cjs"),_=require("./useGenericRefs-CZ_HIQG_.cjs"),te=require("./useNavigation-D-c4u9T4.cjs"),ne=require("./runtimeFilter-5rYxTYwr.cjs"),re=require("./WorldContainer-BjZj0uvZ.cjs"),ie=require("./timeStore-Be94nnui.cjs"),v=require("./WorldBridge-DmvFhm9b.cjs"),y=require("./snapshot-BwAZISiG.cjs");let b=require("three");b=e.n(b,1);let x=require("react"),S=require("zustand"),ae=require("@react-three/fiber"),C=require("react/jsx-runtime"),w=require("@react-three/rapier");function oe(e,n,r={},i=t.m){let a=[],o=null,s=i.getGeneration(),c=(e,t)=>{for(let r=0;r<a.length;r++)n(a[r],e,t)},l=()=>{a.length>0||!o||(o(),o=null)};return{add:t=>{a.push(t),s!==i.getGeneration()&&(o=null,s=i.getGeneration()),o??=i.add(e,c,{label:`driver:${e}`,...r});let n=!1;return()=>{if(n)return;n=!0;let e=a.indexOf(t);e>=0&&a.splice(e,1),l()}},size:()=>a.length,dispose:()=>{a.length=0,l()}}}var se=`runtime.saveDiagnostics`,ce=`runtime:saveDiagnostic`,le=`runtime:saveBindingRejected`;function ue(e={}){let t=Math.max(1,e.maxEntries??50),n=[],r=new Set,i=1;return{report(e){let a=fe(e.error),o={...e,id:i,reportedAt:Date.now(),errorMessage:a,message:de(e,a)};i+=1,n.push(o),n.length>t&&n.splice(0,n.length-t);for(let e of r)e(o);return o},getDiagnostics(){return n.map(e=>({...e}))},getLatest(){let e=n[n.length-1];return e?{...e}:void 0},clear(){n.length=0},subscribe(e){return r.add(e),()=>{r.delete(e)}}}}function de(e,t=fe(e.error)){return`Save domain "${e.key}" failed during ${e.phase} for slot "${e.slot}": ${t}`}function fe(e){return e instanceof Error?e.message:typeof e==`string`?e:`Unknown save error`}var T=[`pointerdown`,`keydown`,`touchstart`],E=class{constructor(e={}){this.options=e,this.ctx=null,this.masterGain=null,this.bgmGain=null,this.sfxGain=null,this.bgmInterval=null,this.bgmStep=0,this.currentBgm=null,this.bufferCache=new Map,this.sources=new Map,this.requests=new Map,this.bgmGeneration=0,this.bgmPlayback=new Map,this.resumeAt=new Map,this.playbackEnabled=!0,this.volumes={master:1,bgm:1,sfx:1}}ensure(){if(!this.canPlay())return!1;if(this.ctx)return!0;if(typeof window>`u`||window.AudioContext===void 0)return!1;try{if(this.ctx=new window.AudioContext,this.masterGain=this.ctx.createGain(),this.masterGain.connect(this.ctx.destination),this.bgmGain=this.ctx.createGain(),this.sfxGain=this.ctx.createGain(),this.bgmGain.connect(this.masterGain),this.sfxGain.connect(this.masterGain),this.masterGain.gain.value=this.volumes.master,this.bgmGain.gain.value=this.volumes.bgm,this.sfxGain.gain.value=this.volumes.sfx,this.ctx.state===`suspended`){let e=()=>this.resume();for(let t of T)window.addEventListener(t,e,{once:!0,capture:!0,passive:!0})}return!0}catch{return!1}}resume(){this.ensure()&&this.ctx?.state===`suspended`&&this.ctx.resume().catch(()=>void 0)}suspendPlayback(){this.playbackEnabled=!1,this.stopBgm();for(let e of this.requests.keys())e.abort();for(let e of this.sources.keys())this.stopSource(e)}resumePlayback(){this.playbackEnabled=!0}canPlay(){return this.playbackEnabled&&(this.options.canPlay?.()??!0)}getDiagnostics(){return{contextState:this.ctx?.state??`uninitialized`,bgm:this.currentBgm?.id??null,activeSources:this.sources.size,pendingRequests:this.requests.size,decodedBuffers:this.bufferCache.size}}cancelSfx(){for(let[e,t]of this.requests)t||e.abort();for(let[e,t]of this.sources)t.bgm||this.stopSource(e)}setMasterVolume(e){this.volumes.master=Math.max(0,Math.min(1,e)),this.masterGain&&(this.masterGain.gain.value=this.volumes.master)}setBgmVolume(e){this.volumes.bgm=Math.max(0,Math.min(1,e)),this.bgmGain&&(this.bgmGain.gain.value=this.volumes.bgm)}setSfxVolume(e){this.volumes.sfx=Math.max(0,Math.min(1,e)),this.sfxGain&&(this.sfxGain.gain.value=this.volumes.sfx)}playSfx(e){if(!this.ensure()||!this.ctx||!this.sfxGain)return;if(e.url){this.playFromUrl(e.url,this.sfxGain,e.volume??1);return}let t=this.ctx.createOscillator(),n=this.ctx.createGain();t.type=e.type??`sine`,t.frequency.value=e.freq??440;let r=e.duration??.12,i=this.ctx.currentTime;n.gain.setValueAtTime(0,i),n.gain.linearRampToValueAtTime((e.volume??1)*.3,i+.005),n.gain.exponentialRampToValueAtTime(1e-4,i+r),t.connect(n),n.connect(this.sfxGain),this.trackSource(t,n,!1),t.start(i),t.stop(i+r+.05)}playBgm(e){if(!this.canPlay()||(this.stopBgm(1),!e)||!this.ensure()||!this.ctx||!this.bgmGain)return;if(this.currentBgm=e,e.url){this.playFromUrl(e.url,this.bgmGain,e.volume??1,!0);return}let t=e.pattern??[0,4,7,4],n=e.intervalMs??800,r=e.baseFreq??220;this.bgmStep=0;let i=()=>{if(!this.ctx||!this.bgmGain)return;let i=t[this.bgmStep%t.length]??0,a=r*2**(i/12),o=this.ctx.createOscillator(),s=this.ctx.createGain();o.type=`triangle`,o.frequency.value=a;let c=this.ctx.currentTime;s.gain.setValueAtTime(0,c),s.gain.linearRampToValueAtTime((e.volume??1)*.18,c+.04),s.gain.exponentialRampToValueAtTime(1e-4,c+n/1e3*.95),o.connect(s),s.connect(this.bgmGain),this.trackSource(o,s,!0),o.start(c),o.stop(c+n/1e3+.05),this.bgmStep+=1};i(),this.bgmInterval=window.setInterval(i,n)}stopBgm(e=0){this.bgmGeneration++;for(let[e,t]of this.requests)t&&e.abort();this.bgmInterval!==null&&(window.clearInterval(this.bgmInterval),this.bgmInterval=null),this.currentBgm=null;for(let[t,n]of this.sources)n.bgm&&(this.rememberPlayback(t),e>0&&this.ctx?this.fadeOut(t,n.gain,e):this.stopSource(t))}async dispose(){this.stopBgm();for(let e of this.requests.keys())e.abort();this.requests.clear();for(let e of this.sources.keys())this.stopSource(e);this.bufferCache.clear(),this.bgmGain?.disconnect(),this.sfxGain?.disconnect(),this.masterGain?.disconnect();let e=this.ctx;this.ctx=null,this.bgmGain=this.sfxGain=this.masterGain=null,e&&e.state!==`closed`&&await e.close()}fadeOut(e,t,n){try{let r=this.ctx.currentTime;t.gain.cancelScheduledValues(r),t.gain.setValueAtTime(t.gain.value,r),t.gain.linearRampToValueAtTime(0,r+n),e.stop(r+n)}catch{this.stopSource(e)}}rememberPlayback(e){let t=this.bgmPlayback.get(e);if(!t||!this.ctx)return;this.bgmPlayback.delete(e);let n=t.offset+this.ctx.currentTime-t.startedAt;this.resumeAt.set(t.url,t.duration>0?n%t.duration:0)}trackSource(e,t,n){this.sources.set(e,{gain:t,bgm:n}),e.onended=()=>this.releaseSource(e)}releaseSource(e){let t=this.sources.get(e);t&&(this.sources.delete(e),this.bgmPlayback.delete(e),e.onended=null,e.disconnect(),t.gain.disconnect())}stopSource(e){try{e.stop()}catch{}this.releaseSource(e)}getCurrentBgmId(){return this.currentBgm?.id??null}async playFromUrl(e,t,n,r=!1){let i=this.ctx;if(!i)return;let a=this.bgmGeneration,o=new AbortController;this.requests.set(o,r);let s=()=>this.ctx===i&&!o.signal.aborted&&(!r||a===this.bgmGeneration);try{let a=this.bufferCache.get(e);if(!a){let t=await fetch(e,{signal:o.signal});if(!t.ok||!s())return;let n=await t.arrayBuffer();if(!s()||(a=await i.decodeAudioData(n),!s()))return;this.bufferCache.set(e,a)}if(!s())return;let c=i.createBufferSource();c.buffer=a,c.loop=r;let l=i.createGain(),u=i.currentTime,d=r?this.resumeAt.get(e)??0:0;r?(l.gain.setValueAtTime(0,u),l.gain.linearRampToValueAtTime(n,u+1)):l.gain.value=n,c.connect(l),l.connect(t),this.trackSource(c,l,r);try{r?c.start(u,d):c.start()}catch(e){throw this.releaseSource(c),e}r&&this.bgmPlayback.set(c,{url:e,startedAt:u,offset:d,duration:a.duration??0})}catch{}finally{this.requests.delete(o)}}},D=null;function pe(e={}){return new E(e)}function O(){return D||=new E,D}function me(e=pe()){return(0,S.create)((t,n)=>({masterMuted:!1,bgmMuted:!1,sfxMuted:!1,masterVolume:.6,bgmVolume:.4,sfxVolume:.7,currentBgmId:null,bgmRevision:0,setMaster:e=>{t({masterVolume:Math.max(0,Math.min(1,e))}),n().apply()},setBgm:e=>{t({bgmVolume:Math.max(0,Math.min(1,e))}),n().apply()},setSfx:e=>{t({sfxVolume:Math.max(0,Math.min(1,e))}),n().apply()},toggleMaster:()=>{t({masterMuted:!n().masterMuted}),n().apply()},toggleBgm:()=>{t({bgmMuted:!n().bgmMuted}),n().apply()},toggleSfx:()=>{t({sfxMuted:!n().sfxMuted}),n().apply()},playSfx:t=>{if(!e.canPlay())return;let r=n();r.masterMuted||r.sfxMuted||(n().apply(),e.resume(),e.playSfx(t))},playBgm:r=>{e.canPlay()&&(n().apply(),r&&e.resume(),e.playBgm(r),t(t=>({currentBgmId:e.getCurrentBgmId(),bgmRevision:t.bgmRevision+1})))},stopBgm:()=>{e.stopBgm(1),t(e=>({currentBgmId:null,bgmRevision:e.bgmRevision+1}))},apply:()=>{let t=n(),r=e;r.setMasterVolume(t.masterMuted?0:t.masterVolume),r.setBgmVolume(t.bgmMuted?0:t.bgmVolume),r.setSfxVolume(t.sfxMuted?0:t.sfxVolume)},serialize:()=>{let e=n();return{version:1,masterMuted:e.masterMuted,bgmMuted:e.bgmMuted,sfxMuted:e.sfxMuted,masterVolume:e.masterVolume,bgmVolume:e.bgmVolume,sfxVolume:e.sfxVolume}},prepareHydrate:e=>{if(e==null)return()=>{};if(typeof e!=`object`||e.version!==1||![e.masterMuted,e.bgmMuted,e.sfxMuted].every(e=>typeof e==`boolean`)||![e.masterVolume,e.bgmVolume,e.sfxVolume].every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1))throw TypeError(`Invalid audio snapshot`);let{masterMuted:r,bgmMuted:i,sfxMuted:a,masterVolume:o,bgmVolume:s,sfxVolume:c}=e;return()=>{t({masterMuted:r,bgmMuted:i,sfxMuted:a,masterVolume:o,bgmVolume:s,sfxVolume:c}),n().apply()}},hydrate:e=>n().prepareHydrate(e)()}))}var he=u.n(`audio`),{useStore:ge,useStoreApi:k}=i.t(`useAudioStore`,()=>me(O()),()=>r.n()?.audioStore),A=class{constructor(e){this.target=e,this.listeners=new Set,this.listenerSnapshot=[],this.snapshot=[],this.focused=!0,this.reads=0,this.generation=0,this.polling=!1,this.pollRequested=!1,this.status=`idle`,this.focus=()=>{this.focused=!0,this.wake()},this.blur=()=>{this.focused=!1,this.wake()},this.wake=()=>{this.cancelFrame(),this.poll()},this.poll=()=>{if(this.polling){this.pollRequested=!0;return}if(this.pollRequested=!1,this.frame=void 0,!this.listeners.size)return;this.polling=!0;let e=this.generation,t=[];if(!this.focused||this.target.document.hidden)this.status=`paused`;else if(typeof this.target.navigator.getGamepads!=`function`)this.status=`unsupported`;else try{this.reads++,t=this.target.navigator.getGamepads(),this.status=`ready`}catch{this.status=`blocked`}this.snapshot=t;for(let n of this.listenerSnapshot){if(e!==this.generation)break;this.listeners.has(n)&&this.notify(n.listener,t)}if(this.polling=!1,this.listeners.size&&this.frame===void 0&&(this.pollRequested||e===this.generation&&this.focused&&!this.target.document.hidden&&this.status===`ready`&&t.some(e=>e?.connected))){let e=this.generation,t=this.target.requestAnimationFrame(()=>{this.frame===t&&this.generation===e&&this.poll()});this.frame=t}}}subscribe(e){let t={listener:e},n=this.listeners.size===0;return this.listeners.add(t),this.listenerSnapshot=[...this.listeners],n?(this.focused=this.target.document.hasFocus(),this.target.addEventListener(`gamepadconnected`,this.wake),this.target.addEventListener(`gamepaddisconnected`,this.wake),this.target.addEventListener(`focus`,this.focus),this.target.addEventListener(`blur`,this.blur),this.target.document.addEventListener(`visibilitychange`,this.wake),this.poll()):this.notify(e,this.snapshot),()=>{this.listeners.delete(t)&&(this.listenerSnapshot=[...this.listeners],!this.listeners.size&&(this.generation++,this.cancelFrame(),this.snapshot=[],this.status=`idle`,this.target.removeEventListener(`gamepadconnected`,this.wake),this.target.removeEventListener(`gamepaddisconnected`,this.wake),this.target.removeEventListener(`focus`,this.focus),this.target.removeEventListener(`blur`,this.blur),this.target.document.removeEventListener(`visibilitychange`,this.wake)))}}getStats(){return{subscribers:this.listeners.size,pendingFrames:Number(this.frame!==void 0),reads:this.reads,status:this.status}}notify(e,t){try{e(t)}catch(e){n.t.error(`Gamepad input consumer failed`,e instanceof Error?e:String(e))}}cancelFrame(){this.frame!==void 0&&this.target.cancelAnimationFrame(this.frame),this.frame=void 0}},j=new WeakMap;function M(e=window){let t=j.get(e);return t||(t=new A(e),j.set(e,t)),t}var N=[`A`,`B`,`X`,`Y`,`LB`,`RB`,`LT`,`RT`,`Back`,`Start`,`LeftStick`,`RightStick`,`DPadUp`,`DPadDown`,`DPadLeft`,`DPadRight`,`Guide`],_e={A:`space`,B:`escape`,X:`keyF`,Y:`keyE`,RB:`shift`,Back:`escape`,Start:`escape`,DPadUp:`forward`,DPadDown:`backward`,DPadLeft:`leftward`,DPadRight:`rightward`},ve=(e,t,n)=>Number.isFinite(e)?Math.max(t,Math.min(n,e)):0;function P(e,t,n,r){r.set(ve(e,-1,1),ve(t,-1,1));let i=r.length();return i<=n?r.set(0,0):r.multiplyScalar((Math.min(1,i)-n)/((1-n)*i))}var ye=class{constructor(e,t,r,i={},a,o){this.backend=e,this.scope=t,this.eligible=r,this.source=a,this.onManualMovement=o,this.running=!1,this.blocked=new Uint8Array(17),this.blockedLeft=!1,this.blockedRight=!1,this.armed=!1,this.changes=0,this.selectedIndex=null,this.mappingSupported=!0,this.state={connected:!1,leftStick:new b.Vector2,rightStick:new b.Vector2,triggers:{left:0,right:0},buttons:Object.fromEntries(N.map(e=>[e,!1])),vibration:{weak:0,strong:0}},this.scratchLeft=new b.Vector2,this.scratchRight=new b.Vector2,this.generation=0,this.inputEpoch=0,this.release=()=>{this.inputEpoch++,this.armed=!1,this.deviceId=void 0,this.deviceMapping=void 0,this.selectedIndex=null;let e=this.state.connected,t=this.inputEpoch;this.state.connected=!1,this.state.leftStick.set(0,0),this.state.rightStick.set(0,0),this.state.triggers.left=0,this.state.triggers.right=0;for(let e of N)this.state.buttons[e]=!1;if(this.ownership.release(),e&&t===this.inputEpoch)try{this.publish()}catch(e){n.t.error(`Gamepad state cleanup failed`,e instanceof Error?e:String(e))}},this.options=this.copyOptions(i),this.ownership=_.x(e)}get lookSpeed(){return this.options.lookSpeed??2.5}configure(e){let t=this.copyOptions({...this.options,...e});this.release(),this.options=t,this.refresh()}resume(){this.running=!0,this.refresh()}suspend(){this.running=!1,this.stop()}refresh(){if(!(this.running&&this.options.enabled!==!1&&this.eligible())){this.stop();return}if(this.disconnect)return;let e=this.source??(typeof window>`u`?void 0:M());if(!e)return;let t=++this.generation,n,r=this.scope.onBlur(this.release);this.disconnect=()=>{r(),n?.()};try{let r=e.subscribe(e=>{this.running&&this.generation===t&&this.sample(e)});this.running&&this.generation===t?n=r:r()}catch(e){throw this.stop(),e}}getStats(){return{active:!!this.disconnect,connected:this.state.connected,selectedIndex:this.selectedIndex,mappingSupported:this.mappingSupported,changes:this.changes}}copyOptions(e){if(e.index!==void 0&&(!Number.isInteger(e.index)||e.index<0))throw RangeError(`Gamepad index must be a non-negative integer`);let t=e.deadzone??.15,n=e.lookSpeed??2.5;if(!Number.isFinite(t)||t<0||t>=1)throw RangeError(`Gamepad deadzone must be between 0 and 1`);if(!Number.isFinite(n)||n<0)throw RangeError(`Gamepad look speed must be non-negative`);for(let t of[...Object.values(e.mapping?.axes??{}),...Object.values(e.mapping?.buttons??{})])if(!Number.isInteger(t)||t<0)throw RangeError(`Gamepad mapping indices must be non-negative integers`);return{...e,deadzone:t,lookSpeed:n,...e.bindings?{bindings:{...e.bindings}}:{},...e.mapping?{mapping:{axes:{...e.mapping.axes},buttons:{...e.mapping.buttons}}}:{}}}stop(){let e=this.disconnect;this.disconnect=void 0;let t=++this.generation;try{e?.()}catch(e){n.t.error(`Gamepad source cleanup failed`,e instanceof Error?e:String(e))}t===this.generation&&this.release()}publish(){this.changes++,this.backend.updateGamepad?.(this.state)}sample(e){if(!this.eligible()||!this.scope.isFocused()){this.release();return}let t=this.generation,n,r;for(let t of e)if(!(!t?.connected||this.options.index!==void 0&&t.index!==this.options.index)){if(t.mapping===`standard`||this.options.mapping){n=t;break}r??=t}if(n??=r,this.mappingSupported=!n||n.mapping===`standard`||!!this.options.mapping,!n||!this.mappingSupported){this.release();return}if(this.selectedIndex!==n.index||this.deviceId!==n.id||this.deviceMapping!==n.mapping){let e=this.inputEpoch;if(this.release(),t!==this.generation||this.inputEpoch!==e+1||!this.running)return}this.deviceId=n.id,this.deviceMapping=n.mapping,this.selectedIndex=n.index;let i=this.options.mapping?.axes,a=this.options.deadzone;P(n.axes[i?.leftX??0]??0,n.axes[i?.leftY??1]??0,a,this.scratchLeft),P(n.axes[i?.rightX??2]??0,n.axes[i?.rightY??3]??0,a,this.scratchRight),this.armed||(this.blockedLeft=this.scratchLeft.lengthSq()>0,this.blockedRight=this.scratchRight.lengthSq()>0),this.blockedLeft&&(this.scratchLeft.lengthSq()?this.scratchLeft.set(0,0):this.blockedLeft=!1),this.blockedRight&&(this.scratchRight.lengthSq()?this.scratchRight.set(0,0):this.blockedRight=!1);let o=!this.state.connected||!this.state.leftStick.equals(this.scratchLeft)||!this.state.rightStick.equals(this.scratchRight);this.state.connected=!0,this.state.leftStick.copy(this.scratchLeft),this.state.rightStick.copy(this.scratchRight);let s=this.inputEpoch;for(let e=0;e<N.length;e++){let t=N[e],r=n.buttons[this.options.mapping?.buttons?.[t]??e],i=ve(r?.value,0,1),a=!!r?.pressed||i>=.5;this.armed||(this.blocked[e]=Number(a||i>.01)),!a&&i<=.01&&(this.blocked[e]=0);let s=!this.blocked[e]&&a;if(this.state.buttons[t]!==s&&(this.state.buttons[t]=s,o=!0),t===`LT`||t===`RT`){let n=t===`LT`?`left`:`right`,r=this.blocked[e]?0:i;this.state.triggers[n]!==r&&(this.state.triggers[n]=r,o=!0)}}if(this.armed=!0,!((this.state.leftStick.lengthSq()>0||this.state.buttons.DPadUp||this.state.buttons.DPadDown||this.state.buttons.DPadLeft||this.state.buttons.DPadRight)&&(this.onManualMovement?.(),this.backend.getMouse().isActive&&this.backend.updateMouse({isActive:!1,shouldRun:!1,hasArrived:!1}),t!==this.generation||s!==this.inputEpoch||!this.running))&&(o&&this.publish(),this.scope.isFocused()))for(let e of N){if(t!==this.generation||s!==this.inputEpoch||!this.running)return;let n=this.options.bindings?.[e]===void 0?_e[e]:this.options.bindings[e];n&&this.ownership.set(e,n,this.state.buttons[e])}}},be=class{constructor(){this.counters=new Map,this.sources=new Map}counter(e){if(this.sources.has(e))throw Error(`Engine stat is already a source: ${e}`);let t=this.counters.get(e);return t||this.counters.set(e,t={value:0}),t}source(e,t,n=`cumulative`){if(this.counters.has(e))throw Error(`Engine stat is already a counter: ${e}`);let r={read:t,kind:n,base:n===`cumulative`?t():0};return this.sources.set(e,r),()=>{this.sources.get(e)===r&&this.sources.delete(e)}}snapshot(){let e={};for(let[t,n]of this.counters)e[t]=n.value;for(let[t,n]of this.sources)e[t]=n.kind===`cumulative`?n.read()-n.base:n.read();return e}reset(){for(let e of this.counters.values())e.value=0;for(let e of this.sources.values())e.kind===`cumulative`&&(e.base=e.read())}};function F(e,t,n){return t===n?!0:t<n?e>=t&&e<n:e>=t||e<n}function xe(e,t){return e.weekdays&&e.weekdays.length>0&&!e.weekdays.includes(t.weekday)||e.seasons&&e.seasons.length>0&&!e.seasons.includes(t.season)?!1:F(t.hour,e.startHour,e.endHour)}function Se(e,t){for(let n of e.entries)if(xe(n,t))return{position:n.position,activity:n.activity??`idle`,...n.rotationY===void 0?{}:{rotationY:n.rotationY},...n.dialogTreeId?{dialogTreeId:n.dialogTreeId}:{},source:n};let n=e.defaultEntry;return{position:n?.position??[0,0,0],activity:n?.activity??`idle`,...n?.rotationY===void 0?{}:{rotationY:n.rotationY},...n?.dialogTreeId?{dialogTreeId:n.dialogTreeId}:{},source:null}}var Ce=class{constructor(){this.map=new Map,this.listeners=new Set,this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)})}publish(){for(let e of this.listeners)e()}register(e){this.map.set(e.npcId,e),this.publish()}unregister(e){this.map.delete(e)&&this.publish()}get(e){return this.map.get(e)}resolve(e,t){let n=this.map.get(e);return n?Se(n,t):null}all(){return Array.from(this.map.values())}clear(){this.map.size&&(this.map.clear(),this.publish())}};function we(){return new Ce}var Te=null;function Ee(){return Te||=new Ce,Te}var De=new WeakMap;function Oe(e,t){let n=De.get(e);n||(n=new Map,De.set(e,n));let r=t??e.getDefaultSlot(),i=n.get(r);return i||(i=new ke(e,r,n),n.set(r,i)),i}function I(e,t,n){return Oe(e,t).acquireAutoSave(n)}function L(e,t,n){return Oe(e,t).acquireInitialLoad(n)}var ke=class{constructor(e,t,n){this.system=e,this.slot=t,this.slots=n,this.autoOwners=new Set,this.unload=!1,this.visibility=!1,this.saving=!1,this.pendingSave=!1,this.requestSave=()=>{if(this.canSave()){if(this.saving){this.pendingSave=!0;return}this.saving=!0,this.system.save(this.slot,{skipUnchanged:!0}).catch(e=>{this.system.reportError(e,{source:`save:autosave`,label:this.slot})}).finally(()=>{this.saving=!1;let e=this.pendingSave;this.pendingSave=!1,e&&this.requestSave(),this.prune()})}},this.onVisibility=()=>{document.visibilityState===`hidden`&&this.requestSave()}}acquireAutoSave(e){let t={...e,intervalMs:Number.isFinite(e.intervalMs)?Math.max(1e3,e.intervalMs):3e5};return this.autoOwners.add(t),this.syncResources(),()=>{this.autoOwners.delete(t),this.autoOwners.size===0&&(this.pendingSave=!1),this.syncResources(),this.prune()}}acquireInitialLoad(e){let t={notify:e,delivered:!1},n=this.initialLoad;if(!n)n={controller:new AbortController,owners:new Set([t]),state:`pending`,result:!1},this.initialLoad=n,this.startLoad(n);else{n.owners.add(t);let e=n;Promise.resolve().then(()=>this.notifyLoaded(e,t))}let r=n;return()=>{r.owners.delete(t),r.owners.size===0&&this.initialLoad===r&&(r.controller.abort(),this.initialLoad=void 0,this.prune())}}startLoad(e){this.system.load(this.slot,e.controller.signal).then(t=>{if(!(this.initialLoad!==e||e.controller.signal.aborted)){e.state=`loaded`,e.result=t;for(let t of[...e.owners])this.notifyLoaded(e,t)}}).catch(t=>{this.initialLoad!==e||e.controller.signal.aborted||(e.state=`failed`,this.system.reportError(t,{source:`save:load`,label:this.slot}))})}notifyLoaded(e,t){if(this.initialLoad===e&&e.state===`loaded`&&e.owners.has(t)&&!t.delivered){t.delivered=!0;try{t.notify(e.result)}catch(e){this.system.reportError(e,{source:`save:load-callback`,label:this.slot})}}}canSave(){return this.autoOwners.size>0&&!re.a()&&!this.system.isLoading()&&!this.system.isRestoring()&&(!this.initialLoad||this.initialLoad.state===`loaded`)}syncResources(){let e,t=!1,n=!1;for(let r of this.autoOwners)e=Math.min(e??1/0,r.intervalMs),t||=r.saveOnUnload,n||=r.saveOnVisibilityChange;e!==this.intervalMs&&(this.timer!==void 0&&window.clearInterval(this.timer),this.timer=e===void 0?void 0:window.setInterval(this.requestSave,e),this.intervalMs=e),t!==this.unload&&(t?window.addEventListener(`beforeunload`,this.requestSave):window.removeEventListener(`beforeunload`,this.requestSave),this.unload=t),n!==this.visibility&&(n?document.addEventListener(`visibilitychange`,this.onVisibility):document.removeEventListener(`visibilitychange`,this.onVisibility),this.visibility=n)}prune(){!this.autoOwners.size&&!this.initialLoad&&!this.saving&&this.slots.get(this.slot)===this&&this.slots.delete(this.slot)}};function Ae({enabled:e=!0,intervalMs:t=3e5,slot:n,saveOnUnload:i=!0,saveOnVisibilityChange:a=!0,saveSystem:o}={}){let s=r.n(),c=o??s?.save??p.i();(0,x.useEffect)(()=>{if(e)return z(s,()=>I(c,n,{intervalMs:t,saveOnUnload:i,saveOnVisibilityChange:a}))},[e,t,n,i,a,c,s])}function R(e,t,n){let i=r.n(),a=n??i?.save??p.i(),o=(0,x.useRef)(t);(0,x.useLayoutEffect)(()=>{o.current=t},[t]),(0,x.useEffect)(()=>z(i,()=>L(a,e,e=>o.current?.(e))),[e,a,i])}function z(e,t){let n,r=()=>{!e||e.isActive()?n??=t():(n?.(),n=void 0)},i=e?.subscribeLifecycle(r);return r(),()=>{i?.(),n?.(),n=void 0}}function B(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function je(){return(0,S.create)(e=>({rooms:new Map,portals:new Map,currentRoomId:null,visibleRoomIds:new Set,initializedSceneId:null,registerRoom:t=>e(e=>{let n=new Map(e.rooms);return n.set(t.id,t),{rooms:n}}),unregisterRoom:t=>e(e=>{if(!e.rooms.has(t))return e;let n=new Map(e.rooms);return n.delete(t),{rooms:n,currentRoomId:e.currentRoomId===t?null:e.currentRoomId}}),registerPortal:t=>e(e=>{let n=new Map(e.portals);return n.set(t.id,t),{portals:n}}),unregisterPortal:t=>e(e=>{if(!e.portals.has(t))return e;let n=new Map(e.portals);return n.delete(t),{portals:n}}),setVisibleRooms:(t,n,r)=>e(e=>e.initializedSceneId===t&&e.currentRoomId===n&&B(e.visibleRoomIds,r)?e:{initializedSceneId:t,currentRoomId:n,visibleRoomIds:r}),reset:()=>e({currentRoomId:null,visibleRoomIds:new Set,initializedSceneId:null})}))}var{useStore:Me,useStoreApi:V}=i.t(`useRoomVisibilityStore`,je,()=>r.n()?.roomVisibilityStore),Ne=class{constructor(){this.entries=new Set,this.enabled=!0}register(e){let t={view:e};return this.entries.add(t),this.selected=t,this.enabled&&this.attach(t),()=>{this.entries.delete(t)&&(t.detach?.(),this.selected===t&&(this.selected=[...this.entries].at(-1)))}}attach(e){let t=e.view.surface;if(!t)return;let n=()=>{this.enabled&&(this.selected=e)};t.addEventListener(`pointerdown`,n),t.addEventListener(`focusin`,n),e.detach=()=>{t.removeEventListener(`pointerdown`,n),t.removeEventListener(`focusin`,n)}}current(){return this.enabled?this.selected?.view??null:null}suspend(){this.enabled=!1;for(let e of this.entries)e.detach?.(),delete e.detach}resume(){if(!this.enabled){this.enabled=!0;for(let e of this.entries)this.attach(e)}}dispose(){this.suspend(),this.entries.clear(),this.selected=void 0}},Pe=()=>({objects:[],selectedObjectId:void 0,interactionMode:`view`,showDebugInfo:!1,events:[],loading:!1,error:void 0}),H=e=>({objects:e.objects,selectedObjectId:e.selectedObjectId,interactionMode:e.interactionMode,showDebugInfo:e.showDebugInfo,events:e.events,loading:!1,error:void 0});function Fe({bridge:e,worldId:t,owned:n=!1,active:r=!0}){return(i,a)=>{let o,s=!1,c=(e,n)=>{s&&n===t&&i(H(e))},l=()=>{if(s)return;n&&e.resume();let r=a();if(!e.getEngine(t)){e.register(t,r?{selectedObjectId:r.selectedObjectId,interactionMode:r.interactionMode,showDebugInfo:r.showDebugInfo}:{});let n=e.getEngine(t)?.system;if(r){for(let e of r.objects)n?.addObject(e);for(let e of r.events)n?.processInteraction(e)}}s=!0,o=e.subscribe(c);let i=e.snapshot(t);r&&i&&c(i,t)},u=()=>{if(s)try{let n=e.snapshot(t);n&&c(n,t)}finally{s=!1,o?.(),o=void 0,n&&(e.suspend(),e.dispose())}};r?l():n&&e.suspend();let d=s?e.snapshot(t):null,f=(e,t)=>{if(!s)return e;try{let e=t();return(a().loading||a().error!==void 0)&&i({loading:!1,error:void 0}),e}catch(t){return i({loading:!1,error:t instanceof Error?t.message:String(t)}),e}};return{...d?H(d):Pe(),activateWorldBridge:l,deactivateWorldBridge:u,addObject:n=>f(``,()=>e.addObject(t,n)),removeObject:n=>f(!1,()=>e.getEngine(t)?.system.getObject(n)?(e.removeObject(t,n),!0):!1),updateObject:(n,r)=>f(!1,()=>e.getEngine(t)?.system.getObject(n)?(e.updateObject(t,n,r),!0):!1),selectObject:n=>f(void 0,()=>e.selectObject(t,n)),setInteractionMode:n=>f(void 0,()=>e.setInteractionMode(t,n)),toggleDebugInfo:()=>f(void 0,()=>e.toggleDebugInfo(t)),setLoading:e=>i({loading:e}),setError:e=>i({error:e}),clearEvents:()=>f(void 0,()=>e.clearEvents(t)),getBridge:()=>e,getObjectsInRadius:(n,r)=>s?e.getObjectsInRadius(t,n,r):[],getObjectsByType:n=>s?e.getObjectsByType(t,n):[],raycast:(n,r)=>s?e.raycast(t,n,r):null,interact:(n,r)=>f(void 0,()=>e.interact(t,n,r)),cleanup:()=>{s?f(void 0,()=>e.cleanup(t)):i(Pe())}}}}var U=(...e)=>Fe({bridge:c.n.getOrCreateFor(v.t),worldId:`default`})(...e);function Ie(e=`default`,t=!0){let n=new v.t;return(0,S.create)()(Fe({bridge:n,worldId:e,owned:!0,active:t}))}var Le;function Re(){return r.n()?.worldObjectStore??(Le??=(0,S.create)()(U))}function W(e=e=>e){return(0,S.useStore)(Re(),e)}function ze(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.key==`string`&&typeof t.serialize==`function`&&typeof t.hydrate==`function`}function G(e={}){let t=e.worldId??l.t();if(!t.trim())throw TypeError(`Runtime worldId must not be empty`);let n=`inactive`,r=(t,r)=>{e.onError&&n!==`inactive`?o.n(e.onError,t,r):o.r(t,r)},i=a.t(),u=ie.n(),h=d.n(),re=m.m(),v=m.u(re),y=pe({canPlay:()=>!U.isRestoring()}),b=me(y);y.suspendPlayback();let x=p.x(),S=p.d(),ae=je();S.getState().suspendTransitions();let C=ee.r(m.i({dialogStore:v,emit:(e,t)=>H.context.events.emit(e,t)})),w=new ee.t({registry:C});w.suspend();let oe=e=>{w.dispatch(e).catch(t=>r(t,{source:`gameplay:trigger`,label:e.type}))},de=g.t(e=>oe({type:`enterArea`,areaId:e})),fe,T=s.gr();T.suspend();let E=new s.Bt,D=new _.b(E,T,!1),O=f.M(!1,e=>oe({type:`interaction`,targetId:e.id,action:`interact`})),ge=e.inputExtensionId??`interaction.input`,k=c.a(E,r),A=p.c({store:k,characterStore:x,sceneStore:S,dialogStore:v},!1),j=s.Ht(),M=new ye(E,T,()=>k.getState().mode?.controller===`gamepad`&&k.getState().interaction?.isActive!==!1&&!j.getState().isInEditMode(),e.gamepad===!1?{enabled:!1}:e.gamepad,void 0,()=>{k.getState().automation?.queue.isRunning&&k.getState().stopAutomation(),I.getClickNavigationRoute().length&&I.clearClickNavigationRoute()}),N,_e,ve=()=>{N?.(),N=void 0,_e?.(),_e=void 0,M.suspend()},P=f.f();P.suspend();let F=f.y({active:!1,isCurrent:({instance:e})=>{let t=xe.getState().instances.get(e.id);return!!(t&&t.brain===e.brain&&t.templateId===e.templateId)}}),xe=f.i({onInvalidateBrain:F.release});f._(P,F);let Se=we(),Ce=f.R(),Te=f.Ct(),Ee=f.F(),De=te.a(),Oe=new te.c(e.navigation),I=te.d(),L=new s.pt,ke=Ie(t,!1),Ae=ke.getState().getBridge(),R=new Ne;R.suspend();let z=f.Et({weather:()=>h.getState().current,trample:()=>({position:L.getActiveState().position,isMoving:L.getGameStates().isMoving,isGrounded:L.getActiveState().isGround})});z.suspend();let B=s.Z(u,r);B.suspend();let Me=new be;Me.source(`fixedTicks`,()=>B.clock.tick),Me.source(`clockSystems`,()=>B.clock.systemCount,`gauge`);let V=new f.l(xe,B,{adapters:P,scoped:!0,navigation:Oe}),Pe=ne.d(e.logger),H=ne.l({...e.logger?{logger:e.logger}:{},report:r}),Fe=e.pluginRuntime??`client`,U=e.saveSystem??(e.saveOptions?new p.n({report:r,...e.saveOptions}):p.r({namespace:t,report:r})),Le=ue(e.saveDiagnostics),Re=[...e.saveBindings??[]],W=new Map,G=new Set,Be=new WeakSet,Ve,He,Ue,We=!1,K=!1,q=!1,Ge=!1,J=new Set,Ke=Promise.resolve(),Y=0,qe=new Set,X,Je,Ye,Xe,Ze,Qe=()=>{let e=H.context.input.get(ge);if(!(E.getStats().active&&e===Xe))try{let t=e?.createAdapter();T.releaseFocus(),E.activate(t),Xe=e}catch(e){throw E.suspend(),Xe=void 0,e}},$e=()=>X??={physicsBridge:new s.ut,inputAdapter:E,events:H.context.events,extensionIds:{physics:`gaesup.runtime.physics`,input:ge}},et=()=>{Y++;for(let e of qe)try{e()}catch(e){Pe.warn(`Runtime lifecycle subscriber failed`,{error:e})}};for(let t of ne.t(e.plugins??[],Fe))H.register(t);let Z=e=>{if(W.has(e.key))return;let t=U.register({key:e.key,serialize:()=>e.serialize()??null,hydrate:e.hydrate,...e.prepareHydrate?{prepareHydrate:t=>e.prepareHydrate(t)}:{},...e.owned?{owned:!0}:{},...e.revision?{revision:()=>e.revision()}:{},...e.reset?{reset:()=>e.reset()}:{}});W.set(e.key,t)},tt=()=>{for(let e of H.context.save.list())ze(e.value)&&(Z(e.value),G.add(e.value.key))},nt=()=>{let e=new Set;for(let t of H.context.save.list())if(ze(t.value)&&(e.add(t.value.key),!(G.has(t.value.key)||Be.has(t.value))))try{if(W.has(t.value.key))throw new p.t(t.value.key);Z(t.value),G.add(t.value.key)}catch(e){Be.add(t.value);let n={key:t.value.key,pluginId:t.pluginId,error:e};Pe.warn(`Save binding "${t.value.key}" was rejected after runtime setup.`,n),H.context.events.emit(le,n)}for(let t of G)e.has(t)||(G.delete(t),W.get(t)?.(),W.delete(t))},rt=async()=>{let t=e.assets?.source;t&&await i.getState().loadAssets(t)},it=()=>{H.context.services.register(se,Le,`gaesup.runtime`),We=!0,He=U.subscribeDiagnostics(e=>{let t=Le.report(e);Pe.warn(t.message,t),H.context.events.emit(ce,t)})},at=async e=>{U.cancelPendingLoads();let t=Ue;Ue=void 0,ve(),A.suspend(),D.suspend(),O.getState().suspend(),Ze?.(),Ze=void 0,E.suspend(),Xe=void 0,V.suspend(),P.suspend(),F.suspend(),R.suspend(),z.suspend(),B.suspend(),w.suspend(),T.suspend(),fe?.(),fe=void 0,de.reset(),S.getState().suspendTransitions(),ae.getState().reset(),y.suspendPlayback(),b.getState().stopBgm();let n,r=!1,i=e=>{r||(r=!0,n=e)},a=async e=>{try{await e()}catch(e){i(e)}};t&&await a(t),await a(()=>y.dispose()),await a(()=>ke.getState().deactivateWorldBridge()),I.nextClickNavigationRequest(),await a(()=>I.clearClickNavigationRoute());let o=e?new Set(H.list().filter(e=>e.status===`failed`).map(e=>e.manifest.id)):new Set;await a(()=>H.disposeAll());for(let e of[...H.list()].reverse())(e.status===`ready`||o.has(e.manifest.id))&&await a(()=>H.dispose(e.manifest.id));Ve?.(),Ve=void 0,G.clear(),await a(()=>Oe.dispose()),await a(()=>v.getState().close()),await a(()=>Ce.getState().reset()),await a(()=>Te.getState().reset()),await a(()=>Ee.getState().reset()),await a(()=>k.disposeInteractions());let l=X,u=Je;X=void 0,Je=void 0,l&&await a(()=>l.physicsBridge.dispose()),u&&await a(()=>u.dispose());let d=Ye;Ye=void 0,d&&await a(()=>d.dispose());let f=He;He=void 0,f&&await a(f);let p=[...W.values()];W.clear();for(let e of p)await a(e);We&&(We=!1,await a(()=>{H.context.services.remove(se)})),K&&(K=!1,await a(()=>{H.context.services.remove(s.X)})),q&&(q=!1,await a(()=>{H.context.services.remove(c.i)})),Ge&&(Ge=!1,await a(()=>{H.context.services.remove(s.at)}));for(let e of J)await a(()=>{H.context.services.remove(e)});return J.clear(),r?{failed:!0,error:n}:{failed:!1}},Q=(e,t)=>{H.context.services.register(e,t,`gaesup.runtime`),J.add(e)},ot=async()=>{if(n!==`active`){n=`setting-up`;try{k.activateInteractions(),ke.getState().activateWorldBridge(),H.context.services.register(s.X,u,`gaesup.runtime`),K=!0,H.context.services.register(c.i,k,`gaesup.runtime`),q=!0,H.context.services.register(s.at,{create:$e,inputExtensionId:ge},`gaesup.runtime`),Ge=!0,Q(s.Vt,j),Q(f.r,xe);for(let[e,t]of Object.entries({"gaesup.runtime.npc-brain-adapters":P,"gaesup.runtime.npc-reinforcement":F,"gaesup.runtime.interactables-store":O,"gaesup.runtime.input-actions":D,"gaesup.runtime.gamepad":M,"gaesup.runtime.cinematics":A}))H.context.services.register(e,t,`gaesup.runtime`),J.add(e);Q(he,b),Q(p.v,x),Q(p.u,S),Q(d.t,h),Q(m.l,v);for(let[e,t]of Object.entries({"gaesup.runtime.world-object-store":ke,"gaesup.runtime.world-bridge":Ae,"gaesup.runtime.world-views":R,"gaesup.runtime.input-scope":T,"gaesup.runtime.gameplay-event-registry":C,"gaesup.runtime.gameplay-events":w}))H.context.services.register(e,t,`gaesup.runtime`),J.add(e);it(),H.context.services.register(`gaesup.runtime.save-system`,U,`gaesup.runtime`),J.add(`gaesup.runtime.save-system`);for(let e of Re)Z(e);e.assets?.loadOnCreate&&await rt(),await H.setupAll(),tt(),Ve=H.onLifecycle(nt);let t=`gameplay-events`;W.set(t,U.register({key:t,serialize:()=>w.serialize(),revision:()=>w.revision(),hydrate:e=>w.hydrate(e),prepareHydrate:e=>w.prepareHydrate(e)})),Ue=U.registerRestoreGuard(()=>{let e=Y,t=n===`active`,r=()=>{t&&n===`active`&&Y===e&&(A.resume(),S.getState().resumeTransitions(),w.resume(),V.resume())};try{V.suspend(),A.suspend(),S.getState().suspendTransitions(),y.cancelSfx(),w.suspend()}catch(e){throw r(),e}return r}),Qe(),Ze=H.context.input.subscribe?.(e=>{(e===null||e===ge)&&Qe()}),n=`active`,w.resume(),S.getState().resumeTransitions(),y.resumePlayback(),T.resume(),z.resume(),R.resume(),P.resume(),F.resume(),V.resume(),O.getState().resume(),D.resume(),A.resume(),N=k.subscribe(()=>M.refresh()),_e=j.subscribe(()=>M.refresh()),M.resume();let r=B.clock.addSystem({id:`gameplay-areas`,phase:`postSimulation`,update:()=>de.update(L.getActiveState().position)}),i=u.getState().addListener(e=>{e.kind===`newHour`&&oe({type:`timeChanged`,hour:e.time.hour})});fe=()=>{r(),i()},B.resume(),et()}catch(e){throw await at(!0),n=`inactive`,e}}},st=async()=>{if(ve(),A.suspend(),D.suspend(),O.getState().suspend(),Ze?.(),Ze=void 0,E.suspend(),V.suspend(),P.suspend(),F.suspend(),R.suspend(),Ae.suspend(),z.suspend(),B.suspend(),w.suspend(),T.suspend(),S.getState().suspendTransitions(),ae.getState().reset(),y.suspendPlayback(),b.getState().stopBgm(),n===`inactive`){let e=await at(!1);if(e.failed)throw e.error;return}n=`disposing`,et();let e=await at(!1);if(n=`inactive`,e.failed)throw e.error},ct=e=>{let t=Ke.then(e);return Ke=t.catch(()=>void 0),t};return{worldId:t,reportError:r,assetStore:i,dialogRegistry:re,store:k,timeStore:u,clockLoop:B,stats:Me,inputScope:T,inputActions:D,gamepad:M,interactablesStore:O,cinematics:A,navigation:Oe,clickNavigation:I,stateManager:L,inputAdapter:E,grassManager:z,worldBridge:Ae,worldObjectStore:ke,worldViews:R,weatherStore:h,dialogStore:v,audioEngine:y,audioStore:b,characterStore:x,sceneStore:S,roomVisibilityStore:ae,gameplayEventRegistry:C,gameplayEvents:w,gameplayAreas:de,buildingStore:j,npcStore:xe,npcScheduler:Se,npcSimulation:V,npcBrainAdapters:P,npcReinforcement:F,buildingRenderStore:Ce,buildingCullingStore:Te,buildingVisibilityStore:Ee,navigationObstacles:De,get motions(){return $e()},get motionBridge(){return Je??=new s.ur},get animationBridge(){return Ye??=new s.pr},isActive:()=>n===`active`,getLifecycleRevision:()=>Y,subscribeLifecycle:e=>(qe.add(e),()=>{qe.delete(e)}),pluginRuntime:Fe,plugins:H,save:U,saveDiagnostics:Le,loadAssets:rt,getService:e=>H.context.services.get(e),requireService:e=>H.context.services.require(e),setup:()=>ct(ot),dispose:()=>(U.cancelPendingLoads(),ct(st))}}var Be={isRiderOn:!1,position:(0,w.vec3)(),rotation:(0,w.euler)(),offset:(0,w.vec3)(),visible:!0};function Ve(){let e=s.mr(),t=c.s(),{gameStates:n,updateGameStates:r,activeState:i}=s.Y(),a=c.o(e=>e.rideable),o=c.o(e=>e.urls),l=c.o(e=>e.setMode),u=c.o(e=>e.setRideable),d=c.o(e=>e.setUrls),f=(0,x.useCallback)(e=>e===`airplane`?`airplane`:`vehicle`,[]),p=(0,x.useCallback)(e=>{let t={},n=e.ridingUrl??o.characterUrl;if(typeof n==`string`&&n.length>0&&(t.ridingUrl=n),e.objectType===`airplane`){t.airplaneUrl=e.url??``,d(t);return}e.objectType&&(t.vehicleUrl=e.url??``),d(t)},[d,o]),m=(0,x.useCallback)(e=>{let t=a[e];if(!t?.position)return;let n=i.position.clone().add(t.landingOffset??(0,w.vec3)());r({canRide:!1,isRiding:!1,currentRideable:void 0}),u(e,{...t,isOccupied:!1,isRiderOn:!1,visible:!0,position:n}),t.onExit?.(e)},[a,r,u,i.position]),h=(0,x.useCallback)(async()=>{if(n.canRide&&n.nearbyRideable&&!n.isRiding){let{objectkey:e,objectType:t}=n.nearbyRideable,i=a[e];if(!i||i.enableRiding===!1||i.isOccupied)return;p(i),l({type:f(t)}),r({currentRideable:n.nearbyRideable,isRiding:!0,canRide:!1,nearbyRideable:void 0}),u(e,{...i,isOccupied:!0,isRiderOn:!0,visible:!1}),i.onRide?.(e)}},[n.canRide,n.nearbyRideable,n.isRiding,a,p,l,f,r,u]),g=(0,x.useCallback)(async()=>{n.isRiding&&n.currentRideable&&(m(n.currentRideable.objectkey),l({type:`character`}),r({isRiding:!1,currentRideable:void 0}))},[n.isRiding,n.currentRideable,m,l,r]);return(0,x.useEffect)(()=>{let t=e.listen(`keydown`,e=>{e.defaultPrevented||e.isComposing||e.ctrlKey||e.metaKey||e.altKey||e.code===`KeyF`&&(e.repeat||(n.canRide&&n.nearbyRideable?(e.preventDefault(),h()):n.isRiding&&(e.preventDefault(),g())))});return()=>t()},[e,n.canRide,n.nearbyRideable,n.isRiding,h,g]),{initRideable:(0,x.useCallback)(e=>{let n=t.getState().rideable[e.objectkey];u(e.objectkey,{...n?{}:Be,...e})},[u,t]),updateRideable:(0,x.useCallback)(e=>{u(e.objectkey,e)},[u,t]),getRideable:e=>a[e],onRideableNear:(0,x.useCallback)(async(e,t)=>{if((e.other.rigidBodyObject&&e.other.rigidBodyObject.name===`character`||e.other.rigidBodyObject&&!e.other.rigidBodyObject.name||e.other.rigidBody)&&!n.isRiding){if(!t.objectType||t.enableRiding===!1||t.isOccupied)return;r({nearbyRideable:{id:t.objectkey,objectkey:t.objectkey,objectType:t.objectType,...t.position?{position:t.position.clone()}:{},...t.rotation?{rotation:t.rotation.clone()}:{},type:`rideable`,maxSpeed:t.maxSpeed??(t.objectType===`airplane`?38:18),acceleration:t.acceleration??(t.objectType===`airplane`?14:9),deceleration:t.deceleration??8,isOccupied:!1,controls:{forward:!1,backward:!1,left:!1,right:!1,brake:!1},name:t.objectType===`vehicle`?`Vehicle`:t.objectType===`airplane`?`Airplane`:`Rideable`,...t.rideMessage?{rideMessage:t.rideMessage}:{},...t.exitMessage?{exitMessage:t.exitMessage}:{},...t.displayName?{displayName:t.displayName}:{}},canRide:!0})}},[n.isRiding,r]),onRideableLeave:(0,x.useCallback)(async e=>{(e.other.rigidBodyObject&&e.other.rigidBodyObject.name===`character`||e.other.rigidBodyObject&&!e.other.rigidBodyObject.name||e.other.rigidBody)&&r({nearbyRideable:void 0,canRide:!1})},[r]),enterRideable:h,exitRideable:g,landing:m}}function He(e,t,n){let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(`${n} timed out after ${t}ms`)),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))}function Ue(e,t,n,r=10){let i=Number.isNaN(r)?10:Math.max(1,Math.floor(r)),a=`${t}_`,o=e=>Number(e.slice(a.length));return e.filter(e=>e!==n&&e.startsWith(a)&&/^\d+$/.test(e.slice(a.length))).sort((e,t)=>o(t)-o(e)).slice(i-1)}var We=`1.0.0`,K=`gaesup_world_save_`,q=`base64-json:`,Ge=`gaesup-world:gzip-json:v1`,J=5e3,Ke=class{constructor(e={}){this.version=e.version??We,this.storage=e.storage,this.fileWriter=e.fileWriter,this.now=e.now??Date.now,this.maxSlotsPerWorld=e.maxSlotsPerWorld??10}async save(e,t,n={}){try{let r=this.createSaveData(e,t,n),i=n.compress?await He(this.compressData(r),J,`save`):JSON.stringify(r);return this.writeSlot(r,i),{success:!0,data:r}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Unknown error occurred`}}}async load(e,t={}){try{let n=`${K}${e}`,r=this.getStorage().getItem(n);if(!r)throw Error(`Save data not found: ${e}`);let i=await He(this.parseStoredSaveData(r),J,`load`);if(!this.validateSaveData(i))throw Error(`Invalid save data format`);return{success:!0,data:{...i,world:this.filterWorldData(i.world,t)}}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to load save data`}}}async saveToFile(e,t,n,r={}){try{let i=this.createSaveData(e,n,r);return await this.writeFile(t,i),{success:!0,data:i}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to save file`}}}async loadFromFile(e,t={}){try{let n=await e.text(),r=JSON.parse(n);if(!this.validateSaveData(r))throw Error(`Invalid save file format`);return{success:!0,data:{...r,world:this.filterWorldData(r.world,t)}}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to load file`}}}listSaves(){let e=[],t;try{t=this.getStorage()}catch(t){return o.r(t,{source:`save:list`}),e}for(let n=0;n<t.length;n++){let r=t.key(n);if(r&&r.startsWith(K))try{let n=r.substring(18),i=t.getItem(r);if(i){let t=this.parseStoredSaveDataSync(i);e.push({id:n,timestamp:t.timestamp,...t.metadata?{metadata:t.metadata}:{}})}}catch(e){o.r(e,{source:`save:list`,label:r})}}return e.sort((e,t)=>t.timestamp-e.timestamp)}deleteSave(e){try{let t=`${K}${e}`;return this.getStorage().removeItem(t),!0}catch(t){return o.r(t,{source:`save:delete`,label:e}),!1}}filterWorldData(e,t){let n={...e};return t.includeBuildings===!1&&(n.buildings={wallGroups:[],tileGroups:[],blocks:[],meshes:[]}),t.includeNPCs===!1&&(n.npcs=[]),t.includeEnvironment===!1&&(n.environment={lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}}),t.includeCamera===!1&&delete n.camera,n}createSaveData(e,t,n={}){let r=this.now();return{version:this.version,timestamp:r,world:this.filterWorldData(e,n),...t?{metadata:{...t,createdAt:t.createdAt||r,updatedAt:r}}:{}}}getStorage(){if(this.storage)return this.storage;if(typeof localStorage>`u`)throw Error(`Legacy save storage is not available in this environment`);return localStorage}async writeFile(e,t){if(this.fileWriter){await this.fileWriter(e,t);return}if(typeof document>`u`||typeof URL>`u`||typeof Blob>`u`)throw Error(`File download is not available in this environment`);let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e.endsWith(`.json`)?e:`${e}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}writeSlot(e,t){let n=`${e.world.id}_${e.timestamp}`,r=this.getStorage();try{r.setItem(`${K}${n}`,t)}catch(e){throw e instanceof Error&&e.name===`QuotaExceededError`?Error(`Storage quota exceeded. Please delete some saves.`):e}let i=[];for(let e=0;e<r.length;e++){let t=r.key(e);t?.startsWith(K)&&i.push(t.slice(18))}for(let t of Ue(i,e.world.id,n,this.maxSlotsPerWorld))r.removeItem(`${K}${t}`)}async compressData(e){let t=JSON.stringify(e);if(!Xe())return`${q}${Y(Je(t))}`;let n=await this.gzipBytes(Je(t)),r={encoding:Ge,version:e.version,timestamp:e.timestamp,worldId:e.world.id,worldName:e.world.name,...e.metadata?{metadata:e.metadata}:{},payload:Y(n)};return JSON.stringify(r)}async decompressData(e){let t=qe(e),n=Ye(await this.gunzipBytes(t));return JSON.parse(n)}async parseStoredSaveData(e){if(e.startsWith(`{`)){let t=JSON.parse(e);return Qe(t)?this.decompressData(t.payload):t}return e.startsWith(q)?X(e.slice(12)):X(e)}parseStoredSaveDataSync(e){if(e.startsWith(`{`)){let t=JSON.parse(e);return Qe(t)?{version:t.version,timestamp:t.timestamp,world:{id:t.worldId,name:t.worldName,buildings:{wallGroups:[],tileGroups:[],blocks:[],meshes:[]},npcs:[],environment:{lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}}},...t.metadata?{metadata:t.metadata}:{}}:t}return e.startsWith(q)?X(e.slice(12)):X(e)}async gzipBytes(e){if(!Xe())return e;let t=new Blob([e]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async gunzipBytes(e){if(!Ze())return e;let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}validateSaveData(e){return typeof e==`object`&&!!e&&`version`in e&&`timestamp`in e&&`world`in e&&typeof e.version==`string`&&typeof e.timestamp==`number`&&e.world&&typeof e.world.id==`string`&&typeof e.world.name==`string`}};function Y(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function qe(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function X(e){return JSON.parse(Ye(qe(e)))}function Je(e){if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function Ye(e){if(typeof TextDecoder<`u`)return new TextDecoder().decode(e);let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return decodeURIComponent(escape(t))}function Xe(){return typeof CompressionStream<`u`&&typeof Blob<`u`&&typeof Response<`u`&&typeof new Blob().stream==`function`}function Ze(){return typeof DecompressionStream<`u`&&typeof Blob<`u`&&typeof Response<`u`&&typeof new Blob().stream==`function`}function Qe(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.encoding===Ge&&typeof t.version==`string`&&typeof t.timestamp==`number`&&typeof t.worldId==`string`&&typeof t.worldName==`string`&&typeof t.payload==`string`}var $e={lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}};function et(e){return typeof structuredClone==`function`?structuredClone(e):JSON.parse(JSON.stringify(e))}function Z(e){return Array.isArray(e)?e.map(e=>et(e)):[]}function tt(e,t){let n=e[t];return h.r(n)?n:void 0}function nt(e){if(Array.isArray(e)&&e.length>=3){let[t,n,r]=e;if(typeof t==`number`&&typeof n==`number`&&typeof r==`number`)return{x:t,y:n,z:r}}if(h.r(e)&&typeof e.x==`number`&&typeof e.y==`number`&&typeof e.z==`number`)return{x:e.x,y:e.y,z:e.z}}function rt(e){if(!h.r(e)||typeof e.id!=`string`)return null;let t=nt(e.position)??{x:0,y:0,z:0},n=nt(e.rotation)??{x:0,y:0,z:0},r=h.r(e.metadata)?et(e.metadata):void 0,i=h.r(e.behavior)?e.behavior:void 0,a=i&&typeof i.mode==`string`?i.mode:void 0;return{id:e.id,name:typeof e.name==`string`?e.name:e.id,position:t,rotation:n,...typeof e.modelUrl==`string`?{modelUrl:e.modelUrl}:{},...a?{behavior:a}:{},...r?{metadata:r}:{}}}function it(e){let t=e?.instances;return Array.isArray(t)?t.map(rt).filter(e=>e!==null):[]}function at(e){if(!e)return;let t=h.r(e.mode)?e.mode:void 0,n=typeof e.mode==`string`?e.mode:t&&typeof t.control==`string`?t.control:`default`,r=h.r(e.settings)?et(e.settings):h.r(e.cameraOption)?et(e.cameraOption):void 0;return{mode:n,...r?{settings:r}:{}}}function Q(e,t,n){let r=tt(e,`building`),i=at(tt(e,`camera`));return{id:t,name:n,buildings:{wallGroups:Z(r?.wallGroups),tileGroups:Z(r?.tileGroups),blocks:Z(r?.blocks),meshes:Z(r?.meshes)},npcs:it(tt(e,`npc`)),environment:$e,...i?{camera:i}:{}}}function ot(e){let t=e.slice(e.lastIndexOf(`_`)+1),n=Number(t);return Number.isFinite(n)?n:Date.now()}function st(e){let t=e.lastIndexOf(`_`);return t>0?e.slice(0,t):e}function ct(e,t){if(e)return{...e,createdAt:e.createdAt??t,updatedAt:e.updatedAt??t}}function lt(e,t,n,r){let i=ot(t),a=st(t),o={version:`1.0.0`,timestamp:i,world:Q(y.r(e),a,n??a)},s=ct(r,i);return s?{...o,metadata:s}:o}var ut=()=>({});function dt(e,t,n){let{buildingStore:r,npcStore:i,cameraStore:a}=e;if(!r)throw Error(`Building store not initialized`);let o=r.getState(),s=a?.getState(),c=s?{mode:s.mode,...s.settings?{settings:s.settings}:{}}:void 0;return{id:t,name:n,buildings:{wallGroups:Array.from(o.wallGroups.values()),tileGroups:Array.from(o.tileGroups.values()),blocks:Array.from(o.blocks),meshes:Array.from(o.meshes.values())},npcs:i?Array.from(i.getState().instances.values()):[],environment:$e,...c?{camera:c}:{}}}function ft(e,t){if(!e||!t)return;let n=e.getState();if(typeof n.hydrate==`function`){n.hydrate(t);return}if(e.setState){e.setState({wallGroups:new Map(t.wallGroups.map(e=>[e.id,e])),tileGroups:new Map(t.tileGroups.map(e=>[e.id,e])),meshes:new Map(t.meshes.map(e=>[e.id,e])),blocks:[...t.blocks??[]]});return}n.wallGroups.clear(),n.tileGroups.clear(),n.meshes.clear(),n.blocks=[],t.wallGroups.forEach(e=>{n.wallGroups.set(e.id,e)}),t.tileGroups.forEach(e=>{n.tileGroups.set(e.id,e)}),t.meshes.forEach(e=>{n.meshes.set(e.id,e)}),n.blocks=[...t.blocks??[]]}function pt(e,t){if(!e||!t)return;if(e.setState){e.setState({instances:new Map(t.map(e=>[e.id,e]))});return}let n=e.getState();n.instances.clear(),t.forEach(e=>{n.instances.set(e.id,e)})}function mt(e,t){e&&t&&e.setState({mode:t.mode,settings:t.settings||{}})}function ht(e,t){ft(e.buildingStore,t.buildings),pt(e.npcStore,t.npcs),mt(e.cameraStore,t.camera)}function gt(e){return e.replace(/\.json$/i,``)}function _t(e){return h.r(e)&&typeof e.version==`number`&&typeof e.savedAt==`number`&&h.r(e.domains)}function vt(e){return h.r(e)&&e.kind===`gaesup.save-system`&&typeof e.worldId==`string`&&typeof e.worldName==`string`&&_t(e.blob)}async function yt(e){return(await e.list()).map(e=>({id:e,timestamp:ot(e)})).sort((e,t)=>t.timestamp-e.timestamp)}async function bt(e,t,n,r){let i=Ue(await e.list(),t,n,r);await Promise.all(i.map(t=>e.remove(t)))}function xt(e,t){if(typeof document>`u`||typeof URL>`u`||typeof Blob>`u`)throw Error(`File download is not available in this environment`);let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e.endsWith(`.json`)?e:`${e}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function St(e){let t=JSON.parse(await e.text());if(vt(t)||_t(t))return t;throw Error(`Invalid SaveSystem file format`)}function Ct(e={}){let t=e.getStores??ut,n=e.saveSystem,{maxSlotsPerWorld:r}=e;return(i,a)=>({saveLoadManager:e.saveLoadManager??new Ke(r===void 0?{}:{maxSlotsPerWorld:r}),currentSaveId:null,saves:[],isSaving:!1,isLoading:!1,lastError:null,saveWorld:async(e,o,s,c)=>{i({isSaving:!0,lastError:null});try{if(n){let t=`${e}_${Date.now()}`;await n.save(t),await bt(n,e,t,r),i({currentSaveId:t,saves:await yt(n)});return}let l=dt(t(),e,o),u=await a().saveLoadManager.save(l,s,c);if(u.success)i({currentSaveId:`${e}_${u.data.timestamp}`}),a().refreshSaveList();else throw Error(u.error)}catch(e){throw i({lastError:e instanceof Error?e.message:`Save failed`}),e}finally{i({isSaving:!1})}},loadWorld:async(e,r)=>{i({isLoading:!0,lastError:null});try{if(n){if(!await n.load(e))throw Error(`Save data not found: ${e}`);return i({currentSaveId:e}),lt(n,e)}let o=await a().saveLoadManager.load(e,r);if(o.success&&o.data)return ht(t(),o.data.world),i({currentSaveId:e}),o.data;throw Error(o.error)}catch(e){return i({lastError:e instanceof Error?e.message:`Load failed`}),null}finally{i({isLoading:!1})}},saveToFile:async(e,r,o,s,c)=>{i({isSaving:!0,lastError:null});try{if(n){xt(o,{kind:`gaesup.save-system`,version:1,worldId:e,worldName:r,blob:n.createBlob(o),...s?{metadata:s}:{}});return}let i=dt(t(),e,r),l=await a().saveLoadManager.saveToFile(i,o,s,c);if(!l.success)throw Error(l.error)}catch(e){throw i({lastError:e instanceof Error?e.message:`Save to file failed`}),e}finally{i({isSaving:!1})}},loadFromFile:async(e,r)=>{i({isLoading:!0,lastError:null});try{if(n){let t=await St(e),r=vt(t)?t.blob:t;n.hydrateBlob(r,e.name);let i=vt(t)?t.worldId:gt(e.name),a=vt(t)?t.worldName:i,o=r.savedAt,s={version:String(r.version),timestamp:o,world:Q(r.domains,i,a)},c=vt(t)?ct(t.metadata,o):void 0;return c?{...s,metadata:c}:s}let i=await a().saveLoadManager.loadFromFile(e,r);if(i.success&&i.data)return ht(t(),i.data.world),i.data;throw Error(i.error)}catch(e){return i({lastError:e instanceof Error?e.message:`Load from file failed`}),null}finally{i({isLoading:!1})}},refreshSaveList:()=>{if(n){yt(n).then(e=>i({saves:e})).catch(e=>{o.r(e,{source:`save:list`}),i({lastError:e instanceof Error?e.message:`Failed to list saves`})});return}i({saves:a().saveLoadManager.listSaves()})},deleteSave:e=>{if(n){(async()=>{try{await n.remove(e),i({saves:await yt(n),...a().currentSaveId===e?{currentSaveId:null}:{}})}catch(t){o.r(t,{source:`save:delete`,label:e}),i({lastError:t instanceof Error?t.message:`Failed to delete save`})}})();return}a().saveLoadManager.deleteSave(e)&&(a().refreshSaveList(),a().currentSaveId===e&&i({currentSaveId:null}))},clearError:()=>{i({lastError:null})}})}var wt=Ct();function Tt({object:e,selected:t=!1,onSelect:n,showDebugInfo:r=!1}){let i=_.t(),a=e.metadata?.airplaneUrl??e.metadata?.modelUrl,o=typeof a==`string`?a:void 0;if(typeof o!=`string`||o.length===0)return null;let c=e.metadata?.ridingUrl,l=typeof c==`string`?c:void 0,u=e.metadata?.currentAnimation,d=typeof u==`string`?u:`idle`;return(0,C.jsx)(s.n,{url:o,isActive:!1,componentType:`airplane`,name:`active-airplane-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,currentAnimation:d,...l?{ridingUrl:l}:{},ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,userData:{id:e.id,type:`active`,subType:`airplane`,health:e.health,maxHealth:e.maxHealth,energy:e.energy,maxEnergy:e.maxEnergy},onCollisionEnter:()=>{n&&n(e.id)},children:t&&r&&(0,C.jsxs)(`mesh`,{position:[0,3,0],children:[(0,C.jsx)(`boxGeometry`,{args:[.5,.5,.5]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#00ffff`,transparent:!0,opacity:.6})]})})}function Et({object:e,selected:t=!1,onSelect:n,showDebugInfo:r=!1}){let i=_.t();(0,x.useEffect)(()=>{i.rigidBodyRef&&i.rigidBodyRef.current&&i.rigidBodyRef.current.setEnabledRotations(!1,!1,!1,!1)},[i.rigidBodyRef]);let a=e.metadata?.characterUrl;if(typeof a!=`string`||a.length===0)return null;let o=e.metadata?.currentAnimation,c=typeof o==`string`?o:`idle`,l=e.metadata?.nameTag,u=typeof l==`string`?l:void 0;return(0,C.jsx)(s.n,{url:a,isActive:!1,componentType:`character`,name:`active-character-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,currentAnimation:c,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,userData:{id:e.id,type:`active`,subType:`character`,health:e.health,maxHealth:e.maxHealth,energy:e.energy,maxEnergy:e.maxEnergy,nameTag:u},onCollisionEnter:()=>{n&&n(e.id)},children:t&&r&&(0,C.jsxs)(`mesh`,{position:[0,3,0],children:[(0,C.jsx)(`boxGeometry`,{args:[.5,.5,.5]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#ff0000`,transparent:!0,opacity:.6})]})})}function Dt({object:e,selected:t=!1,onSelect:n,showDebugInfo:r=!1}){let i=_.t(),a=e.metadata?.vehicleUrl??e.metadata?.modelUrl,o=typeof a==`string`?a:void 0;if(typeof o!=`string`||o.length===0)return null;let c=e.metadata?.ridingUrl,l=typeof c==`string`?c:void 0,u=e.metadata?.currentAnimation,d=typeof u==`string`?u:`idle`;return(0,C.jsx)(s.n,{url:o,isActive:!1,componentType:`vehicle`,name:`active-vehicle-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,currentAnimation:d,...l?{ridingUrl:l}:{},ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,userData:{id:e.id,type:`active`,subType:`vehicle`,health:e.health,maxHealth:e.maxHealth,energy:e.energy,maxEnergy:e.maxEnergy},onCollisionEnter:()=>{n&&n(e.id)},children:t&&r&&(0,C.jsxs)(`mesh`,{position:[0,3,0],children:[(0,C.jsx)(`boxGeometry`,{args:[.5,.5,.5]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#0000ff`,transparent:!0,opacity:.6})]})})}function Ot({objects:e,selectedId:t,onSelect:n,showDebugInfo:r=!1}){let{gameStates:i}=s.Y(),a=c.o(e=>e.mode);return(0,C.jsx)(`group`,{name:`active-objects`,children:e.map(e=>{let o=e.id===t;if(e.type===`character`&&i?.isRiding&&a?.type!==`character`)return null;switch(e.type){case`vehicle`:return(0,C.jsx)(Dt,{object:e,selected:o,...n?{onSelect:n}:{},showDebugInfo:r},e.id);case`airplane`:return(0,C.jsx)(Tt,{object:e,selected:o,...n?{onSelect:n}:{},showDebugInfo:r},e.id);case`character`:return(0,C.jsx)(Et,{object:e,selected:o,...n?{onSelect:n}:{},showDebugInfo:r},e.id);default:return null}})})}function kt(e){let{children:t,visible:n=!0,...r}=e,i=_.t();return(0,C.jsx)(`group`,{visible:n,children:(0,C.jsx)(s.n,{...r,url:r.url||``,isActive:!1,componentType:`vehicle`,name:r.name??`vehicle`,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,children:t})})}function At(e){let{children:t,visible:n=!0,...r}=e,i=_.t();return(0,C.jsx)(`group`,{visible:n,children:(0,C.jsx)(s.n,{...r,url:r.url||``,isActive:!1,componentType:`airplane`,name:r.name??`airplane`,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,children:t})})}function jt(e){let{children:t,visible:n=!0,...r}=e,i=_.t();(0,x.useEffect)(()=>{i.rigidBodyRef&&i.rigidBodyRef.current&&i.rigidBodyRef.current.setEnabledRotations(!1,!1,!1,!1)},[i.rigidBodyRef]);let a=r.controllerOptions??{lerp:{cameraTurn:1,cameraPosition:1}};return(0,C.jsx)(`group`,{visible:n,children:(0,C.jsx)(s.n,{...r,url:r.url||``,isActive:!1,componentType:`character`,controllerOptions:a,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,children:t})})}var Mt=22500,Nt=(0,x.memo)(function({object:e,isSelected:t,onSelect:n,showDebugInfo:r=!1,enableInteraction:i=!0}){let a=_.t(),o=e.metadata?.modelUrl,c=typeof o==`string`?o:void 0,l=(0,x.useCallback)(()=>{i&&e.interactable&&n&&n(e.id)},[i,e.interactable,e.id,n]),u=(0,x.useCallback)(t=>{i&&e.interactable&&(t.stopPropagation(),document.body.style.cursor=`pointer`)},[i,e.interactable]),d=(0,x.useCallback)(()=>{document.body.style.cursor=`default`},[]);return c?(0,C.jsx)(s.n,{url:c,isActive:!1,componentType:e.type,name:`passive-${e.type}-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,userData:{id:e.id,type:`passive`,subType:e.type,interactable:e.interactable,onNear:e.metadata?.onNear,onLeave:e.metadata?.onLeave,onInteract:e.metadata?.onInteract},onCollisionEnter:()=>{i&&e.interactable&&n&&n(e.id)},children:t&&r&&(0,C.jsxs)(`mesh`,{position:[0,3,0],children:[(0,C.jsx)(`boxGeometry`,{args:[.5,.5,.5]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#00ff00`,transparent:!0,opacity:.6})]})}):(0,C.jsxs)(w.RigidBody,{type:`fixed`,position:e.position,rotation:e.rotation,colliders:!1,children:[(0,C.jsx)(w.CapsuleCollider,{args:[1,.5],position:[0,1,0]}),(0,C.jsx)(`group`,{scale:e.scale,onClick:l,onPointerEnter:u,onPointerLeave:d})]})}),Pt=(0,x.memo)(function({objects:e,selectedId:n,onSelect:r,showDebugInfo:i=!1,enableInteraction:a=!0}){let[o,s]=(0,x.useState)(()=>new Set),c=(0,x.useRef)(0),l=(0,ae.useThree)(e=>e.get);t.t(`effects`,t=>{if(c.current+=t,c.current<.5)return;c.current=0;let n=l().camera.position,r=new Set;for(let t of e){let e=t.position.x,i=t.position.y,a=t.position.z,o=e-n.x,s=i-n.y,c=a-n.z;o*o+s*s+c*c<=Mt&&r.add(t.id)}(r.size!==o.size||[...r].some(e=>!o.has(e)))&&s(r)},{label:`world:passive-objects-lod`});let u=(0,x.useMemo)(()=>e.filter(e=>o.has(e.id)).map(e=>(0,C.jsx)(Nt,{object:e,isSelected:e.id===n,...r?{onSelect:r}:{},showDebugInfo:i,enableInteraction:a},e.id)),[e,n,r,i,a,o]);return(0,C.jsx)(`group`,{name:`passive-objects`,children:u})});function Ft(e){let{states:t}=e;return!t||!t.canRide&&!t.isRiding?null:(0,C.jsx)(It,{...e})}function $(...e){return e.filter(Boolean).join(` `)}function It({states:e,actionKey:t=`F`,unstyled:n=!1,className:r,classNames:i,styles:a,labels:o}){let s=e.nearbyRideable??e.currentRideable;if(!s)return null;let c=o?.ride?.(s)??s.rideMessage??`Press ${t} to ride ${s.displayName??s.name??`vehicle`}`,l=o?.exit?.(s)??s.exitMessage??`Press ${t} to exit`,u=e.isRiding?l:c,d=$(!n&&`rideable-ui-container`,i?.root,r),f=$(!n&&`rideable-message-box`,i?.box),p=$(!n&&`rideable-message`,i?.message),m=$(!n&&`rideable-key`,i?.key),h=$(!n&&`rideable-stats`,i?.stats),g=$(!n&&`rideable-stat`,i?.stat),ee=$(!n&&`rideable-stat__label`,i?.statLabel),_=$(!n&&`rideable-stat__value`,i?.statValue);return(0,C.jsx)(`div`,{className:d||void 0,style:a?.root,children:(0,C.jsxs)(`div`,{className:f||void 0,style:a?.box,children:[(0,C.jsx)(`kbd`,{className:m||void 0,style:a?.key,children:t}),(0,C.jsx)(`div`,{className:p||void 0,style:a?.message,children:u}),(0,C.jsxs)(`div`,{className:h||void 0,style:a?.stats,children:[(0,C.jsxs)(`div`,{className:g||void 0,style:a?.stat,children:[(0,C.jsx)(`span`,{className:ee||void 0,style:a?.statLabel,children:o?.speed??`속도`}),(0,C.jsx)(`span`,{className:_||void 0,style:a?.statValue,children:s.maxSpeed})]}),(0,C.jsxs)(`div`,{className:g||void 0,style:a?.stat,children:[(0,C.jsx)(`span`,{className:ee||void 0,style:a?.statLabel,children:o?.acceleration??`가속`}),(0,C.jsx)(`span`,{className:_||void 0,style:a?.statValue,children:s.acceleration})]})]})]})})}function Lt(e){let t=c.o(e=>e.rideable),{initRideable:n,onRideableNear:r,onRideableLeave:i,landing:a}=Ve();(0,x.useEffect)(()=>{n(e)},[e,n]);let{controllerOptions:o,...s}=e,l=o?.lerp?{lerp:{cameraTurn:o.lerp.cameraTurn??1,cameraPosition:o.lerp.cameraPosition??1}}:void 0,u={objectType:e.objectType,objectkey:e.objectkey,rideable:!0,init:n,onNear:r,onLeave:i,landing:a,rideMessage:e.rideMessage,exitMessage:e.exitMessage,displayName:e.displayName};return(0,C.jsxs)(C.Fragment,{children:[e.objectType===`vehicle`&&(0,C.jsx)(kt,{...s,...l?{controllerOptions:l}:{},userData:u,sensor:!0,visible:t[e.objectkey]?.visible!==!1&&!t[e.objectkey]?.isOccupied}),e.objectType===`airplane`&&(0,C.jsx)(At,{...s,...l?{controllerOptions:l}:{},userData:u,sensor:!0,visible:t[e.objectkey]?.visible!==!1&&!t[e.objectkey]?.isOccupied})]})}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return At}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return st}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return ye}});
|
|
1
|
+
const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./useEngineFrame-ujTlLQfa.cjs"),n=require("./logger-B9OaKOPw.cjs"),r=require("./runtimeContext-zx_GnKx4.cjs"),i=require("./scopedStore-Px5jL718.cjs"),a=require("./assetStore-DbqlOBWB.cjs"),o=require("./reportError-CkJ7vZsX.cjs"),s=require("./useClicker-B-fGashd.cjs"),c=require("./CoreBridge-L4l4UNtR.cjs"),l=require("./id-DWiNl1ym.cjs"),u=require("./serviceKey-DwHFFFAA.cjs"),d=require("./weatherStore-DwLl0Jjo.cjs"),f=require("./WorldProps-C0JF5fFD.cjs"),p=require("./SaveSystem-Bj41IbmF.cjs"),m=require("./clientServices-Bs-PZVqS.cjs"),h=require("./guards-FnxbNibY.cjs"),g=require("./areas-CnRl22N4.cjs"),ee=require("./engine-DLNEnn0R.cjs"),_=require("./useGenericRefs-DzuTNaAX.cjs"),te=require("./useNavigation-D-c4u9T4.cjs"),ne=require("./runtimeFilter-5rYxTYwr.cjs"),re=require("./WorldContainer-CDC2nj9-.cjs"),ie=require("./timeStore-Be94nnui.cjs"),v=require("./WorldBridge-CBEkEehK.cjs"),y=require("./snapshot-BwAZISiG.cjs");let b=require("three");b=e.n(b,1);let x=require("react"),S=require("zustand"),ae=require("@react-three/fiber"),C=require("react/jsx-runtime"),w=require("@react-three/rapier");function oe(e,n,r={},i=t.m){let a=[],o=null,s=i.getGeneration(),c=(e,t)=>{for(let r=0;r<a.length;r++)n(a[r],e,t)},l=()=>{a.length>0||!o||(o(),o=null)};return{add:t=>{a.push(t),s!==i.getGeneration()&&(o=null,s=i.getGeneration()),o??=i.add(e,c,{label:`driver:${e}`,...r});let n=!1;return()=>{if(n)return;n=!0;let e=a.indexOf(t);e>=0&&a.splice(e,1),l()}},size:()=>a.length,dispose:()=>{a.length=0,l()}}}var se=`runtime.saveDiagnostics`,ce=`runtime:saveDiagnostic`,le=`runtime:saveBindingRejected`;function ue(e={}){let t=Math.max(1,e.maxEntries??50),n=[],r=new Set,i=1;return{report(e){let a=fe(e.error),o={...e,id:i,reportedAt:Date.now(),errorMessage:a,message:de(e,a)};i+=1,n.push(o),n.length>t&&n.splice(0,n.length-t);for(let e of r)e(o);return o},getDiagnostics(){return n.map(e=>({...e}))},getLatest(){let e=n[n.length-1];return e?{...e}:void 0},clear(){n.length=0},subscribe(e){return r.add(e),()=>{r.delete(e)}}}}function de(e,t=fe(e.error)){return`Save domain "${e.key}" failed during ${e.phase} for slot "${e.slot}": ${t}`}function fe(e){return e instanceof Error?e.message:typeof e==`string`?e:`Unknown save error`}var T=[`pointerdown`,`keydown`,`touchstart`],E=class{constructor(e={}){this.options=e,this.ctx=null,this.masterGain=null,this.bgmGain=null,this.sfxGain=null,this.bgmInterval=null,this.bgmStep=0,this.currentBgm=null,this.bufferCache=new Map,this.sources=new Map,this.requests=new Map,this.bgmGeneration=0,this.bgmPlayback=new Map,this.resumeAt=new Map,this.playbackEnabled=!0,this.volumes={master:1,bgm:1,sfx:1}}ensure(){if(!this.canPlay())return!1;if(this.ctx)return!0;if(typeof window>`u`||window.AudioContext===void 0)return!1;try{if(this.ctx=new window.AudioContext,this.masterGain=this.ctx.createGain(),this.masterGain.connect(this.ctx.destination),this.bgmGain=this.ctx.createGain(),this.sfxGain=this.ctx.createGain(),this.bgmGain.connect(this.masterGain),this.sfxGain.connect(this.masterGain),this.masterGain.gain.value=this.volumes.master,this.bgmGain.gain.value=this.volumes.bgm,this.sfxGain.gain.value=this.volumes.sfx,this.ctx.state===`suspended`){let e=()=>this.resume();for(let t of T)window.addEventListener(t,e,{once:!0,capture:!0,passive:!0})}return!0}catch{return!1}}resume(){this.ensure()&&this.ctx?.state===`suspended`&&this.ctx.resume().catch(()=>void 0)}suspendPlayback(){this.playbackEnabled=!1,this.stopBgm();for(let e of this.requests.keys())e.abort();for(let e of this.sources.keys())this.stopSource(e)}resumePlayback(){this.playbackEnabled=!0}canPlay(){return this.playbackEnabled&&(this.options.canPlay?.()??!0)}getDiagnostics(){return{contextState:this.ctx?.state??`uninitialized`,bgm:this.currentBgm?.id??null,activeSources:this.sources.size,pendingRequests:this.requests.size,decodedBuffers:this.bufferCache.size}}cancelSfx(){for(let[e,t]of this.requests)t||e.abort();for(let[e,t]of this.sources)t.bgm||this.stopSource(e)}setMasterVolume(e){this.volumes.master=Math.max(0,Math.min(1,e)),this.masterGain&&(this.masterGain.gain.value=this.volumes.master)}setBgmVolume(e){this.volumes.bgm=Math.max(0,Math.min(1,e)),this.bgmGain&&(this.bgmGain.gain.value=this.volumes.bgm)}setSfxVolume(e){this.volumes.sfx=Math.max(0,Math.min(1,e)),this.sfxGain&&(this.sfxGain.gain.value=this.volumes.sfx)}playSfx(e){if(!this.ensure()||!this.ctx||!this.sfxGain)return;if(e.url){this.playFromUrl(e.url,this.sfxGain,e.volume??1);return}let t=this.ctx.createOscillator(),n=this.ctx.createGain();t.type=e.type??`sine`,t.frequency.value=e.freq??440;let r=e.duration??.12,i=this.ctx.currentTime;n.gain.setValueAtTime(0,i),n.gain.linearRampToValueAtTime((e.volume??1)*.3,i+.005),n.gain.exponentialRampToValueAtTime(1e-4,i+r),t.connect(n),n.connect(this.sfxGain),this.trackSource(t,n,!1),t.start(i),t.stop(i+r+.05)}playBgm(e){if(!this.canPlay()||(this.stopBgm(1),!e)||!this.ensure()||!this.ctx||!this.bgmGain)return;if(this.currentBgm=e,e.url){this.playFromUrl(e.url,this.bgmGain,e.volume??1,!0);return}let t=e.pattern??[0,4,7,4],n=e.intervalMs??800,r=e.baseFreq??220;this.bgmStep=0;let i=()=>{if(!this.ctx||!this.bgmGain)return;let i=t[this.bgmStep%t.length]??0,a=r*2**(i/12),o=this.ctx.createOscillator(),s=this.ctx.createGain();o.type=`triangle`,o.frequency.value=a;let c=this.ctx.currentTime;s.gain.setValueAtTime(0,c),s.gain.linearRampToValueAtTime((e.volume??1)*.18,c+.04),s.gain.exponentialRampToValueAtTime(1e-4,c+n/1e3*.95),o.connect(s),s.connect(this.bgmGain),this.trackSource(o,s,!0),o.start(c),o.stop(c+n/1e3+.05),this.bgmStep+=1};i(),this.bgmInterval=window.setInterval(i,n)}stopBgm(e=0){this.bgmGeneration++;for(let[e,t]of this.requests)t&&e.abort();this.bgmInterval!==null&&(window.clearInterval(this.bgmInterval),this.bgmInterval=null),this.currentBgm=null;for(let[t,n]of this.sources)n.bgm&&(this.rememberPlayback(t),e>0&&this.ctx?this.fadeOut(t,n.gain,e):this.stopSource(t))}async dispose(){this.stopBgm();for(let e of this.requests.keys())e.abort();this.requests.clear();for(let e of this.sources.keys())this.stopSource(e);this.bufferCache.clear(),this.bgmGain?.disconnect(),this.sfxGain?.disconnect(),this.masterGain?.disconnect();let e=this.ctx;this.ctx=null,this.bgmGain=this.sfxGain=this.masterGain=null,e&&e.state!==`closed`&&await e.close()}fadeOut(e,t,n){try{let r=this.ctx.currentTime;t.gain.cancelScheduledValues(r),t.gain.setValueAtTime(t.gain.value,r),t.gain.linearRampToValueAtTime(0,r+n),e.stop(r+n)}catch{this.stopSource(e)}}rememberPlayback(e){let t=this.bgmPlayback.get(e);if(!t||!this.ctx)return;this.bgmPlayback.delete(e);let n=t.offset+this.ctx.currentTime-t.startedAt;this.resumeAt.set(t.url,t.duration>0?n%t.duration:0)}trackSource(e,t,n){this.sources.set(e,{gain:t,bgm:n}),e.onended=()=>this.releaseSource(e)}releaseSource(e){let t=this.sources.get(e);t&&(this.sources.delete(e),this.bgmPlayback.delete(e),e.onended=null,e.disconnect(),t.gain.disconnect())}stopSource(e){try{e.stop()}catch{}this.releaseSource(e)}getCurrentBgmId(){return this.currentBgm?.id??null}async playFromUrl(e,t,n,r=!1){let i=this.ctx;if(!i)return;let a=this.bgmGeneration,o=new AbortController;this.requests.set(o,r);let s=()=>this.ctx===i&&!o.signal.aborted&&(!r||a===this.bgmGeneration);try{let a=this.bufferCache.get(e);if(!a){let t=await fetch(e,{signal:o.signal});if(!t.ok||!s())return;let n=await t.arrayBuffer();if(!s()||(a=await i.decodeAudioData(n),!s()))return;this.bufferCache.set(e,a)}if(!s())return;let c=i.createBufferSource();c.buffer=a,c.loop=r;let l=i.createGain(),u=i.currentTime,d=r?this.resumeAt.get(e)??0:0;r?(l.gain.setValueAtTime(0,u),l.gain.linearRampToValueAtTime(n,u+1)):l.gain.value=n,c.connect(l),l.connect(t),this.trackSource(c,l,r);try{r?c.start(u,d):c.start()}catch(e){throw this.releaseSource(c),e}r&&this.bgmPlayback.set(c,{url:e,startedAt:u,offset:d,duration:a.duration??0})}catch{}finally{this.requests.delete(o)}}},D=null;function pe(e={}){return new E(e)}function O(){return D||=new E,D}function me(e=pe()){return(0,S.create)((t,n)=>({masterMuted:!1,bgmMuted:!1,sfxMuted:!1,masterVolume:.6,bgmVolume:.4,sfxVolume:.7,currentBgmId:null,bgmRevision:0,setMaster:e=>{t({masterVolume:Math.max(0,Math.min(1,e))}),n().apply()},setBgm:e=>{t({bgmVolume:Math.max(0,Math.min(1,e))}),n().apply()},setSfx:e=>{t({sfxVolume:Math.max(0,Math.min(1,e))}),n().apply()},toggleMaster:()=>{t({masterMuted:!n().masterMuted}),n().apply()},toggleBgm:()=>{t({bgmMuted:!n().bgmMuted}),n().apply()},toggleSfx:()=>{t({sfxMuted:!n().sfxMuted}),n().apply()},playSfx:t=>{if(!e.canPlay())return;let r=n();r.masterMuted||r.sfxMuted||(n().apply(),e.resume(),e.playSfx(t))},playBgm:r=>{e.canPlay()&&(n().apply(),r&&e.resume(),e.playBgm(r),t(t=>({currentBgmId:e.getCurrentBgmId(),bgmRevision:t.bgmRevision+1})))},stopBgm:()=>{e.stopBgm(1),t(e=>({currentBgmId:null,bgmRevision:e.bgmRevision+1}))},apply:()=>{let t=n(),r=e;r.setMasterVolume(t.masterMuted?0:t.masterVolume),r.setBgmVolume(t.bgmMuted?0:t.bgmVolume),r.setSfxVolume(t.sfxMuted?0:t.sfxVolume)},serialize:()=>{let e=n();return{version:1,masterMuted:e.masterMuted,bgmMuted:e.bgmMuted,sfxMuted:e.sfxMuted,masterVolume:e.masterVolume,bgmVolume:e.bgmVolume,sfxVolume:e.sfxVolume}},prepareHydrate:e=>{if(e==null)return()=>{};if(typeof e!=`object`||e.version!==1||![e.masterMuted,e.bgmMuted,e.sfxMuted].every(e=>typeof e==`boolean`)||![e.masterVolume,e.bgmVolume,e.sfxVolume].every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1))throw TypeError(`Invalid audio snapshot`);let{masterMuted:r,bgmMuted:i,sfxMuted:a,masterVolume:o,bgmVolume:s,sfxVolume:c}=e;return()=>{t({masterMuted:r,bgmMuted:i,sfxMuted:a,masterVolume:o,bgmVolume:s,sfxVolume:c}),n().apply()}},hydrate:e=>n().prepareHydrate(e)()}))}var he=u.n(`audio`),{useStore:ge,useStoreApi:k}=i.t(`useAudioStore`,()=>me(O()),()=>r.n()?.audioStore),A=class{constructor(e){this.target=e,this.listeners=new Set,this.listenerSnapshot=[],this.snapshot=[],this.focused=!0,this.reads=0,this.generation=0,this.polling=!1,this.pollRequested=!1,this.status=`idle`,this.focus=()=>{this.focused=!0,this.wake()},this.blur=()=>{this.focused=!1,this.wake()},this.wake=()=>{this.cancelFrame(),this.poll()},this.poll=()=>{if(this.polling){this.pollRequested=!0;return}if(this.pollRequested=!1,this.frame=void 0,!this.listeners.size)return;this.polling=!0;let e=this.generation,t=[];if(!this.focused||this.target.document.hidden)this.status=`paused`;else if(typeof this.target.navigator.getGamepads!=`function`)this.status=`unsupported`;else try{this.reads++,t=this.target.navigator.getGamepads(),this.status=`ready`}catch{this.status=`blocked`}this.snapshot=t;for(let n of this.listenerSnapshot){if(e!==this.generation)break;this.listeners.has(n)&&this.notify(n.listener,t)}if(this.polling=!1,this.listeners.size&&this.frame===void 0&&(this.pollRequested||e===this.generation&&this.focused&&!this.target.document.hidden&&this.status===`ready`&&t.some(e=>e?.connected))){let e=this.generation,t=this.target.requestAnimationFrame(()=>{this.frame===t&&this.generation===e&&this.poll()});this.frame=t}}}subscribe(e){let t={listener:e},n=this.listeners.size===0;return this.listeners.add(t),this.listenerSnapshot=[...this.listeners],n?(this.focused=this.target.document.hasFocus(),this.target.addEventListener(`gamepadconnected`,this.wake),this.target.addEventListener(`gamepaddisconnected`,this.wake),this.target.addEventListener(`focus`,this.focus),this.target.addEventListener(`blur`,this.blur),this.target.document.addEventListener(`visibilitychange`,this.wake),this.poll()):this.notify(e,this.snapshot),()=>{this.listeners.delete(t)&&(this.listenerSnapshot=[...this.listeners],!this.listeners.size&&(this.generation++,this.cancelFrame(),this.snapshot=[],this.status=`idle`,this.target.removeEventListener(`gamepadconnected`,this.wake),this.target.removeEventListener(`gamepaddisconnected`,this.wake),this.target.removeEventListener(`focus`,this.focus),this.target.removeEventListener(`blur`,this.blur),this.target.document.removeEventListener(`visibilitychange`,this.wake)))}}getStats(){return{subscribers:this.listeners.size,pendingFrames:Number(this.frame!==void 0),reads:this.reads,status:this.status}}notify(e,t){try{e(t)}catch(e){n.t.error(`Gamepad input consumer failed`,e instanceof Error?e:String(e))}}cancelFrame(){this.frame!==void 0&&this.target.cancelAnimationFrame(this.frame),this.frame=void 0}},j=new WeakMap;function M(e=window){let t=j.get(e);return t||(t=new A(e),j.set(e,t)),t}var N=[`A`,`B`,`X`,`Y`,`LB`,`RB`,`LT`,`RT`,`Back`,`Start`,`LeftStick`,`RightStick`,`DPadUp`,`DPadDown`,`DPadLeft`,`DPadRight`,`Guide`],_e={A:`space`,B:`escape`,X:`keyF`,Y:`keyE`,RB:`shift`,Back:`escape`,Start:`escape`,DPadUp:`forward`,DPadDown:`backward`,DPadLeft:`leftward`,DPadRight:`rightward`},ve=(e,t,n)=>Number.isFinite(e)?Math.max(t,Math.min(n,e)):0;function P(e,t,n,r){r.set(ve(e,-1,1),ve(t,-1,1));let i=r.length();return i<=n?r.set(0,0):r.multiplyScalar((Math.min(1,i)-n)/((1-n)*i))}var ye=class{constructor(e,t,r,i={},a,o){this.backend=e,this.scope=t,this.eligible=r,this.source=a,this.onManualMovement=o,this.running=!1,this.blocked=new Uint8Array(17),this.blockedLeft=!1,this.blockedRight=!1,this.armed=!1,this.changes=0,this.selectedIndex=null,this.mappingSupported=!0,this.state={connected:!1,leftStick:new b.Vector2,rightStick:new b.Vector2,triggers:{left:0,right:0},buttons:Object.fromEntries(N.map(e=>[e,!1])),vibration:{weak:0,strong:0}},this.scratchLeft=new b.Vector2,this.scratchRight=new b.Vector2,this.generation=0,this.inputEpoch=0,this.release=()=>{this.inputEpoch++,this.armed=!1,this.deviceId=void 0,this.deviceMapping=void 0,this.selectedIndex=null;let e=this.state.connected,t=this.inputEpoch;this.state.connected=!1,this.state.leftStick.set(0,0),this.state.rightStick.set(0,0),this.state.triggers.left=0,this.state.triggers.right=0;for(let e of N)this.state.buttons[e]=!1;if(this.ownership.release(),e&&t===this.inputEpoch)try{this.publish()}catch(e){n.t.error(`Gamepad state cleanup failed`,e instanceof Error?e:String(e))}},this.options=this.copyOptions(i),this.ownership=_.x(e)}get lookSpeed(){return this.options.lookSpeed??2.5}configure(e){let t=this.copyOptions({...this.options,...e});this.release(),this.options=t,this.refresh()}resume(){this.running=!0,this.refresh()}suspend(){this.running=!1,this.stop()}refresh(){if(!(this.running&&this.options.enabled!==!1&&this.eligible())){this.stop();return}if(this.disconnect)return;let e=this.source??(typeof window>`u`?void 0:M());if(!e)return;let t=++this.generation,n,r=this.scope.onBlur(this.release);this.disconnect=()=>{r(),n?.()};try{let r=e.subscribe(e=>{this.running&&this.generation===t&&this.sample(e)});this.running&&this.generation===t?n=r:r()}catch(e){throw this.stop(),e}}getStats(){return{active:!!this.disconnect,connected:this.state.connected,selectedIndex:this.selectedIndex,mappingSupported:this.mappingSupported,changes:this.changes}}copyOptions(e){if(e.index!==void 0&&(!Number.isInteger(e.index)||e.index<0))throw RangeError(`Gamepad index must be a non-negative integer`);let t=e.deadzone??.15,n=e.lookSpeed??2.5;if(!Number.isFinite(t)||t<0||t>=1)throw RangeError(`Gamepad deadzone must be between 0 and 1`);if(!Number.isFinite(n)||n<0)throw RangeError(`Gamepad look speed must be non-negative`);for(let t of[...Object.values(e.mapping?.axes??{}),...Object.values(e.mapping?.buttons??{})])if(!Number.isInteger(t)||t<0)throw RangeError(`Gamepad mapping indices must be non-negative integers`);return{...e,deadzone:t,lookSpeed:n,...e.bindings?{bindings:{...e.bindings}}:{},...e.mapping?{mapping:{axes:{...e.mapping.axes},buttons:{...e.mapping.buttons}}}:{}}}stop(){let e=this.disconnect;this.disconnect=void 0;let t=++this.generation;try{e?.()}catch(e){n.t.error(`Gamepad source cleanup failed`,e instanceof Error?e:String(e))}t===this.generation&&this.release()}publish(){this.changes++,this.backend.updateGamepad?.(this.state)}sample(e){if(!this.eligible()||!this.scope.isFocused()){this.release();return}let t=this.generation,n,r;for(let t of e)if(!(!t?.connected||this.options.index!==void 0&&t.index!==this.options.index)){if(t.mapping===`standard`||this.options.mapping){n=t;break}r??=t}if(n??=r,this.mappingSupported=!n||n.mapping===`standard`||!!this.options.mapping,!n||!this.mappingSupported){this.release();return}if(this.selectedIndex!==n.index||this.deviceId!==n.id||this.deviceMapping!==n.mapping){let e=this.inputEpoch;if(this.release(),t!==this.generation||this.inputEpoch!==e+1||!this.running)return}this.deviceId=n.id,this.deviceMapping=n.mapping,this.selectedIndex=n.index;let i=this.options.mapping?.axes,a=this.options.deadzone;P(n.axes[i?.leftX??0]??0,n.axes[i?.leftY??1]??0,a,this.scratchLeft),P(n.axes[i?.rightX??2]??0,n.axes[i?.rightY??3]??0,a,this.scratchRight),this.armed||(this.blockedLeft=this.scratchLeft.lengthSq()>0,this.blockedRight=this.scratchRight.lengthSq()>0),this.blockedLeft&&(this.scratchLeft.lengthSq()?this.scratchLeft.set(0,0):this.blockedLeft=!1),this.blockedRight&&(this.scratchRight.lengthSq()?this.scratchRight.set(0,0):this.blockedRight=!1);let o=!this.state.connected||!this.state.leftStick.equals(this.scratchLeft)||!this.state.rightStick.equals(this.scratchRight);this.state.connected=!0,this.state.leftStick.copy(this.scratchLeft),this.state.rightStick.copy(this.scratchRight);let s=this.inputEpoch;for(let e=0;e<N.length;e++){let t=N[e],r=n.buttons[this.options.mapping?.buttons?.[t]??e],i=ve(r?.value,0,1),a=!!r?.pressed||i>=.5;this.armed||(this.blocked[e]=Number(a||i>.01)),!a&&i<=.01&&(this.blocked[e]=0);let s=!this.blocked[e]&&a;if(this.state.buttons[t]!==s&&(this.state.buttons[t]=s,o=!0),t===`LT`||t===`RT`){let n=t===`LT`?`left`:`right`,r=this.blocked[e]?0:i;this.state.triggers[n]!==r&&(this.state.triggers[n]=r,o=!0)}}if(this.armed=!0,!((this.state.leftStick.lengthSq()>0||this.state.buttons.DPadUp||this.state.buttons.DPadDown||this.state.buttons.DPadLeft||this.state.buttons.DPadRight)&&(this.onManualMovement?.(),this.backend.getMouse().isActive&&this.backend.updateMouse({isActive:!1,shouldRun:!1,hasArrived:!1}),t!==this.generation||s!==this.inputEpoch||!this.running))&&(o&&this.publish(),this.scope.isFocused()))for(let e of N){if(t!==this.generation||s!==this.inputEpoch||!this.running)return;let n=this.options.bindings?.[e]===void 0?_e[e]:this.options.bindings[e];n&&this.ownership.set(e,n,this.state.buttons[e])}}},be=class{constructor(){this.counters=new Map,this.sources=new Map}counter(e){if(this.sources.has(e))throw Error(`Engine stat is already a source: ${e}`);let t=this.counters.get(e);return t||this.counters.set(e,t={value:0}),t}source(e,t,n=`cumulative`){if(this.counters.has(e))throw Error(`Engine stat is already a counter: ${e}`);let r={read:t,kind:n,base:n===`cumulative`?t():0};return this.sources.set(e,r),()=>{this.sources.get(e)===r&&this.sources.delete(e)}}snapshot(){let e={};for(let[t,n]of this.counters)e[t]=n.value;for(let[t,n]of this.sources)e[t]=n.kind===`cumulative`?n.read()-n.base:n.read();return e}reset(){for(let e of this.counters.values())e.value=0;for(let e of this.sources.values())e.kind===`cumulative`&&(e.base=e.read())}};function F(e,t,n){return t===n?!0:t<n?e>=t&&e<n:e>=t||e<n}function xe(e,t){return e.weekdays&&e.weekdays.length>0&&!e.weekdays.includes(t.weekday)||e.seasons&&e.seasons.length>0&&!e.seasons.includes(t.season)?!1:F(t.hour,e.startHour,e.endHour)}function Se(e,t){for(let n of e.entries)if(xe(n,t))return{position:n.position,activity:n.activity??`idle`,...n.rotationY===void 0?{}:{rotationY:n.rotationY},...n.dialogTreeId?{dialogTreeId:n.dialogTreeId}:{},source:n};let n=e.defaultEntry;return{position:n?.position??[0,0,0],activity:n?.activity??`idle`,...n?.rotationY===void 0?{}:{rotationY:n.rotationY},...n?.dialogTreeId?{dialogTreeId:n.dialogTreeId}:{},source:null}}var Ce=class{constructor(){this.map=new Map,this.listeners=new Set,this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)})}publish(){for(let e of this.listeners)e()}register(e){this.map.set(e.npcId,e),this.publish()}unregister(e){this.map.delete(e)&&this.publish()}get(e){return this.map.get(e)}resolve(e,t){let n=this.map.get(e);return n?Se(n,t):null}all(){return Array.from(this.map.values())}clear(){this.map.size&&(this.map.clear(),this.publish())}};function we(){return new Ce}var Te=null;function Ee(){return Te||=new Ce,Te}var De=new WeakMap;function Oe(e,t){let n=De.get(e);n||(n=new Map,De.set(e,n));let r=t??e.getDefaultSlot(),i=n.get(r);return i||(i=new ke(e,r,n),n.set(r,i)),i}function I(e,t,n){return Oe(e,t).acquireAutoSave(n)}function L(e,t,n){return Oe(e,t).acquireInitialLoad(n)}var ke=class{constructor(e,t,n){this.system=e,this.slot=t,this.slots=n,this.autoOwners=new Set,this.unload=!1,this.visibility=!1,this.saving=!1,this.pendingSave=!1,this.requestSave=()=>{if(this.canSave()){if(this.saving){this.pendingSave=!0;return}this.saving=!0,this.system.save(this.slot,{skipUnchanged:!0}).catch(e=>{this.system.reportError(e,{source:`save:autosave`,label:this.slot})}).finally(()=>{this.saving=!1;let e=this.pendingSave;this.pendingSave=!1,e&&this.requestSave(),this.prune()})}},this.onVisibility=()=>{document.visibilityState===`hidden`&&this.requestSave()}}acquireAutoSave(e){let t={...e,intervalMs:Number.isFinite(e.intervalMs)?Math.max(1e3,e.intervalMs):3e5};return this.autoOwners.add(t),this.syncResources(),()=>{this.autoOwners.delete(t),this.autoOwners.size===0&&(this.pendingSave=!1),this.syncResources(),this.prune()}}acquireInitialLoad(e){let t={notify:e,delivered:!1},n=this.initialLoad;if(!n)n={controller:new AbortController,owners:new Set([t]),state:`pending`,result:!1},this.initialLoad=n,this.startLoad(n);else{n.owners.add(t);let e=n;Promise.resolve().then(()=>this.notifyLoaded(e,t))}let r=n;return()=>{r.owners.delete(t),r.owners.size===0&&this.initialLoad===r&&(r.controller.abort(),this.initialLoad=void 0,this.prune())}}startLoad(e){this.system.load(this.slot,e.controller.signal).then(t=>{if(!(this.initialLoad!==e||e.controller.signal.aborted)){e.state=`loaded`,e.result=t;for(let t of[...e.owners])this.notifyLoaded(e,t)}}).catch(t=>{this.initialLoad!==e||e.controller.signal.aborted||(e.state=`failed`,this.system.reportError(t,{source:`save:load`,label:this.slot}))})}notifyLoaded(e,t){if(this.initialLoad===e&&e.state===`loaded`&&e.owners.has(t)&&!t.delivered){t.delivered=!0;try{t.notify(e.result)}catch(e){this.system.reportError(e,{source:`save:load-callback`,label:this.slot})}}}canSave(){return this.autoOwners.size>0&&!re.a()&&!this.system.isLoading()&&!this.system.isRestoring()&&(!this.initialLoad||this.initialLoad.state===`loaded`)}syncResources(){let e,t=!1,n=!1;for(let r of this.autoOwners)e=Math.min(e??1/0,r.intervalMs),t||=r.saveOnUnload,n||=r.saveOnVisibilityChange;e!==this.intervalMs&&(this.timer!==void 0&&window.clearInterval(this.timer),this.timer=e===void 0?void 0:window.setInterval(this.requestSave,e),this.intervalMs=e),t!==this.unload&&(t?window.addEventListener(`beforeunload`,this.requestSave):window.removeEventListener(`beforeunload`,this.requestSave),this.unload=t),n!==this.visibility&&(n?document.addEventListener(`visibilitychange`,this.onVisibility):document.removeEventListener(`visibilitychange`,this.onVisibility),this.visibility=n)}prune(){!this.autoOwners.size&&!this.initialLoad&&!this.saving&&this.slots.get(this.slot)===this&&this.slots.delete(this.slot)}};function Ae({enabled:e=!0,intervalMs:t=3e5,slot:n,saveOnUnload:i=!0,saveOnVisibilityChange:a=!0,saveSystem:o}={}){let s=r.n(),c=o??s?.save??p.i();(0,x.useEffect)(()=>{if(e)return z(s,()=>I(c,n,{intervalMs:t,saveOnUnload:i,saveOnVisibilityChange:a}))},[e,t,n,i,a,c,s])}function R(e,t,n){let i=r.n(),a=n??i?.save??p.i(),o=(0,x.useRef)(t);(0,x.useLayoutEffect)(()=>{o.current=t},[t]),(0,x.useEffect)(()=>z(i,()=>L(a,e,e=>o.current?.(e))),[e,a,i])}function z(e,t){let n,r=()=>{!e||e.isActive()?n??=t():(n?.(),n=void 0)},i=e?.subscribeLifecycle(r);return r(),()=>{i?.(),n?.(),n=void 0}}function B(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function je(){return(0,S.create)(e=>({rooms:new Map,portals:new Map,currentRoomId:null,visibleRoomIds:new Set,initializedSceneId:null,registerRoom:t=>e(e=>{let n=new Map(e.rooms);return n.set(t.id,t),{rooms:n}}),unregisterRoom:t=>e(e=>{if(!e.rooms.has(t))return e;let n=new Map(e.rooms);return n.delete(t),{rooms:n,currentRoomId:e.currentRoomId===t?null:e.currentRoomId}}),registerPortal:t=>e(e=>{let n=new Map(e.portals);return n.set(t.id,t),{portals:n}}),unregisterPortal:t=>e(e=>{if(!e.portals.has(t))return e;let n=new Map(e.portals);return n.delete(t),{portals:n}}),setVisibleRooms:(t,n,r)=>e(e=>e.initializedSceneId===t&&e.currentRoomId===n&&B(e.visibleRoomIds,r)?e:{initializedSceneId:t,currentRoomId:n,visibleRoomIds:r}),reset:()=>e({currentRoomId:null,visibleRoomIds:new Set,initializedSceneId:null})}))}var{useStore:Me,useStoreApi:V}=i.t(`useRoomVisibilityStore`,je,()=>r.n()?.roomVisibilityStore),Ne=class{constructor(){this.entries=new Set,this.enabled=!0}register(e){let t={view:e};return this.entries.add(t),this.selected=t,this.enabled&&this.attach(t),()=>{this.entries.delete(t)&&(t.detach?.(),this.selected===t&&(this.selected=[...this.entries].at(-1)))}}attach(e){let t=e.view.surface;if(!t)return;let n=()=>{this.enabled&&(this.selected=e)};t.addEventListener(`pointerdown`,n),t.addEventListener(`focusin`,n),e.detach=()=>{t.removeEventListener(`pointerdown`,n),t.removeEventListener(`focusin`,n)}}current(){return this.enabled?this.selected?.view??null:null}suspend(){this.enabled=!1;for(let e of this.entries)e.detach?.(),delete e.detach}resume(){if(!this.enabled){this.enabled=!0;for(let e of this.entries)this.attach(e)}}dispose(){this.suspend(),this.entries.clear(),this.selected=void 0}},Pe=()=>({objects:[],selectedObjectId:void 0,interactionMode:`view`,showDebugInfo:!1,events:[],loading:!1,error:void 0}),H=e=>({objects:e.objects,selectedObjectId:e.selectedObjectId,interactionMode:e.interactionMode,showDebugInfo:e.showDebugInfo,events:e.events,loading:!1,error:void 0});function Fe({bridge:e,worldId:t,owned:n=!1,active:r=!0}){return(i,a)=>{let o,s=!1,c=(e,n)=>{s&&n===t&&i(H(e))},l=()=>{if(s)return;n&&e.resume();let r=a();if(!e.getEngine(t)){e.register(t,r?{selectedObjectId:r.selectedObjectId,interactionMode:r.interactionMode,showDebugInfo:r.showDebugInfo}:{});let n=e.getEngine(t)?.system;if(r){for(let e of r.objects)n?.addObject(e);for(let e of r.events)n?.processInteraction(e)}}s=!0,o=e.subscribe(c);let i=e.snapshot(t);r&&i&&c(i,t)},u=()=>{if(s)try{let n=e.snapshot(t);n&&c(n,t)}finally{s=!1,o?.(),o=void 0,n&&(e.suspend(),e.dispose())}};r?l():n&&e.suspend();let d=s?e.snapshot(t):null,f=(e,t)=>{if(!s)return e;try{let e=t();return(a().loading||a().error!==void 0)&&i({loading:!1,error:void 0}),e}catch(t){return i({loading:!1,error:t instanceof Error?t.message:String(t)}),e}};return{...d?H(d):Pe(),activateWorldBridge:l,deactivateWorldBridge:u,addObject:n=>f(``,()=>e.addObject(t,n)),removeObject:n=>f(!1,()=>e.getEngine(t)?.system.getObject(n)?(e.removeObject(t,n),!0):!1),updateObject:(n,r)=>f(!1,()=>e.getEngine(t)?.system.getObject(n)?(e.updateObject(t,n,r),!0):!1),selectObject:n=>f(void 0,()=>e.selectObject(t,n)),setInteractionMode:n=>f(void 0,()=>e.setInteractionMode(t,n)),toggleDebugInfo:()=>f(void 0,()=>e.toggleDebugInfo(t)),setLoading:e=>i({loading:e}),setError:e=>i({error:e}),clearEvents:()=>f(void 0,()=>e.clearEvents(t)),getBridge:()=>e,getObjectsInRadius:(n,r)=>s?e.getObjectsInRadius(t,n,r):[],getObjectsByType:n=>s?e.getObjectsByType(t,n):[],raycast:(n,r)=>s?e.raycast(t,n,r):null,interact:(n,r)=>f(void 0,()=>e.interact(t,n,r)),cleanup:()=>{s?f(void 0,()=>e.cleanup(t)):i(Pe())}}}}var U=(...e)=>Fe({bridge:c.n.getOrCreateFor(v.t),worldId:`default`})(...e);function Ie(e=`default`,t=!0){let n=new v.t;return(0,S.create)()(Fe({bridge:n,worldId:e,owned:!0,active:t}))}var Le;function Re(){return r.n()?.worldObjectStore??(Le??=(0,S.create)()(U))}function W(e=e=>e){return(0,S.useStore)(Re(),e)}function ze(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.key==`string`&&typeof t.serialize==`function`&&typeof t.hydrate==`function`}function G(e={}){let t=e.worldId??l.t();if(!t.trim())throw TypeError(`Runtime worldId must not be empty`);let n=`inactive`,r=(t,r)=>{e.onError&&n!==`inactive`?o.n(e.onError,t,r):o.r(t,r)},i=a.t(),u=ie.n(),h=d.n(),re=m.m(),v=m.u(re),y=pe({canPlay:()=>!U.isRestoring()}),b=me(y);y.suspendPlayback();let x=p.x(),S=p.d(),ae=je();S.getState().suspendTransitions();let C=ee.r(m.i({dialogStore:v,emit:(e,t)=>H.context.events.emit(e,t)})),w=new ee.t({registry:C});w.suspend();let oe=e=>{w.dispatch(e).catch(t=>r(t,{source:`gameplay:trigger`,label:e.type}))},de=g.t(e=>oe({type:`enterArea`,areaId:e})),fe,T=s.gr();T.suspend();let E=new s.Bt,D=new _.b(E,T,!1),O=f.M(!1,e=>oe({type:`interaction`,targetId:e.id,action:`interact`})),ge=e.inputExtensionId??`interaction.input`,k=c.a(E,r),A=p.c({store:k,characterStore:x,sceneStore:S,dialogStore:v},!1),j=s.Ht(),M=new ye(E,T,()=>k.getState().mode?.controller===`gamepad`&&k.getState().interaction?.isActive!==!1&&!j.getState().isInEditMode(),e.gamepad===!1?{enabled:!1}:e.gamepad,void 0,()=>{k.getState().automation?.queue.isRunning&&k.getState().stopAutomation(),I.getClickNavigationRoute().length&&I.clearClickNavigationRoute()}),N,_e,ve=()=>{N?.(),N=void 0,_e?.(),_e=void 0,M.suspend()},P=f.f();P.suspend();let F=f.y({active:!1,isCurrent:({instance:e})=>{let t=xe.getState().instances.get(e.id);return!!(t&&t.brain===e.brain&&t.templateId===e.templateId)}}),xe=f.i({onInvalidateBrain:F.release});f._(P,F);let Se=we(),Ce=f.R(),Te=f.Ct(),Ee=f.F(),De=te.a(),Oe=new te.c(e.navigation),I=te.d(),L=new s.pt,ke=Ie(t,!1),Ae=ke.getState().getBridge(),R=new Ne;R.suspend();let z=f.Et({weather:()=>h.getState().current,trample:()=>({position:L.getActiveState().position,isMoving:L.getGameStates().isMoving,isGrounded:L.getActiveState().isGround})});z.suspend();let B=s.Z(u,r);B.suspend();let Me=new be;Me.source(`fixedTicks`,()=>B.clock.tick),Me.source(`clockSystems`,()=>B.clock.systemCount,`gauge`);let V=new f.l(xe,B,{adapters:P,scoped:!0,navigation:Oe}),Pe=ne.d(e.logger),H=ne.l({...e.logger?{logger:e.logger}:{},report:r}),Fe=e.pluginRuntime??`client`,U=e.saveSystem??(e.saveOptions?new p.n({report:r,...e.saveOptions}):p.r({namespace:t,report:r})),Le=ue(e.saveDiagnostics),Re=[...e.saveBindings??[]],W=new Map,G=new Set,Be=new WeakSet,Ve,He,Ue,We=!1,K=!1,q=!1,Ge=!1,J=new Set,Ke=Promise.resolve(),Y=0,qe=new Set,X,Je,Ye,Xe,Ze,Qe=()=>{let e=H.context.input.get(ge);if(!(E.getStats().active&&e===Xe))try{let t=e?.createAdapter();T.releaseFocus(),E.activate(t),Xe=e}catch(e){throw E.suspend(),Xe=void 0,e}},$e=()=>X??={physicsBridge:new s.ut,inputAdapter:E,events:H.context.events,extensionIds:{physics:`gaesup.runtime.physics`,input:ge}},et=()=>{Y++;for(let e of qe)try{e()}catch(e){Pe.warn(`Runtime lifecycle subscriber failed`,{error:e})}};for(let t of ne.t(e.plugins??[],Fe))H.register(t);let Z=e=>{if(W.has(e.key))return;let t=U.register({key:e.key,serialize:()=>e.serialize()??null,hydrate:e.hydrate,...e.prepareHydrate?{prepareHydrate:t=>e.prepareHydrate(t)}:{},...e.owned?{owned:!0}:{},...e.revision?{revision:()=>e.revision()}:{},...e.reset?{reset:()=>e.reset()}:{}});W.set(e.key,t)},tt=()=>{for(let e of H.context.save.list())ze(e.value)&&(Z(e.value),G.add(e.value.key))},nt=()=>{let e=new Set;for(let t of H.context.save.list())if(ze(t.value)&&(e.add(t.value.key),!(G.has(t.value.key)||Be.has(t.value))))try{if(W.has(t.value.key))throw new p.t(t.value.key);Z(t.value),G.add(t.value.key)}catch(e){Be.add(t.value);let n={key:t.value.key,pluginId:t.pluginId,error:e};Pe.warn(`Save binding "${t.value.key}" was rejected after runtime setup.`,n),H.context.events.emit(le,n)}for(let t of G)e.has(t)||(G.delete(t),W.get(t)?.(),W.delete(t))},rt=async()=>{let t=e.assets?.source;t&&await i.getState().loadAssets(t)},it=()=>{H.context.services.register(se,Le,`gaesup.runtime`),We=!0,He=U.subscribeDiagnostics(e=>{let t=Le.report(e);Pe.warn(t.message,t),H.context.events.emit(ce,t)})},at=async e=>{U.cancelPendingLoads();let t=Ue;Ue=void 0,ve(),A.suspend(),D.suspend(),O.getState().suspend(),Ze?.(),Ze=void 0,E.suspend(),Xe=void 0,V.suspend(),P.suspend(),F.suspend(),R.suspend(),z.suspend(),B.suspend(),w.suspend(),T.suspend(),fe?.(),fe=void 0,de.reset(),S.getState().suspendTransitions(),ae.getState().reset(),y.suspendPlayback(),b.getState().stopBgm();let n,r=!1,i=e=>{r||(r=!0,n=e)},a=async e=>{try{await e()}catch(e){i(e)}};t&&await a(t),await a(()=>y.dispose()),await a(()=>ke.getState().deactivateWorldBridge()),I.nextClickNavigationRequest(),await a(()=>I.clearClickNavigationRoute());let o=e?new Set(H.list().filter(e=>e.status===`failed`).map(e=>e.manifest.id)):new Set;await a(()=>H.disposeAll());for(let e of[...H.list()].reverse())(e.status===`ready`||o.has(e.manifest.id))&&await a(()=>H.dispose(e.manifest.id));Ve?.(),Ve=void 0,G.clear(),await a(()=>Oe.dispose()),await a(()=>v.getState().close()),await a(()=>Ce.getState().reset()),await a(()=>Te.getState().reset()),await a(()=>Ee.getState().reset()),await a(()=>k.disposeInteractions());let l=X,u=Je;X=void 0,Je=void 0,l&&await a(()=>l.physicsBridge.dispose()),u&&await a(()=>u.dispose());let d=Ye;Ye=void 0,d&&await a(()=>d.dispose());let f=He;He=void 0,f&&await a(f);let p=[...W.values()];W.clear();for(let e of p)await a(e);We&&(We=!1,await a(()=>{H.context.services.remove(se)})),K&&(K=!1,await a(()=>{H.context.services.remove(s.X)})),q&&(q=!1,await a(()=>{H.context.services.remove(c.i)})),Ge&&(Ge=!1,await a(()=>{H.context.services.remove(s.at)}));for(let e of J)await a(()=>{H.context.services.remove(e)});return J.clear(),r?{failed:!0,error:n}:{failed:!1}},Q=(e,t)=>{H.context.services.register(e,t,`gaesup.runtime`),J.add(e)},ot=async()=>{if(n!==`active`){n=`setting-up`;try{k.activateInteractions(),ke.getState().activateWorldBridge(),H.context.services.register(s.X,u,`gaesup.runtime`),K=!0,H.context.services.register(c.i,k,`gaesup.runtime`),q=!0,H.context.services.register(s.at,{create:$e,inputExtensionId:ge},`gaesup.runtime`),Ge=!0,Q(s.Vt,j),Q(f.r,xe);for(let[e,t]of Object.entries({"gaesup.runtime.npc-brain-adapters":P,"gaesup.runtime.npc-reinforcement":F,"gaesup.runtime.interactables-store":O,"gaesup.runtime.input-actions":D,"gaesup.runtime.gamepad":M,"gaesup.runtime.cinematics":A}))H.context.services.register(e,t,`gaesup.runtime`),J.add(e);Q(he,b),Q(p.v,x),Q(p.u,S),Q(d.t,h),Q(m.l,v);for(let[e,t]of Object.entries({"gaesup.runtime.world-object-store":ke,"gaesup.runtime.world-bridge":Ae,"gaesup.runtime.world-views":R,"gaesup.runtime.input-scope":T,"gaesup.runtime.gameplay-event-registry":C,"gaesup.runtime.gameplay-events":w}))H.context.services.register(e,t,`gaesup.runtime`),J.add(e);it(),H.context.services.register(`gaesup.runtime.save-system`,U,`gaesup.runtime`),J.add(`gaesup.runtime.save-system`);for(let e of Re)Z(e);e.assets?.loadOnCreate&&await rt(),await H.setupAll(),tt(),Ve=H.onLifecycle(nt);let t=`gameplay-events`;W.set(t,U.register({key:t,serialize:()=>w.serialize(),revision:()=>w.revision(),hydrate:e=>w.hydrate(e),prepareHydrate:e=>w.prepareHydrate(e)})),Ue=U.registerRestoreGuard(()=>{let e=Y,t=n===`active`,r=()=>{t&&n===`active`&&Y===e&&(A.resume(),S.getState().resumeTransitions(),w.resume(),V.resume())};try{V.suspend(),A.suspend(),S.getState().suspendTransitions(),y.cancelSfx(),w.suspend()}catch(e){throw r(),e}return r}),Qe(),Ze=H.context.input.subscribe?.(e=>{(e===null||e===ge)&&Qe()}),n=`active`,w.resume(),S.getState().resumeTransitions(),y.resumePlayback(),T.resume(),z.resume(),R.resume(),P.resume(),F.resume(),V.resume(),O.getState().resume(),D.resume(),A.resume(),N=k.subscribe(()=>M.refresh()),_e=j.subscribe(()=>M.refresh()),M.resume();let r=B.clock.addSystem({id:`gameplay-areas`,phase:`postSimulation`,update:()=>de.update(L.getActiveState().position)}),i=u.getState().addListener(e=>{e.kind===`newHour`&&oe({type:`timeChanged`,hour:e.time.hour})});fe=()=>{r(),i()},B.resume(),et()}catch(e){throw await at(!0),n=`inactive`,e}}},st=async()=>{if(ve(),A.suspend(),D.suspend(),O.getState().suspend(),Ze?.(),Ze=void 0,E.suspend(),V.suspend(),P.suspend(),F.suspend(),R.suspend(),Ae.suspend(),z.suspend(),B.suspend(),w.suspend(),T.suspend(),S.getState().suspendTransitions(),ae.getState().reset(),y.suspendPlayback(),b.getState().stopBgm(),n===`inactive`){let e=await at(!1);if(e.failed)throw e.error;return}n=`disposing`,et();let e=await at(!1);if(n=`inactive`,e.failed)throw e.error},ct=e=>{let t=Ke.then(e);return Ke=t.catch(()=>void 0),t};return{worldId:t,reportError:r,assetStore:i,dialogRegistry:re,store:k,timeStore:u,clockLoop:B,stats:Me,inputScope:T,inputActions:D,gamepad:M,interactablesStore:O,cinematics:A,navigation:Oe,clickNavigation:I,stateManager:L,inputAdapter:E,grassManager:z,worldBridge:Ae,worldObjectStore:ke,worldViews:R,weatherStore:h,dialogStore:v,audioEngine:y,audioStore:b,characterStore:x,sceneStore:S,roomVisibilityStore:ae,gameplayEventRegistry:C,gameplayEvents:w,gameplayAreas:de,buildingStore:j,npcStore:xe,npcScheduler:Se,npcSimulation:V,npcBrainAdapters:P,npcReinforcement:F,buildingRenderStore:Ce,buildingCullingStore:Te,buildingVisibilityStore:Ee,navigationObstacles:De,get motions(){return $e()},get motionBridge(){return Je??=new s.ur},get animationBridge(){return Ye??=new s.pr},isActive:()=>n===`active`,getLifecycleRevision:()=>Y,subscribeLifecycle:e=>(qe.add(e),()=>{qe.delete(e)}),pluginRuntime:Fe,plugins:H,save:U,saveDiagnostics:Le,loadAssets:rt,getService:e=>H.context.services.get(e),requireService:e=>H.context.services.require(e),setup:()=>ct(ot),dispose:()=>(U.cancelPendingLoads(),ct(st))}}var Be={isRiderOn:!1,position:(0,w.vec3)(),rotation:(0,w.euler)(),offset:(0,w.vec3)(),visible:!0};function Ve(){let e=s.mr(),t=c.s(),{gameStates:n,updateGameStates:r,activeState:i}=s.Y(),a=c.o(e=>e.rideable),o=c.o(e=>e.urls),l=c.o(e=>e.setMode),u=c.o(e=>e.setRideable),d=c.o(e=>e.setUrls),f=(0,x.useCallback)(e=>e===`airplane`?`airplane`:`vehicle`,[]),p=(0,x.useCallback)(e=>{let t={},n=e.ridingUrl??o.characterUrl;if(typeof n==`string`&&n.length>0&&(t.ridingUrl=n),e.objectType===`airplane`){t.airplaneUrl=e.url??``,d(t);return}e.objectType&&(t.vehicleUrl=e.url??``),d(t)},[d,o]),m=(0,x.useCallback)(e=>{let t=a[e];if(!t?.position)return;let n=i.position.clone().add(t.landingOffset??(0,w.vec3)());r({canRide:!1,isRiding:!1,currentRideable:void 0}),u(e,{...t,isOccupied:!1,isRiderOn:!1,visible:!0,position:n}),t.onExit?.(e)},[a,r,u,i.position]),h=(0,x.useCallback)(async()=>{if(n.canRide&&n.nearbyRideable&&!n.isRiding){let{objectkey:e,objectType:t}=n.nearbyRideable,i=a[e];if(!i||i.enableRiding===!1||i.isOccupied)return;p(i),l({type:f(t)}),r({currentRideable:n.nearbyRideable,isRiding:!0,canRide:!1,nearbyRideable:void 0}),u(e,{...i,isOccupied:!0,isRiderOn:!0,visible:!1}),i.onRide?.(e)}},[n.canRide,n.nearbyRideable,n.isRiding,a,p,l,f,r,u]),g=(0,x.useCallback)(async()=>{n.isRiding&&n.currentRideable&&(m(n.currentRideable.objectkey),l({type:`character`}),r({isRiding:!1,currentRideable:void 0}))},[n.isRiding,n.currentRideable,m,l,r]);return(0,x.useEffect)(()=>{let t=e.listen(`keydown`,e=>{e.defaultPrevented||e.isComposing||e.ctrlKey||e.metaKey||e.altKey||e.code===`KeyF`&&(e.repeat||(n.canRide&&n.nearbyRideable?(e.preventDefault(),h()):n.isRiding&&(e.preventDefault(),g())))});return()=>t()},[e,n.canRide,n.nearbyRideable,n.isRiding,h,g]),{initRideable:(0,x.useCallback)(e=>{let n=t.getState().rideable[e.objectkey];u(e.objectkey,{...n?{}:Be,...e})},[u,t]),updateRideable:(0,x.useCallback)(e=>{u(e.objectkey,e)},[u,t]),getRideable:e=>a[e],onRideableNear:(0,x.useCallback)(async(e,t)=>{if((e.other.rigidBodyObject&&e.other.rigidBodyObject.name===`character`||e.other.rigidBodyObject&&!e.other.rigidBodyObject.name||e.other.rigidBody)&&!n.isRiding){if(!t.objectType||t.enableRiding===!1||t.isOccupied)return;r({nearbyRideable:{id:t.objectkey,objectkey:t.objectkey,objectType:t.objectType,...t.position?{position:t.position.clone()}:{},...t.rotation?{rotation:t.rotation.clone()}:{},type:`rideable`,maxSpeed:t.maxSpeed??(t.objectType===`airplane`?38:18),acceleration:t.acceleration??(t.objectType===`airplane`?14:9),deceleration:t.deceleration??8,isOccupied:!1,controls:{forward:!1,backward:!1,left:!1,right:!1,brake:!1},name:t.objectType===`vehicle`?`Vehicle`:t.objectType===`airplane`?`Airplane`:`Rideable`,...t.rideMessage?{rideMessage:t.rideMessage}:{},...t.exitMessage?{exitMessage:t.exitMessage}:{},...t.displayName?{displayName:t.displayName}:{}},canRide:!0})}},[n.isRiding,r]),onRideableLeave:(0,x.useCallback)(async e=>{(e.other.rigidBodyObject&&e.other.rigidBodyObject.name===`character`||e.other.rigidBodyObject&&!e.other.rigidBodyObject.name||e.other.rigidBody)&&r({nearbyRideable:void 0,canRide:!1})},[r]),enterRideable:h,exitRideable:g,landing:m}}function He(e,t,n){let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(`${n} timed out after ${t}ms`)),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))}function Ue(e,t,n,r=10){let i=Number.isNaN(r)?10:Math.max(1,Math.floor(r)),a=`${t}_`,o=e=>Number(e.slice(a.length));return e.filter(e=>e!==n&&e.startsWith(a)&&/^\d+$/.test(e.slice(a.length))).sort((e,t)=>o(t)-o(e)).slice(i-1)}var We=`1.0.0`,K=`gaesup_world_save_`,q=`base64-json:`,Ge=`gaesup-world:gzip-json:v1`,J=5e3,Ke=class{constructor(e={}){this.version=e.version??We,this.storage=e.storage,this.fileWriter=e.fileWriter,this.now=e.now??Date.now,this.maxSlotsPerWorld=e.maxSlotsPerWorld??10}async save(e,t,n={}){try{let r=this.createSaveData(e,t,n),i=n.compress?await He(this.compressData(r),J,`save`):JSON.stringify(r);return this.writeSlot(r,i),{success:!0,data:r}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Unknown error occurred`}}}async load(e,t={}){try{let n=`${K}${e}`,r=this.getStorage().getItem(n);if(!r)throw Error(`Save data not found: ${e}`);let i=await He(this.parseStoredSaveData(r),J,`load`);if(!this.validateSaveData(i))throw Error(`Invalid save data format`);return{success:!0,data:{...i,world:this.filterWorldData(i.world,t)}}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to load save data`}}}async saveToFile(e,t,n,r={}){try{let i=this.createSaveData(e,n,r);return await this.writeFile(t,i),{success:!0,data:i}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to save file`}}}async loadFromFile(e,t={}){try{let n=await e.text(),r=JSON.parse(n);if(!this.validateSaveData(r))throw Error(`Invalid save file format`);return{success:!0,data:{...r,world:this.filterWorldData(r.world,t)}}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Failed to load file`}}}listSaves(){let e=[],t;try{t=this.getStorage()}catch(t){return o.r(t,{source:`save:list`}),e}for(let n=0;n<t.length;n++){let r=t.key(n);if(r&&r.startsWith(K))try{let n=r.substring(18),i=t.getItem(r);if(i){let t=this.parseStoredSaveDataSync(i);e.push({id:n,timestamp:t.timestamp,...t.metadata?{metadata:t.metadata}:{}})}}catch(e){o.r(e,{source:`save:list`,label:r})}}return e.sort((e,t)=>t.timestamp-e.timestamp)}deleteSave(e){try{let t=`${K}${e}`;return this.getStorage().removeItem(t),!0}catch(t){return o.r(t,{source:`save:delete`,label:e}),!1}}filterWorldData(e,t){let n={...e};return t.includeBuildings===!1&&(n.buildings={wallGroups:[],tileGroups:[],blocks:[],meshes:[]}),t.includeNPCs===!1&&(n.npcs=[]),t.includeEnvironment===!1&&(n.environment={lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}}),t.includeCamera===!1&&delete n.camera,n}createSaveData(e,t,n={}){let r=this.now();return{version:this.version,timestamp:r,world:this.filterWorldData(e,n),...t?{metadata:{...t,createdAt:t.createdAt||r,updatedAt:r}}:{}}}getStorage(){if(this.storage)return this.storage;if(typeof localStorage>`u`)throw Error(`Legacy save storage is not available in this environment`);return localStorage}async writeFile(e,t){if(this.fileWriter){await this.fileWriter(e,t);return}if(typeof document>`u`||typeof URL>`u`||typeof Blob>`u`)throw Error(`File download is not available in this environment`);let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e.endsWith(`.json`)?e:`${e}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}writeSlot(e,t){let n=`${e.world.id}_${e.timestamp}`,r=this.getStorage();try{r.setItem(`${K}${n}`,t)}catch(e){throw e instanceof Error&&e.name===`QuotaExceededError`?Error(`Storage quota exceeded. Please delete some saves.`):e}let i=[];for(let e=0;e<r.length;e++){let t=r.key(e);t?.startsWith(K)&&i.push(t.slice(18))}for(let t of Ue(i,e.world.id,n,this.maxSlotsPerWorld))r.removeItem(`${K}${t}`)}async compressData(e){let t=JSON.stringify(e);if(!Xe())return`${q}${Y(Je(t))}`;let n=await this.gzipBytes(Je(t)),r={encoding:Ge,version:e.version,timestamp:e.timestamp,worldId:e.world.id,worldName:e.world.name,...e.metadata?{metadata:e.metadata}:{},payload:Y(n)};return JSON.stringify(r)}async decompressData(e){let t=qe(e),n=Ye(await this.gunzipBytes(t));return JSON.parse(n)}async parseStoredSaveData(e){if(e.startsWith(`{`)){let t=JSON.parse(e);return Qe(t)?this.decompressData(t.payload):t}return e.startsWith(q)?X(e.slice(12)):X(e)}parseStoredSaveDataSync(e){if(e.startsWith(`{`)){let t=JSON.parse(e);return Qe(t)?{version:t.version,timestamp:t.timestamp,world:{id:t.worldId,name:t.worldName,buildings:{wallGroups:[],tileGroups:[],blocks:[],meshes:[]},npcs:[],environment:{lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}}},...t.metadata?{metadata:t.metadata}:{}}:t}return e.startsWith(q)?X(e.slice(12)):X(e)}async gzipBytes(e){if(!Xe())return e;let t=new Blob([e]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async gunzipBytes(e){if(!Ze())return e;let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}validateSaveData(e){return typeof e==`object`&&!!e&&`version`in e&&`timestamp`in e&&`world`in e&&typeof e.version==`string`&&typeof e.timestamp==`number`&&e.world&&typeof e.world.id==`string`&&typeof e.world.name==`string`}};function Y(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function qe(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function X(e){return JSON.parse(Ye(qe(e)))}function Je(e){if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function Ye(e){if(typeof TextDecoder<`u`)return new TextDecoder().decode(e);let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return decodeURIComponent(escape(t))}function Xe(){return typeof CompressionStream<`u`&&typeof Blob<`u`&&typeof Response<`u`&&typeof new Blob().stream==`function`}function Ze(){return typeof DecompressionStream<`u`&&typeof Blob<`u`&&typeof Response<`u`&&typeof new Blob().stream==`function`}function Qe(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.encoding===Ge&&typeof t.version==`string`&&typeof t.timestamp==`number`&&typeof t.worldId==`string`&&typeof t.worldName==`string`&&typeof t.payload==`string`}var $e={lighting:{ambientIntensity:1,directionalIntensity:1,directionalPosition:{x:0,y:10,z:0}}};function et(e){return typeof structuredClone==`function`?structuredClone(e):JSON.parse(JSON.stringify(e))}function Z(e){return Array.isArray(e)?e.map(e=>et(e)):[]}function tt(e,t){let n=e[t];return h.r(n)?n:void 0}function nt(e){if(Array.isArray(e)&&e.length>=3){let[t,n,r]=e;if(typeof t==`number`&&typeof n==`number`&&typeof r==`number`)return{x:t,y:n,z:r}}if(h.r(e)&&typeof e.x==`number`&&typeof e.y==`number`&&typeof e.z==`number`)return{x:e.x,y:e.y,z:e.z}}function rt(e){if(!h.r(e)||typeof e.id!=`string`)return null;let t=nt(e.position)??{x:0,y:0,z:0},n=nt(e.rotation)??{x:0,y:0,z:0},r=h.r(e.metadata)?et(e.metadata):void 0,i=h.r(e.behavior)?e.behavior:void 0,a=i&&typeof i.mode==`string`?i.mode:void 0;return{id:e.id,name:typeof e.name==`string`?e.name:e.id,position:t,rotation:n,...typeof e.modelUrl==`string`?{modelUrl:e.modelUrl}:{},...a?{behavior:a}:{},...r?{metadata:r}:{}}}function it(e){let t=e?.instances;return Array.isArray(t)?t.map(rt).filter(e=>e!==null):[]}function at(e){if(!e)return;let t=h.r(e.mode)?e.mode:void 0,n=typeof e.mode==`string`?e.mode:t&&typeof t.control==`string`?t.control:`default`,r=h.r(e.settings)?et(e.settings):h.r(e.cameraOption)?et(e.cameraOption):void 0;return{mode:n,...r?{settings:r}:{}}}function Q(e,t,n){let r=tt(e,`building`),i=at(tt(e,`camera`));return{id:t,name:n,buildings:{wallGroups:Z(r?.wallGroups),tileGroups:Z(r?.tileGroups),blocks:Z(r?.blocks),meshes:Z(r?.meshes)},npcs:it(tt(e,`npc`)),environment:$e,...i?{camera:i}:{}}}function ot(e){let t=e.slice(e.lastIndexOf(`_`)+1),n=Number(t);return Number.isFinite(n)?n:Date.now()}function st(e){let t=e.lastIndexOf(`_`);return t>0?e.slice(0,t):e}function ct(e,t){if(e)return{...e,createdAt:e.createdAt??t,updatedAt:e.updatedAt??t}}function lt(e,t,n,r){let i=ot(t),a=st(t),o={version:`1.0.0`,timestamp:i,world:Q(y.r(e),a,n??a)},s=ct(r,i);return s?{...o,metadata:s}:o}var ut=()=>({});function dt(e,t,n){let{buildingStore:r,npcStore:i,cameraStore:a}=e;if(!r)throw Error(`Building store not initialized`);let o=r.getState(),s=a?.getState(),c=s?{mode:s.mode,...s.settings?{settings:s.settings}:{}}:void 0;return{id:t,name:n,buildings:{wallGroups:Array.from(o.wallGroups.values()),tileGroups:Array.from(o.tileGroups.values()),blocks:Array.from(o.blocks),meshes:Array.from(o.meshes.values())},npcs:i?Array.from(i.getState().instances.values()):[],environment:$e,...c?{camera:c}:{}}}function ft(e,t){if(!e||!t)return;let n=e.getState();if(typeof n.hydrate==`function`){n.hydrate(t);return}if(e.setState){e.setState({wallGroups:new Map(t.wallGroups.map(e=>[e.id,e])),tileGroups:new Map(t.tileGroups.map(e=>[e.id,e])),meshes:new Map(t.meshes.map(e=>[e.id,e])),blocks:[...t.blocks??[]]});return}n.wallGroups.clear(),n.tileGroups.clear(),n.meshes.clear(),n.blocks=[],t.wallGroups.forEach(e=>{n.wallGroups.set(e.id,e)}),t.tileGroups.forEach(e=>{n.tileGroups.set(e.id,e)}),t.meshes.forEach(e=>{n.meshes.set(e.id,e)}),n.blocks=[...t.blocks??[]]}function pt(e,t){if(!e||!t)return;if(e.setState){e.setState({instances:new Map(t.map(e=>[e.id,e]))});return}let n=e.getState();n.instances.clear(),t.forEach(e=>{n.instances.set(e.id,e)})}function mt(e,t){e&&t&&e.setState({mode:t.mode,settings:t.settings||{}})}function ht(e,t){ft(e.buildingStore,t.buildings),pt(e.npcStore,t.npcs),mt(e.cameraStore,t.camera)}function gt(e){return e.replace(/\.json$/i,``)}function _t(e){return h.r(e)&&typeof e.version==`number`&&typeof e.savedAt==`number`&&h.r(e.domains)}function vt(e){return h.r(e)&&e.kind===`gaesup.save-system`&&typeof e.worldId==`string`&&typeof e.worldName==`string`&&_t(e.blob)}async function yt(e){return(await e.list()).map(e=>({id:e,timestamp:ot(e)})).sort((e,t)=>t.timestamp-e.timestamp)}async function bt(e,t,n,r){let i=Ue(await e.list(),t,n,r);await Promise.all(i.map(t=>e.remove(t)))}function xt(e,t){if(typeof document>`u`||typeof URL>`u`||typeof Blob>`u`)throw Error(`File download is not available in this environment`);let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e.endsWith(`.json`)?e:`${e}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function St(e){let t=JSON.parse(await e.text());if(vt(t)||_t(t))return t;throw Error(`Invalid SaveSystem file format`)}function Ct(e={}){let t=e.getStores??ut,n=e.saveSystem,{maxSlotsPerWorld:r}=e;return(i,a)=>({saveLoadManager:e.saveLoadManager??new Ke(r===void 0?{}:{maxSlotsPerWorld:r}),currentSaveId:null,saves:[],isSaving:!1,isLoading:!1,lastError:null,saveWorld:async(e,o,s,c)=>{i({isSaving:!0,lastError:null});try{if(n){let t=`${e}_${Date.now()}`;await n.save(t),await bt(n,e,t,r),i({currentSaveId:t,saves:await yt(n)});return}let l=dt(t(),e,o),u=await a().saveLoadManager.save(l,s,c);if(u.success)i({currentSaveId:`${e}_${u.data.timestamp}`}),a().refreshSaveList();else throw Error(u.error)}catch(e){throw i({lastError:e instanceof Error?e.message:`Save failed`}),e}finally{i({isSaving:!1})}},loadWorld:async(e,r)=>{i({isLoading:!0,lastError:null});try{if(n){if(!await n.load(e))throw Error(`Save data not found: ${e}`);return i({currentSaveId:e}),lt(n,e)}let o=await a().saveLoadManager.load(e,r);if(o.success&&o.data)return ht(t(),o.data.world),i({currentSaveId:e}),o.data;throw Error(o.error)}catch(e){return i({lastError:e instanceof Error?e.message:`Load failed`}),null}finally{i({isLoading:!1})}},saveToFile:async(e,r,o,s,c)=>{i({isSaving:!0,lastError:null});try{if(n){xt(o,{kind:`gaesup.save-system`,version:1,worldId:e,worldName:r,blob:n.createBlob(o),...s?{metadata:s}:{}});return}let i=dt(t(),e,r),l=await a().saveLoadManager.saveToFile(i,o,s,c);if(!l.success)throw Error(l.error)}catch(e){throw i({lastError:e instanceof Error?e.message:`Save to file failed`}),e}finally{i({isSaving:!1})}},loadFromFile:async(e,r)=>{i({isLoading:!0,lastError:null});try{if(n){let t=await St(e),r=vt(t)?t.blob:t;n.hydrateBlob(r,e.name);let i=vt(t)?t.worldId:gt(e.name),a=vt(t)?t.worldName:i,o=r.savedAt,s={version:String(r.version),timestamp:o,world:Q(r.domains,i,a)},c=vt(t)?ct(t.metadata,o):void 0;return c?{...s,metadata:c}:s}let i=await a().saveLoadManager.loadFromFile(e,r);if(i.success&&i.data)return ht(t(),i.data.world),i.data;throw Error(i.error)}catch(e){return i({lastError:e instanceof Error?e.message:`Load from file failed`}),null}finally{i({isLoading:!1})}},refreshSaveList:()=>{if(n){yt(n).then(e=>i({saves:e})).catch(e=>{o.r(e,{source:`save:list`}),i({lastError:e instanceof Error?e.message:`Failed to list saves`})});return}i({saves:a().saveLoadManager.listSaves()})},deleteSave:e=>{if(n){(async()=>{try{await n.remove(e),i({saves:await yt(n),...a().currentSaveId===e?{currentSaveId:null}:{}})}catch(t){o.r(t,{source:`save:delete`,label:e}),i({lastError:t instanceof Error?t.message:`Failed to delete save`})}})();return}a().saveLoadManager.deleteSave(e)&&(a().refreshSaveList(),a().currentSaveId===e&&i({currentSaveId:null}))},clearError:()=>{i({lastError:null})}})}var wt=Ct();function Tt({object:e,selected:t=!1,onSelect:n,showDebugInfo:r=!1}){let i=_.t(),a=e.metadata?.airplaneUrl??e.metadata?.modelUrl,o=typeof a==`string`?a:void 0;if(typeof o!=`string`||o.length===0)return null;let c=e.metadata?.ridingUrl,l=typeof c==`string`?c:void 0,u=e.metadata?.currentAnimation,d=typeof u==`string`?u:`idle`;return(0,C.jsx)(s.n,{url:o,isActive:!1,componentType:`airplane`,name:`active-airplane-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,currentAnimation:d,...l?{ridingUrl:l}:{},ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,userData:{id:e.id,type:`active`,subType:`airplane`,health:e.health,maxHealth:e.maxHealth,energy:e.energy,maxEnergy:e.maxEnergy},onCollisionEnter:()=>{n&&n(e.id)},children:t&&r&&(0,C.jsxs)(`mesh`,{position:[0,3,0],children:[(0,C.jsx)(`boxGeometry`,{args:[.5,.5,.5]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#00ffff`,transparent:!0,opacity:.6})]})})}function Et({object:e,selected:t=!1,onSelect:n,showDebugInfo:r=!1}){let i=_.t();(0,x.useEffect)(()=>{i.rigidBodyRef&&i.rigidBodyRef.current&&i.rigidBodyRef.current.setEnabledRotations(!1,!1,!1,!1)},[i.rigidBodyRef]);let a=e.metadata?.characterUrl;if(typeof a!=`string`||a.length===0)return null;let o=e.metadata?.currentAnimation,c=typeof o==`string`?o:`idle`,l=e.metadata?.nameTag,u=typeof l==`string`?l:void 0;return(0,C.jsx)(s.n,{url:a,isActive:!1,componentType:`character`,name:`active-character-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,currentAnimation:c,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,userData:{id:e.id,type:`active`,subType:`character`,health:e.health,maxHealth:e.maxHealth,energy:e.energy,maxEnergy:e.maxEnergy,nameTag:u},onCollisionEnter:()=>{n&&n(e.id)},children:t&&r&&(0,C.jsxs)(`mesh`,{position:[0,3,0],children:[(0,C.jsx)(`boxGeometry`,{args:[.5,.5,.5]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#ff0000`,transparent:!0,opacity:.6})]})})}function Dt({object:e,selected:t=!1,onSelect:n,showDebugInfo:r=!1}){let i=_.t(),a=e.metadata?.vehicleUrl??e.metadata?.modelUrl,o=typeof a==`string`?a:void 0;if(typeof o!=`string`||o.length===0)return null;let c=e.metadata?.ridingUrl,l=typeof c==`string`?c:void 0,u=e.metadata?.currentAnimation,d=typeof u==`string`?u:`idle`;return(0,C.jsx)(s.n,{url:o,isActive:!1,componentType:`vehicle`,name:`active-vehicle-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,currentAnimation:d,...l?{ridingUrl:l}:{},ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,userData:{id:e.id,type:`active`,subType:`vehicle`,health:e.health,maxHealth:e.maxHealth,energy:e.energy,maxEnergy:e.maxEnergy},onCollisionEnter:()=>{n&&n(e.id)},children:t&&r&&(0,C.jsxs)(`mesh`,{position:[0,3,0],children:[(0,C.jsx)(`boxGeometry`,{args:[.5,.5,.5]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#0000ff`,transparent:!0,opacity:.6})]})})}function Ot({objects:e,selectedId:t,onSelect:n,showDebugInfo:r=!1}){let{gameStates:i}=s.Y(),a=c.o(e=>e.mode);return(0,C.jsx)(`group`,{name:`active-objects`,children:e.map(e=>{let o=e.id===t;if(e.type===`character`&&i?.isRiding&&a?.type!==`character`)return null;switch(e.type){case`vehicle`:return(0,C.jsx)(Dt,{object:e,selected:o,...n?{onSelect:n}:{},showDebugInfo:r},e.id);case`airplane`:return(0,C.jsx)(Tt,{object:e,selected:o,...n?{onSelect:n}:{},showDebugInfo:r},e.id);case`character`:return(0,C.jsx)(Et,{object:e,selected:o,...n?{onSelect:n}:{},showDebugInfo:r},e.id);default:return null}})})}function kt(e){let{children:t,visible:n=!0,...r}=e,i=_.t();return(0,C.jsx)(`group`,{visible:n,children:(0,C.jsx)(s.n,{...r,url:r.url||``,isActive:!1,componentType:`vehicle`,name:r.name??`vehicle`,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,children:t})})}function At(e){let{children:t,visible:n=!0,...r}=e,i=_.t();return(0,C.jsx)(`group`,{visible:n,children:(0,C.jsx)(s.n,{...r,url:r.url||``,isActive:!1,componentType:`airplane`,name:r.name??`airplane`,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,children:t})})}function jt(e){let{children:t,visible:n=!0,...r}=e,i=_.t();(0,x.useEffect)(()=>{i.rigidBodyRef&&i.rigidBodyRef.current&&i.rigidBodyRef.current.setEnabledRotations(!1,!1,!1,!1)},[i.rigidBodyRef]);let a=r.controllerOptions??{lerp:{cameraTurn:1,cameraPosition:1}};return(0,C.jsx)(`group`,{visible:n,children:(0,C.jsx)(s.n,{...r,url:r.url||``,isActive:!1,componentType:`character`,controllerOptions:a,ref:i.rigidBodyRef,outerGroupRef:i.outerGroupRef,innerGroupRef:i.innerGroupRef,colliderRef:i.colliderRef,children:t})})}var Mt=22500,Nt=(0,x.memo)(function({object:e,isSelected:t,onSelect:n,showDebugInfo:r=!1,enableInteraction:i=!0}){let a=_.t(),o=e.metadata?.modelUrl,c=typeof o==`string`?o:void 0,l=(0,x.useCallback)(()=>{i&&e.interactable&&n&&n(e.id)},[i,e.interactable,e.id,n]),u=(0,x.useCallback)(t=>{i&&e.interactable&&(t.stopPropagation(),document.body.style.cursor=`pointer`)},[i,e.interactable]),d=(0,x.useCallback)(()=>{document.body.style.cursor=`default`},[]);return c?(0,C.jsx)(s.n,{url:c,isActive:!1,componentType:e.type,name:`passive-${e.type}-${e.id}`,position:e.position,rotation:e.rotation,scale:e.scale,ref:a.rigidBodyRef,outerGroupRef:a.outerGroupRef,innerGroupRef:a.innerGroupRef,colliderRef:a.colliderRef,userData:{id:e.id,type:`passive`,subType:e.type,interactable:e.interactable,onNear:e.metadata?.onNear,onLeave:e.metadata?.onLeave,onInteract:e.metadata?.onInteract},onCollisionEnter:()=>{i&&e.interactable&&n&&n(e.id)},children:t&&r&&(0,C.jsxs)(`mesh`,{position:[0,3,0],children:[(0,C.jsx)(`boxGeometry`,{args:[.5,.5,.5]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#00ff00`,transparent:!0,opacity:.6})]})}):(0,C.jsxs)(w.RigidBody,{type:`fixed`,position:e.position,rotation:e.rotation,colliders:!1,children:[(0,C.jsx)(w.CapsuleCollider,{args:[1,.5],position:[0,1,0]}),(0,C.jsx)(`group`,{scale:e.scale,onClick:l,onPointerEnter:u,onPointerLeave:d})]})}),Pt=(0,x.memo)(function({objects:e,selectedId:n,onSelect:r,showDebugInfo:i=!1,enableInteraction:a=!0}){let[o,s]=(0,x.useState)(()=>new Set),c=(0,x.useRef)(0),l=(0,ae.useThree)(e=>e.get);t.t(`effects`,t=>{if(c.current+=t,c.current<.5)return;c.current=0;let n=l().camera.position,r=new Set;for(let t of e){let e=t.position.x,i=t.position.y,a=t.position.z,o=e-n.x,s=i-n.y,c=a-n.z;o*o+s*s+c*c<=Mt&&r.add(t.id)}(r.size!==o.size||[...r].some(e=>!o.has(e)))&&s(r)},{label:`world:passive-objects-lod`});let u=(0,x.useMemo)(()=>e.filter(e=>o.has(e.id)).map(e=>(0,C.jsx)(Nt,{object:e,isSelected:e.id===n,...r?{onSelect:r}:{},showDebugInfo:i,enableInteraction:a},e.id)),[e,n,r,i,a,o]);return(0,C.jsx)(`group`,{name:`passive-objects`,children:u})});function Ft(e){let{states:t}=e;return!t||!t.canRide&&!t.isRiding?null:(0,C.jsx)(It,{...e})}function $(...e){return e.filter(Boolean).join(` `)}function It({states:e,actionKey:t=`F`,unstyled:n=!1,className:r,classNames:i,styles:a,labels:o}){let s=e.nearbyRideable??e.currentRideable;if(!s)return null;let c=o?.ride?.(s)??s.rideMessage??`Press ${t} to ride ${s.displayName??s.name??`vehicle`}`,l=o?.exit?.(s)??s.exitMessage??`Press ${t} to exit`,u=e.isRiding?l:c,d=$(!n&&`rideable-ui-container`,i?.root,r),f=$(!n&&`rideable-message-box`,i?.box),p=$(!n&&`rideable-message`,i?.message),m=$(!n&&`rideable-key`,i?.key),h=$(!n&&`rideable-stats`,i?.stats),g=$(!n&&`rideable-stat`,i?.stat),ee=$(!n&&`rideable-stat__label`,i?.statLabel),_=$(!n&&`rideable-stat__value`,i?.statValue);return(0,C.jsx)(`div`,{className:d||void 0,style:a?.root,children:(0,C.jsxs)(`div`,{className:f||void 0,style:a?.box,children:[(0,C.jsx)(`kbd`,{className:m||void 0,style:a?.key,children:t}),(0,C.jsx)(`div`,{className:p||void 0,style:a?.message,children:u}),(0,C.jsxs)(`div`,{className:h||void 0,style:a?.stats,children:[(0,C.jsxs)(`div`,{className:g||void 0,style:a?.stat,children:[(0,C.jsx)(`span`,{className:ee||void 0,style:a?.statLabel,children:o?.speed??`속도`}),(0,C.jsx)(`span`,{className:_||void 0,style:a?.statValue,children:s.maxSpeed})]}),(0,C.jsxs)(`div`,{className:g||void 0,style:a?.stat,children:[(0,C.jsx)(`span`,{className:ee||void 0,style:a?.statLabel,children:o?.acceleration??`가속`}),(0,C.jsx)(`span`,{className:_||void 0,style:a?.statValue,children:s.acceleration})]})]})]})})}function Lt(e){let t=c.o(e=>e.rideable),{initRideable:n,onRideableNear:r,onRideableLeave:i,landing:a}=Ve();(0,x.useEffect)(()=>{n(e)},[e,n]);let{controllerOptions:o,...s}=e,l=o?.lerp?{lerp:{cameraTurn:o.lerp.cameraTurn??1,cameraPosition:o.lerp.cameraPosition??1}}:void 0,u={objectType:e.objectType,objectkey:e.objectkey,rideable:!0,init:n,onNear:r,onLeave:i,landing:a,rideMessage:e.rideMessage,exitMessage:e.exitMessage,displayName:e.displayName};return(0,C.jsxs)(C.Fragment,{children:[e.objectType===`vehicle`&&(0,C.jsx)(kt,{...s,...l?{controllerOptions:l}:{},userData:u,sensor:!0,visible:t[e.objectkey]?.visible!==!1&&!t[e.objectkey]?.isOccupied}),e.objectType===`airplane`&&(0,C.jsx)(At,{...s,...l?{controllerOptions:l}:{},userData:u,sensor:!0,visible:t[e.objectkey]?.visible!==!1&&!t[e.objectkey]?.isOccupied})]})}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return At}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return st}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return ye}});
|
|
@@ -2,8 +2,8 @@ import { t as e } from "./logger-CIvdj60w.js";
|
|
|
2
2
|
import { n as t } from "./runtimeContext-IAbUva69.js";
|
|
3
3
|
import { t as n } from "./scopedStore-DgCiroRs.js";
|
|
4
4
|
import { r } from "./reportError-B14ENRN4.js";
|
|
5
|
-
import { qt as i } from "./useClicker-
|
|
6
|
-
import { o as a } from "./CoreBridge-
|
|
5
|
+
import { qt as i } from "./useClicker-ChI9FA0J.js";
|
|
6
|
+
import { o as a } from "./CoreBridge-CoU_vJOo.js";
|
|
7
7
|
import { n as o } from "./serviceKey-DSiyXcgA.js";
|
|
8
8
|
import { f as s } from "./clientServices-BKUcxr74.js";
|
|
9
9
|
import * as c from "three";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./logger-B9OaKOPw.cjs"),n=require("./runtimeContext-zx_GnKx4.cjs"),r=require("./scopedStore-Px5jL718.cjs"),i=require("./reportError-CkJ7vZsX.cjs"),a=require("./useClicker-0Ln5ZSz0.cjs"),o=require("./CoreBridge-CnLqWZNv.cjs"),s=require("./serviceKey-DwHFFFAA.cjs"),c=require("./clientServices-Bs-PZVqS.cjs");let l=require("three");l=e.n(l,1);let u=require("zustand");var d=new WeakMap;function f(e){return{...e,...e.offset?{offset:e.offset.clone()}:{},...e.focusTarget?{focusTarget:e.focusTarget.clone()}:{},...e.fixedPosition?{fixedPosition:e.fixedPosition.clone()}:{},...e.smoothing?{smoothing:{...e.smoothing}}:{},...e.bounds?{bounds:{...e.bounds}}:{}}}function p(e){return e instanceof l.Vector3?e.clone():Array.isArray(e)?new l.Vector3(e[0],e[1],e[2]):new l.Vector3(e.x,e.y,e.z)}function m(e,t={}){return{enableFocus:!0,focus:!0,focusTarget:p(e),focusDistance:t.focusDistance??4,focusLerpSpeed:t.focusLerpSpeed??8,fov:t.fov??46,enableCollision:t.enableCollision??!1}}function h(e,t={},n=o.o){let r=n.getState();return t.rememberPrevious!==!1&&!d.has(n)&&d.set(n,f(r.cameraOption)),r.setCameraOption(m(e,t)),()=>g(n)}function g(e=o.o){let t=e.getState(),n=d.get(e);if(n){t.replaceCameraOption({...f(n),focus:!1}),d.delete(e);return}t.setCameraOption({focus:!1})}var _={name:`플레이어`,colors:{body:`#ffd9b8`,hair:`#3a2a1a`,hat:`#5a8acf`,top:`#f0e0c8`,bottom:`#3a4a6a`,shoes:`#3a2a1a`},face:`default`,hair:`short`},v={hat:`모자`,top:`상의`,bottom:`하의`,shoes:`신발`,face:`표정`,glasses:`안경`,weapon:`무기`,accessory:`액세서리`},y={short:`짧은 머리`,long:`긴 머리`,cap:`모자 머리`,bun:`묶은 머리`,spiky:`뻗친 머리`},b={default:`기본`,smile:`미소`,wink:`윙크`,sleepy:`졸림`,surprised:`놀람`},x=`player`,S={hat:null,top:null,bottom:null,shoes:null,face:null,glasses:null,weapon:null,accessory:null},C=()=>({appearance:{..._,colors:{..._.colors}},outfits:{...S}}),w=e=>({appearance:{...e.appearance,colors:{...e.appearance.colors}},outfits:{...e.outfits}});function T(e){if(!e||typeof e!=`object`||Array.isArray(e)||e.appearance!==void 0&&(!e.appearance||typeof e.appearance!=`object`||Array.isArray(e.appearance))||e.appearance?.colors!==void 0&&(!e.appearance.colors||typeof e.appearance.colors!=`object`||Array.isArray(e.appearance.colors))||e.outfits!==void 0&&(!e.outfits||typeof e.outfits!=`object`||Array.isArray(e.outfits)))throw TypeError(`Invalid character profile`);let t={appearance:{..._,...e.appearance,colors:{..._.colors,...e.appearance?.colors}},outfits:{...S,...e.outfits}};if(typeof t.appearance.name!=`string`||!Object.hasOwn(b,t.appearance.face)||!Object.hasOwn(y,t.appearance.hair)||!Object.values(t.appearance.colors).every(e=>typeof e==`string`)||!Object.values(t.outfits).every(e=>e===null||typeof e==`string`))throw TypeError(`Invalid character appearance or outfit`);return t}var E=(e,t,n)=>{let r=t??e.activeCharacterId,i=n(e.characters[r]??C()),a={...e.characters,[r]:i};return r===e.activeCharacterId?{characters:a,appearance:i.appearance,outfits:i.outfits}:{characters:a}};function D(){return(0,u.create)((e,t)=>{let n=C();return{activeCharacterId:x,characters:{[x]:n},appearance:n.appearance,outfits:n.outfits,setActiveCharacter:t=>e(e=>{let n=e.characters[t]??C();return{activeCharacterId:t,characters:{...e.characters,[t]:n},appearance:n.appearance,outfits:n.outfits}}),removeCharacter:t=>e(e=>{if(!(t in e.characters))return{};let n={...e.characters};if(delete n[t],t!==e.activeCharacterId)return{characters:n};let r=C();return n[e.activeCharacterId]=r,{characters:n,appearance:r.appearance,outfits:r.outfits}}),getProfile:e=>{let n=t(),r=n.characters[e??n.activeCharacterId];return r?w(r):C()},setName:(t,n)=>e(e=>E(e,n,e=>({...e,appearance:{...e.appearance,name:t.slice(0,16)||`플레이어`}}))),setColor:(t,n,r)=>e(e=>E(e,r,e=>({...e,appearance:{...e.appearance,colors:{...e.appearance.colors,[t]:n}}}))),setFace:(t,n)=>e(e=>E(e,n,e=>({...e,appearance:{...e.appearance,face:t}}))),setHair:(t,n)=>e(e=>E(e,n,e=>({...e,appearance:{...e.appearance,hair:t}}))),equipOutfit:(t,n,r)=>e(e=>E(e,r,e=>({...e,outfits:{...e.outfits,[t]:n}}))),resetAppearance:t=>e(e=>{if(t!==void 0)return E(e,t,()=>C());let n=C();return{activeCharacterId:x,characters:{[x]:n},appearance:n.appearance,outfits:n.outfits}}),getEquippedAssetIds:e=>{let n=t(),r=n.characters[e??n.activeCharacterId]?.outfits??S;return Object.values(r).filter(e=>typeof e==`string`&&e.length>0)},serialize:()=>{let e=t(),n={};for(let[t,r]of Object.entries(e.characters))n[t]=w(r);return{version:3,activeCharacterId:e.activeCharacterId,characters:n}},prepareHydrate:t=>{if(t==null)return()=>{};if(typeof t!=`object`||![1,2,3].includes(t.version))throw TypeError(`Invalid character snapshot`);if(t.version===3){if(!t.characters||typeof t.characters!=`object`||Array.isArray(t.characters)||typeof t.activeCharacterId!=`string`||!t.activeCharacterId.trim())throw TypeError(`Invalid character collection`);let n=Object.entries(t.characters);if(n.length===0)return()=>{};let r=Object.fromEntries(n.map(([e,t])=>{if(!e.trim())throw TypeError(`Invalid character ID`);return[e,T(t)]})),i=Object.hasOwn(r,t.activeCharacterId)?t.activeCharacterId:Object.keys(r)[0],a=r[i];return()=>e({activeCharacterId:i,characters:r,appearance:a.appearance,outfits:a.outfits})}let n=T(t);return()=>e(e=>E(e,e.activeCharacterId,()=>n))},hydrate:e=>t().prepareHydrate(e)()}})}var O=s.n(`character`),{useStore:k,useStoreApi:A}=r.t(`useCharacterStore`,D,()=>n.n()?.characterStore),j=[{id:`starter-adventurer`,label:`모험가`,face:`smile`,hair:`cap`,outfits:{hat:`ally-hat`,top:`warrior-cloth-basic`,bottom:`starter-bottom-layer`,shoes:`starter-shoes-layer`,glasses:`ally-glasses`,weapon:`starter-weapon-layer`,accessory:`starter-accessory-ring`}},{id:`rabbit-warrior`,label:`토끼 전사`,face:`wink`,hair:`spiky`,outfits:{top:`warrior-cloth-rabbit`,bottom:`starter-bottom-layer`,shoes:`starter-shoes-layer`,weapon:`starter-weapon-layer`}}];function M(e,t=k){let n=t.getState();e.face&&n.setFace(e.face),e.hair&&n.setHair(e.hair),e.colors&&Object.entries(e.colors).forEach(([e,t])=>{t&&n.setColor(e,t)}),e.outfits&&Object.entries(e.outfits).forEach(([e,t])=>{n.equipOutfit(e,t??null)})}function N(e=`starter-weapon-layer`,t=k){let n=t.getState();n.equipOutfit(`weapon`,n.outfits.weapon===e?null:e)}var P=`outdoor`;function F(e,t){return t.aborted?Promise.resolve():new Promise(n=>{let r=()=>{clearTimeout(i),t.removeEventListener(`abort`,r),n()},i=setTimeout(r,e);t.addEventListener(`abort`,r,{once:!0})})}var I=220,L=80,R=240;function z(){let e=!0,n,r=()=>{let e=n;n=void 0,e?.abort()};return(0,u.create)((i,a)=>({current:P,pending:null,scenes:{[P]:{id:P,name:`야외`,interior:!1}},transition:{progress:0,color:`#000000`,active:!1},lastReturnPoint:null,registerScene:e=>i(t=>t.scenes[e.id]?t:{scenes:{...t.scenes,[e.id]:e}}),unregisterScene:e=>{a().pending===e&&a().cancelTransition(),i(t=>{if(e===`outdoor`||!t.scenes[e])return t;let n={...t.scenes};return delete n[e],{scenes:n}})},setTransition:e=>i(t=>({transition:{...t.transition,...e}})),setReturnPoint:e=>i({lastReturnPoint:e}),cancelTransition:()=>{r(),i(e=>!e.pending&&!e.transition.active?e:{pending:null,transition:{...e.transition,active:!1,progress:0}})},suspendTransitions:()=>{e=!1,a().cancelTransition()},resumeTransitions:()=>{e=!0},goTo:async(r,o)=>{let s=a();if(!e||o?.signal?.aborted||s.pending||r===s.current&&!o?.entry)return;let c=s.scenes[r];if(!c){t.t.warn(`[scene] Unknown scene "${r}". Did you forget to register it?`);return}let l=c.interior??!1?`#0d0d10`:`#f5f5f5`,u=new AbortController;n=u;let d=()=>e&&n===u&&!u.signal.aborted,f=()=>{n===u&&a().cancelTransition()};o?.signal?.addEventListener(`abort`,f,{once:!0});let p=async(e,t)=>{let n=performance.now();for(;d();){let r=Math.min(1,(performance.now()-n)/e);if(a().setTransition({progress:t?1-r:r}),r>=1||!d())break;await F(16,u.signal)}};try{if(i({pending:r,transition:{active:!0,color:l,progress:0}}),await p(I,!1),!d()||(i({current:r,...o?.saveReturn?{lastReturnPoint:o.saveReturn}:{}}),!d())||(o?.onEntered?.(o.entry??c.entry),!d()))return;await F(L,u.signal),d()&&await p(R,!0)}finally{o?.signal?.removeEventListener(`abort`,f),n===u&&(n=void 0,i({pending:null,transition:{active:!1,color:l,progress:0}}))}},serialize:()=>({version:1,current:a().current}),prepareHydrate:e=>{if(e==null)return()=>{};if(typeof e!=`object`||e.version!==1||typeof e.current!=`string`||!e.current.trim())throw TypeError(`Invalid scene snapshot`);let t=e.current;return Object.hasOwn(a().scenes,t)?()=>{r(),i(e=>({current:t,pending:null,transition:{...e.transition,active:!1,progress:0}}))}:()=>{}},hydrate:e=>a().prepareHydrate(e)()}))}var B=s.n(`scene`),{useStore:V,useStoreApi:H}=r.t(`useSceneStore`,z,()=>n.n()?.sceneStore);function U(e){return e instanceof l.Vector3?e.clone():Array.isArray(e)?new l.Vector3(e[0],e[1],e[2]):new l.Vector3(e.x,e.y,e.z)}var W=new WeakMap;function G(e={},t=!0){let n=e.store??o.o,r=W.get(n);if(r)return r;let i=t,a=0,s,u=0,d=0,p=0,h=0,g=0,_={play:(t,r={})=>{let o={...e,...r,store:n};if(!i||o.signal?.aborted)return h++,{finished:Promise.resolve(),cancel:()=>{},state:`cancelled`};let _=++a;s?.cancel();let v=o.sceneStore??V,y=o.characterStore??k,b=o.dialogStore??c.f,x=t.map(e=>({...e,...`target`in e?{target:U(e.target)}:{},...`position`in e?{position:U(e.position)}:{}})),S=`playing`,C=()=>{},w=()=>{},T=new Promise((e,t)=>{C=e,w=t});T.catch(()=>{});let E,D,O,A,j,N,P=()=>S===`playing`&&i&&s===W&&a===_,F=(e,t=!0)=>{P()&&(t&&!D&&(D=f(n.getState().cameraOption)),O={...n.getState().cameraOption,...e},n.getState().replaceCameraOption(O))},I=(e,t)=>F(m(e,t),t.rememberPrevious!==!1),L=()=>{let e=D,t=O;D=void 0,O=void 0,t&&n.getState().cameraOption===t&&(e?n.getState().replaceCameraOption(f(e)):n.getState().setCameraOption({focus:!1}))},R=()=>{let e=N;if(N=void 0,!e||!O||n.getState().cameraOption!==O)return;let t={...n.getState().cameraOption};e.offset?t.offset=e.offset.clone():delete t.offset,O=t,n.getState().replaceCameraOption(t)},z=()=>{let e=A,t=j;A=void 0,j=void 0,e&&t&&v.getState().transition===t&&v.getState().setTransition(e)},B=(e,t)=>{if(S!==`playing`)return;S=e,s===W&&(s=void 0),o.signal?.removeEventListener(`abort`,H);let n=t,r=e===`failed`;for(let t of[()=>E?.(),R,z,()=>{(e!==`completed`||o.restoreOnComplete!==!1)&&L()}])try{t()}catch(e){r||(n=e),r=!0}r?(S=`failed`,g++,w(n)):(S===`completed`?p++:h++,C())},H=()=>B(`cancelled`),W={finished:T,cancel:H,get state(){return S}},G=(e=0)=>P()?new Promise(t=>{let n=!1,r=()=>{n||(n=!0,clearTimeout(i),u--,E===r&&(E=void 0),t())},i=setTimeout(r,Number.isFinite(e)?Math.max(0,e):0);u++,E=r}):Promise.resolve();return!i||o.signal?.aborted||_!==a?(B(`cancelled`),W):(s=W,d++,o.signal?.addEventListener(`abort`,H,{once:!0}),(async()=>{for(let e of x){if(!P())return;switch(e.kind){case`closeUp`:case`lookAt`:I(e.target,e);break;case`dolly`:if(I(e.target,{...e,...(e.fromDistance??e.toDistance)===void 0?{}:{focusDistance:e.fromDistance??e.toDistance}}),e.fromDistance!==void 0&&e.toDistance!==void 0){if(await G(16),!P())return;I(e.target,{...e,focusDistance:e.toDistance}),await G(Math.max(0,(e.durationMs??0)-16));continue}break;case`orbit`:{let t=U(e.target);t.y+=e.height??0,t.z+=e.radius,I(t,{...e,focusDistance:e.radius});break}case`expression`:y.getState().setFace(e.face);break;case`equip`:M({id:`cinematic-equip`,label:`Cinematic Equip`,outfits:{[e.slot??`weapon`]:e.itemId}},y);break;case`dialog`:b.getState().start(e.treeId,{...e.context?{context:e.context}:{}});break;case`teleport`:o.onTeleport?.(U(e.position));break;case`animation`:o.onAnimation?.(e.name);break;case`npcMove`:o.onNpcMove?.(e.npcId,U(e.position));break;case`event`:o.onEvent?.(e.name,e.payload);break;case`restore`:L();break;case`fade`:A??={...v.getState().transition},j={...v.getState().transition,active:!0,color:e.color??`#000000`,progress:e.direction===`in`?0:1},v.setState({transition:j});break;case`shake`:{let t=n.getState().cameraOption.offset;N=t?{offset:t.clone()}:{};let r=e.intensity??.08;F({offset:new l.Vector3(r,0,-r)});break}default:return e}await G(e.durationMs),P()&&e.kind===`shake`&&R()}})().then(()=>B(`completed`),e=>B(`failed`,e)),W)},cancel:()=>s?.cancel(),suspend:()=>{i=!1,a++,s?.cancel()},resume:()=>{i=!0},getStats:()=>({active:i,playing:!!s,pendingTimers:u,started:d,completed:p,cancelled:h,failed:g})};return W.set(n,_),_}function ee(e,t={}){return G({store:t.store??o.o}).play(e,t)}var te=`gaesup-save`,ne=1,K=`slots`,q={open:5e3,request:8e3},J=(e,t)=>Error(`IndexedDB ${e} did not finish within ${t} ms`);function re(){return new Promise((e,t)=>{if(typeof indexedDB>`u`){t(Error(`IndexedDB unavailable`));return}let n=indexedDB.open(te,ne),r=setTimeout(()=>t(J(`open`,q.open)),q.open);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(K)||e.createObjectStore(K)},n.onsuccess=()=>{clearTimeout(r),e(n.result)},n.onerror=()=>{clearTimeout(r),t(n.error)}})}var Y=class{async read(e){return await this.withStore(`readonly`,t=>t.get(e))??null}async write(e,t){await this.withStore(`readwrite`,n=>n.put(t,e))}async list(){return(await this.withStore(`readonly`,e=>e.getAllKeys())).map(String)}async remove(e){await this.withStore(`readwrite`,t=>t.delete(e))}connect(){let e=this.connection??=re().then(t=>(t.onversionchange=()=>{this.forget(e),t.close()},t.onclose=()=>this.forget(e),t),t=>{throw this.forget(e),t});return e}forget(e){this.connection===e&&(this.connection=void 0)}async withStore(e,t){let n=this.connect(),r=await n;return new Promise((i,a)=>{try{let o=r.transaction(K,e),s=setTimeout(()=>{this.forget(n),a(J(`request`,q.request));try{o.abort()}catch{}},q.request);o.onabort=()=>{clearTimeout(s),a(o.error??Error(`Save transaction aborted`))};let c=t(o.objectStore(K));o.oncomplete=()=>{clearTimeout(s),i(c.result)}}catch(e){this.forget(n),a(e)}})}},X=`gaesup:save:`,Z=class{async read(e){let t=localStorage.getItem(X+e);return t===null?null:JSON.parse(t)}async write(e,t){localStorage.setItem(X+e,JSON.stringify(t))}async list(){let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&n.startsWith(X)&&e.push(n.slice(12))}return e}async remove(e){localStorage.removeItem(X+e)}},Q=class{constructor(e,t){if(this.adapter=e,!t.trim())throw TypeError(`Save namespace must not be empty`);this.prefix=`world:${encodeURIComponent(t)}:`}read(e){return this.adapter.read(this.prefix+e)}write(e,t){return this.adapter.write(this.prefix+e,t)}remove(e){return this.adapter.remove(this.prefix+e)}async list(){return(await this.adapter.list()).filter(e=>e.startsWith(this.prefix)).map(e=>e.slice(this.prefix.length))}},ie=class{constructor(e){this.bindings=new Map,this.diagnosticListeners=new Set,this.restoreGuards=new Set,this.processing=!1,this.restoring=!1,this.restoreGeneration=0,this.pendingMutations=new Map,this.savedDomains=new Map,this.bindingGeneration=0,this.adapter=e.adapter,this.reportError=e.report??i.r,this.currentVersion=e.currentVersion??1,this.migrations=e.migrations??{},this.defaultSlot=e.defaultSlot??`main`,e.onDiagnostic&&this.diagnosticListeners.add(e.onDiagnostic)}register(e){if(this.processing)throw Error(`Save operation already in progress`);if(this.bindings.has(e.key))throw new oe(e.key);let t={key:e.key,serialize:()=>e.serialize(),hydrate:t=>e.hydrate(t),...e.prepareHydrate?{prepareHydrate:t=>e.prepareHydrate(t)}:{},...e.owned?{owned:!0}:{},...e.revision?{revision:()=>e.revision()}:{},...e.reset?{reset:()=>e.reset()}:{}};return this.bindings.set(e.key,t),this.bindingsChanged(),()=>{if(this.bindings.get(e.key)===t){if(this.processing)throw Error(`Save operation already in progress`);this.bindings.delete(e.key),this.bindingsChanged()}}}bindingsChanged(){this.cancelPendingLoads(),this.bindingGeneration++,this.savedDomains.clear()}has(e){return this.bindings.has(e)}getDefaultSlot(){return this.defaultSlot}registerRestoreGuard(e){if(this.processing)throw Error(`Save operation already in progress`);let t=()=>e();return this.restoreGuards.add(t),()=>{this.restoreGuards.has(t)&&this.restoreGuards.delete(t)}}subscribeDiagnostics(e){return this.diagnosticListeners.add(e),()=>{this.diagnosticListeners.delete(e)}}getBindings(){return this.bindings.values()}createBlob(e=this.defaultSlot){return this.process(()=>this.serializeBlob(e))}serializeBlob(e){return this.envelope(this.serializeDomains(e).domains)}envelope(e){return{version:this.currentVersion,savedAt:Date.now(),domains:e}}serializeDomains(e,t){let n={},r=new Map,i=[],o=0;for(let[s,c]of this.bindings){let l=c.revision?.(),u=l===void 0?void 0:t?.get(s);if(u&&u.revision===l){n[s]=u.value,r.set(s,u);continue}try{let e=c.serialize(),t=c.owned?e:a.qt(e);n[s]=t,o++,l!==void 0&&r.set(s,{revision:l,value:t})}catch(t){i.push(t),this.reportDiagnostic({phase:`serialize`,key:s,slot:e,error:t})}}if(i.length>0)throw AggregateError(i,`Save serialization failed`);return{domains:n,saved:r,serialized:o}}hydrateBlob(e,t=this.defaultSlot){return this.restoreBlob(e,t)}cancelPendingLoads(){this.restoreGeneration++}isRestoring(){return this.restoring}isLoading(){return this.loading!==void 0&&this.loading.generation===this.restoreGeneration&&!this.loading.signal?.aborted}restoreBlob(e,t,n){return this.process(()=>{let r=++this.restoreGeneration,i=[],a=[],o=!1;this.restoring=!0;try{o=this.applyBlob(e,t,()=>!n?.aborted&&r===this.restoreGeneration,i)}catch(e){a.push(e)}finally{this.restoring=!1;for(let e of i.reverse())try{e()}catch(e){a.push(e),this.reportDiagnostic({phase:`hydrate`,key:`$restore-effects`,slot:t,error:e})}}if(a.length===1)throw a[0];if(a.length>1)throw AggregateError(a,`Save restoration or effect cleanup failed`);return o})}applyBlob(e,t,n,r){let i=a.qt(e);if(ae(i),!Number.isInteger(i.version)||i.version<1||i.version>this.currentVersion)throw Error(`Unsupported save version: ${i.version}`);for(;i.version<this.currentVersion;){let e=i.version,t=this.migrations[i.version];if(!t)throw Error(`Missing save migration: ${i.version}`);if(i=t(i),ae(i),!Number.isInteger(i.version)||i.version<=e||i.version>this.currentVersion)throw Error(`Invalid save migration: ${e} -> ${i.version}`)}if(!n())return!1;let o=[],s=[];for(let[e,n]of this.bindings)try{let t=i.domains[e],r=Object.hasOwn(i.domains,e)?void 0:n.reset;s.push({key:e,binding:n,apply:r??(n.prepareHydrate?n.prepareHydrate(t):()=>n.hydrate(t))})}catch(n){o.push(n),this.reportDiagnostic({phase:`hydrate`,key:e,slot:t,error:n})}if(o.length>0)throw AggregateError(o,`Save hydration failed`);if(!n())return!1;let c=this.serializeBlob(t);for(let e of this.restoreGuards){if(!n())return!1;try{let t=e();if(t!==void 0&&typeof t!=`function`)throw TypeError(`Restore guards must return a synchronous release function or undefined`);t&&r.push(t)}catch(e){throw this.reportDiagnostic({phase:`hydrate`,key:`$restore-effects`,slot:t,error:e}),e}}let l=-1;for(let e=0;e<s.length;e++){let{key:r,apply:i}=s[e];try{if(!n()||(l=e,i(),!n()))throw new $}catch(e){o.push(e),e instanceof $||this.reportDiagnostic({phase:`hydrate`,key:r,slot:t,error:e});for(let e=l;e>=0;e--){let n=s[e];try{n.binding.hydrate(c.domains[n.key])}catch(e){o.push(e),this.reportDiagnostic({phase:`hydrate`,operation:`rollback`,key:n.key,slot:t,error:e})}}if(e instanceof $&&o.length===1)return!1;throw AggregateError(o,o.length>1?`Save hydration failed; rollback incomplete`:`Save hydration failed; previous state restored`)}}return n()}async save(e=this.defaultSlot,t={}){let n=this.bindingGeneration,r,i=this.process(()=>{if(!t.skipUnchanged)return this.serializeBlob(e);let n=this.savedDomains.get(e),i=this.serializeDomains(e,n);if(!(n&&i.serialized===0))return r=i.saved,this.envelope(i.domains)});i&&await this.enqueueMutation(e,async()=>{await this.adapter.write(e,i),r&&n===this.bindingGeneration&&this.savedDomains.set(e,r)})}async load(e=this.defaultSlot,t){if(t?.aborted)return!1;if(this.processing)throw Error(`Save operation already in progress`);let n=++this.restoreGeneration,r={generation:n,signal:t};this.loading=r;try{let r=this.pendingMutations.get(e);if(r&&await r,t?.aborted||n!==this.restoreGeneration)return!1;let i;try{i=await this.adapter.read(e)}catch(e){if(t?.aborted||n!==this.restoreGeneration)return!1;throw e}return!i||t?.aborted||n!==this.restoreGeneration?!1:this.restoreBlob(i,e,t)}finally{this.loading===r&&(this.loading=void 0)}}async list(){return this.adapter.list()}async remove(e=this.defaultSlot){return this.savedDomains.delete(e),this.enqueueMutation(e,()=>(this.savedDomains.delete(e),this.adapter.remove(e)))}enqueueMutation(e,t){let n=(this.pendingMutations.get(e)??Promise.resolve()).then(t),r=()=>{this.pendingMutations.get(e)===i&&this.pendingMutations.delete(e)},i=n.then(r,r);return this.pendingMutations.set(e,i),n}process(e){if(this.processing)throw Error(`Save operation already in progress`);this.processing=!0;try{return e()}finally{this.processing=!1}}reportDiagnostic(e){this.reportError(e.error,{source:`save:${e.phase}`,label:`${e.slot}/${e.key}`});for(let t of this.diagnosticListeners)try{t(e)}catch(e){this.reportError(e,{source:`save:diagnostic-listener`})}}},$=class extends Error{constructor(){super(`Save restoration was cancelled`)}};function ae(e){if(!e||typeof e!=`object`||Array.isArray(e)||!Number.isFinite(e.savedAt)||e.savedAt<0||!e.domains||typeof e.domains!=`object`||Array.isArray(e.domains))throw TypeError(`Invalid save data envelope`)}var oe=class extends Error{constructor(e){super(`Save domain "${e}" is already registered.`),this.name=`DuplicateSaveDomainBindingError`}},se=null;function ce(e={}){let t=typeof indexedDB<`u`?new Y:new Z;return new ie({adapter:e.namespace===void 0?t:new Q(t,e.namespace),defaultSlot:`main`,currentVersion:1,...e.report?{report:e.report}:{}})}function le(){return se||=ce(),se}Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return x}});
|
|
1
|
+
const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./logger-B9OaKOPw.cjs"),n=require("./runtimeContext-zx_GnKx4.cjs"),r=require("./scopedStore-Px5jL718.cjs"),i=require("./reportError-CkJ7vZsX.cjs"),a=require("./useClicker-B-fGashd.cjs"),o=require("./CoreBridge-L4l4UNtR.cjs"),s=require("./serviceKey-DwHFFFAA.cjs"),c=require("./clientServices-Bs-PZVqS.cjs");let l=require("three");l=e.n(l,1);let u=require("zustand");var d=new WeakMap;function f(e){return{...e,...e.offset?{offset:e.offset.clone()}:{},...e.focusTarget?{focusTarget:e.focusTarget.clone()}:{},...e.fixedPosition?{fixedPosition:e.fixedPosition.clone()}:{},...e.smoothing?{smoothing:{...e.smoothing}}:{},...e.bounds?{bounds:{...e.bounds}}:{}}}function p(e){return e instanceof l.Vector3?e.clone():Array.isArray(e)?new l.Vector3(e[0],e[1],e[2]):new l.Vector3(e.x,e.y,e.z)}function m(e,t={}){return{enableFocus:!0,focus:!0,focusTarget:p(e),focusDistance:t.focusDistance??4,focusLerpSpeed:t.focusLerpSpeed??8,fov:t.fov??46,enableCollision:t.enableCollision??!1}}function h(e,t={},n=o.o){let r=n.getState();return t.rememberPrevious!==!1&&!d.has(n)&&d.set(n,f(r.cameraOption)),r.setCameraOption(m(e,t)),()=>g(n)}function g(e=o.o){let t=e.getState(),n=d.get(e);if(n){t.replaceCameraOption({...f(n),focus:!1}),d.delete(e);return}t.setCameraOption({focus:!1})}var _={name:`플레이어`,colors:{body:`#ffd9b8`,hair:`#3a2a1a`,hat:`#5a8acf`,top:`#f0e0c8`,bottom:`#3a4a6a`,shoes:`#3a2a1a`},face:`default`,hair:`short`},v={hat:`모자`,top:`상의`,bottom:`하의`,shoes:`신발`,face:`표정`,glasses:`안경`,weapon:`무기`,accessory:`액세서리`},y={short:`짧은 머리`,long:`긴 머리`,cap:`모자 머리`,bun:`묶은 머리`,spiky:`뻗친 머리`},b={default:`기본`,smile:`미소`,wink:`윙크`,sleepy:`졸림`,surprised:`놀람`},x=`player`,S={hat:null,top:null,bottom:null,shoes:null,face:null,glasses:null,weapon:null,accessory:null},C=()=>({appearance:{..._,colors:{..._.colors}},outfits:{...S}}),w=e=>({appearance:{...e.appearance,colors:{...e.appearance.colors}},outfits:{...e.outfits}});function T(e){if(!e||typeof e!=`object`||Array.isArray(e)||e.appearance!==void 0&&(!e.appearance||typeof e.appearance!=`object`||Array.isArray(e.appearance))||e.appearance?.colors!==void 0&&(!e.appearance.colors||typeof e.appearance.colors!=`object`||Array.isArray(e.appearance.colors))||e.outfits!==void 0&&(!e.outfits||typeof e.outfits!=`object`||Array.isArray(e.outfits)))throw TypeError(`Invalid character profile`);let t={appearance:{..._,...e.appearance,colors:{..._.colors,...e.appearance?.colors}},outfits:{...S,...e.outfits}};if(typeof t.appearance.name!=`string`||!Object.hasOwn(b,t.appearance.face)||!Object.hasOwn(y,t.appearance.hair)||!Object.values(t.appearance.colors).every(e=>typeof e==`string`)||!Object.values(t.outfits).every(e=>e===null||typeof e==`string`))throw TypeError(`Invalid character appearance or outfit`);return t}var E=(e,t,n)=>{let r=t??e.activeCharacterId,i=n(e.characters[r]??C()),a={...e.characters,[r]:i};return r===e.activeCharacterId?{characters:a,appearance:i.appearance,outfits:i.outfits}:{characters:a}};function D(){return(0,u.create)((e,t)=>{let n=C();return{activeCharacterId:x,characters:{[x]:n},appearance:n.appearance,outfits:n.outfits,setActiveCharacter:t=>e(e=>{let n=e.characters[t]??C();return{activeCharacterId:t,characters:{...e.characters,[t]:n},appearance:n.appearance,outfits:n.outfits}}),removeCharacter:t=>e(e=>{if(!(t in e.characters))return{};let n={...e.characters};if(delete n[t],t!==e.activeCharacterId)return{characters:n};let r=C();return n[e.activeCharacterId]=r,{characters:n,appearance:r.appearance,outfits:r.outfits}}),getProfile:e=>{let n=t(),r=n.characters[e??n.activeCharacterId];return r?w(r):C()},setName:(t,n)=>e(e=>E(e,n,e=>({...e,appearance:{...e.appearance,name:t.slice(0,16)||`플레이어`}}))),setColor:(t,n,r)=>e(e=>E(e,r,e=>({...e,appearance:{...e.appearance,colors:{...e.appearance.colors,[t]:n}}}))),setFace:(t,n)=>e(e=>E(e,n,e=>({...e,appearance:{...e.appearance,face:t}}))),setHair:(t,n)=>e(e=>E(e,n,e=>({...e,appearance:{...e.appearance,hair:t}}))),equipOutfit:(t,n,r)=>e(e=>E(e,r,e=>({...e,outfits:{...e.outfits,[t]:n}}))),resetAppearance:t=>e(e=>{if(t!==void 0)return E(e,t,()=>C());let n=C();return{activeCharacterId:x,characters:{[x]:n},appearance:n.appearance,outfits:n.outfits}}),getEquippedAssetIds:e=>{let n=t(),r=n.characters[e??n.activeCharacterId]?.outfits??S;return Object.values(r).filter(e=>typeof e==`string`&&e.length>0)},serialize:()=>{let e=t(),n={};for(let[t,r]of Object.entries(e.characters))n[t]=w(r);return{version:3,activeCharacterId:e.activeCharacterId,characters:n}},prepareHydrate:t=>{if(t==null)return()=>{};if(typeof t!=`object`||![1,2,3].includes(t.version))throw TypeError(`Invalid character snapshot`);if(t.version===3){if(!t.characters||typeof t.characters!=`object`||Array.isArray(t.characters)||typeof t.activeCharacterId!=`string`||!t.activeCharacterId.trim())throw TypeError(`Invalid character collection`);let n=Object.entries(t.characters);if(n.length===0)return()=>{};let r=Object.fromEntries(n.map(([e,t])=>{if(!e.trim())throw TypeError(`Invalid character ID`);return[e,T(t)]})),i=Object.hasOwn(r,t.activeCharacterId)?t.activeCharacterId:Object.keys(r)[0],a=r[i];return()=>e({activeCharacterId:i,characters:r,appearance:a.appearance,outfits:a.outfits})}let n=T(t);return()=>e(e=>E(e,e.activeCharacterId,()=>n))},hydrate:e=>t().prepareHydrate(e)()}})}var O=s.n(`character`),{useStore:k,useStoreApi:A}=r.t(`useCharacterStore`,D,()=>n.n()?.characterStore),j=[{id:`starter-adventurer`,label:`모험가`,face:`smile`,hair:`cap`,outfits:{hat:`ally-hat`,top:`warrior-cloth-basic`,bottom:`starter-bottom-layer`,shoes:`starter-shoes-layer`,glasses:`ally-glasses`,weapon:`starter-weapon-layer`,accessory:`starter-accessory-ring`}},{id:`rabbit-warrior`,label:`토끼 전사`,face:`wink`,hair:`spiky`,outfits:{top:`warrior-cloth-rabbit`,bottom:`starter-bottom-layer`,shoes:`starter-shoes-layer`,weapon:`starter-weapon-layer`}}];function M(e,t=k){let n=t.getState();e.face&&n.setFace(e.face),e.hair&&n.setHair(e.hair),e.colors&&Object.entries(e.colors).forEach(([e,t])=>{t&&n.setColor(e,t)}),e.outfits&&Object.entries(e.outfits).forEach(([e,t])=>{n.equipOutfit(e,t??null)})}function N(e=`starter-weapon-layer`,t=k){let n=t.getState();n.equipOutfit(`weapon`,n.outfits.weapon===e?null:e)}var P=`outdoor`;function F(e,t){return t.aborted?Promise.resolve():new Promise(n=>{let r=()=>{clearTimeout(i),t.removeEventListener(`abort`,r),n()},i=setTimeout(r,e);t.addEventListener(`abort`,r,{once:!0})})}var I=220,L=80,R=240;function z(){let e=!0,n,r=()=>{let e=n;n=void 0,e?.abort()};return(0,u.create)((i,a)=>({current:P,pending:null,scenes:{[P]:{id:P,name:`야외`,interior:!1}},transition:{progress:0,color:`#000000`,active:!1},lastReturnPoint:null,registerScene:e=>i(t=>t.scenes[e.id]?t:{scenes:{...t.scenes,[e.id]:e}}),unregisterScene:e=>{a().pending===e&&a().cancelTransition(),i(t=>{if(e===`outdoor`||!t.scenes[e])return t;let n={...t.scenes};return delete n[e],{scenes:n}})},setTransition:e=>i(t=>({transition:{...t.transition,...e}})),setReturnPoint:e=>i({lastReturnPoint:e}),cancelTransition:()=>{r(),i(e=>!e.pending&&!e.transition.active?e:{pending:null,transition:{...e.transition,active:!1,progress:0}})},suspendTransitions:()=>{e=!1,a().cancelTransition()},resumeTransitions:()=>{e=!0},goTo:async(r,o)=>{let s=a();if(!e||o?.signal?.aborted||s.pending||r===s.current&&!o?.entry)return;let c=s.scenes[r];if(!c){t.t.warn(`[scene] Unknown scene "${r}". Did you forget to register it?`);return}let l=c.interior??!1?`#0d0d10`:`#f5f5f5`,u=new AbortController;n=u;let d=()=>e&&n===u&&!u.signal.aborted,f=()=>{n===u&&a().cancelTransition()};o?.signal?.addEventListener(`abort`,f,{once:!0});let p=async(e,t)=>{let n=performance.now();for(;d();){let r=Math.min(1,(performance.now()-n)/e);if(a().setTransition({progress:t?1-r:r}),r>=1||!d())break;await F(16,u.signal)}};try{if(i({pending:r,transition:{active:!0,color:l,progress:0}}),await p(I,!1),!d()||(i({current:r,...o?.saveReturn?{lastReturnPoint:o.saveReturn}:{}}),!d())||(o?.onEntered?.(o.entry??c.entry),!d()))return;await F(L,u.signal),d()&&await p(R,!0)}finally{o?.signal?.removeEventListener(`abort`,f),n===u&&(n=void 0,i({pending:null,transition:{active:!1,color:l,progress:0}}))}},serialize:()=>({version:1,current:a().current}),prepareHydrate:e=>{if(e==null)return()=>{};if(typeof e!=`object`||e.version!==1||typeof e.current!=`string`||!e.current.trim())throw TypeError(`Invalid scene snapshot`);let t=e.current;return Object.hasOwn(a().scenes,t)?()=>{r(),i(e=>({current:t,pending:null,transition:{...e.transition,active:!1,progress:0}}))}:()=>{}},hydrate:e=>a().prepareHydrate(e)()}))}var B=s.n(`scene`),{useStore:V,useStoreApi:H}=r.t(`useSceneStore`,z,()=>n.n()?.sceneStore);function U(e){return e instanceof l.Vector3?e.clone():Array.isArray(e)?new l.Vector3(e[0],e[1],e[2]):new l.Vector3(e.x,e.y,e.z)}var W=new WeakMap;function G(e={},t=!0){let n=e.store??o.o,r=W.get(n);if(r)return r;let i=t,a=0,s,u=0,d=0,p=0,h=0,g=0,_={play:(t,r={})=>{let o={...e,...r,store:n};if(!i||o.signal?.aborted)return h++,{finished:Promise.resolve(),cancel:()=>{},state:`cancelled`};let _=++a;s?.cancel();let v=o.sceneStore??V,y=o.characterStore??k,b=o.dialogStore??c.f,x=t.map(e=>({...e,...`target`in e?{target:U(e.target)}:{},...`position`in e?{position:U(e.position)}:{}})),S=`playing`,C=()=>{},w=()=>{},T=new Promise((e,t)=>{C=e,w=t});T.catch(()=>{});let E,D,O,A,j,N,P=()=>S===`playing`&&i&&s===W&&a===_,F=(e,t=!0)=>{P()&&(t&&!D&&(D=f(n.getState().cameraOption)),O={...n.getState().cameraOption,...e},n.getState().replaceCameraOption(O))},I=(e,t)=>F(m(e,t),t.rememberPrevious!==!1),L=()=>{let e=D,t=O;D=void 0,O=void 0,t&&n.getState().cameraOption===t&&(e?n.getState().replaceCameraOption(f(e)):n.getState().setCameraOption({focus:!1}))},R=()=>{let e=N;if(N=void 0,!e||!O||n.getState().cameraOption!==O)return;let t={...n.getState().cameraOption};e.offset?t.offset=e.offset.clone():delete t.offset,O=t,n.getState().replaceCameraOption(t)},z=()=>{let e=A,t=j;A=void 0,j=void 0,e&&t&&v.getState().transition===t&&v.getState().setTransition(e)},B=(e,t)=>{if(S!==`playing`)return;S=e,s===W&&(s=void 0),o.signal?.removeEventListener(`abort`,H);let n=t,r=e===`failed`;for(let t of[()=>E?.(),R,z,()=>{(e!==`completed`||o.restoreOnComplete!==!1)&&L()}])try{t()}catch(e){r||(n=e),r=!0}r?(S=`failed`,g++,w(n)):(S===`completed`?p++:h++,C())},H=()=>B(`cancelled`),W={finished:T,cancel:H,get state(){return S}},G=(e=0)=>P()?new Promise(t=>{let n=!1,r=()=>{n||(n=!0,clearTimeout(i),u--,E===r&&(E=void 0),t())},i=setTimeout(r,Number.isFinite(e)?Math.max(0,e):0);u++,E=r}):Promise.resolve();return!i||o.signal?.aborted||_!==a?(B(`cancelled`),W):(s=W,d++,o.signal?.addEventListener(`abort`,H,{once:!0}),(async()=>{for(let e of x){if(!P())return;switch(e.kind){case`closeUp`:case`lookAt`:I(e.target,e);break;case`dolly`:if(I(e.target,{...e,...(e.fromDistance??e.toDistance)===void 0?{}:{focusDistance:e.fromDistance??e.toDistance}}),e.fromDistance!==void 0&&e.toDistance!==void 0){if(await G(16),!P())return;I(e.target,{...e,focusDistance:e.toDistance}),await G(Math.max(0,(e.durationMs??0)-16));continue}break;case`orbit`:{let t=U(e.target);t.y+=e.height??0,t.z+=e.radius,I(t,{...e,focusDistance:e.radius});break}case`expression`:y.getState().setFace(e.face);break;case`equip`:M({id:`cinematic-equip`,label:`Cinematic Equip`,outfits:{[e.slot??`weapon`]:e.itemId}},y);break;case`dialog`:b.getState().start(e.treeId,{...e.context?{context:e.context}:{}});break;case`teleport`:o.onTeleport?.(U(e.position));break;case`animation`:o.onAnimation?.(e.name);break;case`npcMove`:o.onNpcMove?.(e.npcId,U(e.position));break;case`event`:o.onEvent?.(e.name,e.payload);break;case`restore`:L();break;case`fade`:A??={...v.getState().transition},j={...v.getState().transition,active:!0,color:e.color??`#000000`,progress:e.direction===`in`?0:1},v.setState({transition:j});break;case`shake`:{let t=n.getState().cameraOption.offset;N=t?{offset:t.clone()}:{};let r=e.intensity??.08;F({offset:new l.Vector3(r,0,-r)});break}default:return e}await G(e.durationMs),P()&&e.kind===`shake`&&R()}})().then(()=>B(`completed`),e=>B(`failed`,e)),W)},cancel:()=>s?.cancel(),suspend:()=>{i=!1,a++,s?.cancel()},resume:()=>{i=!0},getStats:()=>({active:i,playing:!!s,pendingTimers:u,started:d,completed:p,cancelled:h,failed:g})};return W.set(n,_),_}function ee(e,t={}){return G({store:t.store??o.o}).play(e,t)}var te=`gaesup-save`,ne=1,K=`slots`,q={open:5e3,request:8e3},J=(e,t)=>Error(`IndexedDB ${e} did not finish within ${t} ms`);function re(){return new Promise((e,t)=>{if(typeof indexedDB>`u`){t(Error(`IndexedDB unavailable`));return}let n=indexedDB.open(te,ne),r=setTimeout(()=>t(J(`open`,q.open)),q.open);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(K)||e.createObjectStore(K)},n.onsuccess=()=>{clearTimeout(r),e(n.result)},n.onerror=()=>{clearTimeout(r),t(n.error)}})}var Y=class{async read(e){return await this.withStore(`readonly`,t=>t.get(e))??null}async write(e,t){await this.withStore(`readwrite`,n=>n.put(t,e))}async list(){return(await this.withStore(`readonly`,e=>e.getAllKeys())).map(String)}async remove(e){await this.withStore(`readwrite`,t=>t.delete(e))}connect(){let e=this.connection??=re().then(t=>(t.onversionchange=()=>{this.forget(e),t.close()},t.onclose=()=>this.forget(e),t),t=>{throw this.forget(e),t});return e}forget(e){this.connection===e&&(this.connection=void 0)}async withStore(e,t){let n=this.connect(),r=await n;return new Promise((i,a)=>{try{let o=r.transaction(K,e),s=setTimeout(()=>{this.forget(n),a(J(`request`,q.request));try{o.abort()}catch{}},q.request);o.onabort=()=>{clearTimeout(s),a(o.error??Error(`Save transaction aborted`))};let c=t(o.objectStore(K));o.oncomplete=()=>{clearTimeout(s),i(c.result)}}catch(e){this.forget(n),a(e)}})}},X=`gaesup:save:`,Z=class{async read(e){let t=localStorage.getItem(X+e);return t===null?null:JSON.parse(t)}async write(e,t){localStorage.setItem(X+e,JSON.stringify(t))}async list(){let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&n.startsWith(X)&&e.push(n.slice(12))}return e}async remove(e){localStorage.removeItem(X+e)}},Q=class{constructor(e,t){if(this.adapter=e,!t.trim())throw TypeError(`Save namespace must not be empty`);this.prefix=`world:${encodeURIComponent(t)}:`}read(e){return this.adapter.read(this.prefix+e)}write(e,t){return this.adapter.write(this.prefix+e,t)}remove(e){return this.adapter.remove(this.prefix+e)}async list(){return(await this.adapter.list()).filter(e=>e.startsWith(this.prefix)).map(e=>e.slice(this.prefix.length))}},ie=class{constructor(e){this.bindings=new Map,this.diagnosticListeners=new Set,this.restoreGuards=new Set,this.processing=!1,this.restoring=!1,this.restoreGeneration=0,this.pendingMutations=new Map,this.savedDomains=new Map,this.bindingGeneration=0,this.adapter=e.adapter,this.reportError=e.report??i.r,this.currentVersion=e.currentVersion??1,this.migrations=e.migrations??{},this.defaultSlot=e.defaultSlot??`main`,e.onDiagnostic&&this.diagnosticListeners.add(e.onDiagnostic)}register(e){if(this.processing)throw Error(`Save operation already in progress`);if(this.bindings.has(e.key))throw new oe(e.key);let t={key:e.key,serialize:()=>e.serialize(),hydrate:t=>e.hydrate(t),...e.prepareHydrate?{prepareHydrate:t=>e.prepareHydrate(t)}:{},...e.owned?{owned:!0}:{},...e.revision?{revision:()=>e.revision()}:{},...e.reset?{reset:()=>e.reset()}:{}};return this.bindings.set(e.key,t),this.bindingsChanged(),()=>{if(this.bindings.get(e.key)===t){if(this.processing)throw Error(`Save operation already in progress`);this.bindings.delete(e.key),this.bindingsChanged()}}}bindingsChanged(){this.cancelPendingLoads(),this.bindingGeneration++,this.savedDomains.clear()}has(e){return this.bindings.has(e)}getDefaultSlot(){return this.defaultSlot}registerRestoreGuard(e){if(this.processing)throw Error(`Save operation already in progress`);let t=()=>e();return this.restoreGuards.add(t),()=>{this.restoreGuards.has(t)&&this.restoreGuards.delete(t)}}subscribeDiagnostics(e){return this.diagnosticListeners.add(e),()=>{this.diagnosticListeners.delete(e)}}getBindings(){return this.bindings.values()}createBlob(e=this.defaultSlot){return this.process(()=>this.serializeBlob(e))}serializeBlob(e){return this.envelope(this.serializeDomains(e).domains)}envelope(e){return{version:this.currentVersion,savedAt:Date.now(),domains:e}}serializeDomains(e,t){let n={},r=new Map,i=[],o=0;for(let[s,c]of this.bindings){let l=c.revision?.(),u=l===void 0?void 0:t?.get(s);if(u&&u.revision===l){n[s]=u.value,r.set(s,u);continue}try{let e=c.serialize(),t=c.owned?e:a.qt(e);n[s]=t,o++,l!==void 0&&r.set(s,{revision:l,value:t})}catch(t){i.push(t),this.reportDiagnostic({phase:`serialize`,key:s,slot:e,error:t})}}if(i.length>0)throw AggregateError(i,`Save serialization failed`);return{domains:n,saved:r,serialized:o}}hydrateBlob(e,t=this.defaultSlot){return this.restoreBlob(e,t)}cancelPendingLoads(){this.restoreGeneration++}isRestoring(){return this.restoring}isLoading(){return this.loading!==void 0&&this.loading.generation===this.restoreGeneration&&!this.loading.signal?.aborted}restoreBlob(e,t,n){return this.process(()=>{let r=++this.restoreGeneration,i=[],a=[],o=!1;this.restoring=!0;try{o=this.applyBlob(e,t,()=>!n?.aborted&&r===this.restoreGeneration,i)}catch(e){a.push(e)}finally{this.restoring=!1;for(let e of i.reverse())try{e()}catch(e){a.push(e),this.reportDiagnostic({phase:`hydrate`,key:`$restore-effects`,slot:t,error:e})}}if(a.length===1)throw a[0];if(a.length>1)throw AggregateError(a,`Save restoration or effect cleanup failed`);return o})}applyBlob(e,t,n,r){let i=a.qt(e);if(ae(i),!Number.isInteger(i.version)||i.version<1||i.version>this.currentVersion)throw Error(`Unsupported save version: ${i.version}`);for(;i.version<this.currentVersion;){let e=i.version,t=this.migrations[i.version];if(!t)throw Error(`Missing save migration: ${i.version}`);if(i=t(i),ae(i),!Number.isInteger(i.version)||i.version<=e||i.version>this.currentVersion)throw Error(`Invalid save migration: ${e} -> ${i.version}`)}if(!n())return!1;let o=[],s=[];for(let[e,n]of this.bindings)try{let t=i.domains[e],r=Object.hasOwn(i.domains,e)?void 0:n.reset;s.push({key:e,binding:n,apply:r??(n.prepareHydrate?n.prepareHydrate(t):()=>n.hydrate(t))})}catch(n){o.push(n),this.reportDiagnostic({phase:`hydrate`,key:e,slot:t,error:n})}if(o.length>0)throw AggregateError(o,`Save hydration failed`);if(!n())return!1;let c=this.serializeBlob(t);for(let e of this.restoreGuards){if(!n())return!1;try{let t=e();if(t!==void 0&&typeof t!=`function`)throw TypeError(`Restore guards must return a synchronous release function or undefined`);t&&r.push(t)}catch(e){throw this.reportDiagnostic({phase:`hydrate`,key:`$restore-effects`,slot:t,error:e}),e}}let l=-1;for(let e=0;e<s.length;e++){let{key:r,apply:i}=s[e];try{if(!n()||(l=e,i(),!n()))throw new $}catch(e){o.push(e),e instanceof $||this.reportDiagnostic({phase:`hydrate`,key:r,slot:t,error:e});for(let e=l;e>=0;e--){let n=s[e];try{n.binding.hydrate(c.domains[n.key])}catch(e){o.push(e),this.reportDiagnostic({phase:`hydrate`,operation:`rollback`,key:n.key,slot:t,error:e})}}if(e instanceof $&&o.length===1)return!1;throw AggregateError(o,o.length>1?`Save hydration failed; rollback incomplete`:`Save hydration failed; previous state restored`)}}return n()}async save(e=this.defaultSlot,t={}){let n=this.bindingGeneration,r,i=this.process(()=>{if(!t.skipUnchanged)return this.serializeBlob(e);let n=this.savedDomains.get(e),i=this.serializeDomains(e,n);if(!(n&&i.serialized===0))return r=i.saved,this.envelope(i.domains)});i&&await this.enqueueMutation(e,async()=>{await this.adapter.write(e,i),r&&n===this.bindingGeneration&&this.savedDomains.set(e,r)})}async load(e=this.defaultSlot,t){if(t?.aborted)return!1;if(this.processing)throw Error(`Save operation already in progress`);let n=++this.restoreGeneration,r={generation:n,signal:t};this.loading=r;try{let r=this.pendingMutations.get(e);if(r&&await r,t?.aborted||n!==this.restoreGeneration)return!1;let i;try{i=await this.adapter.read(e)}catch(e){if(t?.aborted||n!==this.restoreGeneration)return!1;throw e}return!i||t?.aborted||n!==this.restoreGeneration?!1:this.restoreBlob(i,e,t)}finally{this.loading===r&&(this.loading=void 0)}}async list(){return this.adapter.list()}async remove(e=this.defaultSlot){return this.savedDomains.delete(e),this.enqueueMutation(e,()=>(this.savedDomains.delete(e),this.adapter.remove(e)))}enqueueMutation(e,t){let n=(this.pendingMutations.get(e)??Promise.resolve()).then(t),r=()=>{this.pendingMutations.get(e)===i&&this.pendingMutations.delete(e)},i=n.then(r,r);return this.pendingMutations.set(e,i),n}process(e){if(this.processing)throw Error(`Save operation already in progress`);this.processing=!0;try{return e()}finally{this.processing=!1}}reportDiagnostic(e){this.reportError(e.error,{source:`save:${e.phase}`,label:`${e.slot}/${e.key}`});for(let t of this.diagnosticListeners)try{t(e)}catch(e){this.reportError(e,{source:`save:diagnostic-listener`})}}},$=class extends Error{constructor(){super(`Save restoration was cancelled`)}};function ae(e){if(!e||typeof e!=`object`||Array.isArray(e)||!Number.isFinite(e.savedAt)||e.savedAt<0||!e.domains||typeof e.domains!=`object`||Array.isArray(e.domains))throw TypeError(`Invalid save data envelope`)}var oe=class extends Error{constructor(e){super(`Save domain "${e}" is already registered.`),this.name=`DuplicateSaveDomainBindingError`}},se=null;function ce(e={}){let t=typeof indexedDB<`u`?new Y:new Z;return new ie({adapter:e.namespace===void 0?t:new Q(t,e.namespace),defaultSlot:`main`,currentVersion:1,...e.report?{report:e.report}:{}})}function le(){return se||=ce(),se}Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return x}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./CoreBridge-
|
|
1
|
+
const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./CoreBridge-L4l4UNtR.cjs"),n=require("./id-DWiNl1ym.cjs"),r=require("./SpatialGrid-DreiJto-.cjs");let i=require("three");i=e.n(i,1);function a(e){return Number.isNaN(e.min.x)||Number.isNaN(e.min.y)||Number.isNaN(e.min.z)||Number.isNaN(e.max.x)||Number.isNaN(e.max.y)||Number.isNaN(e.max.z)}var o=class{constructor(e=10,t=256){if(this.cellSize=e,this.maxCells=t,this.entries=new Map,this.columns=new Map,this.overflow=new Set,this.visited=new Set,!Number.isFinite(e)||e<=0||!Number.isSafeInteger(t)||t<1)throw RangeError(`Bounds index requires a positive cell size and cell budget`)}range(e){let t=Math.floor(e.min.x/this.cellSize),n=Math.floor(e.max.x/this.cellSize),r=Math.floor(e.min.z/this.cellSize),i=Math.floor(e.max.z/this.cellSize);return!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||!Number.isSafeInteger(r)||!Number.isSafeInteger(i)||(n-t+1)*(i-r+1)>this.maxCells?null:{minX:t,maxX:n,minZ:r,maxZ:i}}update(e,t){if(!t||t.isEmpty()||a(t)){this.remove(e);return}let n=this.entries.get(e);if(n?.bounds.equals(t))return;let r=this.range(t),i=n?.range;if(n&&(i===null&&r===null||i&&r&&i.minX===r.minX&&i.maxX===r.maxX&&i.minZ===r.minZ&&i.maxZ===r.maxZ)){n.bounds.copy(t);return}this.remove(e);let o={id:e,bounds:t.clone(),range:r};if(this.entries.set(e,o),!r){this.overflow.add(o);return}for(let e=r.minX;e<=r.maxX;e++){let t=this.columns.get(e);t||this.columns.set(e,t=new Map);for(let e=r.minZ;e<=r.maxZ;e++){let n=t.get(e);n||t.set(e,n=new Set),n.add(o)}}}remove(e){let t=this.entries.get(e);if(!t)return;this.entries.delete(e),this.overflow.delete(t);let n=t.range;if(n)for(let e=n.minX;e<=n.maxX;e++){let r=this.columns.get(e);if(r){for(let e=n.minZ;e<=n.maxZ;e++){let n=r.get(e);n?.delete(t),n?.size===0&&r.delete(e)}r.size===0&&this.columns.delete(e)}}}query(e,t=[]){if(t.length=0,e.isEmpty()||a(e))return t;let n=this.range(e);if(!n){for(let n of this.entries.values())e.intersectsBox(n.bounds)&&t.push(n.id);return t}this.visited.clear();for(let r=n.minX;r<=n.maxX;r++){let i=this.columns.get(r);if(i)for(let r=n.minZ;r<=n.maxZ;r++){let n=i.get(r);if(n)for(let r of n)this.visited.has(r)||(this.visited.add(r),e.intersectsBox(r.bounds)&&t.push(r.id))}}for(let n of this.overflow)e.intersectsBox(n.bounds)&&t.push(n.id);return this.visited.clear(),t}clear(){this.entries.clear(),this.columns.clear(),this.overflow.clear(),this.visited.clear()}},s=class{constructor(){this.revision=0,this.objects=new Map,this.interactionEvents=[],this.spatial=new r.t({cellSize:10}),this.bounds=new o,this.ray=new i.Ray,this.rayBounds=new i.Box3,this.rayEnd=new i.Vector3,this.nearestPoint=new i.Vector3,this.tempVector=new i.Vector3,this.nearbyIds=[],this.nearbyIds2=[]}getRevision(){return this.revision}async init(){}update(e){}dispose(){this.cleanup()}addObject(e){this.objects.set(e.id,e),this.spatial.add(e.id,e.position),this.bounds.update(e.id,e.boundingBox),this.revision++}removeObject(e){this.objects.get(e)&&(this.spatial.remove(e),this.bounds.remove(e));let t=this.objects.delete(e);return t&&this.revision++,t}getObject(e){return this.objects.get(e)}getAllObjects(){return Array.from(this.objects.values())}getObjectsByType(e){return this.getAllObjects().filter(t=>t.type===e)}updateObject(e,t){let n=this.objects.get(e);if(!n)return!1;if(t.id!==void 0&&t.id!==e)throw TypeError(`World object identity cannot change during update`);let r={...n,...t,id:e};return this.objects.set(e,r),this.bounds.update(e,r.boundingBox),t.position&&this.spatial.update(e,t.position),this.revision++,!0}getObjectsInRadius(e,t){let n=this.spatial.getNearby(e,t,this.nearbyIds),r=[];for(let e of n){let t=this.objects.get(e);t&&r.push(t)}return r}checkCollisions(e){let t=this.objects.get(e);if(!t||!t.boundingBox)return[];let n=this.bounds.query(t.boundingBox,this.nearbyIds2),r=[];for(let i of n){if(i===e)continue;let n=this.objects.get(i);n&&n.boundingBox&&t.boundingBox.intersectsBox(n.boundingBox)&&r.push(n)}return r}processInteraction(e){this.interactionEvents.push(e),this.revision++,this.interactionEvents.length>1e3&&(this.interactionEvents=this.interactionEvents.slice(-500))}getRecentEvents(e=1e3){let t=Date.now();return this.interactionEvents.filter(n=>t-n.timestamp<=e)}clearEvents(){this.interactionEvents.length=0,this.revision++}raycast(e,t,n=100){let r=Math.hypot(t.x,t.y,t.z);if(!Number.isFinite(r)||r===0||Number.isNaN(n)||n<0||!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.z))return null;this.ray.origin.copy(e),this.ray.direction.copy(t).multiplyScalar(1/r),n===1/0?(this.rayBounds.min.set(-1/0,-1/0,-1/0),this.rayBounds.max.set(1/0,1/0,1/0)):(this.rayEnd.copy(e).addScaledVector(this.ray.direction,n),this.rayBounds.set(e,e).expandByPoint(this.rayEnd));let i=this.bounds.query(this.rayBounds,this.nearbyIds),a,o=n*n;for(let t of i){let n=this.objects.get(t);if(n&&n.boundingBox){let t=this.ray.intersectBox(n.boundingBox,this.tempVector);if(t){let r=e.distanceToSquared(t);if(r>o||a&&r===o)continue;a=n,o=r,this.nearestPoint.copy(t)}}}return a?{object:a,distance:Math.sqrt(o),point:this.nearestPoint.clone()}:null}cleanup(){this.objects.clear(),this.interactionEvents.length=0,this.spatial.clear(),this.bounds.clear(),this.revision++}};function c(e){return{objectsInRadius:(t,n)=>e.getObjectsInRadius(t,n),objectsByType:t=>e.getObjectsByType(t),raycast:(t,n)=>e.raycast(t,n)?.object??null}}var l=class extends t.t{constructor(){super({eventLog:!0}),this.enabled=!0,this.snapshotCache=new WeakMap}suspend(){this.enabled=!1}resume(){this.enabled=!0}execute(e,t){this.enabled&&super.execute(e,t)}buildEngine(e,t){if(!this.enabled)return null;let n=new s;return{system:n,state:{...t?.selectedObjectId===void 0?{}:{selectedObjectId:t.selectedObjectId},interactionMode:t?.interactionMode??`view`,showDebugInfo:t?.showDebugInfo??!1},queries:c(n),revision:0,dispose:()=>n.dispose()}}executeCommand(e,t,r){if(!this.enabled)return;e.revision++;let{system:i,state:a}=e;switch(t.type){case`clearEvents`:i.clearEvents();break;case`addObject`:let{id:e,...r}=t.data,o=typeof e==`string`&&e.length>0?e:n.t(`world`),s={...r,id:o};i.addObject(s);break;case`removeObject`:i.removeObject(t.data.id),a.selectedObjectId===t.data.id&&delete a.selectedObjectId;break;case`updateObject`:i.updateObject(t.data.id,t.data.updates);break;case`selectObject`:t.data.id===void 0?delete a.selectedObjectId:a.selectedObjectId=t.data.id;break;case`setInteractionMode`:a.interactionMode=t.data.mode;break;case`toggleDebugInfo`:a.showDebugInfo=!a.showDebugInfo;break;case`interact`:let c=i.getObject(t.data.objectId);if(c&&c.canInteract){let e={type:`custom`,object1Id:t.data.objectId,timestamp:Date.now(),data:{action:t.data.action}};i.processInteraction(e)}break;case`cleanup`:i.cleanup(),delete a.selectedObjectId,a.interactionMode=`view`,a.showDebugInfo=!1}}createSnapshot(e,t){let{system:n,state:r,queries:i}=e,a=n.getRevision(),o=e.revision+a,s=this.snapshotCache.get(e),c=s&&Date.now()<s.expires;if(s?.revision===o&&c)return s.value;let l=s?.systemRevision===a,u=l&&c?s.value.events:n.getRecentEvents(),d={objects:l?s.value.objects:n.getAllObjects(),...r.selectedObjectId===void 0?{}:{selectedObjectId:r.selectedObjectId},interactionMode:r.interactionMode,showDebugInfo:r.showDebugInfo,events:u,objectsInRadius:i.objectsInRadius,objectsByType:i.objectsByType,raycast:i.raycast},f=u.reduce((e,t)=>Math.min(e,t.timestamp+1001),1/0);return this.snapshotCache.set(e,{revision:o,systemRevision:a,expires:f,value:d}),d}addObject(e,t){if(!this.enabled||!this.getEngine(e))return``;let r=t.id,i=typeof r==`string`&&r.length>0?r:n.t(`world`);return this.execute(e,{type:`addObject`,data:{...t,id:i}}),i}removeObject(e,t){this.execute(e,{type:`removeObject`,data:{id:t}})}updateObject(e,t,n){this.execute(e,{type:`updateObject`,data:{id:t,updates:n}})}selectObject(e,t){this.execute(e,{type:`selectObject`,data:t===void 0?{}:{id:t}})}setInteractionMode(e,t){this.execute(e,{type:`setInteractionMode`,data:{mode:t}})}toggleDebugInfo(e){this.execute(e,{type:`toggleDebugInfo`})}interact(e,t,n){this.execute(e,{type:`interact`,data:{objectId:t,action:n}})}cleanup(e){this.execute(e,{type:`cleanup`})}clearEvents(e){this.execute(e,{type:`clearEvents`})}getObjectsInRadius(e,t,n){let r=this.getEngine(e);return r?r.system.getObjectsInRadius(t,n):[]}getObjectsByType(e,t){let n=this.getEngine(e);return n?n.system.getObjectsByType(t):[]}raycast(e,t,n){let r=this.getEngine(e);return r&&r.system.raycast(t,n)?.object||null}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./useEngineFrame-ujTlLQfa.cjs"),n=require("./logger-B9OaKOPw.cjs"),r=require("./runtimeContext-zx_GnKx4.cjs"),i=require("./WorldPhysics-
|
|
1
|
+
const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./useEngineFrame-ujTlLQfa.cjs"),n=require("./logger-B9OaKOPw.cjs"),r=require("./runtimeContext-zx_GnKx4.cjs"),i=require("./WorldPhysics-CQAfZYGi.cjs"),a=require("./CoreBridge-L4l4UNtR.cjs"),o=require("./useGenericRefs-DzuTNaAX.cjs"),s=require("./timeStore-Be94nnui.cjs"),c=require("./sceneCompile-CWcdcntc.cjs"),l=require("./quality-CxseVZ9x.cjs");let u=require("three");u=e.n(u,1);let d=require("react"),f=require("@react-three/fiber"),p=require("react/jsx-runtime");var m=0;function h(){m++;let e=!1;return()=>{e||(e=!0,m=Math.max(0,m-1))}}function g(){return m>0}var _=()=>()=>{},v=()=>0;function y({runtime:e,revision:t,children:n}){let i=(0,d.useContext)(r.t),o=e===void 0?i.runtime:e,c=(0,d.useSyncExternalStore)(o?.subscribeLifecycle??_,o?.getLifecycleRevision??v,o?.getLifecycleRevision??v),l=t===void 0?e===void 0?i.revision:c:t+c,u=(0,d.useMemo)(()=>({runtime:o,revision:l}),[o,l]);return(0,p.jsx)(r.t.Provider,{value:u,children:(0,p.jsx)(a.r,{value:o?.store??null,children:(0,p.jsx)(s.t,{value:o?.timeStore??null,children:n})})})}function b(e){let t=typeof e.render.drawCalls==`number`;return{counterModel:t?`common`:`webgl`,counterScope:e.autoReset===!1?`since-reset`:t?`renderer-frame`:`last-render`,drawCalls:t?e.render.drawCalls:e.render.calls,renderInvocations:t?e.render.frameCalls??null:null,triangles:e.render.triangles,points:e.render.points,lines:e.render.lines,geometries:e.memory.geometries,textures:e.memory.textures,programs:t?e.memory.programs??0:e.programs?.length??0,allocatedBytesEstimate:typeof e.memory.total==`number`?e.memory.total:null}}var x=.25;function S(){let e=(0,f.useThree)(e=>e.gl),n=a.o(e=>e.setPerformance),r=a.o(e=>e.setFramePhases),i=t.i(),o=(0,d.useRef)(0),s=(0,d.useRef)(!1);return(0,d.useEffect)(()=>(0,f.addAfterEffect)(()=>{if(!s.current)return;s.current=!1;let t=b(e.info);n({render:{calls:t.drawCalls,renderInvocations:t.renderInvocations,counterScope:t.counterScope,triangles:t.triangles,points:t.points,lines:t.lines,backend:c.g(e)},engine:{geometries:t.geometries,textures:t.textures,programs:t.programs,allocatedBytesEstimate:t.allocatedBytesEstimate}})}),[e,n]),t.t(`snapshot`,e=>{if(o.current+=e,o.current<x||(o.current=0,s.current=!0,!i.isMetricsEnabled()))return;let n={};for(let e of t.g){let t=i.getMetrics(e);n[e]=t.calls>0?t.totalMs/t.calls:0}i.resetMetrics(),r(n)},{label:`perf:renderer-stats`}),null}function C(e){return e?`1`:`0`}function w(e){let t=e;return t.clipShadows&&(t.clippingPlanes?.length??0)>0||!!t.displacementMap&&t.displacementScale!==0||!!t.alphaMap&&t.alphaTest>0||!!t.map&&t.alphaTest>0||t.alphaToCoverage}function T(e){let t=e;if(!t.isMesh||!t.castShadow||(Array.isArray(t.material)?t.material:[t.material]).some(w))return null;let n=t.geometry.morphAttributes.position?.length??0,r=[];return t.isInstancedMesh&&r.push(`i${C(t.instanceColor)}${C(t.morphTexture)}`),t.isSkinnedMesh&&r.push(`s`),t.isBatchedMesh&&r.push(`b${C(t.colorTexture)}`),n>0&&r.push(`m${n}`),r.length>0?r.join(``):null}function E(){let e=new Map,t=new Set,n=n=>{let r=e.get(n);return r||(r=new u.MeshDepthMaterial,e.set(n,r),t.add(r)),r},r=e=>e.customDepthMaterial===void 0||t.has(e.customDepthMaterial);return{assign:e=>{e.traverse(e=>{if(!r(e))return;let t=T(e);t?e.customDepthMaterial=n(t):e.customDepthMaterial&&=void 0})},release:e=>{e.traverse(e=>{e.customDepthMaterial&&t.has(e.customDepthMaterial)&&(e.customDepthMaterial=void 0)})},dispose:()=>{e.forEach(e=>e.dispose()),e.clear(),t.clear()}}}var D=500;function O(){return(0,f.useThree)(e=>c.g(e.gl)===`webgl`)?(0,p.jsx)(k,{}):null}function k(){let e=(0,f.useThree)(e=>e.scene),n=(0,d.useMemo)(()=>E(),[]);return(0,d.useEffect)(()=>()=>{n.release(e),n.dispose()},[n,e]),t.t(`lateUpdate`,()=>n.assign(e),{throttleMs:D,label:`rendering:shadow-depth`}),null}var A=(0,d.lazy)(()=>Promise.resolve().then(()=>require("./WorldPostProcessing-C9qqKrpI.cjs")).then(e=>e.n).then(e=>({default:e.WorldPostProcessing}))),j=[`characterUrl`,`vehicleUrl`,`airplaneUrl`,`ridingUrl`],M={characterUrl:`character`,vehicleUrl:`vehicle`,airplaneUrl:`airplane`};function N({children:e,showGrid:t,showAxes:n}){return(0,p.jsxs)(`group`,{name:`gaesup-world`,children:[t&&(0,p.jsx)(`gridHelper`,{args:[100,100,`#888888`,`#444444`]}),n&&(0,p.jsx)(`axesHelper`,{args:[10]}),(0,p.jsx)(l.u,{children:e})]})}function P(e){return(0,p.jsx)(y,{runtime:e.runtime,revision:e.runtimeRevision,children:(0,p.jsx)(F,{...e})})}function F(e){let t=a.s(),n=a.o(e=>e.setMode),r=a.o(e=>e.setUrls),i=a.o(e=>e.replaceCameraOption),o=(0,d.useMemo)(()=>{let t=e.urls;if(!t)return null;let n={};for(let e of j){let r=M[e],i=t[e]??(r?t[r]:void 0);i!==void 0&&(n[e]=i)}return Object.keys(n).length>0?n:null},[e.urls]);(0,d.useEffect)(()=>{o&&r(o)},[o,r]);let s=(0,d.useMemo)(()=>{let t=e.cameraOption;if(!t)return null;let n=t.distance??15,r=t.type===`topDown`,i=t.type===`firstPerson`,o={xDistance:t.xDistance??(r||i?0:n),yDistance:t.yDistance??t.height??(r?n:i?a.w.FIRST_PERSON_EYE_HEIGHT:a.w.Y_DISTANCE),zDistance:t.zDistance??(r?0:i?a.w.FIRST_PERSON_FORWARD:n)};return t.fov!==void 0&&(o.fov=t.fov),o.zoom=t.zoom??a.w.ZOOM,o.focus=a.w.FOCUS,t.enableZoom!==void 0&&(o.enableZoom=t.enableZoom),t.minZoom!==void 0&&(o.minZoom=t.minZoom),t.maxZoom!==void 0&&(o.maxZoom=t.maxZoom),t.zoomSpeed!==void 0&&(o.zoomSpeed=t.zoomSpeed),t.enableCollision!==void 0&&(o.enableCollision=t.enableCollision),t.collisionMode!==void 0&&(o.collisionMode=t.collisionMode),t.collisionFadeOpacity!==void 0&&(o.collisionFadeOpacity=t.collisionFadeOpacity),t.dragOrbit!==void 0&&(o.dragOrbit=t.dragOrbit),t.smoothness!==void 0&&(o.smoothing={position:t.smoothness,rotation:t.smoothness,fov:t.smoothness}),o},[e.cameraOption]);return(0,d.useLayoutEffect)(()=>{if(e.mode&&n(e.mode),e.cameraOption&&n({control:e.cameraOption.type}),s){let e={...t.getState().cameraOption,...s};delete e.offset,delete e.focusTarget,i(e)}},[s,e.cameraOption,e.mode,e.runtimeRevision,i,n,t]),e.children}function I({children:e,showGrid:t,showAxes:r,postProcessing:s,performance:c,quality:u}){let f=a.o(e=>e.performanceSamplers>0);return(0,p.jsxs)(l.n,{quality:u,children:[(0,p.jsx)(i.n,{metrics:!n.r()}),(0,p.jsxs)(d.Suspense,{fallback:null,children:[(0,p.jsx)(o.n,{}),((c??!n.r())||f)&&(0,p.jsx)(S,{}),(0,p.jsx)(O,{}),s&&(0,p.jsx)(d.Suspense,{fallback:null,children:(0,p.jsx)(R,{props:typeof s==`object`?s:{}})}),(0,p.jsx)(N,{showGrid:t??!1,showAxes:r??!1,children:e})]})]})}var L={low:`performance`,medium:`balanced`,high:`quality`};function R({props:e}){let t=l.i();if(t&&!t.postprocess)return null;let n=e.quality??(t?L[t.tier]:void 0);return(0,p.jsx)(A,{...e,...n?{quality:n}:{}})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return I}});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { g as e, i as t, t as n } from "./useEngineFrame-DH3I5P9Z.js";
|
|
2
2
|
import { r } from "./logger-CIvdj60w.js";
|
|
3
3
|
import { t as i } from "./runtimeContext-IAbUva69.js";
|
|
4
|
-
import { n as a } from "./WorldPhysics-
|
|
5
|
-
import { o, r as s, s as c, w as l } from "./CoreBridge-
|
|
6
|
-
import { n as u } from "./useGenericRefs-
|
|
4
|
+
import { n as a } from "./WorldPhysics-Dry82NpQ.js";
|
|
5
|
+
import { o, r as s, s as c, w as l } from "./CoreBridge-CoU_vJOo.js";
|
|
6
|
+
import { n as u } from "./useGenericRefs-PVX2F3On.js";
|
|
7
7
|
import { t as d } from "./timeStore-Ck5CxJuk.js";
|
|
8
|
-
import {
|
|
9
|
-
import { i as p, n as m, u as h } from "./quality
|
|
8
|
+
import { g as f } from "./sceneCompile-CuCsjsKm.js";
|
|
9
|
+
import { i as p, n as m, u as h } from "./quality--izFMxKn.js";
|
|
10
10
|
import * as g from "three";
|
|
11
11
|
import { Suspense as _, lazy as v, useContext as y, useEffect as b, useLayoutEffect as x, useMemo as S, useRef as C, useSyncExternalStore as w } from "react";
|
|
12
12
|
import { addAfterEffect as T, useThree as E } from "@react-three/fiber";
|
|
@@ -151,7 +151,7 @@ function W() {
|
|
|
151
151
|
}
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region src/core/world/components/WorldContainer/index.tsx
|
|
154
|
-
var G = v(() => import("./WorldPostProcessing-
|
|
154
|
+
var G = v(() => import("./WorldPostProcessing-C40JqbKO.js").then((e) => e.n).then((e) => ({ default: e.WorldPostProcessing }))), K = [
|
|
155
155
|
"characterUrl",
|
|
156
156
|
"vehicleUrl",
|
|
157
157
|
"airplaneUrl",
|
|
@@ -205,7 +205,7 @@ function X(e) {
|
|
|
205
205
|
yDistance: t.yDistance ?? t.height ?? (r ? n : i ? l.FIRST_PERSON_EYE_HEIGHT : l.Y_DISTANCE),
|
|
206
206
|
zDistance: t.zDistance ?? (r ? 0 : i ? l.FIRST_PERSON_FORWARD : n)
|
|
207
207
|
};
|
|
208
|
-
return t.fov !== void 0 && (a.fov = t.fov), a.zoom = t.zoom ?? l.ZOOM, a.focus = l.FOCUS, t.enableZoom !== void 0 && (a.enableZoom = t.enableZoom), t.minZoom !== void 0 && (a.minZoom = t.minZoom), t.maxZoom !== void 0 && (a.maxZoom = t.maxZoom), t.zoomSpeed !== void 0 && (a.zoomSpeed = t.zoomSpeed), t.enableCollision !== void 0 && (a.enableCollision = t.enableCollision), t.dragOrbit !== void 0 && (a.dragOrbit = t.dragOrbit), t.smoothness !== void 0 && (a.smoothing = {
|
|
208
|
+
return t.fov !== void 0 && (a.fov = t.fov), a.zoom = t.zoom ?? l.ZOOM, a.focus = l.FOCUS, t.enableZoom !== void 0 && (a.enableZoom = t.enableZoom), t.minZoom !== void 0 && (a.minZoom = t.minZoom), t.maxZoom !== void 0 && (a.maxZoom = t.maxZoom), t.zoomSpeed !== void 0 && (a.zoomSpeed = t.zoomSpeed), t.enableCollision !== void 0 && (a.enableCollision = t.enableCollision), t.collisionMode !== void 0 && (a.collisionMode = t.collisionMode), t.collisionFadeOpacity !== void 0 && (a.collisionFadeOpacity = t.collisionFadeOpacity), t.dragOrbit !== void 0 && (a.dragOrbit = t.dragOrbit), t.smoothness !== void 0 && (a.smoothing = {
|
|
209
209
|
position: t.smoothness,
|
|
210
210
|
rotation: t.smoothness,
|
|
211
211
|
fov: t.smoothness
|