@volter/editor 0.5.57 → 0.5.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/BUNDLED_NOTICES +6 -6
  2. package/dist/.vite/manifest.json +275 -275
  3. package/dist/assets/{AudioViewer-DILwc7Pt.js → AudioViewer-C5C4xeUl.js} +1 -1
  4. package/dist/assets/{EntityModelDocument-DVlDQ_IJ.js → EntityModelDocument-DyhU8umO.js} +1 -1
  5. package/dist/assets/{EnvironmentAssetDocument-BVGDJjW4.js → EnvironmentAssetDocument-D_VZ2iFj.js} +1 -1
  6. package/dist/assets/{GameplaySessionTimeline-X_nMT8Sa.js → GameplaySessionTimeline-kIIuhFBI.js} +1 -1
  7. package/dist/assets/{ImageViewer-D-aZoyr1.js → ImageViewer-Crv-yzT_.js} +1 -1
  8. package/dist/assets/{InspectorObjectPreview-CpHEw6QH.js → InspectorObjectPreview-CO-GVXfu.js} +1 -1
  9. package/dist/assets/{JsonAssetDocument-CLVN1V9Z.js → JsonAssetDocument-Dtg2QwPN.js} +1 -1
  10. package/dist/assets/{ModelAssetDocument-C60lQ11c.js → ModelAssetDocument-BpZ8SZXe.js} +1 -1
  11. package/dist/assets/{NonThreeAuthoringBootstrap-D8oHDftw.js → NonThreeAuthoringBootstrap-0nm5Hl3v.js} +2 -2
  12. package/dist/assets/{Object3DPreview-CSmLPKkk.js → Object3DPreview-dHzSO5Ym.js} +2 -2
  13. package/dist/assets/{OnlineAssetDetail-D8wVVoay.js → OnlineAssetDetail-DAdWXnmZ.js} +2 -2
  14. package/dist/assets/{SourceAssetViewer-BcOCJ2ye.js → SourceAssetViewer-D3m0wF8T.js} +2 -2
  15. package/dist/assets/{StageHost-B_YrFNiC.js → StageHost-DD_m8W0k.js} +4 -4
  16. package/dist/assets/{ToolObject3DPreview-Crowr7IN.js → ToolObject3DPreview-CWdklUZ1.js} +1 -1
  17. package/dist/assets/{TransientHint-GNwuzA4c.js → TransientHint-aFFUtbSY.js} +1 -1
  18. package/dist/assets/{VideoViewer-CjQ4P9AJ.js → VideoViewer-BhH8aSzx.js} +1 -1
  19. package/dist/assets/{asset-editor-persistence-D3Yy77wZ.js → asset-editor-persistence-D5wYXQEL.js} +1 -1
  20. package/dist/assets/blender-emscripten-engine-BhbEQhcb.js +2 -0
  21. package/dist/assets/{blender-node-editor.document-BfvoBocD.js → blender-node-editor.document-D-hrVHmR.js} +1 -1
  22. package/dist/assets/{blender-outliner-model-B8b00oxr.js → blender-outliner-model-FscHWpfW.js} +1 -1
  23. package/dist/assets/{blender-properties-tab-0M780SHF.js → blender-properties-tab-Czi3_yYZ.js} +3 -3
  24. package/dist/assets/blender-runtime-host-C3rVDyG8.js +4 -0
  25. package/dist/assets/{blender-runtime-skin-DcwXD-m8.js → blender-runtime-skin-AJdtKKnf.js} +3 -3
  26. package/dist/assets/blender-runtime.document-JlYY0bb7.js +8 -0
  27. package/dist/assets/{blender-timeline.document-RtHIpbT1.js → blender-timeline.document-5UN8V20F.js} +1 -1
  28. package/dist/assets/{blender-uv-editor.document-ChwaS3BG.js → blender-uv-editor.document-maFJQzgA.js} +1 -1
  29. package/dist/assets/{blender-version.status-Bnhf8h1I.js → blender-version.status-CukRH8K3.js} +1 -1
  30. package/dist/assets/{blender-wali-engine-C7bet0ss.js → blender-wali-engine-B0Q2w2Be.js} +1 -1
  31. package/dist/assets/blender.command-CY6QiXxp.js +1 -0
  32. package/dist/assets/{browserAll-Do0ehj3Q.js → browserAll-BQIn-DRw.js} +1 -1
  33. package/dist/assets/{edit-mode-authoring-BX4IRQq9.js → edit-mode-authoring-CWTeROGv.js} +1 -1
  34. package/dist/assets/{hosted-asset-materialization-BK7DHisS.js → hosted-asset-materialization-DcthzsYS.js} +1 -1
  35. package/dist/assets/{index-5av5LJja.js → index-DmtPt6RQ.js} +348 -348
  36. package/dist/assets/{models.finder-Bm1YfG95.js → models.finder-CrDJ41Cp.js} +1 -1
  37. package/dist/assets/{product-Ywxte8eQ.js → product-CqAh01LU.js} +1 -1
  38. package/dist/assets/{properties-bone-constraints.inspector-Ck0Hzlvr.js → properties-bone-constraints.inspector-BPN6BRJV.js} +1 -1
  39. package/dist/assets/{properties-bone.inspector-B8M42o0V.js → properties-bone.inspector-C4xD61mX.js} +1 -1
  40. package/dist/assets/{properties-collection.inspector-D-RSO5zy.js → properties-collection.inspector-BTps8t6G.js} +1 -1
  41. package/dist/assets/{properties-constraints.inspector-DbJa57oa.js → properties-constraints.inspector-BVvP6esW.js} +1 -1
  42. package/dist/assets/{properties-data.inspector-DLgjbRW6.js → properties-data.inspector-CKKO8DVT.js} +1 -1
  43. package/dist/assets/{properties-material.inspector-B11LZYDW.js → properties-material.inspector-BGfT8kHT.js} +1 -1
  44. package/dist/assets/{properties-modifiers.inspector-BCWwuA26.js → properties-modifiers.inspector-DJRANpOY.js} +1 -1
  45. package/dist/assets/{properties-object.inspector-UZVJG49S.js → properties-object.inspector-CgVfWmw2.js} +1 -1
  46. package/dist/assets/{properties-output.inspector-XOwcBits.js → properties-output.inspector-CBl5xEMZ.js} +1 -1
  47. package/dist/assets/{properties-particles.inspector-By04vT7R.js → properties-particles.inspector-CxVZ09ZY.js} +1 -1
  48. package/dist/assets/{properties-physics.inspector-D3T7FLdg.js → properties-physics.inspector-DmG3i3vY.js} +1 -1
  49. package/dist/assets/{properties-render.inspector-Y0Rjr9gZ.js → properties-render.inspector-TCoPfEn0.js} +1 -1
  50. package/dist/assets/{properties-scene.inspector-CfyDWB4W.js → properties-scene.inspector-BjsTOBiY.js} +1 -1
  51. package/dist/assets/{properties-texture.inspector-AFRsJx6-.js → properties-texture.inspector-D1X9iyVV.js} +1 -1
  52. package/dist/assets/{properties-view-layer.inspector-Co07LAmQ.js → properties-view-layer.inspector-dXTVxzzk.js} +1 -1
  53. package/dist/assets/{properties-world.inspector-C7T4JocI.js → properties-world.inspector-CRxJK930.js} +1 -1
  54. package/dist/assets/{react-story-board-vrmj74Ng.js → react-story-board-CnCZAhn6.js} +1 -1
  55. package/dist/assets/{react-three-rapier.esm-D874pLFD.js → react-three-rapier.esm-DsJqtzy_.js} +1 -1
  56. package/dist/assets/{session-1bPxsLdy.js → session-Dv4dTRLk.js} +180 -22
  57. package/dist/assets/{spark.module-D1CUMLYS.js → spark.module-uQlq--TY.js} +1 -1
  58. package/dist/assets/{stage-keyboard-Cx90EYIT.js → stage-keyboard-DzZMNYAr.js} +1 -1
  59. package/dist/assets/{stage-overlay-set-duu3P0mZ.js → stage-overlay-set-D6OOz1L9.js} +1 -1
  60. package/dist/assets/{stage-presence-markers-DKH3p_ao.js → stage-presence-markers-BUaSzKCv.js} +1 -1
  61. package/dist/assets/{story-capture-Dqurwlhr.js → story-capture-C2ExQiuI.js} +1 -1
  62. package/dist/assets/{story-pixi-preview-c78Aygdi.js → story-pixi-preview-C6n-a2_M.js} +1 -1
  63. package/dist/assets/{story-three-preview-CbZo5B3D.js → story-three-preview-BazrPMDu.js} +2 -2
  64. package/dist/assets/{webworkerAll-iMzrvNir.js → webworkerAll-FJN9IDir.js} +1 -1
  65. package/dist/assets/worker-CBvBkaXr.js +2 -0
  66. package/dist/assets/{world-documents-CGbrcsYk.js → world-documents-B6usBw3s.js} +1 -1
  67. package/dist-node/cli.js +15 -9
  68. package/package.json +9 -9
  69. package/dist/assets/blender-emscripten-engine-C_uFxIuO.js +0 -2
  70. package/dist/assets/blender-runtime-host-D8NHsAfD.js +0 -4
  71. package/dist/assets/blender-runtime.document-BixTvrw8.js +0 -7
  72. package/dist/assets/blender.command-BCCEp0kb.js +0 -1
  73. package/dist/assets/worker-DTgfRRas.js +0 -1
