gaesup-world 1.2.0 → 1.3.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.
Files changed (84) hide show
  1. package/dist/{ControllerWrapper-jGqlqLgR.js → ControllerWrapper-Bc_pRQSv.js} +1 -1
  2. package/dist/{ControllerWrapper-WJUu-I7W.cjs → ControllerWrapper-C6mzwejv.cjs} +1 -1
  3. package/dist/{Gamepad-DsvoS6os.cjs → Gamepad-BVhh5IfO.cjs} +1 -1
  4. package/dist/{Gamepad-D1PJuBvE.js → Gamepad-DpCgazVm.js} +1 -1
  5. package/dist/{NodeGrassMaterial-fyrFt7pU.cjs → NodeGrassMaterial-BMwfsBMP.cjs} +1 -1
  6. package/dist/{NodeGrassMaterial-D3U4NZAW.js → NodeGrassMaterial-W9H9z72i.js} +1 -1
  7. package/dist/{NodeWaterMaterial-CBrHckTC.js → NodeWaterMaterial-Bc1nkYSw.js} +1 -1
  8. package/dist/{NodeWaterMaterial-C90WTomH.cjs → NodeWaterMaterial-C5fHPHUG.cjs} +1 -1
  9. package/dist/{Rideable-C2aoGTmF.cjs → Rideable-CWddzOkn.cjs} +1 -1
  10. package/dist/{Rideable-CuNvwh2D.js → Rideable-DTSh5xu3.js} +2 -2
  11. package/dist/{WorldContainer-DI4x1VGT.cjs → WorldContainer-BjZj0uvZ.cjs} +1 -1
  12. package/dist/{WorldContainer-B5bM3fwx.js → WorldContainer-Ce5PVxSF.js} +4 -4
  13. package/dist/{WorldPostProcessing-2fSaVGEL.cjs → WorldPostProcessing-C80qMk1k.cjs} +1 -1
  14. package/dist/{WorldPostProcessing-C1uP1gjh.js → WorldPostProcessing-Dfq_RW-t.js} +2 -3
  15. package/dist/blueprints-editor.cjs +1 -1
  16. package/dist/blueprints-editor.js +4 -4
  17. package/dist/building.cjs +1 -1
  18. package/dist/building.js +1 -1
  19. package/dist/core/building/components/WallSystem/batch.d.cts +12 -3
  20. package/dist/core/building/components/WallSystem/batch.d.ts +12 -3
  21. package/dist/core/building/components/WallSystem/pieces.d.cts +8 -4
  22. package/dist/core/building/components/WallSystem/pieces.d.ts +8 -4
  23. package/dist/core/building/hooks/useReusedByKey.d.cts +5 -0
  24. package/dist/core/building/hooks/useReusedByKey.d.ts +5 -0
  25. package/dist/core/camera/utils/triangleGrid.d.cts +29 -0
  26. package/dist/core/camera/utils/triangleGrid.d.ts +29 -0
  27. package/dist/core/networks/components/index.d.cts +1 -0
  28. package/dist/core/networks/components/index.d.ts +1 -0
  29. package/dist/core/perf/idle.d.cts +2 -2
  30. package/dist/core/perf/idle.d.ts +2 -2
  31. package/dist/core/rendering/sceneCompile.d.cts +6 -7
  32. package/dist/core/rendering/sceneCompile.d.ts +6 -7
  33. package/dist/editor.cjs +1 -1
  34. package/dist/editor.js +2 -2
  35. package/dist/index.cjs +2 -2
  36. package/dist/index.js +851 -848
  37. package/dist/legacyDrei-B6cWIHbX.js +2 -0
  38. package/dist/network.cjs +1 -1
  39. package/dist/network.js +2 -2
  40. package/dist/{plugin-epk5BZCz.cjs → plugin-BUKo4q0N.cjs} +32 -32
  41. package/dist/{plugin-KFnkRLsd.js → plugin-Dsf9EwPP.js} +1468 -1522
  42. package/dist/postprocessing.cjs +1 -1
  43. package/dist/postprocessing.js +1 -1
  44. package/dist/{quality-KkwsHdju.cjs → quality-0VukPLnv.cjs} +1 -1
  45. package/dist/{quality-BgplnaOO.js → quality-BLE1xXFm.js} +1 -1
  46. package/dist/runtime.cjs +1 -1
  47. package/dist/runtime.js +2 -2
  48. package/dist/{sceneCompile-CHRGwswb.js → sceneCompile-BWpSal9S.js} +80 -64
  49. package/dist/sceneCompile-D9xft0op.cjs +1 -0
  50. package/dist/{sfe-CjDh54rj.js → sfe-BAXSr5BB.js} +147 -40
  51. package/dist/{sfe-aBcZuSF2.cjs → sfe-DnOKmvUM.cjs} +1 -1
  52. package/dist/{shell-Cuw1RbCu.cjs → shell-Bkt0gci9.cjs} +1 -1
  53. package/dist/{shell-69YWpmhQ.js → shell-CdnYaUXk.js} +5 -5
  54. package/dist/useGenericRefs-CZ_HIQG_.cjs +1 -0
  55. package/dist/{useGenericRefs-8NKwNG7N.js → useGenericRefs-D0cOKidj.js} +247 -188
  56. package/dist/{useVisitRoom-BbS5lhx5.js → useVisitRoom-C_UX2avV.js} +372 -390
  57. package/dist/{useVisitRoom-D_7rwTnk.cjs → useVisitRoom-GXR8KyFN.cjs} +1 -1
  58. package/package.json +4 -3
  59. package/public/gltf/nature/fern.glb +0 -0
  60. package/public/gltf/nature/kenney/LICENSE.txt +23 -0
  61. package/public/gltf/nature/kenney/bush.glb +0 -0
  62. package/public/gltf/nature/kenney/fallen-log.glb +0 -0
  63. package/public/gltf/nature/kenney/flower-purple.glb +0 -0
  64. package/public/gltf/nature/kenney/flower-red.glb +0 -0
  65. package/public/gltf/nature/kenney/flower-yellow.glb +0 -0
  66. package/public/gltf/nature/kenney/lily.glb +0 -0
  67. package/public/gltf/nature/kenney/mushroom-cluster.glb +0 -0
  68. package/public/gltf/nature/kenney/rock-flat.glb +0 -0
  69. package/public/gltf/nature/kenney/rock-large.glb +0 -0
  70. package/public/gltf/nature/kenney/rock-moss.glb +0 -0
  71. package/public/gltf/nature/kenney/rock-small.glb +0 -0
  72. package/public/gltf/nature/kenney/stump.glb +0 -0
  73. package/public/gltf/nature/manifest.json +137 -0
  74. package/public/gltf/nature/rock-round.glb +0 -0
  75. package/public/gltf/nature/rock-tall.glb +0 -0
  76. package/public/gltf/nature/rock-wide.glb +0 -0
  77. package/public/gltf/nature/tree-fat.glb +0 -0
  78. package/public/gltf/nature/tree-oak.glb +0 -0
  79. package/public/gltf/nature/tree-pine.glb +0 -0
  80. package/public/gltf/nature/tree-round.glb +0 -0
  81. package/public/gltf/nature/tree-thin.glb +0 -0
  82. package/dist/legacyDrei-DIgQmWEr.js +0 -2
  83. package/dist/sceneCompile-CZwYKosw.cjs +0 -1
  84. package/dist/useGenericRefs-D8axfJ-5.cjs +0 -1
@@ -2,7 +2,7 @@ import { i as e, t } from "./useEngineFrame-DH3I5P9Z.js";
2
2
  import { t as n } from "./logger-CIvdj60w.js";
3
3
  import { L as r, Ut as i, Y as a, i as o, mr as s, n as c, t as l } from "./useClicker-DZrb1I0b.js";
4
4
  import { o as u, s as d } from "./CoreBridge-DdJBUxmY.js";
5
- import { t as f, x as p } from "./useGenericRefs-8NKwNG7N.js";
5
+ import { t as f, x as p } from "./useGenericRefs-D0cOKidj.js";
6
6
  import { r as m, t as h } from "./useNavigation-B-QniiTX.js";
7
7
  import * as g from "three";
8
8
  import { memo as _, useCallback as v, useEffect as y, useMemo as b, useRef as x, useState as S } from "react";
