gaesup-world 1.3.0 → 1.3.2

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.
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-Chgba0Kb.cjs"),t=require("./useEngineFrame-ujTlLQfa.cjs"),n=require("./AnimationSystem-CHlx6FwX.cjs"),r=require("./logger-B9OaKOPw.cjs"),i=require("./runtimeContext-zx_GnKx4.cjs"),a=require("./scopedStore-Px5jL718.cjs"),o=require("./assetStore-DbqlOBWB.cjs"),s=require("./reportError-CkJ7vZsX.cjs"),c=require("./WorldPhysics-CueqwH91.cjs"),l=require("./useClicker-0Ln5ZSz0.cjs"),u=require("./CoreBridge-CnLqWZNv.cjs"),d=require("./id-DWiNl1ym.cjs"),f=require("./defaults-BLDQhn77.cjs"),p=require("./WorldProps-L3Izutxz.cjs"),m=require("./SaveSystem-DwfckGGo.cjs"),h=require("./clientServices-Bs-PZVqS.cjs"),g=require("./AssetPreviewCanvas-C0cInsac.cjs"),_=require("./plugin-BUKo4q0N.cjs"),v=require("./templates-D2DtrEv3.cjs"),y=require("./loader-shJVRMj9.cjs");let b=require("react");b=e.n(b,1);let x=require("zustand"),S=require("@react-three/fiber"),C=require("react/jsx-runtime"),w=require("zustand/react/shallow"),T=require("@react-three/drei");var E=`editor.panel`;function D(e){if(!e||typeof e!=`object`)return!1;let t=e;if(t.kind!==`editor.panel`||!t.panel||typeof t.panel!=`object`)return!1;let n=t.panel;return typeof n.id==`string`&&typeof n.title==`string`&&`component`in n}function O(e){return e.flatMap(e=>{if(!D(e.value))return[];let t=e.value.panel,n=t.pluginId??e.pluginId;return n===void 0?[t]:[{...t,pluginId:n}]})}function k(e={}){let t=e.state??(e.dirty?`dirty`:`clean`);return{state:t,dirty:e.dirty??t===`dirty`,autosaveEnabled:e.autosaveEnabled??!0,...e.autosaveIntervalMs===void 0?{}:{autosaveIntervalMs:e.autosaveIntervalMs},...e.lastChangedAt===void 0?{}:{lastChangedAt:e.lastChangedAt},...e.lastSavedAt===void 0?{}:{lastSavedAt:e.lastSavedAt},...e.nextAutosaveAt===void 0?{}:{nextAutosaveAt:e.nextAutosaveAt},...e.message===void 0?{}:{message:e.message},...e.error===void 0?{}:{error:e.error}}}function A(e,t=Date.now()){let n=P(e,t),r={...e};return delete r.error,{...r,state:`dirty`,dirty:!0,lastChangedAt:t,message:`저장하지 않은 변경 사항`,...n===void 0?{}:{nextAutosaveAt:n}}}function j(e){let t={...e};return delete t.error,{...t,state:`saving`,dirty:!0,message:`저장 중`}}function M(e,t=Date.now()){let n={...e};return delete n.nextAutosaveAt,delete n.error,{...n,state:`saved`,dirty:!1,lastSavedAt:t,message:`저장 완료`}}function N(e,t){return{...e,state:`error`,dirty:!0,message:`저장 실패`,error:t}}function P(e,t=Date.now()){if(e.autosaveEnabled)return t+(e.autosaveIntervalMs??3e4)}function F(e,t=Date.now()){return!!(e.autosaveEnabled&&e.dirty&&e.state!==`saving`&&e.nextAutosaveAt!==void 0&&e.nextAutosaveAt<=t)}function I(e,t=Date.now()){return e.state===`saving`?`저장 중`:e.state===`error`?e.error?`저장 실패: ${e.error}`:`저장 실패`:e.dirty?e.autosaveEnabled&&e.nextAutosaveAt?`저장 대기 · ${L(Math.max(0,e.nextAutosaveAt-t))} 후 자동 저장`:`저장하지 않은 변경 사항`:e.lastSavedAt?`${L(t-e.lastSavedAt)} 전 저장됨`:e.state===`saved`?`저장 완료`:`변경 사항 없음`}function L(e){let t=Math.max(0,Math.ceil(e/1e3));return t<60?`${t}초`:`${Math.ceil(t/60)}분`}function R({status:e,onAutosave:t,enabled:n=!0}){(0,b.useEffect)(()=>{if(!n||!e||!t||!e.autosaveEnabled||!e.dirty||!e.nextAutosaveAt)return;let r=Math.max(0,e.nextAutosaveAt-Date.now()),i=window.setTimeout(()=>{F(e)&&Promise.resolve().then(t).catch(e=>s.r(e,{source:`save:editor-autosave`}))},r);return()=>window.clearTimeout(i)},[n,t,e])}var z={undo:{key:`z`,ctrl:!0,meta:!0},redo:{key:`z`,ctrl:!0,meta:!0,shift:!0},delete:{key:`Delete`},duplicate:{key:`d`,ctrl:!0,meta:!0},frameSelection:{key:`f`},play:{key:` `,code:`Space`}};function B(e=[],t={}){let n=new Map,r=new Map;return e.forEach(e=>n.set(e.id,e)),{register(e){let t=Symbol(e.id);return r.set(e.id,t),n.set(e.id,e),()=>{r.get(e.id)===t&&(r.delete(e.id),n.delete(e.id))}},unregister(e){r.delete(e),n.delete(e)},list(){return Array.from(n.values())},handleKeyDown(e){if(e.defaultPrevented||e.isComposing||H(e.target))return!1;let r=Array.from(n.values()).find(n=>!n.disabled&&V(e,n,t));return r?((r.preventDefault??!0)&&e.preventDefault(),r.run(e),!0):!1}}}function V(e,t,n={}){let r=te(e.key)===te(t.key),i=!!(t.code&&e.code===t.code);if(!r&&!i)return!1;let a=ne(n.platform);return(t.ctrl||t.meta?a===`mac`?e.metaKey||e.ctrlKey:e.ctrlKey||e.metaKey:!e.ctrlKey&&!e.metaKey)&&e.shiftKey===!!t.shift&&e.altKey===!!t.alt}function ee(e,t={}){let n=ne(t.platform),r=[];return(e.ctrl||e.meta)&&r.push(n===`mac`?`Cmd`:`Ctrl`),e.shift&&r.push(`Shift`),e.alt&&r.push(n===`mac`?`Opt`:`Alt`),r.push(e.key===` `?`Space`:e.key.length===1?e.key.toUpperCase():e.key),r.join(`+`)}function H(e){return!e||!(e instanceof HTMLElement)?!1:e.closest(`input, textarea, select, [contenteditable]:not([contenteditable="false"])`)!==null}function te(e){return e===`Spacebar`?` `:e.toLowerCase()}function ne(e){return e&&e!==`auto`?e:typeof navigator<`u`&&/mac|iphone|ipad|ipod/i.test(navigator.platform)?`mac`:typeof navigator<`u`&&/linux/i.test(navigator.platform)?`linux`:`windows`}function re(e,t={}){let n=l.mr(),{enabled:r=!0,target:i,registry:a}=t,o=(0,b.useMemo)(()=>a??B(),[a]);return(0,b.useEffect)(()=>{let t=e.map(e=>o.register(e));return()=>{t.forEach(e=>e())}},[e,o]),(0,b.useEffect)(()=>{if(!r)return;let e=i??(typeof window<`u`?window:void 0);if(!e)return;let t=e=>{n.acceptsKeyboard(e)&&o.handleKeyDown(e)};if(!i||i===window||i===document)return n.listen(`keydown`,t);let a=i instanceof HTMLElement?n.registerSurface(i):void 0;return e.addEventListener(`keydown`,t),()=>{e.removeEventListener(`keydown`,t),a?.()}},[r,o,i,n]),o}function ie({open:e,items:t,placeholder:n=`명령 검색`,onClose:r}){let[i,a]=(0,b.useState)(``),o=(0,b.useRef)(null),s=(0,b.useMemo)(()=>ae(t,i),[t,i]);if((0,b.useEffect)(()=>{if(!e)return;a(``);let t=window.setTimeout(()=>o.current?.focus(),0);return()=>window.clearTimeout(t)},[e]),!e)return null;let c=e=>{e.disabled||(e.run(),r())};return(0,C.jsxs)(`div`,{className:`editor-command-palette`,role:`dialog`,"aria-label":`명령 목록`,children:[(0,C.jsxs)(`div`,{className:`editor-command-palette__surface`,children:[(0,C.jsx)(`input`,{ref:o,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Escape`&&r(),e.key===`Enter`&&s[0]&&c(s[0])},placeholder:n,"aria-label":`명령 검색`}),(0,C.jsx)(`div`,{className:`editor-command-palette__list`,children:s.length===0?(0,C.jsx)(`div`,{className:`editor-command-palette__empty`,children:`검색된 명령이 없습니다`}):s.map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`editor-command-palette__item`,onClick:()=>c(e),disabled:e.disabled,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`strong`,{children:e.label}),e.detail?(0,C.jsx)(`em`,{children:e.detail}):null]}),(0,C.jsxs)(`span`,{children:[e.group?(0,C.jsx)(`small`,{children:e.group}):null,e.shortcut?(0,C.jsx)(`kbd`,{children:e.shortcut}):null]})]},e.id))})]}),(0,C.jsx)(`button`,{type:`button`,className:`editor-command-palette__backdrop`,onClick:r,"aria-label":`명령 검색 닫기`})]})}function ae(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.id.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||e.group?.toLowerCase().includes(n)||e.detail?.toLowerCase().includes(n)):e}var oe=-50,se=50,ce=0,le=80,ue=30,de=120,fe=5,pe=.01,me=1,he=.01,ge=1e-4,_e=.01,ve=1e-4,ye=.1,be=2,xe=1,U=5,W=.1,Se=1,Ce=50,we=5,Te=-10,Ee=100,De=1,Oe={modePrefix:`모드`,fallbackMode:`3인칭`,enabled:`켜짐`,disabled:`꺼짐`},ke={root:`camera-settings-tab`,mode:`camera-settings-tab-mode`,section:`camera-settings-tab-section`,sectionTitle:`camera-settings-tab-section-title`,field:`camera-settings-tab-field`,fieldLabel:`camera-settings-tab-field-label`,fieldControl:`camera-settings-tab-field-control`,rangeInput:`camera-settings-tab-range`,checkboxInput:`camera-settings-tab-checkbox`,fieldValue:`camera-settings-tab-field-value`},Ae=[{key:`distance`,title:`거리`,fields:[{key:`xDistance`,label:`X`,kind:`range`,path:`xDistance`,min:oe,max:se,step:De,defaultValue:0},{key:`yDistance`,label:`Y`,kind:`range`,path:`yDistance`,min:ce,max:le,step:De,defaultValue:0},{key:`zDistance`,label:`Z`,kind:`range`,path:`zDistance`,min:oe,max:se,step:De,defaultValue:0}]},{key:`fov`,title:`시야각·부드러움`,fields:[{key:`fov`,label:`시야각`,kind:`range`,path:`fov`,min:ue,max:de,step:fe,suffix:`도`,defaultValue:75},{key:`smoothingPosition`,label:`위치`,kind:`range`,path:`smoothing.position`,min:pe,max:me,step:he,defaultValue:.1},{key:`smoothingRotation`,label:`회전`,kind:`range`,path:`smoothing.rotation`,min:pe,max:me,step:he,defaultValue:.1},{key:`smoothingFov`,label:`시야각 보간`,kind:`range`,path:`smoothing.fov`,min:pe,max:me,step:he,defaultValue:.2}]},{key:`zoom`,title:`확대`,fields:[{key:`enableZoom`,label:`확대 허용`,kind:`checkbox`,path:`enableZoom`,defaultValue:!1},{key:`zoomSpeed`,label:`속도`,kind:`range`,path:`zoomSpeed`,min:ge,max:_e,step:ve,defaultValue:.001},{key:`minZoom`,label:`최소`,kind:`range`,path:`minZoom`,min:ye,max:be,step:W,defaultValue:.5},{key:`maxZoom`,label:`최대`,kind:`range`,path:`maxZoom`,min:xe,max:U,step:W,defaultValue:2}]},{key:`options`,title:`옵션`,fields:[{key:`enableCollision`,label:`충돌`,kind:`checkbox`,path:`enableCollision`,defaultValue:!1},{key:`enableFocus`,label:`초점 모드`,kind:`checkbox`,path:`enableFocus`,defaultValue:!1},{key:`focusDistance`,label:`초점 거리`,kind:`range`,path:`focusDistance`,min:Se,max:Ce,step:De,defaultValue:15}]},{key:`bounds`,title:`이동 범위`,fields:[{key:`boundsMinY`,label:`최소 높이`,kind:`range`,path:`bounds.minY`,min:Te,max:Ce,step:De,defaultValue:2},{key:`boundsMaxY`,label:`최대 높이`,kind:`range`,path:`bounds.maxY`,min:we,max:Ee,step:De,defaultValue:50}]}];function je(...e){return e.filter(e=>!!e).join(` `)}function G(e){return typeof e==`number`?e:Number(e)}function Me(e){return typeof e==`boolean`?e:!!e}function Ne(e){return{...Oe,...e}}function Pe(e,t,n){return{...n,...e?.[t]}}function Fe(e){return e.filter(e=>e.visible!==!1).map(e=>({...e,fields:e.fields.filter(e=>e.visible!==!1)})).filter(e=>e.fields.length>0)}function Ie(e,t){if(t.getValue)return t.getValue(e);switch(t.path){case`xDistance`:return e.xDistance??t.defaultValue;case`yDistance`:return e.yDistance??t.defaultValue;case`zDistance`:return e.zDistance??t.defaultValue;case`fov`:return e.fov??t.defaultValue;case`enableZoom`:return e.enableZoom??t.defaultValue;case`zoomSpeed`:return e.zoomSpeed??t.defaultValue;case`minZoom`:return e.minZoom??t.defaultValue;case`maxZoom`:return e.maxZoom??t.defaultValue;case`enableCollision`:return e.enableCollision??t.defaultValue;case`enableFocus`:return e.enableFocus??t.defaultValue;case`focusDistance`:return e.focusDistance??t.defaultValue;case`smoothing.position`:return e.smoothing?.position??t.defaultValue;case`smoothing.rotation`:return e.smoothing?.rotation??t.defaultValue;case`smoothing.fov`:return e.smoothing?.fov??t.defaultValue;case`bounds.minY`:return e.bounds?.minY??t.defaultValue;case`bounds.maxY`:return e.bounds?.maxY??t.defaultValue;default:return t.defaultValue}}function Le(e,t,n){if(t.createUpdate)return t.createUpdate(e,n);switch(t.path){case`xDistance`:return{xDistance:G(n)};case`yDistance`:return{yDistance:G(n)};case`zDistance`:return{zDistance:G(n)};case`fov`:return{fov:G(n)};case`enableZoom`:return{enableZoom:Me(n)};case`zoomSpeed`:return{zoomSpeed:G(n)};case`minZoom`:return{minZoom:G(n)};case`maxZoom`:return{maxZoom:G(n)};case`enableCollision`:return{enableCollision:Me(n)};case`enableFocus`:return{enableFocus:Me(n)};case`focusDistance`:return{focusDistance:G(n)};case`smoothing.position`:return{smoothing:{...e.smoothing,position:G(n)}};case`smoothing.rotation`:return{smoothing:{...e.smoothing,rotation:G(n)}};case`smoothing.fov`:return{smoothing:{...e.smoothing,fov:G(n)}};case`bounds.minY`:return{bounds:{...e.bounds,minY:G(n)}};case`bounds.maxY`:return{bounds:{...e.bounds,maxY:G(n)}};default:return{}}}function Re(e,t,n){if(e.kind===`checkbox`)return Me(t)?n.enabled:n.disabled;let r=G(t);return`${e.step!==void 0&&e.step<1?r.toFixed(2):String(r)}${e.suffix??``}`}function ze(e,t,n){if(t?.field)return t.field(e,n);let r=n.kind===`checkbox`?(0,C.jsx)(`input`,{"aria-label":n.label,className:e.classNameFor(`checkboxInput`),checked:Me(n.value),disabled:n.disabled,onChange:t=>e.actions.updateField(n,t.target.checked),style:e.styleFor(`checkboxInput`),type:`checkbox`}):(0,C.jsx)(`input`,{"aria-label":n.label,className:e.classNameFor(`rangeInput`),disabled:n.disabled,max:n.max,min:n.min,onChange:t=>e.actions.updateField(n,Number(t.target.value)),step:n.step,style:e.styleFor(`rangeInput`),type:`range`,value:G(n.value)});return(0,C.jsxs)(`div`,{className:e.classNameFor(`field`),style:e.styleFor(`field`),children:[(0,C.jsx)(`span`,{className:e.classNameFor(`fieldLabel`),style:e.styleFor(`fieldLabel`),children:n.label}),(0,C.jsx)(`span`,{className:e.classNameFor(`fieldControl`),style:e.styleFor(`fieldControl`),children:r}),(0,C.jsx)(`span`,{className:e.classNameFor(`fieldValue`),style:e.styleFor(`fieldValue`),children:n.formattedValue})]},n.key)}function Be(e,t,n){let r=n.fields.map(n=>ze(e,t,n));return t?.section?t.section(e,n,r):(0,C.jsxs)(`section`,{className:e.classNameFor(`section`),style:e.styleFor(`section`),children:[(0,C.jsx)(`h3`,{className:e.classNameFor(`sectionTitle`),style:e.styleFor(`sectionTitle`),children:n.title}),r]},n.key)}function Ve(e,t){if(!e.showMode)return null;if(t?.mode)return t.mode(e);let n=e.mode.control,r=f.r.find(e=>e.value===n)?.label??n??e.labels.fallbackMode;return(0,C.jsxs)(`div`,{className:e.classNameFor(`mode`),style:e.styleFor(`mode`),children:[e.labels.modePrefix,`: `,r]})}function He(e,t,n){return(0,C.jsxs)(C.Fragment,{children:[Ve(e,t),e.sections.map(n=>Be(e,t,n)),n]})}function Ue({cameraOption:e,mode:t,sections:n=Ae,showMode:r=!0,className:i,style:a,classNames:o,styles:s,labels:c,renderers:l,formatValue:d,onCameraOptionChange:f,children:p}={}){let m=u.o(e=>e.cameraOption),h=u.o(e=>e.mode),g=u.o(e=>e.setCameraOption),_=e??m,v=t??h,y=(0,b.useMemo)(()=>Ne(c),[c]),x=(0,b.useCallback)((e,t)=>{let n=Le(_,e,t);if(f){f(n,e,t);return}g(n)},[f,_,g]),S=(0,b.useMemo)(()=>Fe(n).map(e=>({...e,fields:e.fields.map(e=>{let t=Ie(_,e);return{...e,value:t,formattedValue:d?.(e,t,y)??Re(e,t,y)}})})),[d,y,_,n]),w=(0,b.useCallback)((e,t)=>je(ke[e],o?.[e],e===`root`&&i,t),[i,o]),T=(0,b.useCallback)((e,t)=>{let n=Pe(s,e,t);return e===`root`?{...n,...a}:n},[a,s]),E=(0,b.useMemo)(()=>({cameraOption:_,mode:v,labels:y,sections:S,showMode:r,classNameFor:w,styleFor:T,actions:{updateField:x}}),[w,x,y,_,v,S,r,T]),D=He(E,l,p);return l?.root?(0,C.jsx)(C.Fragment,{children:l.root(E,D)}):(0,C.jsx)(`div`,{className:E.classNameFor(`root`),style:E.styleFor(`root`),children:D})}function We(...e){return e.filter(e=>!!e).join(` `)}function Ge(e){return{...f.n,...e}}function Ke(e,t,n){return{...n,...e?.[t]}}function qe(e,t){return e.showTitle?t?.header?t.header(e):(0,C.jsx)(`div`,{className:e.classNameFor(`header`),style:e.styleFor(`header`),children:(0,C.jsx)(`span`,{className:e.classNameFor(`title`),style:e.styleFor(`title`),children:e.labels.title})}):null}function Je(e,t,n){let r=e.activeMode===n.value;return t?.modeButton?(0,C.jsx)(b.Fragment,{children:t.modeButton(e,n,r)},n.value):(0,C.jsxs)(`button`,{type:`button`,className:We(e.classNameFor(`modeButton`),r&&e.classNameFor(`activeModeButton`)),style:r?e.styleFor(`activeModeButton`,e.styleFor(`modeButton`)):e.styleFor(`modeButton`),onClick:()=>e.actions.selectMode(n.value),"aria-pressed":r,children:[n.icon&&(0,C.jsx)(`span`,{className:e.classNameFor(`modeIcon`),style:e.styleFor(`modeIcon`),children:n.icon}),e.showLabels&&(0,C.jsx)(`span`,{className:e.classNameFor(`modeLabel`),style:e.styleFor(`modeLabel`),children:n.label})]},n.value)}function Ye(e,t){let n=e.modes.map(n=>Je(e,t,n));return t?.list?t.list(e,n):(0,C.jsx)(`div`,{className:e.classNameFor(`list`),style:e.styleFor(`list`),children:n})}function Xe(e,t,n){return(0,C.jsxs)(C.Fragment,{children:[qe(e,t),Ye(e,t),n]})}function Ze({position:e,showLabels:t=!0,showTitle:n=!1,compact:r=!1,modes:i=f.r,className:a,style:o,classNames:s,styles:c,labels:l,renderers:d,onModeChange:p,children:m}={}){let{mode:h,setCameraOption:g,setMode:_}=u.o((0,w.useShallow)(e=>({mode:e.mode,setCameraOption:e.setCameraOption,setMode:e.setMode}))),v=h?.control||`thirdPerson`,y=(0,b.useMemo)(()=>Ge(l),[l]),x=(0,b.useCallback)(e=>{_({control:e}),g(f.i[e]),p?.(e)},[p,g,_]),S=(0,b.useCallback)((t,n)=>We(f.t[t],s?.[t],t===`root`&&e&&`camera-controller-panel--${e}`,t===`root`&&e&&f.t.floatingRoot,t===`root`&&r&&f.t.compactRoot,t===`root`&&a,n),[a,s,r,e]),T=(0,b.useCallback)((e,t)=>{let n=Ke(c,e,t);return e===`root`?{...n,...o}:n},[o,c]),E=(0,b.useMemo)(()=>({activeMode:v,modes:i,labels:y,showLabels:t,showTitle:n,compact:r,position:e,classNameFor:S,styleFor:T,actions:{selectMode:x}}),[v,S,r,y,i,e,x,t,n,T]),D=Xe(E,d,m);return d?.root?(0,C.jsx)(C.Fragment,{children:d.root(E,D)}):(0,C.jsx)(`div`,{className:E.classNameFor(`root`),style:E.styleFor(`root`),children:D})}var Qe=100,$e=2,et={empty:`표시할 진단 항목이 없습니다`,unavailable:`정보 없음`},tt=[{key:`mode`,label:`모드`,enabled:!0,format:`text`},{key:`position`,label:`조작 대상 위치`,enabled:!0,format:`vector3`,precision:2},{key:`distance`,label:`거리 설정`,enabled:!0,format:`vector3`,precision:2},{key:`fov`,label:`시야각 설정`,enabled:!0,format:`angle`,precision:1},{key:`velocity`,label:`조작 대상 속도`,enabled:!1,format:`vector3`,precision:2},{key:`rotation`,label:`조작 대상 회전`,enabled:!1,format:`vector3`,precision:2},{key:`zoom`,label:`확대`,enabled:!1,format:`number`,precision:2}],nt={root:`camera-debug-panel`,floatingRoot:`camera-debug-panel--floating`,compactRoot:`camera-debug-panel--compact`,grid:`camera-debug-panel-grid`,item:`camera-debug-panel-item`,label:`camera-debug-panel-label`,value:`camera-debug-panel-value`,empty:`camera-debug-panel-empty`};function rt(e=Date.now()){return{frameCount:0,averageFrameTime:0,lastUpdateTime:e,mode:`unknown`,distance:null,fov:0,position:null,targetPosition:null,velocity:null,rotation:null}}function it(...e){return e.filter(e=>!!e).join(` `)}function at(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.x==`number`&&typeof t.y==`number`&&typeof t.z==`number`}function ot(e){return at(e)?{x:e.x,y:e.y,z:e.z}:null}function st(e,t){return e===t?!1:at(e)?!at(t)||e.x!==t.x||e.y!==t.y||e.z!==t.z:typeof e!=`object`||!e||JSON.stringify(e)!==JSON.stringify(t)}function ct(e,t=2,n=et.unavailable){return e==null?n:at(e)?`X:${e.x.toFixed(t)} Y:${e.y.toFixed(t)} Z:${e.z.toFixed(t)}`:typeof e==`number`?e.toFixed(t):e.toString()}function lt(e,t){if(t in e)return e[t]}function ut(e){return{...et,...e}}function dt(e,t,n){return{...n,...e?.[t]}}function ft(e,t){return[...e.filter(e=>e.enabled),...t??[]]}function pt(e,t,n){return t?.field?(0,C.jsx)(b.Fragment,{children:t.field(e,n)},n.key):(0,C.jsxs)(`div`,{className:e.classNameFor(`item`),style:e.styleFor(`item`),children:[(0,C.jsx)(`span`,{className:e.classNameFor(`label`),style:e.styleFor(`label`),children:n.label}),(0,C.jsx)(`span`,{className:e.classNameFor(`value`),style:e.styleFor(`value`),children:n.formattedValue})]},n.key)}function mt(e,t){return t?.empty?t.empty(e):(0,C.jsx)(`div`,{className:e.classNameFor(`empty`),style:e.styleFor(`empty`),children:e.labels.empty})}function ht(e,t){let n=e.fields.length>0?e.fields.map(n=>pt(e,t,n)):mt(e,t);return t?.grid?t.grid(e,n):(0,C.jsx)(`div`,{className:e.classNameFor(`grid`),style:e.styleFor(`grid`),children:n})}function gt(e,t,n){return(0,C.jsxs)(C.Fragment,{children:[ht(e,t),n]})}function _t({position:e,visible:t=!0,updateInterval:n=100,zIndex:r,compact:i=!1,theme:a=`dark`,fields:o=tt,precision:s=2,width:c,height:d,customFields:p,className:m,style:h,classNames:g,styles:_,labels:v,renderers:y,formatValue:x,children:S}={}){let w=(0,b.useMemo)(()=>rt(),[]),[T,E]=(0,b.useState)(w),D=u.o(e=>e.mode),O=u.o(e=>e.cameraOption),{activeState:k}=l.Y(),A=(0,b.useRef)(w),j=(0,b.useMemo)(()=>ut(v),[v]),M=(0,b.useCallback)(()=>{let e=O?.xDistance!==void 0&&O?.yDistance!==void 0&&O?.zDistance!==void 0?{x:O.xDistance,y:O.yDistance,z:O.zDistance}:null,t=Date.now(),n={...A.current,frameCount:A.current.frameCount+1,averageFrameTime:t-A.current.lastUpdateTime,mode:D?.control??`unknown`,distance:e,fov:O?.fov??0,position:ot(k?.position),targetPosition:ot(O?.focusTarget),velocity:ot(k?.velocity),rotation:ot(k?.euler),lastUpdateTime:t,...O?.zoom===void 0?{}:{zoom:O.zoom}};Object.keys(n).some(e=>st(n[e],A.current[e]))&&(A.current=n,E(n))},[k,O,D]);(0,b.useEffect)(()=>{if(!t)return;M();let e=setInterval(M,n);return()=>{clearInterval(e)}},[n,M,t]);let N=(0,b.useMemo)(()=>ft(o,p).map(e=>{let t=`getValue`in e?e.getValue():lt(T,e.key),n=e.precision??s,r=!(`getValue`in e)&&e.key===`mode`?f.r.find(e=>e.value===t)?.label??(t===`unknown`?j.unavailable:t):t,i=x?.(t,e,n)??ct(r,n,j.unavailable);return{key:e.key,label:e.label,value:t,formattedValue:i,...e.format?{format:e.format}:{}}}),[p,o,x,j.unavailable,T,s]),P=(0,b.useCallback)((t,n)=>it(nt[t],g?.[t],t===`root`&&e&&nt.floatingRoot,t===`root`&&e&&`camera-debug-panel--${e}`,t===`root`&&i&&nt.compactRoot,t===`root`&&a&&`camera-debug-panel--${a}`,t===`root`&&m,n),[m,g,i,e,a]),F=(0,b.useCallback)((e,t)=>{let n=dt(_,e,t);return e===`root`?{...n,width:c,height:d,zIndex:r,...h}:n},[d,h,_,c,r]),I=(0,b.useMemo)(()=>({metrics:T,fields:N,labels:j,visible:t,compact:i,theme:a,position:e,classNameFor:P,styleFor:F}),[P,i,j,T,e,N,F,a,t]);if(!t)return null;let L=gt(I,y,S);return y?.root?(0,C.jsx)(C.Fragment,{children:y.root(I,L)}):(0,C.jsx)(`div`,{className:I.classNameFor(`root`),style:I.styleFor(`root`),children:L})}var vt={position:.1,rotation:.1,fov:.1},yt=[{id:`classic`,name:`기본`,description:`일반적인 3인칭 시점입니다.`,config:{mode:`thirdPerson`,distance:{x:0,y:8,z:10},fov:75,smoothing:vt}},{id:`cinematic`,name:`영화처럼`,description:`영화처럼 부드럽게 움직이는 시점입니다.`,config:{mode:`chase`,distance:{x:2,y:7,z:8},fov:60,smoothing:{position:.05,rotation:.05,fov:.05}}},{id:`action`,name:`액션`,description:`빠른 움직임에 민첩하게 반응하는 시점입니다.`,config:{mode:`thirdPerson`,distance:{x:0,y:6,z:6},fov:85,smoothing:{position:.2,rotation:.2,fov:.2}}},{id:`strategy`,name:`전략`,description:`위에서 공간 전체를 살펴보는 시점입니다.`,config:{mode:`topDown`,distance:{x:0,y:20,z:0},fov:45,smoothing:vt}},{id:`retro`,name:`복고풍`,description:`옆에서 바라보는 횡스크롤 시점입니다.`,config:{mode:`sideScroll`,distance:{x:15,y:0,z:0},fov:75,smoothing:{position:.15,rotation:.15,fov:.15}}}],bt={empty:`카메라 프리셋이 없습니다`},xt={root:`camera-presets-panel`,floatingRoot:`camera-presets-panel--floating`,grid:`camera-presets-panel-grid`,presetButton:`camera-presets-panel-preset`,activePresetButton:`camera-presets-panel-preset--active`,presetIcon:`camera-presets-panel-icon`,presetContent:`camera-presets-panel-content`,presetName:`camera-presets-panel-name`,presetDescription:`camera-presets-panel-description`,empty:`camera-presets-panel-empty`};function St(...e){return e.filter(e=>!!e).join(` `)}function Ct(e,t){return!e||!t?!1:e.x===t.x&&e.y===t.y&&e.z===t.z}function wt(e){let t=e?.xDistance,n=e?.yDistance,r=e?.zDistance;if(t!==void 0&&n!==void 0&&r!==void 0)return{x:t,y:n,z:r}}function Tt(e,t,n){return e.find(e=>e.config.mode===t&&Ct(e.config.distance,wt(n)))?.id??null}function Et(e){return{...bt,...e}}function Dt(e,t,n){return{...n,...e?.[t]}}function Ot(e,t,n){let r=e.currentPresetId===n.id;return t?.presetButton?(0,C.jsx)(b.Fragment,{children:t.presetButton(e,n,r)},n.id):(0,C.jsxs)(`button`,{type:`button`,className:St(e.classNameFor(`presetButton`),r&&e.classNameFor(`activePresetButton`)),style:r?e.styleFor(`activePresetButton`,e.styleFor(`presetButton`)):e.styleFor(`presetButton`),onClick:()=>e.actions.applyPreset(n),"aria-pressed":r,children:[n.icon&&(0,C.jsx)(`span`,{className:e.classNameFor(`presetIcon`),style:e.styleFor(`presetIcon`),children:n.icon}),(0,C.jsxs)(`span`,{className:e.classNameFor(`presetContent`),style:e.styleFor(`presetContent`),children:[(0,C.jsx)(`span`,{className:e.classNameFor(`presetName`),style:e.styleFor(`presetName`),children:n.name}),(0,C.jsx)(`span`,{className:e.classNameFor(`presetDescription`),style:e.styleFor(`presetDescription`),children:n.description})]})]},n.id)}function kt(e,t){return t?.empty?t.empty(e):(0,C.jsx)(`div`,{className:e.classNameFor(`empty`),style:e.styleFor(`empty`),children:e.labels.empty})}function At(e,t){let n=e.presets.length>0?e.presets.map(n=>Ot(e,t,n)):kt(e,t);return t?.grid?t.grid(e,n):(0,C.jsx)(`div`,{className:e.classNameFor(`grid`),style:e.styleFor(`grid`),children:n})}function jt(e,t,n){return(0,C.jsxs)(C.Fragment,{children:[At(e,t),n]})}function Mt({position:e,presets:t=yt,className:n,style:r,classNames:i,styles:a,labels:o,renderers:s,onApplyPreset:c,children:l}={}){let d=u.o(e=>e.setMode),f=u.o(e=>e.setCameraOption),p=u.o(e=>e.mode?.control),m=u.o(e=>e.cameraOption),h=(0,b.useMemo)(()=>Et(o),[o]),g=(0,b.useMemo)(()=>Tt(t,p,m),[m,p,t]),_=(0,b.useCallback)(e=>{d({control:e.config.mode}),f({xDistance:e.config.distance.x,yDistance:e.config.distance.y,zDistance:e.config.distance.z,fov:e.config.fov,smoothing:e.config.smoothing??vt}),c?.(e)},[c,f,d]),v=(0,b.useCallback)((t,r)=>St(xt[t],i?.[t],t===`root`&&e&&xt.floatingRoot,t===`root`&&e&&`camera-presets-panel--${e}`,t===`root`&&n,r),[n,i,e]),y=(0,b.useCallback)((e,t)=>{let n=Dt(a,e,t);return e===`root`?{...n,...r}:n},[r,a]),x=(0,b.useMemo)(()=>({presets:t,currentPresetId:g,mode:p,cameraOption:m,labels:h,position:e,classNameFor:v,styleFor:y,actions:{applyPreset:_}}),[_,m,v,g,h,p,e,t,y]),S=jt(x,s,l);return s?.root?(0,C.jsx)(C.Fragment,{children:s.root(x,S)}):(0,C.jsx)(`div`,{className:x.classNameFor(`root`),style:x.styleFor(`root`),children:S})}var Nt={Settings:`설정`,Controller:`조작`,Presets:`프리셋`,Debug:`진단`},Pt=[{id:`Settings`,label:Nt.Settings},{id:`Controller`,label:Nt.Controller},{id:`Presets`,label:Nt.Presets},{id:`Debug`,label:Nt.Debug}],Ft={root:`tabbed-panel camera-panel`,tabs:`panel-tabs camera-panel-tabs`,tab:`panel-tab camera-panel-tab`,activeTab:`active camera-panel-tab--active`,content:`panel-tab-content camera-panel-content`};function It(...e){return e.filter(e=>!!e).join(` `)}function Lt(e,t,n){return{...n,...e?.[t]}}function Rt(e,t){switch(e){case`Settings`:return(0,C.jsx)(Ue,{...t.settings});case`Controller`:return(0,C.jsx)(Ze,{...t.controller});case`Presets`:return(0,C.jsx)(Mt,{...t.presets});case`Debug`:return(0,C.jsx)(_t,{...t.debug});default:return null}}function zt({activeTab:e,defaultTab:t=`Settings`,tabs:n,labels:r,componentProps:i={},className:a,style:o,classNames:s,styles:c,renderers:l,onTabChange:u,children:d}={}){let[f,p]=(0,b.useState)(t),m=(0,b.useMemo)(()=>({...Nt,...r}),[r]),h=(0,b.useMemo)(()=>(n??Pt).map(e=>({...e,label:r?.[e.id]??e.label})),[r,n]),g=h.find(e=>!e.disabled)?.id??t,_=e??f,v=h.some(e=>e.id===_&&!e.disabled)?_:g,y=(0,b.useCallback)(t=>{e===void 0&&p(t),u?.(t)},[e,u]),x=(0,b.useCallback)((e,t)=>It(Ft[e],s?.[e],e===`root`&&a,t),[a,s]),S=(0,b.useCallback)((e,t)=>{let n=Lt(c,e,t);return e===`root`?{...n,...o}:n},[o,c]),w=(0,b.useMemo)(()=>({activeTab:v,tabs:h,labels:m,componentProps:i,classNameFor:x,styleFor:S,actions:{setActiveTab:y}}),[x,i,y,m,v,h,S]),T=e=>{let t=e.id===w.activeTab;return l?.tab?l.tab(w,e,t):(0,C.jsx)(`button`,{className:w.classNameFor(`tab`,t?w.classNameFor(`activeTab`):void 0),disabled:e.disabled,onClick:()=>w.actions.setActiveTab(e.id),style:w.styleFor(`tab`),type:`button`,children:e.label},e.id)},E=h.find(e=>e.id===w.activeTab)?.render?.(w)??Rt(w.activeTab,i),D=h.map(T),O=l?.tabs?l.tabs(w,D):(0,C.jsx)(`div`,{className:w.classNameFor(`tabs`),style:w.styleFor(`tabs`),children:D}),k=l?.content?l.content(w,(0,C.jsxs)(C.Fragment,{children:[E,d]})):(0,C.jsxs)(`div`,{className:w.classNameFor(`content`),style:w.styleFor(`content`),children:[E,d]}),A=(0,C.jsxs)(C.Fragment,{children:[O,k]});return l?.root?(0,C.jsx)(C.Fragment,{children:l.root(w,A)}):(0,C.jsx)(`div`,{className:w.classNameFor(`root`),style:w.styleFor(`root`),children:A})}var Bt=[{value:`idle`,label:`대기`},{value:`walk`,label:`걷기`},{value:`run`,label:`달리기`},{value:`jump`,label:`점프`},{value:`fall`,label:`낙하`},{value:`dance`,label:`춤`},{value:`wave`,label:`손 흔들기`}];function Vt(...e){return e.filter(e=>!!e).join(` `)}function Ht({position:e=`bottom-left`,showLabels:t=!0,compact:n=!1}={}){let{playAnimation:r,currentType:i,currentAnimation:a}=l.G(),o=e=>{r(i,e)};return(0,C.jsx)(`div`,{className:Vt(`ac-panel`,`ac-panel--${e}`,n&&`ac-panel--compact`),children:(0,C.jsx)(`div`,{className:`ac-grid`,children:Bt.map(e=>(0,C.jsx)(`button`,{className:`ac-button ${e.value===a?`active`:``}`,onClick:()=>o(e.value),title:e.label,children:t?e.label:e.label.slice(0,1)},e.value))})})}var Ut=[{key:`currentAnimation`,label:`현재 애니메이션`,format:`text`,enabled:!0},{key:`animationType`,label:`애니메이션 타입`,format:`text`,enabled:!0},{key:`isPlaying`,label:`재생 상태`,format:`text`,enabled:!0},{key:`weight`,label:`가중치`,format:`number`,enabled:!0},{key:`speed`,label:`속도`,format:`number`,enabled:!0},{key:`blendDuration`,label:`블렌드 시간`,format:`number`,enabled:!1},{key:`activeActions`,label:`활성 액션`,format:`number`,enabled:!0},{key:`availableAnimations`,label:`사용 가능 애니메이션`,format:`array`,enabled:!1},{key:`frameCount`,label:`프레임 카운트`,format:`number`,enabled:!1},{key:`averageFrameTime`,label:`평균 프레임 시간`,format:`number`,enabled:!1}],Wt=250;function Gt(...e){return e.filter(e=>!!e).join(` `)}function Kt({position:e=`top-right`,fields:t,customFields:n,precision:r=2,compact:i=!1}={}){let{bridge:a,currentType:o}=l.G(),s=[...t??Ut,...n??[]],[c,u]=(0,b.useState)({frameCount:0,averageFrameTime:0,lastUpdateTime:Date.now(),currentAnimation:`idle`,animationType:`character`,availableAnimations:[],isPlaying:!1,weight:1,speed:1,blendDuration:.3,activeActions:0});(0,b.useEffect)(()=>{if(!a)return;let e=()=>{let e=a.snapshot(o);e&&u(t=>({...t,currentAnimation:e.currentAnimation,animationType:o,availableAnimations:e.availableAnimations,isPlaying:e.isPlaying,weight:e.weight,speed:e.speed,activeActions:e.metrics.activeAnimations,lastUpdateTime:Date.now()}))};e();let t=!1,n=a.subscribe((e,n)=>{n===o&&(t=!0)}),r=window.setInterval(()=>{t&&(t=!1,e())},Wt);return()=>{window.clearInterval(r),n()}},[a,o]);let d=(e,t,n=r)=>{if(e==null)return`정보 없음`;if(typeof e==`boolean`)return e?`재생 중`:`정지`;switch(t){case`array`:return Array.isArray(e)?`${e.length}개`:String(e);case`number`:return typeof e==`number`?e.toFixed(n):String(e);default:return String(e)}},f=e=>{if(e!==`frameCount`&&e!==`averageFrameTime`&&e!==`blendDuration`){if(e===`animationType`)return c.animationType===`vehicle`?`차량`:c.animationType===`airplane`?`비행기`:`캐릭터`;if(e in c)return c[e]}};return(0,C.jsx)(`div`,{className:Gt(`ad-panel`,`ad-panel--${e}`,i&&`ad-panel--compact`),children:(0,C.jsx)(`div`,{className:`ad-content`,children:s.filter(e=>e.enabled).map(e=>(0,C.jsxs)(`div`,{className:`ad-item`,children:[(0,C.jsx)(`span`,{className:`ad-label`,children:e.label}),(0,C.jsx)(`span`,{className:`ad-value`,children:d(f(e.key),e.format)})]},e.key))})})}var qt=()=>(0,C.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,C.jsx)(`path`,{d:`M8 5v14l11-7z`})}),Jt=()=>(0,C.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,C.jsx)(`path`,{d:`M6 6h12v12H6z`})}),Yt=()=>(0,C.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,C.jsx)(`path`,{d:`M6 6h2v12H6zm3.5 6l8.5 6V6z`})}),Xt=()=>(0,C.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,C.jsx)(`path`,{d:`M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z`})});function Zt(...e){return e.filter(e=>!!e).join(` `)}function Qt({position:e=`bottom-left`,showControls:t=!0,compact:n=!1}={}){let{bridge:r,playAnimation:i,stopAnimation:a,currentType:o,currentAnimation:s}=l.G(),[c,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)([]),p=d.includes(s)?s:d[0]??``;(0,b.useEffect)(()=>{let e=()=>{let e=r?.snapshot(o);u(e?.isPlaying??!1),f(e?.availableAnimations??[])};if(e(),r)return r.subscribe((t,n)=>{n===o&&e()})},[r,o]);let m=()=>{c?a(o):p&&i(o,p)},h=e=>{if(!d.length)return;let t=d.indexOf(p),n=d[(t+e+d.length)%d.length];n&&i(o,n)};return(0,C.jsxs)(`div`,{className:Zt(`ap-panel`,`ap-panel--${e}`,n&&`ap-panel--compact`),children:[(0,C.jsxs)(`div`,{className:`ap-controls`,children:[(0,C.jsxs)(`select`,{"aria-label":`애니메이션 선택`,className:`ap-select`,value:p,disabled:!d.length,onChange:e=>i(o,e.target.value),children:[!d.length&&(0,C.jsx)(`option`,{value:``,children:`등록된 애니메이션 없음`}),d.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))]}),t&&(0,C.jsxs)(`div`,{className:`ap-buttons`,children:[(0,C.jsx)(`button`,{type:`button`,className:`ap-btn`,"aria-label":`이전 애니메이션`,disabled:d.length<2,onClick:()=>h(-1),children:(0,C.jsx)(Yt,{})}),(0,C.jsx)(`button`,{type:`button`,className:`ap-btn-primary`,onClick:m,disabled:!p&&!c,"aria-label":c?`애니메이션 정지`:`애니메이션 재생`,children:c?(0,C.jsx)(Jt,{}):(0,C.jsx)(qt,{})}),(0,C.jsx)(`button`,{type:`button`,className:`ap-btn`,"aria-label":`다음 애니메이션`,disabled:d.length<2,onClick:()=>h(1),children:(0,C.jsx)(Xt,{})})]})]}),!d.length&&(0,C.jsx)(`p`,{role:`status`,children:`재생할 애니메이션이 아직 등록되지 않았습니다.`})]})}var $t={Player:`재생`,Controller:`재생 설정`,Debug:`상태 진단`},en=[{id:`Player`,label:$t.Player},{id:`Controller`,label:$t.Controller},{id:`Debug`,label:$t.Debug}],tn={root:`tabbed-panel animation-panel`,tabs:`panel-tabs animation-panel-tabs`,tab:`panel-tab animation-panel-tab`,activeTab:`active animation-panel-tab--active`,content:`panel-tab-content animation-panel-content`,contentWrapper:`panel-content-wrapper animation-panel-content-wrapper`};function nn(...e){return e.filter(e=>!!e).join(` `)}function rn(e,t,n){return{...n,...e?.[t]}}function an(e){let{componentProps:t}=e;switch(e.activeTab){case`Player`:return(0,C.jsx)(Qt,{...t.player});case`Controller`:return(0,C.jsx)(Ht,{...t.controller});case`Debug`:return(0,C.jsx)(Kt,{...t.debug});default:return null}}function on({activeTab:e,defaultTab:t=`Player`,tabs:n,labels:r,componentProps:i={},className:a,style:o,classNames:s,styles:c,renderers:l,onTabChange:u,children:d}={}){let[f,p]=(0,b.useState)(t),m=(0,b.useMemo)(()=>({...$t,...r}),[r]),h=(0,b.useMemo)(()=>(n??en).map(e=>({...e,label:r?.[e.id]??e.label})),[r,n]),g=h.find(e=>!e.disabled)?.id??t,_=e??f,v=h.some(e=>e.id===_&&!e.disabled)?_:g,y=(0,b.useCallback)(t=>{e===void 0&&p(t),u?.(t)},[e,u]),x=(0,b.useCallback)((e,t)=>nn(tn[e],s?.[e],e===`root`&&a,t),[a,s]),S=(0,b.useCallback)((e,t)=>{let n=rn(c,e,t);return e===`root`?{...n,...o}:n},[o,c]),w=(0,b.useMemo)(()=>({activeTab:v,tabs:h,labels:m,componentProps:i,classNameFor:x,styleFor:S,actions:{setActiveTab:y}}),[x,i,y,m,v,h,S]),T=e=>{let t=e.id===w.activeTab;return l?.tab?l.tab(w,e,t):(0,C.jsx)(`button`,{className:w.classNameFor(`tab`,t?w.classNameFor(`activeTab`):void 0),disabled:e.disabled,onClick:()=>w.actions.setActiveTab(e.id),style:w.styleFor(`tab`),type:`button`,children:e.label},e.id)},E=h.find(e=>e.id===w.activeTab)?.render?.(w)??an(w),D=h.map(T),O=l?.tabs?l.tabs(w,D):(0,C.jsx)(`div`,{className:w.classNameFor(`tabs`),style:w.styleFor(`tabs`),children:D}),k=(0,C.jsx)(`div`,{className:w.classNameFor(`contentWrapper`),style:w.styleFor(`contentWrapper`),children:E}),A=(0,C.jsxs)(C.Fragment,{children:[k,d]}),j=l?.content?l.content(w,A):(0,C.jsx)(`div`,{className:w.classNameFor(`content`),style:w.styleFor(`content`),children:A}),M=(0,C.jsxs)(C.Fragment,{children:[O,j]});return l?.root?(0,C.jsx)(C.Fragment,{children:l.root(w,M)}):(0,C.jsx)(`div`,{className:w.classNameFor(`root`),style:w.styleFor(`root`),children:M})}var sn=[{id:`slow`,name:`느리게`,maxSpeed:5,acceleration:8},{id:`normal`,name:`보통`,maxSpeed:10,acceleration:15},{id:`fast`,name:`빠르게`,maxSpeed:20,acceleration:25},{id:`sprint`,name:`전력 질주`,maxSpeed:35,acceleration:40}],cn=[{id:`eco`,name:`절약`,maxSpeed:15,acceleration:10},{id:`comfort`,name:`편안하게`,maxSpeed:25,acceleration:20},{id:`sport`,name:`스포츠`,maxSpeed:40,acceleration:35},{id:`turbo`,name:`터보`,maxSpeed:60,acceleration:50}];function ln(e,t){let n=e??`bottom-left`,r={position:`fixed`,zIndex:t??1e4};return n.includes(`top`)&&(r.top=12),n.includes(`bottom`)&&(r.bottom=12),n.includes(`left`)&&(r.left=12),n.includes(`right`)&&(r.right=12),r}function un(e){let t=ln(e.position,e.zIndex),n=u.o(e=>e.mode.type),r=u.o(e=>e.setMode),i=u.o(e=>e.setPhysics),a=n===`vehicle`?`vehicle`:`character`,o=a===`vehicle`?cn:sn,[s,c]=(0,b.useState)(a===`vehicle`?`comfort`:`normal`),l=(0,b.useCallback)((e,t)=>{let n=(e===`vehicle`?cn:sn).find(e=>e.id===t);if(n){if(e===`vehicle`){i({maxSpeed:n.maxSpeed,accelRatio:n.acceleration});return}i({walkSpeed:Math.max(1,n.maxSpeed*.5),runSpeed:n.maxSpeed,accelRatio:n.acceleration})}},[i]),d=(0,b.useCallback)(t=>{c(t),l(a,t),e.onPresetChange?.(t)},[l,a,e]),f=(0,b.useCallback)(t=>{let n=t.target.value;r({type:n});let i=n===`vehicle`?`comfort`:`normal`;c(i),l(n,i),e.onPresetChange?.(i)},[l,r,e]);return(0,C.jsxs)(`div`,{className:`mc-panel ${e.compact?`compact`:``}`,style:t,children:[(0,C.jsxs)(`div`,{className:`mc-setting-row`,children:[(0,C.jsx)(`label`,{htmlFor:`motion-type-select`,className:`mc-label`,children:`이동 유형`}),(0,C.jsxs)(`select`,{id:`motion-type-select`,className:`mc-select`,value:a,onChange:f,children:[(0,C.jsx)(`option`,{value:`character`,children:`캐릭터`}),(0,C.jsx)(`option`,{value:`vehicle`,children:`차량`})]})]}),(0,C.jsxs)(`div`,{className:`mc-setting-row`,children:[(0,C.jsx)(`label`,{className:`mc-label`,children:`프리셋`}),(0,C.jsx)(`div`,{className:`mc-presets-grid`,children:o.map(e=>(0,C.jsx)(`button`,{type:`button`,"aria-pressed":e.id===s,className:`mc-preset-btn ${e.id===s?`active`:``}`,onClick:()=>d(e.id),title:`최대 속도: ${e.maxSpeed}, 가속: ${e.acceleration}`,children:e.name},e.id))})]})]})}var dn=[{key:`motionType`,label:`이동 유형`,type:`text`},{key:`position`,label:`위치`,type:`vector3`},{key:`velocity`,label:`속도 벡터`,type:`vector3`},{key:`speed`,label:`속력`,type:`number`},{key:`direction`,label:`방향`,type:`vector3`},{key:`isGrounded`,label:`지면 접촉`,type:`text`},{key:`isMoving`,label:`이동 중`,type:`text`},{key:`acceleration`,label:`가속도`,type:`number`},{key:`jumpForce`,label:`점프 힘`,type:`number`},{key:`maxSpeed`,label:`최대 속력`,type:`number`},{key:`totalDistance`,label:`총 이동 거리`,type:`number`},{key:`gameState`,label:`이동 상태`,type:`text`}];function fn(e,t){let n=e??`top-right`,r={position:`fixed`,zIndex:t??1e4};return n.includes(`top`)&&(r.top=12),n.includes(`bottom`)&&(r.bottom=12),n.includes(`left`)&&(r.left=12),n.includes(`right`)&&(r.right=12),r}function pn(e){let t=e.embedded?{}:fn(e.position,e.zIndex),n=u.o(e=>e.mode),r=u.o(e=>e.physics),{activeState:i,gameStates:a}=l.Y(),o=e.precision??2,s=e.customFields?[...dn,...e.customFields]:dn,c=(e,t,n=2)=>{if(t==null)return`정보 없음`;switch(e.type){case`vector3`:if(Array.isArray(t)&&t.length===3){let[e,r,i]=t;return`X:${e.toFixed(n)} Y:${r.toFixed(n)} Z:${i.toFixed(n)}`}if(typeof t==`object`&&t&&`x`in t&&`y`in t&&`z`in t){let e=t;return`X:${e.x.toFixed(n)} Y:${e.y.toFixed(n)} Z:${e.z.toFixed(n)}`}return String(t);case`number`:return typeof t==`number`?t.toFixed(n):String(t);default:return String(t)}},d=e=>{if(e.value!==void 0)return e.value;switch(e.key){case`motionType`:return n?.type===`vehicle`?`차량`:n?.type===`airplane`?`비행기`:`캐릭터`;case`position`:return i?.position?{x:i.position.x,y:i.position.y,z:i.position.z}:{x:0,y:0,z:0};case`velocity`:return i?.velocity?{x:i.velocity.x,y:i.velocity.y,z:i.velocity.z}:{x:0,y:0,z:0};case`speed`:return i?.velocity?i.velocity.length():0;case`direction`:return i?.direction?{x:i.direction.x,y:i.direction.y,z:i.direction.z}:{x:0,y:0,z:0};case`isGrounded`:return a?.isOnTheGround?`예`:`아니요`;case`isMoving`:return a?.isMoving?`예`:`아니요`;case`acceleration`:return r?.accelRatio??0;case`jumpForce`:return r?.jumpSpeed??0;case`maxSpeed`:return n?.type===`character`?r?.runSpeed??0:r?.maxSpeed??0;case`totalDistance`:return null;case`gameState`:return a?.isRiding?`탑승 중`:a?.isOnTheGround?`지상`:`공중`;default:return null}};return(0,C.jsx)(`div`,{className:`md-panel ${e.compact?`compact`:``} ${e.theme?`theme-${e.theme}`:``}`,style:t,children:(0,C.jsx)(`div`,{className:`md-content`,children:s.map(e=>(0,C.jsxs)(`div`,{className:`md-item`,children:[(0,C.jsx)(`span`,{className:`md-label`,children:e.label}),(0,C.jsx)(`span`,{className:`md-value`,children:c(e,d(e),o)})]},e.key))})})}var mn={Controller:`이동 설정`,Debug:`상태 진단`},hn=[{id:`Controller`,label:mn.Controller},{id:`Debug`,label:mn.Debug}],gn={root:`tabbed-panel motion-panel`,tabs:`panel-tabs motion-panel-tabs`,tab:`panel-tab motion-panel-tab`,activeTab:`active motion-panel-tab--active`,content:`panel-tab-content motion-panel-content`,contentWrapper:`panel-content-wrapper motion-panel-content-wrapper`};function _n(...e){return e.filter(e=>!!e).join(` `)}function vn(e,t,n){return{...n,...e?.[t]}}function yn(e){let{componentProps:t}=e;switch(e.activeTab){case`Controller`:return(0,C.jsx)(un,{...t.controller});case`Debug`:return(0,C.jsx)(pn,{embedded:!0,...t.debug});default:return null}}function bn({activeTab:e,defaultTab:t=`Controller`,tabs:n,labels:r,componentProps:i={},className:a,style:o,classNames:s,styles:c,renderers:l,onTabChange:u,children:d}={}){let[f,p]=(0,b.useState)(t),m=(0,b.useMemo)(()=>({...mn,...r}),[r]),h=(0,b.useMemo)(()=>(n??hn).map(e=>({...e,label:r?.[e.id]??e.label})),[r,n]),g=h.find(e=>!e.disabled)?.id??t,_=e??f,v=h.some(e=>e.id===_&&!e.disabled)?_:g,y=(0,b.useCallback)(t=>{e===void 0&&p(t),u?.(t)},[e,u]),x=(0,b.useCallback)((e,t)=>_n(gn[e],s?.[e],e===`root`&&a,t),[a,s]),S=(0,b.useCallback)((e,t)=>{let n=vn(c,e,t);return e===`root`?{...n,...o}:n},[o,c]),w=(0,b.useMemo)(()=>({activeTab:v,tabs:h,labels:m,componentProps:i,classNameFor:x,styleFor:S,actions:{setActiveTab:y}}),[x,i,y,m,v,h,S]),T=e=>{let t=e.id===w.activeTab;return l?.tab?l.tab(w,e,t):(0,C.jsx)(`button`,{className:w.classNameFor(`tab`,t?w.classNameFor(`activeTab`):void 0),disabled:e.disabled,onClick:()=>w.actions.setActiveTab(e.id),style:w.styleFor(`tab`),type:`button`,children:e.label},e.id)},E=h.find(e=>e.id===w.activeTab)?.render?.(w)??yn(w),D=h.map(T),O=l?.tabs?l.tabs(w,D):(0,C.jsx)(`div`,{className:w.classNameFor(`tabs`),style:w.styleFor(`tabs`),children:D}),k=(0,C.jsx)(`div`,{className:w.classNameFor(`contentWrapper`),style:w.styleFor(`contentWrapper`),children:E}),A=(0,C.jsxs)(C.Fragment,{children:[k,d]}),j=l?.content?l.content(w,A):(0,C.jsx)(`div`,{className:w.classNameFor(`content`),style:w.styleFor(`content`),children:A}),M=(0,C.jsxs)(C.Fragment,{children:[O,j]});return l?.root?(0,C.jsx)(C.Fragment,{children:l.root(w,M)}):(0,C.jsx)(`div`,{className:w.classNameFor(`root`),style:w.styleFor(`root`),children:M})}var xn={input:`입력`,script:`스크립트`,prePhysics:`물리 전`,postPhysics:`물리 후`,animation:`애니메이션`,lateUpdate:`후처리 갱신`,camera:`카메라`,effects:`이펙트`,snapshot:`스냅샷`};function Sn(){let e=u.o(e=>e.framePhases);if(!e)return null;let n=0;for(let r of t.g)n+=e[r];return(0,C.jsxs)(`div`,{className:`perf-stat-group`,children:[(0,C.jsxs)(`div`,{className:`perf-header`,children:[(0,C.jsx)(`h4`,{className:`perf-title`,children:`엔진 프레임 단계`}),(0,C.jsxs)(`span`,{className:`perf-current`,children:[n.toFixed(2),` ms`]})]}),(0,C.jsx)(`div`,{className:`perf-details-grid`,children:t.g.map(t=>(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:xn[t]}),e[t].toFixed(2)]},t))})]})}var Cn=60,wn=({data:e,color:t,max:n,warn:r})=>{let i=e.filter(e=>isFinite(e));if(i.length<2)return null;let a=Math.max(1,n),o=i.map((e,t)=>{let n=t/(i.length-1)*100,r=40-e/a*40;return`${t===0?`M`:`L`}${n.toFixed(2)},${r.toFixed(2)}`}).join(` `);return(0,C.jsx)(`div`,{className:`perf-chart`,children:(0,C.jsxs)(`svg`,{width:`100%`,height:40,preserveAspectRatio:`none`,viewBox:`0 0 100 40`,children:[r!==void 0&&(0,C.jsx)(`line`,{x1:`0`,y1:40-r/a*40,x2:`100`,y2:40-r/a*40,stroke:`#facc15`,strokeWidth:`0.5`,strokeDasharray:`3,3`,opacity:.5}),(0,C.jsx)(`path`,{d:o,fill:`none`,stroke:t,strokeWidth:`2`,strokeLinejoin:`round`,strokeLinecap:`round`})]})})},Tn=({value:e,max:t,color:n,label:r})=>{let i=t>0?Math.min(100,e/t*100):0;return(0,C.jsxs)(`div`,{style:{marginBottom:4},children:[(0,C.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:10,marginBottom:2},children:[(0,C.jsx)(`span`,{className:`perf-label`,children:r}),(0,C.jsx)(`span`,{children:e.toFixed(1)})]}),(0,C.jsx)(`div`,{style:{height:4,background:`#1e293b`,borderRadius:2,overflow:`hidden`},children:(0,C.jsx)(`div`,{style:{width:`${i}%`,height:`100%`,background:n,borderRadius:2,transition:`width 0.3s`}})})]})};function En({className:e=``,style:t,children:n}={}){let r=u.o((0,w.useShallow)(e=>e.performance)),i=u.o(e=>e.retainPerformanceSampling);(0,b.useEffect)(()=>i(),[i]);let[a,o]=(0,b.useState)({current:0,min:1/0,max:0,avg:0,p1Low:0,history:Array(Cn).fill(0)}),[s,c]=(0,b.useState)({used:0,limit:0,history:Array(Cn).fill(0)}),[l,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(0),[m,h]=(0,b.useState)(Array(Cn).fill(0)),[g,_]=(0,b.useState)(Array(Cn).fill(0)),v=(0,b.useRef)(0),y=(0,b.useRef)(0),x=(0,b.useRef)(0),S=(0,b.useRef)([]),T=(0,b.useRef)(0),E=(0,b.useRef)(null),D=(0,b.useRef)(0),O=(0,b.useRef)(0),k=(0,b.useRef)(0),A=(0,b.useCallback)(e=>{if(e.length<5)return 0;let t=[...e].filter(e=>e>0).sort((e,t)=>e-t),n=Math.max(1,Math.floor(t.length*.01)),r=0;for(let e=0;e<n;e++)r+=t[e]??0;return r/n},[]);(0,b.useEffect)(()=>{let e=window.performance.now();v.current=e,y.current=e,T.current=e;let t=e=>{let n=e-y.current;if(y.current=e,S.current.push(n),S.current.length>300&&S.current.shift(),D.current+=n,O.current++,O.current>=10){let e=D.current/O.current;p(e),_(t=>[...t.slice(1),e]),D.current=0,O.current=0}if(x.current++,e-v.current>=500){let t=x.current*1e3/(e-v.current),n=S.current.map(e=>e>0?1e3/e:0),r=e-T.current>3e3;o(e=>{let i=[...e.history.slice(1),t],a=r?Math.min(e.min===1/0?t:e.min,t):1/0,o=r?Math.max(e.max,t):0,s=r?i.filter(e=>e>0):[],c=s.length>0?s.reduce((e,t)=>e+t,0)/s.length:t,l=r?A(n):t;return{current:t,min:a,max:o,avg:c,p1Low:l,history:i}});let i=window.performance.memory,a=!!(i&&Number.isFinite(i.usedJSHeapSize)&&i.usedJSHeapSize>=0&&Number.isFinite(i.jsHeapSizeLimit)&&i.jsHeapSizeLimit>0);d(a),i&&a&&c(e=>{let t=Math.round(i.usedJSHeapSize/1048576);return{used:t,limit:Math.round(i.jsHeapSizeLimit/1048576),history:[...e.history.slice(1),t]}}),v.current=e,x.current=0}E.current=requestAnimationFrame(t)};return E.current=requestAnimationFrame(t),()=>{E.current&&cancelAnimationFrame(E.current)}},[A]),(0,b.useEffect)(()=>{let e=r.render.calls;e!==k.current&&(k.current=e,h(t=>[...t.slice(1),e]))},[r.render.calls]);let j=e=>e>=55?`#4ade80`:e>=30?`#facc15`:`#f87171`,M=e=>e<=16.7?`#4ade80`:e<=33.3?`#facc15`:`#f87171`,N=e=>e<=100?`#4ade80`:e<=300?`#facc15`:`#f87171`,P=(e,t)=>{let n=t>0?e/t*100:0;return n<60?`#4ade80`:n<80?`#facc15`:`#f87171`},F=r.render.triangles,I=r.render.calls,L=r.engine.geometries,R=r.engine.textures;return(0,C.jsxs)(`div`,{className:`perf-panel ${e}`,style:t,children:[(0,C.jsxs)(`div`,{className:`perf-stat-group`,children:[(0,C.jsxs)(`div`,{className:`perf-header`,children:[(0,C.jsx)(`h4`,{className:`perf-title`,children:`브라우저 초당 프레임`}),(0,C.jsxs)(`span`,{className:`perf-current`,style:{color:j(a.current)},children:[a.current.toFixed(0),` FPS`]})]}),(0,C.jsxs)(`div`,{className:`perf-details-grid`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`평균`}),a.avg.toFixed(1)]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`최소`}),isFinite(a.min)?a.min.toFixed(1):`...`]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`최대`}),a.max.toFixed(1)]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`하위 1%`}),(0,C.jsx)(`span`,{style:{color:j(a.p1Low)},children:a.p1Low.toFixed(1)})]})]}),(0,C.jsx)(wn,{data:a.history,color:j(a.current),max:90,warn:60})]}),(0,C.jsxs)(`div`,{className:`perf-stat-group`,children:[(0,C.jsxs)(`div`,{className:`perf-header`,children:[(0,C.jsx)(`h4`,{className:`perf-title`,children:`브라우저 프레임 간격`}),(0,C.jsxs)(`span`,{className:`perf-current`,style:{color:M(f)},children:[f.toFixed(2),` ms`]})]}),(0,C.jsx)(Tn,{value:f,max:33.3,color:M(f),label:`목표 시간(16.7ms)`}),(0,C.jsx)(wn,{data:g,color:M(f),max:33.3,warn:16.7})]}),(0,C.jsx)(Sn,{}),(0,C.jsxs)(`div`,{className:`perf-stat-group`,children:[(0,C.jsxs)(`div`,{className:`perf-header`,children:[(0,C.jsx)(`h4`,{className:`perf-title`,children:`GPU 렌더링`}),(0,C.jsxs)(`span`,{className:`perf-current`,style:{color:N(I)},children:[I,` 회`]})]}),(0,C.jsxs)(`div`,{className:`perf-details-grid`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`삼각형`}),F>=1e6?(F/1e6).toFixed(2)+`M`:F>=1e3?(F/1e3).toFixed(1)+`K`:F]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`그리기 호출`}),(0,C.jsx)(`span`,{style:{color:N(I)},children:I})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`호출당 삼각형`}),I>0?Math.round(F/I):0]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`점`}),r.render.points]})]}),(0,C.jsx)(wn,{data:m,color:N(I),max:Math.max(200,...m)})]}),(0,C.jsxs)(`div`,{className:`perf-stat-group`,children:[(0,C.jsx)(`div`,{className:`perf-header`,children:(0,C.jsx)(`h4`,{className:`perf-title`,children:`리소스`})}),(0,C.jsxs)(`div`,{className:`perf-details-grid`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`도형`}),L]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`텍스처`}),R]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`셰이더 프로그램`}),r.engine.programs]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`선`}),r.render.lines]})]}),(0,C.jsx)(Tn,{value:L,max:200,color:L>150?`#f87171`:`#4ade80`,label:`도형 수 (비교 기준 200개)`}),(0,C.jsx)(Tn,{value:R,max:100,color:R>80?`#f87171`:`#4ade80`,label:`텍스처 수 (비교 기준 100개)`})]}),(0,C.jsxs)(`div`,{className:`perf-stat-group`,children:[(0,C.jsxs)(`div`,{className:`perf-header`,children:[(0,C.jsx)(`h4`,{className:`perf-title`,children:`자바스크립트 메모리`}),l&&(0,C.jsxs)(`span`,{className:`perf-current`,style:{color:P(s.used,s.limit)},children:[s.used,` MB`]})]}),l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`perf-details-grid`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`한도`}),s.limit,` MB`]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`perf-label`,children:`사용률`}),s.limit>0?(s.used/s.limit*100).toFixed(0):0,`%`]})]}),(0,C.jsx)(wn,{data:s.history,color:P(s.used,s.limit),max:s.limit||1})]}):(0,C.jsx)(`p`,{className:`perf-label`,children:`메모리 측정값이 없습니다. 브라우저 지원 여부에 따라 표시됩니다.`})]}),n]})}var Dn=`__root__`;function On({sceneDocument:e,selectedObjectId:t,selectedObjectIds:n=t?[t]:[],hoveredObjectId:r,defaultExpandedIds:i=[],searchPlaceholder:a=`객체 검색`,emptyLabel:o=`장면에 객체가 없습니다`,onSelectObject:s,onHoverObject:c,className:l=``,style:u,children:d}={}){let[f,p]=(0,b.useState)(``),[m,h]=(0,b.useState)(()=>new Set(i)),g=(0,b.useMemo)(()=>kn(e?.objects??[],m,f),[m,f,e]),_=e?.objects.length??0,v=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,C.jsxs)(`div`,{className:`hierarchy-panel hierarchy-panel--scene-object ${l}`,style:u,children:[(0,C.jsxs)(`div`,{className:`hierarchy-panel__toolbar`,children:[(0,C.jsx)(`input`,{className:`hierarchy-panel__search`,type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:a,"aria-label":`장면 객체 검색`}),(0,C.jsx)(`span`,{className:`hierarchy-panel__count`,children:_})]}),(0,C.jsx)(`div`,{className:`hierarchy-panel__tree`,role:`tree`,"aria-label":`장면 계층`,children:g.length===0?(0,C.jsx)(`div`,{className:`hierarchy-panel__empty`,children:o}):g.map(({object:e,depth:t,hasChildren:i})=>{let a=f.trim()?!0:m.has(e.id),o=n.includes(e.id),l=e.id===r;return(0,C.jsxs)(`div`,{className:`hierarchy-item ${o?`selected`:``} ${l?`hovered`:``}`,role:`treeitem`,"aria-selected":o,"aria-expanded":i?a:void 0,style:{paddingLeft:`${12+t*14}px`},onMouseEnter:()=>c?.(e),onMouseLeave:()=>c?.(void 0),children:[(0,C.jsx)(`button`,{type:`button`,className:`hierarchy-toggle`,onClick:()=>v(e.id),disabled:!i||!!f.trim(),"aria-label":a?`하위 객체 접기`:`하위 객체 펼치기`,children:i?a?`-`:`+`:``}),(0,C.jsxs)(`button`,{type:`button`,className:`hierarchy-object`,onClick:()=>s?.(e),children:[(0,C.jsx)(`span`,{className:`hierarchy-name`,children:e.name||e.id}),(0,C.jsxs)(`span`,{className:`hierarchy-meta`,children:[e.layer?(0,C.jsx)(`span`,{children:e.layer}):null,e.components.length>0?(0,C.jsxs)(`span`,{children:[`컴포넌트 `,e.components.length,`개`]}):null]})]})]},e.id)})}),d]})}function kn(e,t=new Set,n=``){let r=n.trim().toLowerCase(),i=new Set(e.map(e=>e.id)),a=new Map,o=new Map(e.map(e=>[e.id,e]));e.forEach(e=>{let t=e.parentId&&i.has(e.parentId)?e.parentId:Dn,n=a.get(t)??[];n.push(e),a.set(t,n)});let s=r?An(e,o,r):void 0,c=[],l=(e,n)=>{if(s&&!s.has(e.id))return;let i=a.get(e.id)??[];c.push({object:e,depth:n,hasChildren:i.length>0}),(r||t.has(e.id))&&i.forEach(e=>l(e,n+1))};return(a.get(Dn)??[]).forEach(e=>l(e,0)),c}function An(e,t,n){let r=new Set;return e.forEach(e=>{if(!jn(e,n))return;let i=e;for(;i;)r.add(i.id),i=i.parentId?t.get(i.parentId):void 0}),r}function jn(e,t){return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.tags.some(e=>e.toLowerCase().includes(t))||!!e.layer?.toLowerCase().includes(t)}var Mn=new Map,Nn=!1;function Pn(){return Nn||(Nn=!0,Fn(l.U)),Mn}function Fn(e){let t=n.o(e);if(!t.valid){let n=t.issues[0];throw Error(`[AnimatorRegistry Error]: 잘못된 컨트롤러 ${e.id} (${n?.path}: ${n?.message})`)}return Pn().set(e.id,e),()=>{Mn.get(e.id)===e&&Mn.delete(e.id)}}function In(e){return Pn().get(e)}function Ln(){return Array.from(Pn().values())}function Rn(e){return e===void 0?`-`:String(typeof e==`number`?Number(e.toFixed(3)):e)}function zn({data:e}){let t=typeof e.controllerId==`string`?e.controllerId:``,n=e.parameters,r=n&&typeof n==`object`&&!Array.isArray(n)?n:{},i=t?In(t):void 0;return i?(0,C.jsxs)(`div`,{className:`inspector-animator`,children:[(0,C.jsxs)(`div`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:`컨트롤러`}),(0,C.jsx)(`span`,{className:`prop-value prop-value--readonly`,children:i.id})]}),Object.entries(i.parameters??{}).map(([e,t])=>(0,C.jsxs)(`div`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:e}),(0,C.jsxs)(`span`,{className:`prop-value prop-value--readonly`,children:[t.type,` · `,Rn(r[e]??t.default)]})]},e)),i.layers.map(e=>(0,C.jsxs)(`div`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:e.name}),(0,C.jsx)(`span`,{className:`prop-value prop-value--readonly`,children:e.states.map(t=>t.name===e.defaultState?`[${t.name}]`:t.name).join(`, `)})]},e.name))]}):(0,C.jsxs)(`div`,{className:`inspector-animator inspector-animator--missing`,children:[(0,C.jsxs)(`div`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:`컨트롤러`}),(0,C.jsx)(`span`,{className:`prop-value prop-value--readonly`,children:t||`(지정 안 됨)`})]}),(0,C.jsx)(`div`,{className:`inspector-component-empty`,children:`등록되지 않은 Animator 컨트롤러입니다`})]})}function Bn(e,t){let n=t=>e.objects.find(e=>e.id===t)?.name||t;switch(t.kind){case`property`:return`${n(t.objectId)} · ${t.path}`;case`componentData`:return`${n(t.objectId)} · ${t.componentId} 데이터`;case`addedComponent`:return`${n(t.objectId)} · ${t.component.type} 추가`;case`removedComponent`:return`${n(t.objectId)} · ${t.componentId} 삭제`;case`addedObject`:return`${t.object.name||t.object.id} 추가`;case`removedObject`:return`${n(t.objectId)} 삭제`}}var Vn=1,Hn={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]};function Un(e){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`Scene component input must be an object.`);let{data:t,enabled:n,id:r,type:i}=e;if(typeof i!=`string`||!i.trim())throw TypeError(`Scene component type must be a non-empty string.`);if(r!==void 0&&(typeof r!=`string`||!r.trim()))throw TypeError(`Scene component id must be a non-empty string when provided.`);if(n!==void 0&&typeof n!=`boolean`)throw TypeError(`Scene component enabled must be a boolean when provided.`);let a=$n(t===void 0?{}:t,`Scene component "${i}" data`);return{id:r??d.t(`component`),type:i,enabled:n??!0,data:a}}function Wn(e={}){return{id:e.id??d.t(`object`),name:e.name??`Scene Object`,...e.parentId===void 0?{}:{parentId:e.parentId},transform:Jn(e.transform),components:rr(e.components??[],`Scene object components`,Zn),tags:rr(e.tags??[],`Scene object tags`,e=>e),...e.layer===void 0?{}:{layer:e.layer}}}function Gn(e){return{version:1,id:e.id,...e.name===void 0?{}:{name:e.name},objects:rr(e.objects??[],`Scene document objects`,e=>Wn(e))}}function Kn(e){let t=[];if(typeof e!=`object`||!e||e.version!==1||typeof e.id!=`string`||!e.id.trim()||e.name!==void 0&&typeof e.name!=`string`||!Array.isArray(e.objects))return{valid:!1,issues:[{code:`invalid-document-shape`,message:`Scene document shape is invalid.`}]};let n=new Set,r=new Map;for(let i of e.objects){if(!sr(i)){t.push({code:`invalid-document-shape`,message:`Scene document contains an invalid object record.`});continue}n.has(i.id)&&t.push({code:`duplicate-object-id`,objectId:i.id,message:`Scene object "${i.id}" is duplicated.`}),n.add(i.id),r.set(i.id,i),(!lr(i.transform.position)||!lr(i.transform.rotation)||!lr(i.transform.scale))&&t.push({code:`invalid-transform`,objectId:i.id,message:`Scene object "${i.id}" has an invalid transform.`});let e=new Set;for(let n of i.components){if(!cr(n)){t.push({code:`invalid-document-shape`,objectId:i.id,message:`Scene object "${i.id}" contains an invalid component record.`});continue}e.has(n.id)&&t.push({code:`duplicate-component-id`,objectId:i.id,componentId:n.id,message:`Scene object "${i.id}" has duplicate component "${n.id}".`}),e.add(n.id),Qn(n.data)||t.push({code:`invalid-component-data`,objectId:i.id,componentId:n.id,message:`Scene component "${n.id}" contains non-canonical JSON data.`})}}for(let n of e.objects)if(sr(n)&&n.parentId!==void 0){if(n.parentId===n.id){t.push({code:`self-parent`,objectId:n.id,message:`Scene object "${n.id}" cannot parent itself.`});continue}if(!r.has(n.parentId)){t.push({code:`missing-parent`,objectId:n.id,message:`Scene object "${n.id}" references missing parent "${n.parentId}".`});continue}ur(n,r)&&t.push({code:`parent-cycle`,objectId:n.id,message:`Scene object "${n.id}" is part of a parent cycle.`})}return{valid:t.length===0,issues:t}}function qn(e,t){return e.objects.filter(e=>e.parentId===t)}function Jn(e){return{position:Yn(e?.position,Hn.position),rotation:Yn(e?.rotation,Hn.rotation),scale:Yn(e?.scale,Hn.scale)}}function Yn(e,t){return e===void 0?[...t]:[e[0],e[1],e[2]]}function Xn(e){return cr(e)}function Zn(e){return Xn(e)?{id:e.id,type:e.type,enabled:e.enabled,data:$n(e.data,`Scene component "${e.id}" data`)}:Un(e)}function Qn(e){return typeof e!=`object`||!e||Array.isArray(e)?!1:or(e,new WeakSet)}function $n(e,t){try{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError();return nr(e,new WeakSet,new WeakMap)}catch{throw TypeError(`${t} must contain only canonical JSON values.`)}}function er(e,t,n){if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`){if(!Number.isFinite(e)||Object.is(e,-0))throw TypeError();return e}if(typeof e!=`object`||t.has(e))throw TypeError();let r=n.get(e);return r===void 0?Array.isArray(e)?tr(e,t,n):nr(e,t,n):r}function tr(e,t,n){if(Object.getPrototypeOf(e)!==Array.prototype)throw TypeError();let r=Reflect.ownKeys(e);if(r.length!==e.length+1||!r.every(e=>e===`length`||typeof e==`string`&&/^0$|^[1-9]\d*$/.test(e)))throw TypeError();let i=[];n.set(e,i),t.add(e);try{for(let r=0;r<e.length;r++){let a=Object.getOwnPropertyDescriptor(e,String(r));if(!a?.enumerable||!(`value`in a))throw TypeError();i.push(er(a.value,t,n))}}finally{t.delete(e)}return i}function nr(e,t,n){let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw TypeError();let i={};n.set(e,i),t.add(e);try{for(let r of Reflect.ownKeys(e)){if(typeof r!=`string`)throw TypeError();let a=Object.getOwnPropertyDescriptor(e,r);if(!a?.enumerable||!(`value`in a))throw TypeError();Object.defineProperty(i,r,{configurable:!0,enumerable:!0,value:er(a.value,t,n),writable:!0})}}finally{t.delete(e)}return i}function rr(e,t,n){if(!Array.isArray(e))throw TypeError(`${t} must be an array.`);let r=Reflect.ownKeys(e);if(r.length!==e.length+1)throw TypeError(`${t} must be a dense array.`);if(!r.every(e=>e===`length`||typeof e==`string`&&/^0$|^[1-9]\d*$/.test(e)))throw TypeError(`${t} must not contain custom properties.`);let i=[];for(let r=0;r<e.length;r++){let a=Object.getOwnPropertyDescriptor(e,String(r));if(!a?.enumerable||!(`value`in a))throw TypeError(`${t} must contain only data elements.`);i.push(n(a.value))}return i}function ir(e,t){if(e===null||typeof e==`string`||typeof e==`boolean`)return!0;if(typeof e==`number`)return Number.isFinite(e)&&!Object.is(e,-0);if(typeof e!=`object`||t.has(e))return!1;t.add(e);try{return Array.isArray(e)?ar(e,t):or(e,t)}finally{t.delete(e)}}function ar(e,t){if(Object.getPrototypeOf(e)!==Array.prototype)return!1;let n=Reflect.ownKeys(e);if(n.length!==e.length+1)return!1;for(let n=0;n<e.length;n++){let r=Object.getOwnPropertyDescriptor(e,String(n));if(!r?.enumerable||!(`value`in r)||!ir(r.value,t))return!1}return n.every(e=>e===`length`||typeof e==`string`&&/^0$|^[1-9]\d*$/.test(e))}function or(e,t){let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)return!1;for(let n of Reflect.ownKeys(e)){if(typeof n!=`string`)return!1;let r=Object.getOwnPropertyDescriptor(e,n);if(!r?.enumerable||!(`value`in r)||!ir(r.value,t))return!1}return!0}function sr(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&!!t.id.trim()&&typeof t.name==`string`&&(t.parentId===void 0||typeof t.parentId==`string`)&&t.transform!==null&&typeof t.transform==`object`&&Array.isArray(t.components)&&Array.isArray(t.tags)&&t.tags.every(e=>typeof e==`string`)&&(t.layer===void 0||typeof t.layer==`string`)}function cr(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&!!t.id.trim()&&typeof t.type==`string`&&!!t.type.trim()&&typeof t.enabled==`boolean`&&t.data!==null&&typeof t.data==`object`&&!Array.isArray(t.data)}function lr(e){if(!Array.isArray(e)||e.length!==3)return!1;for(let t=0;t<e.length;t++){let n=Object.getOwnPropertyDescriptor(e,String(t));if(!n?.enumerable||!(`value`in n)||typeof n.value!=`number`||!Number.isFinite(n.value)||Object.is(n.value,-0))return!1}return!0}function ur(e,t){let n=new Set,r=e;for(;r?.parentId!==void 0;){if(n.has(r.parentId))return!0;n.add(r.id),r=t.get(r.parentId)}return!1}var K={meshRenderer:`gaesup.meshRenderer`,collider:`gaesup.collider`,rigidBody:`gaesup.rigidBody`,script:`gaesup.script`,interactable:`gaesup.interactable`,buildingPiece:`gaesup.buildingPiece`,npc:`gaesup.npc`,animator:`gaesup.animator`,prefabInstance:`gaesup.prefabInstance`};function dr(e={}){return Un({type:K.meshRenderer,data:e})}function fr(e){return Un({type:K.collider,data:e})}function pr(e){return Un({type:K.rigidBody,data:e})}function mr(e){return Un({type:K.script,data:e})}function hr(e){return Un({type:K.interactable,data:e})}function gr(e){return Un({type:K.buildingPiece,data:e})}function _r(e){return Un({type:K.npc,data:e})}function vr(e){return Un({type:K.animator,data:e})}var q=Symbol(`missing-scene-property`),J=class extends TypeError{},yr=class extends TypeError{};function br(e){let t=Kn(e).issues[0];if(t)throw TypeError(t.message);let n=Gn({id:e.id,...e.name===void 0?{}:{name:e.name},objects:e.objects}),r=Kn(n).issues[0];if(r)throw TypeError(r.message);return JSON.stringify(n)}function xr(e){return Sr(br(e)).document??{version:1,id:e.id,objects:[]}}function Sr(e){let t=typeof e==`string`?Er(e):e,n,r,i,a;try{Mr(t,`Scene document`),n=Y(t,`version`),r=Y(t,`id`),i=Y(t,`name`),a=Y(t,`objects`)}catch(e){return Dr(e instanceof Error?e.message:`Scene document must be a plain data object.`,`invalid-document-shape`)}if(n!==1)return Dr(`Scene document version must be 1.`);if(typeof r!=`string`||!r.trim())return Dr(`Scene document id must be a non-empty string.`);if(i!==q&&typeof i!=`string`)return Dr(`Scene document name must be a string.`,`invalid-document-shape`);if(!Array.isArray(a))return Dr(`Scene document objects must be an array.`);let o;try{o=Cr(a)}catch(e){return Dr(e instanceof Error?e.message:`Scene document objects are invalid.`,`invalid-document-shape`)}let s;try{s={version:1,id:r,...typeof i==`string`?{name:i}:{},objects:o.map(e=>Or(e))}}catch(e){return Dr(e instanceof Error?e.message:`Scene component data is invalid.`,e instanceof yr?`invalid-transform`:e instanceof J?`invalid-document-shape`:`invalid-component-data`)}let c=Kn(s);return{ok:c.valid,document:s,issues:c.issues}}function Cr(e){return wr(e,`Scene document objects`)}function wr(e,t){let n=Reflect.ownKeys(e);if(n.length!==e.length+1)throw new J(`${t} must be a dense array.`);if(!n.every(e=>e===`length`||typeof e==`string`&&/^0$|^[1-9]\d*$/.test(e)))throw new J(`${t} must not contain custom properties.`);let r=[];for(let n=0;n<e.length;n++){let i=Object.getOwnPropertyDescriptor(e,String(n));if(!i?.enumerable||!(`value`in i))throw new J(`${t} must contain only data elements.`);r.push(i.value)}return r}function Tr(e){let t=Sr(e);return{valid:t.ok,issues:t.issues}}function Er(e){try{return JSON.parse(e)}catch{return null}}function Dr(e,t=`invalid-transform`){return{ok:!1,issues:[{code:t,message:e}]}}function Or(e){Mr(e,`Scene object`);let t=Y(e,`id`);if(typeof t!=`string`||!t.trim())throw new J(`Persisted scene object id must be a non-empty string.`);let n=Y(e,`name`);if(n!==q&&typeof n!=`string`)throw new J(`Scene object name must be a string when provided.`);let r=Y(e,`parentId`);if(r!==q&&(typeof r!=`string`||!r.trim()))throw new J(`Scene object parentId must be a non-empty string when provided.`);let i=Y(e,`transform`);if(i!==q&&(typeof i!=`object`||!i||Array.isArray(i)))throw new yr(`Scene object transform must be an object when provided.`);let a=i===q?q:kr(i),o=Y(e,`components`);if(o!==q&&!Array.isArray(o))throw new J(`Scene object components must be an array when provided.`);let s=o===q?[]:wr(o,`Scene object components`).map(jr),c=Y(e,`tags`);if(c!==q&&!Array.isArray(c))throw new J(`Scene object tags must be an array when provided.`);let l=c===q?[]:wr(c,`Scene object tags`);if(!l.every(e=>typeof e==`string`))throw new J(`Scene object tags must contain only strings.`);let u=Y(e,`layer`);if(u!==q&&typeof u!=`string`)throw new J(`Scene object layer must be a string when provided.`);return Wn({id:t,...n===q?{}:{name:n},...r===q?{}:{parentId:r},...a===q?{}:{transform:a},components:s,tags:l,...u===q?{}:{layer:u}})}function kr(e){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new yr(`Scene object transform must be a plain object.`);let n=Y(e,`position`),r=Y(e,`rotation`),i=Y(e,`scale`);return{...n===q?{}:{position:Ar(n,`position`)},...r===q?{}:{rotation:Ar(r,`rotation`)},...i===q?{}:{scale:Ar(i,`scale`)}}}function Ar(e,t){if(!Array.isArray(e)||e.length!==3)throw new yr(`Scene transform ${t} must be a 3-tuple.`);let n=Reflect.ownKeys(e);if(n.length!==4||!n.every(e=>e===`length`||typeof e==`string`&&/^[0-2]$/.test(e)))throw new yr(`Scene transform ${t} must be a dense 3-tuple.`);let r=[0,0,0];for(let n=0;n<e.length;n++){let i=Object.getOwnPropertyDescriptor(e,String(n));if(!i?.enumerable||!(`value`in i)||typeof i.value!=`number`||!Number.isFinite(i.value)||Object.is(i.value,-0))throw new yr(`Scene transform ${t} must contain finite canonical numbers.`);r[n]=i.value}return r}function jr(e){Mr(e,`Scene component`);let t=Y(e,`id`),n=Y(e,`type`),r=Y(e,`enabled`),i=Y(e,`data`);if(typeof t!=`string`||!t.trim())throw new J(`Persisted scene component id must be a non-empty string.`);if(typeof n!=`string`||!n.trim())throw new J(`Persisted scene component type must be a non-empty string.`);if(typeof r!=`boolean`)throw new J(`Persisted scene component enabled must be a boolean.`);if(i===q||typeof i!=`object`||!i||Array.isArray(i))throw new J(`Persisted scene component data must be an object.`);return{id:t,type:n,enabled:r,data:i}}function Mr(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new J(`${t} must be an object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new J(`${t} must be a plain object.`)}function Y(e,t){let n=Object.getOwnPropertyDescriptor(e,t);if(n===void 0)return q;if(!n.enumerable||!(`value`in n))throw new J(`Scene property "${t}" must be enumerable data.`);return n.value}var Nr=e=>e===0?0:e,Pr=new Map;function Fr(e,t){return Pr.set(e,t),()=>{Pr.get(e)===t&&Pr.delete(e)}}function Ir(e,t){let n=Pr.get(e);if(!n)return null;try{return n(t)}catch(e){return e instanceof Error?e.message:`Component data validator failed.`}}function Lr(e){if(typeof e!=`object`||!e||Object.isFrozen(e))return e;for(let t of Reflect.ownKeys(e)){let n=Object.getOwnPropertyDescriptor(e,t);n&&`value`in n&&Lr(n.value)}return Object.freeze(e)}var Rr=new WeakSet,zr=new WeakMap;function Br(e){return Rr.add(e),e}function Vr(e){return Rr.has(e)}function Hr(e){let t=zr.get(e);if(!t){t=new Map;for(let n=0;n<e.objects.length;n++)t.set(e.objects[n].id,n);zr.set(e,t)}return t}function Ur(e,t){let n=Hr(e).get(t);return n===void 0?void 0:e.objects[n]}function Wr(e,t){let n=qr(e),r=e.objects.slice();return r[n.get(t.id)]=Lr(t),Jr(e,r,n)}function Gr(e,t){let n=qr(e);return n.set(t.id,e.objects.length),Jr(e,[...e.objects,Lr(t)],n)}function Kr(e,t){return Jr(e,e.objects.filter(e=>!t.has(e.id)))}function qr(e){let t=Hr(e);return zr.delete(e),t}function Jr(e,t,n){let r=Object.freeze({version:e.version,id:e.id,...e.name===void 0?{}:{name:e.name},objects:Object.freeze(t)});return n&&zr.set(r,n),r}function Yr(e,t){return Lr({accepted:!0,document:e,event:t})}function Xr(e,t){let n=t.map(e=>Lr({...e}));return Object.freeze({accepted:!1,document:e,issues:Object.freeze(n)})}function Zr(e,t){let{objectId:n,componentId:r}=t,i=Vr(e),a=i?Ur(e,n):e.objects.find(e=>e.id===n);if(!a)return Xr(e,[{code:`missing-object`,objectId:n,message:`Scene object "${n}" does not exist.`}]);let o=a.components.find(e=>e.id===r);if(!o)return Xr(e,[{code:`missing-component`,objectId:n,componentId:r,message:`Scene object "${n}" does not contain component "${r}".`}]);if(t.data===void 0&&t.enabled===void 0)return Xr(e,[{code:`invalid-scene-command`,objectId:n,componentId:r,message:`Component update is empty.`}]);if(t.enabled!==void 0&&typeof t.enabled!=`boolean`)return Xr(e,[{code:`invalid-scene-command`,objectId:n,componentId:r,message:`Component enabled must be boolean.`}]);let s={code:`invalid-component-data`,objectId:n,componentId:r,message:`Component data must be canonical JSON.`};if(t.data!==void 0){if(!Qn(t.data))return Xr(e,[s]);let i=Ir(o.type,t.data);if(i)return Xr(e,[{code:`invalid-component-data`,objectId:n,componentId:r,message:i}])}let c={...o,...t.data===void 0?{}:{data:t.data},...t.enabled===void 0?{}:{enabled:t.enabled}},l;if(i){let t;try{t=Un(c)}catch{return Xr(e,[s])}l=Wr(e,{...a,components:a.components.map(e=>e.id===r?t:e)})}else{let t={...a,components:a.components.map(e=>e.id===r?c:e)},i=Sr({version:e.version,id:e.id,...e.name===void 0?{}:{name:e.name},objects:e.objects.map(e=>e.id===n?t:e)});if(!i.ok||!i.document)return Xr(e,i.issues);l=i.document}let u=Yr(l,{type:`scene-object.component.updated`,documentId:l.id,objectId:n,componentId:r});return Br(l),u}function Qr(e,t,n){if(!Array.isArray(t.commands)||t.commands.length===0)return Xr(e,[{code:`invalid-scene-command`,message:`Scene batch must contain commands.`}]);if(t.label!==void 0&&typeof t.label!=`string`)return Xr(e,[{code:`invalid-scene-command`,message:`Scene batch label must be a string.`}]);let r=e,i=[];for(let a of t.commands){let t=n(r,a);if(!t.accepted)return Xr(e,t.issues);r=t.document,i.push(t.event)}return Yr(r,{type:`scene-document.batch-applied`,documentId:r.id,...t.label===void 0?{}:{label:t.label},events:i})}var $r=Symbol(`missing-scene-command-property`),ei=class extends Error{constructor(e){super(e.message),this.issue=e}};function ti(e,t){let n=e;if(!Vr(e)){try{yi(e,`Current scene document`)}catch(t){return Ni(e,[{code:`invalid-document-shape`,message:t instanceof Error?t.message:`Current scene document is invalid.`}])}let t=Sr(e);if(!t.ok||!t.document)return Ni(e,t.issues);n=Br(Lr(t.document))}let r=ni(n,t);return r.accepted?r:Object.freeze({accepted:!1,document:e,issues:r.issues})}function ni(e,t){if(ri(t,`scene-object.component.update`))return Zr(e,t);if(ri(t,`scene-document.batch`))return Qr(e,t,ni);let n;try{n=ii(e,t)}catch(t){return Ni(e,[t instanceof ei?t.issue:{code:`invalid-scene-command`,message:t instanceof Error?t.message:`Scene command is invalid.`}])}let r=n.document;if(!r){let t=Sr(n.candidate());if(!t.ok||!t.document)return Ni(e,t.issues);r=t.document}return Mi(r,n.createEvent(r))}function ri(e,t){return typeof e==`object`&&!!e&&e.type===t}function ii(e,t){let n=xi(t,`Scene command`),r=wi(n,`type`,`Scene command type`);switch(r){case`scene-document.replace`:{Si(n,[`type`,`document`],`Replace scene command`);let e=X(n,`document`,`Replacement scene document`),t=Vr(e);return t||yi(e,`Replacement scene document`),{...t?{document:e}:{},candidate:()=>e,createEvent:e=>({type:`scene-document.replaced`,documentId:e.id})}}case`scene-object.create`:{Si(n,[`type`,`object`],`Create scene object command`);let t=X(n,`object`,`Created scene object`),r=gi(t),i=Hr(e);return{...!i.has(r.id)&&ci(r)&&(r.parentId===void 0||r.parentId!==r.id&&i.has(r.parentId))?{document:Gr(e,_i(r))}:{},candidate:()=>ai(e,[...e.objects,t]),createEvent:e=>({type:`scene-object.created`,documentId:e.id,objectId:r.id})}}case`scene-object.update`:{Si(n,[`type`,`objectId`,`patch`],`Update scene object command`);let t=Ti(n,`objectId`,`Scene object id`),r=li(e,t),i=fi(X(n,`patch`,`Scene object patch`)),a=di(r,i);return{...!(`parentId`in i)||si(e,t,a.parentId)?{document:Wr(e,a)}:{},candidate:()=>oi(e,a),createEvent:e=>({type:`scene-object.updated`,documentId:e.id,objectId:t})}}case`scene-object.delete`:{Si(n,[`type`,`objectId`],`Delete scene object command`);let t=Ti(n,`objectId`,`Scene object id`);li(e,t);let r=ui(e,t),i=Kr(e,new Set(r));return{document:i,candidate:()=>i,createEvent:e=>({type:`scene-object.deleted`,documentId:e.id,objectIds:r})}}case`scene-object.move`:{Si(n,[`type`,`objectId`,`parentId`],`Move scene object command`);let t=Ti(n,`objectId`,`Scene object id`),r=li(e,t),i=Ei(n,`parentId`,`Scene parent id`),a=di(r,{parentId:i});return{...si(e,t,a.parentId)?{document:Wr(e,a)}:{},candidate:()=>oi(e,a),createEvent:e=>({type:`scene-object.moved`,documentId:e.id,objectId:t,parentId:i})}}case`scene-object.component.add`:{Si(n,[`type`,`objectId`,`component`],`Add scene component command`);let t=Ti(n,`objectId`,`Scene object id`),r=li(e,t),i=X(n,`component`,`Scene component`),a=bi(i);return{...r.components.some(e=>e.id===a.id)?{}:{document:Wr(e,{...r,components:[...r.components,vi(a)]})},candidate:()=>oi(e,{...r,components:[...r.components,i]}),createEvent:e=>({type:`scene-object.component.added`,documentId:e.id,objectId:t,componentId:a.id})}}case`scene-object.component.remove`:{Si(n,[`type`,`objectId`,`componentId`],`Remove scene component command`);let t=Ti(n,`objectId`,`Scene object id`),r=Ti(n,`componentId`,`Scene component id`),i=li(e,t);if(!i.components.some(e=>e.id===r))throw new ei({code:`missing-component`,objectId:t,componentId:r,message:`Scene object "${t}" does not contain component "${r}".`});let a=Wr(e,{...i,components:i.components.filter(e=>e.id!==r)});return{document:a,candidate:()=>a,createEvent:e=>({type:`scene-object.component.removed`,documentId:e.id,objectId:t,componentId:r})}}default:throw TypeError(`Unsupported scene command type "${r}".`)}}function ai(e,t){return{version:e.version,id:e.id,...e.name===void 0?{}:{name:e.name},objects:t}}function oi(e,t){return ai(e,e.objects.map(e=>e.id===t.id?t:e))}function si(e,t,n){for(let r=n;r!==void 0;){if(r===t)return!1;let n=Ur(e,r);if(!n)return!1;r=n.parentId}return!0}function ci(e){return new Set(e.components.map(e=>e.id)).size===e.components.length}function li(e,t){let n=Ur(e,t);if(!n)throw new ei({code:`missing-object`,objectId:t,message:`Scene object "${t}" does not exist.`});return n}function ui(e,t){let n=new Map;for(let t of e.objects){if(t.parentId===void 0)continue;let e=n.get(t.parentId);e?e.push(t.id):n.set(t.parentId,[t.id])}let r=new Set([t]),i=[t];for(;i.length;)for(let e of n.get(i.pop())??[])r.has(e)||(r.add(e),i.push(e));return e.objects.filter(e=>r.has(e.id)).map(e=>e.id)}function di(e,t){let n=t.transform,r={...e,...t.name===void 0?{}:{name:t.name},...t.tags===void 0?{}:{tags:[...t.tags]},...n===void 0?{}:{transform:{position:n.position??e.transform.position,rotation:n.rotation??e.transform.rotation,scale:n.scale??e.transform.scale}}};return`parentId`in t&&(t.parentId===null?delete r.parentId:r.parentId=t.parentId),`layer`in t&&(t.layer===null?delete r.layer:r.layer=t.layer),r}function fi(e){let t=xi(e,`Scene object patch`);Si(t,[`name`,`parentId`,`transform`,`tags`,`layer`],`Scene object patch`);let n=Ci(t,`name`),r=Ci(t,`parentId`),i=Ci(t,`transform`),a=Ci(t,`tags`),o=Ci(t,`layer`);return{...n===$r?{}:{name:Di(n,`Scene object name`)},...r===$r?{}:{parentId:ki(r,`Scene parent id`)},...i===$r?{}:{transform:pi(i)},...a===$r?{}:{tags:mi(a)},...o===$r?{}:{layer:Ai(o,`Scene layer`)}}}function pi(e){let t=xi(e,`Scene transform patch`);Si(t,[`position`,`rotation`,`scale`],`Scene transform patch`);let n=Ci(t,`position`),r=Ci(t,`rotation`),i=Ci(t,`scale`);return{...n===$r?{}:{position:hi(n,`Scene position`)},...r===$r?{}:{rotation:hi(r,`Scene rotation`)},...i===$r?{}:{scale:hi(i,`Scene scale`)}}}function mi(e){return ji(e,`Scene object tags`).map(e=>Di(e,`Scene object tag`))}function hi(e,t){let n=ji(e,t);if(n.length!==3)throw TypeError(`${t} must be a 3-tuple.`);let r=[0,0,0];for(let e=0;e<n.length;e++){let i=n[e];if(typeof i!=`number`||!Number.isFinite(i)||Object.is(i,-0))throw TypeError(`${t} must contain finite canonical numbers.`);r[e]=i}return r}function gi(e){let t=xi(e,`Created scene object`);Si(t,[`id`,`name`,`parentId`,`transform`,`components`,`tags`,`layer`],`Created scene object`);let n=Ti(t,`id`,`Created scene object id`),r=wi(t,`name`,`Created scene object name`),i=xi(X(t,`transform`,`Created scene object transform`),`Created scene object transform`);Si(i,[`position`,`rotation`,`scale`],`Created scene object transform`);let a=hi(X(i,`position`,`Created scene object position`),`Created scene object position`),o=hi(X(i,`rotation`,`Created scene object rotation`),`Created scene object rotation`),s=hi(X(i,`scale`,`Created scene object scale`),`Created scene object scale`),c=ji(X(t,`components`,`Created scene object components`),`Created scene object components`).map(bi),l=mi(X(t,`tags`,`Created scene object tags`)),u=Ci(t,`parentId`),d=Ci(t,`layer`);return{id:n,name:r,...u===$r?{}:{parentId:Oi(u,`Created scene parent id`)},transform:{position:a,rotation:o,scale:s},components:c,tags:l,...d===$r?{}:{layer:Di(d,`Created scene layer`)}}}function _i(e){return{...e,components:e.components.map(vi)}}function vi(e){return Un(e)}function yi(e,t){let n=xi(e,t);if(Si(n,[`version`,`id`,`name`,`objects`],t),X(n,`version`,`${t} version`)!==1)throw TypeError(`${t} version must be 1.`);Ti(n,`id`,`${t} id`);let r=Ci(n,`name`);r!==$r&&Di(r,`${t} name`);for(let e of ji(X(n,`objects`,`${t} objects`),`${t} objects`))gi(e)}function bi(e){let t=xi(e,`Scene component`);Si(t,[`id`,`type`,`enabled`,`data`],`Scene component`);let n=Ti(t,`id`,`Scene component id`),r=Ti(t,`type`,`Scene component type`),i=X(t,`enabled`,`Scene component enabled`);if(typeof i!=`boolean`)throw TypeError(`Scene component enabled must be boolean.`);let a=X(t,`data`,`Scene component data`);if(!Qn(a))throw TypeError(`Scene component data must contain only canonical JSON values.`);return{id:n,type:r,enabled:i,data:a}}function xi(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`${t} must be a plain data object.`);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`${t} must be a plain data object.`);for(let n of Reflect.ownKeys(e)){if(typeof n!=`string`)throw TypeError(`${t} must use string keys.`);let r=Object.getOwnPropertyDescriptor(e,n);if(!r?.enumerable||!(`value`in r))throw TypeError(`${t} must contain only enumerable data properties.`)}return e}function Si(e,t,n){let r=new Set(t);for(let t of Reflect.ownKeys(e))if(typeof t!=`string`||!r.has(t))throw TypeError(`${n} contains unsupported properties.`)}function Ci(e,t){let n=Object.getOwnPropertyDescriptor(e,t);if(n===void 0)return $r;if(!n.enumerable||!(`value`in n))throw TypeError(`Scene command property "${t}" must be enumerable data.`);return n.value}function X(e,t,n){let r=Ci(e,t);if(r===$r)throw TypeError(`${n} is required.`);return r}function wi(e,t,n){return Di(X(e,t,n),n)}function Ti(e,t,n){return Oi(X(e,t,n),n)}function Ei(e,t,n){return ki(X(e,t,n),n)}function Di(e,t){if(typeof e!=`string`)throw TypeError(`${t} must be a string.`);return e}function Oi(e,t){let n=Di(e,t);if(!n.trim())throw TypeError(`${t} must be a non-empty string.`);return n}function ki(e,t){return e===null?null:Oi(e,t)}function Ai(e,t){return e===null?null:Di(e,t)}function ji(e,t){if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)throw TypeError(`${t} must be an array.`);let n=Reflect.ownKeys(e);if(n.length!==e.length+1||!n.every(e=>e===`length`||typeof e==`string`&&/^0$|^[1-9]\d*$/.test(e)))throw TypeError(`${t} must be a dense data array.`);let r=[];for(let n=0;n<e.length;n++){let i=Object.getOwnPropertyDescriptor(e,String(n));if(!i?.enumerable||!(`value`in i))throw TypeError(`${t} must contain only data elements.`);r.push(i.value)}return r}function Mi(e,t){let n=Lr({accepted:!0,document:e,event:t});return Br(n.document),n}function Ni(e,t){let n=t.map(e=>Lr({...e}));return Object.freeze({accepted:!1,document:e,issues:Object.freeze(n)})}var Pi=1,Fi={tags:[]};function Ii(e){let t=(e.objects??[]).map(e=>Wn(e)),n=e.rootObjectIds??Bi(t);return{version:1,id:e.id,name:e.name??e.id,objects:t,rootObjectIds:n,metadata:{...Fi,...e.metadata,tags:[...e.metadata?.tags??Fi.tags]}}}function Li(e){return Ii({id:e.id,...e.name===void 0?{}:{name:e.name},objects:e.objects,...e.rootObjectIds===void 0?{}:{rootObjectIds:e.rootObjectIds},...e.metadata===void 0?{}:{metadata:e.metadata}})}function Ri(e){let t=[];e.version!==1&&t.push({code:`unsupported-prefab-version`,message:`Prefab document version must be 1.`}),(typeof e.id!=`string`||!e.id.trim())&&t.push({code:`invalid-prefab-id`,message:`Prefab id must be a non-empty string.`}),e.objects.length===0&&t.push({code:`empty-prefab`,message:`Prefab must contain at least one scene object.`});let n=Kn(Gn({id:`prefab:${e.id||`unknown`}`,objects:e.objects}));for(let e of n.issues)t.push({code:`invalid-prefab-scene`,...e.objectId===void 0?{}:{objectId:e.objectId},message:e.message});let r=new Set(e.objects.map(e=>e.id));for(let n of e.rootObjectIds)r.has(n)||t.push({code:`missing-root-object`,objectId:n,message:`Prefab root object "${n}" does not exist.`});for(let n of e.objects)n.parentId===void 0&&!e.rootObjectIds.includes(n.id)&&t.push({code:`invalid-root-object`,objectId:n.id,message:`Top-level object "${n.id}" must be listed in rootObjectIds.`});return{valid:t.length===0,issues:t}}function zi(e,t){let n=new Set(t),r=!0;for(;r;){r=!1;for(let t of e)t.parentId!==void 0&&n.has(t.parentId)&&!n.has(t.id)&&(n.add(t.id),r=!0)}return n}function Bi(e){let t=new Set(e.map(e=>e.id));return e.filter(e=>e.parentId===void 0||!t.has(e.parentId)).map(e=>e.id)}function Vi(e,t={}){let n=t.idPrefix??d.t(e.id),r=new Map;for(let t of e.objects)r.set(t.id,`${n}:${t.id}`);return e.objects.map(i=>{let a=r.get(i.id)??`${n}:${i.id}`,o=i.parentId===void 0?t.parentId:r.get(i.parentId),s=e.rootObjectIds.includes(i.id),c={...i};return delete c.parentId,{...c,id:a,name:t.nameSuffix?`${i.name}${t.nameSuffix}`:i.name,...o===void 0?{}:{parentId:o},transform:s&&t.rootTransform?Ui(i.transform,t.rootTransform):Wi(i.transform),components:i.components.map(e=>Hi(e,n)),tags:[...i.tags]}})}function Hi(e,t){return{...e,id:`${t}:${e.id}`,data:JSON.parse(JSON.stringify(e.data))}}function Ui(e,t){return{position:t.position?[...t.position]:[...e.position],rotation:t.rotation?[...t.rotation]:[...e.rotation],scale:t.scale?[...t.scale]:[...e.scale]}}function Wi(e){return{position:[...e.position],rotation:[...e.rotation],scale:[...e.scale]}}var Gi=[{path:`transform.position`,key:`position`},{path:`transform.rotation`,key:`rotation`},{path:`transform.scale`,key:`scale`}];function Ki(e,t){return JSON.stringify(e)===JSON.stringify(t)}function qi(e){return JSON.parse(JSON.stringify(e))}function Ji(e){return t=>`${e}:${t}`}function Yi(e){return e.type===K.prefabInstance}function Xi(e,t){return{id:`${t}:prefab-link`,type:K.prefabInstance,enabled:!0,data:{prefabId:e.prefabId,idPrefix:e.idPrefix}}}function Zi(e){let t=e.components.find(Yi),n=t?.data.prefabId,r=t?.data.idPrefix;return typeof n==`string`&&typeof r==`string`?{prefabId:n,idPrefix:r}:null}function Qi(e,t={}){let n=t.idPrefix??d.t(`${e.id}-instance`),r={prefabId:e.id,idPrefix:n},i=Ji(n),a=new Set(e.rootObjectIds.map(i));return{objects:Vi(e,{...t,idPrefix:n}).map(e=>a.has(e.id)?{...e,components:[...e.components,Xi(r,e.id)]}:e),link:r}}function $i(e,t){switch(t){case`name`:return e.name;case`tags`:return[...e.tags];case`layer`:return e.layer??null;case`transform.position`:return[...e.transform.position];case`transform.rotation`:return[...e.transform.rotation];case`transform.scale`:return[...e.transform.scale]}}function ea(e,t,n){switch(t){case`name`:return typeof n==`string`?{...e,name:n}:e;case`tags`:return Array.isArray(n)?{...e,tags:n.filter(e=>typeof e==`string`)}:e;case`layer`:{if(typeof n==`string`)return{...e,layer:n};let t={...e};return delete t.layer,t}default:{let r=Gi.find(e=>e.path===t);return!r||!Array.isArray(n)||n.length!==3?e:{...e,transform:{...e.transform,[r.key]:[...n]}}}}}function ta(e,t,n,r={}){let i=Ji(n.idPrefix),a=new Map(t.map(e=>[e.id,e])),o=new Set,s=[],c=new Set(e.rootObjectIds);for(let t of e.objects){let e=i(t.id);o.add(e);let n=a.get(e);if(!n){s.push({kind:`removedObject`,objectId:t.id});continue}let l=[`name`,`tags`,`layer`];(!c.has(t.id)||r.includeRootTransform)&&l.push(...Gi.map(e=>e.path));for(let e of l){let r=$i(n,e);Ki($i(t,e),r)||s.push({kind:`property`,objectId:t.id,path:e,value:r})}let u=new Set;for(let e of t.components){let r=i(e.id);u.add(r);let a=n.components.find(e=>e.id===r);a?(!Ki(e.data,a.data)||e.enabled!==a.enabled)&&s.push({kind:`componentData`,objectId:t.id,componentId:e.id,data:qi(a.data),enabled:a.enabled}):s.push({kind:`removedComponent`,objectId:t.id,componentId:e.id})}for(let e of n.components)u.has(e.id)||Yi(e)||s.push({kind:`addedComponent`,objectId:t.id,component:qi(e)})}for(let e of t)o.has(e.id)||s.push({kind:`addedObject`,object:qi(e)});return s}function na(e,t,n){let r=e,i=(e,t)=>{let i=n(e);r=r.map(e=>e.id===i?t(e):e)};for(let e of t)switch(e.kind){case`property`:i(e.objectId,t=>ea(t,e.path,e.value));break;case`componentData`:i(e.objectId,t=>({...t,components:t.components.map(t=>t.id===n(e.componentId)?{...t,data:qi(e.data),enabled:e.enabled}:t)}));break;case`addedComponent`:i(e.objectId,t=>t.components.some(t=>t.id===e.component.id)?t:{...t,components:[...t.components,qi(e.component)]});break;case`removedComponent`:i(e.objectId,t=>({...t,components:t.components.filter(t=>t.id!==n(e.componentId))}));break;case`addedObject`:r.some(t=>t.id===e.object.id)||(r=[...r,qi(e.object)]);break;case`removedObject`:{let t=zi(r,[n(e.objectId)]);r=r.filter(e=>!t.has(e.id));break}}return r}function ra(e,t,n){let{objects:r}=Qi(e,{idPrefix:n.idPrefix});return na(r,t,Ji(n.idPrefix))}function ia(e,t,n,r){return ra(t,ta(e,n,r,{includeRootTransform:!0}),r)}function aa(e,t){if(e.kind!==t.kind)return!1;switch(e.kind){case`property`:return t.kind===`property`&&e.objectId===t.objectId&&e.path===t.path;case`componentData`:return t.kind===`componentData`&&e.objectId===t.objectId&&e.componentId===t.componentId;case`addedComponent`:return t.kind===`addedComponent`&&e.objectId===t.objectId&&e.component.id===t.component.id;case`removedComponent`:return t.kind===`removedComponent`&&e.objectId===t.objectId&&e.componentId===t.componentId;case`addedObject`:return t.kind===`addedObject`&&e.object.id===t.object.id;case`removedObject`:return t.kind===`removedObject`&&e.objectId===t.objectId}}function oa(e,t,n,r){return ra(e,ta(e,t,n,{includeRootTransform:!0}).filter(e=>!aa(e,r)),n)}function sa(e,t,n){let r=`${n.idPrefix}:`,i=e=>e.startsWith(r)?e.slice(r.length):e,a=ta(e,t,n).map(e=>e.kind===`addedComponent`?{...e,component:{...e.component,id:i(e.component.id)}}:e.kind===`addedObject`?{kind:`addedObject`,object:{...e.object,id:i(e.object.id),...e.object.parentId===void 0?{}:{parentId:i(e.object.parentId)},components:e.object.components.filter(e=>!Yi(e))}}:e);return{...e,objects:na(qi(e.objects),a,e=>e),metadata:{...e.metadata,updatedAt:new Date().toISOString()}}}function ca(e,t){return{...e,id:t.id,name:t.name??`${e.name} Variant`,objects:na(qi(e.objects),t.overrides,e=>e),metadata:{...e.metadata,tags:[...e.metadata.tags],sourceSceneId:e.id}}}var la=`transform.`;function ua(e,t){let n=`${t.idPrefix}:`,r=zi(e,e.filter(e=>e.id.startsWith(n)).map(e=>e.id));return e.filter(e=>r.has(e.id))}function da(e,t){let n=e.objects.find(e=>e.id===t);return n?Zi(n):null}function fa(e,t){let n=new Set(e.map(e=>e.id)),r=new Map;return e.forEach(e=>{e.parentId!==void 0&&!n.has(e.parentId)&&r.set(e.id,e.parentId)}),t.map(e=>{let t=r.get(e.id);return t!==void 0&&e.parentId===void 0?{...e,parentId:t}:e})}function pa(e,t,n){let r=new Set(t.map(e=>e.id)),i=e.objects.findIndex(e=>r.has(e.id)),a=e.objects.filter(e=>!r.has(e.id)),o=i<0?a.length:i;return{...e,objects:[...a.slice(0,o),...n,...a.slice(o)]}}function ma(e,t,n){let r=ua(e.objects,t);return pa(e,r,fa(r,n(r)))}function ha(e,t,n){return{...e,objects:[...e.objects,...Qi(t,n).objects]}}function ga(e,t,n,r){let i=e.objects.find(e=>e.id===t);if(!i)return e;let a=zi(e.objects,[t]),{objects:o}=Qi(n,{idPrefix:r,rootTransform:i.transform,...i.parentId===void 0?{}:{parentId:i.parentId}});return pa(e,e.objects.filter(e=>a.has(e.id)),o)}function _a(e,t,n,r){return ma(e,n,e=>oa(t,e,n,r))}function va(e,t,n){let r=new Set(t.rootObjectIds);return ma(e,n,e=>ra(t,ta(t,e,n,{includeRootTransform:!0}).filter(e=>e.kind===`property`&&r.has(e.objectId)&&e.path.startsWith(la)),n))}function ya(e,t,n){let r=new Map;e.objects.forEach(e=>{let t=Zi(e);t?.prefabId===n.id&&r.set(t.idPrefix,t)});let i=e;return r.forEach(e=>{i=ma(i,e,r=>ia(t,n,r,e))}),i}function ba({document:e,object:t,prefabs:n,onCreate:r,onRevertOverride:i,onRevertAll:a,onApply:o}){let s=(0,b.useMemo)(()=>Zi(t),[t]),c=s?n.find(e=>e.id===s.prefabId):void 0,l=(0,b.useMemo)(()=>s&&c?ta(c,ua(e.objects,s),s):[],[e,s,c]);return s?c?(0,C.jsxs)(`section`,{className:`prop-group`,children:[(0,C.jsxs)(`div`,{className:`inspector-section-header`,children:[(0,C.jsxs)(`h4`,{className:`prop-group-title`,children:[`프리팹 · `,c.name]}),(0,C.jsx)(`span`,{className:`object-tag`,children:l.length})]}),(0,C.jsx)(`div`,{className:`inspector-component-list`,children:l.length===0?(0,C.jsx)(`div`,{className:`inspector-component-empty`,children:`원본과 같습니다`}):l.map((e,n)=>(0,C.jsxs)(`div`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:Bn(c,e)}),i&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>i(t.id,c,e),children:`되돌리기`})]},`${e.kind}-${n}`))}),(0,C.jsxs)(`div`,{className:`inspector-add-component`,children:[a&&(0,C.jsx)(`button`,{type:`button`,disabled:l.length===0,onClick:()=>a(t.id,c),children:`모두 되돌리기`}),o&&(0,C.jsx)(`button`,{type:`button`,disabled:l.length===0,onClick:()=>o(t.id,c),children:`프리팹에 적용`})]})]}):(0,C.jsxs)(`section`,{className:`prop-group`,children:[(0,C.jsx)(`h4`,{className:`prop-group-title`,children:`프리팹`}),(0,C.jsxs)(`div`,{className:`inspector-component-empty`,children:[`원본 프리팹을 찾을 수 없습니다 (`,s.prefabId,`)`]})]}):r?(0,C.jsxs)(`section`,{className:`prop-group`,children:[(0,C.jsx)(`h4`,{className:`prop-group-title`,children:`프리팹`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>r(t.id),children:`프리팹으로 만들기`})]}):null}function xa(e){return e==null?`-`:Array.isArray(e)?`[${e.join(`, `)}]`:String(e)}function Sa({name:e,schema:t,value:n,onChange:r}){if(!r)return(0,C.jsxs)(`span`,{className:`prop-value prop-value--readonly`,children:[t.kind,` · `,xa(n)]});switch(t.kind){case`number`:return(0,C.jsx)(`input`,{type:`number`,"aria-label":e,defaultValue:typeof n==`number`?n:t.default,...t.min===void 0?{}:{min:t.min},...t.max===void 0?{}:{max:t.max},onBlur:t=>{let i=Number(t.target.value);Number.isFinite(i)&&i!==n&&r(e,i)}},String(n));case`boolean`:return(0,C.jsx)(`input`,{type:`checkbox`,"aria-label":e,checked:n===!0,onChange:t=>r(e,t.target.checked)});case`enum`:return(0,C.jsx)(`select`,{"aria-label":e,value:String(n),onChange:t=>r(e,t.target.value),children:t.values.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))});case`color`:return(0,C.jsx)(`input`,{type:`color`,"aria-label":e,value:typeof n==`string`?n:t.default,onChange:t=>r(e,t.target.value)});case`string`:return(0,C.jsx)(`input`,{type:`text`,"aria-label":e,defaultValue:typeof n==`string`?n:t.default,onBlur:t=>{t.target.value!==n&&r(e,t.target.value)}},String(n));default:return(0,C.jsxs)(`span`,{className:`prop-value prop-value--readonly`,children:[t.kind,` · `,xa(n)]})}}var Ca=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,wa={number:e=>({kind:`number`,...e}),boolean:e=>({kind:`boolean`,...e}),string:e=>({kind:`string`,...e}),enum:e=>({kind:`enum`,...e}),vector3:e=>({kind:`vector3`,...e}),color:e=>({kind:`color`,...e}),assetRef:e=>({kind:`assetRef`,...e}),objectRef:e=>({kind:`objectRef`,...e})};function Ta(e){return Array.isArray(e)&&e.length===3&&e.every(e=>typeof e==`number`&&Number.isFinite(e))}function Ea(e,t){if(t===void 0)return{value:e.default};switch(e.kind){case`number`:{if(typeof t!=`number`||!Number.isFinite(t))return{value:e.default,issue:`숫자가 아닙니다`};let n=e.min??-1/0,r=e.max??1/0;return t<n||t>r?{value:Math.min(r,Math.max(n,t)),issue:`범위(${n}~${r})를 벗어났습니다`}:{value:t}}case`boolean`:return typeof t==`boolean`?{value:t}:{value:e.default,issue:`불리언이 아닙니다`};case`string`:return typeof t==`string`?{value:t}:{value:e.default,issue:`문자열이 아닙니다`};case`enum`:return typeof t==`string`&&e.values.includes(t)?{value:t}:{value:e.default,issue:`허용 값이 아닙니다: ${String(t)}`};case`vector3`:return Ta(t)?{value:t}:{value:e.default,issue:`[x, y, z] 형식이 아닙니다`};case`color`:return typeof t==`string`&&Ca.test(t)?{value:t}:{value:e.default,issue:`#RGB 또는 #RRGGBB 형식이 아닙니다`};case`assetRef`:case`objectRef`:return t===null||typeof t==`string`&&t.trim().length>0?{value:t}:{value:e.default,issue:`참조 id 형식이 아닙니다`}}}function Da(e,t){let n={},r=[];for(let[i,a]of Object.entries(e)){let e=Ea(a,t?.[i]);n[i]=e.value,e.issue&&r.push({prop:i,message:e.issue})}return{props:n,issues:r}}var Oa=new Map;function ka(e){if(!e.id.trim())throw Error(`[ScriptRegistry Error]: 스크립트 id가 비어 있습니다`);return e}function Aa(e){let t=e;return Oa.set(e.id,t),()=>{Oa.get(e.id)===t&&Oa.delete(e.id)}}function ja(e){return Oa.get(e)}function Ma(){return Array.from(Oa.values())}function Na(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pa({data:e,onChange:t}){let n=typeof e.scriptId==`string`?e.scriptId:``,r=n?ja(n):void 0,i=e.props,a=Na(i)?i:void 0;if(!r)return(0,C.jsxs)(`div`,{className:`inspector-script inspector-script--missing`,children:[(0,C.jsxs)(`div`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:`스크립트`}),(0,C.jsx)(`span`,{className:`prop-value prop-value--readonly`,children:n||`(지정 안 됨)`})]}),(0,C.jsx)(`div`,{className:`inspector-component-empty`,children:`등록되지 않은 스크립트입니다`})]});let{props:o,issues:s}=Da(r.props,a),c=o,l=t?(n,r)=>t({...e,props:{...a,[n]:r}}):void 0;return(0,C.jsxs)(`div`,{className:`inspector-script`,children:[(0,C.jsxs)(`div`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:`스크립트`}),(0,C.jsx)(`span`,{className:`prop-value prop-value--readonly`,children:r.name??r.id})]}),Object.entries(r.props).map(([e,t])=>(0,C.jsxs)(`label`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:e}),(0,C.jsx)(Sa,{name:e,schema:t,value:c[e],...l?{onChange:l}:{}})]},e)),s.map(e=>(0,C.jsxs)(`div`,{className:`inspector-component-empty`,children:[e.prop,`: `,e.message]},e.prop))]})}function Fa({onAdd:e}){let t=Ma(),[n,r]=(0,b.useState)(``);if(t.length===0)return null;let i=t.some(e=>e.id===n)?n:t[0].id;return(0,C.jsxs)(`div`,{className:`inspector-add-component`,children:[(0,C.jsx)(`select`,{"aria-label":`추가할 스크립트`,value:i,onChange:e=>r(e.target.value),children:t.map(e=>(0,C.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>e(i),children:`스크립트 추가`})]})}var Ia=[`X`,`Y`,`Z`];function La({sceneDocument:e,selectedObjectId:t,selectedObject:n,emptyLabel:r=`장면에서 객체를 선택하세요`,onUpdateObject:i,onAddComponent:a,onRemoveComponent:o,onUpdateComponent:s,prefab:c,className:l=``,style:u,children:d}={}){let f=(0,b.useMemo)(()=>n??e?.objects.find(e=>e.id===t),[e,n,t]),[p,m]=(0,b.useState)(``);if(!f)return(0,C.jsxs)(`div`,{className:`inspector-panel empty ${l}`,style:u,children:[r,d]});let h=(e,t,n)=>{let r=[...f.transform[e]];r[t]=n,i?.(f.id,{transform:{[e]:r}})},g=()=>{let e=p.trim();e&&(a?.(f.id,{type:e,data:{}}),m(``))};return(0,C.jsxs)(`div`,{className:`inspector-panel inspector-panel--scene-object ${l}`,style:u,children:[(0,C.jsxs)(`div`,{className:`inspector-header`,children:[(0,C.jsx)(`h3`,{children:f.name||f.id}),(0,C.jsx)(`span`,{className:`object-tag`,children:f.id})]}),(0,C.jsxs)(`section`,{className:`prop-group`,children:[(0,C.jsx)(`h4`,{className:`prop-group-title`,children:`객체`}),(0,C.jsx)(Ra,{label:`이름`,value:f.name,onChange:e=>i?.(f.id,{name:e})}),(0,C.jsx)(Ra,{label:`레이어`,value:f.layer??``,onChange:e=>i?.(f.id,{layer:e||void 0})}),(0,C.jsxs)(`label`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:`태그`}),(0,C.jsx)(`span`,{className:`prop-value`,children:(0,C.jsx)(`input`,{type:`text`,defaultValue:f.tags.join(`, `),placeholder:`쉼표로 구분해서 입력`,onBlur:e=>{let t=e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean);e.target.value=t.join(`, `),(t.length!==f.tags.length||t.some((e,t)=>e!==f.tags[t]))&&i?.(f.id,{tags:t})},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.currentTarget.blur()}},JSON.stringify([f.id,f.tags]))})]}),(0,C.jsx)(za,{label:`상위 객체`,value:f.parentId??`최상위`})]}),c&&e&&(0,C.jsx)(ba,{...c,document:e,object:f}),(0,C.jsxs)(`section`,{className:`prop-group`,children:[(0,C.jsx)(`h4`,{className:`prop-group-title`,children:`위치·회전·크기`}),(0,C.jsx)(Ba,{label:`위치`,value:f.transform.position,onChange:(e,t)=>h(`position`,e,t)}),(0,C.jsx)(Ba,{label:`회전 (라디안)`,value:f.transform.rotation,onChange:(e,t)=>h(`rotation`,e,t)}),(0,C.jsx)(Ba,{label:`배율`,value:f.transform.scale,onChange:(e,t)=>h(`scale`,e,t)})]},f.id),(0,C.jsxs)(`section`,{className:`prop-group`,children:[(0,C.jsxs)(`div`,{className:`inspector-section-header`,children:[(0,C.jsx)(`h4`,{className:`prop-group-title`,children:`구성 요소`}),(0,C.jsx)(`span`,{className:`object-tag`,children:f.components.length})]}),(0,C.jsx)(`div`,{className:`inspector-component-list`,children:f.components.length===0?(0,C.jsx)(`div`,{className:`inspector-component-empty`,children:`구성 요소가 없습니다`}):f.components.map(e=>(0,C.jsx)(Va,{component:e,onRemove:()=>o?.(f.id,e.id),...s?{onChange:t=>s(f.id,e.id,t)}:{}},e.id))}),(0,C.jsxs)(`div`,{className:`inspector-add-component`,children:[(0,C.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:`구성 요소 유형 (예: game.health)`,"aria-label":`새 구성 요소 유형`}),(0,C.jsx)(`button`,{type:`button`,onClick:g,disabled:!p.trim(),children:`추가`})]}),a&&(0,C.jsx)(Fa,{onAdd:e=>a(f.id,{type:K.script,data:{scriptId:e,props:{}}})})]}),d]})}function Ra({label:e,value:t,onChange:n}){return(0,C.jsxs)(`label`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:e}),(0,C.jsx)(`span`,{className:`prop-value`,children:(0,C.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value)})})]})}function za({label:e,value:t}){return(0,C.jsxs)(`div`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:e}),(0,C.jsx)(`span`,{className:`prop-value prop-value--readonly`,children:t})]})}function Ba({label:e,value:t,onChange:n}){return(0,C.jsxs)(`div`,{className:`prop-item`,children:[(0,C.jsx)(`span`,{className:`prop-label`,children:e}),(0,C.jsx)(`span`,{className:`prop-value vector-input`,children:t.map((t,r)=>(0,C.jsxs)(`label`,{className:`vector-input__field`,children:[(0,C.jsx)(`span`,{children:Ia[r]}),(0,C.jsx)(`input`,{type:`number`,step:`any`,"aria-label":`${e} ${Ia[r]}`,defaultValue:t,onBlur:e=>{let i=e.currentTarget.valueAsNumber;if(!Number.isFinite(i)){e.currentTarget.value=String(t);return}i!==t&&n(r,i)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.currentTarget.blur()}},t)]},`${e}-${Ia[r]}`))})]})}function Va({component:e,onRemove:t,onChange:n}){return(0,C.jsxs)(`article`,{className:`inspector-component`,children:[(0,C.jsxs)(`header`,{className:`inspector-component__header`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`strong`,{children:e.type}),(0,C.jsx)(`span`,{children:e.id})]}),(0,C.jsx)(`button`,{type:`button`,onClick:t,children:`삭제`})]}),e.type===K.animator?(0,C.jsx)(zn,{data:e.data}):e.type===K.script?(0,C.jsx)(Pa,{data:e.data,...n?{onChange:n}:{}}):(0,C.jsx)(`pre`,{children:JSON.stringify(e.data,null,2)})]})}var Ha=[{id:`assets`,label:`에셋`},{id:`materials`,label:`재질`},{id:`scenes`,label:`장면`},{id:`prefabs`,label:`프리팹`}],Ua=[`all`,`characterPart`,`weapon`,`material`,`tile`,`wall`,`object3d`],Wa={tabs:{assets:`에셋`,materials:`재질`,scenes:`장면`,prefabs:`프리팹`},tabsAriaLabel:`프로젝트 항목 분류`,searchPlaceholder:`프로젝트 검색`,searchAriaLabel:`프로젝트 에셋 검색`,kindFilterAriaLabel:`에셋 종류`,empty:`프로젝트 항목이 없습니다`,statusItems:e=>`${e}개 항목`,statusFallback:`상태 확인 중`},Ga={all:`전체`,characterPart:`캐릭터 부품`,weapon:`무기`,material:`재질`,tile:`바닥`,wall:`벽`,object3d:`입체 소품`,scene:`장면`,prefab:`프리팹`,body:`몸`,hair:`머리카락`,hat:`모자`,top:`상의`,bottom:`하의`,shoes:`신발`,face:`얼굴`,shield:`방패`,accessory:`장신구`,glasses:`안경`,seed:`기본 에셋`,loading:`불러오는 중`,loaded:`불러오기 완료`,fallback:`기본 에셋 사용 중`,starter:`기본`,cloth:`의상`,"local-variant":`색상 변형`,generated:`생성 에셋`,placeholder:`임시 에셋`,building:`건축`,brick:`벽돌`,wood:`목재`,glass:`유리`,prop:`소품`,door:`문`,window:`창문`,fence:`울타리`,lamp:`조명`,chair:`의자`,table:`탁자`,bed:`침대`,storage:`수납`,mailbox:`우편함`,crafting:`제작`,shop:`상점`,cc0:`CC0`},Ka={root:`project-assets-panel`,toolbar:`project-assets-panel__toolbar`,tabs:`project-assets-panel__tabs`,tab:`project-assets-panel__tab`,activeTab:`active project-assets-panel__tab--active`,searchInput:`project-assets-panel__search`,kindSelect:`project-assets-panel__kind`,status:`project-assets-panel__status`,statusCount:`project-assets-panel__status-count`,statusCatalog:`project-assets-panel__status-catalog`,list:`project-assets-panel__list`,empty:`project-assets-panel__empty`,item:`project-assets-panel__item`,activeItem:`active project-assets-panel__item--active`,thumb:`project-assets-panel__thumb`,itemMain:`project-assets-panel__item-main`,itemName:`project-assets-panel__item-name`,itemSubtitle:`project-assets-panel__item-subtitle`,badges:`project-assets-panel__badges`,badge:`project-assets-panel__badge`};function qa(...e){return e.filter(e=>!!e).join(` `)}function Ja(e){return{...Wa,...e,tabs:{...Wa.tabs,...e?.tabs}}}function Ya(e,t,n){return{...n,...e?.[t]}}function Xa(e,t){return e.map(e=>({...e,label:t.tabs[e.id]??e.label}))}function Za(e){let t=(e.assets??[]).map(e=>({id:e.id,name:e.name,kind:e.kind,group:e.kind===`material`?`materials`:`assets`,...e.slot?{subtitle:e.slot}:{},...e.thumbnailUrl?{thumbnailUrl:e.thumbnailUrl}:{},tags:e.tags??[],source:e})),n=(e.scenes??[]).map(e=>({id:e.id,name:e.name??e.id,kind:`scene`,group:`scenes`,subtitle:`오브젝트 ${e.objects.length}개`,tags:[],source:e})),r=(e.prefabs??[]).map(e=>{let t=e.description??e.metadata?.description,n=e.thumbnailUrl??e.metadata?.thumbnailUrl;return{id:e.id,name:e.name,kind:`prefab`,group:`prefabs`,...t?{subtitle:t}:{},...n?{thumbnailUrl:n}:{},tags:e.tags??e.metadata?.tags??[],source:e}});return[...t,...n,...r]}function Qa(e,t){let n=t.query?.trim().toLowerCase(),r=e=>!!(n&&(e.toLowerCase().includes(n)||Ga[e]?.toLowerCase().includes(n)));return e.filter(e=>t.tab&&e.group!==t.tab||t.kind&&t.kind!==`all`&&e.kind!==t.kind?!1:!n||e.id.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)||r(e.kind)||e.subtitle&&(e.group===`assets`||e.group===`materials`?r(e.subtitle):e.subtitle.toLowerCase().includes(n))||e.tags.some(r))}function $a(e,t){return(0,C.jsx)(`span`,{className:e.classNameFor(`thumb`),style:e.styleFor(`thumb`),children:t.thumbnailUrl?(0,C.jsx)(`img`,{alt:``,src:t.thumbnailUrl}):(Ga[t.kind]??t.kind).slice(0,2)})}function eo(e,t,n){let r=e.activeId===n.id;return t?.item?t.item(e,n,r):(0,C.jsx)(`div`,{role:`listitem`,children:(0,C.jsxs)(`button`,{className:e.classNameFor(`item`,r?e.classNameFor(`activeItem`):void 0),onClick:()=>e.actions.selectItem(n),"aria-pressed":r,style:e.styleFor(`item`),type:`button`,children:[$a(e,n),(0,C.jsxs)(`span`,{className:e.classNameFor(`itemMain`),style:e.styleFor(`itemMain`),children:[(0,C.jsx)(`strong`,{className:e.classNameFor(`itemName`),style:e.styleFor(`itemName`),children:n.name}),(0,C.jsx)(`span`,{className:e.classNameFor(`itemSubtitle`),style:e.styleFor(`itemSubtitle`),children:n.subtitle?n.group===`assets`||n.group===`materials`?Ga[n.subtitle]??n.subtitle:n.subtitle:Ga[n.kind]??n.kind})]}),(0,C.jsxs)(`span`,{className:e.classNameFor(`badges`),style:e.styleFor(`badges`),children:[(0,C.jsx)(`span`,{className:e.classNameFor(`badge`),style:e.styleFor(`badge`),children:Ga[n.kind]??n.kind}),n.tags.slice(0,2).map(t=>(0,C.jsx)(`span`,{className:e.classNameFor(`badge`),style:e.styleFor(`badge`),children:Ga[t]??t},t))]})]})},`${n.group}:${n.id}`)}function to(e,t){let n=e.items.length===0?t?.empty?.(e)??(0,C.jsx)(`div`,{className:e.classNameFor(`empty`),style:e.styleFor(`empty`),children:e.labels.empty}):e.items.map(n=>eo(e,t,n));return t?.list?t.list(e,n):(0,C.jsx)(`div`,{className:e.classNameFor(`list`),role:`list`,style:e.styleFor(`list`),children:n})}function no(e,t,n){let r=n.id===e.activeTab;return t?.tab?t.tab(e,n,r):(0,C.jsx)(`button`,{"aria-pressed":r,className:e.classNameFor(`tab`,r?e.classNameFor(`activeTab`):void 0),disabled:n.disabled,onClick:()=>e.actions.setTab(n.id),style:e.styleFor(`tab`),type:`button`,children:n.label},n.id)}function ro(e,t){let n=e.tabs.map(n=>no(e,t,n));return t?.tabs?t.tabs(e,n):(0,C.jsx)(`div`,{"aria-label":e.labels.tabsAriaLabel,className:e.classNameFor(`tabs`),role:`group`,style:e.styleFor(`tabs`),children:n})}function io(e,t){return t?.search?t.search(e):(0,C.jsx)(`input`,{"aria-label":e.labels.searchAriaLabel,className:e.classNameFor(`searchInput`),onChange:t=>e.actions.setQuery(t.target.value),placeholder:e.labels.searchPlaceholder,style:e.styleFor(`searchInput`),type:`search`,value:e.query})}function ao(e,t){return t?.kindFilter?t.kindFilter(e):(0,C.jsx)(`select`,{"aria-label":e.labels.kindFilterAriaLabel,className:e.classNameFor(`kindSelect`),disabled:e.activeTab!==`assets`,onChange:t=>e.actions.setKind(t.target.value),style:e.styleFor(`kindSelect`),value:e.kind,children:e.kindOptions.map(e=>(0,C.jsx)(`option`,{value:e,children:Ga[e]??e},e))})}function oo(e,t){let n=(0,C.jsxs)(C.Fragment,{children:[ro(e,t),io(e,t),ao(e,t)]});return t?.toolbar?t.toolbar(e,n):(0,C.jsx)(`div`,{className:e.classNameFor(`toolbar`),style:e.styleFor(`toolbar`),children:n})}function so(e,t){return t?.status?t.status(e):(0,C.jsxs)(`div`,{className:e.classNameFor(`status`),style:e.styleFor(`status`),children:[(0,C.jsx)(`span`,{className:e.classNameFor(`statusCount`),style:e.styleFor(`statusCount`),children:e.labels.statusItems(e.items.length)}),(0,C.jsx)(`span`,{className:e.classNameFor(`statusCatalog`),style:e.styleFor(`statusCatalog`),children:e.catalogStatus?Ga[e.catalogStatus.state]??e.labels.statusFallback:e.labels.statusFallback})]})}function co(e,t,n){return(0,C.jsxs)(C.Fragment,{children:[oo(e,t),so(e,t),to(e,t),n]})}function lo({assets:e,scenes:t=[],prefabs:n=[],activeTab:r,defaultTab:i=`assets`,query:a,defaultQuery:s=``,kind:c,defaultKind:l=`all`,tabs:u=Ha,kindOptions:d=Ua,selectedItemId:f,labels:p,className:m,style:h,classNames:g,styles:_,renderers:v,onTabChange:y,onQueryChange:x,onKindChange:S,onSelectItem:w,children:T}={}){let E=o.i(e=>e.ids),D=o.i(e=>e.records),O=o.i(e=>e.catalogStatus),k=o.i(e=>e.selectedId),A=o.i(e=>e.selectAsset),[j,M]=(0,b.useState)(i),[N,P]=(0,b.useState)(s),[F,I]=(0,b.useState)(l),L=r??j,R=a??N,z=c??F,B=(0,b.useMemo)(()=>Ja(p),[p]),V=(0,b.useMemo)(()=>Xa(u,B),[B,u]),ee=(0,b.useMemo)(()=>E.map(e=>D[e]).filter(e=>!!e),[E,D]),H=e??ee,te=(0,b.useMemo)(()=>Za({assets:H,scenes:t,prefabs:n}),[H,n,t]),ne=(0,b.useMemo)(()=>Qa(te,{tab:L,query:R,kind:L===`assets`?z:`all`}),[te,z,R,L]),re=f??k,ie=(0,b.useCallback)(e=>{r===void 0&&M(e),y?.(e)},[r,y]),ae=(0,b.useCallback)(e=>{a===void 0&&P(e),x?.(e)},[x,a]),oe=(0,b.useCallback)(e=>{c===void 0&&I(e),S?.(e)},[c,S]),se=(0,b.useCallback)(e=>{(e.group===`assets`||e.group===`materials`)&&A(e.id),w?.(e)},[w,A]),ce=(0,b.useCallback)((e,t)=>qa(Ka[e],g?.[e],e===`root`&&m,t),[m,g]),le=(0,b.useCallback)((e,t)=>{let n=Ya(_,e,t);return e===`root`?{...n,...h}:n},[h,_]),ue=(0,b.useMemo)(()=>({activeTab:L,query:R,kind:z,tabs:V,kindOptions:d,items:ne,allItems:te,activeId:re,catalogStatus:O,labels:B,classNameFor:ce,styleFor:le,actions:{setTab:ie,setQuery:ae,setKind:oe,selectItem:se}}),[re,te,O,ce,z,R,L,oe,ae,se,ie,ne,d,B,V,le]),de=co(ue,v,T);return v?.root?(0,C.jsx)(C.Fragment,{children:v.root(ue,de)}):(0,C.jsx)(`div`,{className:ue.classNameFor(`root`),style:ue.styleFor(`root`),children:de})}var uo=[{type:`character`,label:`캐릭터`,description:`캐릭터로 걸어 다닙니다`},{type:`vehicle`,label:`차량`,description:`차량을 운전합니다`},{type:`airplane`,label:`비행기`,description:`비행기를 조종합니다`}],fo=({className:e=``,style:t,children:n})=>{let r=u.o(e=>e.mode.type),i=u.o(e=>e.setMode),a=e=>{i({type:e,controller:`keyboard`,control:e===`airplane`||e===`vehicle`?`chase`:`thirdPerson`})};return(0,C.jsxs)(`div`,{className:`vehicle-panel ${e}`,style:t,children:[(0,C.jsx)(`div`,{className:`vehicle-panel__modes`,children:uo.map(e=>(0,C.jsxs)(`button`,{type:`button`,"aria-pressed":r===e.type,className:`vehicle-panel__mode-button ${r===e.type?`vehicle-panel__mode-button--active`:``}`,onClick:()=>a(e.type),children:[(0,C.jsx)(`span`,{className:`vehicle-panel__mode-label`,children:e.label}),(0,C.jsx)(`span`,{className:`vehicle-panel__mode-description`,children:e.description})]},e.type))}),(0,C.jsxs)(`div`,{className:`vehicle-panel__info`,children:[(0,C.jsxs)(`div`,{className:`vehicle-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`vehicle-panel__info-label`,children:`현재 모드:`}),(0,C.jsx)(`span`,{className:`vehicle-panel__info-value`,children:uo.find(e=>e.type===r)?.label??r})]}),(0,C.jsxs)(`div`,{className:`vehicle-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`vehicle-panel__info-label`,children:`조작:`}),(0,C.jsx)(`span`,{className:`vehicle-panel__info-value`,children:r===`airplane`?`WASD + 스페이스/Shift`:`WASD + 스페이스`})]})]}),n]})},po={none:`사용 안 함`,scripted:`스크립트`,llm:`언어 모델`,reinforcement:`강화 학습`,idle:`대기`,moveTo:`지점 이동`,patrol:`순찰`,wander:`배회`,playAnimation:`애니메이션 재생`,moving:`이동 중`,arrived:`도착`,walk:`걷기`,run:`달리기`,jump:`점프`,greet:`인사`,lookAt:`바라보기`,speak:`말하기`,interact:`상호작용`,remember:`기억 저장`,moveToTarget:`대상 이동`,always:`항상`,navigationIdle:`이동 대기 중`,perceivedAny:`대상 감지`,perceivedEntered:`새 대상 감지`,memoryEquals:`기억 값 일치`,point:`지점`,self:`자신`,nearestPerceived:`가장 가까운 감지 대상`,next:`다음`,true:`참`,false:`거짓`};function Z(e){return po[e]??e}var mo=e=>e.kind===`material`||e.kind===`wall`||e.kind===`tile`;function ho(e,t){let n=JSON.stringify({...t,id:``}),r=2166136261;for(let e=0;e<n.length;e++)r=Math.imul(r^n.charCodeAt(e),16777619);return`${e}-${(r>>>0).toString(36)}`}function go(e,t,n){let{mapTextureUrl:r,textureUrl:i,materialParams:a,...o}=n??{};return{...o,id:e,color:t,material:`STANDARD`,materialParams:{...a??{},color:t}}}function _o(){return{id:d.t(`condition-idle`),type:`condition`,label:`이동 대기`,condition:{type:`navigationIdle`}}}function vo(e,t){return e===`speak`?{id:d.t(`speak`),type:`action`,label:`말하기`,action:{type:`speak`,text:`안녕?`,duration:2}}:{id:d.t(`wander`),type:`action`,label:`배회`,action:{type:`wander`,radius:t?.wanderRadius??4,speed:t?.speed??2.2}}}function yo(e){return e.label?e.label:e.type===`start`?`시작`:e.type===`condition`?`조건: ${Z(e.condition.type)}`:`행동: ${Z(e.action.type)}`}function bo(e){return e.type===`start`?`블루프린트 실행 시작점`:e.type===`condition`?Z(e.condition.type):e.action.type===`moveToTarget`?`${Z(e.action.target.type)} 이동`:e.action.type===`speak`?e.action.text:e.action.type===`playAnimation`?e.action.animationId:Z(e.action.type)}function xo(e,t){let n=e.nodes[e.nodes.length-1],r=n?{id:`${n.id}-${t.id}`,source:n.id,target:t.id,branch:`next`}:void 0;return{...e,nodes:[...e.nodes,t],edges:r?[...e.edges,r]:e.edges}}function So(e,t,n){if(t.type!==`condition`)return xo(e,t);let r=xo(e,t),i=vo(`wander`,n),a=vo(`speak`,n),o={...i,label:i.label??`참 경로`},s={...a,label:a.label??`거짓 경로`};return{...r,nodes:[...r.nodes,o,s],edges:[...r.edges,{id:`${t.id}-true-${o.id}`,source:t.id,target:o.id,branch:`true`},{id:`${t.id}-false-${s.id}`,source:t.id,target:s.id,branch:`false`}]}}function Co(e,t){let n=e.nodes.find(e=>e.id===t);return!n||n.type===`start`?e:{...e,nodes:e.nodes.filter(e=>e.id!==t),edges:e.edges.filter(e=>e.source!==t&&e.target!==t)}}function wo(e){return{...e,nodes:[{id:`start`,type:`start`,label:`시작`}],edges:[]}}function To(e,t){return{...e,id:d.t(`npc-custom-${t}`),name:`${e.name} 사본`,description:e.description?`${e.description} ${t} 전용 사본.`:`${t} 전용 사본.`,nodes:e.nodes.map(e=>({...e})),edges:e.edges.map(e=>({...e}))}}function Eo(e,t){let n=new Map(e.nodes.map(e=>[e.id,e])),r=e.edges.filter(e=>e.source===t);return r.length===0?`다음 없음`:r.map(e=>{let t=n.get(e.target);return`${Z(e.branch??`next`)} → ${t?yo(t):e.target}`}).join(` · `)}function Q(e){return l.Ut((0,w.useShallow)(t=>{let n={};for(let r of e)n[r]=t[r];return n}))}function Do({wallGroups:e,selectedWallId:t,selectedWallGroupId:n}){if(!t)return{group:e.get(n??``),wall:void 0};for(let n of e.values()){let e=n.walls.find(e=>e.id===t);if(e)return{group:n,wall:e}}return{group:void 0,wall:void 0}}function Oo({tileGroups:e,selectedTileId:t,selectedTileGroupId:n}){if(!t)return{group:e.get(n??``),tile:void 0};for(let n of e.values()){let e=n.tiles.find(e=>e.id===t);if(e)return{group:n,tile:e}}return{group:void 0,tile:void 0}}var ko=[`wallGroups`,`selectedWallId`,`selectedWallGroupId`],Ao=[`tileGroups`,`selectedTileId`,`selectedTileGroupId`];function jo(){let e=Q(ko);return(0,b.useMemo)(()=>Do(e),[e])}function Mo(){let e=Q(Ao);return(0,b.useMemo)(()=>Oo(e),[e])}function No(){let e=o.i(e=>e.ids),t=o.i(e=>e.records);return(0,b.useMemo)(()=>e.map(e=>t[e]).filter(e=>!!e).filter(mo),[e,t])}function Po(e,t,n){let r=ho(t,n),i=e.getState();return i.meshes.has(r)||i.addMesh({...n,id:r}),r}function Fo(e,t,n,r,i){let{meshes:a,addMesh:o,updateMesh:s}=e.getState(),c=g.i(n,r,i.id),l=g.r(c,i,t?a.get(t):void 0);return a.has(c)?s(c,l):o(l),c}function Io(e,t){let n=e.getState(),{group:r,wall:i}=Do(n);if(r){if(n.selectedWallId){let a=Fo(e,i?.materialId??r.frontMeshId,n.selectedWallId,`wall`,t);n.updateWall(r.id,n.selectedWallId,{materialId:a});return}n.setCurrentWallMaterialId(Po(e,`placement-wall`,g.r(``,t,r.frontMeshId?n.meshes.get(r.frontMeshId):void 0)))}}function Lo(e,t){let n=e.getState(),{group:r,tile:i}=Oo(n);if(r){if(n.selectedTileId){let a=Fo(e,i?.materialId??r.floorMeshId,n.selectedTileId,`tile`,t);n.updateTile(r.id,n.selectedTileId,{materialId:a});return}n.setCurrentTileMaterialId(Po(e,`placement-tile`,g.r(``,t,n.meshes.get(r.floorMeshId))))}}function Ro(e,t){let n=e.getState(),{group:r,tile:i}=Oo(n);if(!r)return;let{meshes:a,selectedTileId:o}=n;if(o){let e=g.i(o,`tile-color`,t),s=go(e,t,a.get(i?.materialId??r.floorMeshId));a.has(e)?n.updateMesh(e,s):n.addMesh(s),n.updateTile(r.id,o,{materialId:e});return}let s=go(``,t,a.get(n.currentTileMaterialId??r.floorMeshId));n.setCurrentTileMaterialId(Po(e,`placement-tile-color`,s))}function zo(e,t,n){let r=e.getState();r.setTerrainColors(t,n);let{group:i,tile:a}=Oo(r);i&&a&&a.objectType&&a.objectType!==`none`&&a.objectType!==`water`&&r.updateTile(i.id,a.id,{objectConfig:{...a.objectConfig??{},terrainColor:t,terrainAccentColor:n}})}function $({label:e,children:t}){return(0,C.jsxs)(`div`,{className:`editor-field-row`,children:[(0,C.jsx)(`span`,{className:`editor-field-row__label`,children:e}),(0,C.jsx)(`div`,{className:`editor-field-row__control`,children:t})]})}function Bo({value:e,onChange:t}){return(0,C.jsx)(`button`,{type:`button`,className:`editor-field-toggle ${e?`editor-field-toggle--on`:``}`,onClick:()=>t(!e),"aria-pressed":e,children:e?`켜짐`:`꺼짐`})}function Vo({value:e,onChange:t}){return(0,C.jsxs)(`div`,{className:`editor-field-color`,children:[(0,C.jsx)(`input`,{type:`color`,value:e,onChange:e=>t(e.target.value)}),(0,C.jsx)(`span`,{children:e})]})}var Ho=b.default.memo(function({actions:e}){return e.length===0?null:(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`커스텀 액션`}),(0,C.jsx)(`div`,{className:`building-panel__segmented`,children:e.map(e=>(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,disabled:e.disabled,onClick:()=>{e.onClick()},children:e.label},e.id))})]})}),Uo=[`showSnow`,`showFog`,`fogColor`,`weatherEffect`,`worldSurface`],Wo=b.default.memo(function(){let{showSnow:e,showFog:t,fogColor:n,weatherEffect:r,worldSurface:i}=Q(Uo),{setShowSnow:a,setShowFog:o,setFogColor:s,setWeatherEffect:c,setWorldSurface:u}=l.Wt().getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`전역 환경`}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsx)($,{label:`눈`,children:(0,C.jsx)(Bo,{value:e,onChange:a})}),(0,C.jsx)($,{label:`안개`,children:(0,C.jsx)(Bo,{value:t,onChange:o})}),(0,C.jsx)($,{label:`안개색`,children:(0,C.jsx)(Vo,{value:n,onChange:s})}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`표면`}),(0,C.jsx)(`div`,{className:`building-panel__segmented`,children:l.cn.map(e=>(0,C.jsx)(`button`,{className:`building-panel__segment-btn ${i===e.type?`building-panel__segment-btn--active`:``}`,onClick:()=>u(e.type),children:e.labelKo},e.type))})]}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,style:{alignItems:`flex-start`},children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`날씨`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,style:{display:`flex`},children:l.sn.map(e=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${r===e.type?`building-panel__grid-btn--active`:``}`,onClick:()=>c(e.type),children:e.labelKo},e.type))})]})]})]})}),Go=[0,Math.PI/4,Math.PI/2,Math.PI*.75,Math.PI,Math.PI*1.25,Math.PI*1.5,Math.PI*1.75],Ko=b.default.memo(function(){let e=l.Ut(e=>e.currentObjectRotation),{setObjectRotation:t}=l.Wt().getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`오브젝트 회전`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:Go.map((n,r)=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${Math.abs(e-n)<.01?`building-panel__grid-btn--active`:``}`,onClick:()=>t(n),children:r*45},n))})]})}),qo=[{value:0,label:`0도`},{value:Math.PI/2,label:`90도`},{value:Math.PI,label:`180도`},{value:Math.PI*1.5,label:`270도`}],Jo=[`currentTileMultiplier`,`currentTileHeight`,`snapToGrid`],Yo=b.default.memo(function({isTileMode:e}){let{currentTileMultiplier:t,currentTileHeight:n,snapToGrid:r}=Q(Jo),{setTileMultiplier:i,setTileHeight:a,setSnapToGrid:o}=l.Wt().getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`배치 설정`}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`크기`}),(0,C.jsxs)(`div`,{className:`building-panel__stepper`,children:[(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>i(Math.max(1,t-1)),children:`-`}),(0,C.jsx)(`span`,{className:`building-panel__stepper-value`,children:t}),(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>i(Math.min(4,t+1)),children:`+`})]})]}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`격자 맞춤`}),(0,C.jsx)(`button`,{className:`building-panel__toggle ${r?`building-panel__toggle--on`:``}`,onClick:()=>o(!r),children:r?`켜짐`:`꺼짐`})]}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`높이`}),(0,C.jsxs)(`div`,{className:`building-panel__stepper`,children:[(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>a(Math.max(0,n-1)),children:`-`}),(0,C.jsx)(`span`,{className:`building-panel__stepper-value`,children:n}),(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>a(Math.min(6,n+1)),children:`+`})]})]})]}),e&&(0,C.jsx)(Zo,{})]})}),Xo=[`currentTileShape`,`currentTileRotation`,`selectedTileId`],Zo=b.default.memo(function(){let{currentTileShape:e,currentTileRotation:t,selectedTileId:n}=Q(Xo),{group:r}=Mo(),i=l.Wt(),{setTileShape:a,setTileRotation:o}=i.getState();return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`타일 형태`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:l.nn.map(t=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${e===t.type?`building-panel__grid-btn--active`:``}`,onClick:()=>a(t.type),children:t.labelKo},t.type))}),(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`타일 회전`}),(0,C.jsx)(`div`,{className:`building-panel__segmented`,children:qo.map(e=>(0,C.jsx)(`button`,{className:`building-panel__segment-btn ${Math.abs(t-e.value)<1e-4?`building-panel__segment-btn--active`:``}`,onClick:()=>o(e.value),children:e.label},e.value))}),(0,C.jsxs)(`div`,{className:`building-panel__delete-card`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`strong`,{children:`선택한 타일`}),(0,C.jsx)(`span`,{children:n?`ID: ${n}`:`타일 하이라이트를 클릭해 선택하세요`})]}),(0,C.jsx)(`button`,{className:`building-panel__delete-button`,disabled:!n||!r,onClick:()=>{n&&r&&i.getState().removeTile(r.id,n)},children:`선택 타일 삭제`})]})]})}),Qo=[`currentTileMultiplier`,`currentTileHeight`,`selectedBlockId`],$o=b.default.memo(function(){let{currentTileMultiplier:e,currentTileHeight:t,selectedBlockId:n}=Q(Qo),r=l.Wt();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`박스 편집`}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`박스 크기`}),(0,C.jsxs)(`span`,{className:`building-panel__info-value`,children:[e,` x `,e]})]}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`쌓기 높이`}),(0,C.jsx)(`span`,{className:`building-panel__info-value`,children:t})]})]}),(0,C.jsxs)(`div`,{className:`building-panel__delete-card`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`strong`,{children:`선택한 박스`}),(0,C.jsx)(`span`,{children:n?`ID: ${n}`:`박스 하이라이트를 클릭해 선택하세요`})]}),(0,C.jsx)(`button`,{className:`building-panel__delete-button`,disabled:!n,onClick:()=>{n&&r.getState().removeBlock(n)},children:`선택 박스 삭제`})]})]})}),es=[`currentWallKind`,`currentWallRotation`,`selectedWallId`],ts=b.default.memo(function(){let{currentWallKind:e,currentWallRotation:t,selectedWallId:n}=Q(es),{group:r,wall:i}=jo(),a=l.Wt(),{setWallKind:o,setWallRotation:s}=a.getState(),c=i?.wallKind??e,u=l.an.find(e=>e.type===c)?.labelKo??e,d=!!(n&&r);return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`벽 모듈 / 회전 / 삭제`}),(0,C.jsxs)(`div`,{className:`building-panel__section-subtitle`,children:[`벽 모듈: `,u]}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:l.an.map(e=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${c===e.type?`building-panel__grid-btn--active`:``}`,onClick:()=>o(e.type),children:e.labelKo},e.type))}),(0,C.jsx)(`div`,{className:`building-panel__segmented`,children:qo.map(e=>(0,C.jsx)(`button`,{className:`building-panel__segment-btn ${Math.abs(t-e.value)<1e-4?`building-panel__segment-btn--active`:``}`,onClick:()=>s(e.value),children:e.label},e.value))}),(0,C.jsxs)(`div`,{className:`building-panel__delete-card`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`strong`,{children:`선택한 벽`}),(0,C.jsx)(`span`,{children:n?`ID: ${n}`:`벽 마커를 클릭해 선택하세요`})]}),(0,C.jsx)(`button`,{className:`building-panel__delete-button`,disabled:!d,onClick:()=>{n&&r&&a.getState().updateWall(r.id,n,{flipSides:!i?.flipSides})},children:`내외부 뒤집기`}),(0,C.jsx)(`button`,{className:`building-panel__delete-button`,disabled:!d,onClick:()=>{n&&r&&a.getState().removeWall(r.id,n)},children:`선택 벽 삭제`})]})]})}),ns=[`idle`,`patrol`,`wander`];function rs({instance:e,updateBehavior:t,setNavigation:n,clearNavigation:r}){let i=l.Ut(e=>e.hoverPosition),a=e.behavior?.speed??2.2,o=e.behavior?.wanderRadius??4,s=e.behavior?.waypoints??[],c=i?`${i.x.toFixed(1)}, ${i.z.toFixed(1)}`:`없음`;return(0,C.jsxs)(`div`,{className:`building-panel__npc-card`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`이동 설정`}),(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`행동 모드`}),(0,C.jsx)(`div`,{className:`building-panel__segmented`,children:ns.map(n=>(0,C.jsx)(`button`,{className:`building-panel__segment-btn ${e.behavior?.mode===n?`building-panel__segment-btn--active`:``}`,onClick:()=>{t(e.id,{mode:n,speed:a}),n===`idle`&&r(e.id)},children:n},n))}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`이동 속도`}),(0,C.jsxs)(`div`,{className:`building-panel__stepper`,children:[(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>t(e.id,{speed:Math.max(.4,a-.4)}),children:`-`}),(0,C.jsx)(`span`,{className:`building-panel__stepper-value`,children:a.toFixed(1)}),(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>t(e.id,{speed:Math.min(7,a+.4)}),children:`+`})]})]}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`배회 반경`}),(0,C.jsxs)(`div`,{className:`building-panel__stepper`,children:[(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>t(e.id,{wanderRadius:Math.max(1,o-1)}),children:`-`}),(0,C.jsxs)(`span`,{className:`building-panel__stepper-value`,children:[o,`m`]}),(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>t(e.id,{wanderRadius:Math.min(30,o+1)}),children:`+`})]})]})]}),(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`웨이포인트`}),(0,C.jsxs)(`div`,{className:`building-panel__asset-targets`,children:[(0,C.jsxs)(`span`,{children:[s.length,`개 지정됨`]}),(0,C.jsxs)(`span`,{children:[`호버 위치: `,c]})]}),(0,C.jsxs)(`div`,{className:`building-panel__segmented`,children:[(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,disabled:!i,onClick:()=>{if(!i)return;let r=[i.x,i.y,i.z],o=[...s,r];t(e.id,{mode:`patrol`,waypoints:o}),n(e.id,o,a)},children:`호버 위치 추가`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,disabled:s.length===0,onClick:()=>{s.length!==0&&(t(e.id,{mode:`patrol`,waypoints:s}),n(e.id,s,a))},children:`순찰 시작`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>{t(e.id,{waypoints:[]}),r(e.id)},children:`경로 초기화`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,disabled:!i,onClick:()=>{if(!i)return;let r=[i.x,i.y,i.z];t(e.id,{mode:`idle`}),n(e.id,[r],a)},children:`호버 위치로 1회 이동`})]})]})}function is({instance:e,animations:t,updateInstance:n,updateBehavior:r}){let i=t=>{n(e.id,{currentAnimation:t}),r(e.id,{mode:`idle`,idleAnimation:t,arriveAnimation:t})};return(0,C.jsxs)(`div`,{className:`building-panel__npc-card`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`애니메이션 설정`}),(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`애니메이션`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:t.map(t=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${e.currentAnimation===t.id?`building-panel__grid-btn--active`:``}`,onClick:()=>i(t.id),children:t.name},t.id))}),(0,C.jsx)(`div`,{className:`building-panel__segmented`,children:t.map(t=>(0,C.jsxs)(`button`,{className:`building-panel__segment-btn ${e.behavior?.moveAnimation===t.id?`building-panel__segment-btn--active`:``}`,onClick:()=>r(e.id,{moveAnimation:t.id}),children:[`이동:`,t.name]},`move-${t.id}`))}),(0,C.jsx)(`div`,{className:`building-panel__segmented`,children:t.map(t=>(0,C.jsxs)(`button`,{className:`building-panel__segment-btn ${e.behavior?.idleAnimation===t.id?`building-panel__segment-btn--active`:``}`,onClick:()=>r(e.id,{idleAnimation:t.id,arriveAnimation:t.id}),children:[`대기:`,t.name]},`idle-${t.id}`))})]})}function as({instance:e,updateBrain:t,updatePerception:n}){let r=e.perception?.sightRadius??8;return(0,C.jsxs)(`div`,{className:`building-panel__npc-card`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`지각/연동 설정`}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsx)($,{label:`시야 감지`,children:(0,C.jsx)(Bo,{value:e.perception?.enabled??!0,onChange:t=>n(e.id,{enabled:t})})}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`시야 반경`}),(0,C.jsxs)(`div`,{className:`building-panel__stepper`,children:[(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>n(e.id,{sightRadius:Math.max(1,r-1)}),children:`-`}),(0,C.jsxs)(`span`,{className:`building-panel__stepper-value`,children:[r,`m`]}),(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:()=>n(e.id,{sightRadius:Math.min(60,r+1)}),children:`+`})]})]}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`제공자`}),(0,C.jsx)(`input`,{value:e.brain?.providerId??``,onChange:n=>t(e.id,{providerId:n.target.value}),placeholder:`언어 모델 제공자 식별자`,style:{width:`100%`,minWidth:0}})]}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`정책`}),(0,C.jsx)(`input`,{value:e.brain?.policyId??``,onChange:n=>t(e.id,{policyId:n.target.value}),placeholder:`학습 정책 식별자`,style:{width:`100%`,minWidth:0}})]}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`관측`}),(0,C.jsx)(`span`,{className:`building-panel__info-value`,children:(0,C.jsx)(os,{id:e.id})})]})]})]})}function os({id:e}){let t=_.mt(),n=(0,b.useCallback)(e=>t.subscribeRecords(e),[t]),r=(0,b.useSyncExternalStore)(n,()=>t.getRecord(e));return(0,C.jsxs)(C.Fragment,{children:[`감지 `,r?.observation.perceived.length??0,` · 결정 `,r?.decision?.source??`없음`]})}function ss({label:e,value:t,onDecrement:n,onIncrement:r}){return(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:e}),(0,C.jsxs)(`div`,{className:`building-panel__stepper`,children:[(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:n,children:`-`}),(0,C.jsx)(`span`,{className:`building-panel__stepper-value`,children:t}),(0,C.jsx)(`button`,{className:`building-panel__stepper-btn`,onClick:r,children:`+`})]})]})}function cs({label:e,value:t,placeholder:n,onChange:r}){return(0,C.jsxs)(`div`,{className:`building-panel__info-item`,style:{flexDirection:`column`,alignItems:`stretch`,gap:`4px`},children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:e}),(0,C.jsx)(`input`,{type:`text`,value:t,onChange:e=>r(e.target.value),placeholder:n,style:{width:`100%`,padding:`4px 6px`,fontSize:`11px`,background:`var(--panel-bg, #1a1a2e)`,border:`1px solid var(--border-color, #333)`,borderRadius:`3px`,color:`inherit`,boxSizing:`border-box`}})]})}var ls=[`currentTreeKind`,`currentObjectPrimaryColor`,`currentObjectSecondaryColor`],us=b.default.memo(function(){let{currentTreeKind:e,currentObjectPrimaryColor:t,currentObjectSecondaryColor:n}=Q(ls),{setTreeKind:r,setObjectPrimaryColor:i,setObjectSecondaryColor:a}=l.Wt().getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`나무 프리셋`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:l.in.map(t=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${e===t.type?`building-panel__grid-btn--active`:``}`,onClick:()=>r(t.type),children:t.labelKo},t.type))}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsx)($,{label:`잎/꽃 색`,children:(0,C.jsx)(Vo,{value:t,onChange:i})}),(0,C.jsx)($,{label:`줄기 색`,children:(0,C.jsx)(Vo,{value:n,onChange:a})})]})]})}),ds=[`currentFireIntensity`,`currentFireWidth`,`currentFireHeight`,`currentFireColor`],fs=b.default.memo(function(){let{currentFireIntensity:e,currentFireWidth:t,currentFireHeight:n,currentFireColor:r}=Q(ds),{setFireIntensity:i,setFireWidth:a,setFireHeight:o,setFireColor:s}=l.Wt().getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`불 설정`}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsx)(ss,{label:`강도`,value:e.toFixed(1),onDecrement:()=>i(Math.max(.5,e-.5)),onIncrement:()=>i(Math.min(3,e+.5))}),(0,C.jsx)(ss,{label:`너비`,value:`${t.toFixed(1)}m`,onDecrement:()=>a(Math.max(.3,t-.2)),onIncrement:()=>a(Math.min(4,t+.2))}),(0,C.jsx)(ss,{label:`높이`,value:`${n.toFixed(1)}m`,onDecrement:()=>o(Math.max(.5,n-.3)),onIncrement:()=>o(Math.min(5,n+.3))}),(0,C.jsx)($,{label:`색상`,children:(0,C.jsx)(Vo,{value:r,onChange:s})})]})]})}),ps=[{value:`#00ff88`,label:`초록`},{value:`#00aaff`,label:`파랑`},{value:`#f59e0b`,label:`앰버`},{value:`#ffffff`,label:`흰색`},{value:`#ffdd00`,label:`노랑`}],ms=[`currentBillboardScale`,`currentBillboardOffsetY`,`currentBillboardWidth`,`currentBillboardHeight`,`currentBillboardElevation`,`currentBillboardIntensity`,`currentBillboardText`,`currentBillboardImageUrl`,`currentBillboardColor`],hs=b.default.memo(function(){let{currentBillboardScale:e,currentBillboardOffsetY:t,currentBillboardWidth:n,currentBillboardHeight:r,currentBillboardElevation:i,currentBillboardIntensity:a,currentBillboardText:o,currentBillboardImageUrl:s,currentBillboardColor:c}=Q(ms),{setBillboardScale:u,setBillboardOffsetY:d,setBillboardWidth:f,setBillboardHeight:p,setBillboardElevation:m,setBillboardIntensity:h,setBillboardText:g,setBillboardImageUrl:_,setBillboardColor:v}=l.Wt().getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`간판 설정`}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsx)(ss,{label:`크기`,value:`${e.toFixed(1)}x`,onDecrement:()=>u(Math.max(.2,e-.2)),onIncrement:()=>u(Math.min(10,e+.2))}),(0,C.jsx)(ss,{label:`배치 높이`,value:`${t.toFixed(2)}m`,onDecrement:()=>d(Math.max(-4,t-.25)),onIncrement:()=>d(Math.min(12,t+.25))}),(0,C.jsx)(ss,{label:`판넬 너비`,value:n>0?`${n.toFixed(2)}m`:`자동`,onDecrement:()=>f(Math.max(0,n-.25)),onIncrement:()=>f(Math.min(12,n+.25))}),(0,C.jsx)(ss,{label:`판넬 높이`,value:`${r.toFixed(2)}m`,onDecrement:()=>p(Math.max(.3,r-.25)),onIncrement:()=>p(Math.min(8,r+.25))}),(0,C.jsx)(ss,{label:`기둥 높이`,value:`${i.toFixed(2)}m`,onDecrement:()=>m(Math.max(0,i-.25)),onIncrement:()=>m(Math.min(8,i+.25))}),(0,C.jsx)(ss,{label:`밝기`,value:a.toFixed(2),onDecrement:()=>h(Math.max(0,a-.25)),onIncrement:()=>h(Math.min(8,a+.25))}),(0,C.jsx)(cs,{label:`문구`,value:o,onChange:g,placeholder:`표시할 문구...`}),(0,C.jsx)(cs,{label:`이미지 URL`,value:s,onChange:_,placeholder:`https://...`}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,style:{flexDirection:`column`,alignItems:`stretch`,gap:`4px`},children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`색상`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:ps.map(e=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${c===e.value?`building-panel__grid-btn--active`:``}`,onClick:()=>v(e.value),style:{borderBottom:`3px solid ${e.value}`},children:e.label},e.value))})]})]})]})}),gs=[`currentFlagStyle`,`currentFlagWidth`,`currentFlagHeight`,`currentFlagImageUrl`],_s=b.default.memo(function(){let{currentFlagStyle:e,currentFlagWidth:t,currentFlagHeight:n,currentFlagImageUrl:r}=Q(gs),{setFlagStyle:i,setFlagWidth:a,setFlagHeight:o,setFlagImageUrl:s}=l.Wt().getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`깃발 설정`}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsxs)(`div`,{className:`building-panel__info-item`,style:{flexDirection:`column`,alignItems:`stretch`,gap:`4px`},children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`스타일`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:l.Xt.map(({style:t,meta:n})=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${e===t?`building-panel__grid-btn--active`:``}`,onClick:()=>i(t),children:n.label},t))})]}),(0,C.jsx)(ss,{label:`너비`,value:`${t}m`,onDecrement:()=>a(Math.max(.5,t-.5)),onIncrement:()=>a(Math.min(8,t+.5))}),(0,C.jsx)(ss,{label:`높이`,value:`${n}m`,onDecrement:()=>o(Math.max(.5,n-.5)),onIncrement:()=>o(Math.min(6,n+.5))}),(0,C.jsx)(cs,{label:`이미지 URL`,value:r,onChange:s,placeholder:`https://...`})]})]})}),vs=[`none`,`scripted`,`llm`,`reinforcement`],ys=[`always`,`navigationIdle`,`perceivedAny`,`memoryEquals`],bs=[`idle`,`moveTo`,`patrol`,`wander`,`playAnimation`,`lookAt`,`speak`,`interact`,`remember`,`moveToTarget`];function xs({editor:e}){let{updateSelectedNode:t,selectedNode:n}=e;return n?.type===`action`?(0,C.jsx)(C.Fragment,{children:(0,C.jsx)($,{label:`액션 타입`,children:(0,C.jsx)(`select`,{value:n.action.type,onChange:e=>{let n=e.target.value;t(e=>{if(e.type!==`action`)return e;switch(n){case`idle`:return{...e,action:{type:`idle`,animationId:`idle`}};case`moveTo`:return{...e,action:{type:`moveTo`,target:[0,0,0],speed:2.2,animationId:`walk`}};case`patrol`:return{...e,action:{type:`patrol`,waypoints:[[0,0,0],[2,0,2]],speed:2.2,loop:!0,animationId:`walk`}};case`wander`:return{...e,action:{type:`wander`,radius:4,speed:2.2,waitSeconds:1.5}};case`playAnimation`:return{...e,action:{type:`playAnimation`,animationId:`wave`,loop:!1,speed:1}};case`lookAt`:return{...e,action:{type:`lookAt`,target:[0,0,0]}};case`speak`:return{...e,action:{type:`speak`,text:`안녕?`,duration:2}};case`interact`:return{...e,action:{type:`interact`,targetId:`target.entity`}};case`remember`:return{...e,action:{type:`remember`,key:`memory.key`,value:!0}};case`moveToTarget`:return{...e,action:{type:`moveToTarget`,target:{type:`self`},speed:2.2,animationId:`walk`}};default:return e}})},children:bs.map(e=>(0,C.jsx)(`option`,{value:e,children:Z(e)},e))})})}):null}function Ss({editor:e}){let{updateSelectedNode:t,selectedNode:n,parseNumeric:r,updateVectorAxis:i}=e;return n?.type===`action`?(0,C.jsx)(C.Fragment,{children:n.action.type===`moveToTarget`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`대상`,children:(0,C.jsxs)(`select`,{value:n.action.target.type,onChange:e=>t(t=>{if(t.type!==`action`||t.action.type!==`moveToTarget`)return t;let n=e.target.value;return n===`point`?{...t,action:{...t.action,target:{type:`point`,value:[0,0,0]}}}:{...t,action:{...t.action,target:{type:n}}}}),children:[(0,C.jsx)(`option`,{value:`self`,children:`자기 자신`}),(0,C.jsx)(`option`,{value:`nearestPerceived`,children:`가장 가까운 감지 대상`}),(0,C.jsx)(`option`,{value:`point`,children:`지정 위치`})]})}),n.action.target.type===`point`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`위치 X`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.target.value[0],onChange:e=>t(t=>t.type!==`action`||t.action.type!==`moveToTarget`||t.action.target.type!==`point`?t:{...t,action:{...t.action,target:{type:`point`,value:i(t.action.target.value,0,e.target.value)}}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`위치 Y`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.target.value[1],onChange:e=>t(t=>t.type!==`action`||t.action.type!==`moveToTarget`||t.action.target.type!==`point`?t:{...t,action:{...t.action,target:{type:`point`,value:i(t.action.target.value,1,e.target.value)}}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`위치 Z`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.target.value[2],onChange:e=>t(t=>t.type!==`action`||t.action.type!==`moveToTarget`||t.action.target.type!==`point`?t:{...t,action:{...t.action,target:{type:`point`,value:i(t.action.target.value,2,e.target.value)}}}),style:{width:`100%`}})})]}),(0,C.jsx)($,{label:`속도`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.speed??2.2,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`moveToTarget`?t:{...t,action:{...t.action,speed:r(e.target.value,t.action.speed??2.2)}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`애니메이션 식별자`,children:(0,C.jsx)(`input`,{value:n.action.animationId??``,onChange:e=>t(t=>{if(t.type!==`action`||t.action.type!==`moveToTarget`)return t;let n=e.target.value.trim(),r={...t.action};return delete r.animationId,{...t,action:{...r,...n?{animationId:n}:{}}}}),style:{width:`100%`}})})]})}):null}function Cs({editor:e}){let{updateSelectedNode:t,selectedNode:n,parseNumeric:r,updateVectorAxis:i}=e;return n?.type===`action`?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(Ss,{editor:e}),n.action.type===`moveTo`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`대상 X`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.target[0],onChange:e=>t(t=>t.type!==`action`||t.action.type!==`moveTo`?t:{...t,action:{...t.action,target:i(t.action.target,0,e.target.value)}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`대상 Y`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.target[1],onChange:e=>t(t=>t.type!==`action`||t.action.type!==`moveTo`?t:{...t,action:{...t.action,target:i(t.action.target,1,e.target.value)}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`대상 Z`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.target[2],onChange:e=>t(t=>t.type!==`action`||t.action.type!==`moveTo`?t:{...t,action:{...t.action,target:i(t.action.target,2,e.target.value)}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`속도`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.speed??2.2,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`moveTo`?t:{...t,action:{...t.action,speed:r(e.target.value,t.action.speed??2.2)}}),style:{width:`100%`}})})]}),n.action.type===`lookAt`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`대상 X`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.target[0],onChange:e=>t(t=>t.type!==`action`||t.action.type!==`lookAt`?t:{...t,action:{...t.action,target:i(t.action.target,0,e.target.value)}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`대상 Y`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.target[1],onChange:e=>t(t=>t.type!==`action`||t.action.type!==`lookAt`?t:{...t,action:{...t.action,target:i(t.action.target,1,e.target.value)}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`대상 Z`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.target[2],onChange:e=>t(t=>t.type!==`action`||t.action.type!==`lookAt`?t:{...t,action:{...t.action,target:i(t.action.target,2,e.target.value)}}),style:{width:`100%`}})})]})]}):null}var ws=[0,1,2];function Ts({editor:e,waypoint:t,index:n}){let{updateSelectedNode:r,updateVectorAxis:i}=e,a=e=>r(t=>{if(t.type!==`action`||t.action.type!==`patrol`)return t;let n=e([...t.action.waypoints]);return n?{...t,action:{...t.action,waypoints:n}}:t}),o=(e,t)=>a(n=>{let r=n[e],i=n[t];return e<0||!r||!i?null:(n[e]=i,n[t]=r,n)});return(0,C.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(3, minmax(0, 1fr)) auto auto auto`,gap:`4px`,alignItems:`center`},children:[ws.map(e=>(0,C.jsx)(`input`,{type:`number`,value:t[e],onChange:r=>a(a=>(a[n]=i(a[n]??t,e,r.target.value),a))},e)),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>o(n-1,n),children:`위`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>o(n,n+1),children:`아래`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>a(e=>e.length<=1?null:e.filter((e,t)=>t!==n)),children:`삭제`})]})}function Es({editor:e}){let{updateSelectedNode:t,selectedNode:n,parseNumeric:r}=e;return n?.type===`action`?(0,C.jsx)(C.Fragment,{children:n.action.type===`patrol`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`웨이포인트 수`,children:(0,C.jsx)(`span`,{children:n.action.waypoints.length})}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,style:{flexDirection:`column`,alignItems:`stretch`,gap:`6px`},children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`웨이포인트 편집`}),n.action.waypoints.map((t,n)=>(0,C.jsx)(Ts,{editor:e,waypoint:t,index:n},`waypoint-${n}`)),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>t(e=>{if(e.type!==`action`||e.action.type!==`patrol`)return e;let t=e.action.waypoints[e.action.waypoints.length-1]??[0,0,0],n=[t[0]+1,t[1],t[2]+1];return{...e,action:{...e.action,waypoints:[...e.action.waypoints,n]}}}),children:`웨이포인트 추가`})]}),(0,C.jsx)($,{label:`속도`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.speed??2.2,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`patrol`?t:{...t,action:{...t.action,speed:r(e.target.value,t.action.speed??2.2)}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`반복`,children:(0,C.jsx)(`input`,{type:`checkbox`,checked:n.action.loop??!0,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`patrol`?t:{...t,action:{...t.action,loop:e.target.checked}})})})]})}):null}function Ds({editor:e}){let{updateSelectedNode:t,selectedNode:n}=e;return n?.type===`action`?(0,C.jsxs)(C.Fragment,{children:[n.action.type===`idle`&&(0,C.jsx)($,{label:`애니메이션 식별자`,children:(0,C.jsx)(`input`,{value:n.action.animationId??``,onChange:e=>t(t=>{if(t.type!==`action`||t.action.type!==`idle`)return t;let n=e.target.value.trim(),r={...t.action};return delete r.animationId,{...t,action:{...r,...n?{animationId:n}:{}}}}),style:{width:`100%`}})}),n.action.type===`interact`&&(0,C.jsx)($,{label:`대상 식별자`,children:(0,C.jsx)(`input`,{value:n.action.targetId,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`interact`?t:{...t,action:{...t.action,targetId:e.target.value}}),style:{width:`100%`}})}),n.action.type===`remember`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`기억 키`,children:(0,C.jsx)(`input`,{value:n.action.key,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`remember`?t:{...t,action:{...t.action,key:e.target.value}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`기억 값`,children:(0,C.jsx)(`input`,{value:String(n.action.value),onChange:e=>t(t=>t.type!==`action`||t.action.type!==`remember`?t:{...t,action:{...t.action,value:e.target.value}}),style:{width:`100%`}})})]})]}):null}function Os({editor:e}){let{updateSelectedNode:t,selectedNode:n,parseNumeric:r}=e;return n?.type===`action`?(0,C.jsxs)(C.Fragment,{children:[n.action.type===`wander`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`반경`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.radius??4,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`wander`?t:{...t,action:{...t.action,radius:r(e.target.value,t.action.radius??4)}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`속도`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.speed??2.2,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`wander`?t:{...t,action:{...t.action,speed:r(e.target.value,t.action.speed??2.2)}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`대기(초)`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.waitSeconds??1.5,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`wander`?t:{...t,action:{...t.action,waitSeconds:r(e.target.value,t.action.waitSeconds??1.5)}}),style:{width:`100%`}})})]}),n.action.type===`speak`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`대사`,children:(0,C.jsx)(`input`,{value:n.action.text,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`speak`?t:{...t,action:{...t.action,text:e.target.value}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`지속시간(초)`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.duration??2,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`speak`?t:{...t,action:{...t.action,duration:r(e.target.value,t.action.duration??2)}}),style:{width:`100%`}})})]}),n.action.type===`playAnimation`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`애니메이션 식별자`,children:(0,C.jsx)(`input`,{value:n.action.animationId,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`playAnimation`?t:{...t,action:{...t.action,animationId:e.target.value}}),style:{width:`100%`}})}),(0,C.jsx)($,{label:`반복`,children:(0,C.jsx)(`input`,{type:`checkbox`,checked:n.action.loop??!1,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`playAnimation`?t:{...t,action:{...t.action,loop:e.target.checked}})})}),(0,C.jsx)($,{label:`재생속도`,children:(0,C.jsx)(`input`,{type:`number`,value:n.action.speed??1,onChange:e=>t(t=>t.type!==`action`||t.action.type!==`playAnimation`?t:{...t,action:{...t.action,speed:r(e.target.value,t.action.speed??1)}}),style:{width:`100%`}})})]})]}):null}function ks({editor:e}){let{selectedNode:t}=e;return t?.type===`action`?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(xs,{editor:e}),(0,C.jsx)(Os,{editor:e}),(0,C.jsx)(Ds,{editor:e}),(0,C.jsx)(Cs,{editor:e}),(0,C.jsx)(Es,{editor:e})]}):null}function As(e){return e===`memoryEquals`?{type:e,key:`memory.key`,value:!0}:{type:e}}function js({editor:e}){let{updateSelectedNode:t,selectedNode:n}=e;return n?.type===`condition`?(0,C.jsx)($,{label:`조건 타입`,children:(0,C.jsx)(`select`,{value:n.condition.type,onChange:e=>{let n=e.target.value;t(e=>e.type===`condition`?{...e,condition:As(n)}:e)},children:ys.map(e=>(0,C.jsx)(`option`,{value:e,children:Z(e)},e))})}):null}function Ms({editor:e}){let{availableEdgeNodes:t,selectedEdge:n,selectedEdgeTarget:r,updateSelectedEdge:i}=e;return(0,C.jsx)(C.Fragment,{children:n&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`시작 노드`,children:(0,C.jsx)(`select`,{value:n.source,onChange:e=>i(t=>({...t,source:e.target.value})),style:{width:`100%`},children:t.map(e=>(0,C.jsx)(`option`,{value:e.id,children:yo(e)},e.id))})}),(0,C.jsx)($,{label:`분기`,children:(0,C.jsxs)(`select`,{value:n.branch??`next`,onChange:e=>i(t=>({...t,branch:e.target.value})),style:{width:`100%`},children:[(0,C.jsx)(`option`,{value:`next`,children:`다음`}),(0,C.jsx)(`option`,{value:`true`,children:`참`}),(0,C.jsx)(`option`,{value:`false`,children:`거짓`})]})}),(0,C.jsx)($,{label:`대상`,children:(0,C.jsx)(`select`,{value:n.target,onChange:e=>i(t=>({...t,target:e.target.value})),style:{width:`100%`},children:t.map(e=>(0,C.jsx)(`option`,{value:e.id,children:yo(e)},e.id))})}),!r&&(0,C.jsx)($,{label:`주의`,children:(0,C.jsx)(`span`,{children:`타겟 노드를 찾을 수 없습니다.`})})]})})}function Ns({editor:e}){let{selectedBlueprint:t,setSelectedEdgeId:n,edgeIntegrityMessage:r,activeNpcTab:i,updateSelectedNode:a,selectedNode:o,primaryStartNode:s,danglingEdges:c,orphanNodeIds:l,conditionBranchIssues:u,availableEdgeNodes:d,selectedNodeOutgoingEdges:f,selectedEdge:p,recoverOrphanNode:m,recoverAllOrphans:h,addOutgoingEdge:g,removeSelectedEdge:_,addConditionBranchEdge:v,fixConditionBranches:y}=e;return t?(0,C.jsx)(C.Fragment,{children:i===`inspector`&&o&&(0,C.jsxs)(`div`,{className:`building-panel__info building-panel__brain-inspector`,style:{marginTop:`8px`},children:[(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`노드 인스펙터`}),(0,C.jsx)($,{label:`라벨`,children:(0,C.jsx)(`input`,{value:o.label??``,onChange:e=>a(t=>({...t,label:e.target.value})),style:{width:`100%`}})}),(0,C.jsx)($,{label:`나가는 연결`,children:(0,C.jsxs)(`select`,{value:p?.id??``,onChange:e=>n(e.target.value||null),style:{width:`100%`},disabled:f.length===0,children:[f.length===0&&(0,C.jsx)(`option`,{value:``,children:`다음 없음`}),f.map(e=>(0,C.jsxs)(`option`,{value:e.id,children:[e.branch??`next`,` -> `,t?.nodes.find(t=>t.id===e.target)?.label??e.target]},e.id))]})}),(0,C.jsxs)(`div`,{className:`building-panel__segmented`,children:[(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:g,disabled:!o||d.length<=1||!d.some(e=>e.id!==o.id&&!t.edges.some(t=>t.source===o.id&&t.target===e.id)),children:`엣지 추가`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:_,disabled:!p,children:`엣지 삭제`})]}),(c.length>0||l.size>0)&&(0,C.jsx)($,{label:`그래프 상태`,children:(0,C.jsxs)(`span`,{children:[`끊어진 연결 `,c.length,` · 고립된 노드 `,l.size]})}),l.size>0&&(0,C.jsxs)(`div`,{className:`building-panel__segmented`,children:[(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:h,disabled:!s,children:`도달 불가 노드 전체 복구`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>{o&&l.has(o.id)&&m(o.id)},disabled:!o||!l.has(o.id)||!s,children:`선택 노드 복구`})]}),r&&(0,C.jsx)($,{label:`그래프 규칙`,children:(0,C.jsx)(`span`,{children:r})}),(0,C.jsx)(Ms,{editor:e}),o.type===`condition`&&u.has(o.id)&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)($,{label:`분기 검증`,children:(0,C.jsx)(`span`,{children:u.get(o.id)?.join(` · `)})}),(0,C.jsxs)(`div`,{className:`building-panel__segmented`,children:[(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>v(o.id,`true`),disabled:f.some(e=>(e.branch??`next`)===`true`),children:`참 분기 추가`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>v(o.id,`false`),disabled:f.some(e=>(e.branch??`next`)===`false`),children:`거짓 분기 추가`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>y(o.id),children:`누락 분기 자동 보완`})]})]}),(0,C.jsx)(js,{editor:e}),(0,C.jsx)(ks,{editor:e})]})}):null}function Ps({editor:e}){let{selectedBlueprint:t,updateBrainBlueprint:n,selectedNodeId:r,setSelectedNodeId:i,activeNpcTab:a,setActiveNpcTab:o,primaryStartNode:s,orphanNodeIds:c,conditionBranchIssues:l,recoverOrphanNode:u}=e;return t?(0,C.jsx)(C.Fragment,{children:a===`nodes`&&(0,C.jsx)(`div`,{className:`building-panel__node-list`,children:t.nodes.map(e=>(0,C.jsxs)(`div`,{className:`building-panel__node-card`,style:e.id===r?{borderColor:`#6dd3ff`,boxShadow:`0 0 0 1px #6dd3ff`}:c.has(e.id)?{borderColor:`#f59e0b`,boxShadow:`0 0 0 1px #f59e0b`}:void 0,onClick:()=>{e.type!==`start`&&(i(e.id),o(`inspector`))},children:[(0,C.jsxs)(`div`,{className:`building-panel__node-card-header`,children:[(0,C.jsx)(`div`,{className:`building-panel__node-card-title`,children:yo(e)}),e.type!==`start`&&(0,C.jsx)(`button`,{className:`building-panel__node-card-action`,onClick:()=>n(t.id,Co(t,e.id)),children:`삭제`})]}),(0,C.jsx)(`div`,{className:`building-panel__node-card-desc`,children:bo(e)}),(0,C.jsx)(`div`,{className:`building-panel__node-card-edge`,children:Eo(t,e.id)}),c.has(e.id)&&(0,C.jsxs)(`div`,{className:`building-panel__node-card-edge`,style:{display:`flex`,justifyContent:`space-between`,gap:`8px`},children:[(0,C.jsx)(`span`,{children:`도달 불가 노드`}),(0,C.jsx)(`button`,{className:`building-panel__node-card-action`,onClick:t=>{t.stopPropagation(),u(e.id)},disabled:!s,children:`시작점에 연결`})]}),l.has(e.id)&&(0,C.jsx)(`div`,{className:`building-panel__node-card-edge`,style:{color:`#f59e0b`},children:l.get(e.id)?.join(` · `)})]},e.id))})}):null}function Fs({editor:e}){let{instance:t,selectedBlueprint:n,updateBrainBlueprint:r}=e;return n?(0,C.jsx)(C.Fragment,{children:(0,C.jsxs)(`div`,{className:`building-panel__segmented`,children:[(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>r(n.id,So(n,_o(),t.behavior)),children:`조건:이동 대기`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>r(n.id,xo(n,vo(`wander`,t.behavior))),children:`배회 노드 추가`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>r(n.id,xo(n,vo(`speak`,t.behavior))),children:`대화 노드 추가`})]})}):null}function Is(e,t){let n={mode:`idle`,label:`대기`};if(e?.type===`action`)switch(e.action.type){case`moveTo`:n={mode:`move`,label:`지점 이동`,target:e.action.target,...e.action.animationId?{animationId:e.action.animationId}:{}};break;case`patrol`:n={mode:`patrol`,label:`순찰`,waypoints:e.action.waypoints,...e.action.animationId?{animationId:e.action.animationId}:{}};break;case`wander`:n={mode:`wander`,label:`배회`,...e.action.radius?{radius:e.action.radius}:{}};break;case`moveToTarget`:n=e.action.target.type===`point`?{mode:`move`,label:`지점 이동`,target:e.action.target.value,...e.action.animationId?{animationId:e.action.animationId}:{}}:{mode:`action`,label:`${Z(e.action.target.type)} 이동`,...e.action.animationId?{animationId:e.action.animationId}:{}};break;case`playAnimation`:n={mode:`action`,label:`애니메이션 재생`,animationId:e.action.animationId};break;case`speak`:n={mode:`action`,label:`말하기: ${e.action.text}`};break;default:n={mode:`action`,label:Z(e.action.type)}}else t?.mode===`patrol`&&t.waypoints&&t.waypoints.length>0?n={mode:`patrol`,label:`기본 행동: 순찰`,waypoints:t.waypoints}:t?.mode===`wander`&&(n={mode:`wander`,label:`기본 행동: 배회`,radius:t.wanderRadius??4});return n}function Ls({instance:e,blueprints:t,selectedBlueprint:n,updateBrain:r,addBrainBlueprint:i,updateBrainBlueprint:a,onPreviewStateChange:o}){let s=b.default.useRef(null),[c,l]=b.default.useState(null),[u,f]=b.default.useState(null),[p,m]=b.default.useState(``),[h,g]=b.default.useState(!0),[_,v]=b.default.useState(`nodes`),[y,x]=b.default.useState(!1);b.default.useEffect(()=>{let e=s.current;e&&x(!!e.closest(`.editor-panel-modal`))},[n]),b.default.useEffect(()=>{y&&(h||g(!0))},[y,h]),b.default.useEffect(()=>{if(!n){l(null),g(!0),v(`nodes`);return}if(c&&n.nodes.some(e=>e.id===c&&e.type!==`start`))return;let e=n.nodes.find(e=>e.type!==`start`);l(e?.id??null)},[n,c]);let S=e=>{if(!n||!c)return;let t=n.nodes.map(t=>t.id!==c||t.type===`start`?t:e(t));a(n.id,{...n,nodes:t})},C=n?.nodes.find(e=>e.id===c&&e.type!==`start`);b.default.useEffect(()=>{o?.(Is(C,e.behavior))},[e.behavior,o,C]);let w=n?.nodes.find(e=>e.type===`start`)??null,T=b.default.useMemo(()=>new Set((n?.nodes??[]).map(e=>e.id)),[n]),E=b.default.useMemo(()=>(n?.edges??[]).filter(e=>!T.has(e.source)||!T.has(e.target)),[T,n]),D=b.default.useMemo(()=>{if(!n)return new Set;let e=new Map;for(let t of n.edges){if(!T.has(t.source)||!T.has(t.target))continue;let n=e.get(t.source)??[];n.push(t.target),e.set(t.source,n)}let t=new Set,r=n.nodes.filter(e=>e.type===`start`).map(e=>e.id);for(;r.length>0;){let n=r.shift();if(!n||t.has(n))continue;t.add(n);let i=e.get(n)??[];for(let e of i)t.has(e)||r.push(e)}return t},[T,n]),O=b.default.useMemo(()=>new Set((n?.nodes??[]).filter(e=>e.type!==`start`&&!D.has(e.id)).map(e=>e.id)),[D,n]),k=b.default.useMemo(()=>{let e=new Map;if(!n)return e;for(let t of n.nodes){if(t.type!==`condition`)continue;let r=n.edges.filter(e=>e.source===t.id).map(e=>e.branch??`next`),i=[];r.includes(`true`)||i.push(`참 분기 누락`),r.includes(`false`)||i.push(`거짓 분기 누락`),r.includes(`next`)&&i.push(`조건에는 다음 대신 참·거짓 분기를 권장합니다`),i.length>0&&e.set(t.id,i)}return e},[n]),A=n?.nodes.filter(e=>e.type!==`start`)??[],j=b.default.useMemo(()=>n?.edges.filter(e=>e.source===c)??[],[n,c]),M=j.find(e=>e.id===u)??j[0]??null,N=n?.nodes.find(e=>e.id===M?.target);b.default.useEffect(()=>{if(j.length===0){f(null);return}(!u||!j.some(e=>e.id===u))&&f(j[0]?.id??null)},[u,j]),b.default.useEffect(()=>{n&&E.length!==0&&(a(n.id,{...n,edges:n.edges.filter(e=>T.has(e.source)&&T.has(e.target))}),m(`유효하지 않은 연결 ${E.length}개를 자동 정리했습니다.`))},[T,E,n,a]);let P=(e,t,r,i=n?.edges??[])=>e===t?`self-loop는 허용하지 않습니다.`:i.some(n=>n.id!==r&&n.source===e&&n.target===t)?`같은 시작 노드와 대상 노드 사이에 이미 연결이 있습니다.`:null,F=e=>{if(!n||!M)return;let t=[];for(let r of n.edges){if(r.id!==M.id){t.push(r);continue}let n=e(r),i=P(n.source,n.target,r.id);i?(m(i),t.push(r)):(m(``),t.push(n))}a(n.id,{...n,edges:t})},I=e=>{if(!n||!w)return;let t={id:d.t(`${w.id}-${e}`),source:w.id,target:e,branch:`next`},r=P(t.source,t.target);if(r){m(r);return}a(n.id,{...n,edges:[...n.edges,t]}),m(`도달 불가 노드 ${e}를 시작점에 연결했습니다.`)},L=()=>{if(!n||!w||O.size===0)return;let e=0,t=[...n.edges];for(let n of O)P(w.id,n,void 0,t)||(t.push({id:d.t(`${w.id}-${n}`),source:w.id,target:n,branch:`next`}),e+=1);if(e===0){m(`복구 가능한 도달 불가 노드가 없습니다.`);return}a(n.id,{...n,edges:t}),m(`도달 불가 노드 ${e}개를 시작점에 연결했습니다.`)},R=()=>{if(!n||!c)return;let e=A.find(e=>e.id!==c&&!n.edges.some(t=>t.source===c&&t.target===e.id));if(!e)return;let t={id:d.t(`${c}-${e.id}`),source:c,target:e.id,branch:`next`},r=P(t.source,t.target);if(r){m(r);return}a(n.id,{...n,edges:[...n.edges,t]}),m(``),f(t.id)},z=()=>{n&&M&&(a(n.id,{...n,edges:n.edges.filter(e=>e.id!==M.id)}),m(``),f(null))},B=(e,t)=>{if(!n)return;let r=n.nodes.find(t=>t.id===e);if(!r||r.type!==`condition`||n.edges.some(n=>n.source===e&&(n.branch??`next`)===t))return;let i=[...n.edges],o=A.find(t=>t.id!==e&&!i.some(n=>n.source===e&&n.target===t.id));if(!o){m(`${Z(t)} 분기를 추가할 대상 노드를 찾을 수 없습니다.`);return}let s=P(e,o.id,void 0,i);if(s){m(s);return}let c={id:d.t(`${e}-${t}-${o.id}`),source:e,target:o.id,branch:t};a(n.id,{...n,edges:[...i,c]}),f(c.id),m(`조건 ${e}에 ${Z(t)} 분기를 추가했습니다.`)},V=e=>{if(!n)return;let t=n.edges.filter(t=>t.source===e).map(e=>e.branch??`next`),r=!t.includes(`true`),i=!t.includes(`false`);if(!r&&!i)return;let o=[...n.edges],s=[...r?[`true`]:[],...i?[`false`]:[]],c=0;for(let t of s){if(o.some(n=>n.source===e&&(n.branch??`next`)===t))continue;let n=A.find(t=>t.id!==e&&!o.some(n=>n.source===e&&n.target===t.id));n&&(P(e,n.id,void 0,o)||(o.push({id:d.t(`${e}-${t}-${n.id}`),source:e,target:n.id,branch:t}),c+=1))}if(c===0){m(`자동 보완할 분기를 찾지 못했습니다.`);return}a(n.id,{...n,edges:o}),m(`누락 분기 ${c}개를 자동 보완했습니다.`)},ee=(e,t)=>{let n=Number(e);return Number.isFinite(n)?n:t};return{instance:e,blueprints:t,selectedBlueprint:n,updateBrain:r,addBrainBlueprint:i,updateBrainBlueprint:a,brainEditorRef:s,selectedNodeId:c,setSelectedNodeId:l,selectedEdgeId:u,setSelectedEdgeId:f,edgeIntegrityMessage:p,setEdgeIntegrityMessage:m,showReactFlowView:h,setShowReactFlowView:g,activeNpcTab:_,setActiveNpcTab:v,isInEditorModal:y,setIsInEditorModal:x,updateSelectedNode:S,selectedNode:C,primaryStartNode:w,blueprintNodeIds:T,danglingEdges:E,reachableNodeIds:D,orphanNodeIds:O,conditionBranchIssues:k,availableEdgeNodes:A,selectedNodeOutgoingEdges:j,selectedEdge:M,selectedEdgeTarget:N,getEdgeIntegrityError:P,updateSelectedEdge:F,recoverOrphanNode:I,recoverAllOrphans:L,addOutgoingEdge:R,removeSelectedEdge:z,addConditionBranchEdge:B,fixConditionBranches:V,parseNumeric:ee,updateVectorAxis:(e,t,n)=>{let r=[...e];return r[t]=ee(n,e[t]),r}}}var Rs=(0,b.lazy)(()=>Promise.resolve().then(()=>require("./flow-BnFTzumT.cjs")).then(e=>({default:e.BrainFlow})));function zs(e){let t=Ls(e),{instance:n,blueprints:r,selectedBlueprint:i,updateBrain:a,addBrainBlueprint:o,updateBrainBlueprint:s,brainEditorRef:c,selectedNodeId:l,setSelectedNodeId:u,selectedEdgeId:d,setSelectedEdgeId:f,showReactFlowView:p,setShowReactFlowView:m,activeNpcTab:h,setActiveNpcTab:g,isInEditorModal:_}=t;return(0,C.jsxs)(`div`,{className:`building-panel__npc-card building-panel__npc-card--brain`,children:[(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`AI 두뇌`}),(0,C.jsx)(`div`,{className:`building-panel__segmented`,children:vs.map(e=>(0,C.jsx)(`button`,{className:`building-panel__segment-btn ${n.brain?.mode===e?`building-panel__segment-btn--active`:``}`,onClick:()=>a(n.id,{mode:e}),children:Z(e)},e))})]}),(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`행동 블루프린트`}),(0,C.jsxs)(`div`,{className:`building-panel__grid`,children:[(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${n.brain?.blueprintId?``:`building-panel__grid-btn--active`}`,onClick:()=>a(n.id,{blueprintId:``}),children:`없음`}),r.map(e=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${n.brain?.blueprintId===e.id?`building-panel__grid-btn--active`:``}`,onClick:()=>a(n.id,{mode:`scripted`,blueprintId:e.id}),title:e.description,children:e.name},e.id))]}),i&&(0,C.jsx)(C.Fragment,{children:(0,C.jsxs)(`div`,{ref:c,className:`building-panel__node-editor`,children:[(0,C.jsxs)(`div`,{className:`building-panel__asset-targets building-panel__brain-summary`,children:[(0,C.jsx)(`span`,{children:i.name}),(0,C.jsxs)(`span`,{children:[i.nodes.length,` 노드 · `,i.edges.length,` 연결`]})]}),(0,C.jsxs)(`div`,{className:`building-panel__segmented building-panel__brain-toolbar`,children:[(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>{let e=To(i,n.id);o(e),a(n.id,{mode:`scripted`,blueprintId:e.id})},children:`전용 복제본`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>s(i.id,wo(i)),children:`초기화`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:()=>m(e=>!e),children:p?`캔버스 숨기기`:`캔버스 보기`})]}),p&&(0,C.jsx)(`div`,{className:`building-panel__brain-canvas`,style:{height:_?`64vh`:`320px`,border:`1px solid rgba(255,255,255,0.14)`,borderRadius:`8px`,overflow:`hidden`,marginBottom:`8px`,background:`#0f172a`},children:(0,C.jsx)(b.Suspense,{fallback:null,children:(0,C.jsx)(Rs,{blueprint:i,selectedNodeId:l,selectedEdgeId:d,onSelectNode:u,onSelectEdge:f,onDelete:(e,t)=>{let n=e.reduce(Co,i),r=new Set(t);s(i.id,{...n,edges:n.edges.filter(e=>!r.has(e.id))})}})})}),(0,C.jsxs)(`div`,{className:`building-panel__brain-tabs`,children:[(0,C.jsx)(`button`,{type:`button`,className:`building-panel__brain-tab ${h===`nodes`?`building-panel__brain-tab--active`:``}`,onClick:()=>g(`nodes`),children:`노드 목록`}),(0,C.jsx)(`button`,{type:`button`,className:`building-panel__brain-tab ${h===`inspector`?`building-panel__brain-tab--active`:``}`,onClick:()=>g(`inspector`),children:`노드 인스펙터`})]}),(0,C.jsx)(Ps,{editor:t}),(0,C.jsx)(Ns,{editor:t}),(0,C.jsx)(Fs,{editor:t})]})})]})}var Bs=b.default.memo(function({layout:e=`default`}){let t=p.a((0,w.useShallow)(e=>({templates:e.templates,instances:e.instances,animations:e.animations,brainBlueprints:e.brainBlueprints,selectedTemplateId:e.selectedTemplateId,selectedInstanceId:e.selectedInstanceId}))),{setSelectedTemplate:n,setSelectedInstance:r,updateInstance:i,updateInstanceBehavior:a,setNavigation:o,clearNavigation:s,updateInstanceBrain:c,updateInstancePerception:l,addBrainBlueprint:u,updateBrainBlueprint:d}=p.o().getState(),f=b.default.useMemo(()=>Array.from(t.templates.values()),[t.templates]),m=b.default.useMemo(()=>Array.from(t.instances.values()),[t.instances]),h=b.default.useMemo(()=>Array.from(t.animations.values()),[t.animations]),g=b.default.useMemo(()=>Array.from(t.brainBlueprints.values()),[t.brainBlueprints]),_=t.selectedTemplateId,v=t.selectedInstanceId??null,y=v?t.instances.get(v):void 0,x=y?.brain?.blueprintId?t.brainBlueprints.get(y.brain.blueprintId):void 0,[S,T]=b.default.useState(`movement`),[E,D]=b.default.useState({mode:`idle`,label:`대기`}),O=b.default.useMemo(()=>m.findIndex(e=>e.id===v),[m,v]),k=O>=0,A=b.default.useCallback(()=>{if(m.length===0)return;let e=k?(O-1+m.length)%m.length:0,t=m[e];t&&r(t.id)},[k,m,O,r]),j=b.default.useCallback(()=>{if(m.length===0)return;let e=k?(O+1)%m.length:0,t=m[e];t&&r(t.id)},[k,m,O,r]),M=b.default.useMemo(()=>y?S===`movement`?(0,C.jsx)(rs,{instance:y,updateBehavior:a,setNavigation:o,clearNavigation:s}):S===`animation`?(0,C.jsx)(is,{instance:y,animations:h,updateInstance:i,updateBehavior:a}):(0,C.jsx)(as,{instance:y,updateBrain:c,updatePerception:l}):null,[S,s,h,y,o,a,c,i,l]),N=y?(0,C.jsx)(rs,{instance:y,updateBehavior:a,setNavigation:o,clearNavigation:s}):null,P=y?(0,C.jsx)(is,{instance:y,animations:h,updateInstance:i,updateBehavior:a}):null,F=y?(0,C.jsx)(as,{instance:y,updateBrain:c,updatePerception:l}):null,I=(0,C.jsxs)(`div`,{className:`building-panel__asset-targets building-panel__npc-summary building-panel__npc-statusbar`,children:[(0,C.jsxs)(`span`,{children:[`선택 NPC: `,y?.name??v??`선택 없음`]}),(0,C.jsxs)(`span`,{children:[`행동: `,y?Z(y.behavior?.mode??`idle`):`없음`,` · 이동: `,Z(y?.navigation?.state??`없음`)]}),(0,C.jsxs)(`span`,{children:[`현재 애니메이션: `,y?h.find(e=>e.id===y.currentAnimation)?.name??Z(y.currentAnimation??`idle`):`없음`]})]}),L=(0,C.jsxs)(`div`,{className:`building-panel__npc-switcher`,children:[(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:A,disabled:m.length<2,children:`이전 NPC`}),(0,C.jsx)(`span`,{children:k?`${O+1} / ${m.length}`:`0 / ${m.length}`}),(0,C.jsx)(`button`,{className:`building-panel__segment-btn`,onClick:j,disabled:m.length<2,children:`다음 NPC`})]}),R=(0,C.jsxs)(`div`,{className:`building-panel__npc-head`,children:[(0,C.jsxs)(`div`,{className:`building-panel__npc-head-block`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`템플릿`}),(0,C.jsx)(`div`,{className:`building-panel__npc-chip-list`,children:f.map(e=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${_===e.id?`building-panel__grid-btn--active`:``}`,onClick:()=>n(e.id),children:e.name},e.id))})]}),(0,C.jsxs)(`div`,{className:`building-panel__npc-head-block`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`NPC 선택`}),(0,C.jsx)(`div`,{className:`building-panel__npc-chip-list`,children:m.map(e=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${v===e.id?`building-panel__grid-btn--active`:``}`,onClick:()=>r(e.id),children:e.name},e.id))})]})]}),z=y?(0,C.jsxs)(`div`,{className:`building-panel__npc-modal-controls`,children:[(0,C.jsxs)(`div`,{className:`building-panel__brain-tabs`,children:[(0,C.jsx)(`button`,{type:`button`,className:`building-panel__brain-tab ${S===`movement`?`building-panel__brain-tab--active`:``}`,onClick:()=>T(`movement`),children:`이동`}),(0,C.jsx)(`button`,{type:`button`,className:`building-panel__brain-tab ${S===`animation`?`building-panel__brain-tab--active`:``}`,onClick:()=>T(`animation`),children:`애니메이션`}),(0,C.jsx)(`button`,{type:`button`,className:`building-panel__brain-tab ${S===`perception`?`building-panel__brain-tab--active`:``}`,onClick:()=>T(`perception`),children:`지각`})]}),M]}):null,B=y?(0,C.jsxs)(`div`,{className:`building-panel__npc-card`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`미니 프리뷰 캔버스`}),(0,C.jsxs)(`div`,{className:`building-panel__asset-targets`,children:[(0,C.jsxs)(`span`,{children:[`노드 프리뷰: `,E.label]}),E.animationId&&(0,C.jsxs)(`span`,{children:[`애니메이션: `,E.animationId]})]}),(0,C.jsx)(`div`,{className:`building-panel__npc-avatar-canvas`,children:(0,C.jsx)(Us,{state:E,instance:y})})]}):null,V=y?(0,C.jsx)(zs,{instance:y,blueprints:g,selectedBlueprint:x,updateBrain:c,addBrainBlueprint:u,updateBrainBlueprint:d,onPreviewStateChange:D}):null,ee=(0,C.jsxs)(C.Fragment,{children:[f.length===0&&(0,C.jsx)(`div`,{className:`building-panel__empty`,children:`사용 가능한 NPC 템플릿이 없습니다.`}),m.length===0&&(0,C.jsx)(`div`,{className:`building-panel__empty`,children:`월드에 NPC를 배치하면 상세 편집이 열립니다.`})]});return e===`split`?(0,C.jsxs)(`div`,{className:`building-panel__section building-panel__npc-shell building-panel__npc-shell--split`,children:[(0,C.jsxs)(`div`,{className:`building-panel__npc-pane building-panel__npc-pane--left`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`선택`}),I,L,R,ee]}),(0,C.jsxs)(`div`,{className:`building-panel__npc-board`,children:[(0,C.jsxs)(`div`,{className:`building-panel__npc-pane building-panel__npc-pane--movement`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`이동`}),N]}),(0,C.jsxs)(`div`,{className:`building-panel__npc-pane building-panel__npc-pane--animation`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`애니메이션`}),P]}),(0,C.jsxs)(`div`,{className:`building-panel__npc-pane building-panel__npc-pane--perception`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`지각`}),F]})]}),(0,C.jsxs)(`div`,{className:`building-panel__npc-pane building-panel__npc-pane--right`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`두뇌/프리뷰`}),B,V]})]}):e===`sidebars`?(0,C.jsxs)(`div`,{className:`building-panel__section building-panel__npc-shell building-panel__npc-shell--sidebars`,children:[(0,C.jsxs)(`aside`,{className:`building-panel__npc-side building-panel__npc-side--left`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`NPC 선택`}),I,L,R,(0,C.jsxs)(`div`,{className:`building-panel__npc-board`,children:[(0,C.jsxs)(`div`,{className:`building-panel__npc-pane building-panel__npc-pane--movement`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`이동`}),N]}),(0,C.jsxs)(`div`,{className:`building-panel__npc-pane building-panel__npc-pane--animation`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`애니메이션`}),P]}),(0,C.jsxs)(`div`,{className:`building-panel__npc-pane building-panel__npc-pane--perception`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`지각`}),F]})]}),ee]}),(0,C.jsx)(`aside`,{className:`building-panel__npc-side building-panel__npc-side--right`,children:(0,C.jsxs)(`div`,{className:`building-panel__npc-pane building-panel__npc-pane--brain`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`두뇌/프리뷰`}),B,V]})})]}):(0,C.jsxs)(`div`,{className:`building-panel__section building-panel__npc-shell building-panel__npc-shell--modal`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`NPC 에디터`}),I,L,R,y&&(0,C.jsxs)(`div`,{className:`building-panel__npc-workspace building-panel__npc-workspace--modal`,children:[(0,C.jsx)(`div`,{className:`building-panel__npc-column building-panel__npc-column--controls`,children:z}),(0,C.jsxs)(`div`,{className:`building-panel__npc-column building-panel__npc-column--brain`,children:[B,V]})]}),ee]})}),Vs=.25;function Hs(e,t){let n=(e[0]-t[0])*Vs,r=(e[2]-t[2])*Vs;return[Math.max(-2.8,Math.min(2.8,n)),Math.max(-2.8,Math.min(2.8,r))]}function Us({state:e,instance:t}){let n=t.position,r=b.default.useMemo(()=>t.templateId?.trim()||p.c,[t.templateId]),i=b.default.useMemo(()=>{let i=`preview-${n.join(`-`)}`,a=e.waypoints&&e.waypoints.length>0?e.waypoints:[[n[0]+2,n[1],n[2]],[n[0],n[1],n[2]+2],[n[0]-2,n[1],n[2]],[n[0],n[1],n[2]-2]],o=e.mode===`move`&&e.target?{waypoints:[e.target],currentIndex:0,speed:1.7,state:`moving`}:e.mode===`patrol`?{waypoints:a,currentIndex:0,speed:1.6,state:`moving`}:e.mode===`wander`?{waypoints:a,currentIndex:0,speed:1.3,state:`moving`}:void 0;return{id:i,templateId:r,name:`${t.name}-preview`,position:[0,0,0],rotation:[0,0,0],scale:t.scale??[1,1,1],currentAnimation:e.animationId??t.currentAnimation??`idle`,...t.currentClothingSetId?{currentClothingSetId:t.currentClothingSetId}:{},...t.customParts?{customParts:t.customParts}:{},...t.metadata?{metadata:t.metadata}:{},brain:{mode:`none`},behavior:{mode:e.mode===`patrol`?`patrol`:e.mode===`wander`?`wander`:`idle`,speed:1.6},...o?{navigation:o}:{}}},[t,n,e.animationId,e.mode,e.target,e.waypoints,r]);return(0,C.jsxs)(S.Canvas,{camera:{position:[0,6.2,11.5],fov:34,near:.1,far:120},children:[(0,C.jsx)(c.n,{}),(0,C.jsx)(`ambientLight`,{intensity:.72}),(0,C.jsx)(`directionalLight`,{position:[5,8,4],intensity:1}),(0,C.jsx)(`gridHelper`,{args:[8,16,`#3b82f6`,`#1e293b`]}),(0,C.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],position:[0,-.01,0],receiveShadow:!0,children:[(0,C.jsx)(`circleGeometry`,{args:[3.2,48]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#0f172a`})]}),(0,C.jsx)(c.t,{gravity:[0,0,0],children:(0,C.jsx)(_.at,{instance:i,isEditMode:!1})}),(0,C.jsx)(Ws,{state:e,origin:n})]})}function Ws({state:e,origin:t}){let n=e.target?Hs(e.target,t):null;return(0,C.jsxs)(`group`,{children:[n&&(0,C.jsxs)(`mesh`,{position:[n[0],.12,n[1]],children:[(0,C.jsx)(`sphereGeometry`,{args:[.08,12,12]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#38bdf8`})]}),(e.waypoints??[]).map((e,n)=>{let r=Hs(e,t);return(0,C.jsxs)(`mesh`,{position:[r[0],.1,r[1]],children:[(0,C.jsx)(`sphereGeometry`,{args:[.06,10,10]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#34d399`})]},`${e.join(`-`)}-${n}`)}),e.mode===`wander`&&(0,C.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],position:[0,.03,0],children:[(0,C.jsx)(`ringGeometry`,{args:[Math.max(.35,(e.radius??4)*.16),Math.max(.45,(e.radius??4)*.16+.07),48]}),(0,C.jsx)(`meshStandardMaterial`,{color:`#f59e0b`,transparent:!0,opacity:.55})]})]})}var Gs=[{type:`none`,label:`없음`,description:`건축 편집을 끕니다`},{type:`world`,label:`전역`,description:`전역 설정을 배치합니다`},{type:`wall`,label:`벽`,description:`벽 조각을 배치합니다`},{type:`tile`,label:`타일`,description:`바닥 타일을 배치합니다`},{type:`block`,label:`박스`,description:`복셀 박스를 쌓습니다`},{type:`object`,label:`오브젝트`,description:`타일 위에 장식을 배치합니다`}],Ks=[...Gs,{type:`npc`,label:`NPC`,description:`NPC를 배치합니다`}],qs={},Js=[],Ys=[],Xs=[`editMode`,`selectedPlacedObjectType`],Zs=({className:e=``,style:t,children:n,slots:r=qs,actions:i=Js,disabledSections:a=Ys,forcedEditMode:o,npcLayout:s=`default`,npcPanel:c,hideHeader:u=!1})=>{let d=l.Wt(),f=p.o(),m=(0,b.useMemo)(()=>new Set(a),[a]),{editMode:h,selectedPlacedObjectType:g}=Q(Xs),_=b.default.useRef([]),v=c!==!1,y=v?Ks:Gs,x=o??h,S=y.find(e=>e.type===x)?.label??x,w=x===`wall`,T=x===`world`,E=x===`tile`,D=x===`block`,O=x===`object`,k=x===`npc`&&v;return b.default.useEffect(()=>{v&&f.getState().initializeDefaults()},[v,f]),b.default.useEffect(()=>{if(!o)return;let e=d.getState().editMode;return d.getState().setEditMode(o),()=>{d.getState().editMode===o&&d.getState().setEditMode(e)}},[d,o]),b.default.useEffect(()=>{o&&h!==o&&d.getState().setEditMode(o)},[d,h,o]),b.default.useEffect(()=>()=>{_.current.forEach(e=>URL.revokeObjectURL(e)),_.current=[]},[]),(0,C.jsxs)(`div`,{className:`building-panel ${e}`,style:t,children:[!u&&(0,C.jsxs)(`div`,{className:`building-panel__header`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`building-panel__eyebrow`,children:`모드`}),(0,C.jsxs)(`div`,{className:`building-panel__title`,children:[S,` 인스펙터`]})]}),!o&&(0,C.jsx)(`div`,{className:`building-panel__mode-tabs`,children:y.map(e=>(0,C.jsx)(`button`,{className:`building-panel__mode-tab ${h===e.type?`building-panel__mode-tab--active`:``}`,onClick:()=>d.getState().setEditMode(e.type),title:e.description,children:e.label},e.type))})]}),r.header,(0,C.jsxs)(`div`,{className:`building-panel__inspector`,children:[r.beforeInspector,(0,C.jsx)(Ho,{actions:i}),T&&!m.has(`environment`)&&(0,C.jsx)(Wo,{}),w&&!m.has(`wallPresets`)&&(0,C.jsx)(Qs,{}),w&&!m.has(`wallModules`)&&(0,C.jsx)(ts,{}),w&&r.afterWallSettings,(w||E)&&!m.has(`assetMaterials`)&&(0,C.jsx)(ec,{isWallMode:w,isTileMode:E}),E&&!m.has(`tilePresets`)&&(0,C.jsx)(tc,{}),E&&!m.has(`customTile`)&&(0,C.jsx)(rc,{objectUrls:_}),E&&!m.has(`terrainCover`)&&(0,C.jsx)(ac,{}),O&&!m.has(`objectPresets`)&&(0,C.jsx)(oc,{}),O&&g===`model`&&!m.has(`modelSettings`)&&(0,C.jsx)(cc,{}),(E||D)&&!m.has(`placement`)&&(0,C.jsx)(Yo,{isTileMode:E}),D&&(0,C.jsx)($o,{}),E&&r.afterTileSettings,E&&!m.has(`tileColor`)&&(0,C.jsx)(uc,{}),k&&(()=>{if(c!==void 0&&typeof c!=`function`)return c;let e=(0,C.jsx)(Bs,{layout:s});return c===void 0?e:c({editMode:`npc`,layout:s,defaultPanel:e})})(),O&&g!==`none`&&!m.has(`objectRotation`)&&(0,C.jsx)(Ko,{}),O&&(g===`tree`||g===`sakura`)&&!m.has(`treeSettings`)&&(0,C.jsx)(us,{}),O&&g===`fire`&&!m.has(`fireSettings`)&&(0,C.jsx)(fs,{}),O&&g===`billboard`&&!m.has(`billboardSettings`)&&(0,C.jsx)(hs,{}),O&&g===`flag`&&!m.has(`flagSettings`)&&(0,C.jsx)(_s,{}),O&&r.afterObjectSettings,n]})]})},Qs=b.default.memo(function(){let e=l.Ut(e=>e.selectedWallGroupId),{applyWallPreset:t}=l.Wt().getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`벽 프리셋`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:l.on.map(n=>{let r=`${n.id}-walls`;return(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${e===r?`building-panel__grid-btn--active`:``}`,onClick:()=>t(n.id),title:n.labelEn,children:n.labelKo},n.id)})})]})}),$s=[`selectedTileId`,`currentTileMaterialId`],ec=b.default.memo(function({isWallMode:e,isTileMode:t}){let n=l.Wt(),r=No(),{selectedTileId:i,currentTileMaterialId:a}=Q($s),{group:o}=jo(),{group:s}=Mo();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`에셋 재질`}),(0,C.jsxs)(`div`,{className:`building-panel__asset-targets`,children:[e&&(0,C.jsxs)(`span`,{children:[`벽: `,o?.name??`선택 없음`]}),t&&(0,C.jsxs)(`span`,{children:[`타일: `,i?`선택 타일 ${i}`:`다음 생성 타일`]}),t&&(0,C.jsxs)(`span`,{children:[`현재 생성 재질: `,a?`사용자 지정 재질`:s?.name??`기본값`]})]}),(0,C.jsxs)(`div`,{className:`building-panel__asset-list`,children:[r.map(r=>(0,C.jsxs)(`div`,{className:`building-panel__asset-card`,children:[(0,C.jsx)(g.t,{asset:r,size:54}),(0,C.jsxs)(`div`,{className:`building-panel__asset-info`,children:[(0,C.jsx)(`strong`,{children:r.name}),(0,C.jsx)(`span`,{children:r.kind===`wall`?`벽`:r.kind===`tile`?`바닥`:`재질`})]}),(0,C.jsxs)(`div`,{className:`building-panel__asset-actions`,children:[e&&(0,C.jsx)(`button`,{className:`building-panel__asset-action`,disabled:!o,onClick:()=>Io(n,r),children:`벽`}),t&&(0,C.jsx)(`button`,{className:`building-panel__asset-action`,disabled:!s,onClick:()=>Lo(n,r),children:`타일`})]})]},r.id)),r.length===0&&(0,C.jsx)(`div`,{className:`building-panel__empty`,children:`사용 가능한 빌딩 에셋이 없습니다.`})]})]})}),tc=b.default.memo(function(){let e=l.Ut(e=>e.selectedTileGroupId),{applyTilePreset:t}=l.Wt().getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`타일 프리셋`}),(0,C.jsx)(`div`,{className:`building-panel__section-subtitle`,children:`클릭해 선택하거나, 월드 화면으로 끌어다 놓으면 그 자리에 배치됩니다`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:l.en.map(n=>{let r=`${n.id}-floor`;return(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${e===r?`building-panel__grid-btn--active`:``}`,onClick:()=>t(n.id),draggable:!0,onDragStart:e=>{e.dataTransfer.setData(l.tn,n.id),e.dataTransfer.effectAllowed=`copy`,t(n.id)},title:n.labelEn,children:n.labelKo},n.id)})})]})}),nc=[`currentCustomTileName`,`currentCustomTileColor`,`currentCustomTileTextureUrl`],rc=b.default.memo(function({objectUrls:e}){let t=l.Wt(),{currentCustomTileName:n,currentCustomTileColor:r,currentCustomTileTextureUrl:i}=Q(nc),{setCustomTileDraft:a,applyCustomTile:o}=t.getState(),s=b.default.useCallback(n=>{if(!n||!n.type.startsWith(`image/`))return;let r=URL.createObjectURL(n);e.current.push(r);let i=n.name.replace(/\.[^.]+$/,``).trim(),a={id:d.t(`custom-tile-texture`),name:i||`사용자 지정 타일 텍스처`,kind:`tile`,metadata:{textureUrl:r}};t.getState().setCustomTileDraft({textureUrl:r,...i?{name:i}:{}}),Lo(t,a)},[t,e]),c=b.default.useCallback(e=>{e.preventDefault(),s(e.dataTransfer.files.item(0))},[s]),u=b.default.useCallback(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`copy`},[]),f=b.default.useCallback(e=>{s(e.target.files?.item(0)),e.target.value=``},[s]);return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`커스텀 타일 맵`}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsxs)(`label`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`이름`}),(0,C.jsx)(`input`,{type:`text`,value:n,onChange:e=>a({name:e.target.value}),className:`building-panel__text-input`})]}),(0,C.jsx)($,{label:`기본색`,children:(0,C.jsx)(Vo,{value:r,onChange:e=>a({color:e})})}),(0,C.jsxs)(`label`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`텍스처 URL`}),(0,C.jsx)(`input`,{type:`text`,value:i,onChange:e=>a({textureUrl:e.target.value}),placeholder:`textures/floor.png`,className:`building-panel__text-input`})]}),(0,C.jsxs)(`div`,{className:`building-panel__texture-dropzone`,onDrop:c,onDragOver:u,children:[(0,C.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:f,className:`building-panel__texture-file-input`}),(0,C.jsx)(`span`,{className:`building-panel__texture-dropzone-title`,children:`이미지 추가`}),(0,C.jsx)(`span`,{className:`building-panel__texture-dropzone-text`,children:`바닥 텍스처 이미지를 끌어 놓거나 선택하세요`})]}),(0,C.jsx)(`button`,{className:`building-panel__asset-action`,onClick:o,children:`별도 타일 맵 생성/선택`}),(0,C.jsx)(`div`,{className:`building-panel__drag-chip`,draggable:!0,onDragStart:e=>{o();let n=t.getState().selectedTileGroupId;n&&(e.dataTransfer.setData(l.Qt,n),e.dataTransfer.effectAllowed=`copy`)},title:`월드 화면으로 끌어다 놓으면 그 자리에 이 커스텀 타일이 배치됩니다`,children:`⠿ 끌어서 월드에 배치`})]})]})}),ic=[`selectedTileObjectType`,`currentTerrainColor`,`currentTerrainAccentColor`],ac=b.default.memo(function(){let e=l.Wt(),{selectedTileObjectType:t,currentTerrainColor:n,currentTerrainAccentColor:r}=Q(ic),{setSelectedTileObjectType:i}=e.getState();return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`지형 덮개`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:l.$t.map(e=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${t===e.type?`building-panel__grid-btn--active`:``}`,onClick:()=>i(e.type),children:e.labelKo},e.type))}),(0,C.jsxs)(`div`,{className:`building-panel__terrain-colors`,children:[(0,C.jsxs)(`label`,{children:[(0,C.jsx)(`span`,{children:`기본색`}),(0,C.jsx)(`input`,{type:`color`,value:n,onChange:t=>zo(e,t.target.value,r)})]}),(0,C.jsxs)(`label`,{children:[(0,C.jsx)(`span`,{children:`강조색`}),(0,C.jsx)(`input`,{type:`color`,value:r,onChange:t=>zo(e,n,t.target.value)})]})]})]})}),oc=b.default.memo(function(){let e=l.Wt(),t=l.Ut(e=>e.selectedPlacedObjectType);return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`배치 오브젝트`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:l.Zt.map(n=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${t===n.type?`building-panel__grid-btn--active`:``}`,onClick:()=>{let t=e.getState();t.setSelectedPlacedObjectType(n.type);let r=_.it(t.selectedModelObjectId)??_.rt[0];n.type===`model`&&r&&(t.setModelScale(r.defaultScale),t.setModelColor(r.defaultColor),t.setModelUrl(r.modelUrl??``))},children:n.labelKo},n.type))})]})}),sc=[`selectedModelObjectId`,`currentModelUrl`,`currentModelScale`,`currentModelColor`],cc=b.default.memo(function(){let{selectedModelObjectId:e,currentModelUrl:t,currentModelScale:n,currentModelColor:r}=Q(sc),{setSelectedModelObjectId:i,setModelScale:a,setModelColor:o,setModelUrl:s}=l.Wt().getState(),c=_.it(e)??_.rt[0];return(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`기본 기물 GLB`}),(0,C.jsx)(`div`,{className:`building-panel__grid`,children:_.rt.map(t=>(0,C.jsx)(`button`,{className:`building-panel__grid-btn ${e===t.id?`building-panel__grid-btn--active`:``}`,onClick:()=>{i(t.id),a(t.defaultScale),o(t.defaultColor),s(t.modelUrl??``)},children:t.label},t.id))}),(0,C.jsxs)(`div`,{className:`building-panel__info`,children:[(0,C.jsxs)(`label`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`GLB 파일 주소`}),(0,C.jsx)(`input`,{type:`text`,value:t,onChange:e=>s(e.target.value),placeholder:`gltf/props/door.glb`,className:`building-panel__text-input`})]}),(0,C.jsxs)(`label`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`스케일`}),(0,C.jsx)(`input`,{type:`number`,min:`0.1`,max:`10`,step:`0.1`,value:n,onChange:e=>a(Number(e.target.value)||1),className:`building-panel__number-input`})]}),(0,C.jsxs)(`label`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`색상`}),(0,C.jsx)(`input`,{type:`color`,value:r,onChange:e=>o(e.target.value),style:{width:`36px`,height:`24px`,border:`none`,cursor:`pointer`,background:`none`}}),(0,C.jsx)(`span`,{className:`building-panel__info-value`,style:{fontSize:`10px`},children:r})]}),(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`대체 표시`}),(0,C.jsx)(`span`,{className:`building-panel__info-value`,children:c?.fallbackKind??`generic`})]})]})]})}),lc=[`selectedTileGroupId`,`currentTileMaterialId`,`tileGroups`,`meshes`],uc=b.default.memo(function(){let e=l.Wt(),{selectedTileGroupId:t,currentTileMaterialId:n,tileGroups:r,meshes:i}=Q(lc),{tile:a}=Mo();if(!t)return null;let o=a?.materialId??n??r.get(t)?.floorMeshId,s=o?i.get(o):void 0;return s?(0,C.jsxs)(`div`,{className:`building-panel__section`,children:[(0,C.jsx)(`div`,{className:`building-panel__section-title`,children:`타일 색상`}),(0,C.jsx)(`div`,{className:`building-panel__info`,children:(0,C.jsxs)(`div`,{className:`building-panel__info-item`,children:[(0,C.jsx)(`span`,{className:`building-panel__info-label`,children:`색상`}),(0,C.jsx)(`input`,{type:`color`,value:s.color||`#888888`,onChange:t=>Ro(e,t.target.value),style:{width:`36px`,height:`24px`,border:`none`,cursor:`pointer`,background:`none`}}),(0,C.jsx)(`span`,{className:`building-panel__info-value`,style:{fontSize:`10px`},children:s.color||`#888888`})]})})]}):null});function dc(e={}){return(0,C.jsx)(Zs,{...e,forcedEditMode:`world`})}function fc(e={}){return(0,C.jsx)(Zs,{...e,forcedEditMode:`wall`})}function pc(e={}){return(0,C.jsx)(Zs,{...e,forcedEditMode:`tile`})}function mc(e={}){return(0,C.jsx)(Zs,{...e,forcedEditMode:`block`})}function hc(e={}){return(0,C.jsx)(Zs,{...e,forcedEditMode:`object`})}function gc(e={}){return(0,C.jsx)(Zs,{...e,forcedEditMode:`npc`})}var _c=Object.keys(m.D),vc=(e,t)=>t===`weapon`?e.kind===`weapon`||e.slot===`weapon`:e.slot===t&&(e.kind===`characterPart`||e.kind===`weapon`),yc=({className:e=``,style:t,children:n})=>{let r=m.S(e=>e.activeCharacterId),i=m.S(e=>e.outfits),a=m.S(e=>e.equipOutfit),s=m.S(e=>e.resetAppearance),c=o.i(e=>e.ids),l=o.i(e=>e.records),u=o.i(e=>e.isLoading),d=o.i(e=>e.error),[f,p]=(0,b.useState)(`top`),[h,_]=(0,b.useState)(``),[v,y]=(0,b.useState)(!1),x=(0,b.useMemo)(()=>{let e=h.trim().toLowerCase();return c.map(e=>l[e]).filter(e=>!!e).filter(e=>vc(e,f)).filter(t=>!e||t.name.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.tags?.some(t=>t.toLowerCase().includes(e))??!1)).filter(e=>!v||e.metadata?.owned!==!1)},[c,l,v,f,h]);return(0,C.jsxs)(`div`,{className:`character-asset-panel ${e}`,style:t,children:[(0,C.jsxs)(`section`,{className:`character-asset-panel__section`,children:[(0,C.jsxs)(`div`,{className:`character-asset-panel__header`,children:[(0,C.jsx)(`span`,{className:`character-asset-panel__section-title`,children:`캐릭터 에셋`}),(0,C.jsx)(`button`,{className:`character-asset-panel__ghost-btn`,onClick:()=>s(r),type:`button`,children:`초기화`})]}),(0,C.jsx)(`div`,{className:`character-asset-panel__slot-grid`,children:_c.map(e=>(0,C.jsxs)(`button`,{type:`button`,"aria-pressed":f===e,className:`character-asset-panel__slot-btn ${f===e?`character-asset-panel__slot-btn--active`:``}`,onClick:()=>p(e),children:[(0,C.jsx)(`span`,{children:m.D[e]}),(0,C.jsx)(`small`,{children:i[e]?l[i[e]]?.name??`에셋 정보 없음`:`비어 있음`})]},e))})]}),(0,C.jsxs)(`section`,{className:`character-asset-panel__section`,children:[(0,C.jsxs)(`div`,{className:`character-asset-panel__filters`,children:[(0,C.jsx)(`input`,{type:`search`,value:h,onChange:e=>_(e.target.value),placeholder:`이름 또는 태그 검색`,"aria-label":`캐릭터 에셋 검색`,className:`character-asset-panel__input`}),(0,C.jsxs)(`label`,{className:`character-asset-panel__check`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:v,onChange:e=>y(e.target.checked)}),`보유만`]})]}),d&&!u&&(0,C.jsx)(`p`,{className:`character-asset-panel__notice`,role:`alert`,children:`새 에셋 목록을 불러오지 못했습니다. 현재 사용 가능한 에셋을 표시합니다.`}),u&&(0,C.jsx)(`p`,{className:`character-asset-panel__notice`,role:`status`,children:`에셋을 불러오고 있습니다.`}),(0,C.jsxs)(`div`,{className:`character-asset-panel__asset-list`,children:[(0,C.jsxs)(`button`,{type:`button`,"aria-pressed":i[f]===null,className:`character-asset-panel__asset-card ${i[f]===null?`character-asset-panel__asset-card--active`:``}`,onClick:()=>a(f,null),children:[(0,C.jsx)(`div`,{className:`character-asset-panel__empty-preview`}),(0,C.jsx)(`span`,{children:`비우기`})]}),x.map(e=>(0,C.jsxs)(`button`,{type:`button`,"aria-pressed":i[f]===e.id,className:`character-asset-panel__asset-card ${i[f]===e.id?`character-asset-panel__asset-card--active`:``}`,onClick:()=>a(f,e.id),children:[(0,C.jsx)(g.t,{asset:e,size:58}),(0,C.jsx)(`span`,{children:e.name})]},e.id)),x.length===0&&!u&&!d&&(0,C.jsx)(`p`,{className:`character-asset-panel__notice`,role:`status`,children:h.trim()||v?`검색 조건에 맞는 에셋이 없습니다.`:`선택한 부위에 사용할 에셋이 없습니다.`})]})]}),n]})},bc={manual:`수동`,interaction:`상호작용`,enterArea:`영역 진입`,timeChanged:`시간 변경`,custom:`커스텀`},xc={info:`안내`,success:`성공`,warn:`주의`,error:`오류`,reward:`보상`,mail:`우편`},Sc={dialogTreeId:`대화 ID`,npcId:`NPC ID`,kind:`알림 종류`,text:`내용`,eventName:`이벤트 이름`,id:`ID`,name:`이름`,description:`설명`,type:`타입`,key:`키`,run:`실행 방식`,cooldownMs:`쿨다운(ms)`,requiresServer:`서버 필요`,targetId:`대상 ID`,action:`액션`,areaId:`영역 ID`,hour:`시간`,operator:`연산자`,value:`값`,message:`메시지`,toast:`토스트`,durationMs:`지속시간(ms)`},Cc={always:`항상`,flagEquals:`상태 값 일치`,custom:`사용자 정의`},wc={showDialog:`대화 표시`,toast:`알림 표시`,setFlag:`상태 값 설정`,emit:`이벤트 발생`,custom:`사용자 정의`},Tc={...bc,...Cc,...wc},Ec=new Set([`e`,`f`]),Dc=e=>{let t=e.trim().toLowerCase();return t.length===1&&Ec.has(t)},Oc=e=>{let t=e.trigger;switch(t.type){case`manual`:return{type:`manual`,key:t.key};case`interaction`:return{type:`interaction`,targetId:t.targetId,...t.action?{action:t.action}:{}};case`enterArea`:return{type:`enterArea`,areaId:t.areaId};case`timeChanged`:return{type:`timeChanged`,...t.hour===void 0?{}:{hour:t.hour}};case`custom`:return{type:`custom`,key:t.key};default:return t}},kc=e=>{if(e===`true`)return!0;if(e===`false`)return!1;let t=Number(e);return Number.isFinite(t)&&e.trim()!==``?t:e};function Ac({blueprints:e=v.l,onCreate:t,onUpdate:n,onDelete:a,onRun:o,className:s=``,style:c,children:l}){let u=i.n(),d=(0,b.useMemo)(()=>u?.gameplayEvents??new h.t,[u]),[f,p]=(0,b.useState)(`manual-event`),[m,g]=(0,b.useState)(`수동 이벤트`),[_,y]=(0,b.useState)(`manual.event`),[x,S]=(0,b.useState)(`이벤트가 실행되었습니다.`),[w,T]=(0,b.useState)(null),[E,D]=(0,b.useState)(!1),O=(0,b.useMemo)(()=>e.find(e=>e.id===w)??null,[e,w]),[k,A]=(0,b.useState)({kind:`idle`,message:`대기 중`}),[j,M]=(0,b.useState)(!1),N=(0,b.useRef)(!1),P=()=>{if(Dc(_)){A({kind:`error`,message:`트리거 키 "${_}" 는 월드 단축키로 예약되어 있습니다.`});return}let e=v.s({id:f,name:m,triggerKey:_,message:x});t?.(e),T(e.id),D(!0),A({kind:`success`,message:`이벤트를 생성했습니다: ${e.id}`})},F=()=>{let e=f.trim(),n=m.trim(),r=v.c({...e?{id:`${e}-npc-talk`}:{},...n?{name:`${n} NPC 대화`}:{}});t?.(r),T(r.id),D(!0),A({kind:`success`,message:`NPC 대화 프리셋을 추가했습니다: ${r.id}`})},I=(0,b.useCallback)(e=>{if(!O)return;let t={...O,...e};n?.(t),T(t.id),A({kind:`success`,message:`이벤트를 수정했습니다: ${t.id}`})},[n,O]),L=()=>{if(!O)return;a?.(O.id);let t=e.find(e=>e.id!==O.id)??null;T(t?.id??null),D(!1),A({kind:`success`,message:`이벤트를 삭제했습니다: ${O.id}`})},R=async e=>{if(!N.current){N.current=!0,M(!0),A({kind:`idle`,message:`이벤트 실행 중: ${e.name}`});try{let t=Oc(e);if(o)await o(t);else{let n=await d.preview(e,t);if(n.skipped||n.actionCount===0){let e=n.skipped===`already-executed`?`이미 실행한 일회성 이벤트입니다.`:n.skipped===`cooldown`?`다시 실행하려면 대기 시간이 필요합니다.`:n.skipped===`requires-server`?`서버에서 실행해야 하는 이벤트입니다.`:n.skipped?.startsWith(`condition:`)?`실행 조건을 충족하지 못했습니다.`:`실행된 동작이 없습니다. 이벤트 활성화와 동작 설정을 확인하세요.`;A({kind:`idle`,message:e});return}A({kind:`success`,message:`이벤트를 시험했습니다: ${e.name} (동작 ${n.actionCount}개, 실제 보상 없음)`});return}A({kind:`success`,message:`이벤트를 실행했습니다: ${e.name}`})}catch(t){r.t.error(`Gameplay event execution failed`,t instanceof Error?t:String(t)),A({kind:`error`,message:`이벤트 실행에 실패했습니다: ${e.name}`})}finally{N.current=!1,M(!1)}}},z=(0,b.useCallback)((e,t)=>{if(!O)return;let n=[...O.conditions??[]];n[e]=t,I({conditions:n})},[O,I]),B=(0,b.useCallback)((e,t)=>{if(!O)return;let n=[...O.actions];n[e]=t,I({actions:n})},[O,I]),V=(0,b.useCallback)((e,t,n)=>{if(!O||t===`type`)return;let r=n;if(e===`root`){I({[t]:r});return}if(e===`policy`){t===`run`&&(r===`once`||r===`repeat`)&&I({policy:{...O.policy,run:r}}),t===`cooldownMs`&&I({policy:{...O.policy,cooldownMs:Number(r)}}),t===`requiresServer`&&I({policy:{...O.policy,requiresServer:kc(String(r))===!0}});return}if(e===`trigger`){let e=O.trigger;if(e.type===`manual`&&t===`key`){let e=String(r);if(Dc(e)){A({kind:`error`,message:`트리거 키 "${e}" 는 월드 단축키로 예약되어 있습니다.`});return}I({trigger:{type:`manual`,key:e}})}if(e.type===`interaction`&&(t===`targetId`||t===`action`)&&I({trigger:{...e,[t]:String(r)}}),e.type===`enterArea`&&t===`areaId`&&I({trigger:{type:`enterArea`,areaId:String(r)}}),e.type===`timeChanged`&&t===`hour`&&I({trigger:{type:`timeChanged`,hour:Number(r)}}),e.type===`custom`&&t===`key`){let e=String(r);if(Dc(e)){A({kind:`error`,message:`트리거 키 "${e}" 는 월드 단축키로 예약되어 있습니다.`});return}I({trigger:{type:`custom`,key:e}})}return}if(e.startsWith(`condition:`)){let n=Number(e.split(`:`)[1]),i=O.conditions?.[n];if(!i)return;z(n,{...i,[t]:t===`value`?kc(String(r)):r});return}if(e.startsWith(`action:`)){let n=Number(e.split(`:`)[1]),i=O.actions[n];if(!i)return;B(n,{...i,[t]:t===`value`?kc(String(r)):r})}},[O,B,z,I]),ee=(0,b.useCallback)(e=>{if(O){if(e.startsWith(`condition:`)){let t=Number(e.split(`:`)[1]);I({conditions:(O.conditions??[]).filter((e,n)=>n!==t)});return}if(e.startsWith(`action:`)){let t=Number(e.split(`:`)[1]);I({actions:O.actions.filter((e,n)=>n!==t)})}}},[O,I]),H=(e,t)=>(0,C.jsx)(`div`,{className:`gameplay-event-panel__field-grid`,children:Object.entries(t).map(([n,r])=>(0,C.jsxs)(`label`,{className:`gameplay-event-panel__field`,children:[(0,C.jsx)(`span`,{children:Sc[n]??n}),e===`policy`&&n===`run`?(0,C.jsxs)(`select`,{value:String(r),onChange:t=>V(e,n,t.target.value),children:[(0,C.jsx)(`option`,{value:`once`,children:`한 번만 실행`}),(0,C.jsx)(`option`,{value:`repeat`,children:`반복 실행`})]}):e===`policy`&&n===`requiresServer`?(0,C.jsxs)(`select`,{value:String(r),onChange:t=>V(e,n,t.target.value===`true`),children:[(0,C.jsx)(`option`,{value:`false`,children:`필요 없음`}),(0,C.jsx)(`option`,{value:`true`,children:`서버에서만 실행`})]}):n===`kind`&&t.type===`toast`?(0,C.jsx)(`select`,{value:String(r),onChange:t=>V(e,n,t.target.value),children:Object.entries(xc).map(([e,t])=>(0,C.jsx)(`option`,{value:e,children:t},e))}):(0,C.jsx)(`input`,{type:typeof r==`number`?`number`:`text`,value:n===`type`?Tc[String(r)]??String(r):String(r),disabled:n===`type`,onChange:t=>V(e,n,n===`value`||typeof r==`number`?kc(t.target.value):t.target.value)})]},`${e}-${n}`))});return(0,C.jsxs)(`div`,{className:`gameplay-event-panel ${s}`,style:c,children:[(0,C.jsxs)(`section`,{className:`gameplay-event-panel__section`,children:[(0,C.jsx)(`div`,{className:`gameplay-event-panel__title`,children:`빠른 생성`}),(0,C.jsxs)(`label`,{className:`gameplay-event-panel__field`,children:[(0,C.jsx)(`span`,{children:`ID`}),(0,C.jsx)(`input`,{value:f,onChange:e=>p(e.target.value)})]}),(0,C.jsxs)(`label`,{className:`gameplay-event-panel__field`,children:[(0,C.jsx)(`span`,{children:`이름`}),(0,C.jsx)(`input`,{value:m,onChange:e=>g(e.target.value)})]}),(0,C.jsxs)(`label`,{className:`gameplay-event-panel__field`,children:[(0,C.jsx)(`span`,{children:`트리거 키`}),(0,C.jsx)(`input`,{value:_,onChange:e=>y(e.target.value)})]}),(0,C.jsx)(`div`,{className:`gameplay-event-panel__hint`,children:"`e`(상호작용)와 `f`(탑승)는 월드 단축키로 예약됩니다."}),(0,C.jsxs)(`label`,{className:`gameplay-event-panel__field`,children:[(0,C.jsx)(`span`,{children:`토스트 메시지`}),(0,C.jsx)(`input`,{value:x,onChange:e=>S(e.target.value)})]}),(0,C.jsx)(`button`,{type:`button`,className:`gameplay-event-panel__primary`,onClick:P,children:`수동 이벤트 생성`}),(0,C.jsx)(`button`,{type:`button`,className:`gameplay-event-panel__primary`,onClick:F,children:`NPC 대화 프리셋 추가`})]}),(0,C.jsxs)(`section`,{className:`gameplay-event-panel__section`,children:[(0,C.jsx)(`div`,{className:`gameplay-event-panel__title`,children:`이벤트 목록`}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__list`,children:[e.map(e=>(0,C.jsxs)(`article`,{className:`gameplay-event-panel__card`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`gameplay-event-panel__card-title`,children:e.name}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__card-meta`,children:[e.id,` · `,bc[e.trigger.type],` · 액션 `,e.actions.length,`개`]})]}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__card-actions`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>{T(e.id),D(!0)},children:`편집`}),(0,C.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>{R(e)},children:`실행`})]})]},e.id)),e.length===0&&(0,C.jsx)(`div`,{className:`gameplay-event-panel__empty`,children:`등록된 이벤트가 없습니다. 위에서 새 이벤트를 생성하세요.`})]})]}),O&&(0,C.jsxs)(`section`,{className:`gameplay-event-panel__section gameplay-event-panel__detail`,children:[(0,C.jsxs)(`div`,{className:`gameplay-event-panel__editor-head`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`gameplay-event-panel__title`,children:`이벤트 인스펙터`}),(0,C.jsx)(`div`,{className:`gameplay-event-panel__hint`,children:`그래프 노드 대신 트리거, 조건, 액션을 섹션별 인스펙터에서 수정합니다.`})]}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__editor-tools`,children:[(0,C.jsxs)(`label`,{className:`gameplay-event-panel__type-select`,children:[(0,C.jsx)(`span`,{children:`트리거 타입`}),(0,C.jsx)(`select`,{value:O.trigger.type,onChange:e=>I({trigger:v.o(e.target.value)}),children:v.r.map(e=>(0,C.jsx)(`option`,{value:e,children:bc[e]},e))})]}),(0,C.jsx)(`button`,{type:`button`,className:`gameplay-event-panel__primary`,onClick:()=>D(e=>!e),children:E?`상세 편집 접기`:`상세 편집 열기`})]})]}),E?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`gameplay-event-panel__inspector`,children:[(0,C.jsxs)(`div`,{className:`gameplay-event-panel__inspector-card`,children:[(0,C.jsx)(`div`,{className:`gameplay-event-panel__subhead`,children:`기본 정보`}),H(`root`,{id:O.id,name:O.name,description:O.description??``})]}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__inspector-card`,children:[(0,C.jsx)(`div`,{className:`gameplay-event-panel__subhead`,children:`트리거`}),H(`trigger`,O.trigger)]}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__inspector-card`,children:[(0,C.jsx)(`div`,{className:`gameplay-event-panel__subhead`,children:`실행 정책`}),H(`policy`,{run:O.policy?.run??`repeat`,cooldownMs:O.policy?.cooldownMs??0,requiresServer:O.policy?.requiresServer??!1})]}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__inspector-card`,children:[(0,C.jsx)(`div`,{className:`gameplay-event-panel__subhead`,children:`조건`}),(O.conditions??[]).map((e,t)=>(0,C.jsxs)(`div`,{className:`gameplay-event-panel__item-editor`,children:[H(`condition:${t}`,e),(0,C.jsx)(`button`,{type:`button`,onClick:()=>ee(`condition:${t}`),children:`삭제`})]},`condition-${t}`)),(O.conditions??[]).length===0&&(0,C.jsx)(`div`,{className:`gameplay-event-panel__hint`,children:`조건 없음`})]}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__inspector-card`,children:[(0,C.jsx)(`div`,{className:`gameplay-event-panel__subhead`,children:`액션`}),O.actions.map((e,t)=>(0,C.jsxs)(`div`,{className:`gameplay-event-panel__item-editor`,children:[H(`action:${t}`,e),(0,C.jsx)(`button`,{type:`button`,onClick:()=>ee(`action:${t}`),children:`삭제`})]},`action-${t}`))]})]}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__node-toolbar`,children:[(0,C.jsxs)(`select`,{"aria-label":`조건 유형`,onChange:e=>{I({conditions:[...O.conditions??[],v.a(e.target.value)]}),e.currentTarget.value=``},defaultValue:``,children:[(0,C.jsx)(`option`,{value:``,disabled:!0,children:`조건 추가`}),v.n.map(e=>(0,C.jsx)(`option`,{value:e,children:Cc[e]},e))]}),(0,C.jsxs)(`select`,{"aria-label":`동작 유형`,onChange:e=>{I({actions:[...O.actions,v.i(e.target.value)]}),e.currentTarget.value=``},defaultValue:``,children:[(0,C.jsx)(`option`,{value:``,disabled:!0,children:`액션 추가`}),v.t.map(e=>(0,C.jsx)(`option`,{value:e,children:wc[e]},e))]})]})]}):(0,C.jsx)(`div`,{className:`gameplay-event-panel__hint`,children:`상세 편집이 접혀 있습니다. 필요할 때만 열어 수정하세요.`}),(0,C.jsxs)(`div`,{className:`gameplay-event-panel__actions`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:L,children:`이벤트 삭제`}),(0,C.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>{R(O)},children:`선택 이벤트 실행`})]})]}),!O&&(0,C.jsx)(`section`,{className:`gameplay-event-panel__section`,children:(0,C.jsx)(`div`,{className:`gameplay-event-panel__hint`,children:"이벤트 목록에서 `편집`을 누르면 상세 설정이 열립니다."})}),(0,C.jsx)(`section`,{className:`gameplay-event-panel__section`,children:(0,C.jsx)(`div`,{role:`status`,className:`gameplay-event-panel__status gameplay-event-panel__status--${k.kind}`,children:k.message})}),l]})}function jc(e){let t=i.n()?.gameplayEvents,[n,r]=(0,b.useState)(()=>t?.getBlueprints()??[]);(0,b.useEffect)(()=>r(t?.getBlueprints()??[]),[t]);let a=e=>{t?.setBlueprints(e),r(e)};return(0,C.jsx)(Ac,{...e,blueprints:n,onCreate:e=>a([...n.filter(t=>t.id!==e.id),e]),onUpdate:e=>a(n.map(t=>t.id===e.id?e:t)),onDelete:e=>a(n.filter(t=>t.id!==e))})}var Mc=[{kind:`fade`,direction:`in`,durationMs:180},{kind:`lookAt`,target:[0,1.4,0],focusDistance:4.5,durationMs:520,fov:44},{kind:`dolly`,target:[0,1.2,-2],fromDistance:6,toDistance:3.4,durationMs:640,fov:40},{kind:`orbit`,target:[0,1.2,0],radius:5,angleDeg:35,height:.4,durationMs:640,fov:48},{kind:`expression`,face:`smile`,durationMs:120},{kind:`equip`,slot:`weapon`,itemId:`starter-sword`,durationMs:120},{kind:`shake`,intensity:.08,durationMs:120},{kind:`fade`,direction:`out`,durationMs:180},{kind:`restore`}],Nc={"Look At":{kind:`lookAt`,target:[0,1.4,0],focusDistance:4.5,durationMs:520,fov:44},Dolly:{kind:`dolly`,target:[0,1.2,-2],fromDistance:6,toDistance:3.4,durationMs:640,fov:40},Orbit:{kind:`orbit`,target:[0,1.2,0],radius:5,angleDeg:35,height:.4,durationMs:640,fov:48},Fade:{kind:`fade`,direction:`inOut`,durationMs:180},Expression:{kind:`expression`,face:`smile`,durationMs:120},Equip:{kind:`equip`,slot:`weapon`,itemId:`starter-sword`,durationMs:120},Teleport:{kind:`teleport`,position:[0,0,-1.5],durationMs:120},Event:{kind:`event`,name:`cinematic.preview`,payload:{source:`CinematicPanel`},durationMs:20},Restore:{kind:`restore`}};function Pc(e){return JSON.parse(JSON.stringify(e))}var Fc={closeUp:`가까이 보기`,lookAt:`대상 바라보기`,dolly:`카메라 이동`,orbit:`주변 회전`,shake:`화면 흔들기`,fade:`화면 전환`,expression:`표정`,equip:`장비 착용`,dialog:`대화`,teleport:`순간 이동`,animation:`애니메이션`,npcMove:`NPC 이동`,event:`이벤트`,restore:`원래 시점 복원`};function Ic(e){let t=Fc[e.kind];return`durationMs`in e&&typeof e.durationMs==`number`?`${t} / ${e.durationMs}ms`:t}function Lc({beats:e,defaultBeats:t=Mc,playbackOptions:n,onChange:r,onPreview:a,className:o=``,style:s,children:c}){let l=i.n(),u=(0,b.useRef)(void 0),d=()=>{let e=u.current;u.current=void 0,e?.detach(),e?.controller.abort(),e?.playback?.cancel()};(0,b.useEffect)(()=>{let e=l?.subscribeLifecycle(()=>{l.isActive()||(d(),y({kind:`idle`,message:`미리 보기가 중지됐습니다`}))});return()=>{e?.(),d()}},[l]);let f=e!==void 0,[p,h]=(0,b.useState)(()=>t.map(Pc)),[g,_]=(0,b.useState)(Object.keys(Nc)[0]??`Look At`),[v,y]=(0,b.useState)({kind:`idle`,message:`준비됨`}),x=f?e:p,S=(0,b.useMemo)(()=>JSON.stringify(x,null,2),[x]),w=e=>{f||h(e),r?.(e)},T=()=>{let e=Nc[g];e&&(w([...x,Pc(e)]),y({kind:`success`,message:`${Fc[e.kind]} 추가됨`}))},E=(e,t)=>{let n=e+t;if(n<0||n>=x.length)return;let r=[...x],[i]=r.splice(e,1);i&&(r.splice(n,0,i),w(r))},D=e=>{w(x.filter((t,n)=>n!==e))},O=()=>{w(t.map(Pc)),y({kind:`success`,message:`타임라인을 초기화했습니다`})},k=async()=>{if(d(),l&&!l.isActive()){y({kind:`idle`,message:`월드가 비활성 상태입니다`});return}let e={controller:new AbortController,detach:()=>{}};u.current=e;let t=()=>{e.controller.abort(),u.current===e&&y({kind:`idle`,message:`미리 보기가 중지됐습니다`})};e.detach=()=>n?.signal?.removeEventListener(`abort`,t),n?.signal?.addEventListener(`abort`,t,{once:!0}),n?.signal?.aborted&&t();try{if(e.controller.signal.aborted)return;if(y({kind:`idle`,message:`미리 보기 재생 중`}),a)await a(x,e.controller.signal);else{let t={...n,signal:e.controller.signal};e.playback=l?l.cinematics.play(x,t):m.l(x,t),await e.playback.finished}u.current===e&&!e.controller.signal.aborted&&y({kind:`success`,message:e.playback?.state===`cancelled`?`미리 보기가 중지됐습니다`:`미리 보기가 끝났습니다`})}catch(t){if(u.current!==e||e.controller.signal.aborted)return;y({kind:`error`,message:t instanceof Error?`미리 보기 실패: ${t.message}`:`미리 보기에 실패했습니다`})}finally{e.detach(),u.current===e&&(u.current=void 0)}};return(0,C.jsxs)(`div`,{className:`cinematic-panel ${o}`,style:s,children:[(0,C.jsxs)(`section`,{className:`cinematic-panel__section`,children:[(0,C.jsx)(`div`,{className:`cinematic-panel__title`,children:`연출 타임라인`}),(0,C.jsx)(`div`,{className:`cinematic-panel__hint`,children:`카메라와 게임플레이 연출을 추가하고 순서를 바꿔 미리 볼 수 있습니다.`}),(0,C.jsxs)(`div`,{className:`cinematic-panel__toolbar`,children:[(0,C.jsx)(`select`,{"aria-label":`연출 프리셋`,value:g,onChange:e=>_(e.target.value),children:Object.entries(Nc).map(([e,t])=>(0,C.jsx)(`option`,{value:e,children:Fc[t.kind]},e))}),(0,C.jsx)(`button`,{type:`button`,onClick:T,children:`추가`}),(0,C.jsx)(`button`,{type:`button`,onClick:O,children:`초기화`}),(0,C.jsx)(`button`,{type:`button`,className:`cinematic-panel__primary`,onClick:()=>{k()},children:`미리 보기`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>{d(),y({kind:`idle`,message:`미리 보기가 중지됐습니다`})},children:`중지`})]})]}),(0,C.jsxs)(`section`,{className:`cinematic-panel__section`,children:[(0,C.jsx)(`div`,{className:`cinematic-panel__title`,children:`연출 단계`}),(0,C.jsxs)(`div`,{className:`cinematic-panel__list`,children:[x.map((e,t)=>(0,C.jsxs)(`article`,{className:`cinematic-panel__card`,children:[(0,C.jsx)(`div`,{children:(0,C.jsx)(`div`,{className:`cinematic-panel__card-title`,children:Ic(e)})}),(0,C.jsxs)(`div`,{className:`cinematic-panel__card-actions`,children:[(0,C.jsx)(`button`,{type:`button`,disabled:t===0,onClick:()=>E(t,-1),children:`위로`}),(0,C.jsx)(`button`,{type:`button`,disabled:t===x.length-1,onClick:()=>E(t,1),children:`아래로`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>D(t),children:`삭제`})]})]},`${e.kind}-${t}`)),x.length===0&&(0,C.jsx)(`div`,{className:`cinematic-panel__empty`,children:`연출 단계가 없습니다. 프리셋을 추가해 시작하세요.`})]})]}),(0,C.jsxs)(`details`,{className:`cinematic-panel__section`,children:[(0,C.jsx)(`summary`,{className:`cinematic-panel__title`,children:`개발자용 저장 데이터`}),(0,C.jsx)(`textarea`,{"aria-label":`연출 저장 데이터`,readOnly:!0,value:S})]}),(0,C.jsx)(`section`,{className:`cinematic-panel__section`,children:(0,C.jsx)(`div`,{className:`cinematic-panel__status cinematic-panel__status--${v.kind}`,children:v.message})}),c]})}var Rc=`studio-social-world`,zc=`스튜디오 소셜 월드`,Bc=`1.0.0`,Vc=(e,t)=>{if(typeof window>`u`||typeof document>`u`)return;let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=window.URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),window.URL.revokeObjectURL(r)};function Hc({gameplayEvents:e=v.l,defaultSlot:t=`main`,defaultBundleId:n=Rc,defaultBundleName:r=zc,defaultVersion:a=Bc,buildBundle:c,validateBundle:l=y.r,onSaveWorld:u,onLoadWorld:d,onExportBundle:f,className:h=``,style:g,children:_}){let x=i.n()?.save??m.i(),S=o.i(e=>e.ids),w=o.i(e=>e.records),T=(0,b.useMemo)(()=>S.map(e=>w[e]).filter(e=>!!e),[S,w]),E=p.o(),D=p.a(e=>e.instances.size),[O,k]=(0,b.useState)(t),[A,j]=(0,b.useState)(n),[M,N]=(0,b.useState)(r),[P,F]=(0,b.useState)(a),[I,L]=(0,b.useState)([]),[R,z]=(0,b.useState)({kind:`idle`,message:`대기 중`}),[B,V]=(0,b.useState)(null),[ee,H]=(0,b.useState)(!1),[te,ne]=(0,b.useState)(!1),re=(0,b.useRef)(!1),ie=async(e,t)=>{if(!re.current){re.current=!0,ne(!0),z({kind:`idle`,message:`${e} 중입니다.`});try{await t()}catch(t){s.r(t,{source:`editor:studio`,label:e}),z({kind:`error`,message:`${e}에 실패했습니다. 다시 시도해 주세요.`})}finally{re.current=!1,ne(!1)}}},ae=(0,b.useCallback)(()=>{let t=Array.from(E.getState().instances.values(),e=>p.E(e,{id:`npc-behavior-${e.id}`})),n=t.map(e=>p.w(e,{id:`agent-behavior-${e.id}`,ownerType:`npc`}));return c?c({assets:T,bundleId:A,bundleName:M,version:P,gameplayEvents:e,npcBehaviorBlueprints:t,agentBehaviorBlueprints:n}):y.a(x,T,{id:A,name:M,version:P,gameplayEvents:e,npcBehaviorBlueprints:t,agentBehaviorBlueprints:n})},[T,c,A,M,e,E,x,P]),oe=(0,b.useCallback)(async()=>{let e=await x.list();L(e),z({kind:`success`,message:`저장 슬롯 ${e.length}개를 불러왔습니다.`})},[x]),se=(0,b.useCallback)(async()=>{u?await u(O):await x.save(O),z({kind:`success`,message:`슬롯 "${O}" 에 저장했습니다.`});try{L(await x.list())}catch(e){s.r(e,{source:`editor:studio`,label:`refresh slots`}),z({kind:`error`,message:`슬롯 "${O}"에 저장했지만 목록을 갱신하지 못했습니다.`})}},[u,x,O]),ce=(0,b.useCallback)(async()=>{let e=d?await d(O):await x.load(O),t=e===void 0||!!e;z({kind:t?`success`:`error`,message:t?`슬롯 "${O}" 을 불러왔습니다.`:`슬롯 "${O}" 에 저장 데이터가 없습니다.`})},[d,x,O]),le=(0,b.useCallback)(()=>{let e=l(ae());V(e),z({kind:e.ok?`success`:`error`,message:e.ok?`번들 검증이 통과했습니다.`:`번들 오류 ${e.errors.length}개가 발견되었습니다.`})},[ae,l]),ue=(0,b.useCallback)(async()=>{let e=ae(),t=l(e);if(V(t),!t.ok){z({kind:`error`,message:`번들 오류를 먼저 수정한 뒤 내보내세요.`});return}f?await f(e):Vc(`${e.id}-${e.version}.bundle.json`,e),z({kind:`success`,message:`콘텐츠 번들 JSON을 내보냈습니다.`})},[ae,f,l]);return(0,C.jsxs)(`div`,{className:`studio-panel ${h}`,style:g,children:[(0,C.jsxs)(`section`,{className:`studio-panel__section`,children:[(0,C.jsx)(`div`,{className:`studio-panel__title`,children:`월드 저장 관리`}),(0,C.jsx)(`div`,{className:`studio-panel__hint`,children:`작업 중인 월드 상태를 슬롯 단위로 저장하거나 불러옵니다.`}),(0,C.jsxs)(`label`,{className:`studio-panel__field`,children:[(0,C.jsx)(`span`,{children:`슬롯 이름`}),(0,C.jsx)(`input`,{value:O,onChange:e=>k(e.target.value||`main`)})]}),(0,C.jsxs)(`div`,{className:`studio-panel__actions`,children:[(0,C.jsx)(`button`,{type:`button`,disabled:te,onClick:()=>{ie(`월드 저장`,se)},children:`현재 월드 저장`}),(0,C.jsx)(`button`,{type:`button`,disabled:te,onClick:()=>{ie(`월드 불러오기`,ce)},children:`슬롯 불러오기`}),(0,C.jsx)(`button`,{type:`button`,disabled:te,onClick:()=>{ie(`슬롯 새로고침`,oe)},children:`슬롯 새로고침`})]}),I.length>0&&(0,C.jsx)(`div`,{className:`studio-panel__chips`,children:I.map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>k(e),children:e},e))})]}),(0,C.jsxs)(`section`,{className:`studio-panel__section`,children:[(0,C.jsx)(`div`,{className:`studio-panel__title`,children:`콘텐츠 번들`}),(0,C.jsx)(`div`,{className:`studio-panel__hint`,children:`배포용 번들을 검증하고 JSON으로 내보냅니다.`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>H(e=>!e),className:`studio-panel__ghost`,children:ee?`번들 상세 설정 접기`:`번들 상세 설정 열기`}),ee&&(0,C.jsxs)(`div`,{className:`studio-panel__advanced`,children:[(0,C.jsxs)(`label`,{className:`studio-panel__field`,children:[(0,C.jsx)(`span`,{children:`번들 ID`}),(0,C.jsx)(`input`,{value:A,onChange:e=>j(e.target.value)})]}),(0,C.jsxs)(`label`,{className:`studio-panel__field`,children:[(0,C.jsx)(`span`,{children:`번들 이름`}),(0,C.jsx)(`input`,{value:M,onChange:e=>N(e.target.value)})]}),(0,C.jsxs)(`label`,{className:`studio-panel__field`,children:[(0,C.jsx)(`span`,{children:`버전`}),(0,C.jsx)(`input`,{value:P,onChange:e=>F(e.target.value)})]})]}),(0,C.jsxs)(`div`,{className:`studio-panel__meta`,children:[`에셋 `,T.length,`개 · 이벤트 `,e.length,`개 · NPC 행동 `,D,`개 · 에이전트 행동 `,D,`개 · 저장 도메인 `,Array.from(x.getBindings()).length,`개`]}),(0,C.jsxs)(`div`,{className:`studio-panel__actions`,children:[(0,C.jsx)(`button`,{type:`button`,disabled:te,onClick:()=>{ie(`번들 검증`,le)},children:`번들 검증`}),(0,C.jsx)(`button`,{type:`button`,disabled:te,onClick:()=>{ie(`번들 내보내기`,ue)},children:`JSON 내보내기`})]})]}),(0,C.jsxs)(`section`,{className:`studio-panel__section`,children:[(0,C.jsx)(`div`,{className:`studio-panel__title`,children:`상태`}),(0,C.jsx)(`div`,{role:`status`,className:`studio-panel__status studio-panel__status--${R.kind}`,children:R.message}),B&&!B.ok&&(0,C.jsx)(`ul`,{className:`studio-panel__errors`,children:B.errors.map(e=>(0,C.jsx)(`li`,{children:e},e))})]}),_]})}function Uc({status:e,onSave:t,onToggleAutosave:n}){let r=I(e),i=!!t&&e.state!==`saving`&&e.dirty;return(0,C.jsxs)(`div`,{className:`editor-save-status editor-save-status--${e.state}`,"aria-label":`편집 내용 저장 상태`,children:[(0,C.jsxs)(`div`,{className:`editor-save-status__main`,children:[(0,C.jsx)(`span`,{className:`editor-save-status__dot`,"aria-hidden":`true`}),(0,C.jsx)(`span`,{className:`editor-save-status__label`,children:r})]}),(0,C.jsxs)(`div`,{className:`editor-save-status__actions`,children:[n&&(0,C.jsx)(`button`,{type:`button`,className:e.autosaveEnabled?`active`:``,"aria-pressed":e.autosaveEnabled,onClick:()=>n(!e.autosaveEnabled),title:`자동 저장 전환`,children:`자동`}),t&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>{t()},disabled:!i,children:`저장`})]})]})}var Wc={hierarchy:`계층`,inspector:`속성`,"project-assets":`프로젝트`,world:`월드`,wall:`벽`,tile:`타일`,block:`블록`,object:`오브젝트`,npc:`NPC`,character:`캐릭터`,vehicle:`탈것`,animation:`애니메이션`,camera:`카메라`,motion:`모션`,performance:`성능`,"gameplay-events":`게임 이벤트`,cinematic:`연출`,studio:`스튜디오`};function Gc(e){let t=Wc[e.id];return t?{...e,title:t}:e}var Kc=({children:e,panels:t=[],defaultActivePanels:n=[`hierarchy`,`inspector`,`tile`,`camera`],defaultPanelOpen:r=!1,defaultModalOpen:a=!1,actions:o=[],hiddenBuiltInPanels:s=[],panelOrder:c,panelDefaults:l={},sidebarPreset:u=`standard`,validateBundle:d,sceneDocument:p,selectedObjectId:m,selectedObjectIds:h,hoveredObjectId:g,onSelectSceneObject:_,onHoverSceneObject:v,onUpdateSceneObject:y,onAddSceneComponent:x,onRemoveSceneComponent:S,onUpdateSceneComponent:w,scenePrefab:T,projectScenes:E,projectPrefabs:D,selectedProjectItemId:k,onSelectProjectItem:A,playMode:j=`edit`,onEnterPlayMode:M,onExitPlayMode:N,onPausePlayMode:P,onResumePlayMode:F,shortcuts:I=[],shortcutsEnabled:L=!0,commandPaletteItems:z=[],commandPaletteEnabled:B=!0,saveStatus:V,onSave:H,onAutosave:te,onToggleAutosave:ne})=>{let ae=i.n(),oe=i.r(),se=(0,b.useMemo)(()=>ae?O(ae.plugins.context.components.list()):[],[ae,oe]),[ce,le]=(0,b.useState)(!1),ue=(0,b.useMemo)(()=>({id:`editor.commandPalette`,label:`명령 팔레트`,key:`k`,ctrl:!0,meta:!0,run:()=>le(e=>!e)}),[]),de=(0,b.useMemo)(()=>{if(H)return{id:`editor.save`,label:`저장`,key:`s`,ctrl:!0,meta:!0,disabled:V?.state===`saving`||V?.dirty===!1,run:()=>H()}},[H,V?.dirty,V?.state]),fe=(0,b.useMemo)(()=>[...B?[ue]:[],...de?[de]:[],...I],[B,ue,de,I]);re(fe,{enabled:L}),R({...V?{status:V}:{},...te?{onAutosave:te}:{}});let pe=(0,b.useMemo)(()=>{let e={...p?{sceneDocument:p}:{},...m?{selectedObjectId:m}:{},...h?{selectedObjectIds:h}:{},...g?{hoveredObjectId:g}:{},..._?{onSelectObject:_}:{},...v?{onHoverObject:v}:{}},n={...p?{sceneDocument:p}:{},...m?{selectedObjectId:m}:{},...y?{onUpdateObject:y}:{},...x?{onAddComponent:x}:{},...S?{onRemoveComponent:S}:{},...w?{onUpdateComponent:w}:{},...T?{prefab:T}:{}},r={...E?{scenes:E}:{},...D?{prefabs:D}:{},...k?{selectedItemId:k}:{},...A?{onSelectItem:A}:{}},i=[{id:`hierarchy`,title:`계층`,component:(0,C.jsx)(On,{...e}),defaultSide:`left`},{id:`inspector`,title:`속성`,component:(0,C.jsx)(La,{...n}),defaultSide:`right`},{id:`project-assets`,title:`프로젝트`,component:(0,C.jsx)(lo,{...r}),defaultSide:`left`},{id:`world`,title:`월드`,component:(0,C.jsx)(dc,{}),defaultSide:`left`},{id:`wall`,title:`벽`,component:(0,C.jsx)(fc,{}),defaultSide:`left`},{id:`tile`,title:`바닥`,component:(0,C.jsx)(pc,{}),defaultSide:`left`},{id:`block`,title:`블록`,component:(0,C.jsx)(mc,{}),defaultSide:`left`},{id:`object`,title:`소품`,component:(0,C.jsx)(hc,{}),defaultSide:`left`},{id:`npc`,title:`NPC`,component:(0,C.jsx)(gc,{}),defaultSide:`left`},{id:`character`,title:`캐릭터`,component:(0,C.jsx)(yc,{}),defaultSide:`left`},{id:`vehicle`,title:`차량`,component:(0,C.jsx)(fo,{}),defaultSide:`left`},{id:`animation`,title:`애니메이션`,component:(0,C.jsx)(on,{}),defaultSide:`left`},{id:`camera`,title:`카메라`,component:(0,C.jsx)(zt,{}),defaultSide:`right`},{id:`motion`,title:`이동`,component:(0,C.jsx)(bn,{}),defaultSide:`right`},{id:`performance`,title:`성능`,component:(0,C.jsx)(En,{}),defaultSide:`right`},{id:`gameplay-events`,title:`게임 이벤트`,component:(0,C.jsx)(jc,{}),defaultSide:`right`},{id:`studio`,title:`스튜디오`,component:(0,C.jsx)(Hc,{...d?{validateBundle:d}:{}}),defaultSide:`right`}],a=new Set(s),o=new Map;for(let e of i){if(a.has(e.id))continue;let t=Gc(e),n=l[e.id]??{};o.set(e.id,{...t,...n})}for(let e of se){let t=Gc(e),n=l[e.id]??{};o.set(e.id,{...o.get(e.id),...t,...n})}for(let e of t){let t=Gc(e),n=l[e.id]??{};o.set(e.id,{...o.get(e.id),...t,...n})}let u=c??[],f=[];for(let e of u){let t=o.get(e);t&&(f.push(t),o.delete(e))}return[...f,...o.values()]},[se,s,g,x,v,S,_,w,y,T,l,c,t,D,E,p,m,h,k,A,d]),me=(0,b.useMemo)(()=>n.find(e=>pe.some(t=>t.id===e))??pe[0]?.id??``,[n,pe]),[he,ge]=(0,b.useState)(me),[_e,ve]=(0,b.useState)(r),[ye,be]=(0,b.useState)(a),xe=(0,b.useMemo)(()=>new Set([`npc`,`gameplay-events`,`studio`]),[]),U=pe.some(e=>e.id===he)?he:me,W=pe.find(e=>e.id===U),Se=(0,b.useRef)(null),Ce=(0,b.useRef)(null);(0,b.useLayoutEffect)(()=>{let e=Se.current;if(!_e||!ye||!e)return;let t=document.activeElement;return e.showModal(),()=>{e.close(),t instanceof HTMLElement&&t.isConnected?t.focus():Ce.current?.focus()}},[_e,ye,U]);let we=(0,b.useCallback)(e=>{let t=e!==U||!_e,n=t&&xe.has(e);ge(e),ve(t),be(n)},[_e,xe,U]),Te=(0,b.useMemo)(()=>{let e=pe.map(e=>({id:`panel.${e.id}`,label:`${e.title} 열기`,group:`패널`,run:()=>we(e.id)})),t=o.map(e=>({id:`action.${e.id}`,label:e.label,group:`액션`,...e.disabled===void 0?{}:{disabled:e.disabled},run:e.onClick})),n=fe.map(e=>({id:`shortcut.${e.id}`,label:e.label,group:`단축키`,shortcut:ee(e),...e.disabled===void 0?{}:{disabled:e.disabled},run:()=>e.run(new KeyboardEvent(`keydown`,{key:e.key,...e.code?{code:e.code}:{}}))}));return[...e,...t,...n,...z]},[o,fe,z,pe,we]);(0,b.useEffect)(()=>{U&&ge(U)},[U]);let Ee=typeof u==`string`?`editor-sidebar--preset-${u}`:u.className??``,De=typeof u==`string`?void 0:u.style;return(0,C.jsxs)(f.a,{className:`editor-root`,children:[(0,C.jsxs)(`aside`,{className:`editor-sidebar ${Ee} ${_e?`editor-sidebar--open`:`editor-sidebar--collapsed`}`,style:De,"aria-label":`편집 도구`,children:[(0,C.jsxs)(`div`,{className:`editor-sidebar-menu`,children:[(0,C.jsxs)(`div`,{className:`editor-sidebar-header`,children:[(0,C.jsx)(`div`,{className:`editor-shell-title`,children:`에디터`}),(0,C.jsx)(`div`,{className:`editor-shell-status`,children:_e?W?.title??`패널 없음`:``})]}),(0,C.jsx)(`nav`,{className:`editor-panel-menu editor-panel-menu--flat`,"aria-label":`편집 패널 선택`,children:pe.map(e=>(0,C.jsx)(`button`,{ref:U===e.id?Ce:void 0,type:`button`,onClick:()=>we(e.id),"aria-pressed":U===e.id&&_e,className:`editor-panel-toggle ${U===e.id&&_e?`active`:``}`,title:e.title,children:e.title},e.id))}),(0,C.jsxs)(`div`,{className:`editor-sidebar-footer`,children:[V&&(0,C.jsx)(Uc,{status:V,...H?{onSave:H}:{},...ne?{onToggleAutosave:ne}:{}}),(0,C.jsxs)(`div`,{className:`editor-play-mode-controls`,"aria-label":`플레이 모드 조작`,children:[j===`edit`?(0,C.jsx)(`button`,{type:`button`,onClick:()=>{M?.()},children:`실행`}):(0,C.jsx)(`button`,{type:`button`,onClick:()=>{N?.()},children:`정지`}),j===`play`&&(0,C.jsx)(`button`,{type:`button`,onClick:P,children:`일시정지`}),j===`paused`&&(0,C.jsx)(`button`,{type:`button`,onClick:F,children:`재개`})]}),o.length>0&&(0,C.jsxs)(`div`,{className:`editor-menu-section`,children:[(0,C.jsx)(`div`,{className:`editor-region-label`,children:`액션`}),o.map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>{e.onClick()},className:`editor-panel-toggle`,disabled:e.disabled,title:e.label,children:e.label},e.id))]})]})]}),_e&&!ye&&(0,C.jsxs)(`section`,{className:`editor-sidebar-panel ${W?.className??``}`,children:[(0,C.jsxs)(`div`,{className:`editor-sidebar-panel-header`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`editor-region-label`,children:`패널`}),(0,C.jsx)(`h2`,{children:W?.title??`패널`})]}),(0,C.jsx)(`button`,{type:`button`,className:`editor-sidebar-close`,onClick:()=>be(!0),"aria-label":`패널 전체 화면 열기`,children:`전체`}),(0,C.jsx)(`button`,{type:`button`,className:`editor-sidebar-close`,onClick:()=>ve(!1),"aria-label":`패널 닫기`,children:`닫기`})]}),(0,C.jsx)(`div`,{className:`editor-sidebar-panel-content`,style:W?.style,children:W?.component})]})]}),_e&&ye&&W&&(0,C.jsx)(`dialog`,{ref:Se,className:`editor-panel-modal ${U===`npc`?`editor-panel-modal--npc`:``}`,"aria-label":`${W.title} 패널 모달`,onKeyDown:e=>{if(e.stopPropagation(),e.key!==`Tab`||e.defaultPrevented)return;let t=Array.from(e.currentTarget.querySelectorAll(`button, input, select, textarea, a[href], [tabindex], [contenteditable="true"]`)).filter(e=>e.tabIndex>=0&&!e.matches(`:disabled`)&&e.getClientRects().length>0);if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[n<0?e.shiftKey?t.length-1:0:(n+(e.shiftKey?-1:1)+t.length)%t.length]?.focus()},onCancel:e=>{e.preventDefault(),be(!1),ve(!1)},children:(0,C.jsxs)(`div`,{className:`editor-panel-modal__surface ${W.className??``}`,children:[(0,C.jsxs)(`header`,{className:`editor-panel-modal__header`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`editor-region-label`,children:`패널`}),(0,C.jsx)(`h2`,{children:W.title})]}),(0,C.jsxs)(`div`,{className:`editor-panel-modal__actions`,children:[(0,C.jsx)(`button`,{type:`button`,className:`editor-sidebar-close`,onClick:()=>be(!1),"aria-label":`패널을 사이드바로 보내기`,children:`사이드바`}),(0,C.jsx)(`button`,{type:`button`,className:`editor-sidebar-close`,onClick:()=>{be(!1),ve(!1)},"aria-label":`패널 닫기`,children:`닫기`})]})]}),(0,C.jsx)(`div`,{className:`editor-panel-modal__content ${U===`npc`?`editor-panel-modal__content--npc`:``}`,style:W.style,children:W.component})]})}),(0,C.jsx)(ie,{open:ce,items:Te,onClose:()=>le(!1)}),e]})},qc={forward:!1,backward:!1,leftward:!1,rightward:!1,shift:!1,space:!1,keyZ:!1,keyR:!1,keyF:!1,keyE:!1,escape:!1},Jc={isActive:!1,shouldRun:!1,isLookAround:!1},Yc=e=>({...e,...e.smoothing?{smoothing:{...e.smoothing}}:{},...e.bounds?{bounds:{...e.bounds}}:{}}),Xc=({children:e,className:t=``,style:n={},shell:r,sceneDocument:i,selectedObjectId:a,selectedObjectIds:o,hoveredObjectId:s,onSelectSceneObject:c,onHoverSceneObject:l,onUpdateSceneObject:d,onAddSceneComponent:f,onRemoveSceneComponent:p,onUpdateSceneComponent:m,scenePrefab:h,projectScenes:g,projectPrefabs:_,selectedProjectItemId:v,onSelectProjectItem:y,playMode:x,onEnterPlayMode:S,onExitPlayMode:w,onPausePlayMode:T,onResumePlayMode:E,shortcuts:D,shortcutsEnabled:O,commandPaletteItems:k,commandPaletteEnabled:A,saveStatus:j,onSave:M,onAutosave:N,onToggleAutosave:P})=>{let F=u.s(),I=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{let e=F.getState();return I.current={mode:{...e.mode},cameraOption:Yc(e.cameraOption),interactionActive:e.interaction.isActive},e.stopAutomation(),e.updateKeyboard(qc),e.updateMouse(Jc),e.setInteractionActive(!1),()=>{let e=I.current;if(!e)return;let t=F.getState();t.setMode(e.mode),t.replaceCameraOption(e.cameraOption),t.setInteractionActive(e.interactionActive),t.updateKeyboard(qc),t.updateMouse(Jc)}},[F]),(0,C.jsx)(`div`,{className:`gaesup-editor ${t}`,style:{...n},children:(0,C.jsx)(Kc,{...r?.panels?{panels:r.panels}:{},...r?.defaultActivePanels?{defaultActivePanels:r.defaultActivePanels}:{},...typeof r?.defaultPanelOpen==`boolean`?{defaultPanelOpen:r.defaultPanelOpen}:{},...typeof r?.defaultModalOpen==`boolean`?{defaultModalOpen:r.defaultModalOpen}:{},...r?.actions?{actions:r.actions}:{},...r?.hiddenBuiltInPanels?{hiddenBuiltInPanels:r.hiddenBuiltInPanels}:{},...r?.panelOrder?{panelOrder:r.panelOrder}:{},...r?.panelDefaults?{panelDefaults:r.panelDefaults}:{},...r?.sidebarPreset?{sidebarPreset:r.sidebarPreset}:{},...r?.validate?{validateBundle:r.validate}:{},...i?{sceneDocument:i}:{},...a?{selectedObjectId:a}:{},...o?{selectedObjectIds:o}:{},...s?{hoveredObjectId:s}:{},...c?{onSelectSceneObject:c}:{},...l?{onHoverSceneObject:l}:{},...d?{onUpdateSceneObject:d}:{},...f?{onAddSceneComponent:f}:{},...p?{onRemoveSceneComponent:p}:{},...m?{onUpdateSceneComponent:m}:{},...h?{scenePrefab:h}:{},...g?{projectScenes:g}:{},..._?{projectPrefabs:_}:{},...v?{selectedProjectItemId:v}:{},...y?{onSelectProjectItem:y}:{},...x?{playMode:x}:{},...S?{onEnterPlayMode:S}:{},...w?{onExitPlayMode:w}:{},...T?{onPausePlayMode:T}:{},...E?{onResumePlayMode:E}:{},...D?{shortcuts:D}:{},...typeof O==`boolean`?{shortcutsEnabled:O}:{},...k?{commandPaletteItems:k}:{},...typeof A==`boolean`?{commandPaletteEnabled:A}:{},...j?{saveStatus:j}:{},...M?{onSave:M}:{},...N?{onAutosave:N}:{},...P?{onToggleAutosave:P}:{},children:e})})},Zc=()=>(0,C.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,C.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})}),Qc=()=>(0,C.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,C.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,C.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]}),$c=({children:e,title:t,initialWidth:n=280,initialHeight:r=400,minWidth:i=200,minHeight:a=150,maxWidth:o=600,maxHeight:s=800,resizeHandles:c=[`right`],className:l=``,style:u={},onClose:d,onMinimize:f,draggable:p=!0,onDrop:m})=>{let[h,g]=(0,b.useState)({width:n,height:r}),[_,v]=(0,b.useState)({x:0,y:0}),[y,x]=(0,b.useState)(!1),[S,w]=(0,b.useState)(!1),[T,E]=(0,b.useState)(``),[D,O]=(0,b.useState)({x:0,y:0}),k=(0,b.useRef)(null),A=(0,b.useRef)(null),j=(0,b.useCallback)(e=>t=>{t.preventDefault(),x(!0),E(e)},[]),M=(0,b.useCallback)(e=>{if(k.current){if(y){let t=k.current.getBoundingClientRect(),n=h.width,r=h.height;T.includes(`right`)&&(n=Math.min(o,Math.max(i,e.clientX-t.left))),T.includes(`bottom`)&&(r=Math.min(s,Math.max(a,e.clientY-t.top))),g({width:n,height:r})}else S&&v({x:e.clientX-D.x,y:e.clientY-D.y})}},[y,S,T,h,i,o,a,s,D]),N=(0,b.useCallback)(()=>{S&&m&&m(_.x,_.y),x(!1),w(!1),E(``)},[S,m,_]),P=(0,b.useCallback)(e=>{if(!p||y)return;e.preventDefault(),w(!0);let t=k.current?.getBoundingClientRect();t&&O({x:e.clientX-t.left,y:e.clientY-t.top})},[p,y]);return(0,b.useEffect)(()=>{if(y||S)return document.addEventListener(`mousemove`,M),document.addEventListener(`mouseup`,N),()=>{document.removeEventListener(`mousemove`,M),document.removeEventListener(`mouseup`,N)}},[y,S,M,N]),(0,C.jsxs)(`div`,{ref:k,className:`rp-panel ${l} ${S?`dragging`:``}`,style:{width:`${h.width}px`,height:`${h.height}px`,...S?{position:`fixed`,left:`${_.x}px`,top:`${_.y}px`,zIndex:10003}:{},...u},children:[(0,C.jsxs)(`div`,{ref:A,className:`rp-header`,onMouseDown:P,children:[(0,C.jsx)(`h3`,{className:`rp-title`,children:t}),(0,C.jsxs)(`div`,{className:`rp-controls`,onMouseDown:e=>e.stopPropagation(),children:[f&&(0,C.jsx)(`button`,{className:`rp-btn rp-btn--minimize`,onClick:f,title:`최소화`,children:(0,C.jsx)(Zc,{})}),d&&(0,C.jsx)(`button`,{className:`rp-btn rp-btn--close`,onClick:d,title:`닫기`,children:(0,C.jsx)(Qc,{})})]})]}),(0,C.jsx)(`div`,{className:`rp-content`,children:e}),c.map(e=>(0,C.jsx)(`div`,{className:`rp-resize-handle handle-${e}`,onMouseDown:j(e.replace(`corner`,`right bottom`))},e))]})};function el({object:e,enabled:t=!0,visible:n=!0,mode:r=`translate`,space:i=`world`,translationSnap:a,rotationSnap:o,scaleSnap:s,children:c,onTransformChange:l,onDraggingChange:u}){let d=(0,b.useRef)(null);(0,b.useEffect)(()=>{d.current&&e&&tl(d.current,e.transform)},[e]);let f=(0,b.useCallback)(()=>{d.current&&e&&l?.(e.id,nl(d.current))},[e,l]);if(!e||!n)return null;let p={...a===void 0?{}:{translationSnap:a},...o===void 0?{}:{rotationSnap:o},...s===void 0?{}:{scaleSnap:s}};return(0,C.jsx)(T.TransformControls,{enabled:t,mode:r,space:i,...p,onObjectChange:f,onMouseDown:()=>u?.(!0),onMouseUp:()=>u?.(!1),children:(0,C.jsx)(`group`,{ref:d,name:`scene-object-gizmo-${e.id}`,children:c})})}function tl(e,t){e.position.set(...t.position),e.rotation.set(...t.rotation),e.scale.set(...t.scale),e.updateMatrixWorld()}function nl(e){return{position:il(e.position),rotation:il(e.rotation),scale:il(e.scale)}}function rl(e,t){return{position:al(e.position,t.translationSnap),rotation:al(e.rotation,t.rotationSnap),scale:al(e.scale,t.scaleSnap)}}function il(e){return[Nr(e.x),Nr(e.y),Nr(e.z)]}function al(e,t){return!t||t<=0?e:e.map(e=>Nr(Math.round(e/t)*t))}var ol={selectedObjectIds:[],activeObjectId:void 0,hoveredObjectId:void 0};function sl(e={}){let t=ml(e.selectedObjectIds??[]);return{selectedObjectIds:t,activeObjectId:e.activeObjectId&&t.includes(e.activeObjectId)?e.activeObjectId:t.at(-1),hoveredObjectId:e.hoveredObjectId}}function cl(e,t,n={}){let r=n.mode??`replace`;if(r===`add`)return sl({...e,selectedObjectIds:[...e.selectedObjectIds,t],activeObjectId:t});if(r===`toggle`){let n=e.selectedObjectIds.includes(t);return sl({...e,selectedObjectIds:n?e.selectedObjectIds.filter(e=>e!==t):[...e.selectedObjectIds,t],activeObjectId:n?e.selectedObjectIds.filter(e=>e!==t).at(-1):t})}return r===`range`?ll(e,t,n.orderedObjectIds??[]):sl({...e,selectedObjectIds:[t],activeObjectId:t})}function ll(e,t,n){let r=e.activeObjectId??e.selectedObjectIds.at(-1),i=r?n.indexOf(r):-1,a=n.indexOf(t);if(i<0||a<0)return cl(e,t);let o=Math.min(i,a),s=Math.max(i,a);return sl({...e,selectedObjectIds:n.slice(o,s+1),activeObjectId:t})}function ul(e,t){return{...e,hoveredObjectId:t}}function dl(e){return{...e,selectedObjectIds:[],activeObjectId:void 0}}function fl(e,t){return e.selectedObjectIds.includes(t)}function pl(e,t){let n=t.activeObjectId??t.selectedObjectIds.at(-1);return n?e.find(e=>e.id===n):void 0}function ml(e){return Array.from(new Set(e.filter(Boolean)))}var hl=e=>({selectedObjectIds:ol.selectedObjectIds,activeObjectId:ol.activeObjectId,hoveredObjectId:ol.hoveredObjectId,saveStatus:k(),setSelectedObjectIds:t=>e(_l(sl({selectedObjectIds:t}))),selectObject:(t,n)=>e(e=>_l(cl(e,t,n))),setHoveredObjectId:t=>e(e=>_l(ul(e,t))),setSaveStatus:t=>e({saveStatus:t}),updateSaveStatus:t=>e(e=>({saveStatus:{...e.saveStatus,...t}})),clearSelection:()=>e(e=>_l(dl(e))),layoutConfig:null,setLayoutConfig:t=>e({layoutConfig:t}),activeNodeGraph:null,setActiveNodeGraph:t=>e({activeNodeGraph:t}),clipboard:null,setClipboard:t=>e({clipboard:t})}),gl=hl;function _l(e){return{selectedObjectIds:e.selectedObjectIds,activeObjectId:e.activeObjectId,hoveredObjectId:e.hoveredObjectId}}var vl=a.n(()=>(0,x.create)(hl)),yl=()=>{let e=vl((0,w.useShallow)(e=>({selectedObjectIds:e.selectedObjectIds,activeObjectId:e.activeObjectId,hoveredObjectId:e.hoveredObjectId,saveStatus:e.saveStatus,layoutConfig:e.layoutConfig,activeNodeGraph:e.activeNodeGraph,clipboard:e.clipboard,setSelectedObjectIds:e.setSelectedObjectIds,selectObject:e.selectObject,setHoveredObjectId:e.setHoveredObjectId,setSaveStatus:e.setSaveStatus,updateSaveStatus:e.updateSaveStatus,clearSelection:e.clearSelection,setLayoutConfig:e.setLayoutConfig,setActiveNodeGraph:e.setActiveNodeGraph,setClipboard:e.setClipboard})));return{...e,selectObject:e.selectObject,selectMultiple:t=>e.setSelectedObjectIds(t),clearSelection:e.clearSelection}};function bl(e){let t={mode:`edit`},n=new Set,r=e=>{t=e,n.forEach(e=>e(t))},i={getState:()=>t,enter:async()=>{if(t.snapshot&&t.mode!==`edit`)return r({...t,mode:`play`}),t.snapshot;let n={id:d.t(`play-snapshot`),createdAt:Date.now(),data:await e.createSnapshot()};return r({mode:`play`,snapshot:n}),await e.onEnter?.(n),n},exit:async()=>{let n=t.snapshot;if(!n){r({mode:`edit`});return}await e.restoreSnapshot(n.data),r({mode:`edit`}),await e.onExit?.(n)},pause:()=>{t.mode===`play`&&r({...t,mode:`paused`})},resume:()=>{t.mode===`paused`&&r({...t,mode:`play`})},toggle:async()=>{if(t.mode===`edit`){await i.enter();return}await i.exit()},subscribe:e=>(n.add(e),e(t),()=>n.delete(e))};return i}function xl(e={}){let t={panels:e.panels??[],actions:(e.commands??[]).map(e=>({id:e.id,label:e.label,onClick:e.run}))};return e.defaultActivePanels&&(t.defaultActivePanels=e.defaultActivePanels),typeof e.defaultPanelOpen==`boolean`&&(t.defaultPanelOpen=e.defaultPanelOpen),typeof e.defaultModalOpen==`boolean`&&(t.defaultModalOpen=e.defaultModalOpen),e.hiddenBuiltInPanels&&(t.hiddenBuiltInPanels=e.hiddenBuiltInPanels),e.panelOrder&&(t.panelOrder=e.panelOrder),e.panelDefaults&&(t.panelDefaults=e.panelDefaults),e.sidebarPreset&&(t.sidebarPreset=e.sidebarPreset),e.validate&&(t.validate=e.validate),t}function Sl(){let e=[],t=[],n=new Set,r=()=>{let n=e.at(-1);return{undoCount:e.length,redoCount:t.length,...n?{lastCommand:n}:{}}},i=()=>{let e=r();n.forEach(t=>t(e))};return{execute:async n=>{await n.run(),n.undo&&(e.push(n),t.length=0),i()},undo:async()=>{let n=e.at(-1);n?.undo&&(await n.undo(),e.pop(),t.push(n),i())},redo:async()=>{let n=t.at(-1);n&&(await n.run(),t.pop(),e.push(n),i())},canUndo:()=>e.length>0,canRedo:()=>t.length>0,getState:r,subscribe:e=>(n.add(e),e(r()),()=>n.delete(e)),clear:()=>{e.length=0,t.length=0,i()}}}function Cl(e){return{id:e.id,label:e.label,run:async()=>{for(let t of e.commands)await t.run()},undo:async()=>{for(let t of[...e.commands].reverse())await t.undo?.()}}}function wl(e){let t=El(e),n=(e,n,r)=>{let i;return{id:e,label:n,run:()=>{let e=t.capture();i=e,Dl(t,typeof r==`function`?r(e):r)},undo:()=>{i&&Dl(t,{type:`scene-document.replace`,document:i})}}},r=(e,t,r)=>n(e,t,e=>({type:`scene-document.replace`,document:r(e)}));return{createObject(e){let t=Wn(e);return n(`scene-object.create.${t.id}`,`Create ${t.name}`,{type:`scene-object.create`,object:t})},updateObject(e,t){return n(`scene-object.update.${e}`,`Update ${e}`,{type:`scene-object.update`,objectId:e,patch:Ol(t)})},deleteObject(e){return n(`scene-object.delete.${e}`,`Delete ${e}`,{type:`scene-object.delete`,objectId:e})},moveObject(e,t){return n(`scene-object.update.${e}`,`Update ${e}`,{type:`scene-object.move`,objectId:e,parentId:t||null})},addComponent(e,t){let r=Un(t);return n(`scene-object.component.add.${e}.${r.id}`,`Add ${r.type}`,{type:`scene-object.component.add`,objectId:e,component:r})},updateComponent(e,t,r){return n(`scene-object.component.update.${e}.${t}`,`Update ${t}`,{type:`scene-object.component.update`,objectId:e,componentId:t,data:r})},removeComponent(e,t){return n(`scene-object.component.remove.${e}.${t}`,`Remove ${t}`,{type:`scene-object.component.remove`,objectId:e,componentId:t})},revertPrefabOverride(e,t,n){return r(`prefab.revert.${e}`,`Revert ${n.kind}`,r=>_a(r,t,Tl(r,e),n))},revertPrefabInstance(e,t){return r(`prefab.revert-all.${e}`,`Revert ${t.name}`,n=>va(n,t,Tl(n,e)))},propagatePrefab(e,t){return r(`prefab.propagate.${t.id}`,`Apply ${t.name}`,n=>ya(n,e,t))},instantiatePrefab(e,t){return r(`prefab.instantiate.${e.id}`,`Place ${e.name}`,n=>ha(n,e,t))},convertToPrefabInstance(e,t,n){return r(`prefab.link.${e}`,`Link ${t.name}`,r=>{if(!r.objects.some(t=>t.id===e))throw TypeError(`[EditorShell Error]: 객체가 없습니다 ${e}`);return ga(r,e,t,n)})}}}function Tl(e,t){let n=da(e,t);if(!n)throw TypeError(`[EditorShell Error]: prefab 인스턴스 루트가 아닙니다 ${t}`);return n}function El(e){return`getSnapshot`in e?{capture:()=>e.getSnapshot(),dispatch:t=>e.dispatch(t)}:{capture:()=>xr(e.getDocument()),dispatch:t=>{let n=ti(e.getDocument(),t);return n.accepted&&e.setDocument(n.document),n}}}function Dl(e,t){let n=e.dispatch(t);if(!n.accepted)throw TypeError(n.issues.map(e=>e.message).join(` `)||`Scene command was rejected.`);return n.document}function Ol(e){return{...e.name===void 0?{}:{name:e.name},...e.tags===void 0?{}:{tags:[...e.tags]},...e.transform===void 0?{}:{transform:{...e.transform.position===void 0?{}:{position:kl(e.transform.position)},...e.transform.rotation===void 0?{}:{rotation:kl(e.transform.rotation)},...e.transform.scale===void 0?{}:{scale:kl(e.transform.scale)}}},...`parentId`in e?{parentId:e.parentId?e.parentId:null}:{},...`layer`in e?{layer:e.layer?e.layer:null}:{}}}function kl(e){return[e[0],e[1],e[2]]}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return ta}}),Object.defineProperty(exports,"$t",{enumerable:!0,get:function(){return un}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"An",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"At",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return Ma}}),Object.defineProperty(exports,"Bn",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"Bt",{enumerable:!0,get:function(){return qn}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Xc}}),Object.defineProperty(exports,"Cn",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"Ct",{enumerable:!0,get:function(){return Sr}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Ac}}),Object.defineProperty(exports,"Dn",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"Dt",{enumerable:!0,get:function(){return vr}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Lc}}),Object.defineProperty(exports,"En",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,"Et",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(exports,"Fn",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"Ft",{enumerable:!0,get:function(){return Hn}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return da}}),Object.defineProperty(exports,"Gn",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"Gt",{enumerable:!0,get:function(){return Fn}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return Da}}),Object.defineProperty(exports,"Hn",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"Ht",{enumerable:!0,get:function(){return Kn}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return Ha}}),Object.defineProperty(exports,"In",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"It",{enumerable:!0,get:function(){return Vn}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return ga}}),Object.defineProperty(exports,"Jt",{enumerable:!0,get:function(){return gn}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return ua}}),Object.defineProperty(exports,"Kn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"Kt",{enumerable:!0,get:function(){return On}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return La}}),Object.defineProperty(exports,"Ln",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"Lt",{enumerable:!0,get:function(){return Un}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return lo}}),Object.defineProperty(exports,"Mn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"Mt",{enumerable:!0,get:function(){return _r}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Ka}}),Object.defineProperty(exports,"Nn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"Nt",{enumerable:!0,get:function(){return pr}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Zs}}),Object.defineProperty(exports,"On",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"Ot",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return Ua}}),Object.defineProperty(exports,"Pn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"Pt",{enumerable:!0,get:function(){return mr}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return ra}}),Object.defineProperty(exports,"Qt",{enumerable:!0,get:function(){return pn}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return ka}}),Object.defineProperty(exports,"Rn",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"Rt",{enumerable:!0,get:function(){return Gn}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return $c}}),Object.defineProperty(exports,"Sn",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(exports,"St",{enumerable:!0,get:function(){return xr}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Hc}}),Object.defineProperty(exports,"Tn",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"Tt",{enumerable:!0,get:function(){return Tr}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return wa}}),Object.defineProperty(exports,"Un",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"Ut",{enumerable:!0,get:function(){return In}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return Aa}}),Object.defineProperty(exports,"Vn",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"Vt",{enumerable:!0,get:function(){return Qn}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return ha}}),Object.defineProperty(exports,"Wn",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"Wt",{enumerable:!0,get:function(){return Ln}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return _a}}),Object.defineProperty(exports,"Xt",{enumerable:!0,get:function(){return hn}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return va}}),Object.defineProperty(exports,"Yt",{enumerable:!0,get:function(){return mn}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return sa}}),Object.defineProperty(exports,"Zt",{enumerable:!0,get:function(){return bn}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return ul}}),Object.defineProperty(exports,"_n",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(exports,"_t",{enumerable:!0,get:function(){return Br}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return bl}}),Object.defineProperty(exports,"an",{enumerable:!0,get:function(){return Kt}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return Vi}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return nl}}),Object.defineProperty(exports,"bn",{enumerable:!0,get:function(){return et}}),Object.defineProperty(exports,"bt",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return hl}}),Object.defineProperty(exports,"cn",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return zi}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return dl}}),Object.defineProperty(exports,"dn",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return Bi}}),Object.defineProperty(exports,"en",{enumerable:!0,get:function(){return tn}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return Qi}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return sl}}),Object.defineProperty(exports,"fn",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return Ri}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return ll}}),Object.defineProperty(exports,"gn",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,"gt",{enumerable:!0,get:function(){return Vr}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return cl}}),Object.defineProperty(exports,"hn",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,"ht",{enumerable:!0,get:function(){return Qr}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return wl}}),Object.defineProperty(exports,"in",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return oa}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return fo}}),Object.defineProperty(exports,"jn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"jt",{enumerable:!0,get:function(){return dr}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return yo}}),Object.defineProperty(exports,"kn",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"kt",{enumerable:!0,get:function(){return fr}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return gl}}),Object.defineProperty(exports,"ln",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return Ii}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return fl}}),Object.defineProperty(exports,"mn",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return Zr}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return xl}}),Object.defineProperty(exports,"nn",{enumerable:!0,get:function(){return en}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return ia}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return yl}}),Object.defineProperty(exports,"on",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return Fi}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return pl}}),Object.defineProperty(exports,"pn",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return ti}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return ya}}),Object.defineProperty(exports,"qt",{enumerable:!0,get:function(){return En}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Cl}}),Object.defineProperty(exports,"rn",{enumerable:!0,get:function(){return on}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return Zi}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return vl}}),Object.defineProperty(exports,"sn",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return Pi}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Sl}}),Object.defineProperty(exports,"tn",{enumerable:!0,get:function(){return $t}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return ca}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return ol}}),Object.defineProperty(exports,"un",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return Li}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return el}}),Object.defineProperty(exports,"vn",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,"vt",{enumerable:!0,get:function(){return Lr}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Kc}}),Object.defineProperty(exports,"wn",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(exports,"wt",{enumerable:!0,get:function(){return br}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return rl}}),Object.defineProperty(exports,"xn",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"xt",{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return tl}}),Object.defineProperty(exports,"yn",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"yt",{enumerable:!0,get:function(){return Fr}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return ja}}),Object.defineProperty(exports,"zn",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"zt",{enumerable:!0,get:function(){return Wn}});