@@ -1,3 +1,3 @@
1
- import{a}from"./jsx-runtime-DPjLkJKQ.js";import{cc as co,cd as uo,ce as po,cf as ee,az as bn,cg as Ge,ch as fo,Z as Ft,ci as ho,cj as yn,ck as go,cl as je,cm as ne,cn as Pe,co as Kt,u as oe,cp as vn,cq as mo,bq as Ut,bc as xo,bd as et,a4 as nt,br as bo,B as Zt,cr as wn,cs as Sn,ct as En,cu as Yt,a6 as yo,cv as vo,cw as wo,G as re,cx as _e,cy as Xe,cz as He,cA as So,cB as Eo,cC as Co,cD as ko,cE as Io,cF as J,cG as Ro,cH as Cn,cI as zo,cJ as jo,cK as pe,cL as Po,cM as F,cN as Se,cO as Rt,cP as Mo,cQ as Do,cR as To,cS as Lo,cT as $o,cU as Ve,cV as Bo,cW as Oo,cX as Ao,cY as Fo,cZ as Yo,c_ as No,c$ as Go,d0 as kn,d1 as _o,d2 as Xo,t as zt,d3 as Ho,d4 as Vo,d5 as Wo,d6 as Ko,as as In,d7 as Uo,d8 as Zo,d9 as qo,da as Jo,db as Qo,dc as tr,dd as er,aj as nr,de as or,df as rr,dg as Nt,dh as fe,di as ir,dj as Gt,dk as sr,dl as he,dm as We,dn as ar,Y as lr,dp as cr,W as dr,dq as ur,dr as pr,ds as fr,dt as hr,du as gr,dv as mr,dw as xr,dx as Ke,dy as br,dz as yr}from"./index-5av5LJja.js";import{r as c}from"./index-DaQZGF7d.js";import{B as It,q as Ue,I as vr}from"./edit-mode-authoring-BX4IRQq9.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{T as wr}from"./TransientHint-GNwuzA4c.js";import{s as Sr,g as Er,a as Cr,f as kr,t as Ir,z as Rr,b as zr}from"./react-story-board-vrmj74Ng.js";import{g as Me}from"./viewport-pick-context-DkawXbEi.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./client-DNXj_opT.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";const qt=[],Ze=new Set,jr=[];function Pr(){return qt.length===0?jr:qt}function vt(t){for(let e=qt.length-1;e>=0;e--){const n=qt[e];if(n&&n.kind===t)return n}return null}function Mr(t){return Ze.add(t),()=>{Ze.delete(t)}}const Dr={width:null,height:null};let Vt=Dr;const Ee=new Set;function Rn(){return Vt}function Jt(t,e){const n=t===null?null:Math.max(1,Math.round(t)),r=e===null?null:Math.max(1,Math.round(e));if(!(Vt.width===n&&Vt.height===r)){Vt={width:n,height:r};for(const s of Ee)s()}}function Tr(){Jt(null,null)}function zn(t){return Ee.add(t),()=>Ee.delete(t)}const Lr=1;function jn(t){const e=[];for(const{worldId:n,adapter:r}of t.childAdapters()){if(!(r instanceof It))continue;const s=r.inspector.get(n,"kind");if(s!=="dom"&&s!=="canvas"||r.inspector.get(n,"reason")!==void 0)continue;const d=r.inspector.get(n,"adapter");d?.startsWith("ingest")||d?.startsWith("module")||e.push({worldId:n,kind:s,path:r.inspector.get(n,"path"),zOrder:Number(r.inspector.get(n,"zOrder")??0),pausable:r.inspector.get(n,"pausable")!==!1})}return e}function $r(t){return jn(t)}function ge(t,e){return t.childAdapters().some(n=>n.worldId===e)}function Pn(t,e,n="dom"){const r=yn(e)?"none":"block";t.style.display=r,t.style.pointerEvents=vt(n)?.alwaysInteractive||go(e)?"auto":"none";for(const s of Array.from(t.parentElement?.children??[]))s instanceof HTMLElement&&s.dataset.vgaiStoryBoardChromeFor===e&&(s.style.display=r)}function Br(t,e,n,r){const{worldId:s}=e,i=document.createElement("div");return i.dataset.worldId=s,i.dataset.vgaiRootSurface="true",r&&(i.dataset.vgaiCanvasScene="true"),i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.width="100%",i.style.height="100%",i.style.zIndex=String(n),i.style.contain="layout paint",Pn(i,s,e.kind),Ce(i),t.appendChild(i),i}function Ce(t){if(t.dataset.vgaiCanvasScene==="true"){t.style.transform="",t.style.width="100%",t.style.height="100%";return}if(t.style.transform=je(ne())??"",t.style.transformOrigin="0 0",t.dataset.vgaiReactStoryBoard==="true")return;const e=Rn();t.style.width=e.width===null?"100%":`${e.width}px`,t.style.height=e.height===null?"100%":`${e.height}px`}function Or(t,e,n,r,s,i,d){i?i.canvasSceneView.reset():co(),Tr();const x=bn();if(!i&&x?.config.resolution&&Jt(x.config.resolution.width,x.config.resolution.height),n.playState!=="stopped"){let u=!1,I=!1;const L=n.subscribe(()=>{u||I||n.playState!=="stopped"||(I=!0,u||Ue())});return()=>{u=!0,L()}}const v=x?.rootPath,y=r?[...r]:jn(e);if(y.length===0||!v)return()=>{};const w=v,z=uo(y.map(u=>({id:u.worldId,zOrder:u.zOrder}))).map(u=>y.find(I=>I.worldId===u.id)),j=new Map(z.map(u=>[u.worldId,u])),b=new Map,m=new Map,p=new Map,S=new Set,f=new Set,P=new Set;let D=!1,M=!1,k=!1;function X(){for(const u of m.values())try{u()}catch(I){Ft.error(`[design-time-layers] dispose failed: ${I}`,"authoring")}m.clear();for(const u of b.values())u.remove();b.clear();for(const u of z)s?.(u.worldId,null)}function V(){X();for(const u of S){const I=j.get(u);if(!I)continue;const L={id:I.worldId,kind:I.kind,entryOrScenePath:I.path,zOrder:I.zOrder,pausable:I.pausable};e.replaceChild(u,new It(n,L,"Design-time layer suspended by play mode — Stop restores it."))}S.clear(),n.notifyIngestEdit()}function W(u,I,L){const B=vt(u.kind);if(!B){f.add(u.worldId);return}f.delete(u.worldId);const G=(p.get(u.worldId)??0)+1;p.set(u.worldId,G);const A=Br(t,u,Lr+I,!!i);b.set(u.worldId,A);const xt={projectRootPath:w,store:n,...i?{view:i.canvasSceneView}:{},...d?{activationDocumentId:d}:{}};(async()=>B.mount(u,A,xt))().then(K=>{if(D||M||p.get(u.worldId)!==G){K.dispose();return}if(K.adapter)ge(e,u.worldId)&&(e.replaceChild(u.worldId,K.adapter),S.add(u.worldId)),s?.(u.worldId,K.adapter);else if(K.pick){const Q={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};e.replaceChild(u.worldId,new It(n,Q,void 0,K.pick)),S.add(u.worldId)}m.set(u.worldId,K.dispose),Ge(u.worldId),n.notifyIngestEdit(),L?.()}).catch(K=>{if(p.get(u.worldId)!==G||(L?.(),A.remove(),b.get(u.worldId)===A&&b.delete(u.worldId),D||M))return;const Q=fo(K);Ft.error(`[design-time-layers] world "${u.worldId}" (${u.kind}) failed to mount: ${Q}`,"authoring");const ut={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};s?.(u.worldId,null),ge(e,u.worldId)&&e.replaceChild(u.worldId,new It(n,ut,Q)),ho({worldId:u.worldId,kind:u.kind,identity:B.identity,message:Q}),n.notifyIngestEdit()})}z.forEach((u,I)=>{W(u,I)});function Mt(u,I){const L=m.get(u.worldId);m.delete(u.worldId);const B=b.get(u.worldId);b.delete(u.worldId),W(u,I,()=>{const A=b.get(u.worldId);if(A&&(A.style.visibility=""),L)try{L()}catch(xt){Ft.error(`[design-time-layers] re-projection dispose failed: ${xt}`,"authoring")}B?.remove()});const G=b.get(u.worldId);G&&G!==B&&(G.style.visibility="hidden")}function gt(u,I){const L=m.get(u.worldId);if(m.delete(u.worldId),L)try{L()}catch(G){Ft.error(`[design-time-layers] remount dispose failed: ${G}`,"authoring")}const B=b.get(u.worldId);B&&(B.remove(),b.delete(u.worldId)),W(u,I)}const Y=new Map;function Dt(){for(const[u,I]of Y)vt(u.kind)!==u&&(I(),Y.delete(u));for(const u of Pr()){if(Y.has(u)||vt(u.kind)!==u||!z.some(B=>B.kind===u.kind))continue;const I=[],L=B=>()=>{D||M||n.playState!=="stopped"||z.forEach((G,A)=>{G.kind===u.kind&&B(G,A)})};u.remountWhen&&I.push(u.remountWhen(L(gt))),u.reprojectWhen&&I.push(u.reprojectWhen(L(Mt))),Y.set(u,()=>{for(const B of I)B()})}}Dt();const mt=Mr(()=>{D||M||n.playState!=="stopped"||(z.forEach((u,I)=>{f.has(u.worldId)&&vt(u.kind)&&(P.delete(u.worldId),Ge(u.worldId),W(u,I))}),Dt())}),O=po(()=>{if(D||M)return;let u=!1;for(const I of z){if(!f.has(I.worldId)||P.has(I.worldId)||vt(I.kind)||(P.add(I.worldId),!ge(e,I.worldId)))continue;const L={id:I.worldId,kind:I.kind,entryOrScenePath:I.path,zOrder:I.zOrder,pausable:I.pausable};e.replaceChild(I.worldId,new It(n,L,`No package in this editor registered a design-time mount for a "${I.kind}" world, so there is nothing here to author it with. A build ships the packages its own entry in \`builds/\` lists.`)),u=!0}u&&n.notifyIngestEdit()}),se=ee(()=>{for(const u of b.values())Ce(u)}),ae=zn(()=>{for(const u of b.values())Ce(u)}),dt=n.subscribe(()=>{if(!M&&n.playState!=="stopped"){M=!0,V();return}if(M&&!k&&n.playState==="stopped"&&!D){k=!0,D||Ue();return}if(!M)for(const[u,I]of b)Pn(I,u,j.get(u)?.kind??"dom")});return()=>{D=!0;for(const u of Y.values())u();Y.clear(),mt(),O(),dt(),se(),ae(),X()}}const Mn=.1,Dn=4,Tn=.002,Ar=4;function ke(t,e,n){return e===1?t*16:e===2?t*n:t}function Fr(t,e){let n=ke(e.deltaX,e.deltaMode,e.bounds.width),r=ke(e.deltaY,e.deltaMode,e.bounds.height);if(e.ctrlKey||e.metaKey){const s=Math.min(Dn,Math.max(Mn,t.zoom*Math.exp(-r*Tn))),i=e.clientX-e.bounds.left,d=e.clientY-e.bounds.top,x=(i-t.x)/t.zoom,v=(d-t.y)/t.zoom;return{x:i-x*s,y:d-v*s,zoom:s}}return e.shiftKey&&n===0&&(n=r,r=0),{x:t.x-n,y:t.y-r,zoom:t.zoom}}function Yr(t,e){const n=ke(e.deltaY,e.deltaMode,e.bounds.height),r=Math.min(Dn,Math.max(Mn,t.zoom*Math.exp(-n*Tn))),s=e.clientX-e.bounds.left,i=e.clientY-e.bounds.top,d=(s-t.x)/t.zoom,x=(i-t.y)/t.zoom;return{x:s-d*r,y:i-x*r,zoom:r}}function me(t){return t instanceof Element&&t.closest('[data-vgai-canvas-navigation-ignore="true"]')!==null}function Ln(t,e,n,r={}){let s=null,i=!1,d="";const x=()=>t.querySelector('[data-testid="world-selection-overlay-interaction"]'),v=m=>{t.dataset.canvasPanning=m?"true":"false",t.style.cursor=m?"grabbing":"";const p=x();p&&(m?(d=p.style.cursor,p.style.cursor="grabbing"):p.style.cursor=d)},y=m=>{if(!s||m.pointerId!==s.pointerId)return;const p=s.button===1?4:2;if((m.buttons&p)===0){w(m);return}const S=m.clientX-s.startClientX,f=m.clientY-s.startClientY;if(!s.moved){if(Math.hypot(S,f)<=Ar)return;s.moved=!0,v(!0)}e.setPan(s.startPan.x+S,s.startPan.y+f)},w=m=>{if(!s||m.pointerId!==s.pointerId)return;const p=s.pointerId;s.button===2&&s.moved&&(i=!0),s=null,v(!1),t.hasPointerCapture?.(p)&&t.releasePointerCapture(p),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)},E=m=>{const p=m.button===1,S=r.rightDragPans===!0&&m.button===2;!p&&!S||me(m.target)||(S&&(i=!1),m.preventDefault(),p&&m.stopPropagation(),s={pointerId:m.pointerId,button:m.button,startClientX:m.clientX,startClientY:m.clientY,startPan:e.get(),moved:p},t.setPointerCapture?.(m.pointerId),v(p),window.addEventListener("pointermove",y),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w))},z=m=>{m.button===1&&!me(m.target)&&m.preventDefault()},j=m=>{r.rightDragPans!==!0||!(s?.button===2&&s.moved)&&!i||(i=!1,m.preventDefault(),m.stopPropagation())},b=m=>{if(me(m.target))return;m.preventDefault(),m.stopPropagation();const p=n(e.get(),{clientX:m.clientX,clientY:m.clientY,deltaX:m.deltaX,deltaY:m.deltaY,deltaMode:m.deltaMode,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey,bounds:t.getBoundingClientRect()});e.setView(p.x,p.y,p.zoom)};return t.addEventListener("pointerdown",E,!0),t.addEventListener("lostpointercapture",w,!0),t.addEventListener("mousedown",z,!0),t.addEventListener("contextmenu",j,!0),t.addEventListener("wheel",b,{capture:!0,passive:!1}),()=>{s=null,v(!1),t.removeEventListener("pointerdown",E,!0),t.removeEventListener("lostpointercapture",w,!0),t.removeEventListener("mousedown",z,!0),t.removeEventListener("contextmenu",j,!0),t.removeEventListener("wheel",b,!0),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)}}function Nr(t,e=Pe){return Ln(t,e,Fr)}function Gr(t,e){return Ln(t,e,Yr,{rightDragPans:!0})}const Ie="#191c22",_r="rgba(255, 255, 255, 0.2)",jt=[],qe=new Set,Xr=[];function Hr(){return jt.length===0?Xr:jt}function Vr(t){for(let e=jt.length-1;e>=0;e--){const n=jt[e];if(n&&n.medium===t)return n}return null}function Wr(t){return jt.find(e=>e.documentId===t)??null}function Kr(t){return qe.add(t),()=>{qe.delete(t)}}function St(t){return t.map(e=>`“${e}”`).join(", ")}function Ur(t,e){const n=e.map(r=>r.worldId);return{tone:"error",title:n.length===1?`${t} root ${St(n)} failed`:`${n.length} ${t} roots failed`,description:`${e.map(r=>`${r.worldId} (${r.kind}, ${r.identity}): ${r.message}`).join(`
1
+ import{a}from"./jsx-runtime-DPjLkJKQ.js";import{cc as co,cd as uo,ce as po,cf as ee,az as bn,cg as Ge,ch as fo,Z as Ft,ci as ho,cj as yn,ck as go,cl as je,cm as ne,cn as Pe,co as Kt,u as oe,cp as vn,cq as mo,bq as Ut,bc as xo,bd as et,a4 as nt,br as bo,B as Zt,cr as wn,cs as Sn,ct as En,cu as Yt,a6 as yo,cv as vo,cw as wo,G as re,cx as _e,cy as Xe,cz as He,cA as So,cB as Eo,cC as Co,cD as ko,cE as Io,cF as J,cG as Ro,cH as Cn,cI as zo,cJ as jo,cK as pe,cL as Po,cM as F,cN as Se,cO as Rt,cP as Mo,cQ as Do,cR as To,cS as Lo,cT as $o,cU as Ve,cV as Bo,cW as Oo,cX as Ao,cY as Fo,cZ as Yo,c_ as No,c$ as Go,d0 as kn,d1 as _o,d2 as Xo,t as zt,d3 as Ho,d4 as Vo,d5 as Wo,d6 as Ko,as as In,d7 as Uo,d8 as Zo,d9 as qo,da as Jo,db as Qo,dc as tr,dd as er,aj as nr,de as or,df as rr,dg as Nt,dh as fe,di as ir,dj as Gt,dk as sr,dl as he,dm as We,dn as ar,Y as lr,dp as cr,W as dr,dq as ur,dr as pr,ds as fr,dt as hr,du as gr,dv as mr,dw as xr,dx as Ke,dy as br,dz as yr}from"./index-DmtPt6RQ.js";import{r as c}from"./index-DaQZGF7d.js";import{B as It,q as Ue,I as vr}from"./edit-mode-authoring-CWTeROGv.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{T as wr}from"./TransientHint-aFFUtbSY.js";import{s as Sr,g as Er,a as Cr,f as kr,t as Ir,z as Rr,b as zr}from"./react-story-board-CnCZAhn6.js";import{g as Me}from"./viewport-pick-context-DkawXbEi.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./client-DNXj_opT.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";const qt=[],Ze=new Set,jr=[];function Pr(){return qt.length===0?jr:qt}function vt(t){for(let e=qt.length-1;e>=0;e--){const n=qt[e];if(n&&n.kind===t)return n}return null}function Mr(t){return Ze.add(t),()=>{Ze.delete(t)}}const Dr={width:null,height:null};let Vt=Dr;const Ee=new Set;function Rn(){return Vt}function Jt(t,e){const n=t===null?null:Math.max(1,Math.round(t)),r=e===null?null:Math.max(1,Math.round(e));if(!(Vt.width===n&&Vt.height===r)){Vt={width:n,height:r};for(const s of Ee)s()}}function Tr(){Jt(null,null)}function zn(t){return Ee.add(t),()=>Ee.delete(t)}const Lr=1;function jn(t){const e=[];for(const{worldId:n,adapter:r}of t.childAdapters()){if(!(r instanceof It))continue;const s=r.inspector.get(n,"kind");if(s!=="dom"&&s!=="canvas"||r.inspector.get(n,"reason")!==void 0)continue;const d=r.inspector.get(n,"adapter");d?.startsWith("ingest")||d?.startsWith("module")||e.push({worldId:n,kind:s,path:r.inspector.get(n,"path"),zOrder:Number(r.inspector.get(n,"zOrder")??0),pausable:r.inspector.get(n,"pausable")!==!1})}return e}function $r(t){return jn(t)}function ge(t,e){return t.childAdapters().some(n=>n.worldId===e)}function Pn(t,e,n="dom"){const r=yn(e)?"none":"block";t.style.display=r,t.style.pointerEvents=vt(n)?.alwaysInteractive||go(e)?"auto":"none";for(const s of Array.from(t.parentElement?.children??[]))s instanceof HTMLElement&&s.dataset.vgaiStoryBoardChromeFor===e&&(s.style.display=r)}function Br(t,e,n,r){const{worldId:s}=e,i=document.createElement("div");return i.dataset.worldId=s,i.dataset.vgaiRootSurface="true",r&&(i.dataset.vgaiCanvasScene="true"),i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.width="100%",i.style.height="100%",i.style.zIndex=String(n),i.style.contain="layout paint",Pn(i,s,e.kind),Ce(i),t.appendChild(i),i}function Ce(t){if(t.dataset.vgaiCanvasScene==="true"){t.style.transform="",t.style.width="100%",t.style.height="100%";return}if(t.style.transform=je(ne())??"",t.style.transformOrigin="0 0",t.dataset.vgaiReactStoryBoard==="true")return;const e=Rn();t.style.width=e.width===null?"100%":`${e.width}px`,t.style.height=e.height===null?"100%":`${e.height}px`}function Or(t,e,n,r,s,i,d){i?i.canvasSceneView.reset():co(),Tr();const x=bn();if(!i&&x?.config.resolution&&Jt(x.config.resolution.width,x.config.resolution.height),n.playState!=="stopped"){let u=!1,I=!1;const L=n.subscribe(()=>{u||I||n.playState!=="stopped"||(I=!0,u||Ue())});return()=>{u=!0,L()}}const v=x?.rootPath,y=r?[...r]:jn(e);if(y.length===0||!v)return()=>{};const w=v,z=uo(y.map(u=>({id:u.worldId,zOrder:u.zOrder}))).map(u=>y.find(I=>I.worldId===u.id)),j=new Map(z.map(u=>[u.worldId,u])),b=new Map,m=new Map,p=new Map,S=new Set,f=new Set,P=new Set;let D=!1,M=!1,k=!1;function X(){for(const u of m.values())try{u()}catch(I){Ft.error(`[design-time-layers] dispose failed: ${I}`,"authoring")}m.clear();for(const u of b.values())u.remove();b.clear();for(const u of z)s?.(u.worldId,null)}function V(){X();for(const u of S){const I=j.get(u);if(!I)continue;const L={id:I.worldId,kind:I.kind,entryOrScenePath:I.path,zOrder:I.zOrder,pausable:I.pausable};e.replaceChild(u,new It(n,L,"Design-time layer suspended by play mode — Stop restores it."))}S.clear(),n.notifyIngestEdit()}function W(u,I,L){const B=vt(u.kind);if(!B){f.add(u.worldId);return}f.delete(u.worldId);const G=(p.get(u.worldId)??0)+1;p.set(u.worldId,G);const A=Br(t,u,Lr+I,!!i);b.set(u.worldId,A);const xt={projectRootPath:w,store:n,...i?{view:i.canvasSceneView}:{},...d?{activationDocumentId:d}:{}};(async()=>B.mount(u,A,xt))().then(K=>{if(D||M||p.get(u.worldId)!==G){K.dispose();return}if(K.adapter)ge(e,u.worldId)&&(e.replaceChild(u.worldId,K.adapter),S.add(u.worldId)),s?.(u.worldId,K.adapter);else if(K.pick){const Q={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};e.replaceChild(u.worldId,new It(n,Q,void 0,K.pick)),S.add(u.worldId)}m.set(u.worldId,K.dispose),Ge(u.worldId),n.notifyIngestEdit(),L?.()}).catch(K=>{if(p.get(u.worldId)!==G||(L?.(),A.remove(),b.get(u.worldId)===A&&b.delete(u.worldId),D||M))return;const Q=fo(K);Ft.error(`[design-time-layers] world "${u.worldId}" (${u.kind}) failed to mount: ${Q}`,"authoring");const ut={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};s?.(u.worldId,null),ge(e,u.worldId)&&e.replaceChild(u.worldId,new It(n,ut,Q)),ho({worldId:u.worldId,kind:u.kind,identity:B.identity,message:Q}),n.notifyIngestEdit()})}z.forEach((u,I)=>{W(u,I)});function Mt(u,I){const L=m.get(u.worldId);m.delete(u.worldId);const B=b.get(u.worldId);b.delete(u.worldId),W(u,I,()=>{const A=b.get(u.worldId);if(A&&(A.style.visibility=""),L)try{L()}catch(xt){Ft.error(`[design-time-layers] re-projection dispose failed: ${xt}`,"authoring")}B?.remove()});const G=b.get(u.worldId);G&&G!==B&&(G.style.visibility="hidden")}function gt(u,I){const L=m.get(u.worldId);if(m.delete(u.worldId),L)try{L()}catch(G){Ft.error(`[design-time-layers] remount dispose failed: ${G}`,"authoring")}const B=b.get(u.worldId);B&&(B.remove(),b.delete(u.worldId)),W(u,I)}const Y=new Map;function Dt(){for(const[u,I]of Y)vt(u.kind)!==u&&(I(),Y.delete(u));for(const u of Pr()){if(Y.has(u)||vt(u.kind)!==u||!z.some(B=>B.kind===u.kind))continue;const I=[],L=B=>()=>{D||M||n.playState!=="stopped"||z.forEach((G,A)=>{G.kind===u.kind&&B(G,A)})};u.remountWhen&&I.push(u.remountWhen(L(gt))),u.reprojectWhen&&I.push(u.reprojectWhen(L(Mt))),Y.set(u,()=>{for(const B of I)B()})}}Dt();const mt=Mr(()=>{D||M||n.playState!=="stopped"||(z.forEach((u,I)=>{f.has(u.worldId)&&vt(u.kind)&&(P.delete(u.worldId),Ge(u.worldId),W(u,I))}),Dt())}),O=po(()=>{if(D||M)return;let u=!1;for(const I of z){if(!f.has(I.worldId)||P.has(I.worldId)||vt(I.kind)||(P.add(I.worldId),!ge(e,I.worldId)))continue;const L={id:I.worldId,kind:I.kind,entryOrScenePath:I.path,zOrder:I.zOrder,pausable:I.pausable};e.replaceChild(I.worldId,new It(n,L,`No package in this editor registered a design-time mount for a "${I.kind}" world, so there is nothing here to author it with. A build ships the packages its own entry in \`builds/\` lists.`)),u=!0}u&&n.notifyIngestEdit()}),se=ee(()=>{for(const u of b.values())Ce(u)}),ae=zn(()=>{for(const u of b.values())Ce(u)}),dt=n.subscribe(()=>{if(!M&&n.playState!=="stopped"){M=!0,V();return}if(M&&!k&&n.playState==="stopped"&&!D){k=!0,D||Ue();return}if(!M)for(const[u,I]of b)Pn(I,u,j.get(u)?.kind??"dom")});return()=>{D=!0;for(const u of Y.values())u();Y.clear(),mt(),O(),dt(),se(),ae(),X()}}const Mn=.1,Dn=4,Tn=.002,Ar=4;function ke(t,e,n){return e===1?t*16:e===2?t*n:t}function Fr(t,e){let n=ke(e.deltaX,e.deltaMode,e.bounds.width),r=ke(e.deltaY,e.deltaMode,e.bounds.height);if(e.ctrlKey||e.metaKey){const s=Math.min(Dn,Math.max(Mn,t.zoom*Math.exp(-r*Tn))),i=e.clientX-e.bounds.left,d=e.clientY-e.bounds.top,x=(i-t.x)/t.zoom,v=(d-t.y)/t.zoom;return{x:i-x*s,y:d-v*s,zoom:s}}return e.shiftKey&&n===0&&(n=r,r=0),{x:t.x-n,y:t.y-r,zoom:t.zoom}}function Yr(t,e){const n=ke(e.deltaY,e.deltaMode,e.bounds.height),r=Math.min(Dn,Math.max(Mn,t.zoom*Math.exp(-n*Tn))),s=e.clientX-e.bounds.left,i=e.clientY-e.bounds.top,d=(s-t.x)/t.zoom,x=(i-t.y)/t.zoom;return{x:s-d*r,y:i-x*r,zoom:r}}function me(t){return t instanceof Element&&t.closest('[data-vgai-canvas-navigation-ignore="true"]')!==null}function Ln(t,e,n,r={}){let s=null,i=!1,d="";const x=()=>t.querySelector('[data-testid="world-selection-overlay-interaction"]'),v=m=>{t.dataset.canvasPanning=m?"true":"false",t.style.cursor=m?"grabbing":"";const p=x();p&&(m?(d=p.style.cursor,p.style.cursor="grabbing"):p.style.cursor=d)},y=m=>{if(!s||m.pointerId!==s.pointerId)return;const p=s.button===1?4:2;if((m.buttons&p)===0){w(m);return}const S=m.clientX-s.startClientX,f=m.clientY-s.startClientY;if(!s.moved){if(Math.hypot(S,f)<=Ar)return;s.moved=!0,v(!0)}e.setPan(s.startPan.x+S,s.startPan.y+f)},w=m=>{if(!s||m.pointerId!==s.pointerId)return;const p=s.pointerId;s.button===2&&s.moved&&(i=!0),s=null,v(!1),t.hasPointerCapture?.(p)&&t.releasePointerCapture(p),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)},E=m=>{const p=m.button===1,S=r.rightDragPans===!0&&m.button===2;!p&&!S||me(m.target)||(S&&(i=!1),m.preventDefault(),p&&m.stopPropagation(),s={pointerId:m.pointerId,button:m.button,startClientX:m.clientX,startClientY:m.clientY,startPan:e.get(),moved:p},t.setPointerCapture?.(m.pointerId),v(p),window.addEventListener("pointermove",y),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w))},z=m=>{m.button===1&&!me(m.target)&&m.preventDefault()},j=m=>{r.rightDragPans!==!0||!(s?.button===2&&s.moved)&&!i||(i=!1,m.preventDefault(),m.stopPropagation())},b=m=>{if(me(m.target))return;m.preventDefault(),m.stopPropagation();const p=n(e.get(),{clientX:m.clientX,clientY:m.clientY,deltaX:m.deltaX,deltaY:m.deltaY,deltaMode:m.deltaMode,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey,bounds:t.getBoundingClientRect()});e.setView(p.x,p.y,p.zoom)};return t.addEventListener("pointerdown",E,!0),t.addEventListener("lostpointercapture",w,!0),t.addEventListener("mousedown",z,!0),t.addEventListener("contextmenu",j,!0),t.addEventListener("wheel",b,{capture:!0,passive:!1}),()=>{s=null,v(!1),t.removeEventListener("pointerdown",E,!0),t.removeEventListener("lostpointercapture",w,!0),t.removeEventListener("mousedown",z,!0),t.removeEventListener("contextmenu",j,!0),t.removeEventListener("wheel",b,!0),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)}}function Nr(t,e=Pe){return Ln(t,e,Fr)}function Gr(t,e){return Ln(t,e,Yr,{rightDragPans:!0})}const Ie="#191c22",_r="rgba(255, 255, 255, 0.2)",jt=[],qe=new Set,Xr=[];function Hr(){return jt.length===0?Xr:jt}function Vr(t){for(let e=jt.length-1;e>=0;e--){const n=jt[e];if(n&&n.medium===t)return n}return null}function Wr(t){return jt.find(e=>e.documentId===t)??null}function Kr(t){return qe.add(t),()=>{qe.delete(t)}}function St(t){return t.map(e=>`“${e}”`).join(", ")}function Ur(t,e){const n=e.map(r=>r.worldId);return{tone:"error",title:n.length===1?`${t} root ${St(n)} failed`:`${n.length} ${t} roots failed`,description:`${e.map(r=>`${r.worldId} (${r.kind}, ${r.identity}): ${r.message}`).join(`
2
2
  `)}
3
3
  If this followed an edit, Undo (Ctrl+Z) restores the previous source and remounts.`}}function Zr(t,e){return{tone:"loading",title:e.length===0?`Loading ${t}`:e.length===1?`Loading ${t} root ${St(e)}`:`Loading ${e.length} ${t} roots`,description:e.length===0?"Reading the project declaration to identify the root that belongs here.":`Waiting for ${St(e)} to finish mounting.`}}function qr(t,e){return e.length===0?{tone:"neutral",title:`No ${t} root`,description:"No declared root belongs to this surface."}:{tone:"neutral",title:"No renderable content",description:(e.length===1?`Root ${St(e)} mounted successfully but currently produces no renderable content.`:`Roots ${St(e)} mounted successfully but currently produce no renderable content.`)+" If this world builds its content under its game systems, press Play (▶) to run it."}}function Jr(t){if(t.content==="present")return null;if(t.playSuspended)return{tone:"neutral",title:"Editing paused during Play",description:`${St(t.rootIds)} is running in the Game tab. Press Stop (⏹) to edit it here.`};const e=new Set(t.rootIds),n=(t.failures??[]).filter(i=>e.has(i.worldId));if(n.length>0)return Ur(t.surface,n);const r=(t.readiness??[]).filter(i=>i.state==="waiting"&&e.has(i.rootId)).map(i=>i.rootId),s=r.length>0?r:t.rootIds;return t.phase==="loading"||r.length>0||t.content==="unknown"?Zr(t.surface,s):qr(t.surface,t.rootIds)}const Qt=globalThis;function Re(){return Qt.__vgaiBreakpointListeners??=new Set,Qt.__vgaiBreakpointListeners}function Qr(){return Qt.__vgaiActiveBreakpoint??null}function ti(t){Qt.__vgaiActiveBreakpoint=t;for(const e of Re())e()}function ei(t){return Re().add(t),()=>Re().delete(t)}const $n="vgai:board-guides:v1";function Bn(){return typeof window>"u"?null:window.localStorage}function On(){try{return bn()?.rootPath??"(no-project)"}catch{return"(no-project)"}}function An(){try{return JSON.parse(Bn()?.getItem($n)??"{}")}catch{return{}}}function ni(t){try{Bn()?.setItem($n,JSON.stringify(t))}catch{}}const ze=new Set;let xe=null,Je=Date.now()%1e6;function Pt(){return xe||(xe=An()[On()]??{}),xe}function De(){const t=An();t[On()]=Pt(),ni(t);for(const e of ze)e()}const oi=[];function ie(t){return Pt()[t]??oi}function ri(t){return ze.add(t),()=>ze.delete(t)}function ii(t,e,n){Je+=1;const r=`guide-${Je}`;return Pt()[t]=[...ie(t),{id:r,axis:e,value:n}],De(),r}function Qe(t,e,n){Pt()[t]=ie(t).map(r=>r.id===e?{...r,value:n}:r),De()}function tn(t,e){Pt()[t]=ie(t).filter(n=>n.id!==e),De()}const q=16,be="rgba(255, 82, 82, 0.9)",en="rgba(18, 22, 26, 0.92)",_t="rgba(255, 255, 255, 0.28)";function si(t){return[10,25,50,100,250,500,1e3,2500,5e3].find(n=>n*t>=60)??1e4}function nn(t){return Math.abs(t)>=1e3?`${t/1e3}k`:String(t)}function ai({docId:t,containerRef:e}){const n=c.useSyncExternalStore(ee,ne),r=c.useSyncExternalStore(ri,()=>ie(t)),[s,i]=c.useState(null),d=c.useRef(null);c.useEffect(()=>{const p=e.current;if(!p)return;const S=p.getBoundingClientRect();return S.left,S.top,n.x,n.y,n.zoom,()=>void 0},[t,e,n.x,n.y,n.zoom]);const x=(p,S)=>Math.round((p-(S==="x"?n.x:n.y))/n.zoom),v=(p,S)=>(S==="x"?n.x:n.y)+p*n.zoom,y=p=>{const S=e.current?.getBoundingClientRect();return S?{x:p.clientX-S.left,y:p.clientY-S.top}:{x:0,y:0}},w=p=>S=>{S.preventDefault(),S.currentTarget.setPointerCapture(S.pointerId);const f=y(S);i({kind:"place",axis:p,id:null,at:p==="x"?f.x:f.y})},E=p=>S=>{S.preventDefault(),S.stopPropagation(),S.currentTarget.setPointerCapture(S.pointerId);const f=y(S);i({kind:"move",axis:p.axis,id:p.id,at:p.axis==="x"?f.x:f.y})},z=p=>{if(!s)return;const S=y(p),f=s.axis==="x"?S.x:S.y;i({...s,at:f}),s.kind==="move"&&s.id&&Qe(t,s.id,x(f,s.axis))},j=p=>{if(!s)return;const S=y(p),f=s.axis==="x"?S.x:S.y,P=f<=q;s.kind==="place"?P||ii(t,s.axis,x(f,s.axis)):s.id&&(P?tn(t,s.id):Qe(t,s.id,x(f,s.axis))),i(null)},b=p=>{const S=e.current,f=S?p==="x"?S.clientWidth:S.clientHeight:0,P=si(n.zoom),D=Math.ceil(x(q,p)/P)*P,M=x(f,p),k=[];for(let X=D;X<=M&&k.length<200;X+=P)k.push(X);return k},m={position:"absolute",background:en,zIndex:61,userSelect:"none",touchAction:"none",overflow:"hidden"};return a.jsxs("div",{ref:d,"data-testid":"board-rulers",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:60},onPointerMove:z,onPointerUp:j,children:[r.map(p=>{const S=v(p.value,p.axis),f=p.axis==="x";return a.jsx("div",{"data-testid":`board-guide-${p.axis}-${p.value}`,title:`${p.axis} = ${p.value} — drag to move, drop on the ruler or double-click to remove`,onPointerDown:E(p),onPointerMove:z,onPointerUp:j,onDoubleClick:()=>tn(t,p.id),style:{position:"absolute",pointerEvents:"auto",cursor:f?"col-resize":"row-resize",zIndex:60,...f?{left:S-2,top:0,bottom:0,width:5}:{top:S-2,left:0,right:0,height:5}},children:a.jsx("div",{style:{position:"absolute",background:be,...f?{left:2,top:0,bottom:0,width:1}:{top:2,left:0,right:0,height:1}}})},p.id)}),s&&a.jsx("div",{style:{position:"absolute",background:be,zIndex:62,...s.axis==="x"?{left:s.at,top:0,bottom:0,width:1}:{top:s.at,left:0,right:0,height:1}},children:a.jsx("span",{style:{position:"absolute",...s.axis==="x"?{top:q+4,left:4}:{left:q+4,top:4},fontSize:9,fontFamily:"ui-monospace, monospace",color:be,background:en,padding:"1px 3px",borderRadius:3,whiteSpace:"nowrap"},children:x(s.at,s.axis)})}),a.jsx("div",{"data-testid":"board-ruler-top",onPointerDown:w("y"),style:{...m,top:0,left:q,right:0,height:q,cursor:"row-resize",pointerEvents:"auto"},children:b("x").map(p=>a.jsx("span",{style:{position:"absolute",left:v(p,"x"),bottom:0,borderLeft:`1px solid ${_t}`,height:5},children:a.jsx("span",{style:{position:"absolute",left:2,bottom:3,fontSize:8,color:_t,fontFamily:"ui-monospace, monospace"},children:nn(p)})},p))}),a.jsx("div",{"data-testid":"board-ruler-left",onPointerDown:w("x"),style:{...m,top:q,left:0,bottom:0,width:q,cursor:"col-resize",pointerEvents:"auto"},children:b("y").map(p=>a.jsx("span",{style:{position:"absolute",top:v(p,"y"),right:0,borderTop:`1px solid ${_t}`,width:5},children:a.jsx("span",{style:{position:"absolute",top:1,right:3,fontSize:8,color:_t,fontFamily:"ui-monospace, monospace",writingMode:"vertical-rl"},children:nn(p)})},p))}),a.jsx(li,{}),a.jsx("div",{style:{...m,top:0,left:0,width:q,height:q,borderRight:`1px solid ${Kt.border}`,borderBottom:`1px solid ${Kt.border}`}})]})}function li(){const t=c.useSyncExternalStore(ei,Qr);return t?a.jsxs("button",{type:"button","data-testid":"board-breakpoint-pill",title:"Style edits are scoped to this breakpoint — click to return to Base",onClick:()=>ti(null),style:{position:"absolute",top:q+8,right:12,zIndex:62,pointerEvents:"auto",background:"rgba(18, 22, 26, 0.92)",color:Kt.accent,border:`1px solid ${Kt.accent}`,borderRadius:999,fontSize:10,padding:"3px 10px",cursor:"pointer"},children:["@ ",t," · editing this breakpoint — click to clear"]}):null}const on=new WeakMap;let rn=0;function Et(t){let e=on.get(t);return e||(e={guides:[],listeners:new Set,revision:0},on.set(t,e)),e}function Te(t){t.revision+=1;for(const e of t.listeners)e()}function Fn(t){return Et(t).guides}function Yn(t){return Et(t).revision}function Nn(t,e){const n=Et(t);return n.listeners.add(e),()=>n.listeners.delete(e)}function ci(t,e,n){rn+=1;const r=Et(t),s=`canvas-guide-${rn}`;return r.guides=[...r.guides,{id:s,axis:e,value:n}],Te(r),s}function Gn(t,e,n){const r=Et(t),s=r.guides.map(i=>i.id===e?{...i,value:n}:i);s.every((i,d)=>i===r.guides[d])||(r.guides=s,Te(r))}function di(t,e){const n=Et(t),r=n.guides.filter(s=>s.id!==e);r.length!==n.guides.length&&(n.guides=r,Te(n))}const sn="#111214";function _n(t){let e=32;for(;e*t<12;)e*=2;for(;e*t>48;)e/=2;return e}function ui(t){return _n(t)*t}function ye(t){if(t.length===0)return null;let e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const i of t)e=Math.min(e,i.x),n=Math.min(n,i.y),r=Math.max(r,i.x+i.width),s=Math.max(s,i.y+i.height);return{x:e,y:n,width:r-e,height:s-n}}function ve(t,e,n){if(!n||!(n.width>0)||!(n.height>0))return;const r=Math.max(1,t.clientWidth-96),s=Math.max(1,t.clientHeight-96),i=Math.min(4,Math.max(.1,Math.min(r/n.width,s/n.height)));e.setView(t.clientWidth/2-(n.x+n.width/2)*i,t.clientHeight/2-(n.y+n.height/2)*i,i)}function pi({view:t}){const e=oe();c.useSyncExternalStore(e.subscribe,e.getSnapshot);const n=c.useSyncExternalStore(t.subscribe,t.get,t.get);c.useSyncExternalStore(c.useCallback(d=>Nn(t,d),[t]),c.useCallback(()=>Yn(t),[t]));const r=Fn(t),s=ui(n.zoom),i=s*4;return a.jsxs("div",{"data-testid":"canvas-scene-backdrop",style:{position:"absolute",inset:0,zIndex:2,overflow:"hidden",pointerEvents:"none"},children:[e.showGrid&&a.jsx("div",{style:{position:"absolute",inset:0,backgroundImage:"linear-gradient(rgba(255,255,255,.075) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.075) 1px, transparent 1px),linear-gradient(rgba(255,255,255,.14) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.14) 1px, transparent 1px)",backgroundPosition:`${n.x}px ${n.y}px`,backgroundSize:`${s}px ${s}px, ${s}px ${s}px, ${i}px ${i}px, ${i}px ${i}px`}}),a.jsx("div",{"data-testid":"canvas-scene-origin-y",style:{position:"absolute",left:0,right:0,top:n.y,height:1,background:"rgba(238, 91, 91, .8)"}}),a.jsx("div",{"data-testid":"canvas-scene-origin-x",style:{position:"absolute",top:0,bottom:0,left:n.x,width:1,background:"rgba(87, 199, 126, .8)"}}),a.jsx("div",{style:{position:"absolute",left:n.x+6,top:n.y+6,color:"rgba(255,255,255,.68)",font:"10px ui-monospace, SFMono-Regular, Menlo, monospace"},children:"0, 0"}),r.map(d=>a.jsx("div",{"data-testid":`canvas-scene-guide-${d.axis}`,title:`${d.axis.toUpperCase()} ${Math.round(d.value*100)/100} · drag to move · right-click to remove`,onContextMenu:x=>{x.preventDefault(),di(t,d.id)},onPointerDown:x=>{x.preventDefault(),x.stopPropagation();const v=x.currentTarget.parentElement?.getBoundingClientRect();if(!v)return;const y=E=>{const z=d.axis==="x"?E.clientX-v.left:E.clientY-v.top,j=t.get();Gn(t,d.id,(z-(d.axis==="x"?j.x:j.y))/j.zoom)},w=()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w)};window.addEventListener("pointermove",y),window.addEventListener("pointerup",w,{once:!0})},style:{position:"absolute",pointerEvents:"auto",cursor:d.axis==="x"?"ew-resize":"ns-resize",...d.axis==="x"?{left:n.x+d.value*n.zoom-4,top:20,bottom:0,width:9,borderLeft:"1px solid rgba(74, 180, 255, .95)"}:{top:n.y+d.value*n.zoom-4,left:20,right:0,height:9,borderTop:"1px solid rgba(74, 180, 255, .95)"}}},d.id)),a.jsx(fi,{view:t})]})}function fi({view:t}){const e=c.useSyncExternalStore(t.subscribe,t.get,t.get),n=c.useRef(null),r=c.useRef(null),[s,i]=c.useState({width:0,height:0});c.useEffect(()=>{const E=()=>{const j=n.current?.clientWidth??0,b=r.current?.clientHeight??0;i(m=>m.width===j&&m.height===b?m:{width:j,height:b})};if(E(),typeof ResizeObserver>"u")return;const z=new ResizeObserver(E);return n.current&&z.observe(n.current),r.current&&z.observe(r.current),()=>z.disconnect()},[]);const d=(E,z)=>{if(!(z>0))return[];const j=E==="x"?e.x:e.y,b=_n(e.zoom),m=b*e.zoom,p=20,S=Math.ceil((p-j)/m),f=Math.floor((p+z-j)/m);return Array.from({length:Math.max(0,f-S+1)},(P,D)=>{const M=S+D;return{major:M%4===0,screen:j+M*m-p,value:M*b}})},x=d("x",s.width),v=d("y",s.height),y=(E,z)=>{z.preventDefault(),z.stopPropagation();const j=z.currentTarget.parentElement?.getBoundingClientRect();if(!j)return;const b=(f,P)=>{const D=t.get();return((E==="x"?f-j.left:P-j.top)-(E==="x"?D.x:D.y))/D.zoom},m=ci(t,E,b(z.clientX,z.clientY)),p=f=>Gn(t,m,b(f.clientX,f.clientY)),S=()=>{window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",S)};window.addEventListener("pointermove",p),window.addEventListener("pointerup",S,{once:!0})},w={position:"absolute",pointerEvents:"auto",backgroundColor:"rgba(24, 26, 30, .96)",border:0,borderColor:"rgba(255,255,255,.14)",boxSizing:"border-box"};return a.jsxs(a.Fragment,{children:[a.jsx("button",{ref:n,type:"button","data-testid":"canvas-scene-ruler-x","aria-label":"Horizontal ruler; drag to create a horizontal guide",onPointerDown:E=>y("y",E),style:{...w,left:20,right:0,top:0,height:20,borderBottomStyle:"solid",borderBottomWidth:1,cursor:"row-resize",padding:0,overflow:"hidden"},children:x.map(E=>a.jsx("span",{"aria-hidden":"true","data-ruler-axis":"x","data-ruler-value":E.value,style:{position:"absolute",left:E.screen,bottom:0,width:1,height:E.major?8:4,background:E.major?"rgba(255,255,255,.5)":"rgba(255,255,255,.28)",pointerEvents:"none"},children:E.major&&a.jsx("span",{style:{position:"absolute",left:3,bottom:5,color:"rgba(255,255,255,.62)",font:"9px ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1,whiteSpace:"nowrap"},children:E.value})},E.value))}),a.jsx("button",{ref:r,type:"button","data-testid":"canvas-scene-ruler-y","aria-label":"Vertical ruler; drag to create a vertical guide",onPointerDown:E=>y("x",E),style:{...w,top:20,bottom:0,left:0,width:20,borderRightStyle:"solid",borderRightWidth:1,cursor:"col-resize",padding:0,overflow:"hidden"},children:v.map(E=>a.jsx("span",{"aria-hidden":"true","data-ruler-axis":"y","data-ruler-value":E.value,style:{position:"absolute",top:E.screen,right:0,width:E.major?8:4,height:1,background:E.major?"rgba(255,255,255,.5)":"rgba(255,255,255,.28)",pointerEvents:"none"},children:E.major&&a.jsx("span",{style:{position:"absolute",right:4,top:3,color:"rgba(255,255,255,.62)",font:"9px ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1,whiteSpace:"nowrap",writingMode:"vertical-rl",transform:"rotate(180deg)"},children:E.value})},E.value))}),a.jsx("div",{style:{...w,left:0,top:0,width:20,height:20}})]})}function hi({active:t,adapter:e,containerRef:n,view:r}){const s=oe();c.useSyncExternalStore(s.subscribe,s.getSnapshot);const i=c.useSyncExternalStore(r.subscribe,r.get,r.get),d=c.useCallback(w=>{const E=n.current;if(!E)return;const z=Math.min(4,Math.max(.1,w)),j=E.clientWidth/2,b=E.clientHeight/2,m=(j-i.x)/i.zoom,p=(b-i.y)/i.zoom;r.setView(j-m*z,b-p*z,z)},[n,i,r]),x=c.useCallback(w=>{if(!e?.rects)return[];const E=[];for(const z of w){const j=e.rects.rect(z);j&&j.width>0&&j.height>0&&E.push(j)}return E},[e]),v=c.useCallback(()=>{const w=n.current;w&&ve(w,r,ye(x(s.selectedEntityIds)))},[n,x,s,r]),y=c.useCallback(()=>{const w=n.current;!w||!e||ve(w,r,ye(x(vn(e))))},[e,n,x,r]);return c.useEffect(()=>{if(t)return s.onViewportAction(w=>{if(w.type==="focus-entity"){const E=n.current;if(!E)return;ve(E,r,ye(x([w.id])))}else w.type==="focus-selection"?v():w.type==="focus-scene"&&y()})},[t,n,y,v,x,s,r]),a.jsxs(a.Fragment,{children:[a.jsx(wr,{}),a.jsx(mo,{dimensions:"2d"}),a.jsxs(Ut,{label:"2D scene display",className:"vgai-viewport-toolbar vgai-viewport-toolbar-right","data-vgai-canvas-navigation-ignore":"true",children:[a.jsx(xo,{text:`Grid: ${s.showGrid?"On":"Off"}`,children:a.jsx(et,{"aria-label":"Toggle 2D grid","aria-pressed":s.showGrid,size:"comfortable",onClick:()=>s.toggleGrid(),children:a.jsx(nt,{icon:bo,size:"md"})})}),a.jsx(Zt,{"aria-label":"Frame all",variant:"ghost",size:"comfortable",onClick:y,children:"Frame all"})]}),a.jsxs(Ut,{label:"2D scene navigation",className:"vgai-canvas-scene-navigation","data-vgai-canvas-navigation-ignore":"true",children:[a.jsx(et,{"aria-label":"Frame selection",title:"Frame selection",size:"comfortable",disabled:s.selectedEntityIds.size===0,onClick:v,children:a.jsx(nt,{icon:wn,size:"md"})}),a.jsx(et,{"aria-label":"Zoom out",title:"Zoom out",size:"comfortable",onClick:()=>d(i.zoom/1.2),children:a.jsx(nt,{icon:Sn,size:"md"})}),a.jsxs(Zt,{variant:"ghost","aria-label":"Reset zoom to 100%",title:"Reset zoom to 100%",size:"comfortable",onClick:()=>d(1),children:[Math.round(i.zoom*100),"%"]}),a.jsx(et,{"aria-label":"Zoom in",title:"Zoom in",size:"comfortable",onClick:()=>d(i.zoom*1.2),children:a.jsx(nt,{icon:En,size:"md"})})]})]})}const an={fill:null,desktop:{width:1440,height:900},tablet:{width:768,height:1024},mobile:{width:390,height:844}};function gi({boardViewport:t,containerRef:e,selectViewport:n,viewportValue:r}){return a.jsxs(a.Fragment,{children:[a.jsxs(yo,{"aria-label":"Responsive viewport",title:t?.locked?"Viewport is locked by this story’s globals.viewport":"Responsive viewport",value:r,disabled:t?.locked===!0,onChange:s=>n(s.target.value),className:"vgai-react-viewport-select",children:[a.jsx("option",{value:"fill",children:"Responsive"}),t?t.choices.map(s=>a.jsxs("option",{value:s.id,children:[s.label," · ",s.width,"×",s.height]},s.id)):a.jsxs(a.Fragment,{children:[a.jsx("option",{value:"desktop",children:"Desktop · 1440×900"}),a.jsx("option",{value:"tablet",children:"Tablet · 768×1024"}),a.jsx("option",{value:"mobile",children:"Mobile · 390×844"})]})]}),t&&a.jsx(et,{"aria-label":"Rotate viewport",title:t.locked?"Viewport is locked by this story’s globals.viewport":"Rotate viewport",size:"comfortable",disabled:t.locked,onClick:()=>Ir(e.current),children:a.jsx(nt,{icon:vo,size:"md"})})]})}function mi({containerRef:t,context:e,boardOnly:n=!1}){const r=oe();c.useSyncExternalStore(r.subscribe,r.getSnapshot);const s=c.useSyncExternalStore(ee,ne),i=c.useSyncExternalStore(zn,Rn),d=c.useSyncExternalStore(Sr,()=>Er(t.current),()=>null),x=c.useCallback(b=>{const m=t.current;if(!m)return;const p=Math.min(4,Math.max(.1,b)),S=m.clientWidth/2,f=m.clientHeight/2,P=(S-s.x)/s.zoom,D=(f-s.y)/s.zoom;Yt(S-P*p,f-D*p,p)},[t,s]),v=c.useCallback(()=>{const b=t.current,m=[...r.selectedEntityIds].at(-1);if(!b||!m)return;const p=e?.adapter.rects?.rect(m);if(!p||p.width<=0||p.height<=0)return;const S=Math.max(1,b.clientWidth-96),f=Math.max(1,b.clientHeight-96),P=Math.min(4,Math.max(.1,Math.min(S/p.width,f/p.height)));Yt(b.clientWidth/2-(p.x+p.width/2)*P,b.clientHeight/2-(p.y+p.height/2)*P,P)},[t,e,r]),y=c.useCallback(b=>{const m=t.current;if(d){Cr(m,b==="fill"?null:b);return}const p=an[b];if(!m||p===null){Jt(null,null),Yt(0,0,1);return}Jt(p.width,p.height);const S=Math.min(1,Math.max(.1,Math.min((m.clientWidth-96)/p.width,(m.clientHeight-96)/p.height)));Yt((m.clientWidth-p.width*S)/2,(m.clientHeight-p.height*S)/2,S)},[d,t]),w=c.useCallback(()=>{const b=t.current;b&&kr(b)},[t]),E=d!==null,z=e?.kind==="dom"&&!!e.adapter.rects;if(n?!E:!z)return null;const j=d?d.selectedViewportId??"fill":Object.entries(an).find(([,b])=>b===null?i.width===null:b.width===i.width&&b.height===i.height)?.[0]??"fill";return a.jsxs(a.Fragment,{children:[!E&&i.width!==null&&i.height!==null&&a.jsx("div",{"data-testid":"react-canvas-device-frame",style:{position:"absolute",left:0,top:0,zIndex:0,width:i.width,height:i.height,transform:je(s),transformOrigin:"0 0",pointerEvents:"none",background:"#fff",boxShadow:"0 0 0 1px #ffffff40, 0 8px 30px #0009"}}),a.jsxs(Ut,{label:n?"2D component board view":"React canvas view","data-testid":n?"canvas-board-zoom-controls":"react-canvas-zoom-controls","data-vgai-canvas-navigation-ignore":"true",className:"vgai-react-canvas-controls",children:[!n&&a.jsx(gi,{boardViewport:d,containerRef:t,selectViewport:y,viewportValue:j}),E&&a.jsx(Zt,{variant:"ghost","aria-label":"Fit story board",title:"Fit all stories",size:"comfortable",onClick:w,children:"Fit board"}),a.jsx(et,{"aria-label":"Zoom out",title:"Zoom out",size:"comfortable",onClick:()=>x(s.zoom/1.2),children:a.jsx(nt,{icon:Sn,size:"md"})}),a.jsxs(Zt,{variant:"ghost","aria-label":"Reset zoom to 100%",title:"Reset zoom to 100%",size:"comfortable",onClick:()=>x(1),children:[Math.round(s.zoom*100),"%"]}),a.jsx(et,{"aria-label":"Zoom in",title:"Zoom in",size:"comfortable",onClick:()=>x(s.zoom*1.2),children:a.jsx(nt,{icon:En,size:"md"})}),!n&&a.jsx(et,{"aria-label":"Zoom to selection",title:"Zoom to selection",size:"comfortable",onClick:v,children:a.jsx(nt,{icon:wn,size:"md"})})]})]})}let xi=null;const ln=new Set;function bi(){return xi!==null}function yi(t){return ln.add(t),()=>ln.delete(t)}const vi=new Set(["","transparent","rgba(0, 0, 0, 0)"]);function wi(t){return vi.has(t)}function Si(t){for(const e of t)if(!wi(e))return e;return"#fff"}function cn(t,e){for(const n of e){const r=J(t,n.id);if(!r)continue;const s={};n.x!==void 0&&(s.x=n.x),n.y!==void 0&&(s.y=n.y),Object.keys(s).length!==0&&(r.begin(n.id),r.apply(n.id,s),r.end(n.id))}}const Ei=[{op:"left",testId:"align-left",label:"Align left",icon:_e},{op:"hcenter",testId:"align-hcenter",label:"Align horizontal center",icon:Xe},{op:"right",testId:"align-right",label:"Align right",icon:He},{op:"top",testId:"align-top",label:"Align top",icon:_e,rotate:!0},{op:"vcenter",testId:"align-vcenter",label:"Align vertical center",icon:Xe,rotate:!0},{op:"bottom",testId:"align-bottom",label:"Align bottom",icon:He,rotate:!0}],Ci=[{axis:"horizontal",testId:"distribute-horizontal",label:"Distribute horizontally",icon:Co},{axis:"vertical",testId:"distribute-vertical",label:"Distribute vertically",icon:ko}];function ki(t){const r=t.y-30-8;return{left:t.x,top:r<0?t.y+t.height+8:r}}function Ii({adapter:t,entries:e}){if(e.length<2)return null;const n=wo(e.map(d=>d.rect));if(!n)return null;const{left:r,top:s}=ki(n),i=e.length>=3;return a.jsxs(Ut,{label:"Align and distribute","data-testid":"align-toolbar",style:{position:"absolute",left:r,top:s,zIndex:re.overlayLow,gap:2,padding:3},children:[Ei.map(({op:d,testId:x,label:v,icon:y,rotate:w})=>a.jsx(et,{"data-testid":x,title:v,"aria-label":v,variant:"ghost",size:"compact",onClick:()=>cn(t,So(e,d)),children:a.jsx(nt,{icon:y,"aria-hidden":"true",style:w?{transform:"rotate(90deg)"}:void 0})},d)),i&&a.jsxs(a.Fragment,{children:[a.jsx(Eo,{}),Ci.map(({axis:d,testId:x,label:v,icon:y})=>a.jsx(et,{"data-testid":x,title:v,"aria-label":v,variant:"ghost",size:"compact",onClick:()=>cn(t,Io(e,d)),children:a.jsx(nt,{icon:y,"aria-hidden":"true"})},d))]})]})}function Ri({rect:t,initialText:e,onCommit:n,onCancel:r}){const[s,i]=c.useState(e),d=c.useRef(null),x=c.useRef(!1);c.useEffect(()=>{const w=d.current;w&&(w.focus(),w.select())},[]);const v=()=>{x.current||(x.current=!0,n(s))},y=()=>{x.current||(x.current=!0,r())};return a.jsx(Ro,{ref:d,"data-testid":"world-text-editor",value:s,onChange:w=>i(w.target.value),onBlur:v,onKeyDown:w=>{w.key==="Escape"?(w.stopPropagation(),y()):w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),v())},"data-variant":"inline-editor",style:{position:"absolute",left:t.x,top:t.y,width:Math.max(t.width,40),height:Math.max(t.height,20),boxSizing:"border-box",zIndex:re.overlayLow,pointerEvents:"auto",resize:"none"}})}const _=zt.accent.default,zi=re.overlayLow,te=5;function ji(t,e,n){return t?!1:Me()?.editorControls?.activate(e,n)??!1}function Pi(t,e,n,r,s,i){const d=t?null:Me()?.editorControls?.hover(e,n)??null;s(d),i(d?null:r(e,n))}function Mi(t,e){const n=t.hierarchy.node(e);return n?`${n.label}·${n.kind}`:e}function Di(t){return t instanceof In?t.childAdapters().some(e=>!!e.adapter.rects):!!t.rects}function Ti(t){const e=t instanceof In?t.childAdapters():[{worldId:"",adapter:t}],n=[];for(const{worldId:r,adapter:s}of e)if(s.rects&&!(r&&yn(r)))for(const i of vn(s)){if(s.inspector?.get(i,"locked")===!0)continue;const d=s.rects.rect(i);d&&n.push({id:i,rect:d})}return n}function Li(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function $i(t,e,n){if(!n)return[e];const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),[...r]}function Bi(t,e,n,r){return e&&!!n&&(n.width>te||n.height>te)&&n?Ti(t).filter(d=>Li(n,d.rect)).map(d=>d.id):r?null:[]}function Oi(t,e,n,r){return t?"grabbing":e?"grab":n||r?"crosshair":"default"}function ct(t){try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}}function we(t){t.currentTarget.hasPointerCapture?.(t.pointerId)&&t.currentTarget.releasePointerCapture?.(t.pointerId)}function Ai(t,e){if(e!==null)return!1;const n=t.currentTarget.parentElement?.parentElement??null;return zr(n,t.clientX,t.clientY)}function dn(t,e){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,border:`${e?2:1}px solid ${_}`,background:e?`color-mix(in srgb, ${_} 6%, transparent)`:"transparent",boxSizing:"border-box",pointerEvents:"none"}}function Fi(t){return{position:"absolute",left:t.x,top:Math.max(0,t.y-18),padding:"2px 6px",fontSize:11,fontFamily:"'SF Mono', 'Fira Code', Menlo, Consolas, monospace",fontWeight:600,color:"#fff",background:_,borderRadius:3,pointerEvents:"none",whiteSpace:"nowrap"}}const Xt=10,un=48;function pn(t,e){return{position:"absolute",left:t.x-Xt/2,top:t.y-Xt/2,width:Xt,height:Xt,background:"#fff",border:`1px solid ${_}`,boxSizing:"border-box",cursor:e,pointerEvents:"auto"}}const wt=12,Yi=24;function Ni(t){return{position:"absolute",left:t.x+t.width/2-wt/2,top:t.y-Yi-wt/2,width:wt,height:wt,borderRadius:"50%",background:"#fff",border:`1px solid ${_}`,boxSizing:"border-box",cursor:"grab",padding:0,pointerEvents:"auto"}}const fn=12;function Gi(t){return{position:"absolute",left:t.position[0],top:t.position[1],width:fn,height:fn,borderRadius:"50%",background:t.writable?t.color:"transparent",border:`2px solid ${t.color}`,boxSizing:"border-box",cursor:t.writable?"grab":"not-allowed",padding:0,pointerEvents:t.writable?"auto":"none",touchAction:"none"}}function _i(t){return{position:"absolute",left:t.x-8,top:t.y-8,width:16,height:16,display:"grid",placeItems:"center",borderRadius:t.kind==="anchor"?"50%":2,background:"#fff",border:`1px solid ${_}`,boxSizing:"border-box",color:_,cursor:"crosshair",fontSize:9,fontFamily:"'SF Mono', 'Fira Code', Menlo, Consolas, monospace",fontWeight:700,lineHeight:1,padding:0,pointerEvents:"auto",touchAction:"none"}}function Xi(t){return{position:"absolute",left:t.x,top:t.y+t.height+4,padding:"2px 6px",fontSize:11,fontFamily:"'SF Mono', 'Fira Code', Menlo, Consolas, monospace",fontWeight:600,color:"#fff",background:_,borderRadius:3,pointerEvents:"none",whiteSpace:"nowrap"}}const Hi="rgba(46, 204, 113, 0.25)",Vi="rgba(230, 126, 34, 0.25)";function Wi(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,background:t.kind==="padding"?Hi:Vi,boxSizing:"border-box",cursor:t.cursor,pointerEvents:"auto"}}function Ki(t){return{position:"absolute",left:t.labelX,top:t.labelY,transform:"translate(-50%, -50%)",fontSize:10,fontFamily:"monospace",color:t.kind==="padding"?"#1b7a3d":"#a35a12",background:"rgba(255,255,255,0.85)",padding:"0 2px",borderRadius:2,pointerEvents:"none",whiteSpace:"nowrap"}}function Ui(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,border:`2px dashed ${_}`,background:`color-mix(in srgb, ${_} 15%, transparent)`,boxSizing:"border-box",pointerEvents:"none",opacity:.7}}function Zi(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,background:"#ff5fa2",borderRadius:2,pointerEvents:"none"}}const Le="#ff2d92",Ht=6;function qi(t){const e=t.orientation==="horizontal";return{position:"absolute",left:Math.min(t.x1,t.x2),top:Math.min(t.y1,t.y2),width:e?Math.abs(t.x2-t.x1):1,height:e?1:Math.abs(t.y2-t.y1),background:Le,pointerEvents:"none"}}function hn(t,e,n){return{position:"absolute",left:n?t:t-Ht/2,top:n?e-Ht/2:e,width:n?1:Ht,height:n?Ht:1,background:Le,pointerEvents:"none"}}function Ji(t){return{position:"absolute",left:t.labelX,top:t.labelY,transform:"translate(-50%, -50%)",padding:"1px 4px",fontSize:10,fontFamily:"monospace",fontWeight:600,color:"#fff",background:Le,borderRadius:2,pointerEvents:"none",whiteSpace:"nowrap"}}const gn="#f24822";function Qi(t){const e=t.orientation==="vertical";return{position:"absolute",left:e?t.at:t.start,top:e?t.start:t.at,width:e?1:t.end-t.start,height:e?t.end-t.start:1,borderLeft:e?`1px dashed ${gn}`:void 0,borderTop:e?void 0:`1px dashed ${gn}`,pointerEvents:"none"}}function ts(t){return{position:"absolute",left:t.x,top:Math.max(0,t.y-36),display:"flex",gap:4,pointerEvents:"none"}}const mn={padding:"2px 6px",fontSize:10,fontFamily:"'SF Mono', 'Fira Code', Menlo, Consolas, monospace",fontWeight:600,color:zt.content.onAccent,background:`color-mix(in srgb, ${_} 85%, transparent)`,borderRadius:3,whiteSpace:"nowrap"};function es(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,border:`1px dashed color-mix(in srgb, ${_} 45%, transparent)`,boxSizing:"border-box",pointerEvents:"none"}}function xn(t,e,n){return e&&n>0?Math.round(t/n)*n:t}function ns(t,e,n,r,s,i){const d=t.nativeHandleSpan??1,x=t.nativeScaleAxis??"both";let v,y;if(x==="x")v=1+e/d,y=1;else if(x==="y")v=1,y=1+n/d;else{const w=1+(e+n)/(Math.SQRT2*d);v=w,y=w}return{...x!=="y"?{scaleXFactor:v}:{},...x!=="x"?{scaleYFactor:y}:{},...r&&!s?{scaleStep:i}:{}}}function os(t,e,n,r,s,i){const d=t.nativeOrigin;if(!d)return{};const x=r&&!s;return{...t.moveAxis!=="y"?{originX:xn(d.x+e,x,i)}:{},...t.moveAxis!=="x"?{originY:xn(d.y+n,x,i)}:{}}}function rs(t,e,n){return t==="x"?{x:e.x+n,y:e.y}:t==="y"?{x:e.x,y:e.y+n}:{x:e.x+n/Math.SQRT2,y:e.y+n/Math.SQRT2}}function is(t,e,n){return t==="x"?{dx:e,dy:0}:t==="y"?{dx:0,dy:n}:{dx:e,dy:n}}function ss(t,e){t.ownerBoxEdit.begin(t.id);for(const n of t.peers)n.ownerBoxEdit.begin(n.id);return{kind:"move",id:t.id,ownerBoxEdit:t.ownerBoxEdit,startLocal:e,origRect:t.origRect,context:t.context,...t.nativeOrigin?{nativeOrigin:t.nativeOrigin}:{},movePeers:t.peers}}function as(t,e,n){let r=e;for(let s=0;r!==null&&s<256;s++){if(n.has(r))return r;r=t.hierarchy.node(r)?.parentId??null}return null}function ls(t,e,n){const r=J(t,e);if(!r)return null;const s=t.inspector?.get(e,"style.position"),i=Se(t,e)==="2d";if(s!=="absolute"&&s!=="fixed"&&!i)return null;const d=F(t,e);if(!d)return null;const x=i?r.gizmoOrigin?.(e)??void 0:void 0,v=[];for(const y of n){if(y===e)continue;const w=J(t,y),E=F(t,y);if(!w||!E)continue;const z=t.inspector?.get(y,"style.position"),j=Se(t,y)==="2d";if(z!=="absolute"&&z!=="fixed"&&!j)continue;const b=j?w.gizmoOrigin?.(y)??void 0:void 0;v.push({id:y,ownerBoxEdit:w,origRect:E,...b?{nativeOrigin:b}:{}})}return{id:e,ownerBoxEdit:r,origRect:d,context:Rt(t,e),...x?{nativeOrigin:x}:{},peers:v}}function cs(t,e){if(!Wo(t,e)?.reorder)return null;const r=Ko(t,e);if(!r||r.length<3)return null;const s=F(t,e);if(!s)return null;const i=[];for(const d of r){if(d===e)continue;const x=F(t,d);x&&i.push({id:d,rect:x})}return i.length===0?null:{id:e,adapter:t,origRect:s,siblingRects:i}}function ds(){return Uo()}function us(t,e){if(e.size!==1)return null;const n=[...e][0],r=J(t,n);if(!r)return null;const s=F(t,n);if(!s)return null;const i=Zo(s,qo(t,n));return{id:n,rect:s,ownerBoxEdit:r,spacingBands:i}}function ps(t,e){if(e.size<2)return null;const n=[];for(const r of e){const s=F(t,r);if(!s||!J(t,r))return null;n.push({id:r,rect:s})}return n}function fs(t,e,n){const r=e.size===1?[...e][0]:null,s=r?F(t,r):null,i=s&&n?Jo(s,n):[],d=r?Qo(t,r):null,x=!!(d&&(d.position||d.parentLayout)),v=r?Rt(t,r)?.parent??null:null;return{selectedSingleRect:s,measureLines:i,positionBadge:d,showPositionBadge:x,parentRect:v}}function hs({state:t,adapter:e,onClose:n}){const r=c.useRef(null);return c.useEffect(()=>{const s=d=>{r.current?.contains(d.target)||n()},i=d=>{d.key==="Escape"&&n()};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",i),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",i)}},[n]),a.jsx(tr,{children:a.jsx(er,{ref:r,"aria-label":"Pick object under pointer","data-testid":"viewport-pick-menu",style:{position:"fixed",left:t.x,top:t.y,minWidth:190,maxWidth:320,zIndex:re.dropdown},children:t.ids.map(s=>{const i=e.hierarchy.node(s);return a.jsxs(nr,{"data-testid":"viewport-pick-menu-item",onSelect:()=>{kn(e,[s]),n()},style:{justifyContent:"space-between",gap:20},children:[a.jsx("span",{children:i?.label??s}),a.jsx("span",{style:{color:zt.content.muted,fontSize:11},children:i?.kind??""})]},s)})})})}function gs({adapter:t,view:e,transformModeAware:n=!1}={}){const r=oe(),s=c.useSyncExternalStore(r.subscribe,r.getSnapshot),i=t??Cn(r),d=c.useCallback((o,l)=>t?t.pickable?.pick(o,l)??null:zo(r,o,l),[t,r]),x=c.useRef(null),v=c.useRef(null),y=c.useRef(null),[w,E]=c.useState(null),[z,j]=c.useState(null),[b,m]=c.useState(null),[p,S]=c.useState(null),f=c.useRef(null),P=c.useCallback((o,l)=>{const g=jo(r,o,l,{...t?{adapter:t}:{}});if(g.length===0){S(null);return}S({x:o,y:l,ids:g})},[t,r]);c.useEffect(()=>{const o=g=>{const h=f.current;!h||h.pointerId!==g.pointerId||h.moved||Math.hypot(g.clientX-h.startClientX,g.clientY-h.startClientY)>te&&(h.moved=!0)},l=g=>{const h=f.current;!h||h.pointerId!==g.pointerId||(f.current=null,g.type==="pointerup"&&!h.moved&&P(g.clientX,g.clientY))};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)}},[P]);const D=c.useCallback(o=>{o.preventDefault(),o.stopPropagation()},[]),M=e??Pe,k=c.useSyncExternalStore(M.subscribe,M.get,M.get);c.useSyncExternalStore(c.useCallback(o=>Nn(M,o),[M]),c.useCallback(()=>Yn(M),[M]));const X=n?Fn(M):[],V=n?1/k.zoom:1,W=c.useRef(!1),[Mt,gt]=c.useState(!1),Y=c.useRef(null),[Dt,mt]=c.useState(!1),O=c.useRef(null);c.useEffect(()=>()=>{const o=O.current;if(O.current=null,!!o){o.ownerBoxEdit.end(o.id);for(const l of o.movePeers??[])l.ownerBoxEdit.end(l.id)}},[]);const[,se]=c.useState(0),[ae,dt]=c.useState(null),[u,I]=c.useState([]),L=c.useRef(null),[B,G]=c.useState(null),A=c.useCallback(o=>{L.current=o,G(o)},[]),xt=c.useRef(null),[$e,K]=c.useState(null),[Q,ut]=c.useState(null),pt=c.useCallback(o=>{xt.current=o,K(o)},[]),le=c.useRef(null),Be=c.useRef(null);c.useEffect(()=>{const o=le.current;if(!o)return;le.current=null;const l=pe(i,o.id);l&&l.get(o.id)===null&&ut({id:o.id,rect:o.rect})},[s]);const Oe=c.useRef("");c.useEffect(()=>{const o=[...r.selectedEntityIds].sort().join(",");o!==Oe.current&&(Oe.current=o,Q&&ut(null))}),c.useEffect(()=>{if(!Q)return;const o=window.setTimeout(()=>ut(null),4e3);return()=>window.clearTimeout(o)},[Q]);const st=c.useSyncExternalStore(yi,bi),[Xn,Ae]=c.useState(null),tt=c.useCallback(o=>{y.current=o,E(o)},[]),T=c.useCallback((o,l)=>{const g=x.current?.getBoundingClientRect();return{x:(o-(g?.left??0)-k.x)/k.zoom,y:(l-(g?.top??0)-k.y)/k.zoom}},[k.x,k.y,k.zoom]),Hn=c.useCallback(o=>{!e||!n||!i.assetDrop||!o.dataTransfer.types.includes("application/x-editor-asset")||(o.preventDefault(),o.dataTransfer.dropEffect="copy")},[i.assetDrop,e,n]),Vn=c.useCallback(o=>{if(!e||!n||!i.assetDrop)return;const l=o.dataTransfer.getData("application/x-editor-asset");if(!l)return;let g;try{g=JSON.parse(l)}catch{return}const h=T(o.clientX,o.clientY),C={position:[h.x,h.y,0],item:g.component??{kind:"file",name:g.name??g.path.split("/").pop()??g.path}};i.assetDrop.accepts("",g.path,C)&&(o.preventDefault(),o.stopPropagation(),Po(i,"",g.path,C))},[i.assetDrop,e,T,n]),at=c.useCallback(()=>se(o=>o+1),[]),Tt=c.useCallback(()=>{const o=O.current;if(!o)return!1;O.current=null,o.ownerBoxEdit.end(o.id);for(const l of o.movePeers??[])l.ownerBoxEdit.end(l.id);return dt(null),I([]),at(),!0},[at]),Wn=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);if(!C||!R)return;const $=i.inspector?.get(h,"style.position"),it=Se(i,h)==="2d";ct(l),C.begin(h),O.current={kind:"resize",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,pos:o,isPositioned:$==="absolute"||$==="fixed"||it,context:Rt(i,h)}},[i,r,T]),Kn=c.useCallback(o=>{if(o.stopPropagation(),o.button!==0)return;const l=r.selectedEntityIds;if(l.size!==1)return;const g=[...l][0],h=J(i,g),C=F(i,g);if(!h||!C)return;const R=n?h.gizmoOrigin?.(g):null;ct(o),h.begin(g),O.current={kind:"rotate",id:g,ownerBoxEdit:h,startLocal:T(o.clientX,o.clientY),origRect:C,center:R??{x:C.x+C.width/2,y:C.y+C.height/2},...R?{nativeOrigin:R}:{}}},[i,r,T,n]),ce=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);if(!C||!R)return;const $=C.gizmoOrigin?.(h)??{x:R.x+R.width/2,y:R.y+R.height/2};ct(l),C.begin(h),O.current={kind:"move",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,context:Rt(i,h),moveAxis:o,nativeOrigin:$}},[i,r,T]),Un=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);if(!C||!R)return;const $=C.gizmoOrigin?.(h)??{x:R.x+R.width/2,y:R.y+R.height/2};ct(l),C.begin(h),O.current={kind:"native-scale",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,nativeOrigin:$,nativeScaleAxis:o,nativeHandleSpan:un/k.zoom}},[i,k.zoom,r,T]),Zn=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);!C||!R||C.referencePoint?.(h)?.id!==o.id||(ct(l),C.begin(h),O.current={kind:"reference",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,context:Rt(i,h),pointerId:l.pointerId,referencePoint:o})},[i,r,T]),Lt=c.useRef(null),qn=c.useCallback((o,l,g,h)=>{h.stopPropagation(),!(h.button!==0||!g.writable)&&(ct(h),Lt.current={id:o,handleId:g.id,provider:l})},[]),Jn=c.useCallback(o=>{const l=Lt.current;if(!l)return;const g=T(o.clientX,o.clientY);l.provider.preview(l.id,l.handleId,[g.x,g.y,0]),at()},[at,T]),de=c.useCallback(o=>{const l=Lt.current;if(Lt.current=null,!l)return;we(o);const g=T(o.clientX,o.clientY);l.provider.commit(l.id,l.handleId,[g.x,g.y,0]),at()},[at,T]),Qn=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);!C||!R||(ct(l),C.begin(h),O.current={kind:"spacing",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,side:o.side,origValue:o.value})},[i,r,T]),$t=c.useCallback((o,l)=>{if(o.pointerId!==void 0&&l.pointerId!==o.pointerId)return;const g=T(l.clientX,l.clientY),h=g.x-o.startLocal.x,C=g.y-o.startLocal.y;let R;if(o.kind==="resize")R=Mo(o.pos,h,C,o.origRect,!!o.isPositioned,l.altKey,o.context),I(Do(o.pos,h,C,o.origRect,l.altKey,o.context));else if(o.kind==="native-scale")R=ns(o,h,C,r.snapEnabled,l.altKey,r.snapValues.scale),I([]);else if(o.kind==="move"){const{dx:$,dy:it}=is(o.moveAxis,h,C);if(o.nativeOrigin){R=os(o,$,it,r.snapEnabled,l.altKey,r.snapValues.translate);const Z=To({x:R.originX??o.nativeOrigin.x,y:R.originY??o.nativeOrigin.y},o.nativeOrigin,o.origRect,o.context,o.moveAxis,!r.snapEnabled||l.altKey,Lo/Math.max(k.zoom,.01),{x:X.filter(ht=>ht.axis==="x").map(ht=>ht.value),y:X.filter(ht=>ht.axis==="y").map(ht=>ht.value)});R.originX!==void 0&&(R.originX=Z.position.x),R.originY!==void 0&&(R.originY=Z.position.y),I(Z.guides)}else R=$o($,it,o.origRect,l.altKey,o.context);dt(Ve(o.origRect,$,it)),o.nativeOrigin||I(Bo($,it,o.origRect,l.altKey,o.context))}else if(o.kind==="reference"){const $=Oo(g,o.origRect,l.altKey,o.context,{bounded:o.referencePoint?.bounded,snapPoints:o.referencePoint?.snapPoints});R={referenceX:$.position.x,referenceY:$.position.y},I($.guides)}else o.kind==="rotate"?R=Ao(o.center,o.startLocal,g,o.nativeOrigin&&!r.snapEnabled||l.altKey,o.nativeOrigin?r.snapValues.rotate:15):R=Fo(o.side,h,C,o.origValue??0);if(o.ownerBoxEdit.apply(o.id,R),o.kind==="move"&&o.movePeers){const $=o.nativeOrigin?(R.originX??o.nativeOrigin.x)-o.nativeOrigin.x:(R.x??o.origRect.x)-o.origRect.x,it=o.nativeOrigin?(R.originY??o.nativeOrigin.y)-o.nativeOrigin.y:(R.y??o.origRect.y)-o.origRect.y;for(const Z of o.movePeers)Z.ownerBoxEdit.apply(Z.id,Z.nativeOrigin?{originX:Z.nativeOrigin.x+$,originY:Z.nativeOrigin.y+it}:{x:Z.origRect.x+$,y:Z.origRect.y+it})}at()},[T,at,r,X,k.zoom]),Bt=c.useCallback((o,l)=>{const g=d(o,l);if(!g)return null;const h=Yo(i,g)?.backgroundChainAt(o,l)??null;return h?Si(h):null},[i,d]);c.useEffect(()=>{if(!st)return;const o=l=>{l.key};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[st]),c.useEffect(()=>{const o=h=>h instanceof HTMLInputElement||h instanceof HTMLTextAreaElement||h instanceof HTMLSelectElement||h instanceof HTMLElement&&h.isContentEditable,l=h=>{h.code!=="Space"||h.repeat||o(h.target)||h.target instanceof HTMLButtonElement||(h.preventDefault(),W.current=!0,gt(!0))},g=h=>{h.code==="Space"&&(W.current=!1,gt(!1),Y.current&&(Y.current=null,mt(!1)))};return window.addEventListener("keydown",l),window.addEventListener("keyup",g),()=>{window.removeEventListener("keydown",l),window.removeEventListener("keyup",g)}},[]);const Fe=c.useCallback(o=>{if(o.stopPropagation(),ct(o),W.current){Y.current={startClientX:o.clientX,startClientY:o.clientY,startPan:M.get()},mt(!0);return}if(st){Bt(o.clientX,o.clientY),Ae(null);return}if(ji(t,o.clientX,o.clientY)){v.current=null,j(null),tt(null);return}const l=d(o.clientX,o.clientY);if(Ai(o,l)){v.current=null,j(null),tt(null);return}const g=l!==null?as(i,l,r.selectedEntityIds):null,h=(!n||r.transformMode==="translate")&&g!==null?ls(i,g,r.selectedEntityIds):null,C=!h&&g!==null?cs(i,g):null;v.current={downClientX:o.clientX,downClientY:o.clientY,downLocal:T(o.clientX,o.clientY),hitAtDown:l,moved:!1,moveCandidate:h,reorderCandidate:C},j(null),tt(null)},[i,r,M,n,T,tt,st,Bt,d,t]),to=c.useCallback(o=>{if(o.button===2){f.current={pointerId:o.pointerId,startClientX:o.clientX,startClientY:o.clientY,moved:!1};return}o.button===0&&Fe(o)},[Fe]),Ye=c.useCallback((o,l)=>{const g=l.clientX-o.downClientX,h=l.clientY-o.downClientY;if(!o.moved&&Math.hypot(g,h)>te&&(o.moved=!0),!!o.moved){if(o.moveCandidate){const C=ss(o.moveCandidate,o.downLocal);O.current=C,$t(C,l);return}if(o.reorderCandidate){const C=T(l.clientX,l.clientY),R=No(o.reorderCandidate.siblingRects,C);R&&(A({id:o.reorderCandidate.id,adapter:o.reorderCandidate.adapter,gap:R}),dt(Ve(o.reorderCandidate.origRect,C.x-o.downLocal.x,C.y-o.downLocal.y)));return}if(o.hitAtDown===null){const C=T(l.clientX,l.clientY);tt({x:Math.min(o.downLocal.x,C.x),y:Math.min(o.downLocal.y,C.y),width:Math.abs(C.x-o.downLocal.x),height:Math.abs(C.y-o.downLocal.y)})}}},[T,tt,$t,A]),ot=c.useCallback(o=>{const l=Y.current;if(l){M.setPan(l.startPan.x+(o.clientX-l.startClientX),l.startPan.y+(o.clientY-l.startClientY));return}if(st){const C=T(o.clientX,o.clientY);Ae({...C,color:Bt(o.clientX,o.clientY)});return}const g=O.current;if(g){$t(g,o);return}if((o.buttons&1)===0){Pi(t,o.clientX,o.clientY,d,m,j);return}const h=v.current;h&&Ye(h,o)},[r,M,T,$t,st,Bt,Ye,d,t]),rt=c.useCallback(o=>{if(we(o),Y.current){Y.current=null,mt(!1);return}const l=O.current;if(l?.pointerId!==void 0&&o.pointerId!==l.pointerId||Tt())return;const g=L.current;if(g){A(null),dt(null),v.current=null,Go(g.adapter,g.id,g.gap.beforeSiblingId);return}const h=v.current;if(v.current=null,!h)return;const C=h.hitAtDown!==null?$i(r.selectedEntityIds,h.hitAtDown,o.shiftKey):Bi(i,h.moved,y.current,o.shiftKey);C!==null&&kn(i,C),tt(null)},[i,r,tt,Tt,A]),U=c.useCallback(o=>{if(we(o),Y.current){Y.current=null,mt(!1);return}const l=O.current;l?.pointerId!==void 0&&o.pointerId!==l.pointerId||Tt()||(L.current&&(A(null),dt(null)),v.current=null,tt(null))},[Tt,tt,A]),eo=c.useCallback(()=>{t||Me()?.editorControls?.clearHover(),m(null),j(null)},[t]),no=c.useCallback(o=>{const l=x.current?.parentElement??null;if(Rr(l,o.clientX,o.clientY))return;const g=d(o.clientX,o.clientY);if(!g)return;const h=pe(i,g);if(!h)return;const C=F(i,g);if(!C)return;const R=h.get(g);if(R===null){console.warn(`[RootSelectionOverlay] text edit refused for "${g}": dynamic body or has child elements — not inline-editable.`),pt(null),ut({id:g,rect:C});return}ut(null),pt({id:g,rect:C,initialText:R})},[i,d,pt]),oo=c.useCallback(o=>{const l=xt.current;if(!l)return;const g=pe(i,l.id);g&&(le.current={id:l.id,rect:l.rect},g.set(l.id,o)),pt(null)},[i,pt]),ro=c.useCallback(()=>pt(null),[pt]);if(!Di(i)||ds())return null;const ft=new Set([...r.selectedEntityIds].filter(o=>i.hierarchy.node(o)!==void 0)),ue=z!==null&&!ft.has(z)?F(i,z):null,H=us(i,ft),bt=H?.rect??null,io=H?.ownerBoxEdit??null,N=n&&H?H.ownerBoxEdit.gizmoOrigin?.(H.id)??{x:H.rect.x+H.rect.width/2,y:H.rect.y+H.rect.height/2}:null,Ct=un/k.zoom,lt=H?H.ownerBoxEdit.referencePoint?.(H.id):null,so=H?.spacingBands??[],yt=ft.size===1?[...ft][0]:null,Ot=yt?_o(i,yt):null,ao=yt&&Ot&&r.showHelpers?Ot.layers(yt).filter(o=>r.helperVisibility[o.category]??!0):[],kt=n?{selectedSingleRect:null,measureLines:[],positionBadge:null,showPositionBadge:!1,parentRect:null}:fs(i,ft,ue),Ne=n?null:ps(i,ft),At=Be.current,lo=n?[]:At&&At.adapter===i&&At.version===s?At.hints:(()=>{const o=Xo(i);return Be.current={adapter:i,version:s,hints:o},o})();return a.jsxs("div",{style:{position:"absolute",inset:0,zIndex:zi,pointerEvents:"none"},children:[a.jsx("div",{ref:x,"data-testid":"world-selection-overlay-interaction",style:{position:"absolute",inset:0,pointerEvents:"auto",touchAction:"none",userSelect:"none",cursor:b??Oi(Dt,Mt,st,!!w)},onPointerDownCapture:to,onPointerMove:ot,onPointerUp:rt,onPointerCancel:U,onLostPointerCapture:U,onPointerLeave:eo,onDoubleClick:no,onContextMenu:D,onDragOver:Hn,onDrop:Vn}),p?a.jsx(hs,{state:p,adapter:i,onClose:()=>S(null)}):null,a.jsxs("div",{"data-testid":"world-selection-overlay-chrome",style:{position:"absolute",inset:0,pointerEvents:"none",transform:je(k),transformOrigin:"0 0"},children:[!n&&lo.map(o=>a.jsx("div",{"data-testid":"world-empty-container-hint","data-entity-id":o.id,title:o.displayName,style:{position:"absolute",left:o.rect.x,top:o.rect.y,width:o.rect.width,height:o.rect.height,border:"1px dashed rgba(154, 160, 166, 0.7)",borderWidth:n?1/k.zoom:1,boxSizing:"border-box",pointerEvents:"none"}},o.id)),ue&&a.jsx("div",{"data-testid":"world-selection-hover",style:{...dn(ue,!1),...n?{borderWidth:1/k.zoom}:{}}}),[...ft].map(o=>{const l=F(i,o);return l?a.jsxs("div",{children:[a.jsx("div",{"data-testid":"world-selection-box","data-entity-id":o,style:{...dn(l,!0),...n?{borderWidth:1/k.zoom,background:"transparent"}:{}}}),!n&&a.jsx("div",{"data-testid":"world-selection-label",style:Fi(l),children:Mi(i,o)})]},o):null}),w&&a.jsx("div",{"data-testid":"world-selection-marquee",style:{position:"absolute",left:w.x,top:w.y,width:w.width,height:w.height,border:`1px solid ${_}`,background:`color-mix(in srgb, ${_} 10%, transparent)`,pointerEvents:"none"}}),!n&&a.jsx(ms,{measureLines:kt.measureLines,snapGuides:u,positionBadge:kt.positionBadge,showPositionBadge:kt.showPositionBadge,badgeAnchorRect:kt.selectedSingleRect,parentRect:kt.parentRect,screenScale:V,screenZoom:1}),!n&&a.jsx(xs,{dragGhost:ae,reorderPreview:B}),!n&&Ne&&a.jsx(Ii,{adapter:i,entries:Ne}),bt&&io&&a.jsxs(a.Fragment,{children:[!n&&so.map(o=>a.jsxs("div",{children:[a.jsx("div",{"data-testid":`world-spacing-${o.kind}-${ys(o.side)}`,style:Wi(o),onPointerDown:l=>Qn(o,l),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U}),!o.isZero&&a.jsx("div",{style:{...Ki(o),...n?{transform:`translate(-50%, -50%) scale(${V})`,transformOrigin:"center"}:{}},children:Math.round(o.value)})]},o.side)),lt&&a.jsx("div",{"aria-label":`Edit ${lt.label}`,"data-reference-kind":lt.kind,"data-testid":"world-reference-point-handle",title:`${lt.label} (${lt.bounded?"native corner/edge/center snap":"8px/alignment snap"}, Alt for free movement)`,style:{..._i(lt),...n?{transform:`scale(${V})`,transformOrigin:"center"}:{}},onPointerDown:o=>Zn(lt,o),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U,onLostPointerCapture:U,role:"button",tabIndex:0,children:lt.kind==="anchor"?"A":"P"}),yt&&Ot&&ao.flatMap(o=>o.handles.map(l=>a.jsx("div",{"aria-label":l.label,"data-testid":"world-spatial-handle","data-handle-id":l.id,"data-writable":l.writable,role:"button",tabIndex:0,title:l.writable?l.label:`${l.label} — ${l.reason}`,style:{...Gi(l),transform:`translate(-50%, -50%) scale(${V})`},onPointerDown:g=>qn(yt,Ot,l,g),onPointerMove:Jn,onPointerUp:de,onPointerCancel:de,onLostPointerCapture:de},`${o.id}:${l.id}`))),n&&r.transformMode==="translate"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"world-2d-move-axis-x",title:"Move on X axis",style:{position:"absolute",left:N.x,top:N.y-5/k.zoom,width:Ct,height:10/k.zoom,borderTop:`${2/k.zoom}px solid #ef5350`,boxSizing:"border-box",cursor:"ew-resize",pointerEvents:"auto"},onPointerDown:o=>ce("x",o),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U}),a.jsx("div",{"data-testid":"world-2d-move-axis-y",title:"Move on Y axis",style:{position:"absolute",left:N.x-5/k.zoom,top:N.y,width:10/k.zoom,height:Ct,borderLeft:`${2/k.zoom}px solid #66bb6a`,boxSizing:"border-box",cursor:"ns-resize",pointerEvents:"auto"},onPointerDown:o=>ce("y",o),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U}),a.jsx("div",{"data-testid":"world-2d-move-center",title:"Move freely",style:{position:"absolute",left:N.x-5/k.zoom,top:N.y-5/k.zoom,width:10/k.zoom,height:10/k.zoom,border:"1px solid rgba(255,255,255,.9)",background:"#4aa3ff",boxSizing:"border-box",cursor:"move",pointerEvents:"auto"},onPointerDown:o=>ce("both",o),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U})]}),(!n||r.transformMode==="scale")&&(n?a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"world-2d-scale-axis-x",style:{position:"absolute",left:N.x,top:N.y,width:Ct,borderTop:`${2/k.zoom}px solid #ef5350`,pointerEvents:"none"}}),a.jsx("div",{"data-testid":"world-2d-scale-axis-y",style:{position:"absolute",left:N.x,top:N.y,height:Ct,borderLeft:`${2/k.zoom}px solid #66bb6a`,pointerEvents:"none"}}),[["x","ew-resize"],["y","ns-resize"],["both","nwse-resize"]].map(([o,l])=>{const g=rs(o,N,Ct),h=o==="x"?"e":o==="y"?"s":"se";return a.jsx("div",{"data-testid":`world-resize-handle-${h}`,style:{...pn(g,l),transform:`scale(${V})`,transformOrigin:"center",background:o==="x"?"#ef5350":o==="y"?"#66bb6a":"#fff"},onPointerDown:C=>Un(o,C),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U},o)})]}):a.jsxs(a.Fragment,{children:[Ho.map(({pos:o,cursor:l})=>a.jsx("div",{"data-testid":`world-resize-handle-${o}`,style:pn(Vo(bt,o),l),onPointerDown:g=>Wn(o,g),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U},o)),a.jsx("div",{"data-testid":"world-resize-dimension-label",style:Xi(bt),children:`${Math.round(bt.width)}×${Math.round(bt.height)}`})]})),(!n||r.transformMode==="rotate")&&a.jsxs(a.Fragment,{children:[n&&a.jsx("div",{"data-testid":"world-2d-rotate-ring",style:{position:"absolute",left:N.x-40/k.zoom,top:N.y-40/k.zoom,width:80/k.zoom,height:80/k.zoom,border:`${1/k.zoom}px solid #4aa3ff`,borderRadius:"50%",boxSizing:"border-box",pointerEvents:"none"}}),a.jsx("div",{"data-testid":"world-rotate-handle","aria-label":"Rotate selection",title:"Rotate selection (15° snap, Alt for free rotation)",style:{...Ni(bt),...n?{left:N.x-wt/2,top:N.y-40/k.zoom-wt/2,transform:`scale(${V})`,transformOrigin:"center",background:"#4aa3ff"}:{}},onPointerDown:Kn,onPointerMove:ot,onPointerUp:rt,onPointerCancel:U,role:"button",tabIndex:0})]})]}),!n&&a.jsx(bs,{textEdit:$e,onCommitTextEdit:oo,onCancelTextEdit:ro,textEditRefused:Q,eyedropperActive:st,eyedropperPreview:Xn})]})]})}function ms(t){const{measureLines:e,snapGuides:n,positionBadge:r,showPositionBadge:s,badgeAnchorRect:i,parentRect:d,screenScale:x,screenZoom:v}=t;return a.jsxs(a.Fragment,{children:[d&&a.jsx("div",{"data-testid":"world-parent-outline",style:es(d)}),e.map(y=>a.jsxs("div",{"data-testid":"world-measure-line",children:[a.jsx("div",{style:qi(y)}),a.jsx("div",{style:hn(y.x1,y.y1,y.orientation==="horizontal")}),a.jsx("div",{style:hn(y.x2,y.y2,y.orientation==="horizontal")}),a.jsx("div",{"data-testid":"world-measure-line-label",style:{...Ji(y),...x!==1?{transform:`translate(-50%, -50%) scale(${x})`,transformOrigin:"center"}:{}},children:y.distance})]},y.orientation)),n.map(y=>a.jsx("div",{"data-testid":"world-snap-guide",style:Qi(y)},y.orientation)),s&&i&&r&&a.jsxs("div",{"data-testid":"world-position-badge",style:{...ts(i),...x!==1?{top:i.y-36/v,transform:`scale(${x})`,transformOrigin:"top left"}:{}},children:[r.position&&a.jsx("span",{"data-testid":"world-position-badge-mode",style:mn,children:r.position}),r.parentLayout&&a.jsx("span",{"data-testid":"world-position-badge-layout",style:mn,children:r.parentLayout})]})]})}function xs(t){const{dragGhost:e,reorderPreview:n}=t;return a.jsxs(a.Fragment,{children:[e&&a.jsx("div",{"data-testid":"world-drag-ghost",style:Ui(e)}),n&&a.jsx("div",{"data-testid":"world-reorder-preview",style:Zi(n.gap.marker)})]})}function bs(t){const{textEdit:e,onCommitTextEdit:n,onCancelTextEdit:r,textEditRefused:s,eyedropperActive:i,eyedropperPreview:d}=t;return a.jsxs(a.Fragment,{children:[e&&a.jsx("div",{style:{pointerEvents:"auto"},children:a.jsx(Ri,{rect:e.rect,initialText:e.initialText,onCommit:n,onCancel:r})}),s&&a.jsx("div",{"data-testid":"world-text-edit-refused",title:"dynamic body — not inline-editable",style:{position:"absolute",left:s.rect.x,top:s.rect.y,width:Math.max(s.rect.width,40),height:Math.max(s.rect.height,20),border:`2px dashed ${zt.semantic.danger}`,boxSizing:"border-box",background:zt.semantic.dangerMuted,pointerEvents:"none"}}),i&&d&&a.jsx("div",{"data-testid":"world-eyedropper-swatch","data-color-state":d.color?"resolved":"unknown",style:{position:"absolute",left:d.x+12,top:d.y+12,width:24,height:24,borderRadius:4,border:"2px solid #fff",boxShadow:"0 1px 4px rgba(0,0,0,0.5)",background:d.color??"repeating-linear-gradient(45deg, #999, #999 4px, #ccc 4px, #ccc 8px)",pointerEvents:"none"}})]})}function ys(t){return t.endsWith("Top")?"top":t.endsWith("Right")?"right":t.endsWith("Bottom")?"bottom":"left"}function vs({explanation:t,testId:e,style:n}){return t?a.jsx(or,{"data-testid":e,tone:t.tone,title:t.title,description:a.jsx("span",{style:{whiteSpace:"pre-wrap"},children:t.description}),style:{position:"absolute",inset:0,pointerEvents:"none",...n}}):null}const ws="Scene";function Ss({active:t,composite:e,descriptor:n,documentId:r,store:s}){const i=c.useRef(null),d=c.useRef(null),[x]=c.useState(ur),v=n.kind==="canvas",y=v?x:Pe;c.useSyncExternalStore(s.subscribe,s.getSnapshot);const w=c.useSyncExternalStore(pr,fr),E=c.useSyncExternalStore(hr,gr),[z,j]=c.useState(null),b=e.childAdapters().find(k=>k.worldId===n.worldId)?.adapter??z??void 0,m=v&&b?.provenance?.label==="babylon",p=b?.hierarchy.roots()??[],S=new Set(b?.rects?.emptyContainers?.().map(k=>k.id)??[]),f=p.some(k=>!S.has(k.id)),P=Jr({surface:v?"Scene":n.kind==="dom"?"UI":"World",rootIds:[n.worldId],playSuspended:s.playState!=="stopped"&&(!b||b.provenance?.source==="boundary"),phase:!b||b.provenance?.source==="boundary"?"loading":"ready",content:!b||b.provenance?.source==="boundary"?"unknown":f?"present":"empty",readiness:w,failures:E});c.useEffect(()=>{if(b)return mr(r,()=>({adapter:b,nodeId:[...s.selectedEntityIds].find(k=>b.hierarchy.node(k))??null}))},[e,b,r,s]),c.useEffect(()=>{const k=i.current;if(k&&!m)return v?Gr(k,y):Nr(k,y)},[y,m,v]),c.useEffect(()=>{if(!t)return;if(!!!d.current&&i.current){d.current=Or(i.current,e,s,[n],(Mt,gt)=>j(gt),v?{canvasSceneView:x}:void 0,r);return}let X=0,V=0;const W=()=>{if(X+=1,X<2){V=requestAnimationFrame(W);return}yr(r)};return V=requestAnimationFrame(W),()=>cancelAnimationFrame(V)},[t,x,e,n,r,v,s]),c.useEffect(()=>()=>{d.current?.(),d.current=null},[]);const D=xr(Cn(s),s.selectedEntityIds),M=D?.worldId===n.worldId?D:b?.rects?{worldId:n.worldId,kind:"dom",adapter:b}:null;return a.jsxs("div",{ref:i,"data-testid":`world-document:${n.worldId}`,"data-vgai-backdrop-color":t?m?"#111827":v?sn:Ie:void 0,"data-vgai-backdrop-policy":t?"dark-frost":void 0,onPointerDown:()=>br("viewport"),style:{position:"absolute",inset:0,overflow:"hidden",pointerEvents:"auto",backgroundColor:m?"#111827":v?sn:Ie,touchAction:"none"},children:[m?null:v?a.jsx(pi,{view:x}):a.jsx(Es,{}),a.jsx(gs,{...b?{adapter:b}:{},...v&&!m?{view:x,transformModeAware:!0}:{}},`selection:${Ke(b)}`),a.jsx(vs,{explanation:P,testId:`world-surface-status:${n.worldId}`,style:{zIndex:20}}),m?null:v?a.jsx(hi,{active:t,...b?{adapter:b}:{},containerRef:i,view:x},`controls:${Ke(b)}`):a.jsxs(a.Fragment,{children:[a.jsx(ai,{docId:n.worldId,containerRef:i}),a.jsx(mi,{containerRef:i,context:M})]})]})}function Es(){const t=c.useSyncExternalStore(ee,ne),e=Math.max(8,24*t.zoom),n=Math.max(.7,Math.min(1.4,t.zoom));return a.jsx("div",{"data-testid":"react-design-canvas-backdrop","aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none",backgroundColor:Ie,backgroundImage:`radial-gradient(circle, ${_r} ${n}px, transparent ${n}px)`,backgroundPosition:`${t.x}px ${t.y}px`,backgroundSize:`${e}px ${e}px`}})}let Wt=null;function As(){return Wt}function Fs(t,e){Wt={store:t,composite:e};const n=lr(),r=e.childAdapters().some(f=>f.role==="world"&&f.kind==="three"),s=e.childAdapters().some(f=>f.kind===vr);!r&&!s&&rr(Nt,{discardDirty:!0});const i=new Set,d=[];let x=!1;for(const f of e.childAdapters())f.role==="world"&&f.kind==="three"&&d.push(fe(f.worldId,Nt));const v=$r(e),y=v.find(f=>f.kind==="canvas");y&&d.push(fe(y.worldId,Gt));const w=new Set([...e.childAdapters().filter(f=>f.role==="world"&&f.kind==="three"),...y?[y]:[]].map(f=>f.worldId)),E=new Map;function z(){for(const f of v){if(w.has(f.worldId)||E.has(f.worldId))continue;const P=Vr(f.kind);if(!P)continue;const D=fe(f.worldId,P.documentId),M=cr(f.worldId,()=>P.presence()==="absent"?`Root "${f.worldId}" has no document of its own: its design surface is the project's ${P.title} board (${P.documentId}). ${P.absentReason()}`:null);E.set(f.worldId,()=>{M(),D()})}}d.push(ir(f=>{const P=dr();if(P.some(M=>M.descriptor.id===f))return null;const D=Wr(f);return D?D.presence()==="absent"?D.absentReason():null:`No workspace document is named "${f}". Open in this session: ${P.map(M=>M.descriptor.id).join(", ")||"(none)"}. A component board is present only when the package that owns its medium says this project has one, so a board id can be absent for this project and present for another.`}));function j(f){const P=D=>a.jsx(Ss,{...D,composite:e,descriptor:f,store:t});ar({id:Gt,title:ws,kind:"world",workspaceRole:"authored-subject",provenance:{rootId:f.worldId,...f.path?{sourcePath:f.path}:{}},Content:P,presentation:()=>({kind:"world",id:f.worldId}),onActivate:()=>t.setActiveViewportTab("edit")},{category:"scene",default:!r,rootId:f.worldId})}function b(f){i.add(f.documentId);const P=()=>{i.delete(f.documentId)};try{Promise.resolve(f.install({store:t,composite:e})).catch(P)}catch{P()}}function m(){if(!x){z();for(const f of Hr()){const P=f.presence();if(P===null)continue;const D=i.has(f.documentId);P==="present"!==D&&(P==="present"?b(f):(We(f.documentId),i.delete(f.documentId)))}}}y&&(j(y),i.add(Gt)),m();const p=Kr(m),S=y?Gt:[...i][0];return!r&&S!==void 0&&(n===null||n===Nt||n===sr)?he(S):n?he(n):r&&he(Nt),()=>{x=!0,Wt?.store===t&&(Wt=null),p();for(const f of d)f();for(const f of E.values())f();E.clear();for(const f of i)We(f)}}export{Ss as RootDocumentContent,As as activeRootDocumentHost,Fs as installRootDocuments};
package/dist-node/cli.js CHANGED
@@ -254,6 +254,10 @@ var init_client = __esm({
254
254
  async restart() {
255
255
  await this.command({ type: "play" });
256
256
  }
257
+ /** Refuse shutdown if a document cannot be saved. Does not stop the server. */
258
+ async prepareClose() {
259
+ await this.command({ type: "session-prepare-close" });
260
+ }
257
261
  /** Stops play, and finalizes this run's recording before the surface it was
258
262
  * photographing is torn down. The capture is absent when nothing recorded. */
259
263
  async stop() {
@@ -2279,7 +2283,7 @@ function hasManifest(dir) {
2279
2283
  var package_default = {
2280
2284
  name: "@volter/editor",
2281
2285
  author: "Volter AI, Inc.",
2282
- version: "0.5.57",
2286
+ version: "0.5.59",
2283
2287
  publishConfig: {
2284
2288
  access: "public"
2285
2289
  },
@@ -2313,18 +2317,18 @@ var package_default = {
2313
2317
  entry: "./src/index.ts",
2314
2318
  colorTheme: "dark",
2315
2319
  workbench: {
2316
- release: "editor-f8664703ab59-d7489dea9dcd-darwin-arm64",
2317
- tarballSha256: "57692dc03bd5e37f1b02c817bf0601ee3f3d410b6147c24ccd978d22ff4f81ca"
2320
+ release: "editor-f8664703ab59-81f87ec200f3-darwin-arm64",
2321
+ tarballSha256: "2e2139867dda53aaa6fef58005443b9626d2f2975011c342487b1613b8464ef5"
2318
2322
  }
2319
2323
  }
2320
2324
  },
2321
2325
  dependencies: {
2322
- "@volter/editor-core": "0.5.57",
2323
- "@volter/editor-blender": "0.1.0",
2324
- "@volter/blender-engine": "0.1.0",
2325
- "@volter/editor-project": "0.5.57",
2326
- "@volter/editor-sdk": "0.5.57",
2327
- "@volter/editor-live": "0.5.57",
2326
+ "@volter/editor-core": "0.5.59",
2327
+ "@volter/editor-blender": "0.1.2",
2328
+ "@volter/blender-engine": "0.1.2",
2329
+ "@volter/editor-project": "0.5.59",
2330
+ "@volter/editor-sdk": "0.5.59",
2331
+ "@volter/editor-live": "0.5.59",
2328
2332
  "@modelcontextprotocol/sdk": "1.30.0",
2329
2333
  undici: "7.29.1"
2330
2334
  },
@@ -17732,6 +17736,8 @@ async function control(verb, argument, reason) {
17732
17736
  if (verb === "close") {
17733
17737
  const session = (await verifiedSessions(live.session.port)).find((s) => s.port === live.session.port && s.project === live.session.projectRoot && s.registered);
17734
17738
  if (!session?.pid) throw new Error("Cannot close a session without verified process ownership.");
17739
+ const state = await client.getState();
17740
+ if (state.connected || (state.tabs?.length ?? 0) > 0) await client.prepareClose();
17735
17741
  console.log(await terminateEditorSession({ pid: session.pid }));
17736
17742
  return;
17737
17743
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@volter/editor",
3
3
  "author": "Volter AI, Inc.",
4
- "version": "0.5.57",
4
+ "version": "0.5.59",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -35,18 +35,18 @@
35
35
  "entry": "./src/index.ts",
36
36
  "colorTheme": "dark",
37
37
  "workbench": {
38
- "release": "editor-f8664703ab59-d7489dea9dcd-darwin-arm64",
39
- "tarballSha256": "57692dc03bd5e37f1b02c817bf0601ee3f3d410b6147c24ccd978d22ff4f81ca"
38
+ "release": "editor-f8664703ab59-81f87ec200f3-darwin-arm64",
39
+ "tarballSha256": "2e2139867dda53aaa6fef58005443b9626d2f2975011c342487b1613b8464ef5"
40
40
  }
41
41
  }
42
42
  },
43
43
  "dependencies": {
44
- "@volter/editor-core": "0.5.57",
45
- "@volter/editor-blender": "0.1.0",
46
- "@volter/blender-engine": "0.1.0",
47
- "@volter/editor-project": "0.5.57",
48
- "@volter/editor-sdk": "0.5.57",
49
- "@volter/editor-live": "0.5.57",
44
+ "@volter/editor-core": "0.5.59",
45
+ "@volter/editor-blender": "0.1.2",
46
+ "@volter/blender-engine": "0.1.2",
47
+ "@volter/editor-project": "0.5.59",
48
+ "@volter/editor-sdk": "0.5.59",
49
+ "@volter/editor-live": "0.5.59",
50
50
  "@modelcontextprotocol/sdk": "1.30.0",
51
51
  "undici": "7.29.1"
52
52
  },
@@ -1,2 +0,0 @@
1
- import{b as m,a as h,S as c,P as E,s as w,o as F}from"./worker-DTgfRRas.js";import{s as O}from"./session-1bPxsLdy.js";async function g(o){const s=await fetch(o);if(!s.ok)throw new Error(`${o}: HTTP ${s.status}`);const e=await s.text(),t={exports:{}},l=new Function("module","exports","define",`${e}
2
- return typeof createBlenderModule === 'function' ? createBlenderModule : module.exports;`)(t,t.exports,void 0);if(typeof l!="function")throw new Error("blender_browser.js did not produce a module factory");return l}const R=new TextEncoder;function T(o,s){let e="";for(const t of s.split("/").filter(Boolean))o.FS_createPath(e||"/",t,!0,!0),e+=`/${t}`}function P(o){const s=o.FS;return{readFile:async e=>s.readFile(e),writeFile:async(e,t)=>s.writeFile(e,t),mkdirTree:async e=>s.mkdirTree(e),readdir:async e=>s.readdir(e),stat:async e=>{let t;try{t=s.stat(e)}catch{return null}const i=t.mtime;return{size:t.size,mode:t.mode??0,mtimeMs:typeof i=="number"?i:i?.getTime()??0}},unlink:async e=>s.unlink(e)}}async function A(o,s){if(!self.crossOriginIsolated)throw new Error("Headless Blender needs SharedArrayBuffer, so the editor page has to be cross-origin isolated (Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy on every response). This worker reports crossOriginIsolated=false.");const e=m("blender_browser.js"),t=await g(e),i=performance.now();let l=null;const d=(r,n)=>{n.startsWith("@@VGAI-READY ")&&(l=n.slice(13)),o.log(n.startsWith("@@VGAI-WARN")||n.startsWith("@@VGAI-ERROR")?"error":"log",n)},a=await t({arguments:["--background","--factory-startup","--python",h],locateFile:r=>m(r),mainScriptUrlOrBlob:e,print:r=>d("log",r),printErr:r=>d("error",r),preRun:[r=>{r.ENV??={},Object.assign(r.ENV,{BLENDER_SYSTEM_RESOURCES:"/bw",BLENDER_SYSTEM_PYTHON:"/bw/python",BLENDER_SYSTEM_SCRIPTS:"/bw/scripts",BLENDER_SYSTEM_DATAFILES:"/bw/datafiles",VGAI_SESSION_ROOT:c,HOME:"/root",TMPDIR:"/tmp"});for(const n of["/tmp","/root","/work",c,...E,o.project])T(r,n);r.FS_createDataFile(c,"session.py",R.encode(O),!0,!0,!0)}]});for(;l===null;)await w(5);const S=performance.now()-i,b=JSON.parse(l);let f=null;if(typeof a.releasePreloadedFileData=="function"){const r=a.releasePreloadedFileData();f=r.bytes,o.log("log",`blender: released the preloaded ${(r.bytes/1048576).toFixed(0)} MB payload (${r.files} files); WasmFS already holds it`)}else o.log("error","blender: this bundle has no releasePreloadedFileData, so the ~55 MB packed .data payload stays resident beside the copy WasmFS made of it — relink with the recipe's --post-js (recipe/release-preloaded-file-data.js).");const u=a.FS;let p="";for(const r of`${o.project}`.split("/").filter(Boolean)){p+=`/${r}`;try{u.chmod(p,511)}catch{}}for(const r of["/work","/tmp","/root",c,...E])try{u.chmod(r,511)}catch{}const y=P(a),{request:_}=F(y,o);return{skew:"emscripten",banner:b,files:y,request:_,readArena:async()=>a.HEAPU8.subarray(a._blender_web_export_buffer(),a._blender_web_export_buffer()+a._blender_web_export_buffer_size()),bootMs:S,memoryBytes:()=>a.HEAPU8.length,releasedPayloadBytes:f}}export{A as startEmscriptenBlenderEngine};
@@ -1,4 +0,0 @@
1
- import{bS as De,bT as Pe,e as N,ac as Ve,bU as We}from"./index-5av5LJja.js";import{d as ze,W as Me,H as Ge,br as qe,i as He,bK as se,w as Xe,x as Ze,af as xe,V as Q,bl as Ke,$ as Ye,k as Je,bL as Qe,bf as ve}from"./three.module-BynznMJN.js";import{f as et}from"./clip-planes-CnAI6DZn.js";class tt{#r;#c;#n=new Map;#m=0;#h=null;#s=new Map;#i=null;#u=0;#f=0;#w=0;#a=null;#g=null;#d=null;constructor(t){this.#c=t,this.#r=new Worker(new URL("/assets/worker-DTgfRRas.js",import.meta.url),{type:"module",name:"blender"}),this.#r.onmessage=n=>void this.#b(n.data),this.#r.onerror=n=>{const r=n.error,o=n.filename?` at ${n.filename}:${n.lineno}:${n.colno}`:"",a=r?.stack??r?.message??n.message,l=new Error(`Blender worker failed: ${a||"the worker script did not load"}${o}`);console.error(l.message);for(const i of[...this.#n.keys()])this.#p(i);for(const i of this.#n.values())i.reject(l);this.#n.clear()}}#o=null;#l=null;get project(){return this.#o}start(t,n){return this.#o!==null&&this.#o!==t?Promise.reject(new Error(`The Blender session is bound to ${this.#o}, not ${t}`)):n!==void 0&&this.#l!==null&&this.#l!==n?Promise.reject(new Error(`Blender resource conflict: the session holds ${this.#l}; cannot open ${n}`)):(this.#o=t,this.#l??=n??"models/model.blend",this.#h??=this.#e({op:"start",project:t,...n===void 0?{}:{document:n}}),this.#h)}#t(){return this.#o===null?Promise.reject(new Error("The Blender session has not been started with a project (blender-start)")):this.start(this.#o)}async execute(t){return await this.#t(),await this.#e({op:"execute",code:t})}async sceneInfo(){return await this.#t(),await this.#e({op:"scene-info"})}async objectInfo(t){return await this.#t(),await this.#e({op:"object-info",name:t})}async rna(t,n){return await this.#t(),await this.#e({op:"rna",path:t,...n===void 0?{}:{names:n}})}async rnaContext(t,n){return await this.#t(),await this.#e({op:"rna-context",...t===void 0?{}:{object:t},...n===void 0?{}:{collection:n}})}async rnaSet(t,n,r,o){return await this.#t(),await this.#e({op:"rna-set",path:t,property:n,value:r,...o===void 0?{}:{index:o}})}async outliner(t){return await this.#t(),await this.#e({op:"outliner",...t===void 0?{}:{selected:t}})}async nodeTree(t){return await this.#t(),await this.#e({op:"node-tree",...t?.path===void 0?{}:{path:t.path},...t?.material===void 0?{}:{material:t.material}})}async uvLayout(t){return await this.#t(),await this.#e({op:"uv-layout",...t?.object===void 0?{}:{object:t.object},...t?.uvLayer===void 0?{}:{uvLayer:t.uvLayer}})}async rig(t){return await this.#t(),await this.#e({op:"rig",...t?.object===void 0?{}:{object:t.object}})}async actionClip(t){return await this.#t(),await this.#e({op:"action-clip",...t?.object===void 0?{}:{object:t.object},...t?.bake===void 0?{}:{bake:t.bake}})}async outlinerSet(t,n,r){return await this.#t(),await this.#e({op:"outliner-set",path:t,column:n,value:r})}async present(){await this.#t(),await this.#e({op:"present"})}async screenshotView(t){return await this.#t(),await this.#e({op:"screenshot-view",maxSize:t})}async readFile(t){return await this.#t(),await this.#e({op:"read-file",path:t})}async writeFile(t,n){await this.#t(),await this.#e({op:"write-file",path:t,bytes:n})}async listFiles(t){return await this.#t(),await this.#e({op:"list-files",path:t})}get presented(){return this.#g}terminate(){this.#r.terminate();const t=new Error("The Blender session was terminated");for(const n of[...this.#n.keys()])this.#p(n);for(const n of this.#n.values())n.reject(t);this.#n.clear()}metrics(t=performance.now()){let n=null,r=this.#u,o=this.#f,a=this.#w;for(const l of this.#s.values()){const i=t-l;(n===null||i>n)&&(n=i),i>r&&(r=i),i>=5e3&&(o+=1),i>=3e4&&(a+=1)}return{inFlightMs:n===null?null:Math.round(n),lastCallMs:this.#i===null?null:Math.round(this.#i),maxCallMs:this.#i===null&&n===null?null:Math.round(r),callsOver5s:o,callsOver30s:a,lastCallWindow:this.#a,wasmMemoryMB:this.#d===null?null:Math.round(this.#d/1048576)}}#p(t){const n=this.#s.get(t);if(n===void 0)return;this.#s.delete(t);const r=performance.now()-n;this.#i=r,r>this.#u&&(this.#u=r),r>=5e3&&(this.#f+=1),r>=3e4&&(this.#w+=1),this.#a!==null&&this.#a.start===n&&(this.#a={start:n,end:n+r})}#e(t){const n=++this.#m;return new Promise((r,o)=>{this.#n.set(n,{resolve:r,reject:o});const a=performance.now();this.#s.set(n,a),this.#a={start:a,end:null},this.#r.postMessage({...t,id:n})})}async#b(t){if("op"in t){if(t.op==="log"){this.#c.log?.(t.level,t.text);return}if(t.op==="memory"){this.#d=t.bytes;return}const r=t.frame;typeof r?.session=="string"&&typeof r.revision=="number"&&(this.#g={session:r.session,revision:r.revision});try{const o=await this.#c.present(t.frame,t.description,t.capture);this.#r.postMessage({op:"present-result",id:t.id,...o?.capture===void 0?{}:{capture:o.capture},...o!=null&&"held"in o?{held:o.held}:{}})}catch(o){this.#r.postMessage({op:"present-result",id:t.id,error:o instanceof Error?o.message:String(o)})}return}const n=this.#n.get(t.id);n&&(this.#n.delete(t.id),this.#p(t.id),"error"in t?n.reject(new Error(t.error)):n.resolve(t.result))}}const nt="/assets/agx-base-srgb-BjWZJgrZ.lut",rt="/assets/agx-look-medium-high-contrast-D5F_ob1L.lut",ot="/assets/agx-look-punchy-dxsnycNs.lut",at="/assets/filmic-srgb-Ct35FIH6.lut",S=new Float64Array(12),ke=[0,0,0],R=new Float64Array(3),V=new Float64Array(3),A=new Int8Array([1,0,0,1,1,0,0,1,2,1,0,0,1,0,1,0,2,1,0,0,1,1,0,1,2,0,1,0,0,1,0,1,1,2,1,0,0,1,0,0,1,1,1,2,0,0,1,0,1,1,0,1,0,2]);function st(e,t,n){return e>t?t>n?0:e>n?1:2:n>t?3:n>e?4:5}function Be(e,t,n,r,o){const a=t*t,l=Math.min(1,Math.max(0,n))*(t-1),i=Math.min(1,Math.max(0,r))*(t-1),p=Math.min(1,Math.max(0,o))*(t-1),w=Math.min(Math.floor(l),t-2),s=Math.min(Math.floor(i),t-2),d=Math.min(Math.floor(p),t-2),k=l-w,g=i-s,c=p-d,b=(u,y,$,E)=>{const L=(w+y+(s+$)*t+(d+E)*a)*3;S[u]=e[L]/65535,S[u+1]=e[L+1]/65535,S[u+2]=e[L+2]/65535};b(0,0,0,0),b(9,1,1,1),R[0]=k,R[1]=g,R[2]=c;const h=st(k,g,c)*9;b(3,A[h],A[h+1],A[h+2]),b(6,A[h+3],A[h+4],A[h+5]);const M=R[A[h+6]],m=R[A[h+7]],f=R[A[h+8]];for(let u=0;u<3;u++){const y=S[u];ke[u]=y+M*(S[3+u]-y)+m*(S[6+u]-S[3+u])+f*(S[9+u]-S[6+u])}return ke}function W(e){const t=e&32768?-1:1,n=e>>10&31,r=e&1023;return n===0?t*2**-24*r:n===31?r?Number.NaN:t*Number.POSITIVE_INFINITY:t*2**(n-15)*(1+r/1024)}function pe(e,t,n,r){const o=new Uint8ClampedArray(t*4);for(let a=0;a<t;a++){const l=a*4,i=W(e[l+3]),p=i===0?n:n/i;V[0]=W(e[l])*p,V[1]=W(e[l+1])*p,V[2]=W(e[l+2])*p;const w=r(V);o[l]=Math.round(w[0]*255),o[l+1]=Math.round(w[1]*255),o[l+2]=Math.round(w[2]*255),o[l+3]=Math.round(Math.min(1,Math.max(0,i))*255)}return o}function it(e){return new URL(Object.assign({"./agx-base-srgb.lut":nt,"./agx-look-medium-high-contrast.lut":rt,"./agx-look-punchy.lut":ot,"./filmic-srgb.lut":at})[`./${e.replace(/\.lut$/,"")}.lut`],import.meta.url)}const lt=57,j=-12.47393,je=12.5260688117,ct=[[.4123908,.3575843,.1804808],[.212639,.7151687,.0721923],[.0193308,.1191948,.9505322]],ut=[[1.5250528,-.3159135,-.1226583],[-.5091526,1.3333274,.1382844],[.0957153,.0508974,.7879558]];function Ee(e,t,n){const r=t[0],o=t[1],a=t[2];n[0]=e[0][0]*r+e[0][1]*o+e[0][2]*a,n[1]=e[1][0]*r+e[1][1]*o+e[1][2]*a,n[2]=e[2][0]*r+e[2][1]*o+e[2][2]*a}const z=new Float64Array(3),Ce=new Float64Array(3),G=[0,0,0];function ee(e){const t=Math.min(1,Math.max(0,e));return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function Te(e,t,n,r){return Be(e,lt,t,n,r)}function dt(e,t){Ee(ct,t,Ce),Ee(ut,Ce,z);const n=je-j,r=Te(e,(Math.log2(Math.max(z[0],1e-10))-j)/n,(Math.log2(Math.max(z[1],1e-10))-j)/n,(Math.log2(Math.max(z[2],1e-10))-j)/n);return G[0]=ee(Math.max(0,r[0])**2.4),G[1]=ee(Math.max(0,r[1])**2.4),G[2]=ee(Math.max(0,r[2])**2.4),G}const pt={"AgX - Medium High Contrast":"agx-look-medium-high-contrast.lut","AgX - Punchy":"agx-look-punchy.lut"};function ht(e,t){const n=je-j;return Te(e,(Math.log2(Math.max(t[0],1e-10))-j)/n,(Math.log2(Math.max(t[1],1e-10))-j)/n,(Math.log2(Math.max(t[2],1e-10))-j)/n)}function ft(e,t,n,r={}){const o=r.exposure??1,a=r.composedLook===!0?ht:dt;return pe(t,n,o,l=>a(e,l))}const Le=33,ie=Le**3*3,le=4096,te=-12.473931188,ne=25;function re(e,t){const n=Math.min(1,Math.max(0,t))*(le-1),r=Math.min(Math.floor(n),le-2),o=n-r;return((1-o)*e[ie+r]+o*e[ie+r+1])/65535}const q=[0,0,0];function wt(e,t){const n=Be(e,Le,(Math.log2(Math.max(t[0],1e-10))-te)/ne,(Math.log2(Math.max(t[1],1e-10))-te)/ne,(Math.log2(Math.max(t[2],1e-10))-te)/ne);return q[0]=re(e,n[0]/.66),q[1]=re(e,n[1]/.66),q[2]=re(e,n[2]/.66),q}function gt(e,t,n,r){if(e.length!==ie+le)throw new Error("Invalid Blender Filmic display table");return pe(t,n,r,o=>wt(e,o))}const O=2.4,T=.055,Ie=T/(O-1),mt=1/(O/(1+T)*((Ie+T)/(1+T))**(O-1)),bt=((Ie+T)/(1+T))**O;function oe(e){return e>0?e<bt?e*mt:(1+T)*e**(1/O)-T:0}const H=[0,0,0];function yt(e){return H[0]=oe(e[0]),H[1]=oe(e[1]),H[2]=oe(e[2]),H}function Mt(e,t,n){return pe(e,t,n,yt)}function Re(e,t,n,r){if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<1||n.height<1)throw new Error("Scene capture requires finite positive dimensions");const o=Math.min(2048,Math.round(n.width)),a=Math.min(2048,Math.round(n.height)),l=r?1:2,i=o*l,p=a*l,w=De(),s=w.renderer,d={target:s.getRenderTarget(),toneMapping:s.toneMapping,exposure:s.toneMappingExposure,colorSpace:s.outputColorSpace,shadows:s.shadowMap.enabled,shadowType:s.shadowMap.type,clearColor:s.getClearColor(new ze),clearAlpha:s.getClearAlpha(),background:e.background};let k,g,c=!1;try{if(k=new Me(i,p,{type:Ge}),s.shadowMap.enabled=!0,s.shadowMap.type=qe,s.outputColorSpace=He,s.toneMapping=n.toneMapping??se,s.toneMappingExposure=n.exposure??1,s.setClearColor(0,n.transparent?0:1),n.transparent&&(e.background=null),s.setRenderTarget(k),s.clear(),s.render(e,t),r){const E=new Uint16Array(i*p*4);return s.readRenderTargetPixels(k,0,0,i,p,E),c=!0,{pixels:E,width:o,height:a}}g=new Me(i,p),Pe(n.transparent===!0).render(s,g,k,0,!1);const b=new Uint8Array(i*p*4);s.readRenderTargetPixels(g,0,0,i,p,b);const h=document.createElement("canvas");h.width=i,h.height=p;const M=h.getContext("2d");if(!M)throw new Error("Scene capture could not create an image canvas");const m=M.createImageData(i,p),f=i*4;for(let E=0;E<p;E++)m.data.set(b.subarray((p-1-E)*f,(p-E)*f),E*f);M.putImageData(m,0,0);const u=document.createElement("canvas");u.width=o,u.height=a;const y=u.getContext("2d");if(!y)throw new Error("Scene capture could not create an output canvas");y.drawImage(h,0,0,o,a);const $=u.toDataURL("image/png");return c=!0,$}finally{e.background=d.background,s.setRenderTarget(d.target),s.toneMapping=d.toneMapping,s.toneMappingExposure=d.exposure,s.outputColorSpace=d.colorSpace,s.shadowMap.enabled=d.shadows,s.shadowMap.type=d.shadowType,s.setClearColor(d.clearColor,d.clearAlpha),g?.dispose(),k?.dispose(),w.release({discard:!c})}}function xt(e,t,n){return Re(e,t,n,!0)}function vt(e,t,n){return Re(e,t,n,!1)}const kt={transform:{cx:0,cy:0,zoom:1},looked:null,refusal:null,size:{w:0,h:0},framedAt:0,drawn:[]};let ce=kt,he=0;const X=new Set;let Fe=0;function ae(){return ce}function Pt(){return he}function Vt(e){return X.add(e),()=>{X.delete(e)}}function U(e){ce={...ce,...e},he+=1;for(const t of[...X])t()}function Et(){Fe+=1,he+=1;for(const e of[...X])e()}function Wt(){return Fe}function F(e){U({refusal:e})}const Se=new Map;function Ct(e){let t=Se.get(e);return t||(t=fetch(it(e)).then(async n=>{if(!n.ok)throw new Error(`Blender display table ${e}: ${n.status} ${n.statusText}`);return new Uint16Array(await n.arrayBuffer())}),Se.set(e,t)),t}function St(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return new Uint16Array(n.buffer,n.byteOffset,n.byteLength>>1)}async function Ae(e,t){const n=t.look??"None",r=t.toneMapping==="filmic",o=t.toneMapping==="none";if(!o&&t.toneMapping!=="agx"&&!r)throw new Error("Blender's Khronos PBR Neutral view transform has no scene-linear implementation in the browser, so it cannot resolve a composited or scene-referred frame (implemented: Standard, AgX, Filmic)");const a=o?null:r?"filmic-srgb.lut":n==="None"?"agx-base-srgb.lut":pt[n];if(a===void 0)throw new Error(`Blender display transform has no table for look ${n}`);const l=a?await Ct(a):null,i=t.linearInput,p=i?{pixels:St(i.base64),width:i.width,height:i.height}:e;if(!p)throw new Error("Blender display transform requires a linear capture");const{pixels:w,width:s,height:d}=p,k=o?Mt(w,s*d,t.exposure):r?gt(l,w,s*d,t.exposure):ft(l,w,s*d,{exposure:t.exposure,composedLook:n!=="None"}),g=document.createElement("canvas");g.width=s,g.height=d;const c=g.getContext("2d");if(!c)throw new Error("Blender display transform could not create its image canvas");const b=c.createImageData(s,d),h=s*4;for(let f=0;f<d;f++){const u=(d-1-f)*h;b.data.set(k.subarray(u,u+h),f*h)}c.putImageData(b,0,0);const M=g.toDataURL("image/png"),m={base64:M.slice(M.indexOf(",")+1),mimeType:"image/png"};if(t.linear===!0){const f=new Uint8Array(w.buffer,w.byteOffset,w.byteLength);let u="";for(let y=0;y<f.length;y+=32768)u+=String.fromCharCode(...f.subarray(y,y+32768));m.linearBase64=btoa(u),m.linearWidth=s,m.linearHeight=d}return m}const At="document:blender:runtime";let Z=null;function _t(e){Z=e}function I(){return Z?.documentId??At}function zt(){return I()}async function Gt(e,t,n){_t({documentId:e,entryId:n,blend:t});const r=N();if(!r.session.open())return;const o=r.projectLocalState.projectRootPath();o!==null&&(await v().start(o,t),await v().present())}function B(){return _?.project!=null}let Ne=0;const ue=new Set;function qt(){return Ne}function Ht(e){return ue.add(e),()=>{ue.delete(e)}}function fe(){Ne+=1;for(const e of[...ue])e()}async function Xt(e,t){return B()?v().rna(e,t):null}async function Zt(e,t){return B()?v().rnaContext(e,t):null}async function Bt(e,t,n,r){if(!B())return null;const o=await v().rnaSet(e,t,n,r);return fe(),o}async function jt(e){const t=await v().execute(e);fe();const n=/^Error executing code:/.exec(t);return{text:t,executed:n===null,result:n===null?t.replace(/^Code executed successfully: ?/,""):"",error:n===null?null:t.replace(/^Error executing code: ?/,"")}}async function Kt(e){return B()?v().outliner(e):null}async function Yt(e){return B()?v().nodeTree(e):null}async function Jt(e){return B()?v().uvLayout(e):null}async function Qt(e){return B()?v().rig(e):null}async function en(e){return B()?v().actionClip(e):null}async function Tt(e,t,n){if(!B())return null;const r=await v().outlinerSet(e,t,n);return fe(),r}const Lt={view:"blender-node-view",title:"Node Editor",verbs:[["state",void 0],["look",void 0],["view-all","Node Editor: Frame All"],["zoom",void 0],["pan",void 0],["move",void 0],["link",void 0],["set-value",void 0],["use-nodes",void 0],["collapse-panel",void 0]].map(([e,t])=>({id:e,...t?{title:t}:{},run:n=>$e({...n,action:e})}))};function $e(e){const t=typeof e.action=="string"?e.action:"state";switch(t){case"state":break;case"look":U({looked:typeof e.node=="string"?e.node:null,refusal:null});break;case"view-all":Et(),U({refusal:null});break;case"zoom":{const n=typeof e.zoom=="number"?e.zoom:1;U({transform:{...ae().transform,zoom:n},refusal:null});break}case"pan":{const n=ae().transform;U({transform:{...n,cx:typeof e.cx=="number"?e.cx:n.cx,cy:typeof e.cy=="number"?e.cy:n.cy},refusal:null});break}case"move":F(`Moving "${String(e.node??"a node")}" writes Node.location — editing parity is not the program.`);break;case"link":F("Dragging between sockets would make a link — editing parity is not the program.");break;case"set-value":F(`Changing "${String(e.socket??"a socket")}" writes the socket's default_value — editing parity is not the program.`);break;case"use-nodes":F("Use Nodes writes Material.use_nodes — editing parity is not the program.");break;case"collapse-panel":F(`Collapsing "${String(e.panel??"a panel")}" writes the panel's is_collapsed — editing parity is not the program.`);break;default:F(`blender-node-view: no action "${t}" — state, look, view-all, zoom, pan, and the refusals move, link, set-value, use-nodes, collapse-panel.`)}return ae()}let _=null,de=null,_e=!1;function Ue(){de?.abort(),de=null,_?.terminate(),_=null}function It(){_e||(_e=!0,N().session.onEnded(Ue))}const Rt=e=>typeof e=="object"&&e!==null&&typeof e.applyFrame=="function"&&typeof e.snapshot=="function"&&typeof e.captureSnapshot=="function"&&typeof e.recordPresentation=="function"&&typeof e.recordPhotograph=="function";async function Ft(){const{documents:e}=N(),t=await e.waitForContext(I(),15e3);if(Rt(t))return t;throw new Error('The Blender Model document is not open, or the open one is not a Model this engine can present to (it must answer applyFrame, captureSnapshot, recordPresentation and recordPhotograph): present {kind: "document", id: "blender:runtime"} first (it ships with the editor; `vgai blender-mcp` presents it before its first call).')}function v(){if(_!==null)return _;It();const e=new AbortController;de=e;let t=!1;_=new tt({present:async(r,o,a)=>{const l=I(),i=await Ft();if(e.signal.throwIfAborted(),I()!==l)throw new Error("Blender document changed before its frame could be presented");const p=i.applyFrame(r),w=typeof p=="object"&&p!==null&&"held"in p,s=w?p.held:null,d=f=>({...f===void 0?{}:{capture:f},...w?{held:s}:{}});if(i.recordPresentation(o),!a||!a.render)return d(void 0);const k=i.snapshot(),g=()=>{if(e.signal.throwIfAborted(),I()!==l||i.snapshot()!==k)throw new Error("Blender capture document or source revision changed before completion")};if(a.render.linearInput){const f=await Ae(null,a.render);return g(),d(f)}const{render:c,position:b,target:h,up:M}=a;if(!b||!h||!M)throw new Error("A Blender render capture must carry the scene camera position, target and up");if(t)throw new Error("A Blender render capture is already in progress");const m=i.captureSnapshot();t=!0,e.signal.addEventListener("abort",m.dispose,{once:!0});try{g();const f=new Xe;f.add(m.root),f.updateMatrixWorld(!0);const u=m.root.matrixWorld,y=new Ze().copy(u).invert(),$=new xe().setFromMatrix4(u),E=new xe().setFromMatrix4(y),L=new Q(b[0],b[1],b[2]).applyMatrix4(u),we=new Q(h[0],h[1],h[2]).applyMatrix4(u),ge=new Q(M[0],M[1],M[2]).applyMatrix3($),K=Math.min(2048,Math.round(c.width))/Math.min(2048,Math.round(c.height)),me=Ve(m.root).getBoundingSphere(new Ke),D=et(L.distanceTo(me.center),me.radius);let C;if(c.orthographic){const P=c.fov/2;C=new Ye(-P*K,P*K,P,-P,D.near,D.far)}else C=new Je(c.fov,K,D.near,D.far);C.up.copy(ge),C.position.copy(L),C.lookAt(we),C.updateMatrixWorld(!0);const Y={position:L.clone().applyMatrix4(y).toArray(),target:we.clone().applyMatrix4(y).toArray(),up:ge.clone().applyMatrix3(E).toArray()};i.recordPhotograph({sent:{position:b,target:h,up:M},photographed:Y,render:{width:c.width,height:c.height,fov:c.fov,orthographic:c.orthographic}});const Oe={none:se,agx:ve,neutral:Qe,filmic:se};await m.prepare(C),g();const be={width:c.width,height:c.height,transparent:c.transparent===!0,toneMapping:Oe[c.toneMapping]??ve,exposure:c.exposure},ye=c.toneMapping==="agx"||c.toneMapping==="filmic"||c.linear===!0?await Ae(xt(f,C,be),c):null;if(g(),ye)return d({...ye,camera:Y});const J=vt(f,C,be);if(!J)throw new Error("Blender render could not capture its image");return d({base64:J.slice(J.indexOf(",")+1),mimeType:"image/png",camera:Y})}finally{t=!1,e.signal.removeEventListener("abort",m.dispose),m.dispose()}},log:(r,o)=>(r==="error"?console.error:console.log)(`[blender] ${o}`)});const n=_;return N().session.reportWorkerCallMeter(()=>n.metrics()),_}const Nt="models/model.blend",x=(e,t)=>{const n=e[t];if(typeof n!="string")throw new Error(`${String(e.type)} requires a string "${t}"`);return n};async function $t(e){const t=N().projectLocalState.projectRootPath();if(t===null)return{};let n;try{n=await e.execute(`import bpy
2
- print(bpy.data.filepath)
3
- `)}catch{return{}}if(/^Error executing code:/m.test(n))return{};const r=n.replace(/^Code executed successfully:/,"").split(`
4
- `).map(a=>a.trim()).filter(a=>a.startsWith("/")).pop()??"";if(r==="")return{};const o=t.endsWith("/")?t:`${t}/`;return r.startsWith(o)?{document:r.slice(o.length)}:{}}async function tn(e){const t=N();if(e.type==="blender-status")return{ok:!0,data:{started:_?.project!=null,document:t.documents.context(I())!==void 0}};if(!t.session.open())return{ok:!1,error:`${e.type} needs an open project session; this editor page has none.`};try{const n=e.type==="blender-start"?x(e,"project"):null;if((e.type==="blender-stop"||e.type==="blender-start"&&e.fresh===!0)&&(Ue(),e.type==="blender-stop"))return{ok:!0,data:{stopped:!0}};if(e.type==="blender-start"&&!t.documents.context(I())&&!await t.workspace.open({kind:"document",id:"blender:runtime"}))return{ok:!1,error:"blender-start could not open the Blender Model document: nothing in this editor opens {kind: 'document', id: 'blender:runtime'} (it ships with @volter/editor-blender)."};const r=v();switch(e.type){case"blender-start":{const o=typeof e.document=="string"?e.document:Z?.blend??Nt;return{ok:!0,data:{...await r.start(n,o)}}}case"blender-execute":return{ok:!0,data:{result:(await jt(x(e,"code"))).text}};case"blender-scene-info":return{ok:!0,data:{result:await r.sceneInfo()}};case"blender-object-info":return{ok:!0,data:{result:await r.objectInfo(x(e,"name"))}};case"blender-rna":{const o=typeof e.names=="number"?e.names:void 0;return{ok:!0,data:{result:await r.rna(x(e,"path"),o)}}}case"blender-rna-context":{const o=typeof e.object=="string"?e.object:void 0,a=typeof e.collection=="string"?e.collection:void 0;return{ok:!0,data:{result:await r.rnaContext(o,a)}}}case"blender-rna-set":{const o=typeof e.index=="number"?e.index:void 0;return{ok:!0,data:{result:await Bt(x(e,"path"),x(e,"property"),e.value,o)}}}case"blender-outliner":{const o=Array.isArray(e.selected)?e.selected.filter(a=>typeof a=="string"):void 0;return{ok:!0,data:{result:await r.outliner(o)}}}case"blender-node-tree":return{ok:!0,data:{result:await r.nodeTree({...typeof e.path=="string"?{path:e.path}:{},...typeof e.material=="string"?{material:e.material}:{}})}};case"blender-uv-layout":return{ok:!0,data:{result:await r.uvLayout({...typeof e.object=="string"?{object:e.object}:{},...typeof e.uvLayer=="string"?{uvLayer:e.uvLayer}:{}})}};case"blender-rig":return{ok:!0,data:{result:await r.rig({...typeof e.object=="string"?{object:e.object}:{}})}};case"blender-action-clip":return{ok:!0,data:{result:await r.actionClip({...typeof e.object=="string"?{object:e.object}:{},...typeof e.bake=="boolean"?{bake:e.bake}:{}})}};case"blender-node-view":{const o=typeof e.action=="string"?e.action:"state";return{ok:!0,data:{result:Lt.verbs.some(l=>l.id===o)?We("blender-node-view",o,e):$e(e)}}}case"blender-outliner-set":return{ok:!0,data:{result:await Tt(x(e,"path"),x(e,"column"),e.value!==!1)}};case"blender-screenshot-view":{const o=typeof e.maxSize=="number"?e.maxSize:1e3,a={kind:"document",id:Z?.entryId??"blender:runtime"};return{ok:!0,data:{...await r.screenshotView(o),document:a}}}case"blender-read-file":{const o=await r.readFile(x(e,"path")),a=x(e,"transferId"),l=await fetch(`/__editor/blender-file?id=${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/octet-stream"},body:new Blob([o])});return l.ok?{ok:!0,data:{bytes:o.length}}:{ok:!1,error:`Transfer ${a} was refused: ${l.status}`}}case"blender-write-file":{const o=atob(x(e,"base64")),a=Uint8Array.from(o,l=>l.charCodeAt(0));return await r.writeFile(x(e,"path"),a),{ok:!0,data:{written:a.length}}}case"blender-list-files":{const o=await r.listFiles(x(e,"path")),a=r.presented;return{ok:!0,data:{entries:o,...a?{session:a.session,revision:a.revision}:{},...await $t(r)}}}}return{ok:!1,error:`Unknown Blender command ${e.type}`}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}export{Lt as N,zt as a,B as b,Tt as c,Kt as d,qt as e,Vt as f,U as g,tn as h,ae as i,Yt as j,Wt as k,en as l,Qt as m,Pt as n,Jt as o,Bt as p,jt as q,F as r,Ht as s,Gt as t,_t as u,fe as v,Zt as w,Xt as x};
@@ -1,7 +0,0 @@
1
- import{a as u}from"./jsx-runtime-DPjLkJKQ.js";import{c as ce,a as de}from"./blender-runtime-skin-DcwXD-m8.js";import{e as V,ai as ue,aj as S,ak as R,al as H,am as be,an as pe}from"./index-5av5LJja.js";import{r as w}from"./index-DaQZGF7d.js";import{p as te,q as oe,t as fe,u as re}from"./blender-runtime-host-D8NHsAfD.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{o as me,s as B,r as $,b as ge,a as X,c as K,w as le,d as he,e as P}from"./blender-outliner-model-B8b00oxr.js";import{bf as ye}from"./three.module-BynznMJN.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./LineSegments2-vfeDUBfs.js";import"./client-DNXj_opT.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./clip-planes-CnAI6DZn.js";function je(l){return`blender-${l.toLowerCase().replace(/_/g,"-")}`}function x(l){return l?.type==="TSE_SOME_ID"&&l.struct==="Object"&&l.object!==void 0}function ne(l){if(l.struct)return l.struct}function ae(l,o){return{id:l.id,label:l.name,role:"entity",kind:je(l.icon),...ne(l)?{typeLabel:ne(l)}:{},parentId:o,childIds:l.children.map(n=>n.id),defaultExpanded:l.expanded}}const _e={transform:!0,inspectorFields:!1,persist:!0},I=new Set;function ve(l){for(const o of I)if(o.documentId===l)return o;return I.size===1?[...I][0]:null}const ke=()=>({position:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]});function we(l,o){l.updateWorldMatrix(!0,!1);const n=o.matrixWorld.clone().invert().multiply(l.matrixWorld).elements;return[[n[0],n[1],n[2],n[3]],[n[4],n[5],n[6],n[7]],[n[8],n[9],n[10],n[11]],[n[12],n[13],n[14],n[15]]]}function T(l,o){return`${l} needs a file, and this editor has no door to ask for one: the host's file door (\`EditorHost.files\`, \`@volter/editor-sdk/host\`) reads and writes project-relative paths and has no file-picker member, so there is nothing to open the workbench's own dialog through. Blender's row opens a file browser; run without one, the engine answers "${o}".`}const Oe=[{kind:"mesh.plane",label:"Plane",group:"Mesh",call:"mesh.primitive_plane_add"},{kind:"mesh.cube",label:"Cube",group:"Mesh",call:"mesh.primitive_cube_add"},{kind:"mesh.circle",label:"Circle",group:"Mesh",call:"mesh.primitive_circle_add"},{kind:"mesh.uv-sphere",label:"UV Sphere",group:"Mesh",call:"mesh.primitive_uv_sphere_add"},{kind:"mesh.ico-sphere",label:"Ico Sphere",group:"Mesh",call:"mesh.primitive_ico_sphere_add"},{kind:"mesh.cylinder",label:"Cylinder",group:"Mesh",call:"mesh.primitive_cylinder_add"},{kind:"mesh.cone",label:"Cone",group:"Mesh",call:"mesh.primitive_cone_add"},{kind:"mesh.torus",label:"Torus",group:"Mesh",call:"mesh.primitive_torus_add"},{kind:"mesh.grid",label:"Grid",group:"Mesh",call:"mesh.primitive_grid_add",separatorBefore:!0},{kind:"mesh.monkey",label:"Monkey",group:"Mesh",call:"mesh.primitive_monkey_add"},{kind:"curve.bezier",label:"Bézier",group:"Curve",call:"curve.primitive_bezier_curve_add"},{kind:"curve.bezier-circle",label:"Circle",group:"Curve",call:"curve.primitive_bezier_circle_add"},{kind:"curve.nurbs-curve",label:"Nurbs Curve",group:"Curve",call:"curve.primitive_nurbs_curve_add",separatorBefore:!0},{kind:"curve.nurbs-circle",label:"Nurbs Circle",group:"Curve",call:"curve.primitive_nurbs_circle_add"},{kind:"curve.path",label:"Path",group:"Curve",call:"curve.primitive_nurbs_path_add"},{kind:"curve.empty-hair",label:"Empty Hair",group:"Curve",call:"object.curves_empty_hair_add",separatorBefore:!0},{kind:"curve.fur",label:"Fur",group:"Curve",call:"object.quick_fur",placesAtOrigin:!1},{kind:"surface.nurbs-curve",label:"Nurbs Curve",group:"Surface",call:"surface.primitive_nurbs_surface_curve_add"},{kind:"surface.nurbs-circle",label:"Nurbs Circle",group:"Surface",call:"surface.primitive_nurbs_surface_circle_add"},{kind:"surface.nurbs-surface",label:"Nurbs Surface",group:"Surface",call:"surface.primitive_nurbs_surface_surface_add"},{kind:"surface.nurbs-cylinder",label:"Nurbs Cylinder",group:"Surface",call:"surface.primitive_nurbs_surface_cylinder_add"},{kind:"surface.nurbs-sphere",label:"Nurbs Sphere",group:"Surface",call:"surface.primitive_nurbs_surface_sphere_add"},{kind:"surface.nurbs-torus",label:"Nurbs Torus",group:"Surface",call:"surface.primitive_nurbs_surface_torus_add"},{kind:"metaball.ball",label:"Ball",group:"Metaball",call:"object.metaball_add, type='BALL'"},{kind:"metaball.capsule",label:"Capsule",group:"Metaball",call:"object.metaball_add, type='CAPSULE'"},{kind:"metaball.plane",label:"Plane",group:"Metaball",call:"object.metaball_add, type='PLANE'"},{kind:"metaball.ellipsoid",label:"Ellipsoid",group:"Metaball",call:"object.metaball_add, type='ELLIPSOID'"},{kind:"metaball.cube",label:"Cube",group:"Metaball",call:"object.metaball_add, type='CUBE'"},{kind:"text",label:"Text",group:null,call:"object.text_add"},{kind:"point-cloud",label:"Point Cloud",group:null,call:"object.pointcloud_random_add"},{kind:"volume.import",label:"Import OpenVDB...",group:"Volume",call:"object.volume_import",refusal:`${T("Importing an OpenVDB volume","CANCELLED, with nothing created")} This build also has no OpenVDB at all (\`bpy.app.build_options.openvdb\` is False), so a file would not be read even with a picker.`},{kind:"volume.empty",label:"Empty",group:"Volume",call:"object.volume_add"},{kind:"grease-pencil.blank",label:"Blank",group:"Grease Pencil",call:"object.grease_pencil_add, type='EMPTY'"},{kind:"grease-pencil.stroke",label:"Stroke",group:"Grease Pencil",call:"object.grease_pencil_add, type='STROKE'"},{kind:"grease-pencil.monkey",label:"Monkey",group:"Grease Pencil",call:"object.grease_pencil_add, type='MONKEY'"},{kind:"grease-pencil.lineart-scene",label:"Scene Line Art",group:"Grease Pencil",call:"object.grease_pencil_add, type='LINEART_SCENE'",separatorBefore:!0},{kind:"grease-pencil.lineart-collection",label:"Collection Line Art",group:"Grease Pencil",call:"object.grease_pencil_add, type='LINEART_COLLECTION'"},{kind:"grease-pencil.lineart-object",label:"Object Line Art",group:"Grease Pencil",call:"object.grease_pencil_add, type='LINEART_OBJECT'"},{kind:"armature",label:"Armature",group:null,call:"object.armature_add"},{kind:"lattice.lattice",label:"Lattice",group:"Lattice",call:"object.add, type='LATTICE'"},{kind:"lattice.deform-selected",label:"Lattice Deform Selected",group:"Lattice",call:"object.lattice_add_to_selected"},{kind:"empty.plain-axes",label:"Plain Axes",group:"Empty",call:"object.empty_add, type='PLAIN_AXES'"},{kind:"empty.arrows",label:"Arrows",group:"Empty",call:"object.empty_add, type='ARROWS'"},{kind:"empty.single-arrow",label:"Single Arrow",group:"Empty",call:"object.empty_add, type='SINGLE_ARROW'"},{kind:"empty.circle",label:"Circle",group:"Empty",call:"object.empty_add, type='CIRCLE'"},{kind:"empty.cube",label:"Cube",group:"Empty",call:"object.empty_add, type='CUBE'"},{kind:"empty.sphere",label:"Sphere",group:"Empty",call:"object.empty_add, type='SPHERE'"},{kind:"empty.cone",label:"Cone",group:"Empty",call:"object.empty_add, type='CONE'"},{kind:"image.reference",label:"Reference...",group:"Image",call:"object.empty_image_add, background=False",refusal:T("A reference image","poll() failed, context is incorrect / Please select at least one image")},{kind:"image.background",label:"Background...",group:"Image",call:"object.empty_image_add, background=True",refusal:T("A background image","poll() failed, context is incorrect / Please select at least one image")},{kind:"image.mesh-plane",label:"Mesh Plane...",group:"Image",call:"image.import_as_mesh_planes",placesAtOrigin:!1,refusal:T("An image as a mesh plane","CANCELLED, with nothing created")},{kind:"image.empty-image",label:"Empty Image",group:"Image",call:"object.empty_add, type='IMAGE'"},{kind:"light.point",label:"Point",group:"Light",call:"object.light_add, type='POINT'"},{kind:"light.sun",label:"Sun",group:"Light",call:"object.light_add, type='SUN'"},{kind:"light.spot",label:"Spot",group:"Light",call:"object.light_add, type='SPOT'"},{kind:"light.area",label:"Area",group:"Light",call:"object.light_add, type='AREA'"},{kind:"light-probe.sphere",label:"Sphere",group:"Light Probe",call:"object.lightprobe_add, type='SPHERE'"},{kind:"light-probe.plane",label:"Plane",group:"Light Probe",call:"object.lightprobe_add, type='PLANE'"},{kind:"light-probe.volume",label:"Volume",group:"Light Probe",call:"object.lightprobe_add, type='VOLUME'"},{kind:"camera",label:"Camera",group:null,call:"object.camera_add"},{kind:"speaker",label:"Speaker",group:null,call:"object.speaker_add"},{kind:"force-field.force",label:"Force",group:"Force Field",call:"object.effector_add, type='FORCE'"},{kind:"force-field.wind",label:"Wind",group:"Force Field",call:"object.effector_add, type='WIND'"},{kind:"force-field.vortex",label:"Vortex",group:"Force Field",call:"object.effector_add, type='VORTEX'"},{kind:"force-field.magnetic",label:"Magnetic",group:"Force Field",call:"object.effector_add, type='MAGNET'"},{kind:"force-field.harmonic",label:"Harmonic",group:"Force Field",call:"object.effector_add, type='HARMONIC'"},{kind:"force-field.charge",label:"Charge",group:"Force Field",call:"object.effector_add, type='CHARGE'"},{kind:"force-field.lennard-jones",label:"Lennard-Jones",group:"Force Field",call:"object.effector_add, type='LENNARDJ'"},{kind:"force-field.texture",label:"Texture",group:"Force Field",call:"object.effector_add, type='TEXTURE'"},{kind:"force-field.curve-guide",label:"Curve Guide",group:"Force Field",call:"object.effector_add, type='GUIDE'"},{kind:"force-field.boid",label:"Boid",group:"Force Field",call:"object.effector_add, type='BOID'"},{kind:"force-field.turbulence",label:"Turbulence",group:"Force Field",call:"object.effector_add, type='TURBULENCE'"},{kind:"force-field.drag",label:"Drag",group:"Force Field",call:"object.effector_add, type='DRAG'"},{kind:"force-field.fluid-flow",label:"Fluid Flow",group:"Force Field",call:"object.effector_add, type='FLUID'"}],Ee="collection-instance:";function Se(){const l=new Map;for(const o of P().byId.values()){if(o.type!=="TSE_LAYER_COLLECTION")continue;const n=o.data;n===void 0||!n.startsWith("bpy.data.collections[")||l.has(o.name)||l.set(o.name,{kind:`${Ee}${o.name}`,label:o.name,group:"Collection Instance",call:`object.collection_instance_add, collection=${N(o.name)}`})}return[...l.values()]}function D(){return[...Oe,...Se()]}function Ce(l){const[o,...n]=l.call.split(", "),s=l.placesAtOrigin===!1?n:[...n,"location=(0, 0, 0)"];return`bpy.ops.${o}(${s.join(", ")})`}function N(l){return JSON.stringify(l)}async function G(l){const o=["before = {o.name for o in bpy.data.objects}",l,"made = [o.name for o in bpy.data.objects if o.name not in before]",'print("\\n".join(made))'].join(`
2
- `),n=await oe(o);return n.error!==null?{made:[],error:n.error}:{made:n.result.split(`
3
- `).map(h=>h.trim()).filter(h=>h.length>0),error:null}}async function xe(l,o){const n=[`_sel = {${l.map(N).join(", ")}}`,"_vl = bpy.context.view_layer","for _o in _vl.objects:"," _o.select_set(_o.name in _sel)",o===null?"_vl.objects.active = None":`_vl.objects.active = bpy.data.objects.get(${N(o)})`].join(`
4
- `),s=await oe(n);s.error!==null&&V().console.error(`Blender refused the selection write: ${s.error}`,"blender-outliner")}async function z(l,o){if(l.length===0)return{destination:"Nothing is selected, so there was nothing to run it on.",persisted:!1};const n=[`targets = [bpy.data.objects[n] for n in [${l.map(N).join(", ")}]]`,"with bpy.context.temp_override(selected_objects=targets, selected_editable_objects=targets, active_object=targets[0], object=targets[0]):",` ${o}`].join(`
5
- `),{error:s}=await G(n);return s!==null?{destination:s,persisted:!1}:(await $(l),{destination:`Blender — ${o}; the session saves the .blend`,persisted:!0})}const Ne={source:"document",label:"blender",detail:"These rows are Blender's own View Layer tree, read from the engine through RNA. Editing the model is a bpy call; the eye and render columns write the engine directly."},Fe="This collection is excluded from the view layer (LayerCollection.exclude), so its viewport visibility is not what is hiding it. Clear the Exclude checkbox on this row first.",Ae=({defaultAdapter:l})=>{const o=new Set;let n=[],s=null;const h=new Map,F=()=>{for(const t of[...o])t()},f=()=>P().byId,O=t=>{const e=f().get(t),r=K();return e===void 0||r===null?null:e.type==="TSE_VIEW_COLLECTION_BASE"?r.root:e.object===void 0?null:r.objectForBlenderName(e.object)},C=t=>{const e=K();if(e===null)return null;for(const r of f().values())if(x(r)&&e.objectForBlenderName(r.object)===t)return r.id;return null},d=t=>{for(const e of f().values())if(x(e)&&e.object===t)return e.id;return null},p=t=>{if(f().has(t))return t;const e=l.hierarchy.object3D?.(t)??null;return e===null?null:C(e)},g=t=>{const e=p(t);return e===null?null:O(e)},v=t=>{const e=g(t);return e===null?null:l.hierarchy.idForObject3D?.(e)??null},_={roots:()=>(he(y()),(P().tree?.rows??[]).map(e=>ae(e,null))),node:t=>{const e=P(),r=e.byId.has(t)?t:p(t),i=r===null?void 0:e.byId.get(r);return i===void 0?null:ae(i,e.parentOf.get(i.id)??null)},object3D:t=>g(t),idForObject3D:t=>C(t)};function y(){const t=f(),e=new Set;for(const r of n){const i=t.get(r)?.object;i!==void 0&&e.add(i)}return[...e]}const A=()=>{const t=[];for(const e of n){const r=g(e),i=r===null?null:l.hierarchy.idForObject3D?.(r);i&&t.push(i)}l.selection?.set(t,{intent:"exact"}),F()},L=()=>{const t=ge(),e=`${X()}\0${t.active??""}\0${[...t.selected].sort().join("")}`;if(e===s)return;s=e;const r=t.selected.filter(b=>b!==t.active);t.active!==null&&r.push(t.active);const i=r.map(d).filter(b=>b!==null);i.length===n.length&&i.every((b,m)=>b===n[m])||(n=i,A())},a={get:()=>[...n],set:t=>{n=t.map(p).filter(b=>b!==null),A();const e=f(),r=[],i=[];for(const b of n){const m=e.get(b),j=m?.object;j===void 0?i.push(m?.name??b):r.includes(j)||r.push(j)}i.length>0&&V().console.warn(`${i.join(", ")} ${i.length===1?"is":"are"} not an object, so Blender's object selection does not carry ${i.length===1?"it":"them"}. Selecting a collection sets the ACTIVE COLLECTION in Blender, which is its own gesture and not in this editor yet.`,"blender-outliner"),xe(r,r.length===0?null:r[r.length-1])}},c=t=>f().get(t)?.restrict,k={properties:t=>{const e=c(t);if(e===void 0)return[];const r=f().get(t),i=[{path:"name",label:"Name",type:"string",readonly:!x(r)}];return e.hide!==void 0&&i.push({path:"visible",label:"Show in Viewport",type:"boolean"}),e.render!==void 0&&i.push({path:"renderVisible",label:"Show in Renders",type:"boolean"}),e.exclude!==void 0&&i.push({path:"exclude",label:"Exclude from View Layer",type:"boolean"}),i},get:(t,e)=>{const r=f().get(t);if(r!==void 0){if(e==="name")return r.name;if(e==="visible")return r.restrict?.hide===void 0?void 0:!r.restrict.hide;if(e==="renderVisible")return r.restrict?.render===void 0?void 0:!r.restrict.render;if(e==="exclude")return r.restrict?.exclude}},editability:(t,e)=>{const r=f().get(t);return r===void 0?{writable:!1}:e==="name"?x(r)?{writable:!0}:{writable:!1,reason:`Renaming a ${r.struct??r.type} is not in this Outliner yet — only an object row renames here. Rename it with bpy.`}:r.notInCollection?{writable:!1,reason:"This row is a child drawn under its parent although it is not in that collection, and Blender's Outliner draws it no restriction columns."}:e==="visible"&&r.restrict?.exclude===!0?{writable:!1,reason:Fe}:{writable:!0}},set:async(t,e,r)=>{const i=f().get(t);if(i===void 0)return;if(e==="name"){if(!x(i))return;const m=String(r);if(m===i.name||m.length===0)return;await te(`bpy.data.objects[${N(i.object)}]`,"name",m),await $([m]);const j=d(m);j!==null&&a.set([j]);return}if(e==="exclude"){await le(i.path,"exclude",r===!0);return}const b=e==="visible"?"hide":e==="renderVisible"?"render":null;b!==null&&await le(i.path,b,r===!1)}},W={get:t=>{const e=v(t);return(e===null?void 0:l.transforms?.get(e))??ke()},editability:t=>{const e=p(t),r=e===null?void 0:f().get(e);return x(r)&&O(r.id)!==null?{writable:!0}:{writable:!1,reason:`Only an object has a transform; this row is a ${r?.struct??r?.type??"row"}.`}},beginEdit:t=>{const e=g(t);e!==null&&h.set(e,e.matrixWorld.clone())},apply:(t,e)=>{const r=g(t);r!==null&&(r.position.fromArray(e.position),r.quaternion.fromArray(e.rotation),r.scale.fromArray(e.scale),r.updateMatrix(),r.updateMatrixWorld(!0))},endEdit:async t=>{const e=g(t),r=K();if(e===null||r===null)return;const i=h.get(e);if(h.delete(e),e.updateWorldMatrix(!0,!1),i?.equals(e.matrixWorld)===!0)return;const b=r.blenderObjectName(e);if(b===null)return;const m=`bpy.data.objects[${JSON.stringify(b)}]`;try{return await te(m,"matrix_world",we(e,r.root)),{destination:`Blender — ${m}.matrix_world; the session saves the .blend`,persisted:!0}}catch(j){return{destination:j instanceof Error?j.message:String(j),persisted:!1}}}},J=t=>{const e=p(t),r=e===null?void 0:f().get(e);return x(r)?r.object:null},E=t=>({destination:t,persisted:!1}),q=async t=>{await $(t);const e=t.map(d).filter(r=>r!==null);return e.length>0&&a.set(e),e[0]??""},U={creatableKinds:()=>D().map(({kind:t,label:e})=>({kind:t,label:e})),create:t=>{const e=D().find(i=>i.kind===t);if(e===void 0)return{id:"",ack:E(`${t} is not a row of Blender's Add menu that this editor adds. Its rows are: ${D().map(i=>i.label).join(", ")}.`)};if(e.refusal!==void 0)return{id:"",ack:E(e.refusal)};const r=Ce(e);return{id:"",ack:(async()=>{const{made:i,error:b}=await G(r);return b!==null?E(b):i.length===0?E(`Blender ran ${r} and created nothing. The operator reported no error, so it cancelled — most often because it wanted a file browser or a context this headless engine has no window for.`):(await q(i),{destination:`Blender — ${r}; the session saves the .blend`,persisted:!0})})()}},remove:t=>U.removeMany?.([t])??void 0,removeMany:async t=>{const e=[];for(const m of t){const j=J(m);if(j===null){const ee=p(m)===null?void 0:f().get(p(m));return E(`Only an object can be deleted here; this row is a ${ee?.struct??ee?.type??"row"}. Deleting a collection, a modifier or a vertex group is that datablock’s own bpy call.`)}e.push(j)}if(e.length===0)return E("Nothing selected to delete.");const i=[`targets = ${`[bpy.data.objects[n] for n in [${e.map(N).join(", ")}]]`}`,"with bpy.context.temp_override(selected_objects=targets, active_object=targets[0]):"," bpy.ops.object.delete(use_global=False)"].join(`
6
- `),{error:b}=await G(i);return b!==null?E(b):(a.set([]),await $([]),{destination:"Blender — bpy.ops.object.delete(use_global=False); the session saves the .blend",persisted:!0})},duplicate:t=>{const e=J(t);if(e===null)return{id:t,ack:E("Only an object can be duplicated here. Duplicating a collection is `bpy.ops.object.collection_instance_add`, its own gesture.")};const r=[`source = bpy.data.objects[${N(e)}]`,"with bpy.context.temp_override(selected_objects=[source], active_object=source):"," bpy.ops.object.duplicate(linked=False)"].join(`
7
- `);return{id:t,ack:(async()=>{const{made:i,error:b}=await G(r);return b!==null?E(b):(await q(i),{destination:`Blender — bpy.ops.object.duplicate(linked=False) on ${e}; the session saves the .blend`,persisted:!0})})()}},reparent:()=>E("Reparenting is Blender's `bpy.ops.object.parent_set`, which needs a parent TYPE (Object, Object Keep Transform, Armature Deform, …) that a drag does not say. Set the parent on the object’s Relations panel, or with bpy.")},Q={get documentId(){return l.documentId},get documentRootObject(){return l.documentRootObject},capabilities:_e,provenance:Ne,hierarchy:_,selection:a,inspector:k,transforms:W,structure:U,subscribe:t=>{o.add(t);const e=B(t),r=l.subscribe?.(t)??(()=>{});return()=>{o.delete(t),e(),r()}}},Z={get documentId(){return Q.documentId},selectedObjectNames:()=>y(),allObjectNames:()=>{const t=[];for(const e of f().values())x(e)&&t.push(e.object);return t},selectObjects:t=>{const e=t.map(d).filter(r=>r!==null);a.set(e)},rowIdForObject:t=>d(t),structure:U,subscribe:t=>{o.add(t);const e=B(t);return()=>{o.delete(t),e()}}};I.add(Z);const ie=me(L),se=B(L);return L(),{adapter:Q,dispose:()=>{ie(),se(),I.delete(Z),o.clear()}}},Le=[{label:"Location",call:"location=True, rotation=False, scale=False"},{label:"Rotation",call:"location=False, rotation=True, scale=False"},{label:"Scale",call:"location=False, rotation=False, scale=True"},{label:"All Transforms",call:"location=True, rotation=True, scale=True"}],Ie=[{label:"Location",call:"bpy.ops.object.location_clear(clear_delta=False)"},{label:"Rotation",call:"bpy.ops.object.rotation_clear(clear_delta=False)"},{label:"Scale",call:"bpy.ops.object.scale_clear(clear_delta=False)"}],Re=[{label:"Geometry to Origin",type:"GEOMETRY_ORIGIN"},{label:"Origin to Geometry",type:"ORIGIN_GEOMETRY"},{label:"Origin to 3D Cursor",type:"ORIGIN_CURSOR",refusal:"There is no 3D cursor in this editor yet, so there is no point to move the origin to. Blender places it with Shift+Right-click; that gesture is not built here."}],Te=[{submenu:"Mesh",at:"2699"},{submenu:"Curve",at:"2702"},{submenu:"Surface",at:"2704"},{submenu:"Metaball",at:"2705"},{kind:"text",at:"2706"},{kind:"point-cloud",at:"2707"},{submenu:"Volume",at:"2708"},{submenu:"Grease Pencil",at:"2709"},{separatorAt:"2711"},{kind:"armature",at:"2716"},{submenu:"Lattice",at:"2718"},{separatorAt:"2720"},{submenu:"Empty",at:"2722"},{submenu:"Image",at:"2723"},{separatorAt:"2725"},{submenu:"Light",at:"2727"},{submenu:"Light Probe",at:"2728"},{separatorAt:"2730"},{kind:"camera",at:"2735"},{separatorAt:"2737"},{kind:"speaker",at:"2739"},{separatorAt:"2741"},{submenu:"Force Field",at:"2743"},{separatorAt:"2745"},{submenu:"Collection Instance",at:"2759"}],Me="No Collections to Instance";function Y({id:l,open:o,setOpen:n,anchorRef:s,children:h}){return u.jsxs("div",{ref:s,style:{position:"relative"},children:[u.jsx(be,{"data-testid":`blender-menu-${l}`,"aria-expanded":o===l,onClick:()=>n(o===l?null:l),onPointerEnter:()=>{o&&n(l)},style:{textTransform:"capitalize"},children:l}),o===l&&u.jsx(pe,{anchorRef:s,dismissBoundaryRef:s,align:"start",gap:0,clamp:!0,"aria-label":l,onDismiss:()=>n(null),children:h})]})}function Be(l,o,n){(async()=>{const s=await n;s===void 0||typeof s.destination!="string"||s.persisted!==!0&&l?.({tone:"error",title:`${o} was refused`,detail:s.destination})})()}function $e({documentId:l,notify:o}){w.useSyncExternalStore(B,X,X);const[n,s]=w.useState(null),h=w.useRef(null),F=w.useRef(null),f=w.useRef(null),O=w.useRef(null),C=ve(l);if(C===null)return null;const d=(a,c)=>()=>{s(null),Be(o,a,c(C))},p=C.selectedObjectNames(),g=C.allObjectNames(),v=p.length===0?"Nothing is selected.":void 0,_=D(),y=a=>u.jsx(S,{"data-testid":`blender-add-${a.kind}`,disabled:a.refusal!==void 0,title:a.refusal,onSelect:d(`Add ${a.label}`,c=>c.structure.create(a.kind).ack),children:a.label},a.kind),A=a=>_.filter(c=>c.group===a).flatMap(c=>c.separatorBefore===!0?[u.jsx(H,{},`${c.kind}-separator`),y(c)]:[y(c)]),L=a=>{if("separatorAt"in a)return u.jsx(H,{},`separator-${a.separatorAt}`);if("kind"in a){const k=_.find(W=>W.kind===a.kind);return k===void 0?null:y(k)}const c=A(a.submenu);return c.length===0?u.jsx(S,{"data-testid":"blender-add-collection-instance",disabled:!0,children:Me},a.submenu):u.jsx(R,{label:a.submenu,"data-testid":`blender-add-${a.submenu.toLowerCase().replaceAll(" ","-")}`,children:c},a.submenu)};return u.jsxs(ue,{compact:!0,label:"Blender Object Mode menus","data-testid":"blender-object-mode-menus",ref:h,children:[u.jsxs(Y,{id:"select",open:n,setOpen:s,anchorRef:F,children:[u.jsx(S,{"data-testid":"blender-select-all",onSelect:d("Select All",a=>a.selectObjects(g)),children:"All"}),u.jsx(S,{"data-testid":"blender-select-none",onSelect:d("Select None",a=>a.selectObjects([])),children:"None"}),u.jsx(S,{"data-testid":"blender-select-invert",onSelect:d("Select Invert",a=>a.selectObjects(g.filter(c=>!p.includes(c)))),children:"Invert"})]}),u.jsx(Y,{id:"add",open:n,setOpen:s,anchorRef:f,children:Te.map(a=>L(a))}),u.jsxs(Y,{id:"object",open:n,setOpen:s,anchorRef:O,children:[u.jsx(R,{label:"Set Origin","data-testid":"blender-object-origin",children:Re.map(a=>u.jsx(S,{"data-testid":`blender-origin-${a.type}`,disabled:a.refusal!==void 0||p.length===0,title:a.refusal??v,onSelect:d(`Set Origin ▸ ${a.label}`,c=>z(c.selectedObjectNames(),`bpy.ops.object.origin_set(type='${a.type}')`)),children:a.label},a.type))}),u.jsx(R,{label:"Clear","data-testid":"blender-object-clear",children:Ie.map(a=>u.jsx(S,{"data-testid":`blender-clear-${a.label.toLowerCase()}`,disabled:p.length===0,title:v,onSelect:d(`Clear ▸ ${a.label}`,c=>z(c.selectedObjectNames(),a.call)),children:a.label},a.label))}),u.jsx(R,{label:"Apply","data-testid":"blender-object-apply",children:Le.map(a=>u.jsx(S,{"data-testid":`blender-apply-${a.label.toLowerCase().replace(/ /g,"-")}`,disabled:p.length===0,title:v,onSelect:d(`Apply ▸ ${a.label}`,c=>z(c.selectedObjectNames(),`bpy.ops.object.transform_apply(${a.call})`)),children:a.label},a.label))}),u.jsx(H,{}),u.jsx(S,{"data-testid":"blender-object-duplicate",disabled:p.length===0,title:v,onSelect:d("Duplicate Objects",async a=>{for(const c of[...a.selectedObjectNames()]){const k=a.rowIdForObject(c);k!==null&&await a.structure.duplicate(k).ack}}),children:"Duplicate Objects"}),u.jsx(S,{"data-testid":"blender-object-delete",disabled:p.length===0,title:v,onSelect:d("Delete",a=>{const c=a.selectedObjectNames().map(k=>a.rowIdForObject(k)).filter(k=>k!==null);return a.structure.removeMany?.(c)}),children:"Delete"})]})]})}const et="workspace.document",tt="Blender Model",rt=({documentId:l,notify:o})=>u.jsx($e,{documentId:l,notify:o}),lt="model",nt="owned",at=[],M=ce;function ot({active:l,document:o,documentId:n,surfaces:s,notify:h,publishContext:F}){const f=w.useCallback(()=>({root:M.root,dispose(){}}),[]),O=o?.source?.path;if(w.useEffect(()=>F?.(M),[F]),w.useEffect(()=>{if(!n)return;const{viewport:d}=V(),p=M.overlayGroups(),g=()=>{const _=d.stages().find(y=>y.documentId===n);if(_)for(const{kind:y,object:A}of p)_.setHelper(y,A)};g();const v=d.onStages(g);return()=>{v();const _=d.stages().find(y=>y.documentId===n);for(const{kind:y}of p)_?.setHelper(y,null)}},[n]),w.useEffect(()=>{if(!n)return;const{transport:d}=V();let p=null;const g=()=>{if(p)return;const _=d.for(n);_&&(p=de.attachTo(_))};g();const v=d.subscribe(g);return()=>{v(),p?.()}},[n]),w.useEffect(()=>{if(n){if(O===void 0){re(null);return}return fe(n,O,o.id).catch(d=>{h?.({tone:"error",title:`Blender could not open ${O}`,detail:d instanceof Error?d.message:String(d)})}),()=>re(null)}},[O,o?.id,n,h]),!n)return null;const C=s.Object3DAuthoring;return u.jsx(C,{active:l??!0,documentId:n,sourcePath:O??"blender:runtime",displayName:o?.label??"Model",build:f,audit:!1,authoring:Ae,cameraDirection:[.8187,.4458,.3617],openingFit:3,dressing:{environment:!1,keyLight:!1,toneMapping:ye,viewLocked:M.studioLights()}})}export{rt as Toolbar,ot as default,lt as documentKind,at as inspectorBuiltins,nt as inspectorRail,et as point,tt as title};
@@ -1 +0,0 @@
1
- import{h as l}from"./blender-runtime-host-D8NHsAfD.js";import"./index-5av5LJja.js";import"./index-DaQZGF7d.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";import"./clip-planes-CnAI6DZn.js";const v="workspace.command",e=(o,n)=>({...n===void 0?{}:{timeoutMs:n},derivedRefresh:o,handle:r=>l(r)}),y={"blender-start":e("none",12e4),"blender-stop":e("none"),"blender-execute":e("always",30*6e4),"blender-scene-info":e("none",6e4),"blender-object-info":e("none",6e4),"blender-screenshot-view":e("always",6e4),"blender-read-file":e("none",6e4),"blender-write-file":e("none",6e4),"blender-list-files":e("none"),"blender-rna":e("none",6e4),"blender-rna-context":e("none",6e4),"blender-rna-set":e("always",6e4),"blender-outliner":e("none",6e4),"blender-node-tree":e("none",6e4),"blender-uv-layout":e("none",6e4),"blender-rig":e("none",6e4),"blender-action-clip":e("none",12e4),"blender-node-view":e("none"),"blender-outliner-set":e("always",6e4),"blender-status":e("none")};export{y as commands,v as point};
@@ -1 +0,0 @@
1
- const d="/work/.vgai-session",re=`${d}/session.py`,oe=[`${d}/in`,`${d}/reply`],x="/__editor/blender-wasm";function L(e){return new URL(`${x}/${e}`,import.meta.url).href}async function P(){const e=await fetch(L("status"));return e.ok?await e.json():{available:!1,skew:null,dir:null,sizes:{},encoded:{},missing:[`${x}/status answered ${e.status}`]}}async function M(e){const t=await P();if(!t.available)throw new Error(`The headless Blender WebAssembly build is not served by this editor: ${t.missing.join("; ")}`);if(t.skew==="wali"){const{startWaliBlenderEngine:n}=await import("./blender-wali-engine-C7bet0ss.js");return n(e,t)}const{startEmscriptenBlenderEngine:r}=await import("./blender-emscripten-engine-C_uFxIuO.js");return r(e,t)}function D(e){return e<200?1:e<5e3?5:25}const J=e=>new Promise(t=>setTimeout(t,e)),B=new TextDecoder;function ae(e,t,r){let n=0,a=0;const o=new Set;async function s(f){for(const l of o)f.has(`${l}.done`)||(await e.unlink(`${d}/reply/${l}.json`),await e.unlink(`${d}/reply/${l}.done`),o.delete(l))}async function i(){let f;try{f=await e.readdir(`${d}/ask`)}catch{return}const l=new Set(f.filter(h=>h.endsWith(".done")));await s(l);for(const h of l){const w=h.slice(0,-5);if(Number(w)<=a)continue;a=Number(w);const m=JSON.parse(B.decode(await e.readFile(`${d}/ask/${w}.json`)));let E;try{E=await t.ask(m)}catch(O){E={error:O instanceof Error?O.message:String(O)}}await e.writeFile(`${d}/reply/${w}.json`,JSON.stringify(E??null)),await e.writeFile(`${d}/reply/${w}.done`,"1"),o.add(w)}}async function c(f){const l=String(++n);await e.writeFile(`${d}/in/${l}.json`,JSON.stringify(f)),await e.writeFile(`${d}/in/${l}.done`,"1");const h=performance.now();for(;;){if(await i(),await e.stat(`${d}/out/${l}.done`)){const m=JSON.parse(B.decode(await e.readFile(`${d}/out/${l}.json`)));if(await e.unlink(`${d}/in/${l}.json`),await e.unlink(`${d}/in/${l}.done`),m.error)throw new Error(m.error);return m.result}const w=r?.();if(w)throw new Error(`Blender is gone, so this call will never be answered: ${w}. The session keeps its directory and its cached banner, so every later call would wait on the same missing answer; start a new program with \`blender-start {fresh: true}\` (\`VGAI_BLENDER_FRESH_SESSION=1\` for the battery harness).`);await J(D(performance.now()-h))}}return{request:c}}const _=e=>typeof e=="object"&&e!==null&&typeof e.offset=="number"&&typeof e.length=="number"&&typeof e.dtype=="string"&&typeof e.count=="number"&&typeof e.stride=="number",U={f32:e=>new Float32Array(e.buffer,e.byteOffset,e.byteLength>>2),f64:e=>new Float64Array(e.buffer,e.byteOffset,e.byteLength>>3),u32:e=>new Uint32Array(e.buffer,e.byteOffset,e.byteLength>>2),i32:e=>new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),u16:e=>new Uint16Array(e.buffer,e.byteOffset,e.byteLength>>1),i16:e=>new Int16Array(e.buffer,e.byteOffset,e.byteLength>>1),u8:e=>e,i8:e=>new Int8Array(e.buffer,e.byteOffset,e.byteLength)};function V(e,t,r){const n=U[r.dtype];if(!n)throw new Error(`Blender frame column ${t}: unknown dtype ${r.dtype}`);const{offset:a,length:o}=r;if(a<0||o<0||a+o>e.byteLength)throw new Error(`Blender frame column ${t}: bytes ${a}..${a+o} lie outside the ${e.byteLength}-byte export arena`);const s=e.subarray(a,a+o).slice(),i=n(s),c=r.count*r.stride;if(i.length!==c)throw new Error(`Blender frame column ${t}: ${i.length} values, ${c} declared (${r.count} x ${r.stride})`);return i}function C(e,t){const r=(n,a)=>{if(_(n)){const o=V(e,a,n);return a==="co"?Float64Array.from(o):o}if(Array.isArray(n))return n.map(o=>r(o,a));if(typeof n=="object"&&n!==null){const o={};for(const[s,i]of Object.entries(n))o[s]=r(i,s);return o}return n};return r(t,"")}async function W(e,t){const r=async(n,a)=>{if(_(n)){const{offset:o,length:s,dtype:i}=n;if(o<0||s<0||o+s>e.byteLength)throw new Error(`Blender frame column ${a}: bytes ${o}..${o+s} lie outside the ${e.byteLength}-byte export arena`);const c=e.subarray(o,o+s).slice(),f=await crypto.subtle.digest("SHA-256",c),l=[...new Uint8Array(f)].map(h=>h.toString(16).padStart(2,"0")).join("");return{dtype:i,length:s,sha256:l}}if(Array.isArray(n))return Promise.all(n.map(o=>r(o,a)));if(typeof n=="object"&&n!==null){const o={};for(const[s,i]of Object.entries(n))o[s]=await r(i,s);return o}return n};return r(t,"")}const S=e=>self.postMessage(e),p=(e,t)=>S({op:"log",level:e,text:t});let b=null,v=null,z=0;const A=new Map;function G(e,t,r){const n=++z,a=[],o=e;for(const s of[o?.meshes??{},o?.images??{}])for(const i of Object.values(s))for(const c of Object.values(i))ArrayBuffer.isView(c)&&c.buffer instanceof ArrayBuffer&&!a.includes(c.buffer)&&a.push(c.buffer);return new Promise((s,i)=>{A.set(n,{resolve:s,reject:i}),self.postMessage({op:"present",id:n,frame:e,description:t,...r?{capture:r}:{}},a)})}let u=null,j=null,g=null,k=0;const H=1e3;function N(){j!==null&&(g!==null&&clearTimeout(g),g=setTimeout(()=>{g=null,K()},H))}async function K(){if(!u||j===null)return;if(k>0){N();return}const e=j;let t;try{t=await u.request({op:"save-document"})}catch(n){p("error",`@@VGAI-ERROR the Blender document ${e} could not be saved: ${$(n)}`);return}if(!t?.saved||typeof t.path!="string")return;let r;try{r=await u.files.readFile(t.path)}catch(n){p("error",`@@VGAI-ERROR the Blender document ${e} was saved but could not be read back out of the engine: ${$(n)}`);return}y.delete(t.path);try{const n=await fetch(`/__editor/blender-document?path=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/octet-stream"},body:new Blob([r])});if(!n.ok){const a=await n.text().catch(()=>"");p("error",`@@VGAI-ERROR the Blender document ${e} was not written to the project: HTTP ${n.status} ${a}`);return}}catch(n){p("error",`@@VGAI-ERROR the Blender document ${e} was not written to the project: ${$(n)}`);return}p("log",`@@VGAI-DOCUMENT ${JSON.stringify({path:e,bytes:r.length})}`)}async function Q(e,t){const r={engine:null},n=await M({project:e,log:p,ask:async({frame:o,capture:s,saveDue:i})=>{if(!r.engine)throw new Error("The Blender session presented before it started");i&&N();const c=await r.engine.readArena(),f=await W(c,o),l=await G(C(c,o),f,s);return{...typeof l.capture=="object"&&l.capture!==null?l.capture:{},..."held"in l?{held:l.held}:{}}}});r.engine=n,u=n,t&&await F(n.files,e);const a=await n.request({op:"start",project:e,...t?{document:t}:{}});return t&&(j=t),b={start:async()=>a,execute:async o=>{const s=await n.request({op:"execute",code:o});return s.error?`Error executing code: ${s.error}`:`Code executed successfully: ${s.result}`},sceneInfo:async()=>JSON.stringify(await n.request({op:"scene-info"}),null,2),objectInfo:async o=>JSON.stringify(await n.request({op:"object-info",name:o}),null,2),screenshotView:async o=>(await n.request({op:"present",capture:{size:o}}),JSON.stringify({view:{size:o}}))},{...a,engine:"blender-wasm",skew:n.skew,bootMs:Math.round(n.bootMs),releasedPayloadMB:n.releasedPayloadBytes===null?null:Math.round(n.releasedPayloadBytes/1048576)}}async function X(){try{const e=await fetch("/__editor/blender-wasm/status");return e.ok?await e.json():{available:!1,missing:[`status answered ${e.status}`]}}catch(e){return{available:!1,missing:[String(e)]}}}async function Y(e,t){if(b)throw new Error("The Blender session is already started");if(!e.startsWith("/"))throw new Error("The Blender session needs the project's absolute path");if(t!==void 0&&!Z(t))throw new Error(`The Blender document must be a project-relative .blend path with no traversal (models/model.blend); got ${JSON.stringify(t)}`);const r=await X();if(!r.available)throw new Error(`Headless Blender is not served by this editor, so there is no modeling engine: ${r.missing.join("; ")}. The engine is Blender compiled to WebAssembly (packages/blender-engine/wasm, or the directory VGAI_BLENDER_WASM_DIR names); nothing stands in for it.`);return v=e,Q(e,t)}function Z(e){return!e.endsWith(".blend")||e.startsWith("/")||e.includes("\\")?!1:e.split("/").every(r=>r!==""&&r!=="."&&r!=="..")}const I=new Set;function T(e){I.has(e)||(I.add(e),p("error",e))}async function q(e){const t=s=>(T(`The project's files are not readable from Python: ${s}`),null);let r;try{r=await fetch("/__editor/blender-project-index")}catch(s){return t(String(s))}if(!r.ok)return t(`/__editor/blender-project-index answered ${r.status}`);let n;try{if(n=await r.json(),typeof n?.root!="string"||!Array.isArray(n.files))return t("invalid project index")}catch(s){return t(String(s))}const{root:a,files:o}=n;return a!==e&&T(`The editor serving this tab has ${a} open, not ${e}; its files are mounted at ${e}, which is where Python is looking.`),o}const y=new Map;async function ee(e,t){const r=await e.stat(t);return r?`${r.size}:${r.mtimeMs}`:""}async function F(e,t){const r=await q(t);if(!r)return;const n=new Set(r.map(a=>`${t}/${a.path}`));for(const a of[...y.keys()])if(!n.has(a)){try{await e.unlink(a)}catch{}y.delete(a)}for(const a of r){const o=`${t}/${a.path}`,s=`${a.size}:${a.mtime}`;if(y.get(o)?.host===s||!y.has(o)&&await e.stat(o)!==null)continue;const i=await fetch(`/__editor/blender-project-file?path=${encodeURIComponent(a.path)}`);if(!i.ok){T(`${a.path}: HTTP ${i.status}`);continue}const c=o.slice(0,o.lastIndexOf("/"));c&&await e.mkdirTree(c),await e.writeFile(o,new Uint8Array(await i.arrayBuffer())),y.set(o,{host:s,engine:await ee(e,o)})}}async function te(e,t){const r=[],n=async a=>{let o;try{o=await e.readdir(a)}catch{return}for(const s of o){if(s==="."||s==="..")continue;const i=`${a.replace(/\/$/,"")}/${s}`,c=await e.stat(i);if(c){if((c.mode&61440)===16384){await n(i);continue}y.get(i)?.engine!==`${c.size}:${c.mtimeMs}`&&r.push({path:i,size:c.size,mtime:c.mtimeMs})}}};return await n(t),r}async function R(e){switch(e.op){case"start":return Y(e.project,e.document);case"present-result":{const n=A.get(e.id);A.delete(e.id),n&&(e.error?n.reject(new Error(e.error)):n.resolve({...e.capture===void 0?{}:{capture:e.capture},..."held"in e?{held:e.held}:{}}));return}}if(!b||!v||!u)throw new Error("The Blender session has not started");const t=u.files,r=u.request.bind(u);switch(e.op){case"execute":return await F(t,v),b.execute(e.code);case"present":return r({op:"present"});case"scene-info":return b.sceneInfo();case"object-info":return b.objectInfo(e.name);case"rna":return r({op:"rna",path:e.path,...e.names===void 0?{}:{names:e.names}});case"rna-context":return r({op:"rna-context",...e.object===void 0?{}:{object:e.object},...e.collection===void 0?{}:{collection:e.collection}});case"rna-set":return r({op:"rna-set",path:e.path,property:e.property,value:e.value,...e.index===void 0?{}:{index:e.index}});case"outliner":return r({op:"outliner",...e.selected===void 0?{}:{selected:[...e.selected]}});case"node-tree":return r({op:"node-tree",...e.path===void 0?{}:{path:e.path},...e.material===void 0?{}:{material:e.material}});case"uv-layout":return r({op:"uv-layout",...e.object===void 0?{}:{object:e.object},...e.uvLayer===void 0?{}:{uvLayer:e.uvLayer}});case"rig":return r({op:"rig",...e.object===void 0?{}:{object:e.object}});case"action-clip":return r({op:"action-clip",...e.object===void 0?{}:{object:e.object},...e.bake===void 0?{}:{bake:e.bake}});case"outliner-set":return r({op:"outliner-set",path:e.path,column:e.column,value:e.value});case"screenshot-view":return JSON.parse(await b.screenshotView(e.maxSize));case"read-file":return t.readFile(e.path);case"write-file":{const n=e.path.slice(0,e.path.lastIndexOf("/"));n&&await t.mkdirTree(n),await t.writeFile(e.path,e.bytes),y.delete(e.path);return}case"list-files":return te(t,e.path)}throw new Error(`Unknown Blender worker request ${e.op}`)}function $(e){if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;if(typeof e=="object"&&e!==null){const t=e;if(typeof t.message=="string")return typeof t.name=="string"?`${t.name}: ${t.message}`:t.message;try{return JSON.stringify(e)??Object.prototype.toString.call(e)}catch{return Object.prototype.toString.call(e)}}return String(e)}function ne(){if(!u)return;const e=u.memoryBytes();e!==null&&S({op:"memory",bytes:e})}self.onmessage=async e=>{const t=e.data;if(t.op==="present-result"){await R(t);return}k+=1;try{S({id:t.id,result:await R(t)})}catch(r){S({id:t.id,error:$(r)})}finally{k-=1}ne()};export{x as A,oe as P,d as S,re as a,L as b,ae as o,J as s};