@@ -1 +1 @@
1
- const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./useEngineFrame-ujTlLQfa.cjs"),n=require("./logger-B9OaKOPw.cjs"),r=require("./useClicker-0Ln5ZSz0.cjs"),i=require("./CoreBridge-CnLqWZNv.cjs"),a=require("./useGenericRefs-D8axfJ-5.cjs"),o=require("./useNavigation-D-c4u9T4.cjs");let s=require("three");s=e.n(s,1);let c=require("react"),l=require("react/jsx-runtime"),u=require("zustand/react/shallow"),d=require("@react-three/rapier");var f=1e-6,p=1e-4,m=new WeakMap;function h(e,t,n){let r=n.getFrame(),i=m.get(e);if(i&&i.scheduler===n&&i.frame===r&&i.entityId===t)return i.snapshot;let a=e.snapshot(t);return i?(i.scheduler=n,i.frame=r,i.entityId=t,i.snapshot=a,a):(m.set(e,{scheduler:n,frame:r,entityId:t,snapshot:a}),a)}var g=()=>({x:0,y:0,z:0,rx:0,ry:0,rz:0,moving:!1,grounded:!1});function _(e,t){let{position:n,rotation:r}=t,i=n.x-e.x,a=n.y-e.y,o=n.z-e.z;return i*i+a*a+o*o<=f&&Math.abs(r.x-e.rx)<=p&&Math.abs(r.y-e.ry)<=p&&Math.abs(r.z-e.rz)<=p&&t.isMoving===e.moving&&t.isGrounded===e.grounded?!1:(e.x=n.x,e.y=n.y,e.z=n.z,e.rx=r.x,e.ry=r.y,e.rz=r.z,e.moving=t.isMoving,e.grounded=t.isGrounded,!0)}var v=()=>({position:new s.Vector3(0,0,0),velocity:new s.Vector3(0,0,0),rotation:new s.Euler(0,0,0),isMoving:!1,isGrounded:!1,speed:0,height:2});function y(e={}){let{updateInterval:n=0,entityId:i,reactive:a=!0}=e,o=r.L(),s=(0,c.useRef)(null);s.current||=v();let[,l]=(0,c.useState)(0),u=(0,c.useRef)(0),d=(0,c.useRef)(0),f=(0,c.useRef)(g()),p=(0,c.useRef)(null),m=t.i(),{activeState:y,gameStates:b}=r.Y(),x=e=>i||(e.getPlayerEntityId()??void 0),S=(e,t,n)=>{let r=t===e.getPlayerEntityId()?y?.euler:void 0;s.current.rotation.copy(r??n)};return(0,c.useEffect)(()=>{p.current=o;let e=p.current;if(!e)return;let t=e.subscribe((t,r)=>{let i=x(e);if(!i||r!==i)return;let o=performance.now();if(d.current=o,n>0&&o-u.current<n)return;u.current=o;let c=s.current;c.position.copy(t.position),c.velocity.copy(t.velocity),S(e,i,t.rotation),c.isMoving=t.isMoving,c.isGrounded=t.isGrounded,c.speed=t.speed,c.height=2,a&&_(f.current,c)&&l(e=>e+1)});return()=>{t()}},[i,n,a,o]),t.t(`postPhysics`,()=>{let e=performance.now();if(n>0&&e-u.current<n)return;let t=s.current,r=p.current;if(r){let n=x(r);if(!(e-d.current<16)&&n){let i=h(r,n,m);if(i){t.position.copy(i.position),t.velocity.copy(i.velocity),S(r,n,i.rotation),t.isMoving=i.isMoving,t.isGrounded=i.isGrounded,t.speed=i.speed,t.height=2,u.current=e,a&&_(f.current,t)&&l(e=>e+1);return}}}y?.position&&(t.position.copy(y.position),y.velocity?t.velocity.copy(y.velocity):t.velocity.set(0,0,0),y.euler?t.rotation.copy(y.euler):t.rotation.set(0,0,0),t.isMoving=b?.isMoving||!1,t.isGrounded=b?.isOnTheGround||!1,t.speed=y.velocity?y.velocity.length():0,t.height=2,u.current=e,a&&_(f.current,t)&&l(e=>e+1))},{order:10,label:`motions:player-position`}),s.current}function b(e={}){let{position:t}=y(e);return t}var x={move:`move`,jump:`jump`,run:`run`,interact:`interact`},S=`button:0`,C=`button:2`,w=`button:10`,T=`axis:0`,E=`axis:1`;function D(){return[{name:x.move,kind:`axis2D`,bindings:[{device:`keyboard`,code:`KeyW`,axis:`y`,scale:1},{device:`keyboard`,code:`KeyS`,axis:`y`,scale:-1},{device:`keyboard`,code:`KeyD`,axis:`x`,scale:1},{device:`keyboard`,code:`KeyA`,axis:`x`,scale:-1},{device:`keyboard`,code:`ArrowUp`,axis:`y`,scale:1},{device:`keyboard`,code:`ArrowDown`,axis:`y`,scale:-1},{device:`keyboard`,code:`ArrowRight`,axis:`x`,scale:1},{device:`keyboard`,code:`ArrowLeft`,axis:`x`,scale:-1},{device:`gamepad`,code:T,axis:`x`,scale:1},{device:`gamepad`,code:E,axis:`y`,scale:-1},{device:`touch`,code:`stick:x`,axis:`x`,scale:1},{device:`touch`,code:`stick:y`,axis:`y`,scale:1}]},{name:x.jump,kind:`button`,bindings:[{device:`keyboard`,code:`Space`},{device:`gamepad`,code:S},{device:`touch`,code:`button:jump`}]},{name:x.run,kind:`button`,bindings:[{device:`keyboard`,code:`ShiftLeft`},{device:`keyboard`,code:`ShiftRight`},{device:`gamepad`,code:w},{device:`touch`,code:`button:run`}]},{name:x.interact,kind:`button`,bindings:[{device:`keyboard`,code:`KeyE`},{device:`gamepad`,code:C},{device:`touch`,code:`button:interact`}]}]}function O(e,t={}){return Object.entries(e).map(([e,n])=>({name:e,kind:t[e]??(n.some(e=>e.scale!==void 0)?`axis1D`:`button`),bindings:n.map(e=>({device:e.device,code:e.code,...e.scale===void 0?{}:{scale:e.scale}}))}))}var k={"y:1":`forward`,"y:-1":`backward`,"x:1":`rightward`,"x:-1":`leftward`},A={[x.jump]:`space`,[x.run]:`shift`,[x.interact]:`keyE`};function j(){let e={KeyZ:`keyZ`,KeyR:`keyR`,KeyF:`keyF`,Escape:`escape`};for(let t of D())for(let n of t.bindings){if(n.device!==`keyboard`)continue;let r=t.name===x.move?k[`${n.axis}:${Math.sign(n.scale??1)}`]:A[t.name];r&&(e[n.code]=r)}return e}var M=j(),N=(e=!0,t=!0,o,s=!0,l=!0)=>{let u=r.mr(),d=i.o(e=>e.automation?.queue.isRunning),f=i.o(e=>e.stopAutomation),p=i.o(e=>e.interaction?.isActive??!0),m=r.Ut(e=>e.isInEditMode()),h=r.i(),g=(0,c.useMemo)(()=>a.x(h),[h]),_=(0,c.useRef)(new Map),v=(0,c.useMemo)(()=>({...M}),[]),y=(0,c.useCallback)((e,t)=>{if(!s||!p||!u.isEnabled())return!1;try{let n=`api:${e}`;return g.set(n,e,t),t?_.current.set(n,e):_.current.delete(n),!0}catch(e){return n.t.error(`Error updating keyboard state`,e instanceof Error?e:String(e)),!1}},[s,g,p,u]),b=(0,c.useCallback)(()=>{_.current.clear(),g.release();let e={};for(let t of Object.values(M))g.isHeld(t)||Object.assign(e,{[t]:!1});h.updateKeyboard(e)},[h,g]);return(0,c.useEffect)(()=>{let e=_.current;return()=>{g.release(),e.clear()}},[g]),(0,c.useEffect)(()=>{(!p||m)&&b()},[b,p,m]),(0,c.useEffect)(()=>{if(!l)for(let[e,t]of _.current)M[t]&&(_.current.delete(e),g.set(e,M[t],!1))},[l,g]),(0,c.useEffect)(()=>{if(!s){_.current.size>0&&b();return}let e=(e,n)=>{if(n&&(e.ctrlKey||e.altKey||e.metaKey)){_.current.size>0&&b();return}let r=e.target;if(r instanceof HTMLElement&&(r.matches(`input, textarea, select`)||r.isContentEditable)){_.current.size>0&&b();return}let i=v[e.code];if(!i)return;if(!p||m){n&&e.preventDefault(),b();return}let a=u.eventSource(e),o=_.current.has(a);n&&!o?(_.current.set(a,e.code),e.code===`Space`&&e.preventDefault(),t&&d&&(i===`forward`||i===`backward`||i===`leftward`||i===`rightward`)&&(f(),h.updateMouse({isActive:!1,shouldRun:!1})),g.set(a,i,!0)):!n&&o&&(_.current.delete(a),g.set(a,i,!1))},n=t=>e(t,!0),r=t=>e(t,!1),i=l?u.listen(`keydown`,n):void 0,a=l?u.listen(`keyup`,r):void 0,o=u.onBlur(()=>{_.current.size>0&&b()});return()=>{i?.(),a?.(),o()}},[s,l,g,v,t,f,d,b,p,m,h,u]),{pressedKeys:[...new Set(_.current.values())],pushKey:y,isKeyPressed:e=>Array.from(_.current.values()).includes(e),clearAllKeys:b}},P=128,F=100,I=.16,L=.06;function R(e,t,n){for(let r=0;r<t;r+=1){let i=e[r],a=e[Math.max(0,r-1)],o=e[Math.min(t-1,r+1)],s=o.x-a.x,c=o.z-a.z,l=Math.hypot(s,c)||1;s/=l,c/=l;let u=-c*I*.5,d=s*I*.5,f=r*6;n[f]=i.x+u,n[f+1]=i.y+L,n[f+2]=i.z+d,n[f+3]=i.x-u,n[f+4]=i.y+L,n[f+5]=i.z-d}}function z({pointsRef:e,color:n}){let r=(0,c.useRef)(0),i=(0,c.useMemo)(()=>{let e=new s.BufferGeometry,t=new s.BufferAttribute(new Float32Array(768),3).setUsage(s.DynamicDrawUsage);e.setAttribute(`position`,t);let n=[];for(let e=0;e<127;e+=1){let t=e*2;n.push(t,t+1,t+2,t+1,t+3,t+2)}e.setIndex(n),e.setDrawRange(0,0);let r=new s.MeshBasicMaterial({transparent:!0,opacity:.85,depthWrite:!1,side:s.DoubleSide}),i=new s.Mesh(e,r);return i.visible=!1,i.frustumCulled=!1,i.renderOrder=1,i},[]);return(0,c.useEffect)(()=>{i.material.color.set(n)},[i,n]),(0,c.useEffect)(()=>()=>{i.geometry.dispose(),i.material.dispose()},[i]),t.t(`lateUpdate`,()=>{let t=performance.now();if(t-r.current<F)return;r.current=t;let n=e.current;if(!n||n.length<2){i.visible=!1;return}let a=Math.min(n.length,P),o=i.geometry.getAttribute(`position`);R(n,a,o.array),o.needsUpdate=!0,i.geometry.setDrawRange(0,(a-1)*6),i.visible=!0},{label:`interactions:path-line`}),(0,l.jsx)(`primitive`,{object:i})}z.displayName=`PathLine`;var B=(0,c.memo)(()=>(0,l.jsxs)(`group`,{children:[(0,l.jsxs)(`mesh`,{position:[0,.35,0],children:[(0,l.jsx)(`sphereGeometry`,{args:[.16,16,16]}),(0,l.jsx)(`meshStandardMaterial`,{color:`#00ff88`,emissive:`#00ff88`,emissiveIntensity:.5,transparent:!0,opacity:.9})]}),(0,l.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],position:[0,.03,0],renderOrder:2,children:[(0,l.jsx)(`ringGeometry`,{args:[.3,.5,32]}),(0,l.jsx)(`meshBasicMaterial`,{color:`#00ff88`,transparent:!0,opacity:.75,depthTest:!1,side:s.DoubleSide})]})]}));B.displayName=`TargetMarker`;var V=[],H=150,U=1;function W(){let{getClickNavigationRoute:e,subscribeClickNavigationRoute:n}=o.t(),r=o.r(),a=i.o((0,u.useShallow)(e=>e.automation?.queue.actions??V)),d=i.o(e=>e.automation?.queue.currentIndex??0),f=i.o(e=>e.interaction.mouse.target),p=i.o(e=>e.interaction.mouse.isActive),{position:m}=y({updateInterval:H,reactive:!1}),[h,g]=(0,c.useState)(()=>[...e()]),_=(0,c.useRef)(null),v=(0,c.useRef)([]);(0,c.useEffect)(()=>{let t=()=>g([...e()]);return t(),n(t)},[e,n]);let b=(0,c.useMemo)(()=>a.map(e=>e.type===`move`&&e.target?new s.Vector3(e.target.x,e.target.y,e.target.z):null).filter(e=>e!==null),[a]),x=(0,c.useMemo)(()=>[m,...h.length>0?h:[f],...b],[m,h,f,b]),S=(0,c.useMemo)(()=>b.length>0?[m,...b]:[],[m,b]);return t.t(`lateUpdate`,()=>{let t=e(),n=t[t.length-1]??f,i=p&&Math.hypot(n.x-m.x,n.z-m.z)>=U,a=_.current;a&&(a.visible=i,i&&a.position.set(n.x,r.sampleHeight(n.x,n.z),n.z)),v.current=i?x:S},{label:`interactions:clicker`}),(0,l.jsxs)(`group`,{children:[(0,l.jsx)(`group`,{ref:_,visible:!1,children:(0,l.jsx)(B,{})}),(0,l.jsx)(z,{pointsRef:v,color:d>=0?`#00ff88`:`#ffaa00`}),a.map((e,t)=>{if(e.type===`move`&&e.target){let n=t===d,r=t<d;return(0,l.jsx)(`group`,{position:[e.target.x,e.target.y,e.target.z],children:(0,l.jsxs)(`mesh`,{children:[(0,l.jsx)(`sphereGeometry`,{args:[.1,8,8]}),(0,l.jsx)(`meshStandardMaterial`,{color:r?`#888`:n?`#ff4444`:`#ffaa00`,transparent:!0,opacity:r?.3:.8})]})},`action-${t}`)}return null})]})}var G=4;function K({clickerOptions:e}){let t=i.s(),{onClick:n}=r.t(e);return(0,l.jsxs)(`mesh`,{position:[0,0,0],rotation:[-Math.PI/2,0,0],onClick:e=>{if(e.nativeEvent.button!==0||e.delta>G||e.nativeEvent.altKey||e.nativeEvent.ctrlKey||e.nativeEvent.metaKey||e.nativeEvent.shiftKey)return;e.stopPropagation();let{cameraOption:r,setCameraOption:i}=t.getState();if(r?.focus){i({focus:!1});return}n(e)},visible:!0,userData:{intangible:!0},children:[(0,l.jsx)(`planeGeometry`,{args:[1e3,1e3]}),(0,l.jsx)(`meshBasicMaterial`,{transparent:!0,opacity:0,depthWrite:!1,colorWrite:!1})]})}function q({props:e,children:t}){let n=i.o(e=>e.mode),{gameStates:o}=r.Y(),s=i.o(e=>e.rideable),u=i.o(e=>e.urls),f=r.Ut(e=>e.isInEditMode()),p=a.t();N(!0,!0,void 0,e.enableKeyboard??!0);let m=o?.currentRideable?.id,h=(0,c.useMemo)(()=>(m?s?.[m]?.offset:void 0)??(0,d.vec3)(),[m,s]);if(f||!n||!o||!s||!u||n.type===`character`&&!u.characterUrl||n.type===`vehicle`&&!u.vehicleUrl||n.type===`airplane`&&!u.airplaneUrl)return null;let{canRide:g,isRiding:_}=o,v=(()=>{let{enableKeyboard:t,rigidBodyRef:r=p.rigidBodyRef,outerGroupRef:i=p.outerGroupRef,innerGroupRef:a=p.innerGroupRef,colliderRef:o=p.colliderRef,parts:s,baseColor:c,excludeBaseNodes:l,...d}=e,f={...d,isActive:!0,componentType:n.type,enableRiding:g,isRiderOn:_,offset:h,ref:r,outerGroupRef:i,innerGroupRef:a,colliderRef:o,parts:(s||[]).filter(e=>!!e.url).map(e=>({...e,url:e.url})),...typeof c==`string`&&c.trim().length>0?{baseColor:c}:{},...Array.isArray(l)&&l.length>0?{excludeBaseNodes:l}:{}},m=_&&n.type!==`character`?u.ridingUrl:void 0,v=typeof m==`string`&&m.length>0?{ridingUrl:m}:{};switch(n.type){case`character`:return{...f,url:u.characterUrl||``};case`vehicle`:return{...f,...v,url:u.vehicleUrl||``};case`airplane`:return{...f,...v,url:u.airplaneUrl||``};default:return{...f,url:u.characterUrl||``}}})();return n.type===`character`&&o.isRiding?null:(0,l.jsx)(r.n,{...v,children:t})}function J(e){let{clickToMove:t,children:n,clickerOptions:r,...i}=e,a={...r??{},...r?.agentRadius===void 0&&i.colliderSize?.radius!==void 0?{agentRadius:i.colliderSize.radius}:{}};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(q,{props:i,children:(0,l.jsxs)(l.Fragment,{children:[t&&(0,l.jsx)(K,{clickerOptions:a}),n]})}),t&&(0,l.jsx)(W,{})]})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return b}});
1
+ const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./useEngineFrame-ujTlLQfa.cjs"),n=require("./logger-B9OaKOPw.cjs"),r=require("./useClicker-0Ln5ZSz0.cjs"),i=require("./CoreBridge-CnLqWZNv.cjs"),a=require("./useGenericRefs-CZ_HIQG_.cjs"),o=require("./useNavigation-D-c4u9T4.cjs");let s=require("three");s=e.n(s,1);let c=require("react"),l=require("react/jsx-runtime"),u=require("zustand/react/shallow"),d=require("@react-three/rapier");var f=1e-6,p=1e-4,m=new WeakMap;function h(e,t,n){let r=n.getFrame(),i=m.get(e);if(i&&i.scheduler===n&&i.frame===r&&i.entityId===t)return i.snapshot;let a=e.snapshot(t);return i?(i.scheduler=n,i.frame=r,i.entityId=t,i.snapshot=a,a):(m.set(e,{scheduler:n,frame:r,entityId:t,snapshot:a}),a)}var g=()=>({x:0,y:0,z:0,rx:0,ry:0,rz:0,moving:!1,grounded:!1});function _(e,t){let{position:n,rotation:r}=t,i=n.x-e.x,a=n.y-e.y,o=n.z-e.z;return i*i+a*a+o*o<=f&&Math.abs(r.x-e.rx)<=p&&Math.abs(r.y-e.ry)<=p&&Math.abs(r.z-e.rz)<=p&&t.isMoving===e.moving&&t.isGrounded===e.grounded?!1:(e.x=n.x,e.y=n.y,e.z=n.z,e.rx=r.x,e.ry=r.y,e.rz=r.z,e.moving=t.isMoving,e.grounded=t.isGrounded,!0)}var v=()=>({position:new s.Vector3(0,0,0),velocity:new s.Vector3(0,0,0),rotation:new s.Euler(0,0,0),isMoving:!1,isGrounded:!1,speed:0,height:2});function y(e={}){let{updateInterval:n=0,entityId:i,reactive:a=!0}=e,o=r.L(),s=(0,c.useRef)(null);s.current||=v();let[,l]=(0,c.useState)(0),u=(0,c.useRef)(0),d=(0,c.useRef)(0),f=(0,c.useRef)(g()),p=(0,c.useRef)(null),m=t.i(),{activeState:y,gameStates:b}=r.Y(),x=e=>i||(e.getPlayerEntityId()??void 0),S=(e,t,n)=>{let r=t===e.getPlayerEntityId()?y?.euler:void 0;s.current.rotation.copy(r??n)};return(0,c.useEffect)(()=>{p.current=o;let e=p.current;if(!e)return;let t=e.subscribe((t,r)=>{let i=x(e);if(!i||r!==i)return;let o=performance.now();if(d.current=o,n>0&&o-u.current<n)return;u.current=o;let c=s.current;c.position.copy(t.position),c.velocity.copy(t.velocity),S(e,i,t.rotation),c.isMoving=t.isMoving,c.isGrounded=t.isGrounded,c.speed=t.speed,c.height=2,a&&_(f.current,c)&&l(e=>e+1)});return()=>{t()}},[i,n,a,o]),t.t(`postPhysics`,()=>{let e=performance.now();if(n>0&&e-u.current<n)return;let t=s.current,r=p.current;if(r){let n=x(r);if(!(e-d.current<16)&&n){let i=h(r,n,m);if(i){t.position.copy(i.position),t.velocity.copy(i.velocity),S(r,n,i.rotation),t.isMoving=i.isMoving,t.isGrounded=i.isGrounded,t.speed=i.speed,t.height=2,u.current=e,a&&_(f.current,t)&&l(e=>e+1);return}}}y?.position&&(t.position.copy(y.position),y.velocity?t.velocity.copy(y.velocity):t.velocity.set(0,0,0),y.euler?t.rotation.copy(y.euler):t.rotation.set(0,0,0),t.isMoving=b?.isMoving||!1,t.isGrounded=b?.isOnTheGround||!1,t.speed=y.velocity?y.velocity.length():0,t.height=2,u.current=e,a&&_(f.current,t)&&l(e=>e+1))},{order:10,label:`motions:player-position`}),s.current}function b(e={}){let{position:t}=y(e);return t}var x={move:`move`,jump:`jump`,run:`run`,interact:`interact`},S=`button:0`,C=`button:2`,w=`button:10`,T=`axis:0`,E=`axis:1`;function D(){return[{name:x.move,kind:`axis2D`,bindings:[{device:`keyboard`,code:`KeyW`,axis:`y`,scale:1},{device:`keyboard`,code:`KeyS`,axis:`y`,scale:-1},{device:`keyboard`,code:`KeyD`,axis:`x`,scale:1},{device:`keyboard`,code:`KeyA`,axis:`x`,scale:-1},{device:`keyboard`,code:`ArrowUp`,axis:`y`,scale:1},{device:`keyboard`,code:`ArrowDown`,axis:`y`,scale:-1},{device:`keyboard`,code:`ArrowRight`,axis:`x`,scale:1},{device:`keyboard`,code:`ArrowLeft`,axis:`x`,scale:-1},{device:`gamepad`,code:T,axis:`x`,scale:1},{device:`gamepad`,code:E,axis:`y`,scale:-1},{device:`touch`,code:`stick:x`,axis:`x`,scale:1},{device:`touch`,code:`stick:y`,axis:`y`,scale:1}]},{name:x.jump,kind:`button`,bindings:[{device:`keyboard`,code:`Space`},{device:`gamepad`,code:S},{device:`touch`,code:`button:jump`}]},{name:x.run,kind:`button`,bindings:[{device:`keyboard`,code:`ShiftLeft`},{device:`keyboard`,code:`ShiftRight`},{device:`gamepad`,code:w},{device:`touch`,code:`button:run`}]},{name:x.interact,kind:`button`,bindings:[{device:`keyboard`,code:`KeyE`},{device:`gamepad`,code:C},{device:`touch`,code:`button:interact`}]}]}function O(e,t={}){return Object.entries(e).map(([e,n])=>({name:e,kind:t[e]??(n.some(e=>e.scale!==void 0)?`axis1D`:`button`),bindings:n.map(e=>({device:e.device,code:e.code,...e.scale===void 0?{}:{scale:e.scale}}))}))}var k={"y:1":`forward`,"y:-1":`backward`,"x:1":`rightward`,"x:-1":`leftward`},A={[x.jump]:`space`,[x.run]:`shift`,[x.interact]:`keyE`};function j(){let e={KeyZ:`keyZ`,KeyR:`keyR`,KeyF:`keyF`,Escape:`escape`};for(let t of D())for(let n of t.bindings){if(n.device!==`keyboard`)continue;let r=t.name===x.move?k[`${n.axis}:${Math.sign(n.scale??1)}`]:A[t.name];r&&(e[n.code]=r)}return e}var M=j(),N=(e=!0,t=!0,o,s=!0,l=!0)=>{let u=r.mr(),d=i.o(e=>e.automation?.queue.isRunning),f=i.o(e=>e.stopAutomation),p=i.o(e=>e.interaction?.isActive??!0),m=r.Ut(e=>e.isInEditMode()),h=r.i(),g=(0,c.useMemo)(()=>a.x(h),[h]),_=(0,c.useRef)(new Map),v=(0,c.useMemo)(()=>({...M}),[]),y=(0,c.useCallback)((e,t)=>{if(!s||!p||!u.isEnabled())return!1;try{let n=`api:${e}`;return g.set(n,e,t),t?_.current.set(n,e):_.current.delete(n),!0}catch(e){return n.t.error(`Error updating keyboard state`,e instanceof Error?e:String(e)),!1}},[s,g,p,u]),b=(0,c.useCallback)(()=>{_.current.clear(),g.release();let e={};for(let t of Object.values(M))g.isHeld(t)||Object.assign(e,{[t]:!1});h.updateKeyboard(e)},[h,g]);return(0,c.useEffect)(()=>{let e=_.current;return()=>{g.release(),e.clear()}},[g]),(0,c.useEffect)(()=>{(!p||m)&&b()},[b,p,m]),(0,c.useEffect)(()=>{if(!l)for(let[e,t]of _.current)M[t]&&(_.current.delete(e),g.set(e,M[t],!1))},[l,g]),(0,c.useEffect)(()=>{if(!s){_.current.size>0&&b();return}let e=(e,n)=>{if(n&&(e.ctrlKey||e.altKey||e.metaKey)){_.current.size>0&&b();return}let r=e.target;if(r instanceof HTMLElement&&(r.matches(`input, textarea, select`)||r.isContentEditable)){_.current.size>0&&b();return}let i=v[e.code];if(!i)return;if(!p||m){n&&e.preventDefault(),b();return}let a=u.eventSource(e),o=_.current.has(a);n&&!o?(_.current.set(a,e.code),e.code===`Space`&&e.preventDefault(),t&&d&&(i===`forward`||i===`backward`||i===`leftward`||i===`rightward`)&&(f(),h.updateMouse({isActive:!1,shouldRun:!1})),g.set(a,i,!0)):!n&&o&&(_.current.delete(a),g.set(a,i,!1))},n=t=>e(t,!0),r=t=>e(t,!1),i=l?u.listen(`keydown`,n):void 0,a=l?u.listen(`keyup`,r):void 0,o=u.onBlur(()=>{_.current.size>0&&b()});return()=>{i?.(),a?.(),o()}},[s,l,g,v,t,f,d,b,p,m,h,u]),{pressedKeys:[...new Set(_.current.values())],pushKey:y,isKeyPressed:e=>Array.from(_.current.values()).includes(e),clearAllKeys:b}},P=128,F=100,I=.16,L=.06;function R(e,t,n){for(let r=0;r<t;r+=1){let i=e[r],a=e[Math.max(0,r-1)],o=e[Math.min(t-1,r+1)],s=o.x-a.x,c=o.z-a.z,l=Math.hypot(s,c)||1;s/=l,c/=l;let u=-c*I*.5,d=s*I*.5,f=r*6;n[f]=i.x+u,n[f+1]=i.y+L,n[f+2]=i.z+d,n[f+3]=i.x-u,n[f+4]=i.y+L,n[f+5]=i.z-d}}function z({pointsRef:e,color:n}){let r=(0,c.useRef)(0),i=(0,c.useMemo)(()=>{let e=new s.BufferGeometry,t=new s.BufferAttribute(new Float32Array(768),3).setUsage(s.DynamicDrawUsage);e.setAttribute(`position`,t);let n=[];for(let e=0;e<127;e+=1){let t=e*2;n.push(t,t+1,t+2,t+1,t+3,t+2)}e.setIndex(n),e.setDrawRange(0,0);let r=new s.MeshBasicMaterial({transparent:!0,opacity:.85,depthWrite:!1,side:s.DoubleSide}),i=new s.Mesh(e,r);return i.visible=!1,i.frustumCulled=!1,i.renderOrder=1,i},[]);return(0,c.useEffect)(()=>{i.material.color.set(n)},[i,n]),(0,c.useEffect)(()=>()=>{i.geometry.dispose(),i.material.dispose()},[i]),t.t(`lateUpdate`,()=>{let t=performance.now();if(t-r.current<F)return;r.current=t;let n=e.current;if(!n||n.length<2){i.visible=!1;return}let a=Math.min(n.length,P),o=i.geometry.getAttribute(`position`);R(n,a,o.array),o.needsUpdate=!0,i.geometry.setDrawRange(0,(a-1)*6),i.visible=!0},{label:`interactions:path-line`}),(0,l.jsx)(`primitive`,{object:i})}z.displayName=`PathLine`;var B=(0,c.memo)(()=>(0,l.jsxs)(`group`,{children:[(0,l.jsxs)(`mesh`,{position:[0,.35,0],children:[(0,l.jsx)(`sphereGeometry`,{args:[.16,16,16]}),(0,l.jsx)(`meshStandardMaterial`,{color:`#00ff88`,emissive:`#00ff88`,emissiveIntensity:.5,transparent:!0,opacity:.9})]}),(0,l.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],position:[0,.03,0],renderOrder:2,children:[(0,l.jsx)(`ringGeometry`,{args:[.3,.5,32]}),(0,l.jsx)(`meshBasicMaterial`,{color:`#00ff88`,transparent:!0,opacity:.75,depthTest:!1,side:s.DoubleSide})]})]}));B.displayName=`TargetMarker`;var V=[],H=150,U=1;function W(){let{getClickNavigationRoute:e,subscribeClickNavigationRoute:n}=o.t(),r=o.r(),a=i.o((0,u.useShallow)(e=>e.automation?.queue.actions??V)),d=i.o(e=>e.automation?.queue.currentIndex??0),f=i.o(e=>e.interaction.mouse.target),p=i.o(e=>e.interaction.mouse.isActive),{position:m}=y({updateInterval:H,reactive:!1}),[h,g]=(0,c.useState)(()=>[...e()]),_=(0,c.useRef)(null),v=(0,c.useRef)([]);(0,c.useEffect)(()=>{let t=()=>g([...e()]);return t(),n(t)},[e,n]);let b=(0,c.useMemo)(()=>a.map(e=>e.type===`move`&&e.target?new s.Vector3(e.target.x,e.target.y,e.target.z):null).filter(e=>e!==null),[a]),x=(0,c.useMemo)(()=>[m,...h.length>0?h:[f],...b],[m,h,f,b]),S=(0,c.useMemo)(()=>b.length>0?[m,...b]:[],[m,b]);return t.t(`lateUpdate`,()=>{let t=e(),n=t[t.length-1]??f,i=p&&Math.hypot(n.x-m.x,n.z-m.z)>=U,a=_.current;a&&(a.visible=i,i&&a.position.set(n.x,r.sampleHeight(n.x,n.z),n.z)),v.current=i?x:S},{label:`interactions:clicker`}),(0,l.jsxs)(`group`,{children:[(0,l.jsx)(`group`,{ref:_,visible:!1,children:(0,l.jsx)(B,{})}),(0,l.jsx)(z,{pointsRef:v,color:d>=0?`#00ff88`:`#ffaa00`}),a.map((e,t)=>{if(e.type===`move`&&e.target){let n=t===d,r=t<d;return(0,l.jsx)(`group`,{position:[e.target.x,e.target.y,e.target.z],children:(0,l.jsxs)(`mesh`,{children:[(0,l.jsx)(`sphereGeometry`,{args:[.1,8,8]}),(0,l.jsx)(`meshStandardMaterial`,{color:r?`#888`:n?`#ff4444`:`#ffaa00`,transparent:!0,opacity:r?.3:.8})]})},`action-${t}`)}return null})]})}var G=4;function K({clickerOptions:e}){let t=i.s(),{onClick:n}=r.t(e);return(0,l.jsxs)(`mesh`,{position:[0,0,0],rotation:[-Math.PI/2,0,0],onClick:e=>{if(e.nativeEvent.button!==0||e.delta>G||e.nativeEvent.altKey||e.nativeEvent.ctrlKey||e.nativeEvent.metaKey||e.nativeEvent.shiftKey)return;e.stopPropagation();let{cameraOption:r,setCameraOption:i}=t.getState();if(r?.focus){i({focus:!1});return}n(e)},visible:!0,userData:{intangible:!0},children:[(0,l.jsx)(`planeGeometry`,{args:[1e3,1e3]}),(0,l.jsx)(`meshBasicMaterial`,{transparent:!0,opacity:0,depthWrite:!1,colorWrite:!1})]})}function q({props:e,children:t}){let n=i.o(e=>e.mode),{gameStates:o}=r.Y(),s=i.o(e=>e.rideable),u=i.o(e=>e.urls),f=r.Ut(e=>e.isInEditMode()),p=a.t();N(!0,!0,void 0,e.enableKeyboard??!0);let m=o?.currentRideable?.id,h=(0,c.useMemo)(()=>(m?s?.[m]?.offset:void 0)??(0,d.vec3)(),[m,s]);if(f||!n||!o||!s||!u||n.type===`character`&&!u.characterUrl||n.type===`vehicle`&&!u.vehicleUrl||n.type===`airplane`&&!u.airplaneUrl)return null;let{canRide:g,isRiding:_}=o,v=(()=>{let{enableKeyboard:t,rigidBodyRef:r=p.rigidBodyRef,outerGroupRef:i=p.outerGroupRef,innerGroupRef:a=p.innerGroupRef,colliderRef:o=p.colliderRef,parts:s,baseColor:c,excludeBaseNodes:l,...d}=e,f={...d,isActive:!0,componentType:n.type,enableRiding:g,isRiderOn:_,offset:h,ref:r,outerGroupRef:i,innerGroupRef:a,colliderRef:o,parts:(s||[]).filter(e=>!!e.url).map(e=>({...e,url:e.url})),...typeof c==`string`&&c.trim().length>0?{baseColor:c}:{},...Array.isArray(l)&&l.length>0?{excludeBaseNodes:l}:{}},m=_&&n.type!==`character`?u.ridingUrl:void 0,v=typeof m==`string`&&m.length>0?{ridingUrl:m}:{};switch(n.type){case`character`:return{...f,url:u.characterUrl||``};case`vehicle`:return{...f,...v,url:u.vehicleUrl||``};case`airplane`:return{...f,...v,url:u.airplaneUrl||``};default:return{...f,url:u.characterUrl||``}}})();return n.type===`character`&&o.isRiding?null:(0,l.jsx)(r.n,{...v,children:t})}function J(e){let{clickToMove:t,children:n,clickerOptions:r,...i}=e,a={...r??{},...r?.agentRadius===void 0&&i.colliderSize?.radius!==void 0?{agentRadius:i.colliderSize.radius}:{}};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(q,{props:i,children:(0,l.jsxs)(l.Fragment,{children:[t&&(0,l.jsx)(K,{clickerOptions:a}),n]})}),t&&(0,l.jsx)(W,{})]})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return b}});
@@ -1 +1 @@
1
- const e=require("./useClicker-0Ln5ZSz0.cjs"),t=require("./CoreBridge-CnLqWZNv.cjs"),n=require("./defaults-BLDQhn77.cjs"),r=require("./ControllerWrapper-WJUu-I7W.cjs");let i=require("react"),a=require("react/jsx-runtime");function o({value:t,name:n,gamePadButtonStyle:r,onInput:o}){let s=e.mr(),[c,l]=(0,i.useState)(!1),u=(0,i.useRef)(!1),d=(0,i.useRef)(o);d.current=o;let f=()=>{s.isEnabled()&&(s.activate(),!u.current&&o(t,!0)&&(u.current=!0,l(!0)))},p=()=>{u.current&&(o(t,!1),u.current=!1,l(!1))};return(0,i.useEffect)(()=>()=>{u.current&&d.current(t,!1),u.current=!1},[t]),(0,i.useEffect)(()=>c?s.onBlur(()=>{u.current&&d.current(t,!1),u.current=!1,l(!1)}):void 0,[c,t,s]),(0,a.jsx)(`button`,{type:`button`,className:`pad-button ${c?`is-clicked`:``}`,"aria-pressed":c,onBlur:p,onContextMenu:e=>{e.preventDefault(),p()},onPointerDown:f,onPointerUp:p,onPointerLeave:p,onPointerCancel:p,onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),f())},onKeyUp:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),p())},style:r,children:n})}var s={on:!0},c={forward:`앞으로`,backward:`뒤로`,leftward:`왼쪽`,rightward:`오른쪽`,shift:`달리기`,space:`점프`,escape:`취소`,keyZ:`동작 Z`,keyR:`동작 R`,keyF:`동작 F`,keyE:`동작 E`};function l(e){let{gamePadStyle:i,gamePadButtonStyle:s,label:l}=e,u=t.o(e=>e.interaction?.keyboard),d=t.o(e=>e.mode),{pushKey:f}=r.a(!0,!0,void 0,d?.controller===`gamepad`,!1);return d?.controller===`gamepad`?(0,a.jsx)(n.a,{className:`gamepad-container`,style:{...i,display:`flex`},children:Object.keys(u??{}).map(e=>(0,a.jsx)(o,{value:e,name:l?.[e]??c[e]??e,onInput:f,gamePadButtonStyle:s},e))}):null}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
1
+ const e=require("./useClicker-0Ln5ZSz0.cjs"),t=require("./CoreBridge-CnLqWZNv.cjs"),n=require("./defaults-BLDQhn77.cjs"),r=require("./ControllerWrapper-C6mzwejv.cjs");let i=require("react"),a=require("react/jsx-runtime");function o({value:t,name:n,gamePadButtonStyle:r,onInput:o}){let s=e.mr(),[c,l]=(0,i.useState)(!1),u=(0,i.useRef)(!1),d=(0,i.useRef)(o);d.current=o;let f=()=>{s.isEnabled()&&(s.activate(),!u.current&&o(t,!0)&&(u.current=!0,l(!0)))},p=()=>{u.current&&(o(t,!1),u.current=!1,l(!1))};return(0,i.useEffect)(()=>()=>{u.current&&d.current(t,!1),u.current=!1},[t]),(0,i.useEffect)(()=>c?s.onBlur(()=>{u.current&&d.current(t,!1),u.current=!1,l(!1)}):void 0,[c,t,s]),(0,a.jsx)(`button`,{type:`button`,className:`pad-button ${c?`is-clicked`:``}`,"aria-pressed":c,onBlur:p,onContextMenu:e=>{e.preventDefault(),p()},onPointerDown:f,onPointerUp:p,onPointerLeave:p,onPointerCancel:p,onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),f())},onKeyUp:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),e.stopPropagation(),p())},style:r,children:n})}var s={on:!0},c={forward:`앞으로`,backward:`뒤로`,leftward:`왼쪽`,rightward:`오른쪽`,shift:`달리기`,space:`점프`,escape:`취소`,keyZ:`동작 Z`,keyR:`동작 R`,keyF:`동작 F`,keyE:`동작 E`};function l(e){let{gamePadStyle:i,gamePadButtonStyle:s,label:l}=e,u=t.o(e=>e.interaction?.keyboard),d=t.o(e=>e.mode),{pushKey:f}=r.a(!0,!0,void 0,d?.controller===`gamepad`,!1);return d?.controller===`gamepad`?(0,a.jsx)(n.a,{className:`gamepad-container`,style:{...i,display:`flex`},children:Object.keys(u??{}).map(e=>(0,a.jsx)(o,{value:e,name:l?.[e]??c[e]??e,onInput:f,gamePadButtonStyle:s},e))}):null}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
@@ -1,7 +1,7 @@
1
1
  import { mr as e } from "./useClicker-DZrb1I0b.js";
