@fps-games/editor-deployment 0.2.3-beta.8 → 0.2.3-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/fps-editor-agent.mjs +3 -3
- package/licenses/THIRD_PARTY_NOTICES.txt +2 -2
- package/manifest.json +56 -56
- package/npm-shrinkwrap.json +2 -2
- package/package.json +5 -5
- package/public/assets/{index-DsjoVi0a.js → index-CdqIKk65.js} +1 -1
- package/public/assets/index-CdqIKk65.js.br +0 -0
- package/public/assets/index-CdqIKk65.js.gz +0 -0
- package/public/assets/playable-sdk-zyPm5JCa.js +8 -0
- package/public/assets/playable-sdk-zyPm5JCa.js.br +0 -0
- package/public/assets/playable-sdk-zyPm5JCa.js.gz +0 -0
- package/public/assets/playable-standard-project-BA5pc2TZ.js +5140 -0
- package/public/assets/playable-standard-project-BA5pc2TZ.js.br +0 -0
- package/public/assets/playable-standard-project-BA5pc2TZ.js.gz +0 -0
- package/public/index.html +3 -3
- package/public/index.html.br +4 -1
- package/public/index.html.gz +0 -0
- package/runtime/editor-control-plane.mjs +5 -5
- package/runtime/runtime-debug-authoring-bridge.mjs +1 -1
- package/worker/editor-service-worker.mjs +24 -24
- package/public/assets/index-DsjoVi0a.js.br +0 -0
- package/public/assets/index-DsjoVi0a.js.gz +0 -0
- package/public/assets/playable-sdk-BhG9wmjo.js +0 -9
- package/public/assets/playable-sdk-BhG9wmjo.js.br +0 -0
- package/public/assets/playable-sdk-BhG9wmjo.js.gz +0 -0
- package/public/assets/playable-standard-project-BMleU1jU.js +0 -5139
- package/public/assets/playable-standard-project-BMleU1jU.js.br +0 -0
- package/public/assets/playable-standard-project-BMleU1jU.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fB as Ye,fA as Ze,jG as Je,hT as Xe,m0 as er,iT as rr}from"./playable-standard-project-BMleU1jU.js";import{registerFpsEditorContribution as tr}from"@fps-games/editor-core/plugin-host";import"./dynamicTexture-Cuby-VOT.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const p of o.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&n(p)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();const nr="0.2.3-beta.8",or="fps.editor.surface.hierarchy",ir="fps.hierarchy.surface";function ar(){return Object.freeze({type:ir,id:"hierarchy",title:"层级",area:"left",toolbar:"scoped-hierarchy",createKernel:cr})}function sr(e){const{snapshot:r,targetId:t,modifier:n}=e;if(t===null)return r.capabilities.clearSelection?Object.freeze({selectedIds:Object.freeze([]),activeId:null,anchorId:null}):Object.freeze({selectedIds:r.selectedIds,activeId:r.activeId,anchorId:e.anchorId});if(r.nodeById.get(t)?.selectable!==!0)return Object.freeze({selectedIds:r.selectedIds,activeId:r.activeId,anchorId:e.anchorId});if(n==="toggle"){const i=new Set(r.selectedIds);i.has(t)?i.delete(t):i.add(t);const o=[...i];return Object.freeze({selectedIds:Object.freeze(o),activeId:i.has(t)?t:o[o.length-1]??null,anchorId:t})}if(n==="range"&&r.capabilities.rangeSelection&&e.anchorId){const i=e.projection.indexOf(e.anchorId),o=e.projection.indexOf(t);if(i>=0&&o>=0){const[p,c]=i<=o?[i,o]:[o,i],I=e.projection.getRange(p,c).filter(b=>r.nodeById.get(b)?.selectable===!0);return Object.freeze({selectedIds:Object.freeze(I),activeId:t,anchorId:e.anchorId})}}return Object.freeze({selectedIds:Object.freeze([t]),activeId:t,anchorId:t})}function cr(){const e=new Map,r=new Map,t=new Map,n=new WeakMap;let i=new WeakMap;const o=new Map,p=new Set;let c=[],I=null,b=null,v=0;const O=(a=c)=>{const d=a.flatMap(f=>{if(!f.canProvide())return[];const h=f.getSnapshot();return h?[{provider:f,snapshot:h}]:[]}).sort((f,h)=>(h.provider.priority??0)-(f.provider.priority??0)||f.provider.id.localeCompare(h.provider.id));if(d.length>1&&(d[0].provider.priority??0)===(d[1].provider.priority??0))throw new Error(`Ambiguous Hierarchy scope providers: ${d[0].provider.id}, ${d[1].provider.id}.`);return d[0]??null},g=()=>{const a=O(),d=a?.provider??null,f=a?.snapshot??null;f&&d&&hr(r,d,f);const h=f?.scopeKey??null;(I!==d||b!==h)&&(b&&Se(e.get(b)),h&&Se(e.get(h)),I=d,b=h,v+=1);const w=f&&d?we(o,d,f):null;return w&&Ir(E(w.scopeKey),w),w},E=a=>{const d=e.get(a);if(d)return d;const f={collapsedIds:new Set,searchQuery:"",selectionAnchorId:null,rename:null,dragId:null,revision:null,dragIds:[],observedActiveId:null,sanitizedStructureRevision:null,projectionRevision:0,selectionGeneration:0,renameGeneration:0,dragGeneration:0,pendingSelectionGeneration:null,pendingRenameGeneration:null,pendingDragGeneration:null};return e.set(a,f),f},A=(a,d)=>{const f=E(a.scopeKey),h=M(a,f,d),w=x(a,d,se(a,a.activeId),"view");return Object.freeze({providerId:d.id,authorityToken:v,snapshot:a,state:Oe(f,n),projection:h,operations:w})},x=(a,d,f,h)=>{let w=i.get(a);w||(w=new WeakMap,i.set(a,w));let s=w.get(d);s||(s=new Map,w.set(d,s));const $=`${h}\0${f.contextNodeId??""}\0${f.activeId??""}\0${f.targetIds.join("")}`,C=s.get($);if(C)return C;const l=v,J=Object.freeze([...d.listOperations(f)]),q=g();return v!==l||I!==d||q?.scopeKey!==a.scopeKey||q.revision!==a.revision?Object.freeze([]):(s.set($,J),J)},M=(a,d,f)=>{const h=t.get(a.scopeKey);if(h&&h.provider===f&&h.structureRevision===a.structureRevision&&h.projectionRevision===d.projectionRevision)return h.projection;const w=br(a,d);return t.set(a.scopeKey,{provider:f,structureRevision:a.structureRevision,projectionRevision:d.projectionRevision,projection:w}),w},P=()=>{for(let a=0;a<=c.length+1;a+=1){const d=g(),f=I;if(!d||!f)return null;const h=v,w=A(d,f);if(v===h&&I===f&&b===d.scopeKey)return w}throw new Error("Hierarchy provider authority did not stabilize during operation discovery.")},u=a=>{const d=[];for(const f of p)try{f.render(a)}catch(h){d.push(h)}if(d.length>0)throw d[0]},m=()=>{u(P())},y=a=>Object.freeze({ok:!0,changed:!1,revision:a?.revision??0,diagnostics:Object.freeze([])}),S=a=>{const d=Object.freeze({ok:!0,changed:!0,revision:a.revision,diagnostics:Object.freeze([])});try{return m(),d}catch(f){return pe(d,a.revision,f)}},j=async(a,d)=>{try{const f=wr(await a());return f.revision<d.revision?_(d.revision,"hierarchy.operation.revision-regressed",new Error(`Hierarchy operation revision regressed from ${d.revision} to ${f.revision}.`)):f}catch(f){return _(d.revision,"hierarchy.operation.failed",f)}},k={setProviders(a){const d=Object.freeze([...a]);dr(d);const f=c,h=I,w=b,s=v,$=pr(r),C=lr(e),l=new Map(t),J=ur(o);let q;try{c=d,q=P()}catch(z){throw c=f,I=h,b=w,v=s,ce(r,$),ce(e,C),ce(t,l),ce(o,J),z}for(const z of r.keys())d.includes(z)||r.delete(z);for(const[z,W]of o)d.includes(W.provider)||o.delete(z);u(q)},getProvider(){return g(),I},getViewModel:P,patchNodeLabels(a){const d=g(),f=I;if(!d||!f)return null;let h=o.get(d.scopeKey);(h?.provider!==f||h.structureRevision!==d.structureRevision)&&(h={provider:f,structureRevision:d.structureRevision,labels:new Map,sourceSnapshot:null,snapshot:null},o.set(d.scopeKey,h));for(const[w,s]of Object.entries(a))if(!s.trim()||!d.nodeById.has(w))return null;for(const[w,s]of Object.entries(a))h.labels.set(w,s);return h.sourceSnapshot=null,h.snapshot=null,t.delete(d.scopeKey),we(o,f,d)},listOperations(a,d){const f=I,h=b,w=g(),s=I;if((f!==s||h!==b)&&u(P()),!w||!s||d!==void 0&&d!==v||a.scopeKey!==w.scopeKey||a.expectedRevision!==w.revision)return Object.freeze([]);const $=x(w,s,a,"explicit");return I!==s||b!==w.scopeKey?(u(P()),Object.freeze([])):$},attachView(a){let d=null;try{d=a.bind(h=>k.dispatch(h)),p.add(a),a.render(P())}catch(h){if(p.delete(a),d)try{d()}catch(w){const s=new Error(`Hierarchy ViewAdapter initialization failed: ${xe(h)}; cleanup failed: ${xe(w)}`);throw Object.assign(s,{retryCleanup:()=>d?.()}),s}throw h}let f=!0;return()=>{f&&(d?.(),p.delete(a),f=!1)}},refresh(){i=new WeakMap,m()},async dispatch(a){let d=b?fr(r,I,b)?.revision??e.get(b)?.revision??0:0;const f=a.type==="drag.commit"&&b?e.get(b)??null:null,h=f?.dragGeneration??null,w=f?.dragId??null;try{const s=g();d=s?.revision??0;const $=I,C=v;if(!s||!$)return _(s?.revision??0,"hierarchy.scope.unavailable",new Error("No active Hierarchy scope provider is available."));if(a.expectedAuthorityToken!==void 0&&a.expectedAuthorityToken!==C)return _(s.revision,"hierarchy.operation.provider-authority-changed",new Error("Hierarchy intent authority no longer matches the active provider."));if(a.expectedScopeKey!==void 0&&a.expectedScopeKey!==s.scopeKey||a.expectedRevision!==void 0&&a.expectedRevision!==s.revision)return _(s.revision,"hierarchy.operation.view-authority-changed",new Error("Hierarchy intent no longer matches the rendered scope revision."));const l=E(s.scopeKey),J=x(s,$,se(s,s.activeId),"view");if(v!==C||I!==$||b!==s.scopeKey)return _(s.revision,"hierarchy.operation.provider-authority-changed",new Error("Hierarchy provider authority changed during operation discovery."));const q=Object.freeze({providerId:$.id,authorityToken:C,snapshot:s,state:Oe(l,n),projection:M(s,l,$),operations:J});if(a.type==="search.change")return l.searchQuery===a.value?y(s):(l.searchQuery=a.value,l.projectionRevision+=1,S(s));if(a.type==="disclosure.toggle")return!s.nodeById.has(a.targetId)||!s.childrenByParentId.get(a.targetId)?.length?y(s):(l.collapsedIds.has(a.targetId)?l.collapsedIds.delete(a.targetId):l.collapsedIds.add(a.targetId),l.projectionRevision+=1,S(s));if(a.type==="disclosure.expand")return!s.nodeById.has(a.targetId)||!l.collapsedIds.delete(a.targetId)?y(s):(l.projectionRevision+=1,S(s));if(a.type==="disclosure.reveal"){if(!s.nodeById.has(a.targetId))return y(s);let R=!1,F=s.nodeById.get(a.targetId)?.parentId??null;for(;F;)R=l.collapsedIds.delete(F)||R,F=s.nodeById.get(F)?.parentId??null;return R?(l.projectionRevision+=1,S(s)):y(s)}if(a.type==="selection"||a.type==="selection.set"){const R=a.type==="selection"?sr({snapshot:s,targetId:a.targetId,modifier:a.modifier,projection:q.projection,anchorId:l.selectionAnchorId}):vr(s,a.selectedIds,a.activeId,a.anchorId),F=l.selectionAnchorId,L=++l.selectionGeneration;l.pendingSelectionGeneration=L;const U=await j(()=>$.applySelection(Object.freeze({...se(s,a.type==="selection"?a.targetId:a.activeId),selectedIds:R.selectedIds,activeId:R.activeId})),s);U.changed&&i.delete(s);let V;try{V=P()}catch(B){return l.pendingSelectionGeneration===L&&(l.pendingSelectionGeneration=null),de(U,s.revision,B)}const T=V?.snapshot??null,K=V?.authorityToken===C?je(U,s,T):Me(U,s.revision,C,V?.authorityToken??null);L===l.selectionGeneration&&T?.scopeKey===s.scopeKey&&T.revision===K.revision&&(l.revision=T.revision,l.selectionAnchorId=K.ok?R.anchorId:F),l.pendingSelectionGeneration===L&&(l.pendingSelectionGeneration=null);try{T&&I&&(V=A(T,I)),u(V)}catch(B){return pe(K,s.revision,B)}return K}if(a.type==="rename.begin"){const R=s.nodeById.get(a.targetId);return!s.readonly&&s.capabilities.rename&&R?.renamable&&R.editorLocked!==!0?(l.renameGeneration+=1,l.rename={id:R.id,value:R.label},S(s)):y(s)}if(a.type==="rename.change")return l.rename?(l.renameGeneration+=1,l.rename.value=a.value,S(s)):y(s);if(a.type==="rename.cancel")return l.renameGeneration+=1,l.rename=null,S(s);if(a.type==="drag.begin"){const R=s.nodeById.get(a.targetId);if(!s.readonly&&s.capabilities.reparent&&R?.draggable&&R.editorLocked!==!0){const F=q.projection.getTopLevelSelection(s.selectedIds.includes(a.targetId)?s.selectedIds:[a.targetId]).filter(L=>{const U=s.nodeById.get(L);return U?.draggable===!0&&U.editorLocked!==!0});return F.length===0?y(s):(l.dragGeneration+=1,l.dragId=a.targetId,l.dragIds=Object.freeze(F),S(s))}return y(s)}if(a.type==="drag.cancel")return l.dragGeneration+=1,l.dragId=null,l.dragIds=[],S(s);if(a.type==="context")return y(s);let z,W,Q=s.activeId;if(a.type==="primary"&&(z=s.primaryOperationId,Q=a.targetId),a.type==="rename.commit"&&l.rename&&(z="hierarchy.node.rename",W=Object.freeze({targetId:l.rename.id,name:l.rename.value}),Q=l.rename.id),a.type==="drag.commit"&&l.dragId&&(z=a.operationId,W=Object.freeze({...a.input??{},draggedIds:Object.freeze([...l.dragIds])}),Q=l.dragId),a.type==="operation.execute"){if(z=a.operationId,W=a.input,a.context&&(a.context.scopeKey!==s.scopeKey||a.context.expectedRevision!==s.revision))return _(s.revision,"hierarchy.operation.stale",new Error("Hierarchy operation context no longer matches the active scope revision."));Q=a.context?.contextNodeId??Q}if(!z)return y(s);const X=l.renameGeneration,le=l.dragGeneration;a.type==="rename.commit"&&(l.pendingRenameGeneration=X),a.type==="drag.commit"&&(l.pendingDragGeneration=le);const ve=a.type==="rename.commit"?l.rename?.id:a.type==="drag.commit"?l.dragId:null,be=a.type==="operation.execute"&&a.context?a.context:a.type==="drag.commit"?Object.freeze({...se(s,Q),targetIds:Object.freeze([...l.dragIds])}):se(s,Q);try{const R=x(s,$,be,"explicit"),F=g(),L=v!==C||I!==$||b!==s.scopeKey,U=F?.revision!==s.revision;if(L||U){try{u(P())}catch{}return _(F?.revision??s.revision,L?"hierarchy.operation.provider-authority-changed":"hierarchy.operation.stale",new Error(L?"Hierarchy provider authority changed during operation discovery.":"Hierarchy scope revision changed during operation discovery."))}const V=R.find(ae=>ae.id===z);if(!V)return _(s.revision,"hierarchy.operation.unavailable",new Error(`Hierarchy operation is unavailable for this context: ${z}`));if(V.disabledReason)return _(s.revision,"hierarchy.operation.disabled",new Error(V.disabledReason));const T=await j(()=>$.executeOperation(Object.freeze({...be,operationId:z,...W?{input:W}:{}})),s);(T.ok||T.changed)&&i.delete(s);let K;try{K=P()}catch(ae){return a.type==="rename.commit"&&l.pendingRenameGeneration===X&&(l.pendingRenameGeneration=null),de(T,s.revision,ae)}const B=K?.snapshot??null,ee=K?.authorityToken===C?je(T,s,B):Me(T,s.revision,C,K?.authorityToken??null),ue=B?.scopeKey===s.scopeKey&&B.revision===ee.revision;ue&&B&&(l.revision=B.revision),ee.ok&&a.type==="rename.commit"&&ue&&l.renameGeneration===X&&l.rename?.id===ve&&(l.rename=null),!ee.ok&&ee.changed&&ue&&B&&B.revision!==s.revision&&a.type==="rename.commit"&&l.renameGeneration===X&&(l.rename=null),a.type==="rename.commit"&&l.pendingRenameGeneration===X&&(l.pendingRenameGeneration=null);try{B&&I&&(K=A(B,I)),u(K)}catch(ae){return pe(ee,s.revision,ae)}return ee}finally{if(a.type==="rename.commit"&&l.pendingRenameGeneration===X&&(l.pendingRenameGeneration=null),a.type==="drag.commit"&&l.pendingDragGeneration===le&&(l.pendingDragGeneration=null,l.dragGeneration===le&&l.dragId===ve)){l.dragId=null,l.dragIds=[];try{m()}catch{}}}}catch(s){return _(d,"hierarchy.operation.failed",s)}finally{if(f&&h!==null&&f.dragGeneration===h&&f.dragId===w){f.pendingDragGeneration=null,f.dragId=null,f.dragIds=[];try{m()}catch{}}}}};return k}function dr(e){const r=new Set;for(const t of e){if(!t.id.trim())throw new Error("Hierarchy scope provider id is required.");if(r.has(t.id))throw new Error(`Duplicate Hierarchy scope provider id: ${t.id}.`);r.add(t.id)}}function lr(e){return new Map([...e].map(([r,t])=>[r,{...t,collapsedIds:new Set(t.collapsedIds),rename:t.rename?{...t.rename}:null}]))}function ce(e,r){e.clear();for(const[t,n]of r)e.set(t,n)}function we(e,r,t){const n=e.get(t.scopeKey);if(!n)return t;if(n.provider!==r||n.structureRevision!==t.structureRevision)return e.delete(t.scopeKey),t;if(n.sourceSnapshot===t&&n.snapshot)return n.snapshot;const i=new Map(t.nodeById);let o=!1;for(const[c,I]of n.labels){const b=i.get(c);!b||b.label===I||(i.set(c,Object.freeze({...b,label:I})),o=!0)}const p=o?Object.freeze({...t,nodeById:Sr(i)}):t;return n.sourceSnapshot=t,n.snapshot=p,p}function ur(e){return new Map([...e].map(([r,t])=>[r,{...t,labels:new Map(t.labels)}]))}function pr(e){return new Map([...e].map(([r,t])=>[r,new Map(t)]))}function fr(e,r,t){return r?e.get(r)?.get(t):void 0}function hr(e,r,t){let n=e.get(r);n||(n=new Map,e.set(r,n));const i=n.get(t.scopeKey);if(i&&t.revision<i.revision)throw new Error(`Hierarchy scope ${t.scopeKey} revision regressed from ${i.revision} to ${t.revision}.`);if(i&&t.revision===i.revision&&!mr(i.snapshot,t))throw new Error(`Hierarchy scope ${t.scopeKey} reused revision ${t.revision} for a different authority snapshot.`);if(i&&t.structureRevision<i.structureRevision)throw new Error(`Hierarchy scope ${t.scopeKey} structureRevision regressed from ${i.structureRevision} to ${t.structureRevision}.`);if(i&&t.structureRevision===i.structureRevision&&(t.rootIds!==i.rootIds||t.nodeById!==i.nodeById||t.childrenByParentId!==i.childrenByParentId))throw new Error(`Hierarchy scope ${t.scopeKey} must structurally share tree indexes for structureRevision ${t.structureRevision}.`);(!i||t.revision>i.revision)&&n.set(t.scopeKey,{revision:t.revision,snapshot:t,structureRevision:t.structureRevision,rootIds:t.rootIds,nodeById:t.nodeById,childrenByParentId:t.childrenByParentId})}function mr(e,r){return e===r?!0:e.scopeType===r.scopeType&&e.structureRevision===r.structureRevision&&e.title===r.title&&e.searchPlaceholder===r.searchPlaceholder&&e.readonly===r.readonly&&e.rootIds===r.rootIds&&e.nodeById===r.nodeById&&e.childrenByParentId===r.childrenByParentId&&e.activeId===r.activeId&&e.primaryOperationId===r.primaryOperationId&&gr(e.selectedIds,r.selectedIds)&&yr(e.capabilities,r.capabilities)}function gr(e,r){return e.length===r.length&&e.every((t,n)=>t===r[n])}function yr(e,r){const t=new Set([...Object.keys(e),...Object.keys(r)]);for(const n of t)if(e[n]!==r[n])return!1;return!0}function se(e,r){return Object.freeze({scopeKey:e.scopeKey,expectedRevision:e.revision,contextNodeId:r,targetIds:e.selectedIds,activeId:e.activeId})}function Ir(e,r){if(e.revision!==null&&e.revision!==r.revision&&(e.pendingSelectionGeneration===null&&(e.selectionGeneration+=1),e.pendingRenameGeneration===null&&(e.renameGeneration+=1,e.rename=null),e.pendingDragGeneration===null&&(e.dragGeneration+=1,e.dragId=null,e.dragIds=[])),e.revision=r.revision,e.observedActiveId!==r.activeId){let t=!1;if(e.collapsedIds.size>0){let n=r.activeId?r.nodeById.get(r.activeId)?.parentId??null:null;for(;n;)t=e.collapsedIds.delete(n)||t,n=r.nodeById.get(n)?.parentId??null}t&&(e.projectionRevision+=1),e.observedActiveId=r.activeId}if(e.sanitizedStructureRevision!==r.structureRevision){e.selectionAnchorId&&!r.nodeById.has(e.selectionAnchorId)&&(e.selectionAnchorId=null),e.rename&&!r.nodeById.has(e.rename.id)&&(e.rename=null),e.dragId&&!r.nodeById.has(e.dragId)&&(e.dragId=null),e.dragIds=e.dragIds.filter(n=>r.nodeById.has(n)),(!e.dragId||e.dragIds.length===0)&&(e.dragId=null,e.dragIds=[]);let t=!1;for(const n of e.collapsedIds)r.nodeById.has(n)||(t=e.collapsedIds.delete(n)||t);t&&(e.projectionRevision+=1),e.sanitizedStructureRevision=r.structureRevision}}function Se(e){e&&(e.selectionGeneration+=1,e.renameGeneration+=1,e.dragGeneration+=1,e.pendingSelectionGeneration=null,e.pendingRenameGeneration=null,e.pendingDragGeneration=null,e.selectionAnchorId=null,e.rename=null,e.dragId=null,e.dragIds=[])}function vr(e,r,t,n){const i=Be(r).filter(c=>e.nodeById.get(c)?.selectable===!0),o=t&&i.includes(t)?t:i[0]??null,p=n&&e.nodeById.has(n)?n:o;return Object.freeze({selectedIds:Object.freeze(i),activeId:o,anchorId:p})}function br(e,r){const t=r.searchQuery.trim().toLocaleLowerCase(),n=t?new Set:null;if(n)for(const u of e.nodeById.values()){if(!u.label.toLocaleLowerCase().includes(t)&&!u.id.toLocaleLowerCase().includes(t))continue;let m=u;for(;m&&!n.has(m.id);)n.add(m.id),m=m.parentId?e.nodeById.get(m.parentId):void 0}const i=[],o=new Map,p=[...e.rootIds].reverse().map(u=>({id:u,depth:0}));for(;p.length>0;){const{id:u,depth:m}=p.pop();if(!e.nodeById.get(u)||n&&!n.has(u)||(o.set(u,i.length),i.push(Object.freeze({id:u,depth:m})),!n&&r.collapsedIds.has(u)))continue;const S=e.childrenByParentId.get(u)??[];for(let j=S.length-1;j>=0;j-=1)p.push({id:S[j],depth:m+1})}const c=Object.freeze(i),I=Object.freeze([]),b=new Map,v=new Map,O=new Map,g=(u,m,y)=>(u.size>256&&u.clear(),u.set(m,y),y),E=u=>{if(!u)return I;const m=b.get(u);if(m)return m;const y=[];let S=e.nodeById.get(u)?.parentId??null;for(;S;)y.push(S),S=e.nodeById.get(S)?.parentId??null;return g(b,u,Object.freeze(y))},A=u=>{const m=v.get(u);if(m)return m;v.size>256&&v.clear();const y=new Set(E(u));return v.set(u,y),y},x=u=>{const m=Be(u).filter(k=>e.nodeById.has(k));if(m.length===0)return I;const y=m.join("\0"),S=O.get(y);if(S)return S;if(m.length===1)return g(O,y,Object.freeze([...m]));const j=new Set(m);return g(O,y,Object.freeze(m.filter(k=>!E(k).some(a=>j.has(a)))))},M=(u,m)=>u!==m&&A(u).has(m),P=u=>{const m=x(u.draggedIds),y=h=>Object.freeze({ok:!1,reason:h,placement:u.placement,draggedIds:Object.freeze([]),targetId:u.targetId??null,parentId:null,beforeId:null,afterId:null});if(m.length===0)return y("empty-drag");for(const h of m){const w=e.nodeById.get(h);if(!w?.draggable||w.editorLocked===!0)return y("dragged-node-not-movable")}if(u.placement==="root")return Object.freeze({ok:!0,placement:"root",draggedIds:m,targetId:null,parentId:null,beforeId:null,afterId:null});const S=u.targetId??null,j=S?e.nodeById.get(S):void 0;if(!j)return y("missing-target");const k=new Set(m);if(k.has(j.id))return y("cannot-drop-on-self");if(m.some(h=>M(j.id,h)))return y("cannot-drop-on-descendant");if(u.placement==="inside"){if(j.editorLocked===!0)return y("target-node-locked");if(!j.canHaveChildren)return y("target-cannot-have-children");const h=(e.childrenByParentId.get(j.id)??[]).filter(w=>!k.has(w));return Object.freeze({ok:!0,placement:"inside",draggedIds:m,targetId:j.id,parentId:j.id,beforeId:null,afterId:h[h.length-1]??null})}if(j.role==="root")return y("cannot-reorder-root");if(j.editorLocked===!0)return y("target-node-locked");if((j.parentId?e.nodeById.get(j.parentId):void 0)?.editorLocked===!0)return y("target-parent-locked");const d=(e.childrenByParentId.get(j.parentId)??[]).filter(h=>!k.has(h)),f=d.indexOf(j.id);return Object.freeze({ok:!0,placement:u.placement,draggedIds:m,targetId:j.id,parentId:j.parentId,beforeId:u.placement==="before"?j.id:d[f+1]??null,afterId:u.placement==="after"?j.id:d[f-1]??null})};return Object.freeze({structureRevision:e.structureRevision,projectionRevision:r.projectionRevision,totalCount:c.length,indexOf(u){return u?o.get(u)??-1:-1},getRow(u){return Number.isInteger(u)&&u>=0?c[u]??null:null},getWindow(u,m){const y=Math.max(0,Math.trunc(u)),S=Math.max(0,Math.trunc(m));return Object.freeze(c.slice(y,y+S))},getRange(u,m){const y=Math.max(0,Math.min(Math.trunc(u),Math.trunc(m))),S=Math.min(c.length-1,Math.max(Math.trunc(u),Math.trunc(m)));return S<y?Object.freeze([]):Object.freeze(c.slice(y,S+1).map(j=>j.id))},getAncestors:E,getSelectableChildren(u){return Object.freeze(u?(e.childrenByParentId.get(u)??[]).filter(m=>e.nodeById.get(m)?.selectable===!0):[])},getSelectableDescendants(u){if(!u||!e.nodeById.has(u))return Object.freeze([]);const m=[],y=[...e.childrenByParentId.get(u)??[]].reverse();for(;y.length>0;){const S=y.pop();e.nodeById.get(S)?.selectable===!0&&m.push(S);const j=e.childrenByParentId.get(S)??[];for(let k=j.length-1;k>=0;k-=1)y.push(j[k])}return Object.freeze(m)},getTopLevelSelection:x,isDescendant:M,resolveDrop:P})}function wr(e){if(!e||typeof e!="object"||typeof e.ok!="boolean"||!Number.isSafeInteger(e.revision))throw new Error("Hierarchy provider returned an invalid operation result.");return Object.freeze({ok:e.ok,changed:e.changed===!0,revision:e.revision,diagnostics:Object.freeze([...e.diagnostics??[]])})}function _(e,r,t){return Object.freeze({ok:!1,changed:!1,revision:e,diagnostics:Object.freeze([Object.freeze({code:r,message:t instanceof Error?t.message:String(t),severity:"error"})])})}function de(e,r,t){const n=Ie(e);return Object.freeze({ok:!1,changed:e.changed||n,revision:Math.max(r,e.revision),diagnostics:Object.freeze([...e.diagnostics,Object.freeze({code:"hierarchy.snapshot.refresh-failed-after-operation",message:t instanceof Error?t.message:String(t),severity:"error"}),...n?[Object.freeze({code:"hierarchy.operation.commit-status-unknown",message:"The provider failed before the refreshed snapshot could confirm whether its authored change committed.",severity:"error"})]:[]])})}function pe(e,r,t){const n=Ie(e);return Object.freeze({ok:!1,changed:e.changed||n,revision:Math.max(r,e.revision),diagnostics:Object.freeze([...e.diagnostics,Object.freeze({code:"hierarchy.view.render-failed-after-change",message:t instanceof Error?t.message:String(t),severity:"error"}),...n?[Object.freeze({code:"hierarchy.operation.commit-status-unknown",message:"The provider failed before the refreshed snapshot could confirm whether its authored change committed.",severity:"error"})]:[]])})}function je(e,r,t){if(!t||t.scopeKey!==r.scopeKey)return de(e,r.revision,new Error(`Hierarchy scope ${r.scopeKey} was unavailable after the operation.`));if(t.revision<e.revision)return de(e,r.revision,new Error(`Hierarchy operation reported revision ${e.revision}, but the refreshed scope is still at ${t.revision}.`));if(t.revision===e.revision)return e;const n=!e.ok&&e.diagnostics.some(i=>i.code==="hierarchy.operation.failed")&&t.revision>r.revision;return Object.freeze({...e,changed:e.changed||n,revision:t.revision,diagnostics:Object.freeze([...e.diagnostics,Object.freeze({code:n?"hierarchy.operation.failed-after-revision-advanced":"hierarchy.operation.concurrent-revision-advanced",message:n?`The operation failed after the scope advanced from revision ${r.revision} to ${t.revision}; the authored result may already be committed.`:`The scope advanced to revision ${t.revision} while the operation completed.`,severity:n?"error":"info"})])})}function Me(e,r,t,n){const i=Ie(e);return Object.freeze({ok:!1,changed:e.changed||i,revision:Math.max(r,e.revision),diagnostics:Object.freeze([...e.diagnostics,Object.freeze({code:"hierarchy.operation.provider-authority-changed",message:`Hierarchy provider authority changed from token ${t} to ${n??"none"} while the operation was pending.`,severity:"error"}),...i?[Object.freeze({code:"hierarchy.operation.commit-status-unknown",message:"Provider authority changed before the failed operation could confirm whether its authored change committed.",severity:"error"})]:[]])})}function Ie(e){return e.diagnostics.some(r=>r.code==="hierarchy.operation.failed")}function xe(e){return e instanceof Error?e.message:String(e)}function Oe(e,r){const t=r.get(e);if(t&&t.projectionRevision===e.projectionRevision&&t.selectionGeneration===e.selectionGeneration&&t.renameGeneration===e.renameGeneration&&t.dragGeneration===e.dragGeneration&&t.selectionAnchorId===e.selectionAnchorId&&t.renameId===(e.rename?.id??null)&&t.renameValue===(e.rename?.value??null)&&t.dragId===e.dragId&&t.dragIds===e.dragIds)return t.snapshot;const n=Object.freeze({collapsedIds:t?.projectionRevision===e.projectionRevision?t.snapshot.collapsedIds:new Set(e.collapsedIds),searchQuery:e.searchQuery,selectionAnchorId:e.selectionAnchorId,rename:e.rename?Object.freeze({...e.rename}):null,dragId:e.dragId,dragIds:t?.dragGeneration===e.dragGeneration&&t.dragIds===e.dragIds?t.snapshot.dragIds:Object.freeze([...e.dragIds])});return r.set(e,{projectionRevision:e.projectionRevision,selectionGeneration:e.selectionGeneration,renameGeneration:e.renameGeneration,dragGeneration:e.dragGeneration,selectionAnchorId:e.selectionAnchorId,renameId:e.rename?.id??null,renameValue:e.rename?.value??null,dragId:e.dragId,dragIds:e.dragIds,snapshot:n}),n}function Be(e){return[...new Set(e.filter(r=>r.trim()))]}function Sr(e){let r;return r=Object.freeze({get size(){return e.size},has(t){return e.has(t)},get(t){return e.get(t)},entries(){return e.entries()},keys(){return e.keys()},values(){return e.values()},forEach(t,n){e.forEach((i,o)=>t.call(n,i,o,r))},[Symbol.iterator](){return e[Symbol.iterator]()}}),r}const Ge="fps.plugin.hierarchy";function jr(){return Ye({id:Ge,version:nr,apiVersion:1,requires:{},provides:{features:["fps.editor.hierarchy"]},entries:{editor:"./editor"},environmentContracts:{editor:{requires:{services:["fps.editor.contributions"]},provides:{}}},deploymentConstraints:{allowedTargets:["editor"]}})}const Mr=Ze({pluginId:Ge,environment:"editor",register(e){tr(e,{id:or,kind:"hierarchy",value:ar()})}}),N=(e,r)=>({kind:"number",...e!=null?{min:e}:{},...r!=null?{max:r}:{}}),Y={kind:"texture"},Pe={kind:"color"},xr={kind:"enum",values:["lit","unlit"]},Or={kind:"enum",values:["opaque","mask","blend"]},Fe={lightingModel:xr,baseColor:{kind:"object",properties:{color:Pe,texture:Y,brightness:N(0),saturation:N(0),contrast:N(0),hue:N(-180,180)}},normal:{kind:"object",properties:{texture:Y,strength:N(0)}},emission:{kind:"object",properties:{color:Pe,intensity:N(0),texture:Y,maskTexture:Y}},alpha:{kind:"object",properties:{mode:Or,opacity:N(0,1),cutoff:N(0,1),texture:Y}}},Pr={kind:"object",properties:{...Fe,metallic:N(0,1),roughness:N(0,1),metallicRoughness:{kind:"object",properties:{texture:Y}},occlusion:{kind:"object",properties:{texture:Y,strength:N(0)}}}},Rr={kind:"object",properties:Fe},$r={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},metallic:0,roughness:1,emission:{color:{r:0,g:0,b:0},intensity:0}},Er={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},emission:{color:{r:0,g:0,b:0},intensity:0}},Re=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],Z={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},Te=[ne("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),ne("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),oe("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),H("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[re("properties.baseColor.texture.textureAssetId","baseTexture")]}),H("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[re("properties.baseColor.texture.textureAssetId","baseTexture")]}),H("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[re("properties.baseColor.texture.textureAssetId","baseTexture")]}),H("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[re("properties.baseColor.texture.textureAssetId","baseTexture")]}),oe("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[Z]),H("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Z,re("properties.normal.texture.textureAssetId","normalTexture")]}),ne("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),H("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),oe("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),ne("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),H("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),H("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),oe("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],zr=[...Te,H("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[Z]}),H("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[Z]}),oe("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[Z]),oe("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[Z]),H("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Z,re("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],Ke=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:Pr,defaultProperties:$r,inspector:{sections:Re,fields:zr}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Rr,defaultProperties:Er,inspector:{sections:Re,fields:Te}}];_e(Ke);function _e(e){const r=new Map;for(const n of e){kr(n,r);const i=Ar(n);r.set(n.shaderId,Ve(i))}const t=Object.freeze([...r.values()]);return Object.freeze({get(n){return typeof n=="string"?r.get(n)??null:null},list(){return t}})}function ne(e,r,t,n,i,o,p,c){return{path:e,sectionId:r,order:t,control:n,labelKey:i,tooltipKey:o,defaultValue:p,updateClass:"uniform",...c}}function H(e,r,t,n,i,o,p={}){return ne(e,r,t,"number",n,i,o,{binding:e.replace(/^properties\./,""),step:p.step??.05,displayPrecision:2,precision:2,...p})}function oe(e,r,t,n,i,o,p,c){return ne(e,t,n,"texture",i,o,"",{schemaPath:r,binding:p,updateClass:"texture",conditions:c})}function re(e,r){return{path:e,operator:"truthy",inactiveReasonKey:r}}function kr(e,r){if(!Je(e.shaderId)&&!Xe(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(r.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!Br(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);Ne(e.shaderId,e.propertiesSchema,"properties");const t=[];if(Le(e.propertiesSchema,e.defaultProperties,"properties",t),t.length>0){const o=t[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${o.path} ${o.message}.`)}const n=new Set;for(const o of e.inspector.sections){if(!o.id.trim()||n.has(o.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${o.id}`);n.add(o.id)}const i=new Set;for(const o of e.inspector.fields){if(!o.path.startsWith("properties.")||i.has(o.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${o.path}`);if(!n.has(o.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${o.path} references an unknown section.`);Cr(e,o),i.add(o.path)}}function Ar(e){const r=structuredClone(e);return{...r,inspector:{...r.inspector,fields:r.inspector.fields.map(t=>{if(t.control!=="number")return t;const n=He(r.propertiesSchema,t.schemaPath??t.path);return n?.kind!=="number"?t:{...t,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function Cr(e,r){const t=[["min",r.min],["max",r.max],["softMin",r.softMin],["softMax",r.softMax]];for(const[i,o]of t)if(o!=null&&!Number.isFinite(o))throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} ${i} must be finite.`);if(r.control!=="number"){if(t.some(([,i])=>i!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} uses numeric ranges with a non-number control.`);return}const n=He(e.propertiesSchema,r.schemaPath??r.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} must reference a number schema.`);for(const[i,o,p]of[["min",r.min,n.min],["max",r.max,n.max]])if(o!=null&&o!==p)throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} ${i} must match propertiesSchema.`);if(r.softMin!=null&&r.softMax!=null&&r.softMin>r.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} softMin must not exceed softMax.`);if(n.min!=null&&r.softMin!=null&&r.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} softMin must not be below the schema minimum.`);if(n.max!=null&&r.softMax!=null&&r.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} softMax must not exceed the schema maximum.`)}function Ne(e,r,t){if(r.kind==="object"){for(const[n,i]of Object.entries(r.properties))Ne(e,i,`${t}.${n}`);return}if(r.kind==="number"){if(r.min!=null&&!Number.isFinite(r.min))throw new Error(`Material Shader Definition ${e} number field ${t} min must be finite.`);if(r.max!=null&&!Number.isFinite(r.max))throw new Error(`Material Shader Definition ${e} number field ${t} max must be finite.`);if(r.min!=null&&r.max!=null&&r.min>r.max)throw new Error(`Material Shader Definition ${e} number field ${t} min must not exceed max.`);return}if(r.kind==="color"&&r.channels!=null&&r.channels!==3&&r.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${t} channels must be 3 or 4.`)}function Br(e){const r=e.trim();return!r||r.startsWith("/")||r.includes("\\")||r.includes(":")?!1:!r.split("/").includes("..")}function Gr(e){const r=e.trim();return r.startsWith("properties.")?r:`properties.${r}`}function He(e,r){const t=Gr(r).replace(/^properties\./,"").split(".").filter(Boolean);if(t.length===0)return null;let n=e;for(const i of t){if(n.kind!=="object")return null;const o=n.properties[i];if(!o)return null;n=o}return n}function Le(e,r,t,n){if(e.kind==="object"){if(!me(r)){n.push({path:t,message:"must be an object"});return}for(const o of Object.keys(r))Object.prototype.hasOwnProperty.call(e.properties,o)||n.push({path:`${t}.${o}`,message:"is not supported by the selected shader"});for(const[o,p]of Object.entries(e.properties))r[o]!==void 0&&Le(p,r[o],`${t}.${o}`,n);return}if(e.kind==="number"){if(typeof r!="number"||!Number.isFinite(r)){n.push({path:t,message:"must be a finite number"});return}e.min!=null&&r<e.min&&n.push({path:t,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&r>e.max&&n.push({path:t,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof r!="boolean"&&n.push({path:t,message:"must be a boolean"});return}if(e.kind==="string"){r!==null&&typeof r!="string"?n.push({path:t,message:"must be a string"}):r===null&&!e.nullable&&n.push({path:t,message:"must not be null"});return}if(e.kind==="enum"){(typeof r!="string"||!e.values.includes(r))&&n.push({path:t,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){const o=e.channels===4?["r","g","b","a"]:["r","g","b"];$e(r,t,o,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){$e(r,t,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(r===null)return;if(!me(r)){n.push({path:t,message:"must be a texture reference object or null"});return}Object.keys(r).some(o=>o!=="url"&&o!=="textureAssetId")&&n.push({path:t,message:"must contain only url or textureAssetId"});for(const o of["url","textureAssetId"]){const p=r[o];p!==void 0&&(typeof p!="string"||!p.trim())&&n.push({path:`${t}.${o}`,message:"must be a non-empty string"})}}function $e(e,r,t,n,i){if(!me(e)){n.push({path:r,message:`must be ${i}`});return}Object.keys(e).some(o=>!t.includes(o))&&n.push({path:r,message:`must contain only ${t.join(", ")}`});for(const o of t)(typeof e[o]!="number"||!Number.isFinite(e[o]))&&n.push({path:`${r}.${o}`,message:"must be a finite number"})}function Ve(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(const r of Object.values(e))Ve(r)}return e}function me(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const Fr=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Tr=Object.freeze([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ge(e){return _r(new TextEncoder().encode(e))}function Kr(e){return`sha256:${ge(JSON.stringify(e))}`}function _r(e){const r=Math.ceil((e.length+9)/64)*64,t=new Uint8Array(r);t.set(e),t[e.length]=128;const n=new DataView(t.buffer);n.setUint32(r-8,Math.floor(e.length/536870912),!1),n.setUint32(r-4,e.length*8>>>0,!1);const i=[...Fr],o=new Uint32Array(64);for(let p=0;p<t.length;p+=64){for(let x=0;x<16;x+=1)o[x]=n.getUint32(p+x*4,!1);for(let x=16;x<64;x+=1){const M=o[x-15],P=o[x-2],u=D(M,7)^D(M,18)^M>>>3,m=D(P,17)^D(P,19)^P>>>10;o[x]=o[x-16]+u+o[x-7]+m>>>0}let[c,I,b,v,O,g,E,A]=i;for(let x=0;x<64;x+=1){const M=D(O,6)^D(O,11)^D(O,25),P=O&g^~O&E,u=A+M+P+Tr[x]+o[x]>>>0,m=D(c,2)^D(c,13)^D(c,22),y=c&I^c&b^I&b,S=m+y>>>0;A=E,E=g,g=O,O=v+u>>>0,v=b,b=I,I=c,c=u+S>>>0}i[0]=i[0]+c>>>0,i[1]=i[1]+I>>>0,i[2]=i[2]+b>>>0,i[3]=i[3]+v>>>0,i[4]=i[4]+O>>>0,i[5]=i[5]+g>>>0,i[6]=i[6]+E>>>0,i[7]=i[7]+A>>>0}return i.map(p=>p.toString(16).padStart(8,"0")).join("")}function D(e,r){return e>>>r|e<<32-r}const Nr="fps.plugin.materials";function Hr(e){const r=e?.[Nr];if(r==null)return null;if(!te(r)||r.schemaVersion!==1||typeof r.snapshotId!="string"||!Array.isArray(r.shaders))throw new Error("Materials Plugin snapshot is invalid. Run fps-editor-prepare again.");const t=structuredClone(r);return Lr(t),Ue(t)}function De(e){return _e([...Ke,...e?.shaders.map(r=>r.definition)??[]])}function Lr(e){if(!/^sha256:[a-f0-9]{64}$/.test(e.snapshotId)||e.shaders.length===0)throw new Error("Materials Plugin snapshot identity is invalid. Run fps-editor-prepare again.");for(const t of e.shaders)if(!te(t)||!te(t.definition)||!te(t.program))throw new Error("Materials Plugin Shader snapshot is invalid. Run fps-editor-prepare again.");De(e);for(const t of e.shaders){const{definition:n,program:i}=t;if(i.shaderId!==n.shaderId||i.definitionVersion!==n.version)throw new Error(`Material snapshot Definition identity does not match its program: ${n.shaderId}`);if(i.language!=="glsl"||!Ee(i.vertexSourcePath)||!Ee(i.fragmentSourcePath)||!/^[a-f0-9]{64}$/.test(i.vertexSourceHash)||!/^[a-f0-9]{64}$/.test(i.fragmentSourceHash)||typeof i.vertexSource!="string"||!i.vertexSource.trim()||typeof i.fragmentSource!="string"||!i.fragmentSource.trim())throw new Error(`Material snapshot program is invalid: ${n.shaderId}`);if(ge(i.vertexSource)!==i.vertexSourceHash||ge(i.fragmentSource)!==i.fragmentSourceHash)throw new Error(`Material snapshot source hash does not match its GLSL content: ${n.shaderId}`);if(!Array.isArray(i.attributes)||i.attributes.length===0||i.attributes.some(o=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(o))||new Set(i.attributes).size!==i.attributes.length)throw new Error(`Material snapshot attributes are invalid: ${n.shaderId}`);if(!["opaque","combine","add"].includes(i.alphaMode)||!te(i.enumUniformValues)||!te(i.frame)||!["on-demand","continuous"].includes(i.frame.mode))throw new Error(`Material snapshot rendering policy is invalid: ${n.shaderId}`)}const r={schemaVersion:e.schemaVersion,shaders:e.shaders};if(Kr(r)!==e.snapshotId)throw new Error("Materials Plugin snapshot payload does not match its identity. Run fps-editor-prepare again.")}function Ee(e){return typeof e=="string"&&!!e&&!e.startsWith("/")&&!e.includes("\\")&&!e.includes(":")&&e.split("/").every(r=>!!r&&r!=="."&&r!=="..")}function Ue(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(const r of Object.values(e))Ue(r);return Object.freeze(e)}function te(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Vr(e){let r=0;const t=new WeakMap;return Object.freeze(e.shaders.map(({definition:n,program:i})=>Object.freeze({shaderId:n.shaderId,definitionVersion:n.version,snapshotId:e.snapshotId,createMaterial(o){const p=o.babylon,c=`${Yr(n.shaderId)}-${r+=1}`;if(!p.Effect?.ShadersStore||!p.ShaderMaterial||!p.StandardMaterial||!p.Color3)throw new Error(`Babylon ShaderMaterial is unavailable for ${n.shaderId}.`);ze(n,o.definitionVersion),p.Effect.ShadersStore[`${c}VertexShader`]=i.vertexSource,p.Effect.ShadersStore[`${c}FragmentShader`]=i.fragmentSource;const I=n.inspector.fields.filter(M=>M.updateClass==="uniform").map(M=>M.binding),b=[...new Set(["world","worldViewProjection",...i.frame.timeUniform?[i.frame.timeUniform]:[],...i.frame.cameraPositionUniform?[i.frame.cameraPositionUniform]:[],...I])];let v;try{v=new p.ShaderMaterial(c,o.scene,{vertex:c,fragment:c},{attributes:i.attributes,uniforms:b,needAlphaBlending:i.alphaMode!=="opaque"}),v.backFaceCulling=i.alphaMode==="opaque",v.alphaMode=i.alphaMode==="add"?p.Constants.ALPHA_ADD:i.alphaMode==="combine"?p.Constants.ALPHA_COMBINE:p.Constants.ALPHA_DISABLE,ke(p,v,n,i,o.properties)}catch(M){throw delete p.Effect.ShadersStore[`${c}VertexShader`],delete p.Effect.ShadersStore[`${c}FragmentShader`],v?.dispose?.(),M}const O=Dr(p,o.scene,c),g={material:v,mesh:o.mesh,setMaterial:o.setMaterial,placeholder:O,compiled:!1,disposed:!1,failed:!1,failure:null,compilation:null,invalidateFrameParticipant:null,shaderName:c,shadersStore:p.Effect.ShadersStore};t.set(O,g),t.set(v,g);const E=()=>{g.disposed||g.failed||g.compiled||(g.compiled=!0,g.setMaterial(g.material),qr(g.mesh))},A=M=>{g.disposed||g.failed||(g.failed=!0,g.failure=M,g.invalidateFrameParticipant?.(),g.setMaterial(g.placeholder),Ur(g.mesh,{code:"material.shaderCompilationFailed",severity:"error",shaderId:n.shaderId,definitionVersion:n.version,snapshotId:e.snapshotId,message:String(M??"Shader compilation failed.").slice(0,2048)}))};v.onCompiled=()=>{queueMicrotask(()=>{E()})},v.onError=(M,P)=>{A(P)};try{if(typeof v.forceCompilationAsync!="function")throw new Error("Babylon ShaderMaterial.forceCompilationAsync() is unavailable.");g.compilation=Promise.resolve(v.forceCompilationAsync(g.mesh)).then(()=>{if(g.failed)throw g.failure;E()}).catch(M=>{throw A(M),M})}catch(M){A(M),g.compilation=Promise.reject(M)}g.compilation.catch(()=>{}),O.forceCompilationAsync=()=>g.compilation;const x=O.dispose.bind(O);return O.dispose=(...M)=>{g.disposed||(g.disposed=!0,g.invalidateFrameParticipant?.(),delete g.shadersStore[`${g.shaderName}VertexShader`],delete g.shadersStore[`${g.shaderName}FragmentShader`],g.material.dispose?.(),x(...M))},O},updateMaterial(o){const p=o.babylon,c=Ae(o.material)?t.get(o.material):void 0;return!c||c.disposed||c.failed?!1:(ze(n,o.definitionVersion),ke(p,c.material,n,i,o.properties),!0)},...i.frame.mode==="continuous"?{createFrameParticipant(o){const p=o.babylon,c=Ae(o.material)?t.get(o.material):void 0;if(!c)throw new Error(`ShaderMaterial state is unavailable for ${n.shaderId}.`);let I=!1;const b=new Set;return c.invalidateFrameParticipant=()=>{for(const v of[...b])v()},{frameMode:"continuous",resolveFrameMode(){return c.failed||c.disposed||I?"on-demand":"continuous"},isActive(){return!c.failed&&!c.disposed&&!I},onFrameModeChanged(v){return b.add(v),()=>b.delete(v)},updateFrame(v){if(!(c.failed||c.disposed||I)&&(i.frame.timeUniform&&c.material.setFloat(i.frame.timeUniform,v.elapsedSeconds),i.frame.cameraPositionUniform)){const O=o.scene.activeCamera;c.material.setVector3(i.frame.cameraPositionUniform,O?.globalPosition??O?.position??p.Vector3.Zero())}},dispose(){I||(I=!0,b.clear(),c.invalidateFrameParticipant&&(c.invalidateFrameParticipant=null))}}}}:{}})))}function ze(e,r){if(r!==e.version)throw Object.assign(new Error(`Material Definition version mismatch for ${e.shaderId}: expected ${e.version}, received ${String(r)}.`),{code:"material.shaderDefinitionVersionMismatch",shaderId:e.shaderId,expectedVersion:e.version,actualVersion:r})}function Dr(e,r,t){const n=new e.StandardMaterial(`${t}.diagnostic`,r);return n.diffuseColor=new e.Color3(.8,.02,.45),n.emissiveColor=new e.Color3(.35,0,.12),n.specularColor=new e.Color3(0,0,0),n.backFaceCulling=!1,n}function Ur(e,r){const t=ie(e.metadata)?e.metadata:{},n=ie(t.editorProjection)?t.editorProjection:{};e.metadata={...t,editorProjection:{...n,materialDiagnostic:Object.freeze({...r})}}}function qr(e){if(!ie(e.metadata)||!ie(e.metadata.editorProjection)||!Object.prototype.hasOwnProperty.call(e.metadata.editorProjection,"materialDiagnostic"))return;const r={...e.metadata.editorProjection};delete r.materialDiagnostic,e.metadata={...e.metadata,editorProjection:r}}function ke(e,r,t,n,i){for(const o of t.inspector.fields){if(o.updateClass!=="uniform")continue;const p=Qr(i,o.path.replace(/^properties\./,""));if(o.control==="number")r.setFloat(o.binding,G(p,o.path));else if(o.control==="boolean")r.setFloat(o.binding,p===!0?1:0);else if(o.control==="enum"){const c=n.enumUniformValues[o.path],I=typeof p=="string"?c?.[p]:void 0;if(!Number.isFinite(I))throw new Error(`Enum uniform value is not mapped: ${o.path}=${String(p)}`);r.setFloat(o.binding,I)}else if(o.control==="color"){const c=fe(p,o.path);Wr(t,o.path)===4?r.setColor4(o.binding,new e.Color4(G(c.r,`${o.path}.r`),G(c.g,`${o.path}.g`),G(c.b,`${o.path}.b`),G(c.a,`${o.path}.a`))):r.setColor3(o.binding,new e.Color3(G(c.r,`${o.path}.r`),G(c.g,`${o.path}.g`),G(c.b,`${o.path}.b`)))}else if(o.control==="vec2"){const c=fe(p,o.path);r.setVector2(o.binding,new e.Vector2(G(c.x,`${o.path}.x`),G(c.y,`${o.path}.y`)))}else if(o.control==="vec3"){const c=fe(p,o.path);r.setVector3(o.binding,new e.Vector3(G(c.x,`${o.path}.x`),G(c.y,`${o.path}.y`),G(c.z,`${o.path}.z`)))}else throw new Error(`Unsupported ShaderMaterial uniform control: ${o.path} (${o.control})`)}}function Wr(e,r){let t=e.propertiesSchema;for(const n of r.replace(/^properties\./,"").split(".")){if(t.kind!=="object"||!t.properties[n])return 3;t=t.properties[n]}return t.kind==="color"&&t.channels===4?4:3}function Qr(e,r){let t=e;for(const n of r.split(".").filter(Boolean)){if(!ie(t))return;t=t[n]}return t}function fe(e,r){if(!ie(e))throw new Error(`Material property must be an object: ${r}`);return e}function G(e,r){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`Material property must be a finite number: ${r}`);return e}function Yr(e){return e.replace(/[^a-z0-9_-]/gi,"_")}function Ae(e){return!!e&&typeof e=="object"}function ie(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const qe=window.__FPS_EDITOR_PROJECT_DEFINITION__;if(!qe)throw new Error("Editor Project definition was not provided by the control plane.");const We=er(qe),ye=Hr(window.__FPS_EDITOR_PLUGIN_SNAPSHOTS__),Zr=De(ye),Ce=ye?Vr(ye):void 0,he=jr(),Jr=Object.freeze({environment:"editor",buildTarget:"editor",manifests:Object.freeze([he]),entries:Object.freeze([{pluginId:he.id,config:null,load:async()=>Mr}]),pluginConfigs:Object.freeze({...Object.fromEntries(We.plugins.map(e=>[e.pluginId,e.config])),[he.id]:null})}),Qe=await rr(We.project,{root:document.body,window,projectMode:{async enterEditorMode(){},async enterPlayMode(){const e=window.__FPS_EDITOR_RUNTIME_URL__;if(!e)throw new Error("Editor Runtime URL was not provided by the control plane.");window.location.assign(e)}},pluginModule:Jr,getCanvas:()=>document.querySelector("#renderCanvas"),materialShaderDefinitions:Zr,...Ce?{materialProjectionAdapters:Ce}:{}});await Qe.enterEditor();window.addEventListener("pagehide",()=>void Qe.dispose(),{once:!0});
|
|
1
|
+
import{fK as Ye,fJ as Je,jQ as Ze,i0 as Xe,mp as er,i$ as rr}from"./playable-standard-project-BA5pc2TZ.js";import{registerFpsEditorContribution as tr}from"@fps-games/editor-core/plugin-host";import"./dynamicTexture-Cuby-VOT.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const p of o.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&n(p)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();const nr="0.2.3-beta.9",or="fps.editor.surface.hierarchy",ir="fps.hierarchy.surface";function ar(){return Object.freeze({type:ir,id:"hierarchy",title:"层级",area:"left",toolbar:"scoped-hierarchy",createKernel:cr})}function sr(e){const{snapshot:r,targetId:t,modifier:n}=e;if(t===null)return r.capabilities.clearSelection?Object.freeze({selectedIds:Object.freeze([]),activeId:null,anchorId:null}):Object.freeze({selectedIds:r.selectedIds,activeId:r.activeId,anchorId:e.anchorId});if(r.nodeById.get(t)?.selectable!==!0)return Object.freeze({selectedIds:r.selectedIds,activeId:r.activeId,anchorId:e.anchorId});if(n==="toggle"){const i=new Set(r.selectedIds);i.has(t)?i.delete(t):i.add(t);const o=[...i];return Object.freeze({selectedIds:Object.freeze(o),activeId:i.has(t)?t:o[o.length-1]??null,anchorId:t})}if(n==="range"&&r.capabilities.rangeSelection&&e.anchorId){const i=e.projection.indexOf(e.anchorId),o=e.projection.indexOf(t);if(i>=0&&o>=0){const[p,c]=i<=o?[i,o]:[o,i],I=e.projection.getRange(p,c).filter(b=>r.nodeById.get(b)?.selectable===!0);return Object.freeze({selectedIds:Object.freeze(I),activeId:t,anchorId:e.anchorId})}}return Object.freeze({selectedIds:Object.freeze([t]),activeId:t,anchorId:t})}function cr(){const e=new Map,r=new Map,t=new Map,n=new WeakMap;let i=new WeakMap;const o=new Map,p=new Set;let c=[],I=null,b=null,v=0;const O=(a=c)=>{const d=a.flatMap(f=>{if(!f.canProvide())return[];const h=f.getSnapshot();return h?[{provider:f,snapshot:h}]:[]}).sort((f,h)=>(h.provider.priority??0)-(f.provider.priority??0)||f.provider.id.localeCompare(h.provider.id));if(d.length>1&&(d[0].provider.priority??0)===(d[1].provider.priority??0))throw new Error(`Ambiguous Hierarchy scope providers: ${d[0].provider.id}, ${d[1].provider.id}.`);return d[0]??null},g=()=>{const a=O(),d=a?.provider??null,f=a?.snapshot??null;f&&d&&hr(r,d,f);const h=f?.scopeKey??null;(I!==d||b!==h)&&(b&&Se(e.get(b)),h&&Se(e.get(h)),I=d,b=h,v+=1);const w=f&&d?we(o,d,f):null;return w&&Ir(E(w.scopeKey),w),w},E=a=>{const d=e.get(a);if(d)return d;const f={collapsedIds:new Set,searchQuery:"",selectionAnchorId:null,rename:null,dragId:null,revision:null,dragIds:[],observedActiveId:null,sanitizedStructureRevision:null,projectionRevision:0,selectionGeneration:0,renameGeneration:0,dragGeneration:0,pendingSelectionGeneration:null,pendingRenameGeneration:null,pendingDragGeneration:null};return e.set(a,f),f},A=(a,d)=>{const f=E(a.scopeKey),h=M(a,f,d),w=x(a,d,se(a,a.activeId),"view");return Object.freeze({providerId:d.id,authorityToken:v,snapshot:a,state:Oe(f,n),projection:h,operations:w})},x=(a,d,f,h)=>{let w=i.get(a);w||(w=new WeakMap,i.set(a,w));let s=w.get(d);s||(s=new Map,w.set(d,s));const R=`${h}\0${f.contextNodeId??""}\0${f.activeId??""}\0${f.targetIds.join("")}`,C=s.get(R);if(C)return C;const l=v,Z=Object.freeze([...d.listOperations(f)]),q=g();return v!==l||I!==d||q?.scopeKey!==a.scopeKey||q.revision!==a.revision?Object.freeze([]):(s.set(R,Z),Z)},M=(a,d,f)=>{const h=t.get(a.scopeKey);if(h&&h.provider===f&&h.structureRevision===a.structureRevision&&h.projectionRevision===d.projectionRevision)return h.projection;const w=br(a,d);return t.set(a.scopeKey,{provider:f,structureRevision:a.structureRevision,projectionRevision:d.projectionRevision,projection:w}),w},$=()=>{for(let a=0;a<=c.length+1;a+=1){const d=g(),f=I;if(!d||!f)return null;const h=v,w=A(d,f);if(v===h&&I===f&&b===d.scopeKey)return w}throw new Error("Hierarchy provider authority did not stabilize during operation discovery.")},u=a=>{const d=[];for(const f of p)try{f.render(a)}catch(h){d.push(h)}if(d.length>0)throw d[0]},m=()=>{u($())},y=a=>Object.freeze({ok:!0,changed:!1,revision:a?.revision??0,diagnostics:Object.freeze([])}),S=a=>{const d=Object.freeze({ok:!0,changed:!0,revision:a.revision,diagnostics:Object.freeze([])});try{return m(),d}catch(f){return pe(d,a.revision,f)}},j=async(a,d)=>{try{const f=wr(await a());return f.revision<d.revision?_(d.revision,"hierarchy.operation.revision-regressed",new Error(`Hierarchy operation revision regressed from ${d.revision} to ${f.revision}.`)):f}catch(f){return _(d.revision,"hierarchy.operation.failed",f)}},k={setProviders(a){const d=Object.freeze([...a]);dr(d);const f=c,h=I,w=b,s=v,R=pr(r),C=lr(e),l=new Map(t),Z=ur(o);let q;try{c=d,q=$()}catch(z){throw c=f,I=h,b=w,v=s,ce(r,R),ce(e,C),ce(t,l),ce(o,Z),z}for(const z of r.keys())d.includes(z)||r.delete(z);for(const[z,W]of o)d.includes(W.provider)||o.delete(z);u(q)},getProvider(){return g(),I},getViewModel:$,patchNodeLabels(a){const d=g(),f=I;if(!d||!f)return null;let h=o.get(d.scopeKey);(h?.provider!==f||h.structureRevision!==d.structureRevision)&&(h={provider:f,structureRevision:d.structureRevision,labels:new Map,sourceSnapshot:null,snapshot:null},o.set(d.scopeKey,h));for(const[w,s]of Object.entries(a))if(!s.trim()||!d.nodeById.has(w))return null;for(const[w,s]of Object.entries(a))h.labels.set(w,s);return h.sourceSnapshot=null,h.snapshot=null,t.delete(d.scopeKey),we(o,f,d)},listOperations(a,d){const f=I,h=b,w=g(),s=I;if((f!==s||h!==b)&&u($()),!w||!s||d!==void 0&&d!==v||a.scopeKey!==w.scopeKey||a.expectedRevision!==w.revision)return Object.freeze([]);const R=x(w,s,a,"explicit");return I!==s||b!==w.scopeKey?(u($()),Object.freeze([])):R},attachView(a){let d=null;try{d=a.bind(h=>k.dispatch(h)),p.add(a),a.render($())}catch(h){if(p.delete(a),d)try{d()}catch(w){const s=new Error(`Hierarchy ViewAdapter initialization failed: ${xe(h)}; cleanup failed: ${xe(w)}`);throw Object.assign(s,{retryCleanup:()=>d?.()}),s}throw h}let f=!0;return()=>{f&&(d?.(),p.delete(a),f=!1)}},refresh(){i=new WeakMap,m()},async dispatch(a){let d=b?fr(r,I,b)?.revision??e.get(b)?.revision??0:0;const f=a.type==="drag.commit"&&b?e.get(b)??null:null,h=f?.dragGeneration??null,w=f?.dragId??null;try{const s=g();d=s?.revision??0;const R=I,C=v;if(!s||!R)return _(s?.revision??0,"hierarchy.scope.unavailable",new Error("No active Hierarchy scope provider is available."));if(a.expectedAuthorityToken!==void 0&&a.expectedAuthorityToken!==C)return _(s.revision,"hierarchy.operation.provider-authority-changed",new Error("Hierarchy intent authority no longer matches the active provider."));if(a.expectedScopeKey!==void 0&&a.expectedScopeKey!==s.scopeKey||a.expectedRevision!==void 0&&a.expectedRevision!==s.revision)return _(s.revision,"hierarchy.operation.view-authority-changed",new Error("Hierarchy intent no longer matches the rendered scope revision."));const l=E(s.scopeKey),Z=x(s,R,se(s,s.activeId),"view");if(v!==C||I!==R||b!==s.scopeKey)return _(s.revision,"hierarchy.operation.provider-authority-changed",new Error("Hierarchy provider authority changed during operation discovery."));const q=Object.freeze({providerId:R.id,authorityToken:C,snapshot:s,state:Oe(l,n),projection:M(s,l,R),operations:Z});if(a.type==="search.change")return l.searchQuery===a.value?y(s):(l.searchQuery=a.value,l.projectionRevision+=1,S(s));if(a.type==="disclosure.toggle")return!s.nodeById.has(a.targetId)||!s.childrenByParentId.get(a.targetId)?.length?y(s):(l.collapsedIds.has(a.targetId)?l.collapsedIds.delete(a.targetId):l.collapsedIds.add(a.targetId),l.projectionRevision+=1,S(s));if(a.type==="disclosure.expand")return!s.nodeById.has(a.targetId)||!l.collapsedIds.delete(a.targetId)?y(s):(l.projectionRevision+=1,S(s));if(a.type==="disclosure.reveal"){if(!s.nodeById.has(a.targetId))return y(s);let P=!1,F=s.nodeById.get(a.targetId)?.parentId??null;for(;F;)P=l.collapsedIds.delete(F)||P,F=s.nodeById.get(F)?.parentId??null;return P?(l.projectionRevision+=1,S(s)):y(s)}if(a.type==="selection"||a.type==="selection.set"){const P=a.type==="selection"?sr({snapshot:s,targetId:a.targetId,modifier:a.modifier,projection:q.projection,anchorId:l.selectionAnchorId}):vr(s,a.selectedIds,a.activeId,a.anchorId),F=l.selectionAnchorId,L=++l.selectionGeneration;l.pendingSelectionGeneration=L;const U=await j(()=>R.applySelection(Object.freeze({...se(s,a.type==="selection"?a.targetId:a.activeId),selectedIds:P.selectedIds,activeId:P.activeId})),s);U.changed&&i.delete(s);let V;try{V=$()}catch(B){return l.pendingSelectionGeneration===L&&(l.pendingSelectionGeneration=null),de(U,s.revision,B)}const T=V?.snapshot??null,K=V?.authorityToken===C?je(U,s,T):Me(U,s.revision,C,V?.authorityToken??null);L===l.selectionGeneration&&T?.scopeKey===s.scopeKey&&T.revision===K.revision&&(l.revision=T.revision,l.selectionAnchorId=K.ok?P.anchorId:F),l.pendingSelectionGeneration===L&&(l.pendingSelectionGeneration=null);try{T&&I&&(V=A(T,I)),u(V)}catch(B){return pe(K,s.revision,B)}return K}if(a.type==="rename.begin"){const P=s.nodeById.get(a.targetId);return!s.readonly&&s.capabilities.rename&&P?.renamable&&P.editorLocked!==!0?(l.renameGeneration+=1,l.rename={id:P.id,value:P.label},S(s)):y(s)}if(a.type==="rename.change")return l.rename?(l.renameGeneration+=1,l.rename.value=a.value,S(s)):y(s);if(a.type==="rename.cancel")return l.renameGeneration+=1,l.rename=null,S(s);if(a.type==="drag.begin"){const P=s.nodeById.get(a.targetId);if(!s.readonly&&s.capabilities.reparent&&P?.draggable&&P.editorLocked!==!0){const F=q.projection.getTopLevelSelection(s.selectedIds.includes(a.targetId)?s.selectedIds:[a.targetId]).filter(L=>{const U=s.nodeById.get(L);return U?.draggable===!0&&U.editorLocked!==!0});return F.length===0?y(s):(l.dragGeneration+=1,l.dragId=a.targetId,l.dragIds=Object.freeze(F),S(s))}return y(s)}if(a.type==="drag.cancel")return l.dragGeneration+=1,l.dragId=null,l.dragIds=[],S(s);if(a.type==="context")return y(s);let z,W,Q=s.activeId;if(a.type==="primary"&&(z=s.primaryOperationId,Q=a.targetId),a.type==="rename.commit"&&l.rename&&(z="hierarchy.node.rename",W=Object.freeze({targetId:l.rename.id,name:l.rename.value}),Q=l.rename.id),a.type==="drag.commit"&&l.dragId&&(z=a.operationId,W=Object.freeze({...a.input??{},draggedIds:Object.freeze([...l.dragIds])}),Q=l.dragId),a.type==="operation.execute"){if(z=a.operationId,W=a.input,a.context&&(a.context.scopeKey!==s.scopeKey||a.context.expectedRevision!==s.revision))return _(s.revision,"hierarchy.operation.stale",new Error("Hierarchy operation context no longer matches the active scope revision."));Q=a.context?.contextNodeId??Q}if(!z)return y(s);const X=l.renameGeneration,le=l.dragGeneration;a.type==="rename.commit"&&(l.pendingRenameGeneration=X),a.type==="drag.commit"&&(l.pendingDragGeneration=le);const ve=a.type==="rename.commit"?l.rename?.id:a.type==="drag.commit"?l.dragId:null,be=a.type==="operation.execute"&&a.context?a.context:a.type==="drag.commit"?Object.freeze({...se(s,Q),targetIds:Object.freeze([...l.dragIds])}):se(s,Q);try{const P=x(s,R,be,"explicit"),F=g(),L=v!==C||I!==R||b!==s.scopeKey,U=F?.revision!==s.revision;if(L||U){try{u($())}catch{}return _(F?.revision??s.revision,L?"hierarchy.operation.provider-authority-changed":"hierarchy.operation.stale",new Error(L?"Hierarchy provider authority changed during operation discovery.":"Hierarchy scope revision changed during operation discovery."))}const V=P.find(ae=>ae.id===z);if(!V)return _(s.revision,"hierarchy.operation.unavailable",new Error(`Hierarchy operation is unavailable for this context: ${z}`));if(V.disabledReason)return _(s.revision,"hierarchy.operation.disabled",new Error(V.disabledReason));const T=await j(()=>R.executeOperation(Object.freeze({...be,operationId:z,...W?{input:W}:{}})),s);(T.ok||T.changed)&&i.delete(s);let K;try{K=$()}catch(ae){return a.type==="rename.commit"&&l.pendingRenameGeneration===X&&(l.pendingRenameGeneration=null),de(T,s.revision,ae)}const B=K?.snapshot??null,ee=K?.authorityToken===C?je(T,s,B):Me(T,s.revision,C,K?.authorityToken??null),ue=B?.scopeKey===s.scopeKey&&B.revision===ee.revision;ue&&B&&(l.revision=B.revision),ee.ok&&a.type==="rename.commit"&&ue&&l.renameGeneration===X&&l.rename?.id===ve&&(l.rename=null),!ee.ok&&ee.changed&&ue&&B&&B.revision!==s.revision&&a.type==="rename.commit"&&l.renameGeneration===X&&(l.rename=null),a.type==="rename.commit"&&l.pendingRenameGeneration===X&&(l.pendingRenameGeneration=null);try{B&&I&&(K=A(B,I)),u(K)}catch(ae){return pe(ee,s.revision,ae)}return ee}finally{if(a.type==="rename.commit"&&l.pendingRenameGeneration===X&&(l.pendingRenameGeneration=null),a.type==="drag.commit"&&l.pendingDragGeneration===le&&(l.pendingDragGeneration=null,l.dragGeneration===le&&l.dragId===ve)){l.dragId=null,l.dragIds=[];try{m()}catch{}}}}catch(s){return _(d,"hierarchy.operation.failed",s)}finally{if(f&&h!==null&&f.dragGeneration===h&&f.dragId===w){f.pendingDragGeneration=null,f.dragId=null,f.dragIds=[];try{m()}catch{}}}}};return k}function dr(e){const r=new Set;for(const t of e){if(!t.id.trim())throw new Error("Hierarchy scope provider id is required.");if(r.has(t.id))throw new Error(`Duplicate Hierarchy scope provider id: ${t.id}.`);r.add(t.id)}}function lr(e){return new Map([...e].map(([r,t])=>[r,{...t,collapsedIds:new Set(t.collapsedIds),rename:t.rename?{...t.rename}:null}]))}function ce(e,r){e.clear();for(const[t,n]of r)e.set(t,n)}function we(e,r,t){const n=e.get(t.scopeKey);if(!n)return t;if(n.provider!==r||n.structureRevision!==t.structureRevision)return e.delete(t.scopeKey),t;if(n.sourceSnapshot===t&&n.snapshot)return n.snapshot;const i=new Map(t.nodeById);let o=!1;for(const[c,I]of n.labels){const b=i.get(c);!b||b.label===I||(i.set(c,Object.freeze({...b,label:I})),o=!0)}const p=o?Object.freeze({...t,nodeById:Sr(i)}):t;return n.sourceSnapshot=t,n.snapshot=p,p}function ur(e){return new Map([...e].map(([r,t])=>[r,{...t,labels:new Map(t.labels)}]))}function pr(e){return new Map([...e].map(([r,t])=>[r,new Map(t)]))}function fr(e,r,t){return r?e.get(r)?.get(t):void 0}function hr(e,r,t){let n=e.get(r);n||(n=new Map,e.set(r,n));const i=n.get(t.scopeKey);if(i&&t.revision<i.revision)throw new Error(`Hierarchy scope ${t.scopeKey} revision regressed from ${i.revision} to ${t.revision}.`);if(i&&t.revision===i.revision&&!mr(i.snapshot,t))throw new Error(`Hierarchy scope ${t.scopeKey} reused revision ${t.revision} for a different authority snapshot.`);if(i&&t.structureRevision<i.structureRevision)throw new Error(`Hierarchy scope ${t.scopeKey} structureRevision regressed from ${i.structureRevision} to ${t.structureRevision}.`);if(i&&t.structureRevision===i.structureRevision&&(t.rootIds!==i.rootIds||t.nodeById!==i.nodeById||t.childrenByParentId!==i.childrenByParentId))throw new Error(`Hierarchy scope ${t.scopeKey} must structurally share tree indexes for structureRevision ${t.structureRevision}.`);(!i||t.revision>i.revision)&&n.set(t.scopeKey,{revision:t.revision,snapshot:t,structureRevision:t.structureRevision,rootIds:t.rootIds,nodeById:t.nodeById,childrenByParentId:t.childrenByParentId})}function mr(e,r){return e===r?!0:e.scopeType===r.scopeType&&e.structureRevision===r.structureRevision&&e.title===r.title&&e.searchPlaceholder===r.searchPlaceholder&&e.readonly===r.readonly&&e.rootIds===r.rootIds&&e.nodeById===r.nodeById&&e.childrenByParentId===r.childrenByParentId&&e.activeId===r.activeId&&e.primaryOperationId===r.primaryOperationId&&gr(e.selectedIds,r.selectedIds)&&yr(e.capabilities,r.capabilities)}function gr(e,r){return e.length===r.length&&e.every((t,n)=>t===r[n])}function yr(e,r){const t=new Set([...Object.keys(e),...Object.keys(r)]);for(const n of t)if(e[n]!==r[n])return!1;return!0}function se(e,r){return Object.freeze({scopeKey:e.scopeKey,expectedRevision:e.revision,contextNodeId:r,targetIds:e.selectedIds,activeId:e.activeId})}function Ir(e,r){if(e.revision!==null&&e.revision!==r.revision&&(e.pendingSelectionGeneration===null&&(e.selectionGeneration+=1),e.pendingRenameGeneration===null&&(e.renameGeneration+=1,e.rename=null),e.pendingDragGeneration===null&&(e.dragGeneration+=1,e.dragId=null,e.dragIds=[])),e.revision=r.revision,e.observedActiveId!==r.activeId){let t=!1;if(e.collapsedIds.size>0){let n=r.activeId?r.nodeById.get(r.activeId)?.parentId??null:null;for(;n;)t=e.collapsedIds.delete(n)||t,n=r.nodeById.get(n)?.parentId??null}t&&(e.projectionRevision+=1),e.observedActiveId=r.activeId}if(e.sanitizedStructureRevision!==r.structureRevision){e.selectionAnchorId&&!r.nodeById.has(e.selectionAnchorId)&&(e.selectionAnchorId=null),e.rename&&!r.nodeById.has(e.rename.id)&&(e.rename=null),e.dragId&&!r.nodeById.has(e.dragId)&&(e.dragId=null),e.dragIds=e.dragIds.filter(n=>r.nodeById.has(n)),(!e.dragId||e.dragIds.length===0)&&(e.dragId=null,e.dragIds=[]);let t=!1;for(const n of e.collapsedIds)r.nodeById.has(n)||(t=e.collapsedIds.delete(n)||t);t&&(e.projectionRevision+=1),e.sanitizedStructureRevision=r.structureRevision}}function Se(e){e&&(e.selectionGeneration+=1,e.renameGeneration+=1,e.dragGeneration+=1,e.pendingSelectionGeneration=null,e.pendingRenameGeneration=null,e.pendingDragGeneration=null,e.selectionAnchorId=null,e.rename=null,e.dragId=null,e.dragIds=[])}function vr(e,r,t,n){const i=Be(r).filter(c=>e.nodeById.get(c)?.selectable===!0),o=t&&i.includes(t)?t:i[0]??null,p=n&&e.nodeById.has(n)?n:o;return Object.freeze({selectedIds:Object.freeze(i),activeId:o,anchorId:p})}function br(e,r){const t=r.searchQuery.trim().toLocaleLowerCase(),n=t?new Set:null;if(n)for(const u of e.nodeById.values()){if(!u.label.toLocaleLowerCase().includes(t)&&!u.id.toLocaleLowerCase().includes(t))continue;let m=u;for(;m&&!n.has(m.id);)n.add(m.id),m=m.parentId?e.nodeById.get(m.parentId):void 0}const i=[],o=new Map,p=[...e.rootIds].reverse().map(u=>({id:u,depth:0}));for(;p.length>0;){const{id:u,depth:m}=p.pop();if(!e.nodeById.get(u)||n&&!n.has(u)||(o.set(u,i.length),i.push(Object.freeze({id:u,depth:m})),!n&&r.collapsedIds.has(u)))continue;const S=e.childrenByParentId.get(u)??[];for(let j=S.length-1;j>=0;j-=1)p.push({id:S[j],depth:m+1})}const c=Object.freeze(i),I=Object.freeze([]),b=new Map,v=new Map,O=new Map,g=(u,m,y)=>(u.size>256&&u.clear(),u.set(m,y),y),E=u=>{if(!u)return I;const m=b.get(u);if(m)return m;const y=[];let S=e.nodeById.get(u)?.parentId??null;for(;S;)y.push(S),S=e.nodeById.get(S)?.parentId??null;return g(b,u,Object.freeze(y))},A=u=>{const m=v.get(u);if(m)return m;v.size>256&&v.clear();const y=new Set(E(u));return v.set(u,y),y},x=u=>{const m=Be(u).filter(k=>e.nodeById.has(k));if(m.length===0)return I;const y=m.join("\0"),S=O.get(y);if(S)return S;if(m.length===1)return g(O,y,Object.freeze([...m]));const j=new Set(m);return g(O,y,Object.freeze(m.filter(k=>!E(k).some(a=>j.has(a)))))},M=(u,m)=>u!==m&&A(u).has(m),$=u=>{const m=x(u.draggedIds),y=h=>Object.freeze({ok:!1,reason:h,placement:u.placement,draggedIds:Object.freeze([]),targetId:u.targetId??null,parentId:null,beforeId:null,afterId:null});if(m.length===0)return y("empty-drag");for(const h of m){const w=e.nodeById.get(h);if(!w?.draggable||w.editorLocked===!0)return y("dragged-node-not-movable")}if(u.placement==="root")return Object.freeze({ok:!0,placement:"root",draggedIds:m,targetId:null,parentId:null,beforeId:null,afterId:null});const S=u.targetId??null,j=S?e.nodeById.get(S):void 0;if(!j)return y("missing-target");const k=new Set(m);if(k.has(j.id))return y("cannot-drop-on-self");if(m.some(h=>M(j.id,h)))return y("cannot-drop-on-descendant");if(u.placement==="inside"){if(j.editorLocked===!0)return y("target-node-locked");if(!j.canHaveChildren)return y("target-cannot-have-children");const h=(e.childrenByParentId.get(j.id)??[]).filter(w=>!k.has(w));return Object.freeze({ok:!0,placement:"inside",draggedIds:m,targetId:j.id,parentId:j.id,beforeId:null,afterId:h[h.length-1]??null})}if(j.role==="root")return y("cannot-reorder-root");if(j.editorLocked===!0)return y("target-node-locked");if((j.parentId?e.nodeById.get(j.parentId):void 0)?.editorLocked===!0)return y("target-parent-locked");const d=(e.childrenByParentId.get(j.parentId)??[]).filter(h=>!k.has(h)),f=d.indexOf(j.id);return Object.freeze({ok:!0,placement:u.placement,draggedIds:m,targetId:j.id,parentId:j.parentId,beforeId:u.placement==="before"?j.id:d[f+1]??null,afterId:u.placement==="after"?j.id:d[f-1]??null})};return Object.freeze({structureRevision:e.structureRevision,projectionRevision:r.projectionRevision,totalCount:c.length,indexOf(u){return u?o.get(u)??-1:-1},getRow(u){return Number.isInteger(u)&&u>=0?c[u]??null:null},getWindow(u,m){const y=Math.max(0,Math.trunc(u)),S=Math.max(0,Math.trunc(m));return Object.freeze(c.slice(y,y+S))},getRange(u,m){const y=Math.max(0,Math.min(Math.trunc(u),Math.trunc(m))),S=Math.min(c.length-1,Math.max(Math.trunc(u),Math.trunc(m)));return S<y?Object.freeze([]):Object.freeze(c.slice(y,S+1).map(j=>j.id))},getAncestors:E,getSelectableChildren(u){return Object.freeze(u?(e.childrenByParentId.get(u)??[]).filter(m=>e.nodeById.get(m)?.selectable===!0):[])},getSelectableDescendants(u){if(!u||!e.nodeById.has(u))return Object.freeze([]);const m=[],y=[...e.childrenByParentId.get(u)??[]].reverse();for(;y.length>0;){const S=y.pop();e.nodeById.get(S)?.selectable===!0&&m.push(S);const j=e.childrenByParentId.get(S)??[];for(let k=j.length-1;k>=0;k-=1)y.push(j[k])}return Object.freeze(m)},getTopLevelSelection:x,isDescendant:M,resolveDrop:$})}function wr(e){if(!e||typeof e!="object"||typeof e.ok!="boolean"||!Number.isSafeInteger(e.revision))throw new Error("Hierarchy provider returned an invalid operation result.");return Object.freeze({ok:e.ok,changed:e.changed===!0,revision:e.revision,diagnostics:Object.freeze([...e.diagnostics??[]])})}function _(e,r,t){return Object.freeze({ok:!1,changed:!1,revision:e,diagnostics:Object.freeze([Object.freeze({code:r,message:t instanceof Error?t.message:String(t),severity:"error"})])})}function de(e,r,t){const n=Ie(e);return Object.freeze({ok:!1,changed:e.changed||n,revision:Math.max(r,e.revision),diagnostics:Object.freeze([...e.diagnostics,Object.freeze({code:"hierarchy.snapshot.refresh-failed-after-operation",message:t instanceof Error?t.message:String(t),severity:"error"}),...n?[Object.freeze({code:"hierarchy.operation.commit-status-unknown",message:"The provider failed before the refreshed snapshot could confirm whether its authored change committed.",severity:"error"})]:[]])})}function pe(e,r,t){const n=Ie(e);return Object.freeze({ok:!1,changed:e.changed||n,revision:Math.max(r,e.revision),diagnostics:Object.freeze([...e.diagnostics,Object.freeze({code:"hierarchy.view.render-failed-after-change",message:t instanceof Error?t.message:String(t),severity:"error"}),...n?[Object.freeze({code:"hierarchy.operation.commit-status-unknown",message:"The provider failed before the refreshed snapshot could confirm whether its authored change committed.",severity:"error"})]:[]])})}function je(e,r,t){if(!t||t.scopeKey!==r.scopeKey)return de(e,r.revision,new Error(`Hierarchy scope ${r.scopeKey} was unavailable after the operation.`));if(t.revision<e.revision)return de(e,r.revision,new Error(`Hierarchy operation reported revision ${e.revision}, but the refreshed scope is still at ${t.revision}.`));if(t.revision===e.revision)return e;const n=!e.ok&&e.diagnostics.some(i=>i.code==="hierarchy.operation.failed")&&t.revision>r.revision;return Object.freeze({...e,changed:e.changed||n,revision:t.revision,diagnostics:Object.freeze([...e.diagnostics,Object.freeze({code:n?"hierarchy.operation.failed-after-revision-advanced":"hierarchy.operation.concurrent-revision-advanced",message:n?`The operation failed after the scope advanced from revision ${r.revision} to ${t.revision}; the authored result may already be committed.`:`The scope advanced to revision ${t.revision} while the operation completed.`,severity:n?"error":"info"})])})}function Me(e,r,t,n){const i=Ie(e);return Object.freeze({ok:!1,changed:e.changed||i,revision:Math.max(r,e.revision),diagnostics:Object.freeze([...e.diagnostics,Object.freeze({code:"hierarchy.operation.provider-authority-changed",message:`Hierarchy provider authority changed from token ${t} to ${n??"none"} while the operation was pending.`,severity:"error"}),...i?[Object.freeze({code:"hierarchy.operation.commit-status-unknown",message:"Provider authority changed before the failed operation could confirm whether its authored change committed.",severity:"error"})]:[]])})}function Ie(e){return e.diagnostics.some(r=>r.code==="hierarchy.operation.failed")}function xe(e){return e instanceof Error?e.message:String(e)}function Oe(e,r){const t=r.get(e);if(t&&t.projectionRevision===e.projectionRevision&&t.selectionGeneration===e.selectionGeneration&&t.renameGeneration===e.renameGeneration&&t.dragGeneration===e.dragGeneration&&t.selectionAnchorId===e.selectionAnchorId&&t.renameId===(e.rename?.id??null)&&t.renameValue===(e.rename?.value??null)&&t.dragId===e.dragId&&t.dragIds===e.dragIds)return t.snapshot;const n=Object.freeze({collapsedIds:t?.projectionRevision===e.projectionRevision?t.snapshot.collapsedIds:new Set(e.collapsedIds),searchQuery:e.searchQuery,selectionAnchorId:e.selectionAnchorId,rename:e.rename?Object.freeze({...e.rename}):null,dragId:e.dragId,dragIds:t?.dragGeneration===e.dragGeneration&&t.dragIds===e.dragIds?t.snapshot.dragIds:Object.freeze([...e.dragIds])});return r.set(e,{projectionRevision:e.projectionRevision,selectionGeneration:e.selectionGeneration,renameGeneration:e.renameGeneration,dragGeneration:e.dragGeneration,selectionAnchorId:e.selectionAnchorId,renameId:e.rename?.id??null,renameValue:e.rename?.value??null,dragId:e.dragId,dragIds:e.dragIds,snapshot:n}),n}function Be(e){return[...new Set(e.filter(r=>r.trim()))]}function Sr(e){let r;return r=Object.freeze({get size(){return e.size},has(t){return e.has(t)},get(t){return e.get(t)},entries(){return e.entries()},keys(){return e.keys()},values(){return e.values()},forEach(t,n){e.forEach((i,o)=>t.call(n,i,o,r))},[Symbol.iterator](){return e[Symbol.iterator]()}}),r}const Ge="fps.plugin.hierarchy";function jr(){return Ye({id:Ge,version:nr,apiVersion:1,requires:{},provides:{features:["fps.editor.hierarchy"]},entries:{editor:"./editor"},environmentContracts:{editor:{requires:{services:["fps.editor.contributions"]},provides:{}}},deploymentConstraints:{allowedTargets:["editor"]}})}const Mr=Je({pluginId:Ge,environment:"editor",register(e){tr(e,{id:or,kind:"hierarchy",value:ar()})}}),N=(e,r)=>({kind:"number",...e!=null?{min:e}:{},...r!=null?{max:r}:{}}),Y={kind:"texture"},$e={kind:"color"},xr={kind:"enum",values:["lit","unlit"]},Or={kind:"enum",values:["opaque","mask","blend"]},Fe={lightingModel:xr,baseColor:{kind:"object",properties:{color:$e,texture:Y,brightness:N(0),saturation:N(0),contrast:N(0),hue:N(-180,180)}},normal:{kind:"object",properties:{texture:Y,strength:N(0)}},emission:{kind:"object",properties:{color:$e,intensity:N(0),texture:Y,maskTexture:Y}},alpha:{kind:"object",properties:{mode:Or,opacity:N(0,1),cutoff:N(0,1),texture:Y}}},$r={kind:"object",properties:{...Fe,metallic:N(0,1),roughness:N(0,1),metallicRoughness:{kind:"object",properties:{texture:Y}},occlusion:{kind:"object",properties:{texture:Y,strength:N(0)}}}},Pr={kind:"object",properties:Fe},Rr={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},metallic:0,roughness:1,emission:{color:{r:0,g:0,b:0},intensity:0}},Er={lightingModel:"lit",baseColor:{color:{r:1,g:1,b:1},brightness:1,saturation:1,contrast:1,hue:0},emission:{color:{r:0,g:0,b:0},intensity:0}},Pe=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],J={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},Te=[ne("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),ne("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),oe("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),H("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[re("properties.baseColor.texture.textureAssetId","baseTexture")]}),H("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[re("properties.baseColor.texture.textureAssetId","baseTexture")]}),H("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[re("properties.baseColor.texture.textureAssetId","baseTexture")]}),H("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[re("properties.baseColor.texture.textureAssetId","baseTexture")]}),oe("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[J]),H("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[J,re("properties.normal.texture.textureAssetId","normalTexture")]}),ne("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),H("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),oe("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),ne("properties.alpha.mode","alpha",60,"enum","assetAlphaMode","alphaMode","opaque",{options:[{value:"opaque",labelKey:"assetAlphaModeOpaque"},{value:"mask",labelKey:"assetAlphaModeMask"},{value:"blend",labelKey:"assetAlphaModeBlend"}],binding:"alpha.mode",updateClass:"pipeline"}),H("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),H("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),oe("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],zr=[...Te,H("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[J]}),H("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[J]}),oe("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[J]),oe("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[J]),H("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[J,re("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],Ke=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:$r,defaultProperties:Rr,inspector:{sections:Pe,fields:zr}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Pr,defaultProperties:Er,inspector:{sections:Pe,fields:Te}}];_e(Ke);function _e(e){const r=new Map;for(const n of e){kr(n,r);const i=Ar(n);r.set(n.shaderId,Ve(i))}const t=Object.freeze([...r.values()]);return Object.freeze({get(n){return typeof n=="string"?r.get(n)??null:null},list(){return t}})}function ne(e,r,t,n,i,o,p,c){return{path:e,sectionId:r,order:t,control:n,labelKey:i,tooltipKey:o,defaultValue:p,updateClass:"uniform",...c}}function H(e,r,t,n,i,o,p={}){return ne(e,r,t,"number",n,i,o,{binding:e.replace(/^properties\./,""),step:p.step??.05,displayPrecision:2,precision:2,...p})}function oe(e,r,t,n,i,o,p,c){return ne(e,t,n,"texture",i,o,"",{schemaPath:r,binding:p,updateClass:"texture",conditions:c})}function re(e,r){return{path:e,operator:"truthy",inactiveReasonKey:r}}function kr(e,r){if(!Ze(e.shaderId)&&!Xe(e.shaderId))throw new Error("Material Shader Definition shaderId must be a supported built-in id or a lowercase namespaced project id.");if(!Number.isInteger(e.version)||e.version<=0)throw new Error(`Material Shader Definition ${e.shaderId} must use a positive integer version.`);if(r.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!Br(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);Ne(e.shaderId,e.propertiesSchema,"properties");const t=[];if(Le(e.propertiesSchema,e.defaultProperties,"properties",t),t.length>0){const o=t[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${o.path} ${o.message}.`)}const n=new Set;for(const o of e.inspector.sections){if(!o.id.trim()||n.has(o.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${o.id}`);n.add(o.id)}const i=new Set;for(const o of e.inspector.fields){if(!o.path.startsWith("properties.")||i.has(o.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${o.path}`);if(!n.has(o.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${o.path} references an unknown section.`);Cr(e,o),i.add(o.path)}}function Ar(e){const r=structuredClone(e);return{...r,inspector:{...r.inspector,fields:r.inspector.fields.map(t=>{if(t.control!=="number")return t;const n=He(r.propertiesSchema,t.schemaPath??t.path);return n?.kind!=="number"?t:{...t,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function Cr(e,r){const t=[["min",r.min],["max",r.max],["softMin",r.softMin],["softMax",r.softMax]];for(const[i,o]of t)if(o!=null&&!Number.isFinite(o))throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} ${i} must be finite.`);if(r.control!=="number"){if(t.some(([,i])=>i!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} uses numeric ranges with a non-number control.`);return}const n=He(e.propertiesSchema,r.schemaPath??r.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} must reference a number schema.`);for(const[i,o,p]of[["min",r.min,n.min],["max",r.max,n.max]])if(o!=null&&o!==p)throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} ${i} must match propertiesSchema.`);if(r.softMin!=null&&r.softMax!=null&&r.softMin>r.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} softMin must not exceed softMax.`);if(n.min!=null&&r.softMin!=null&&r.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} softMin must not be below the schema minimum.`);if(n.max!=null&&r.softMax!=null&&r.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${r.path} softMax must not exceed the schema maximum.`)}function Ne(e,r,t){if(r.kind==="object"){for(const[n,i]of Object.entries(r.properties))Ne(e,i,`${t}.${n}`);return}if(r.kind==="number"){if(r.min!=null&&!Number.isFinite(r.min))throw new Error(`Material Shader Definition ${e} number field ${t} min must be finite.`);if(r.max!=null&&!Number.isFinite(r.max))throw new Error(`Material Shader Definition ${e} number field ${t} max must be finite.`);if(r.min!=null&&r.max!=null&&r.min>r.max)throw new Error(`Material Shader Definition ${e} number field ${t} min must not exceed max.`);return}if(r.kind==="color"&&r.channels!=null&&r.channels!==3&&r.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${t} channels must be 3 or 4.`)}function Br(e){const r=e.trim();return!r||r.startsWith("/")||r.includes("\\")||r.includes(":")?!1:!r.split("/").includes("..")}function Gr(e){const r=e.trim();return r.startsWith("properties.")?r:`properties.${r}`}function He(e,r){const t=Gr(r).replace(/^properties\./,"").split(".").filter(Boolean);if(t.length===0)return null;let n=e;for(const i of t){if(n.kind!=="object")return null;const o=n.properties[i];if(!o)return null;n=o}return n}function Le(e,r,t,n){if(e.kind==="object"){if(!me(r)){n.push({path:t,message:"must be an object"});return}for(const o of Object.keys(r))Object.prototype.hasOwnProperty.call(e.properties,o)||n.push({path:`${t}.${o}`,message:"is not supported by the selected shader"});for(const[o,p]of Object.entries(e.properties))r[o]!==void 0&&Le(p,r[o],`${t}.${o}`,n);return}if(e.kind==="number"){if(typeof r!="number"||!Number.isFinite(r)){n.push({path:t,message:"must be a finite number"});return}e.min!=null&&r<e.min&&n.push({path:t,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&r>e.max&&n.push({path:t,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof r!="boolean"&&n.push({path:t,message:"must be a boolean"});return}if(e.kind==="string"){r!==null&&typeof r!="string"?n.push({path:t,message:"must be a string"}):r===null&&!e.nullable&&n.push({path:t,message:"must not be null"});return}if(e.kind==="enum"){(typeof r!="string"||!e.values.includes(r))&&n.push({path:t,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){const o=e.channels===4?["r","g","b","a"]:["r","g","b"];Re(r,t,o,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){Re(r,t,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(r===null)return;if(!me(r)){n.push({path:t,message:"must be a texture reference object or null"});return}Object.keys(r).some(o=>o!=="url"&&o!=="textureAssetId")&&n.push({path:t,message:"must contain only url or textureAssetId"});for(const o of["url","textureAssetId"]){const p=r[o];p!==void 0&&(typeof p!="string"||!p.trim())&&n.push({path:`${t}.${o}`,message:"must be a non-empty string"})}}function Re(e,r,t,n,i){if(!me(e)){n.push({path:r,message:`must be ${i}`});return}Object.keys(e).some(o=>!t.includes(o))&&n.push({path:r,message:`must contain only ${t.join(", ")}`});for(const o of t)(typeof e[o]!="number"||!Number.isFinite(e[o]))&&n.push({path:`${r}.${o}`,message:"must be a finite number"})}function Ve(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(const r of Object.values(e))Ve(r)}return e}function me(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const Fr=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Tr=Object.freeze([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ge(e){return _r(new TextEncoder().encode(e))}function Kr(e){return`sha256:${ge(JSON.stringify(e))}`}function _r(e){const r=Math.ceil((e.length+9)/64)*64,t=new Uint8Array(r);t.set(e),t[e.length]=128;const n=new DataView(t.buffer);n.setUint32(r-8,Math.floor(e.length/536870912),!1),n.setUint32(r-4,e.length*8>>>0,!1);const i=[...Fr],o=new Uint32Array(64);for(let p=0;p<t.length;p+=64){for(let x=0;x<16;x+=1)o[x]=n.getUint32(p+x*4,!1);for(let x=16;x<64;x+=1){const M=o[x-15],$=o[x-2],u=D(M,7)^D(M,18)^M>>>3,m=D($,17)^D($,19)^$>>>10;o[x]=o[x-16]+u+o[x-7]+m>>>0}let[c,I,b,v,O,g,E,A]=i;for(let x=0;x<64;x+=1){const M=D(O,6)^D(O,11)^D(O,25),$=O&g^~O&E,u=A+M+$+Tr[x]+o[x]>>>0,m=D(c,2)^D(c,13)^D(c,22),y=c&I^c&b^I&b,S=m+y>>>0;A=E,E=g,g=O,O=v+u>>>0,v=b,b=I,I=c,c=u+S>>>0}i[0]=i[0]+c>>>0,i[1]=i[1]+I>>>0,i[2]=i[2]+b>>>0,i[3]=i[3]+v>>>0,i[4]=i[4]+O>>>0,i[5]=i[5]+g>>>0,i[6]=i[6]+E>>>0,i[7]=i[7]+A>>>0}return i.map(p=>p.toString(16).padStart(8,"0")).join("")}function D(e,r){return e>>>r|e<<32-r}const Nr="fps.plugin.materials";function Hr(e){const r=e?.[Nr];if(r==null)return null;if(!te(r)||r.schemaVersion!==1||typeof r.snapshotId!="string"||!Array.isArray(r.shaders))throw new Error("Materials Plugin snapshot is invalid. Run fps-editor-prepare again.");const t=structuredClone(r);return Lr(t),Ue(t)}function De(e){return _e([...Ke,...e?.shaders.map(r=>r.definition)??[]])}function Lr(e){if(!/^sha256:[a-f0-9]{64}$/.test(e.snapshotId)||e.shaders.length===0)throw new Error("Materials Plugin snapshot identity is invalid. Run fps-editor-prepare again.");for(const t of e.shaders)if(!te(t)||!te(t.definition)||!te(t.program))throw new Error("Materials Plugin Shader snapshot is invalid. Run fps-editor-prepare again.");De(e);for(const t of e.shaders){const{definition:n,program:i}=t;if(i.shaderId!==n.shaderId||i.definitionVersion!==n.version)throw new Error(`Material snapshot Definition identity does not match its program: ${n.shaderId}`);if(i.language!=="glsl"||!Ee(i.vertexSourcePath)||!Ee(i.fragmentSourcePath)||!/^[a-f0-9]{64}$/.test(i.vertexSourceHash)||!/^[a-f0-9]{64}$/.test(i.fragmentSourceHash)||typeof i.vertexSource!="string"||!i.vertexSource.trim()||typeof i.fragmentSource!="string"||!i.fragmentSource.trim())throw new Error(`Material snapshot program is invalid: ${n.shaderId}`);if(ge(i.vertexSource)!==i.vertexSourceHash||ge(i.fragmentSource)!==i.fragmentSourceHash)throw new Error(`Material snapshot source hash does not match its GLSL content: ${n.shaderId}`);if(!Array.isArray(i.attributes)||i.attributes.length===0||i.attributes.some(o=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(o))||new Set(i.attributes).size!==i.attributes.length)throw new Error(`Material snapshot attributes are invalid: ${n.shaderId}`);if(!["opaque","combine","add"].includes(i.alphaMode)||!te(i.enumUniformValues)||!te(i.frame)||!["on-demand","continuous"].includes(i.frame.mode))throw new Error(`Material snapshot rendering policy is invalid: ${n.shaderId}`)}const r={schemaVersion:e.schemaVersion,shaders:e.shaders};if(Kr(r)!==e.snapshotId)throw new Error("Materials Plugin snapshot payload does not match its identity. Run fps-editor-prepare again.")}function Ee(e){return typeof e=="string"&&!!e&&!e.startsWith("/")&&!e.includes("\\")&&!e.includes(":")&&e.split("/").every(r=>!!r&&r!=="."&&r!=="..")}function Ue(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(const r of Object.values(e))Ue(r);return Object.freeze(e)}function te(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Vr(e){let r=0;const t=new WeakMap;return Object.freeze(e.shaders.map(({definition:n,program:i})=>Object.freeze({shaderId:n.shaderId,definitionVersion:n.version,snapshotId:e.snapshotId,createMaterial(o){const p=o.babylon,c=`${Yr(n.shaderId)}-${r+=1}`;if(!p.Effect?.ShadersStore||!p.ShaderMaterial||!p.StandardMaterial||!p.Color3)throw new Error(`Babylon ShaderMaterial is unavailable for ${n.shaderId}.`);ze(n,o.definitionVersion),p.Effect.ShadersStore[`${c}VertexShader`]=i.vertexSource,p.Effect.ShadersStore[`${c}FragmentShader`]=i.fragmentSource;const I=n.inspector.fields.filter(M=>M.updateClass==="uniform").map(M=>M.binding),b=[...new Set(["world","worldViewProjection",...i.frame.timeUniform?[i.frame.timeUniform]:[],...i.frame.cameraPositionUniform?[i.frame.cameraPositionUniform]:[],...I])];let v;try{v=new p.ShaderMaterial(c,o.scene,{vertex:c,fragment:c},{attributes:i.attributes,uniforms:b,needAlphaBlending:i.alphaMode!=="opaque"}),v.backFaceCulling=i.alphaMode==="opaque",v.alphaMode=i.alphaMode==="add"?p.Constants.ALPHA_ADD:i.alphaMode==="combine"?p.Constants.ALPHA_COMBINE:p.Constants.ALPHA_DISABLE,ke(p,v,n,i,o.properties)}catch(M){throw delete p.Effect.ShadersStore[`${c}VertexShader`],delete p.Effect.ShadersStore[`${c}FragmentShader`],v?.dispose?.(),M}const O=Dr(p,o.scene,c),g={material:v,mesh:o.mesh,setMaterial:o.setMaterial,placeholder:O,compiled:!1,disposed:!1,failed:!1,failure:null,compilation:null,invalidateFrameParticipant:null,shaderName:c,shadersStore:p.Effect.ShadersStore};t.set(O,g),t.set(v,g);const E=()=>{g.disposed||g.failed||g.compiled||(g.compiled=!0,g.setMaterial(g.material),qr(g.mesh))},A=M=>{g.disposed||g.failed||(g.failed=!0,g.failure=M,g.invalidateFrameParticipant?.(),g.setMaterial(g.placeholder),Ur(g.mesh,{code:"material.shaderCompilationFailed",severity:"error",shaderId:n.shaderId,definitionVersion:n.version,snapshotId:e.snapshotId,message:String(M??"Shader compilation failed.").slice(0,2048)}))};v.onCompiled=()=>{queueMicrotask(()=>{E()})},v.onError=(M,$)=>{A($)};try{if(typeof v.forceCompilationAsync!="function")throw new Error("Babylon ShaderMaterial.forceCompilationAsync() is unavailable.");g.compilation=Promise.resolve(v.forceCompilationAsync(g.mesh)).then(()=>{if(g.failed)throw g.failure;E()}).catch(M=>{throw A(M),M})}catch(M){A(M),g.compilation=Promise.reject(M)}g.compilation.catch(()=>{}),O.forceCompilationAsync=()=>g.compilation;const x=O.dispose.bind(O);return O.dispose=(...M)=>{g.disposed||(g.disposed=!0,g.invalidateFrameParticipant?.(),delete g.shadersStore[`${g.shaderName}VertexShader`],delete g.shadersStore[`${g.shaderName}FragmentShader`],g.material.dispose?.(),x(...M))},O},updateMaterial(o){const p=o.babylon,c=Ae(o.material)?t.get(o.material):void 0;return!c||c.disposed||c.failed?!1:(ze(n,o.definitionVersion),ke(p,c.material,n,i,o.properties),!0)},...i.frame.mode==="continuous"?{createFrameParticipant(o){const p=o.babylon,c=Ae(o.material)?t.get(o.material):void 0;if(!c)throw new Error(`ShaderMaterial state is unavailable for ${n.shaderId}.`);let I=!1;const b=new Set;return c.invalidateFrameParticipant=()=>{for(const v of[...b])v()},{frameMode:"continuous",resolveFrameMode(){return c.failed||c.disposed||I?"on-demand":"continuous"},isActive(){return!c.failed&&!c.disposed&&!I},onFrameModeChanged(v){return b.add(v),()=>b.delete(v)},updateFrame(v){if(!(c.failed||c.disposed||I)&&(i.frame.timeUniform&&c.material.setFloat(i.frame.timeUniform,v.elapsedSeconds),i.frame.cameraPositionUniform)){const O=o.scene.activeCamera;c.material.setVector3(i.frame.cameraPositionUniform,O?.globalPosition??O?.position??p.Vector3.Zero())}},dispose(){I||(I=!0,b.clear(),c.invalidateFrameParticipant&&(c.invalidateFrameParticipant=null))}}}}:{}})))}function ze(e,r){if(r!==e.version)throw Object.assign(new Error(`Material Definition version mismatch for ${e.shaderId}: expected ${e.version}, received ${String(r)}.`),{code:"material.shaderDefinitionVersionMismatch",shaderId:e.shaderId,expectedVersion:e.version,actualVersion:r})}function Dr(e,r,t){const n=new e.StandardMaterial(`${t}.diagnostic`,r);return n.diffuseColor=new e.Color3(.8,.02,.45),n.emissiveColor=new e.Color3(.35,0,.12),n.specularColor=new e.Color3(0,0,0),n.backFaceCulling=!1,n}function Ur(e,r){const t=ie(e.metadata)?e.metadata:{},n=ie(t.editorProjection)?t.editorProjection:{};e.metadata={...t,editorProjection:{...n,materialDiagnostic:Object.freeze({...r})}}}function qr(e){if(!ie(e.metadata)||!ie(e.metadata.editorProjection)||!Object.prototype.hasOwnProperty.call(e.metadata.editorProjection,"materialDiagnostic"))return;const r={...e.metadata.editorProjection};delete r.materialDiagnostic,e.metadata={...e.metadata,editorProjection:r}}function ke(e,r,t,n,i){for(const o of t.inspector.fields){if(o.updateClass!=="uniform")continue;const p=Qr(i,o.path.replace(/^properties\./,""));if(o.control==="number")r.setFloat(o.binding,G(p,o.path));else if(o.control==="boolean")r.setFloat(o.binding,p===!0?1:0);else if(o.control==="enum"){const c=n.enumUniformValues[o.path],I=typeof p=="string"?c?.[p]:void 0;if(!Number.isFinite(I))throw new Error(`Enum uniform value is not mapped: ${o.path}=${String(p)}`);r.setFloat(o.binding,I)}else if(o.control==="color"){const c=fe(p,o.path);Wr(t,o.path)===4?r.setColor4(o.binding,new e.Color4(G(c.r,`${o.path}.r`),G(c.g,`${o.path}.g`),G(c.b,`${o.path}.b`),G(c.a,`${o.path}.a`))):r.setColor3(o.binding,new e.Color3(G(c.r,`${o.path}.r`),G(c.g,`${o.path}.g`),G(c.b,`${o.path}.b`)))}else if(o.control==="vec2"){const c=fe(p,o.path);r.setVector2(o.binding,new e.Vector2(G(c.x,`${o.path}.x`),G(c.y,`${o.path}.y`)))}else if(o.control==="vec3"){const c=fe(p,o.path);r.setVector3(o.binding,new e.Vector3(G(c.x,`${o.path}.x`),G(c.y,`${o.path}.y`),G(c.z,`${o.path}.z`)))}else throw new Error(`Unsupported ShaderMaterial uniform control: ${o.path} (${o.control})`)}}function Wr(e,r){let t=e.propertiesSchema;for(const n of r.replace(/^properties\./,"").split(".")){if(t.kind!=="object"||!t.properties[n])return 3;t=t.properties[n]}return t.kind==="color"&&t.channels===4?4:3}function Qr(e,r){let t=e;for(const n of r.split(".").filter(Boolean)){if(!ie(t))return;t=t[n]}return t}function fe(e,r){if(!ie(e))throw new Error(`Material property must be an object: ${r}`);return e}function G(e,r){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`Material property must be a finite number: ${r}`);return e}function Yr(e){return e.replace(/[^a-z0-9_-]/gi,"_")}function Ae(e){return!!e&&typeof e=="object"}function ie(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const qe=window.__FPS_EDITOR_PROJECT_DEFINITION__;if(!qe)throw new Error("Editor Project definition was not provided by the control plane.");const We=er(qe),ye=Hr(window.__FPS_EDITOR_PLUGIN_SNAPSHOTS__),Jr=De(ye),Ce=ye?Vr(ye):void 0,he=jr(),Zr=Object.freeze({environment:"editor",buildTarget:"editor",manifests:Object.freeze([he]),entries:Object.freeze([{pluginId:he.id,config:null,load:async()=>Mr}]),pluginConfigs:Object.freeze({...Object.fromEntries(We.plugins.map(e=>[e.pluginId,e.config])),[he.id]:null})}),Qe=await rr(We.project,{root:document.body,window,projectMode:{async enterEditorMode(){},async enterPlayMode(){const e=window.__FPS_EDITOR_RUNTIME_URL__;if(!e)throw new Error("Editor Runtime URL was not provided by the control plane.");window.location.assign(e)}},pluginModule:Zr,getCanvas:()=>document.querySelector("#renderCanvas"),materialShaderDefinitions:Jr,...Ce?{materialProjectionAdapters:Ce}:{}});await Qe.enterEditor();window.addEventListener("pagehide",()=>void Qe.dispose(),{once:!0});
|
|
Binary file
|
|
Binary file
|