2
2
  import { o as t } from "./CoreBridge-DdJBUxmY.js";
3
3
  import { a as n } from "./defaults-jVT3EUVe.js";
4
- import { a as r } from "./ControllerWrapper-jGqlqLgR.js";
4
+ import { a as r } from "./ControllerWrapper-Bc_pRQSv.js";
5
5
  import { useEffect as i, useRef as a, useState as o } from "react";
6
6
  import { jsx as s } from "react/jsx-runtime";
7
7
  //#region src/core/interactions/components/Gamepad/GamePadButton.tsx
@@ -1 +1 @@
1
- const e=require("./plugin-epk5BZCz.cjs");let t=require("react"),n=require("react/jsx-runtime");function r({materialRef:r,texture:i,alphaMap:a,toon:o,tipColor:s,bottomColor:c}){let l=(0,t.useMemo)(()=>new e.k(i,a),[i,a]);return(0,t.useLayoutEffect)(()=>{l.uniforms.uToon.value=+!!o,l.uniforms.tipColor.value.copy(s),l.uniforms.bottomColor.value.copy(c)},[l,o,s,c]),(0,t.useEffect)(()=>()=>l.dispose(),[l]),(0,n.jsx)(`primitive`,{object:l,ref:r,attach:`material`})}exports.default=r;
1
+ const e=require("./plugin-BUKo4q0N.cjs");let t=require("react"),n=require("react/jsx-runtime");function r({materialRef:r,texture:i,alphaMap:a,toon:o,tipColor:s,bottomColor:c}){let l=(0,t.useMemo)(()=>new e.k(i,a),[i,a]);return(0,t.useLayoutEffect)(()=>{l.uniforms.uToon.value=+!!o,l.uniforms.tipColor.value.copy(s),l.uniforms.bottomColor.value.copy(c)},[l,o,s,c]),(0,t.useEffect)(()=>()=>l.dispose(),[l]),(0,n.jsx)(`primitive`,{object:l,ref:r,attach:`material`})}exports.default=r;
@@ -1,4 +1,4 @@
1
- import { k as e } from "./plugin-KFnkRLsd.js";
1
+ import { k as e } from "./plugin-Dsf9EwPP.js";
2
2
  import { useEffect as t, useLayoutEffect as n, useMemo as r } from "react";
3
3
  import { jsx as i } from "react/jsx-runtime";
4
4
  //#region src/core/building/components/mesh/grass/NodeGrassMaterial.tsx
@@ -1,5 +1,5 @@
1
1
  import { br as e } from "./useClicker-DZrb1I0b.js";
2
- import { F as t, N as n, P as r } from "./plugin-KFnkRLsd.js";
2
+ import { F as t, N as n, P as r } from "./plugin-Dsf9EwPP.js";
3
3
  import { useEffect as i, useMemo as a } from "react";
4
4
  import { jsx as o } from "react/jsx-runtime";
5
5
  import { attribute as s, cameraPosition as c, color as l, cos as u, dot as d, max as f, mix as p, modelWorldMatrix as m, normalMap as h, normalView as g, normalize as _, positionGeometry as v, positionWorld as y, pow as b, sin as x, smoothstep as S, texture as C, uniform as w, vec2 as T, vec3 as E, vec4 as D } from "three/tsl";
@@ -1 +1 @@
1
- const e=require("./useClicker-0Ln5ZSz0.cjs"),t=require("./plugin-epk5BZCz.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("three/tsl"),a=require("three/webgpu");var o=(e,[t,n])=>(0,i.smoothstep)(t,n,e);function s(e=t.N(),{toon:n=!0,field:r=null,open:s=!1,lod:c}={}){let l=(0,i.uniform)(0),u=(0,i.uniform)(1),d=(0,i.uniform)(1).onRenderUpdate(()=>c?.detailed===!1?0:1),f=r?{texture:r.texture,transform:(0,i.uniform)(r.transform)}:null,p=e=>f?(0,i.texture)(f.texture,e.sub(f.transform.xy).mul(f.transform.zw)).r:(0,i.attribute)(`waterCoverage`,`float`),m=i.positionGeometry,h=i.modelWorldMatrix.mul((0,i.vec4)(m,1)).xz,g=(0,i.sin)(h.x.mul(.55).add(l.mul(.85))).mul(.045).add((0,i.sin)(h.y.mul(.78).sub(l.mul(1.05)).add(h.x.mul(.33))).mul(.025)).add((0,i.sin)(h.x.add(h.y).mul(1.4).add(l.mul(1.6))).mul(.012)),_=(0,i.vec3)(m.x,m.y,m.z.add(g.mul((0,i.smoothstep)(.7,.9,p(h))).mul(d))),v=i.positionWorld.xz,y=p(v),b=y.add((0,i.sin)(v.x.mul(.9).add((0,i.sin)(v.y.mul(.63)).mul(1.4))).mul((0,i.cos)(v.y.mul(.77).sub(v.x.mul(.21)))).mul(t.F.wobble)),x=(0,i.texture)(e,v.mul(.055).add((0,i.vec2)(l.mul(.009),l.mul(.004)))),S=(0,i.texture)(e,v.mul(.12).add((0,i.vec2)(l.mul(-.006),l.mul(.008)))),C=o(b,t.F.water),[w,T,E,D]=t.F.foam,O=(0,i.sin)(v.x.mul(.7).add(v.y.mul(.5)).sub(l.mul(.55))).mul(.5).add(.5),k=o(b,[w,T]).mul(o(b,[E,D]).oneMinus()).mul(O.mul(d).mul(.45).add(.55)),A=(0,i.mix)((0,i.color)(t.P.bank),(0,i.color)(t.P.wet),o(b,t.F.wet)),j=(0,i.mix)((0,i.color)(t.P.shallow),(0,i.color)(t.P.deep),o(y,t.F.depth)),M;if(n){M=new a.MeshBasicNodeMaterial;let e=(0,i.vec2)(x.x.add(S.x).sub(1),x.y.add(S.y).sub(1)).mul(d.mul(.7)),n=(0,i.normalize)((0,i.vec3)(e.x,1,e.y)),r=(0,i.normalize)(i.cameraPosition.sub(i.positionWorld)),o=(0,i.pow)((0,i.max)((0,i.dot)(n,r),0).oneMinus(),3),s=(0,i.pow)((0,i.max)((0,i.dot)(n,(0,i.normalize)(r.add((0,i.vec3)(-.5,.9,-.3).normalize()))),0),96).mul(d);j=(0,i.mix)(j,(0,i.color)(t.P.sky),o.mul(.5)).add(s.mul(.35))}else{let e=new a.MeshStandardNodeMaterial({metalness:0}),t=(0,i.normalMap)(x.rgb.add(S.rgb).mul(.5),(0,i.vec2)(.35,.35));e.normalNode=(0,i.normalize)((0,i.mix)(i.normalView,t,C.mul(d))),e.roughnessNode=(0,i.mix)(.95,.14,C),M=e}return M.positionNode=_,M.colorNode=(0,i.mix)(A,(0,i.mix)(j,(0,i.color)(t.P.foam),k.mul(.8)),C).mul(u),s||(M.transparent=!0,M.depthWrite=!1,M.opacityNode=o(b,t.F.edge)),{material:M,time:l,brightness:u}}var c={phase:`effects`,label:`building:water-node`};function l({normalMap:t,brightness:i=1,toon:a,field:o,open:l,lod:u}){let{material:d,time:f,brightness:p}=(0,n.useMemo)(()=>s(t,{toon:a,field:o,open:l,lod:u}),[t,a,o,l,u]);return(0,n.useEffect)(()=>{p.value=i},[p,i]),e.br(c,(e,t)=>{f.value=t}),(0,n.useEffect)(()=>()=>d.dispose(),[d]),(0,r.jsx)(`primitive`,{object:d,attach:`material`})}exports.default=l;
1
+ const e=require("./useClicker-0Ln5ZSz0.cjs"),t=require("./plugin-BUKo4q0N.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("three/tsl"),a=require("three/webgpu");var o=(e,[t,n])=>(0,i.smoothstep)(t,n,e);function s(e=t.N(),{toon:n=!0,field:r=null,open:s=!1,lod:c}={}){let l=(0,i.uniform)(0),u=(0,i.uniform)(1),d=(0,i.uniform)(1).onRenderUpdate(()=>c?.detailed===!1?0:1),f=r?{texture:r.texture,transform:(0,i.uniform)(r.transform)}:null,p=e=>f?(0,i.texture)(f.texture,e.sub(f.transform.xy).mul(f.transform.zw)).r:(0,i.attribute)(`waterCoverage`,`float`),m=i.positionGeometry,h=i.modelWorldMatrix.mul((0,i.vec4)(m,1)).xz,g=(0,i.sin)(h.x.mul(.55).add(l.mul(.85))).mul(.045).add((0,i.sin)(h.y.mul(.78).sub(l.mul(1.05)).add(h.x.mul(.33))).mul(.025)).add((0,i.sin)(h.x.add(h.y).mul(1.4).add(l.mul(1.6))).mul(.012)),_=(0,i.vec3)(m.x,m.y,m.z.add(g.mul((0,i.smoothstep)(.7,.9,p(h))).mul(d))),v=i.positionWorld.xz,y=p(v),b=y.add((0,i.sin)(v.x.mul(.9).add((0,i.sin)(v.y.mul(.63)).mul(1.4))).mul((0,i.cos)(v.y.mul(.77).sub(v.x.mul(.21)))).mul(t.F.wobble)),x=(0,i.texture)(e,v.mul(.055).add((0,i.vec2)(l.mul(.009),l.mul(.004)))),S=(0,i.texture)(e,v.mul(.12).add((0,i.vec2)(l.mul(-.006),l.mul(.008)))),C=o(b,t.F.water),[w,T,E,D]=t.F.foam,O=(0,i.sin)(v.x.mul(.7).add(v.y.mul(.5)).sub(l.mul(.55))).mul(.5).add(.5),k=o(b,[w,T]).mul(o(b,[E,D]).oneMinus()).mul(O.mul(d).mul(.45).add(.55)),A=(0,i.mix)((0,i.color)(t.P.bank),(0,i.color)(t.P.wet),o(b,t.F.wet)),j=(0,i.mix)((0,i.color)(t.P.shallow),(0,i.color)(t.P.deep),o(y,t.F.depth)),M;if(n){M=new a.MeshBasicNodeMaterial;let e=(0,i.vec2)(x.x.add(S.x).sub(1),x.y.add(S.y).sub(1)).mul(d.mul(.7)),n=(0,i.normalize)((0,i.vec3)(e.x,1,e.y)),r=(0,i.normalize)(i.cameraPosition.sub(i.positionWorld)),o=(0,i.pow)((0,i.max)((0,i.dot)(n,r),0).oneMinus(),3),s=(0,i.pow)((0,i.max)((0,i.dot)(n,(0,i.normalize)(r.add((0,i.vec3)(-.5,.9,-.3).normalize()))),0),96).mul(d);j=(0,i.mix)(j,(0,i.color)(t.P.sky),o.mul(.5)).add(s.mul(.35))}else{let e=new a.MeshStandardNodeMaterial({metalness:0}),t=(0,i.normalMap)(x.rgb.add(S.rgb).mul(.5),(0,i.vec2)(.35,.35));e.normalNode=(0,i.normalize)((0,i.mix)(i.normalView,t,C.mul(d))),e.roughnessNode=(0,i.mix)(.95,.14,C),M=e}return M.positionNode=_,M.colorNode=(0,i.mix)(A,(0,i.mix)(j,(0,i.color)(t.P.foam),k.mul(.8)),C).mul(u),s||(M.transparent=!0,M.depthWrite=!1,M.opacityNode=o(b,t.F.edge)),{material:M,time:l,brightness:u}}var c={phase:`effects`,label:`building:water-node`};function l({normalMap:t,brightness:i=1,toon:a,field:o,open:l,lod:u}){let{material:d,time:f,brightness:p}=(0,n.useMemo)(()=>s(t,{toon:a,field:o,open:l,lod:u}),[t,a,o,l,u]);return(0,n.useEffect)(()=>{p.value=i},[p,i]),e.br(c,(e,t)=>{f.value=t}),(0,n.useEffect)(()=>()=>d.dispose(),[d]),(0,r.jsx)(`primitive`,{object:d,attach:`material`})}exports.default=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("./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-D8axfJ-5.cjs"),te=require("./useNavigation-D-c4u9T4.cjs"),ne=require("./runtimeFilter-5rYxTYwr.cjs"),re=require("./WorldContainer-DI4x1VGT.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-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}});
@@ -15,10 +15,10 @@ import { i as Ae, l as je, m as Me, u as Ne } from "./clientServices-BKUcxr74.js
15
15
  import { r as x } from "./guards-DxYgyyOk.js";
16
16
  import { t as Pe } from "./areas-B291gcn8.js";
17
17
  import { r as Fe, t as Ie } from "./engine-GWafBTCd.js";
18
- import { b as Le, t as S, x as C } from "./useGenericRefs-8NKwNG7N.js";
18
+ import { b as Le, t as S, x as C } from "./useGenericRefs-D0cOKidj.js";
19
19
  import { a as Re, c as ze, d as Be } from "./useNavigation-B-QniiTX.js";
20
20
  import { d as Ve, l as He, t as Ue } from "./runtimeFilter-hxjkt1oY.js";
21
- import { a as We } from "./WorldContainer-B5bM3fwx.js";
21
+ import { a as We } from "./WorldContainer-Ce5PVxSF.js";
22
22
  import { n as Ge } from "./timeStore-Ck5CxJuk.js";
23
23
  import { t as Ke } from "./WorldBridge-m64VREYb.js";
24
24
  import { r as qe } from "./snapshot-CS3Z5hN5.js";
@@ -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-CueqwH91.cjs"),a=require("./CoreBridge-CnLqWZNv.cjs"),o=require("./useGenericRefs-D8axfJ-5.cjs"),s=require("./timeStore-Be94nnui.cjs"),c=require("./sceneCompile-CZwYKosw.cjs"),l=require("./quality-KkwsHdju.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.h(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.h(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-2fSaVGEL.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.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
+ 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-CueqwH91.cjs"),a=require("./CoreBridge-CnLqWZNv.cjs"),o=require("./useGenericRefs-CZ_HIQG_.cjs"),s=require("./timeStore-Be94nnui.cjs"),c=require("./sceneCompile-D9xft0op.cjs"),l=require("./quality-0VukPLnv.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.h(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.h(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-C80qMk1k.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.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}});
@@ -3,10 +3,10 @@ import { r } from "./logger-CIvdj60w.js";
3
3
  import { t as i } from "./runtimeContext-IAbUva69.js";
4
4
  import { n as a } from "./WorldPhysics-oZdWret8.js";
5
5
  import { o, r as s, s as c, w as l } from "./CoreBridge-DdJBUxmY.js";
6
- import { n as u } from "./useGenericRefs-8NKwNG7N.js";
6
+ import { n as u } from "./useGenericRefs-D0cOKidj.js";
7
7
  import { t as d } from "./timeStore-Ck5CxJuk.js";
8
- import { h as f } from "./sceneCompile-CHRGwswb.js";
9
- import { i as p, n as m, u as h } from "./quality-BgplnaOO.js";
8
+ import { h as f } from "./sceneCompile-BWpSal9S.js";
9
+ import { i as p, n as m, u as h } from "./quality-BLE1xXFm.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-C1uP1gjh.js").then((e) => e.n).then((e) => ({ default: e.WorldPostProcessing }))), K = [
154
+ var G = v(() => import("./WorldPostProcessing-Dfq_RW-t.js").then((e) => e.n).then((e) => ({ default: e.WorldPostProcessing }))), K = [
155
155
  "characterUrl",
156
156
  "vehicleUrl",
157
157
  "airplaneUrl",
@@ -1 +1 @@
1
- const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./logger-B9OaKOPw.cjs"),n=require("./sceneCompile-CZwYKosw.cjs"),r=require("./outline-DX9TqHot.cjs"),i=require("./renderHistory-BLXmtD6m.cjs");let a=require("three"),o=require("react"),s=require("@react-three/fiber"),c=require("react/jsx-runtime");var l=e.t({WorldPostProcessing:()=>d});function u({quality:e=`balanced`,antialias:r=e===`performance`?`none`:`traa`,ambientOcclusion:c=e!==`performance`,aoRadius:l=2,aoSamples:u=e===`quality`?16:8,aoResolutionScale:d=e===`quality`?1:.5,historyVersion:f=0,bloomStrength:p=.18,bloomRadius:m=.4,bloomThreshold:h=1,saturation:g=1.08}){let _=(0,s.useThree)(e=>e.gl),v=(0,s.useThree)(e=>e.scene),y=(0,s.useThree)(e=>e.camera),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)({position:new a.Vector3,quaternion:new a.Quaternion,projection:new a.Matrix4,revision:-1,initialized:!1}),C=(0,o.useRef)(new a.Matrix4),w=(0,o.useRef)(new a.Matrix4),T=(0,o.useRef)({bloomStrength:p,bloomRadius:m,bloomThreshold:h,saturation:g,aoRadius:l,aoSamples:u,aoResolutionScale:d}),E=(0,o.useRef)(null);return(0,o.useEffect)(()=>{x.current?.setSize(1,1),S.current.initialized=!1},[f]),(0,o.useEffect)(()=>{T.current={bloomStrength:p,bloomRadius:m,bloomThreshold:h,saturation:g,aoRadius:l,aoSamples:u,aoResolutionScale:d},E.current?.()},[p,m,h,g,l,u,d]),(0,o.useEffect)(()=>{let e=!1,i;return Promise.all([import(`three/webgpu`),import(`three/tsl`),import(`three/addons/tsl/display/BloomNode.js`),r===`traa`?import(`three/addons/tsl/display/TRAANode.js`):null,c?import(`three/addons/tsl/display/GTAONode.js`):null]).then(([t,a,o,s,l])=>{if(e)return;let u=a.pass(v,y),d,f,p,m,h=[];i=()=>{b.current===f&&(n.c(_,null),b.current=null,E.current=null,x.current=null);try{f?.dispose()}finally{try{d?.dispose()}finally{try{p?.dispose()}finally{try{m?.dispose()}finally{for(let e of h)e.dispose();u.dispose()}}}}};try{(r===`traa`||c)&&(u.setMRT(a.mrt({output:a.output,...r===`traa`?{velocity:a.velocity}:{},...c?{normal:a.normalView}:{}})),u.options.samples=0);let g=u.getTextureNode(`output`);if(s){p=s.traa(g,u.getTextureNode(`depth`),u.getTextureNode(`velocity`),y);let e=p._previousDepthNode?.value;e&&h.push(e),g=p.getTextureNode()}let S=g.rgb;if(l){m=l.ao(u.getTextureNode(`depth`),u.getTextureNode(`normal`),y);let e=m._noiseNode?.value;e&&h.push(e),S=S.mul(m.getTextureNode().r)}if(e){i?.(),i=void 0;return}let C=T.current;d=o.bloom(g,C.bloomStrength,C.bloomRadius,C.bloomThreshold);let w=a.uniform(C.saturation),D=d;f=new t.RenderPipeline(_),f.outputNode=a.vec4(a.saturation(S.add(d.rgb),w),g.a),n.c(_,{renderTarget:u.renderTarget,mrt:u.getMRT(),depth:1});let O=f,k=n.r(_,v,y);k?k.catch(()=>void 0).then(()=>{e||(b.current=O)}):b.current=f,x.current=p??null,E.current=()=>{let e=T.current;D.strength.value=e.bloomStrength,D.radius.value=e.bloomRadius,D.threshold.value=e.bloomThreshold,w.value=e.saturation,m&&(m.radius.value=Math.max(.01,e.aoRadius),m.samples.value=Math.max(1,Math.round(e.aoSamples)),m.resolutionScale=Math.min(1,Math.max(.25,e.aoResolutionScale)))},E.current()}catch(e){let t=i;throw i=void 0,t?.(),e}}).catch(e=>{t.t.error(`WebGPU postprocessing initialization failed`,e instanceof Error?e:String(e))}),()=>{e=!0,i?.()}},[_,v,y,r,c]),(0,s.useFrame)(()=>{let e=S.current,t=i.t(v);if(e.initialized&&(e.revision!==t||e.position.distanceToSquared(y.position)>25||Math.abs(e.quaternion.dot(y.quaternion))<.8||!e.projection.equals(y.projectionMatrix))&&x.current?.setSize(1,1),e.position.copy(y.position),e.quaternion.copy(y.quaternion),e.projection.copy(y.projectionMatrix),e.revision=t,e.initialized=!0,b.current){C.current.copy(y.projectionMatrix),w.current.copy(y.projectionMatrixInverse);let e=`view`in y&&y.view?{...y.view}:null;try{b.current.render()}finally{y.projectionMatrix.copy(C.current),y.projectionMatrixInverse.copy(w.current),`view`in y&&(y.view=e)}}else _.render(v,y)},1),null}function d(e={}){return(0,s.useThree)(e=>n.h(e.gl)!==`webgl`)?(0,c.jsx)(u,{...e}):(0,c.jsx)(r.n,{edgeStrength:4,extraEffects:(0,c.jsx)(r.r,{intensity:.8}),children:(0,c.jsx)(`group`,{})})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
1
+ const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./logger-B9OaKOPw.cjs"),n=require("./sceneCompile-D9xft0op.cjs"),r=require("./outline-DX9TqHot.cjs"),i=require("./renderHistory-BLXmtD6m.cjs");let a=require("three"),o=require("react"),s=require("@react-three/fiber"),c=require("react/jsx-runtime");var l=e.t({WorldPostProcessing:()=>d});function u({quality:e=`balanced`,antialias:r=e===`performance`?`none`:`traa`,ambientOcclusion:c=e!==`performance`,aoRadius:l=2,aoSamples:u=e===`quality`?16:8,aoResolutionScale:d=e===`quality`?1:.5,historyVersion:f=0,bloomStrength:p=.18,bloomRadius:m=.4,bloomThreshold:h=1,saturation:g=1.08}){let _=(0,s.useThree)(e=>e.gl),v=(0,s.useThree)(e=>e.scene),y=(0,s.useThree)(e=>e.camera),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)({position:new a.Vector3,quaternion:new a.Quaternion,projection:new a.Matrix4,revision:-1,initialized:!1}),C=(0,o.useRef)(new a.Matrix4),w=(0,o.useRef)(new a.Matrix4),T=(0,o.useRef)({bloomStrength:p,bloomRadius:m,bloomThreshold:h,saturation:g,aoRadius:l,aoSamples:u,aoResolutionScale:d}),E=(0,o.useRef)(null);return(0,o.useEffect)(()=>{x.current?.setSize(1,1),S.current.initialized=!1},[f]),(0,o.useEffect)(()=>{T.current={bloomStrength:p,bloomRadius:m,bloomThreshold:h,saturation:g,aoRadius:l,aoSamples:u,aoResolutionScale:d},E.current?.()},[p,m,h,g,l,u,d]),(0,o.useEffect)(()=>{let e=!1,i;return Promise.all([import(`three/webgpu`),import(`three/tsl`),import(`three/addons/tsl/display/BloomNode.js`),r===`traa`?import(`three/addons/tsl/display/TRAANode.js`):null,c?import(`three/addons/tsl/display/GTAONode.js`):null]).then(([t,a,o,s,l])=>{if(e)return;let u=a.pass(v,y),d,f,p,m,h=[];i=()=>{b.current===f&&(n.c(_,null),b.current=null,E.current=null,x.current=null);try{f?.dispose()}finally{try{d?.dispose()}finally{try{p?.dispose()}finally{try{m?.dispose()}finally{for(let e of h)e.dispose();u.dispose()}}}}};try{(r===`traa`||c)&&(u.setMRT(a.mrt({output:a.output,...r===`traa`?{velocity:a.velocity}:{},...c?{normal:a.normalView}:{}})),u.options.samples=0);let g=u.getTextureNode(`output`);if(s){p=s.traa(g,u.getTextureNode(`depth`),u.getTextureNode(`velocity`),y);let e=p._previousDepthNode?.value;e&&h.push(e),g=p.getTextureNode()}let S=g.rgb;if(l){m=l.ao(u.getTextureNode(`depth`),u.getTextureNode(`normal`),y);let e=m._noiseNode?.value;e&&h.push(e),S=S.mul(m.getTextureNode().r)}if(e){i?.(),i=void 0;return}let C=T.current;d=o.bloom(g,C.bloomStrength,C.bloomRadius,C.bloomThreshold);let w=a.uniform(C.saturation),D=d;f=new t.RenderPipeline(_),f.outputNode=a.vec4(a.saturation(S.add(d.rgb),w),g.a),n.c(_,{renderTarget:u.renderTarget,mrt:u.getMRT()});let O=f,k=n.r(_,v,y);k?k.catch(()=>void 0).then(()=>{e||(b.current=O)}):b.current=f,x.current=p??null,E.current=()=>{let e=T.current;D.strength.value=e.bloomStrength,D.radius.value=e.bloomRadius,D.threshold.value=e.bloomThreshold,w.value=e.saturation,m&&(m.radius.value=Math.max(.01,e.aoRadius),m.samples.value=Math.max(1,Math.round(e.aoSamples)),m.resolutionScale=Math.min(1,Math.max(.25,e.aoResolutionScale)))},E.current()}catch(e){let t=i;throw i=void 0,t?.(),e}}).catch(e=>{t.t.error(`WebGPU postprocessing initialization failed`,e instanceof Error?e:String(e))}),()=>{e=!0,i?.()}},[_,v,y,r,c]),(0,s.useFrame)(()=>{let e=S.current,t=i.t(v);if(e.initialized&&(e.revision!==t||e.position.distanceToSquared(y.position)>25||Math.abs(e.quaternion.dot(y.quaternion))<.8||!e.projection.equals(y.projectionMatrix))&&x.current?.setSize(1,1),e.position.copy(y.position),e.quaternion.copy(y.quaternion),e.projection.copy(y.projectionMatrix),e.revision=t,e.initialized=!0,b.current){C.current.copy(y.projectionMatrix),w.current.copy(y.projectionMatrixInverse);let e=`view`in y&&y.view?{...y.view}:null;try{b.current.render()}finally{y.projectionMatrix.copy(C.current),y.projectionMatrixInverse.copy(w.current),`view`in y&&(y.view=e)}}else _.render(v,y)},1),null}function d(e={}){return(0,s.useThree)(e=>n.h(e.gl)!==`webgl`)?(0,c.jsx)(u,{...e}):(0,c.jsx)(r.n,{edgeStrength:4,extraEffects:(0,c.jsx)(r.r,{intensity:.8}),children:(0,c.jsx)(`group`,{})})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./logger-CIvdj60w.js";
2
- import { c as t, h as n, r } from "./sceneCompile-CHRGwswb.js";
2
+ import { c as t, h as n, r } from "./sceneCompile-BWpSal9S.js";
3
3
  import { n as i, r as a } from "./outline-CsIagFrc.js";
4
4
  import { t as o } from "./renderHistory-DVcwcyBy.js";
5
5
  import { Matrix4 as s, Quaternion as c, Vector3 as l } from "three";
@@ -110,8 +110,7 @@ function _({ quality: n = "balanced", antialias: i = n === "performance" ? "none
110
110
  let b = s.uniform(y.saturation), x = f;
111
111
  p = new e.RenderPipeline(S), p.outputNode = s.vec4(s.saturation(v.add(f.rgb), b), _.a), t(S, {
112
112
  renderTarget: d.renderTarget,
113
- mrt: d.getMRT(),
114
- depth: 1
113
+ mrt: d.getMRT()
115
114
  });
116
115
  let D = p, O = r(S, C, w);
117
116
  O ? O.catch(() => void 0).then(() => {