@fps-games/editor-deployment 0.2.3-beta.14 → 0.2.3-beta.16

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.
@@ -1,20 +1,20 @@
1
- import{EventEmitter as lP}from"node:events";var Ho="medium",sd={low:{opacity:.32,softness:.25,bias:.0015,normalBias:.02,maxDistance:24,resolution:512,cascadeCount:1,bakeSamples:8,blurKernel:2},medium:{opacity:.42,softness:.4,bias:.001,normalBias:.01,maxDistance:48,resolution:1024,cascadeCount:2,bakeSamples:24,blurKernel:4},high:{opacity:.5,softness:.58,bias:8e-4,normalBias:.006,maxDistance:80,resolution:2048,cascadeCount:4,bakeSamples:64,blurKernel:8},ultra:{opacity:.56,softness:.72,bias:6e-4,normalBias:.004,maxDistance:120,resolution:4096,cascadeCount:4,bakeSamples:128,blurKernel:12}};function hi(e=Ho,t={}){let r=sd[e]??sd[Ho];return{opacity:Ko(t.opacity,r.opacity),softness:Ko(t.softness,r.softness),bias:Ko(t.bias,r.bias),normalBias:Ko(t.normalBias,r.normalBias),maxDistance:Ko(t.maxDistance,r.maxDistance),resolution:SP(t.resolution,r.resolution),cascadeCount:yP(t.cascadeCount,r.cascadeCount),bakeSamples:gP(t.bakeSamples,r.bakeSamples),blurKernel:bP(t.blurKernel,r.blurKernel)}}function Ko(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function gP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):t}function bP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.round(e):t}function SP(e,t){return e===512||e===1024||e===2048||e===4096?e:t}function yP(e,t){return e===1||e===2||e===4?e:t}function Ei(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ii(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function Pi(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function Ti(e){return e==="inherit"||e==="none"||e==="dynamic"||e==="static"||e==="blob"||e==="projected"||e==="auto"}function xi(e){return e==="inherit"||e==="low"||e==="medium"||e==="high"||e==="ultra"}function Ai(e){return e==="inherit"||e==="scene-main"||e==="nearest"||e==="explicit"}function Sf(e){let t=Ei(e);if(!t)return;let r={};Ii(t.cast)&&(r.cast=t.cast),Pi(t.receive)&&(r.receive=t.receive),Ti(t.mode)&&(r.mode=t.mode),xi(t.quality)&&(r.quality=t.quality);let n=Ei(t.light);if(n){let a={};Ai(n.mode)&&(a.mode=n.mode),typeof n.lightId=="string"&&n.lightId.trim()&&(a.lightId=n.lightId.trim()),Object.keys(a).length>0&&(r.light=a)}let o=hP(t.params);return o&&(r.params=o),Object.keys(r).length>0?r:void 0}function He(e){let t=Sf(e);return t?{shadow:t,diagnostics:[]}:{diagnostics:[]}}function cd(e,t="none"){let r=e?.mode;return!r||r==="inherit"||r==="auto"?t:r}function dd(e,t=Ho){let r=e?.quality;return r&&r!=="inherit"?r:t}function hP(e){let t=Ei(e);if(!t)return;let r={};return typeof t.opacity=="number"&&Number.isFinite(t.opacity)&&(r.opacity=t.opacity),typeof t.softness=="number"&&Number.isFinite(t.softness)&&(r.softness=t.softness),typeof t.bias=="number"&&Number.isFinite(t.bias)&&(r.bias=t.bias),typeof t.normalBias=="number"&&Number.isFinite(t.normalBias)&&(r.normalBias=t.normalBias),typeof t.maxDistance=="number"&&Number.isFinite(t.maxDistance)&&(r.maxDistance=t.maxDistance),(t.resolution===512||t.resolution===1024||t.resolution===2048||t.resolution===4096)&&(r.resolution=t.resolution),(t.cascadeCount===1||t.cascadeCount===2||t.cascadeCount===4)&&(r.cascadeCount=t.cascadeCount),typeof t.bakeSamples=="number"&&Number.isFinite(t.bakeSamples)&&(r.bakeSamples=t.bakeSamples),typeof t.blurKernel=="number"&&Number.isFinite(t.blurKernel)&&(r.blurKernel=t.blurKernel),Object.keys(r).length>0?r:void 0}var EP=new Set(["cast","receive","mode","quality","light","params"]),IP=new Set(["mode","lightId"]),PP=new Set(["opacity","softness","bias","normalBias","maxDistance","resolution","cascadeCount","bakeSamples","blurKernel"]);function Wo(e,t="$.shadow"){let r=ud(e);if(!r)throw ve("schema.invalidType",t);if(ld(r,EP,t),"cast"in r&&!Ii(r.cast))throw ve("schema.invalidValue",`${t}.cast`);if("receive"in r&&!Pi(r.receive))throw ve("schema.invalidValue",`${t}.receive`);if("mode"in r&&!Ti(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("quality"in r&&!xi(r.quality))throw ve("schema.invalidValue",`${t}.quality`);"light"in r&&TP(r.light,`${t}.light`),"params"in r&&xP(r.params,`${t}.params`)}function TP(e,t){let r=ud(e);if(!r)throw ve("schema.invalidType",t);if(ld(r,IP,t),"mode"in r&&!Ai(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("lightId"in r&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`);if(r.mode==="explicit"&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`)}function xP(e,t){let r=ud(e);if(!r)throw ve("schema.invalidType",t);if(ld(r,PP,t),Wr(r,"opacity",t,n=>n>=0&&n<=1),Wr(r,"softness",t,n=>n>=0),Wr(r,"bias",t,()=>!0),Wr(r,"normalBias",t,()=>!0),Wr(r,"maxDistance",t,n=>n>0),Wr(r,"bakeSamples",t,n=>n>0),Wr(r,"blurKernel",t,n=>n>=0),"resolution"in r&&![512,1024,2048,4096].includes(r.resolution))throw ve("schema.invalidValue",`${t}.resolution`);if("cascadeCount"in r&&![1,2,4].includes(r.cascadeCount))throw ve("schema.invalidValue",`${t}.cascadeCount`)}function Wr(e,t,r,n){if(!(t in e))return;let o=e[t];if(typeof o!="number"||!Number.isFinite(o)||!n(o))throw ve("schema.invalidValue",`${r}.${t}`)}function ld(e,t,r){for(let n of Object.keys(e))if(!t.has(n))throw ve("schema.deprecatedField",`${r}.${n}`)}function ve(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function ud(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var gd="fps.shadow-map-experiment";function AP(e,t="$.scene.shadowMapExperiment"){let r=ft(e,t);Gt(r,["qualityProfile","behaviorProfile"],t),r.qualityProfile!==void 0&&vt(r.qualityProfile,`${t}.qualityProfile`),r.behaviorProfile!==void 0&&vt(r.behaviorProfile,`${t}.behaviorProfile`)}function DP(e,t="$.shadowMapExperiment"){let r=ft(e,t);Gt(r,["behaviorProfile"],t),vt(r.behaviorProfile,`${t}.behaviorProfile`)}function Mi(e,t="$"){let r=ft(e,t);Gt(r,["schemaVersion","enabled","lightRef","defaultQualityProfile","defaultBehaviorProfile","qualityProfiles","behaviorProfiles"],t),r.schemaVersion!==1&&H(`${t}.schemaVersion`,"expected 1"),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),vt(r.lightRef,`${t}.lightRef`);let n=vt(r.defaultQualityProfile,`${t}.defaultQualityProfile`),o=vt(r.defaultBehaviorProfile,`${t}.defaultBehaviorProfile`),a=hf(r.qualityProfiles,`${t}.qualityProfiles`),i=hf(r.behaviorProfiles,`${t}.behaviorProfiles`);for(let[s,c]of Object.entries(a))wP(c,`${t}.qualityProfiles.${s}`);for(let[s,c]of Object.entries(i))kP(c,`${t}.behaviorProfiles.${s}`);Object.prototype.hasOwnProperty.call(a,n)||H(`${t}.defaultQualityProfile`,`unknown quality profile: ${n}`),Object.prototype.hasOwnProperty.call(i,o)||H(`${t}.defaultBehaviorProfile`,`unknown behavior profile: ${o}`)}function Ef(e){Mi(e.config),e.settings!==void 0&&AP(e.settings),(!Number.isInteger(e.revision)||e.revision<0)&&H("$.revision","expected a non-negative integer");let t=e.settings?.qualityProfile??e.config.defaultQualityProfile,r=e.settings?.behaviorProfile??e.config.defaultBehaviorProfile,n=fd(e.config.qualityProfiles,t,"$.settings.qualityProfile","quality");fd(e.config.behaviorProfiles,r,"$.settings.behaviorProfile","behavior");let o=e.objects.map((s,c)=>{let d=`$.objects[${c}]`;s.override!==void 0&&DP(s.override,`${d}.override`);let u=s.override?.behaviorProfile??r,l=fd(e.config.behaviorProfiles,u,`${d}.override.behaviorProfile`,"behavior");return Object.freeze({entityId:vt(s.entityId,`${d}.entityId`),renderableIds:Object.freeze(FP(s.renderableIds,`${d}.renderableIds`)),cast:yf(s.cast,`${d}.cast`)??l.cast==="enabled",receive:yf(s.receive,`${d}.receive`)??l.receive==="enabled",updateClass:l.updateClass!=="auto"?l.updateClass:s.inferredUpdateClass??"static",behaviorProfileId:u})}).sort((s,c)=>s.entityId.localeCompare(c.entityId)),a=e.config.enabled?o:[];jP(a);let i=Object.fromEntries(Object.entries(e.config.behaviorProfiles).sort(([s],[c])=>s.localeCompare(c)).map(([s,c])=>[s,Object.freeze({cast:c.cast==="enabled",receive:c.receive==="enabled",updateClass:c.updateClass})]));return If({schemaVersion:3,revision:e.revision,enabled:e.config.enabled,scopeId:vt(e.scopeId,"$.scopeId"),light:{entityId:e.config.lightRef,direction:Jo(e.lightDirection,"$.lightDirection")},qualityProfileId:t,generator:{maps:{...n.maps},...n.cascadeCount===void 0?{}:{cascadeCount:n.cascadeCount},filter:n.receiverFilter,bias:n.bias,normalBias:n.normalBias,darkness:n.darkness,...n.softness===void 0?{}:{softness:n.softness},bounds:NP(n.bounds),backend:{...n.backend}},culling:{...n.culling},diagnosticThresholds:{...n.diagnostics},behaviorProfiles:i,objects:a,diagnostics:[]})}function yf(e,t){if(e!==void 0)return typeof e!="boolean"&&H(t,"expected a boolean"),e}function MP(e,t){let r=ft(e,t);Gt(r,["mode","center","extent","near","far"],t),r.mode!=="fixed"&&H(`${t}.mode`,"expected fixed"),Jo(r.center,`${t}.center`),Jo(r.extent,`${t}.extent`).some(i=>i<=0)&&H(`${t}.extent`,"expected positive values");let o=Di(r.near,`${t}.near`),a=Di(r.far,`${t}.far`);(o<0||a<=o)&&H(t,"expected 0 <= near < far")}function wP(e,t){let r=ft(e,t);Gt(r,["maps","cascadeCount","receiverFilter","bias","normalBias","darkness","softness","bounds","backend","culling","diagnostics"],t),OP(r.maps,`${t}.maps`),r.cascadeCount!==void 0&&RP(r.cascadeCount,`${t}.cascadeCount`),r.receiverFilter!=="hard"&&r.receiverFilter!=="low-pcf"&&H(`${t}.receiverFilter`,"expected hard or low-pcf"),qo(r.bias,`${t}.bias`,0,.1),qo(r.normalBias,`${t}.normalBias`,0,1),qo(r.darkness,`${t}.darkness`,0,1),r.softness!==void 0&&qo(r.softness,`${t}.softness`,0,1),MP(r.bounds,`${t}.bounds`),CP(r.backend,`${t}.backend`),vP(r.culling,`${t}.culling`),GP(r.diagnostics,`${t}.diagnostics`)}function kP(e,t){let r=ft(e,t);Gt(r,["cast","receive","updateClass"],t),r.cast!=="enabled"&&r.cast!=="disabled"&&H(`${t}.cast`,"expected enabled or disabled"),r.receive!=="enabled"&&r.receive!=="disabled"&&H(`${t}.receive`,"expected enabled or disabled"),["auto","static","dynamic","skinned"].includes(String(r.updateClass))||H(`${t}.updateClass`,"expected auto, static, dynamic, or skinned")}function OP(e,t){let r=ft(e,t);Gt(r,["staticResolution","dynamicResolution","compositeResolution"],t),md(r.staticResolution,`${t}.staticResolution`),md(r.dynamicResolution,`${t}.dynamicResolution`),md(r.compositeResolution,`${t}.compositeResolution`)}function md(e,t){e!==512&&e!==1024&&e!==2048&&e!==4096&&H(t,"expected 512, 1024, 2048, or 4096")}function RP(e,t){e!==1&&e!==2&&e!==4&&H(t,"expected 1, 2, or 4")}function CP(e,t){let r=ft(e,t);Gt(r,["mode","fallback"],t),["auto","split","single"].includes(String(r.mode))||H(`${t}.mode`,"expected auto, split, or single"),r.fallback!=="single-map"&&r.fallback!=="disable"&&H(`${t}.fallback`,"expected single-map or disable")}function vP(e,t){let r=ft(e,t);Gt(r,["enabled","guardBandRatio"],t),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),qo(r.guardBandRatio,`${t}.guardBandRatio`,0,4)}function GP(e,t){let r=ft(e,t);Gt(r,["staticCasterCountWarning","dynamicCasterCountWarning","renderableCountWarning"],t),pd(r.staticCasterCountWarning,`${t}.staticCasterCountWarning`),pd(r.dynamicCasterCountWarning,`${t}.dynamicCasterCountWarning`),pd(r.renderableCountWarning,`${t}.renderableCountWarning`)}function jP(e){let t=new Set,r=new Set;for(let n of e){t.has(n.entityId)&&H("$.objects",`duplicate entity id: ${n.entityId}`),t.add(n.entityId);for(let o of n.renderableIds)r.has(o)&&H("$.objects",`duplicate renderable id: ${o}`),r.add(o)}}function hf(e,t){let r=ft(e,t);Object.keys(r).length===0&&H(t,"expected at least one profile");for(let n of Object.keys(r))vt(n,`${t} key`);return r}function fd(e,t,r,n){return Object.prototype.hasOwnProperty.call(e,t)||H(r,`unknown ${n} profile: ${t}`),e[t]}function NP(e){return Object.freeze({mode:"fixed",center:Jo(e.center,"$.bounds.center"),extent:Jo(e.extent,"$.bounds.extent"),near:e.near,far:e.far})}function Jo(e,t){let r=_P(e,t);return r.length!==3&&H(t,"expected exactly three numbers"),Object.freeze(r.map((n,o)=>Di(n,`${t}[${o}]`)))}function FP(e,t){let r=e.map((n,o)=>vt(n,`${t}[${o}]`));return new Set(r).size!==r.length&&H(t,"expected unique strings"),r}function Di(e,t){return(typeof e!="number"||!Number.isFinite(e))&&H(t,"expected a finite number"),e}function qo(e,t,r,n){let o=Di(e,t);return(o<r||o>n)&&H(t,`expected ${r}..${n}`),o}function pd(e,t){return(!Number.isInteger(e)||e<0)&&H(t,"expected a non-negative integer"),e}function vt(e,t){return(typeof e!="string"||!e.trim()||e!==e.trim())&&H(t,"expected a trimmed non-empty string"),e}function ft(e,t){(!e||typeof e!="object"||Array.isArray(e))&&H(t,"expected an object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&H(t,"expected a plain object"),e}function _P(e,t){return Array.isArray(e)||H(t,"expected an array"),e}function Gt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||H(`${r}.${o}`,"unknown field")}function If(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))If(t);return Object.freeze(e)}function H(e,t){throw new Error(`shadow_map_experiment_invalid:${e}:${t}`)}var Pf=["useBlobShadow","blobSettings"],$P=["resolution","maxSize"],LP=new Set(["none","blob","static","planar","dynamic"]);function gt(e){let t=qr(e);if(!t)throw X("schema.invalidType","$");for(let o of Pf)if(Object.prototype.hasOwnProperty.call(t,o))throw X("schema.deprecatedField",`$.${o}`);if(q(t,["globalVolume","materials","renderingGroups","shadowMeshes","shadows"],"$"),VP(t.globalVolume,"$.globalVolume"),UP(t.materials,"$.materials"),zP(t.renderingGroups,"$.renderingGroups"),BP(t.globalVolume,"$.globalVolume"),XP(t.shadowMeshes,"$.shadowMeshes"),!Object.prototype.hasOwnProperty.call(t,"shadows"))return;let r=qr(t.shadows);if(!r)throw X("schema.invalidType","$.shadows");for(let o of Pf)if(Object.prototype.hasOwnProperty.call(r,o))throw X("schema.deprecatedField",`$.shadows.${o}`);if(q(r,["defaultMode","enabled","useCsm","settings","blob","staticProjected","planar","shadowRange","shadowOrtho","csm"],"$.shadows"),"defaultMode"in r&&!LP.has(String(r.defaultMode)))throw X("schema.invalidValue","$.shadows.defaultMode");Ge(r,"enabled","$.shadows"),Ge(r,"useCsm","$.shadows");let n=qr(r.settings);if(Object.prototype.hasOwnProperty.call(r,"settings")&&!n)throw X("schema.invalidType","$.shadows.settings");if(n){q(n,["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ","useBlurExponentialShadowMap","shadowColor"],"$.shadows.settings");for(let o of["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ"])Ae(n,o,"$.shadows.settings");Ge(n,"useBlurExponentialShadowMap","$.shadows.settings"),wi(n.shadowColor,"$.shadows.settings.shadowColor",!1)}HP(r.blob,"$.shadows.blob"),WP(r.staticProjected,"$.shadows.staticProjected"),qP(r.planar,"$.shadows.planar"),Jr(r.shadowRange,"$.shadows.shadowRange",["minZ","maxZ"]),Jr(r.shadowOrtho,"$.shadows.shadowOrtho",["left","right","top","bottom"]),JP(r.csm,"$.shadows.csm")}function zP(e,t){if(e===void 0)return;let r=qr(e);if(!r||!Array.isArray(r.slots))throw X("schema.invalidType",t);q(r,["slots"],t),r.slots.forEach((n,o)=>{let a=`${t}.slots[${o}]`,i=qr(n);if(!i)throw X("schema.invalidType",a);if(q(i,["renderingGroupId","name","alphaIndexPresets"],a),![0,1,2,3].includes(i.renderingGroupId))throw X("schema.invalidValue",`${a}.renderingGroupId`);if(typeof i.name!="string"||!i.name.trim())throw X("schema.invalidValue",`${a}.name`);if(!Array.isArray(i.alphaIndexPresets))throw X("schema.invalidType",`${a}.alphaIndexPresets`);i.alphaIndexPresets.forEach((s,c)=>{let d=`${a}.alphaIndexPresets[${c}]`,u=qr(s);if(!u)throw X("schema.invalidType",d);if(q(u,["name","alphaIndex"],d),typeof u.name!="string"||!u.name.trim())throw X("schema.invalidValue",`${d}.name`);Sd(u,"alphaIndex",d)})})}function BP(e,t){if(e===void 0)return;let r=Se(e,t);for(let a of["samples","camera","lights"])if(a in r)throw X("schema.deprecatedField",`${t}.${a}`);if(q(r,["enabled","hdr","environment","imageProcessing","toneMapping","antialiasing","postProcessing","rendering","textures"],t),Ge(r,"enabled",t),Ge(r,"hdr",t),r.environment!==void 0){let a=Se(r.environment,`${t}.environment`);for(let i of["textureAssetId","textureUrl","intensity"])if(i in a)throw X("schema.deprecatedField",`${t}.environment.${i}`);if(q(a,["texture","iblIntensity","rotationY","useCocosIBL"],`${t}.environment`),a.texture!==void 0&&a.texture!==null){let i=Se(a.texture,`${t}.environment.texture`);for(let s of Object.keys(i))if(s!=="textureAssetId"&&s!=="url")throw X("schema.deprecatedField",`${t}.environment.texture.${s}`);for(let s of["textureAssetId","url"])if(s in i&&i[s]!=null&&(typeof i[s]!="string"||!i[s].trim()))throw X("schema.invalidValue",`${t}.environment.texture.${s}`)}Ae(a,"iblIntensity",`${t}.environment`),Ae(a,"rotationY",`${t}.environment`),Ge(a,"useCocosIBL",`${t}.environment`)}if(Jr(r.imageProcessing,`${t}.imageProcessing`,["exposure","contrast"]),r.toneMapping!==void 0){let a=Se(r.toneMapping,`${t}.toneMapping`);if(q(a,["enabled","type"],`${t}.toneMapping`),Ge(a,"enabled",`${t}.toneMapping`),"type"in a&&!["standard","aces","khr-pbr-neutral"].includes(String(a.type)))throw X("schema.invalidValue",`${t}.toneMapping.type`)}if(r.antialiasing!==void 0){let a=Se(r.antialiasing,`${t}.antialiasing`);if(q(a,["samples"],`${t}.antialiasing`),"samples"in a&&![1,2,4,8].includes(a.samples))throw X("schema.invalidValue",`${t}.antialiasing.samples`)}let n=pt(r.postProcessing,`${t}.postProcessing`);n&&q(n,["bloom"],`${t}.postProcessing`);let o=n?pt(n.bloom,`${t}.postProcessing.bloom`):null;if(o){q(o,["enabled","threshold","weight","kernel","scale"],`${t}.postProcessing.bloom`),Ge(o,"enabled",`${t}.postProcessing.bloom`);for(let a of["threshold","weight","kernel","scale"])Ae(o,a,`${t}.postProcessing.bloom`)}}function VP(e,t){if(e===void 0)return;let r=Se(e,t),n=pt(r.rendering,`${t}.rendering`);n&&(q(n,["maxDpr","hardwareScalingLevel"],`${t}.rendering`),Ae(n,"maxDpr",`${t}.rendering`),KP(n,"hardwareScalingLevel",`${t}.rendering`));let o=pt(r.textures,`${t}.textures`);if(o&&(q(o,["anisotropicFilteringLevel","samplingMode"],`${t}.textures`),Ae(o,"anisotropicFilteringLevel",`${t}.textures`),"samplingMode"in o&&(typeof o.samplingMode!="string"||!o.samplingMode.trim())))throw X("schema.invalidValue",`${t}.textures.samplingMode`)}function UP(e,t){if(e===void 0)return;let r=Se(e,t);q(r,["sceneMaterials","plantMaterials"],t);for(let n of["sceneMaterials","plantMaterials"])n in r&&Se(r[n],`${t}.${n}`)}function KP(e,t,r){!(t in e)||e[t]==null||Ae(e,t,r)}function HP(e,t){if(e===void 0)return;let r=Se(e,t);q(r,["enabled","plane","appearance","size"],t),Ge(r,"enabled",t),Jr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);n&&(q(n,["color","edgeSoftness"],`${t}.appearance`),wi(n.color,`${t}.appearance.color`,!0),Ae(n,"edgeSoftness",`${t}.appearance`)),Jr(r.size,`${t}.size`,["sizeMultiplier","minSize","maxSize"])}function WP(e,t){if(e===void 0)return;let r=Se(e,t);q(r,["enabled","plane","appearance","bake"],t),Ge(r,"enabled",t),Jr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);if(n&&(q(n,["color"],`${t}.appearance`),wi(n.color,`${t}.appearance.color`,!0)),r.bake===void 0)return;let o=Se(r.bake,`${t}.bake`);for(let a of $P)if(a in o)throw X("schema.deprecatedField",`${t}.bake.${a}`);q(o,["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"],`${t}.bake`);for(let a of["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"])Ae(o,a,`${t}.bake`)}function qP(e,t){if(e===void 0)return;let r=Se(e,t);q(r,["enabled","plane","appearance","projection","stencil","casters","receivers"],t),Ge(r,"enabled",t);let n=pt(r.plane,`${t}.plane`);if(n){q(n,["normal","height","bias","heightMode"],`${t}.plane`),YP(n.normal,`${t}.plane.normal`);for(let c of["height","bias"])Ae(n,c,`${t}.plane`);if("heightMode"in n&&!["fixed","receiver"].includes(String(n.heightMode)))throw X("schema.invalidValue",`${t}.plane.heightMode`)}let o=pt(r.appearance,`${t}.appearance`);o&&(q(o,["color"],`${t}.appearance`),wi(o.color,`${t}.appearance.color`,!0)),Jr(r.projection,`${t}.projection`,["footprintScale"]);let a=pt(r.stencil,`${t}.stencil`);if(a){q(a,["enabled","receiverRenderingGroup","shadowRenderingGroup"],`${t}.stencil`),Ge(a,"enabled",`${t}.stencil`);for(let c of["receiverRenderingGroup","shadowRenderingGroup"])Ae(a,c,`${t}.stencil`)}let i=pt(r.casters,`${t}.casters`);if(i){q(i,["autoDetectAll","includePatterns","excludePatterns","rootBoundaryPatterns","minVolume"],`${t}.casters`),Ge(i,"autoDetectAll",`${t}.casters`);for(let c of["includePatterns","excludePatterns","rootBoundaryPatterns"])bd(i[c],`${t}.casters.${c}`);Ae(i,"minVolume",`${t}.casters`)}let s=pt(r.receivers,`${t}.receivers`);s&&(q(s,["patterns"],`${t}.receivers`),bd(s.patterns,`${t}.receivers.patterns`))}function JP(e,t){if(e===void 0)return;let r=Se(e,t);q(r,["numCascades","lambda","cascadeBlendPercentage","stabilizeCascades"],t);for(let n of["numCascades","lambda","cascadeBlendPercentage"])Ae(r,n,t);Ge(r,"stabilizeCascades",t)}function XP(e,t){if(e===void 0)return;let r=Se(e,t);q(r,["shadowReceivers","shadowCasters","excludeFromShadow"],t);for(let n of["shadowReceivers","shadowCasters","excludeFromShadow"])bd(r[n],`${t}.${n}`)}function Jr(e,t,r){if(e===void 0)return;let n=Se(e,t);q(n,r,t);for(let o of r)Ae(n,o,t)}function wi(e,t,r){if(e===void 0)return;let n=Se(e,t),o=r?["r","g","b","a"]:["r","g","b"];q(n,o,t);for(let a of o)Sd(n,a,t)}function YP(e,t){if(e===void 0)return;let r=Se(e,t);q(r,["x","y","z"],t);for(let n of["x","y","z"])Sd(r,n,t)}function bd(e,t){if(e!==void 0&&(!Array.isArray(e)||e.some(r=>typeof r!="string")))throw X("schema.invalidType",t)}function Sd(e,t,r){if(!(t in e))throw X("schema.invalidValue",`${r}.${t}`);Ae(e,t,r)}function pt(e,t){return e===void 0?null:Se(e,t)}function Se(e,t){let r=qr(e);if(!r)throw X("schema.invalidType",t);return r}function Ge(e,t,r){if(t in e&&typeof e[t]!="boolean")throw X("schema.invalidValue",`${r}.${t}`)}function Ae(e,t,r){if(!(t in e))return;let n=e[t];if(typeof n!="number"||!Number.isFinite(n))throw X("schema.invalidValue",`${r}.${t}`)}function q(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw X("schema.unknownField",`${r}.${o}`)}function X(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function qr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function L(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Tf(e,t){let r=L(e);return{x:ye(r.x,t.x),y:ye(r.y,t.y),z:ye(r.z,t.z)}}function yd(e,t){let r=L(e);return{r:rr(r.r,t.r,0,1),g:rr(r.g,t.g,0,1),b:rr(r.b,t.b,0,1)}}function Xo(e,t){let r=L(e);return{...yd(r,t),a:rr(r.a,t.a,0,1)}}function Pr(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t.trim():"").filter((t,r,n)=>t.length>0&&n.indexOf(t)===r):[]}function hd(e){return(typeof e=="string"?e.trim():"")||null}function Ed(e,t){return(typeof e=="string"?e.trim():"")||t}function je(e,t){return typeof e=="boolean"?e:t}function xf(e){return e===0||e===1||e===2||e===3?e:null}function Af(e,t){return e==="standard"||e==="aces"||e==="khr-pbr-neutral"?e:t}function Df(e,t){return e===1||e===2||e===4||e===8?e:t}function Mf(e,t){return e==="fixed"||e==="receiver"?e:t}function wf(e,t){return e==="none"||e==="blob"||e==="static"||e==="planar"||e==="dynamic"?e:t}function ye(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Q(e,t){let r=ye(e,t);return Math.max(0,r)}function Tr(e,t){let r=ye(e,t);return r>0?r:t}function rr(e,t,r,n){let o=ye(e,t);return Math.min(n,Math.max(r,o))}var kf=["editor","grid","gizmo","helper","camera","light","decal","texture","trigger","collision","ui","_shadow","_planarShadow"],Of=[...kf,"_blobShadow"],ZP=[...Of,"_staticProjectedShadow"];var Rf=[{renderingGroupId:0,name:"\u666E\u901A\u573A\u666F",alphaIndexPresets:[{name:"\u9ED8\u8BA4\u900F\u660E\u987A\u5E8F",alphaIndex:0},{name:"\u5730\u8868\u8D34\u82B1",alphaIndex:100},{name:"\u8FD1\u666F\u8986\u76D6",alphaIndex:200}]},{renderingGroupId:1,name:"\u6C34\u9762 / \u900F\u660E\u5730\u8868",alphaIndexPresets:[{name:"\u6C34\u9762",alphaIndex:0},{name:"\u900F\u660E\u5730\u8868",alphaIndex:100},{name:"\u6C34\u9762\u9AD8\u5149",alphaIndex:200}]},{renderingGroupId:2,name:"\u7279\u6548",alphaIndexPresets:[{name:"\u666E\u901A\u7279\u6548",alphaIndex:0},{name:"\u524D\u666F\u7279\u6548",alphaIndex:100},{name:"\u6700\u524D\u7279\u6548",alphaIndex:200}]},{renderingGroupId:3,name:"\u4E16\u754C\u7A7A\u95F4 UI / \u5F15\u5BFC\u7BAD\u5934",alphaIndexPresets:[{name:"\u4E16\u754C\u7A7A\u95F4 UI",alphaIndex:0},{name:"\u5F15\u5BFC\u7BAD\u5934",alphaIndex:100},{name:"\u9876\u5C42\u63D0\u793A",alphaIndex:200}]}];function Ne(e){e!=null&&gt(e);let t=L(e),r=L(t.shadows),n=L(r.settings),o=L(r.blob),a=QP(o),i=tT(r.staticProjected),s=L(r.shadowRange),c=L(r.shadowOrtho),d=L(r.csm),u=L(t.shadowMeshes);return{renderingGroups:Cf(t.renderingGroups),environment:rT(t.globalVolume),postProcess:nT(t.globalVolume),shadows:{defaultMode:wf(r.defaultMode,"none"),enabled:je(r.enabled,!1),useCsm:je(r.useCsm,!1),settings:{mapSize:Q(n.mapSize,1024),darkness:Q(n.darkness,.3),blurKernel:Q(n.blurKernel,16),bias:Q(n.bias,5e-5),normalBias:Q(n.normalBias,.02),useBlurExponentialShadowMap:je(n.useBlurExponentialShadowMap,!0),shadowMinZ:Q(n.shadowMinZ,1),shadowMaxZ:Q(n.shadowMaxZ,60),shadowColor:yd(n.shadowColor,{r:0,g:0,b:0})},blob:a,staticProjected:i,shadowRange:{minZ:Q(s.minZ,1),maxZ:Q(s.maxZ,60)},shadowOrtho:{left:ye(c.left,-20),right:ye(c.right,20),top:ye(c.top,20),bottom:ye(c.bottom,-20)},csm:{numCascades:Q(d.numCascades,2),lambda:rr(d.lambda,.5,0,1),cascadeBlendPercentage:rr(d.cascadeBlendPercentage,.1,0,1),stabilizeCascades:je(d.stabilizeCascades,!0)},planar:eT(r.planar)},shadowMeshes:{shadowReceivers:Pr(u.shadowReceivers),shadowCasters:Pr(u.shadowCasters),excludeFromShadow:Pr(u.excludeFromShadow)}}}function Bn(e){let t=e?.environment?.texture!=null;return{environmentTextureAssetId:e?.environment?.texture?.textureAssetId??null,environmentTextureUrl:e?.environment?.texture?.url??null,environmentIblIntensity:t?e?.environment?.iblIntensity??null:null,postProcessEnabled:e?.postProcess?.enabled??null,postProcessExposure:e?.postProcess?.imageProcessing?.exposure??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??null,blobEnabled:e?.shadows?.blob?.enabled??null,blobOpacity:e?.shadows?.blob?.appearance?.color?.a??null,staticProjectedEnabled:e?.shadows?.staticProjected?.enabled??null,staticProjectedOpacity:e?.shadows?.staticProjected?.appearance?.color?.a??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}function QP(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.size),a=Xo(n.color,{r:0,g:0,b:0,a:.35});return{enabled:je(t.enabled,!0),plane:{height:ye(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:Xo(n.color,a),edgeSoftness:rr(n.edgeSoftness,.55,0,.98)},size:{sizeMultiplier:Q(o.sizeMultiplier,1.25),minSize:Q(o.minSize,.25),maxSize:Tr(o.maxSize,20)}}}function Cf(e){let t=L(e),r=Array.isArray(t.slots)?t.slots:[];return{slots:Rf.map(n=>{let o=r.find(i=>xf(L(i).renderingGroupId)===n.renderingGroupId),a=L(o);return{renderingGroupId:n.renderingGroupId,name:Ed(a.name,n.name),alphaIndexPresets:vf(a.alphaIndexPresets,n.alphaIndexPresets)}})}}function vf(e,t){let r=Array.isArray(e)?e:t,n=new Set,o=[];return r.forEach((a,i)=>{let s=L(a),c=ye(s.alphaIndex,Number.NaN);!Number.isFinite(c)||n.has(c)||(n.add(c),o.push({name:Ed(s.name,`Order ${i+1}`),alphaIndex:c}))}),o}function eT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.projection),a=L(t.stencil),i=L(t.casters),s=L(t.receivers);return{enabled:je(t.enabled,!0),plane:{normal:Tf(r.normal,{x:0,y:1,z:0}),height:ye(r.height,0),heightMode:Mf(r.heightMode,"receiver"),bias:Q(r.bias,.4)},appearance:{color:Xo(n.color,{r:0,g:0,b:0,a:.35})},projection:{footprintScale:rr(o.footprintScale,1,0,2)},stencil:{enabled:je(a.enabled,!0),receiverRenderingGroup:Q(a.receiverRenderingGroup,0),shadowRenderingGroup:Q(a.shadowRenderingGroup,1)},casters:{autoDetectAll:je(i.autoDetectAll,!0),includePatterns:Pr(i.includePatterns),excludePatterns:Pr(i.excludePatterns),rootBoundaryPatterns:Pr(i.rootBoundaryPatterns),minVolume:Q(i.minVolume,.001)},receivers:{patterns:Pr(s.patterns)}}}function tT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.bake),a=Tr(o.spatialChunkSize,16);return{enabled:je(t.enabled,!1),plane:{height:ye(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:Xo(n.color,{r:0,g:0,b:0,a:.35})},bake:{padding:Q(o.padding,.15),blur:Q(o.blur,0),texelsPerMeter:Tr(o.texelsPerMeter,256),atlasSize:Tr(o.atlasSize,4096),maxAtlasPages:Tr(o.maxAtlasPages,8),sdfRadiusPx:Q(o.sdfRadiusPx,8),spatialChunkSize:a,targetChunkCount:Tr(o.targetChunkCount,64)}}}function rT(e){let t=L(e),r=L(t.environment),n=L(r.texture),o=hd(n.textureAssetId),a=hd(n.url);return{texture:o||a?{...o?{textureAssetId:o}:{},...a?{url:a}:{}}:null,iblIntensity:Q(r.iblIntensity,1),rotationY:ye(r.rotationY,0)}}function nT(e){let t=L(e),r=L(t.imageProcessing),n=L(t.toneMapping),o=L(t.antialiasing),a=L(t.postProcessing),i=L(a.bloom);return{enabled:je(t.enabled,!0),hdr:je(t.hdr,!0),imageProcessing:{exposure:ye(r.exposure,1),contrast:ye(r.contrast,1)},toneMapping:{enabled:je(n.enabled,!0),type:Af(n.type,"aces")},antialiasing:{samples:Df(o.samples,4)},bloom:{enabled:je(i.enabled,!1),threshold:Q(i.threshold,.9),weight:Q(i.weight,.2),kernel:Q(i.kernel,64),scale:Tr(i.scale,.5)}}}var ki=class extends Error{path;reason;code="runtime.lighting.invalid";constructor(t,r){super(`Invalid Runtime Lighting data at ${t}: ${r}`),this.path=t,this.reason=r,this.name="FpsRuntimeLightingDataError"}},Gf=1e-6,oT=1e-4,aT=new Set(["schemaVersion","type","intensity","direction","diffuseColor"]),iT=new Set(["schemaVersion","type","intensity","diffuseColor","groundColor"]),sT=new Set(["x","y","z"]),cT=new Set(["r","g","b"]);function Zo(e,t="$.direction"){let r=jf(e,t),n=Math.hypot(r.x,r.y,r.z);return n<=Gf&&bt(t,"expected a non-zero direction vector"),Object.freeze({x:r.x/n,y:r.y/n,z:r.z/n})}function Vn(e,t="$.light"){let r=Td(e,t);r.schemaVersion!==1&&bt(`${t}.schemaVersion`,"expected 1");let n=dT(r.intensity,`${t}.intensity`);if(r.type==="directional"){Oi(r,aT,t);let o=jf(r.direction,`${t}.direction`),a=Math.hypot(o.x,o.y,o.z);return a<=Gf&&bt(`${t}.direction`,"expected a non-zero direction vector"),Math.abs(a-1)>oT&&bt(`${t}.direction`,"expected a normalized direction vector"),Object.freeze({schemaVersion:1,type:"directional",intensity:n,direction:o,diffuseColor:Id(r.diffuseColor,`${t}.diffuseColor`)})}if(r.type==="hemispheric")return Oi(r,iT,t),Object.freeze({schemaVersion:1,type:"hemispheric",intensity:n,diffuseColor:Id(r.diffuseColor,`${t}.diffuseColor`),groundColor:Id(r.groundColor,`${t}.groundColor`)});bt(`${t}.type`,"expected directional or hemispheric")}function jf(e,t){let r=Td(e,t);return Oi(r,sT,t),Object.freeze({x:Yo(r.x,`${t}.x`),y:Yo(r.y,`${t}.y`),z:Yo(r.z,`${t}.z`)})}function Id(e,t){let r=Td(e,t);return Oi(r,cT,t),Object.freeze({r:Pd(r.r,`${t}.r`),g:Pd(r.g,`${t}.g`),b:Pd(r.b,`${t}.b`)})}function Td(e,t){(!e||typeof e!="object"||Array.isArray(e))&&bt(t,"expected a plain object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&bt(t,"expected a plain object"),e}function Oi(e,t,r){for(let n of Object.keys(e))t.has(n)||bt(`${r}.${n}`,"unknown field")}function Yo(e,t){return(typeof e!="number"||!Number.isFinite(e))&&bt(t,"expected a finite number"),e}function dT(e,t){let r=Yo(e,t);return r<0&&bt(t,"expected a non-negative number"),r}function Pd(e,t){let r=Yo(e,t);return(r<0||r>1)&&bt(t,"expected a number between 0 and 1"),r}function bt(e,t){throw new ki(e,t)}var lT=new Set([".glb",".gltf",".png",".jpg",".jpeg",".webp",".env",".hdr",".dds",".ktx",".ktx2",".mp3",".wav",".ogg",".flac",".aac",".m4a"]);function Nf(e){let t=String(e??"").trim().toLowerCase();if(/^\.[a-z0-9]+$/.test(t))return t;let r=t.split(/[?#]/,1)[0]??"",n=r.slice(r.lastIndexOf("/")+1),o=n.lastIndexOf(".");return o<=0||o===n.length-1?null:n.slice(o)}function Ff(e){return lT.has(e)}function Hn(e){return e==="fps.builtin.pbr"||e==="fps.builtin.standard"?e:void 0}function _f(e){if(!e||typeof e!="object")return;let t={};(e.lightingModel==="lit"||e.lightingModel==="unlit")&&(t.lightingModel=e.lightingModel);let r={},n=$f(e.baseColor?.color);n&&(r.color=n);let o=Xr(e.baseColor?.texture);o!==void 0&&(r.texture=o),nr(e.baseColor,r,"brightness"),nr(e.baseColor,r,"saturation"),nr(e.baseColor,r,"contrast"),nr(e.baseColor,r,"hue"),Object.keys(r).length>0&&(t.baseColor=r);let a={},i=Xr(e.normal?.texture);i!==void 0&&(a.texture=i),nr(e.normal,a,"strength"),Object.keys(a).length>0&&(t.normal=a),Kn(e.metallic)&&(t.metallic=e.metallic),Kn(e.roughness)&&(t.roughness=e.roughness);let s={},c=Xr(e.metallicRoughness?.texture);c!==void 0&&(s.texture=c),Object.keys(s).length>0&&(t.metallicRoughness=s);let d={},u=Xr(e.occlusion?.texture);u!==void 0&&(d.texture=u),nr(e.occlusion,d,"strength"),Object.keys(d).length>0&&(t.occlusion=d);let l={},m=$f(e.emission?.color);m&&(l.color=m),nr(e.emission,l,"intensity");let f=Xr(e.emission?.texture);f!==void 0&&(l.texture=f);let S=Xr(e.emission?.maskTexture);S!==void 0&&(l.maskTexture=S),Object.keys(l).length>0&&(t.emission=l);let g={};(e.alpha?.mode==="opaque"||e.alpha?.mode==="mask"||e.alpha?.mode==="blend")&&(g.mode=e.alpha.mode),nr(e.alpha,g,"opacity"),nr(e.alpha,g,"cutoff");let b=Xr(e.alpha?.texture);return b!==void 0&&(g.texture=b),Object.keys(g).length>0&&(t.alpha=g),Object.keys(t).length>0?t:void 0}function xd(...e){let t={};for(let r of e){let n=_f(r);n&&(n.lightingModel&&(t.lightingModel=n.lightingModel),Un(t,n,"baseColor"),Un(t,n,"normal"),n.metallic!==void 0&&(t.metallic=n.metallic),n.roughness!==void 0&&(t.roughness=n.roughness),Un(t,n,"metallicRoughness"),Un(t,n,"occlusion"),Un(t,n,"emission"),Un(t,n,"alpha"))}return _f(t)??{}}function Un(e,t,r){let n=t[r];n&&Object.assign(e,{[r]:{...e[r]??{},...n}})}function $f(e){return e&&Kn(e.r)&&Kn(e.g)&&Kn(e.b)?{r:e.r,g:e.g,b:e.b}:void 0}function Xr(e){if(e===null)return null;if(!e||typeof e!="object")return;let t=typeof e.url=="string"?e.url.trim():"",r=typeof e.textureAssetId=="string"?e.textureAssetId.trim():"";if(!(!t&&!r))return{...t?{url:t}:{},...r?{textureAssetId:r}:{}}}function nr(e,t,r){Kn(e?.[r])&&(t[r]=e[r])}function Kn(e){return typeof e=="number"&&Number.isFinite(e)}var Lf="staticShadows";function Ar(e){let t=ar(e);if(!t)return null;let r=ge(t.sourceHash),n=ge(t.lightHash),o=ge(t.profileHash);if(!r||!n||!o)return null;let a={sourceHash:r,lightHash:n,profileHash:o,...typeof t.generatedAt=="string"&&t.generatedAt.trim()?{generatedAt:t.generatedAt.trim()}:{},...(()=>{let u=yT(t.stats);return u?{stats:u}:{}})()};if(t.version!==2||t.format!=="sdf-atlas"||!Array.isArray(t.pages)||!Array.isArray(t.chunks))return null;let i=[],s=new Map;for(let u of t.pages){let l=uT(u);if(!l||s.has(l.id))return null;i.push(l),s.set(l.id,l)}let c=[],d=new Set;for(let u of t.chunks){let l=mT(u,s);if(!l||d.has(l.id))return null;c.push(l),d.add(l.id)}return{version:2,format:"sdf-atlas",pages:i,chunks:c,...a}}function Wn(e,t="$.staticShadows"){let r=Ar(e);if(r)return r;let n=new Error(`schema.unsupportedVersion: ${t}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:t}),n}function uT(e){let t=ar(e);if(!t)return null;let r=ge(t.id),n=Gi(t.width),o=Gi(t.height),a=hT(t.sdfTextureDataUrl);return!r||n==null||o==null||!a?null:{id:r,width:n,height:o,sdfTextureDataUrl:a}}function mT(e,t){let r=ar(e);if(!r)return null;let n=ge(r.id),o=bT(r.bounds),a=ST(r.plane),i=ge(r.pageId),s=pT(r.atlasRect),c=gT(r.atlasUv),d=ET(r.sourceNodeIds),u=ge(r.sourceHash),l=ge(r.lightHash),m=ge(r.profileHash);if(!n||!o||!a||!i||!s||!c||!d||!u||!l||!m)return null;let f=t.get(i);return!f||s.x+s.width>f.width||s.y+s.height>f.height?null:{id:n,bounds:o,plane:a,pageId:i,atlasRect:s,atlasUv:c,sourceNodeIds:d,sourceHash:u,lightHash:l,profileHash:m,...(()=>{let S=fT(r.binding);return S?{binding:S}:{}})()}}function fT(e){let t=ar(e);if(!t)return null;let r=ge(t.id),n=ge(t.ownerCasterId),o=ge(t.receiverId),a=ge(t.generatedAt),i=ge(t.sourceHash);if(!r||!n||!o||!a||!i||t.visibleWhenOwnerVisible!==!0||t.staleWhenOwnerTransformChanges!==!0||t.staleWhenLightChanges!==!0)return null;let s=ge(t.lightId),c=ge(t.textureAssetId),d=ge(t.projectionNodeId);return{id:r,ownerCasterId:n,receiverId:o,...s?{lightId:s}:{},...c?{textureAssetId:c}:{},...d?{projectionNodeId:d}:{},visibleWhenOwnerVisible:!0,staleWhenOwnerTransformChanges:!0,staleWhenLightChanges:!0,generatedAt:a,sourceHash:i}}function pT(e){let t=ar(e);if(!t)return null;let r=xr(t.x),n=xr(t.y),o=Gi(t.width),a=Gi(t.height);return r==null||n==null||o==null||a==null?null:{x:r,y:n,width:o,height:a}}function gT(e){let t=ar(e);if(!t)return null;let r=Ri(t.u0),n=Ri(t.v0),o=Ri(t.u1),a=Ri(t.v1);return r==null||n==null||o==null||a==null||o<=r||a<=n?null:{u0:r,v0:n,u1:o,v1:a}}function bT(e){let t=ar(e);if(!t)return null;let r=jt(t.minX),n=jt(t.maxX),o=jt(t.minZ),a=jt(t.maxZ),i=jt(t.y);return r==null||n==null||o==null||a==null||i==null||n<=r||a<=o?null:{minX:r,maxX:n,minZ:o,maxZ:a,y:i}}function ST(e){let t=ar(e);if(!t)return null;let r=jt(t.height),n=jt(t.yOffset);return r==null||n==null||n<0?null:{height:r,yOffset:n}}function yT(e){let t=ar(e);if(!t)return null;let r=xr(t.sourceRootCount),n=xr(t.sourceMeshCount),o=xr(t.attemptedChunkCount),a=xr(t.chunkCount),i=xr(t.textureCount);return r==null||n==null||o==null||a==null||i==null?null:{sourceRootCount:r,sourceMeshCount:n,attemptedChunkCount:o,chunkCount:a,textureCount:i,...Ci(t.skippedChunkCount,"skippedChunkCount"),...Ci(t.pageCount,"pageCount"),...or(t.resolution,"resolution"),...or(t.chunkSize,"chunkSize"),...or(t.atlasSize,"atlasSize"),...vi(t.atlasUsedPixels,"atlasUsedPixels"),...vi(t.atlasAllocatedPixels,"atlasAllocatedPixels"),...IT(t.atlasOccupancy,"atlasOccupancy"),...or(t.texelsPerMeter,"texelsPerMeter"),...or(t.effectiveTexelsPerMeter,"effectiveTexelsPerMeter"),...or(t.maxAtlasPages,"maxAtlasPages"),...vi(t.sdfRadiusPx,"sdfRadiusPx"),...or(t.spatialChunkSize,"spatialChunkSize"),...or(t.effectiveSpatialChunkSize,"effectiveSpatialChunkSize"),...or(t.targetChunkCount,"targetChunkCount"),...Ci(t.bakedChunkCount,"bakedChunkCount"),...Ci(t.reusedChunkCount,"reusedChunkCount"),...vi(t.durationMs,"durationMs")}}function hT(e){let t=ge(e);return t&&/^data:image\/png[;,]/i.test(t)?t:null}function ET(e){if(!Array.isArray(e)||e.length===0)return null;let t=[],r=new Set;for(let n of e){let o=ge(n);if(!o)return null;r.has(o)||t.push(o),r.add(o)}return t}function ge(e){return typeof e=="string"&&e.trim()?e.trim():null}function jt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function xr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Gi(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:null}function Ri(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:null}function Ci(e,t){let r=xr(e);return r==null?{}:{[t]:r}}function or(e,t){let r=jt(e);return r==null||r<=0?{}:{[t]:r}}function vi(e,t){let r=jt(e);return r==null||r<0?{}:{[t]:r}}function IT(e,t){let r=jt(e);return r==null||r<0||r>1?{}:{[t]:r}}function ar(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var PT="@fps-games/editor.playable-sdk.scene-compiler",TT="2",xT=1e-4,et={nodeKinds:["group","instance","transform","primitive","image"],primitiveShapes:["cube","sphere","plane","capsule"],transformTypes:["plain","light","camera","groundDecal"],assetTypes:["glb","texture"],materialScopes:["sharedAsset","nodeMaterial"],materialModes:["shared","instance"],materialShaderIds:["fps.builtin.pbr","fps.builtin.standard"],materialAssetSystemPresets:["default-pbr","default-standard"],runtimeV3:{assetFields:["id","guid","type","url","external","warmupCount","singleton","materialMode","defaults","materialSlots"],materialSlotFields:["slotId","label","sourceSurfaces"],materialSlotSourceSurfaceFields:["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMeshName"]},hierarchy:{parentTargets:["root","sceneNode"]},runtimeOnlyTokens:["/@fs","assetUrl","sourceAssetUrl","sourceAssetPath"]},AT=new Set(et.nodeKinds),DT=new Set(et.primitiveShapes),MT=new Set(et.assetTypes),wT=new Set(et.materialModes),kT=new Set(et.materialScopes),OT=new Set(et.materialAssetSystemPresets),RT=new Set(et.transformTypes),Qo=new Set(et.hierarchy.parentTargets),CT=et.runtimeOnlyTokens,vT=new Set(et.runtimeV3.assetFields),GT=new Set(et.runtimeV3.materialSlotFields),jT=new Set(et.runtimeV3.materialSlotSourceSurfaceFields);function NT(e,t={}){let{allowOrphanSharedMaterials:r=!0,allowOrphanNodeMaterials:n=!0,strictAssetIds:o=[],strictNodeIds:a=[],maxErrors:i=50}=t,s=Number.isInteger(i)&&i>0?i:50,c=[],d=new Set(o),u=new Set(a),l=(p,D)=>{c.length<s&&c.push({path:p,message:D})};if(!M(e))return l("$","scene json must be an object"),c;let m=e.schemaVersion;m!==2&&m!==3&&l("$.schemaVersion","schemaVersion must be 2 or 3"),YT(e.meta?.generatedFrom,"$.meta.generatedFrom",l);let f=ix(e),S=e.scene;if(!M(S))return l("$.scene","scene must be an object"),c;if(O(S.rootId)||l("$.scene.rootId","rootId must be a non-empty string"),Array.isArray(S.assets)||l("$.scene.assets","assets must be an array"),Array.isArray(S.nodes)||l("$.scene.nodes","nodes must be an array"),Array.isArray(S.materialAssets)||l("$.scene.materialAssets","materialAssets must be an array"),Array.isArray(S.materials)||l("$.scene.materials","materials must be an array"),Array.isArray(S.textures)||l("$.scene.textures","textures must be an array"),c.length>0)return c;e.staticShadows!=null&&zf(()=>Wn(e.staticShadows,"$.staticShadows"),"$.staticShadows",l);let g=new Set,b=new Map,y=new Map,E=new Set,I=new Set([S.rootId]),P=new Map,A=new Map,$=new Set;return S.assets.forEach((p,D)=>{let h=`$.scene.assets[${D}]`;if(!M(p)){l(h,"asset must be an object");return}if(O(p.id)?g.has(p.id)?l(`${h}.id`,`duplicate asset id: ${p.id}`):(g.add(p.id),b.set(p.id,p.type)):l(`${h}.id`,"asset.id must be a non-empty string"),MT.has(p.type)||l(`${h}.type`,"asset.type must be glb or texture"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"asset.guid must be a non-empty string when present"),p.url!=null&&!O(p.url)&&l(`${h}.url`,"url must be a non-empty string when present"),p.external!=null&&!M(p.external)&&l(`${h}.external`,"external must be an object when present"),p.warmupCount!=null&&(!Number.isInteger(p.warmupCount)||p.warmupCount<0)&&l(`${h}.warmupCount`,"warmupCount must be a non-negative integer when present"),p.singleton!=null&&typeof p.singleton!="boolean"&&l(`${h}.singleton`,"singleton must be a boolean when present"),p.materialMode!=null&&!wT.has(p.materialMode)&&l(`${h}.materialMode`,"materialMode must be shared or instance"),XT(p.defaults,`${h}.defaults`,l),m===3)for(let F of Object.keys(p))vT.has(F)||l(`${h}.${F}`,`runtime schema v3 asset field is not allowed: ${F}`);else p.displayName!=null&&!O(p.displayName)&&l(`${h}.displayName`,"displayName must be a non-empty string when present"),p.category!=null&&!O(p.category)&&l(`${h}.category`,"category must be a non-empty string when present"),p.metadata!=null&&!M(p.metadata)&&l(`${h}.metadata`,"metadata must be an object when present");let R=m===3?p.materialSlots:M(p.metadata)?p.metadata.materialSlots:void 0,K=m===3?`${h}.materialSlots`:`${h}.metadata.materialSlots`,ne=new Set;R!=null&&(Array.isArray(R)?R.forEach((F,Ir)=>{let er=`${K}[${Ir}]`;if(!M(F)||!O(F.slotId)){l(er,m===3?"material slot must contain a stable slotId":"material slot must contain stable slotId and ownerNodePath");return}if(m!==3&&!O(F.ownerNodePath)){l(er,"material slot must contain stable slotId and ownerNodePath");return}ne.has(F.slotId)?l(`${er}.slotId`,`duplicate material slot id: ${F.slotId}`):ne.add(F.slotId),m===3&&JT(F,er,l)}):l(K,"materialSlots must be an array when present")),O(p.id)&&y.set(p.id,ne),d.has(p.id)&&Uf(p,h,l)}),S.nodes.forEach((p,D)=>{let h=`$.scene.nodes[${D}]`;if(!M(p)){l(h,"node must be an object");return}O(p.id)&&P.set(p.id,p),O(p.id)?I.has(p.id)?l(`${h}.id`,`duplicate node id: ${p.id}`):(I.add(p.id),typeof p.kind=="string"&&A.set(p.id,p.kind),p.kind==="transform"&&Object.prototype.hasOwnProperty.call(p,"marker")&&$.add(p.id)):l(`${h}.id`,"node.id must be a non-empty string"),AT.has(p.kind)||l(`${h}.kind`,"node.kind must be group, instance, transform, primitive, or image")}),S.materialAssets.forEach((p,D)=>{let h=`$.scene.materialAssets[${D}]`;if(!M(p)){l(h,"material asset must be an object");return}O(p.id)?E.has(p.id)?l(`${h}.id`,`duplicate material asset id: ${p.id}`):E.add(p.id):l(`${h}.id`,"material asset id must be a non-empty string"),p.name!=null&&!O(p.name)&&l(`${h}.name`,"material asset name must be a non-empty string when present"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"material asset guid must be a non-empty string when present"),Object.prototype.hasOwnProperty.call(p,"materialKind")&&l(`${h}.materialKind`,"materialKind is not supported; use shaderId"),Object.prototype.hasOwnProperty.call(p,"profile")&&l(`${h}.profile`,"profile is not supported; use properties");let R=Hn(p.shaderId),K=zT(p.shaderId);!R&&!K&&l(`${h}.shaderId`,"shaderId must be a built-in id or a namespaced lowercase project id"),p.definitionVersion!=null&&!BT(p.definitionVersion)?l(`${h}.definitionVersion`,"definitionVersion must be a positive integer when present"):K&&p.definitionVersion==null&&l(`${h}.definitionVersion`,"definitionVersion is required for project shader material assets"),R?Hf(p.properties,`${h}.properties`,l):VT(p.properties,`${h}.properties`,l);for(let ne of Object.keys(p))["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(ne)||l(`${h}.${ne}`,`material asset field is not allowed: ${ne}`);UT(p.system,`${h}.system`,l),KT(p.origin,`${h}.origin`,l),HT(p,h,l)}),S.nodes.forEach((p,D)=>{if(!M(p))return;let h=`$.scene.nodes[${D}]`,R=Object.prototype.hasOwnProperty.call(p,"parentId");R&&!O(p.parentId)&&l(`${h}.parentId`,"parentId must be a non-empty string when present");let K=R?p.parentId:S.rootId;O(K)&&WT(K,S.rootId,I,`${h}.parentId`,l),O(p.id)&&qT(p.id,S.rootId,P,`${h}.parentId`,l),ZT(p.source,`${h}.source`,l),qf(p.transform,`${h}.transform`,l),Sx(p.rendering,`${h}.rendering`,l),p.shadow!=null&&zf(()=>Wo(p.shadow,`${h}.shadow`),`${h}.shadow`,l),Object.prototype.hasOwnProperty.call(p,"shadowMode")&&l(`${h}.shadowMode`,"deprecated field; use shadow.mode");let ne=null;p.kind==="instance"&&(M(p.instance)?g.has(p.instance.assetId)?b.get(p.instance.assetId)!=="glb"?l(`${h}.instance.assetId`,"instance.assetId must reference a glb asset"):ne=O(p.instance.assetId)?p.instance.assetId:null:l(`${h}.instance.assetId`,`assetId must reference scene.assets: ${p.instance.assetId}`):l(`${h}.instance`,"instance node must contain instance object")),p.kind==="primitive"&&(M(p.primitive)?DT.has(p.primitive.shape)||l(`${h}.primitive.shape`,"primitive.shape must be cube, sphere, plane, or capsule"):l(`${h}.primitive`,"primitive node must contain primitive object")),p.kind==="image"&&(M(p.image)?(g.has(p.image.assetId)?b.get(p.image.assetId)!=="texture"&&l(`${h}.image.assetId`,"image.assetId must reference a texture asset"):l(`${h}.image.assetId`,`assetId must reference scene.assets: ${p.image.assetId}`),M(p.image.size)?(Vf(p.image.size.width)||l(`${h}.image.size.width`,"image.size.width must be positive"),Vf(p.image.size.height)||l(`${h}.image.size.height`,"image.size.height must be positive")):l(`${h}.image.size`,"image.size must be an object")):l(`${h}.image`,"image node must contain image object")),p.kind==="transform"&&p.transformType!=null&&!RT.has(p.transformType)&&l(`${h}.transformType`,"transformType must be plain, light, camera, or groundDecal"),p.kind==="transform"&&p.transformType==="groundDecal"?dx(p.groundDecal,`${h}.groundDecal`,l):Object.prototype.hasOwnProperty.call(p,"groundDecal")&&l(`${h}.groundDecal`,"groundDecal is only allowed on transform nodes with transformType groundDecal"),p.kind==="transform"&&(ax(p.camera,`${h}.camera`,l),sx(p.light,`${h}.light`,l,f)),Object.prototype.hasOwnProperty.call(p,"marker")&&(p.kind!=="transform"?l(`${h}.marker`,"marker is only allowed on transform nodes"):(QT(p.marker,`${h}.marker`,l),ex(p.marker,p.id,I,$,`${h}.marker`,l))),(p.kind==="instance"||p.kind==="transform"||p.kind==="primitive"||p.kind==="image")&&_T(p.overrides,`${h}.overrides`,E,ne?y.get(ne):void 0,m===3?"materialSlots":"metadata.materialSlots",l),u.has(p.id)&&Uf(p,h,l)}),S.materials.forEach((p,D)=>{let h=`$.scene.materials[${D}]`;if(!M(p)){l(h,"material must be an object");return}if(O(p.id)||l(`${h}.id`,"material.id must be a non-empty string"),p.scope!=null&&!kT.has(p.scope)&&l(`${h}.scope`,"material scope must be sharedAsset or nodeMaterial"),p.scope==="sharedAsset"&&(!O(p.assetId)||!g.has(p.assetId))&&!r&&l(`${h}.assetId`,`shared material assetId must reference scene.assets: ${p.assetId}`),p.scope==="nodeMaterial"){if((!O(p.nodeId)||!I.has(p.nodeId))&&!n)l(`${h}.nodeId`,`node material nodeId must reference scene.nodes: ${p.nodeId}`);else if(O(p.nodeId)&&I.has(p.nodeId)){let R=A.get(p.nodeId);R!=="instance"&&R!=="transform"&&R!=="primitive"&&l(`${h}.nodeId`,`node material nodeId must reference an instance, transform, or primitive node: ${p.nodeId}`)}}O(p.materialName)||l(`${h}.materialName`,"materialName must be a non-empty string"),M(p.properties)?Xf(p.properties,`${h}.properties`,l):l(`${h}.properties`,"properties must be an object")}),c}function FT(e,t={}){let r=NT(e,t);return{ok:r.length===0,errors:r}}function zf(e,t,r){try{e()}catch(n){let o=typeof n?.path=="string"?n.path:t,a=typeof n?.code=="string"?n.code:"schema.invalidValue";r(o,a)}}function _T(e,t,r,n,o,a){if(e!=null){if(!M(e)){a(t,"overrides must be an object when present");return}Kf(e.materialBinding,`${t}.materialBinding`,r,a),$T(e.materialSlotBindings,`${t}.materialSlotBindings`,"slotId",r,n,o,a),Object.prototype.hasOwnProperty.call(e,"childMaterialBindings")&&a(`${t}.childMaterialBindings`,"deprecated field; use materialSlotBindings keyed by slotId"),Object.prototype.hasOwnProperty.call(e,"childMaterials")&&a(`${t}.childMaterials`,"deprecated field; use materialSlotBindings keyed by slotId")}}function $T(e,t,r,n,o,a,i){if(e!=null){if(!M(e)){i(t,"material binding map must be an object when present");return}for(let[s,c]of Object.entries(e)){let d=`${t}.${s}`;O(s)||i(d,`${r} must be a non-empty string`),o?o.has(s)||i(d,`${r} must reference asset ${a}`):i(d,`${r} requires an instance asset with ${a}`),c==null?i(d,"material binding must be an object"):Kf(c,d,n,i)}}}function Kf(e,t,r,n){if(e!=null){if(!M(e)){n(t,"material binding must be an object when present");return}e.materialAssetId!=null&&(O(e.materialAssetId)?r.has(e.materialAssetId)||n(`${t}.materialAssetId`,`materialAssetId must reference scene.materialAssets: ${e.materialAssetId}`):n(`${t}.materialAssetId`,"materialAssetId must be non-empty when present")),e.override!=null&&Hf(e.override,`${t}.override`,n)}}function Hf(e,t,r){if(!M(e)){r(t,"material asset profile must be an object");return}if(e.lightingModel!=null&&e.lightingModel!=="lit"&&e.lightingModel!=="unlit"&&r(`${t}.lightingModel`,"lightingModel must be lit or unlit"),e.baseColor!=null)if(!M(e.baseColor))r(`${t}.baseColor`,"baseColor must be an object");else{ji(e.baseColor.color,`${t}.baseColor.color`,r),Yr(e.baseColor.texture,`${t}.baseColor.texture`,r);for(let n of["brightness","saturation","contrast","hue"])e.baseColor[n]!=null&&!We(e.baseColor[n])&&r(`${t}.baseColor.${n}`,`${n} must be a finite number`)}for(let n of["metallic","roughness"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,`${n} must be a finite number`);e.normal!=null&&(M(e.normal)?(Yr(e.normal.texture,`${t}.normal.texture`,r),e.normal.strength!=null&&!We(e.normal.strength)&&r(`${t}.normal.strength`,"normal strength must be a finite number")):r(`${t}.normal`,"normal must be an object")),e.metallicRoughness!=null&&(M(e.metallicRoughness)?Yr(e.metallicRoughness.texture,`${t}.metallicRoughness.texture`,r):r(`${t}.metallicRoughness`,"metallicRoughness must be an object")),e.occlusion!=null&&(M(e.occlusion)?(Yr(e.occlusion.texture,`${t}.occlusion.texture`,r),e.occlusion.strength!=null&&!We(e.occlusion.strength)&&r(`${t}.occlusion.strength`,"occlusion strength must be a finite number")):r(`${t}.occlusion`,"occlusion must be an object")),e.emission!=null&&(M(e.emission)?(ji(e.emission.color,`${t}.emission.color`,r),e.emission.intensity!=null&&!We(e.emission.intensity)&&r(`${t}.emission.intensity`,"emission intensity must be a finite number"),Yr(e.emission.texture,`${t}.emission.texture`,r),Yr(e.emission.maskTexture,`${t}.emission.maskTexture`,r)):r(`${t}.emission`,"emission must be an object")),e.alpha!=null&&(M(e.alpha)?(e.alpha.mode!=null&&e.alpha.mode!=="opaque"&&e.alpha.mode!=="mask"&&e.alpha.mode!=="blend"&&r(`${t}.alpha.mode`,"alpha mode must be opaque, mask, or blend"),e.alpha.opacity!=null&&!We(e.alpha.opacity)&&r(`${t}.alpha.opacity`,"alpha opacity must be a finite number"),e.alpha.cutoff!=null&&!We(e.alpha.cutoff)&&r(`${t}.alpha.cutoff`,"alpha cutoff must be a finite number"),Yr(e.alpha.texture,`${t}.alpha.texture`,r)):r(`${t}.alpha`,"alpha must be an object"))}var LT=/^[a-z0-9]+(?:[._-][a-z0-9]+)+$/;function ta(e){return typeof e=="string"&&!e.startsWith("fps.builtin.")&&LT.test(e)}function zT(e){return ta(e)?e:null}function BT(e){return Number.isSafeInteger(e)&&e>0}function VT(e,t,r){if(!M(e)){r(t,"project shader material properties must be an object");return}Ad(e,t,r)}function Ad(e,t,r){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||r(t,"project shader material numbers must be finite");return}if(Array.isArray(e)){e.forEach((n,o)=>Ad(n,`${t}[${o}]`,r));return}if(M(e)){for(let[n,o]of Object.entries(e))Ad(o,`${t}.${n}`,r);return}r(t,"project shader material properties must be JSON-safe")}}function Yr(e,t,r){if(e!=null){if(!M(e)){r(t,"texture ref must be an object");return}e.url!=null&&!O(e.url)&&r(`${t}.url`,"texture url must be non-empty when present"),e.textureAssetId!=null&&!O(e.textureAssetId)&&r(`${t}.textureAssetId`,"textureAssetId must be non-empty when present")}}function UT(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset system must be an object");return}e.readonly!=null&&typeof e.readonly!="boolean"&&r(`${t}.readonly`,"readonly must be boolean"),e.preset!=null&&!OT.has(e.preset)&&r(`${t}.preset`,"preset must be default-pbr or default-standard")}}function KT(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset origin must be an object");return}e.type!=="imported"&&e.type!=="created"&&e.type!=="duplicated"&&e.type!=="preset"&&r(`${t}.type`,"origin type must be imported, created, duplicated, or preset"),e.sourceAssetGuid!=null&&!O(e.sourceAssetGuid)&&r(`${t}.sourceAssetGuid`,"sourceAssetGuid must be non-empty when present"),e.sourceAssetId!=null&&!O(e.sourceAssetId)&&r(`${t}.sourceAssetId`,"sourceAssetId must be non-empty when present"),e.sourceSlotId!=null&&!O(e.sourceSlotId)&&r(`${t}.sourceSlotId`,"sourceSlotId must be non-empty when present"),e.sourceMaterialIndex!=null&&!Number.isInteger(e.sourceMaterialIndex)&&r(`${t}.sourceMaterialIndex`,"sourceMaterialIndex must be an integer when present"),e.sourceMaterialName!=null&&!O(e.sourceMaterialName)&&r(`${t}.sourceMaterialName`,"sourceMaterialName must be non-empty when present"),e.sourceMaterialAssetId!=null&&!O(e.sourceMaterialAssetId)&&r(`${t}.sourceMaterialAssetId`,"sourceMaterialAssetId must be non-empty when present")}}function HT(e,t,r){let n=M(e.system)?e.system.preset:void 0;n==="default-pbr"&&e.shaderId!=="fps.builtin.pbr"&&r(`${t}.shaderId`,"default-pbr material assets must use shaderId fps.builtin.pbr"),n==="default-standard"&&e.shaderId!=="fps.builtin.standard"&&r(`${t}.shaderId`,"default-standard material assets must use shaderId fps.builtin.standard")}function WT(e,t,r,n,o){if(e===t){Qo.has("root")||o(n,`parentId must point to scene node: ${e}`);return}if(Qo.has("sceneNode")&&r.has(e))return;let a=Qo.has("root")&&Qo.has("sceneNode")?"root or scene node":Qo.has("sceneNode")?"scene node":"root";o(n,`parentId must point to ${a}: ${e}`)}function qT(e,t,r,n,o){if(!O(t))return;let a=new Set([e]),i=O(r.get(e)?.parentId)?r.get(e)?.parentId:t;for(;O(i)&&i!==t;){if(a.has(i)){o(n,`parentId creates a node cycle involving ${e}`);return}a.add(i);let s=r.get(i);if(!s)return;i=O(s.parentId)?s.parentId:t}}function JT(e,t,r){for(let n of Object.keys(e))GT.has(n)||r(`${t}.${n}`,`runtime schema v3 material slot field is not allowed: ${n}`);if(e.label!=null&&!O(e.label)&&r(`${t}.label`,"label must be a non-empty string when present"),!Array.isArray(e.sourceSurfaces)||e.sourceSurfaces.length===0){r(`${t}.sourceSurfaces`,"sourceSurfaces must be a non-empty array");return}for(let n=0;n<e.sourceSurfaces.length;n+=1){let o=`${t}.sourceSurfaces[${n}]`,a=e.sourceSurfaces[n];if(!M(a)){r(o,"source surface must be an object");continue}for(let i of Object.keys(a))jT.has(i)||r(`${o}.${i}`,`runtime schema v3 material slot source surface field is not allowed: ${i}`);O(a.ownerNodePath)||r(`${o}.ownerNodePath`,"ownerNodePath must be a non-empty string");for(let i of["meshIndex","primitiveIndex"])(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer`);for(let i of["nodeIndex","sourceMaterialIndex"])a[i]!=null&&(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer when present`);a.nodeIndexPath!=null&&(!Array.isArray(a.nodeIndexPath)||a.nodeIndexPath.some(i=>!Number.isInteger(i)||i<0))&&r(`${o}.nodeIndexPath`,"nodeIndexPath must contain non-negative integers"),O(a.sourceMeshName)||r(`${o}.sourceMeshName`,"sourceMeshName is required")}}function XT(e,t,r){if(e!=null){if(!M(e)){r(t,"defaults must be an object");return}if(qf(e.transform,`${t}.transform`,r),Bf(e.outline,`${t}.outline`,r),e.childOutlines!=null)if(!M(e.childOutlines))r(`${t}.childOutlines`,"childOutlines must be an object");else for(let[n,o]of Object.entries(e.childOutlines))Bf(o,`${t}.childOutlines.${n}`,r)}}function YT(e,t,r){if(e!=null){if(!M(e)){r(t,"generatedFrom must be an object when present");return}Wf(e,t,r),O(e.compilerId)||r(`${t}.compilerId`,"compilerId must be a non-empty string"),O(e.compilerVersion)||r(`${t}.compilerVersion`,"compilerVersion must be a non-empty string"),O(e.compiledAt)||r(`${t}.compiledAt`,"compiledAt must be a non-empty string")}}function ZT(e,t,r){if(e!=null){if(!M(e)){r(t,"source must be an object when present");return}Wf(e,t,r),e.objectGuid!=null&&!O(e.objectGuid)&&r(`${t}.objectGuid`,"objectGuid must be a non-empty string when present"),e.objectId!=null&&!O(e.objectId)&&r(`${t}.objectId`,"objectId must be a non-empty string when present"),e.component!=null&&!O(e.component)&&r(`${t}.component`,"component must be a non-empty string when present"),e.propertyPath!=null&&!O(e.propertyPath)&&r(`${t}.propertyPath`,"propertyPath must be a non-empty string when present")}}function Wf(e,t,r){O(e.sourceId)||r(`${t}.sourceId`,"sourceId must be a non-empty string"),O(e.sourceType)||r(`${t}.sourceType`,"sourceType must be a non-empty string"),e.revision!=null&&(typeof e.revision!="number"||!Number.isFinite(e.revision))&&r(`${t}.revision`,"revision must be a finite number when present")}function Ni(e,t){let r=FT(e,t);if(r.ok)return;let n=new Error(`scene_json_schema_failed:
2
- ${JSON.stringify(r.errors,null,2)}`);throw Object.assign(n,{code:"scene_json_schema_failed",diagnostics:r.errors}),n}function M(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function O(e){return typeof e=="string"&&e.trim().length>0}function qf(e,t,r){if(e!=null){if(!M(e)){r(t,"transform must be an object");return}Nt(e.position,`${t}.position`,r),Nt(e.rotation,`${t}.rotation`,r),Nt(e.rotationDeg,`${t}.rotationDeg`,r),typeof e.scale=="number"?Number.isFinite(e.scale)||r(`${t}.scale`,"scale number must be finite"):Nt(e.scale,`${t}.scale`,r)}}function QT(e,t,r){if(!M(e)){r(t,"marker must be an object");return}Dr(e,["schemaVersion","label","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t,r),e.schemaVersion!==1&&r(`${t}.schemaVersion`,"marker.schemaVersion must be 1"),O(e.label)||r(`${t}.label`,"marker.label must be a non-empty string"),O(e.type)||r(`${t}.type`,"marker.type must be a non-empty string"),e.kind!=null&&!O(e.kind)&&r(`${t}.kind`,"marker.kind must be a non-empty string when present"),e.tags!=null&&(Array.isArray(e.tags)?e.tags.forEach((n,o)=>{typeof n!="string"&&r(`${t}.tags[${o}]`,"marker tag must be a string")}):r(`${t}.tags`,"marker.tags must be an array when present")),e.note!=null&&typeof e.note!="string"&&r(`${t}.note`,"marker.note must be a string when present"),e.color!=null&&nx(e.color,`${t}.color`,r),e.target!=null&&Dd(e.target,`${t}.target`,r),e.semanticFrame!=null&&tx(e.semanticFrame,`${t}.semanticFrame`,r),rx(e.geometry,`${t}.geometry`,r),e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker.metadata must be an object when present")}function ex(e,t,r,n,o,a){if(!M(e))return;let i=[];e.target!=null&&i.push({value:e.target,path:`${o}.target`}),M(e.geometry)&&e.geometry.target!=null&&i.push({value:e.geometry.target,path:`${o}.geometry.target`});for(let s of i)M(s.value)&&(s.value.kind!=="scene-object"&&s.value.kind!=="marker"&&a(`${s.path}.kind`,"runtime marker target kind must be scene-object or marker"),O(s.value.id)&&(s.value.id===t?a(`${s.path}.id`,"runtime marker target must not reference its marker node"):r.has(s.value.id)?s.value.kind==="marker"&&!n.has(s.value.id)?a(`${s.path}.id`,`runtime marker target must reference a marker node: ${s.value.id}`):s.value.kind==="scene-object"&&n.has(s.value.id)&&a(`${s.path}.id`,`runtime scene-object target must not reference a marker node: ${s.value.id}`):a(`${s.path}.id`,`runtime marker target must reference scene.nodes: ${s.value.id}`)))}function Dd(e,t,r){if(!M(e)){r(t,"marker target must be an object");return}Dr(e,["kind","id","label","path","metadata"],t,r),O(e.kind)||r(`${t}.kind`,"marker target kind must be a non-empty string"),O(e.id)||r(`${t}.id`,"marker target id must be a non-empty string");for(let n of["label","path"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker target ${n} must be a string when present`);e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker target metadata must be an object when present")}function tx(e,t,r){if(!M(e)){r(t,"marker semanticFrame must be an object");return}Dr(e,["origin","forward","right","up","label","description"],t,r),M(e.origin)?Nt(e.origin,`${t}.origin`,r):r(`${t}.origin`,"marker semanticFrame.origin must be a vector object");for(let n of["forward","right","up"])e[n]!=null&&Nt(e[n],`${t}.${n}`,r);for(let n of["label","description"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker semanticFrame ${n} must be a string when present`)}function rx(e,t,r){if(!M(e)){r(t,"marker.geometry must be an object");return}if(e.kind==="box"){Dr(e,["kind"],t,r);return}if(e.kind==="point"){Dr(e,["kind","coordinateSpace","position","offset","target"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&e.coordinateSpace!=="local"&&r(`${t}.coordinateSpace`,"point marker coordinateSpace must be world or local"),e.position!=null&&Nt(e.position,`${t}.position`,r),e.offset!=null&&Nt(e.offset,`${t}.offset`,r),e.target!=null&&Dd(e.target,`${t}.target`,r);return}if(e.kind==="object-bounds"){Dr(e,["kind","target"],t,r),Dd(e.target,`${t}.target`,r);return}if(e.kind==="polyhedron"){Dr(e,["kind","coordinateSpace","vertices","faces"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&r(`${t}.coordinateSpace`,"polyhedron marker coordinateSpace must be world"),Array.isArray(e.vertices)?e.vertices.forEach((n,o)=>{let a=`${t}.vertices[${o}]`;M(n)?Nt(n,a,r):r(a,"polyhedron marker vertex must be a vector object")}):r(`${t}.vertices`,"polyhedron marker vertices must be an array"),e.faces!=null&&(Array.isArray(e.faces)?e.faces.forEach((n,o)=>{Array.isArray(n)?n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&r(`${t}.faces[${o}][${i}]`,"polyhedron marker index must be a non-negative integer")}):r(`${t}.faces[${o}]`,"polyhedron marker face must be an array")}):r(`${t}.faces`,"polyhedron marker faces must be an array when present"));return}r(`${t}.kind`,"marker.geometry.kind must be box, point, object-bounds, or polyhedron")}function nx(e,t,r){if(!M(e)){r(t,"marker color must be an object");return}Dr(e,["r","g","b"],t,r);for(let n of["r","g","b"])Jf(e[n])||r(`${t}.${n}`,"marker color component must be between 0 and 1")}function Dr(e,t,r,n){let o=new Set(t);for(let a of Object.keys(e))o.has(a)||n(`${r}.${a}`,`field is not allowed: ${a}`)}function Nt(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y","z"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function ox(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function We(e){return typeof e=="number"&&Number.isFinite(e)}function Zr(e){return We(e)&&e>0}function Jf(e){return We(e)&&e>=0&&e<=1}function ji(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"color component must be a finite number")}}function ax(e,t,r){if(e!=null){if(!M(e)){r(t,"camera must be an object");return}e.projection!=null&&e.projection!=="orthographic"&&e.projection!=="perspective"&&r(`${t}.projection`,"camera projection must be orthographic or perspective");for(let n of["alpha","beta"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number when present");for(let n of["radius","orthoSize"])e[n]!=null&&!Zr(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number when present");e.fov!=null&&!Zr(e.fov)&&r(`${t}.fov`,"camera fov must be a positive finite number"),Nt(e.targetOffset,`${t}.targetOffset`,r),ox(e.targetScreenOffset,`${t}.targetScreenOffset`,r);for(let n of["minZ","maxZ","lowerRadiusLimit","upperRadiusLimit"])e[n]!=null&&!Zr(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number");for(let n of["lowerBetaLimit","upperBetaLimit"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number");e.inertia!=null&&!Jf(e.inertia)&&r(`${t}.inertia`,"camera inertia must be between 0 and 1"),Zr(e.minZ)&&Zr(e.maxZ)&&e.maxZ<=e.minZ&&r(`${t}.maxZ`,"camera maxZ must be greater than minZ"),We(e.lowerBetaLimit)&&We(e.upperBetaLimit)&&e.upperBetaLimit<e.lowerBetaLimit&&r(`${t}.upperBetaLimit`,"camera upperBetaLimit must be greater than or equal to lowerBetaLimit"),Zr(e.lowerRadiusLimit)&&Zr(e.upperRadiusLimit)&&e.upperRadiusLimit<e.lowerRadiusLimit&&r(`${t}.upperRadiusLimit`,"camera upperRadiusLimit must be greater than or equal to lowerRadiusLimit")}}function ix(e){let t=e.meta?.generatedFrom;return M(t)&&t.compilerId===PT&&t.compilerVersion===TT}function sx(e,t,r,n=!1){if(e==null)return;let o=n&&M(e)&&!Object.prototype.hasOwnProperty.call(e,"schemaVersion")?cx(e,t):e;try{Vn(o,t)}catch(a){let i=a;r(typeof i.path=="string"?i.path:t,typeof i.reason=="string"?i.reason:typeof i.message=="string"?i.message:"light does not satisfy the Engine Runtime Light contract")}}function cx(e,t){let r={...e,schemaVersion:1};if(e.type!=="directional"||!M(e.direction))return r;let{x:n,y:o,z:a}=e.direction;if(![n,o,a].every(s=>typeof s=="number"&&Number.isFinite(s)))return r;let i=Math.hypot(n,o,a);return i<=0||Math.abs(i-1)>xT?r:{...r,direction:Zo(e.direction,`${t}.direction`)}}function Bf(e,t,r){if(e!=null){if(!M(e)){r(t,"outline must be an object");return}e.renderOutline!=null&&typeof e.renderOutline!="boolean"&&r(`${t}.renderOutline`,"renderOutline must be boolean"),e.outlineWidth!=null&&(typeof e.outlineWidth!="number"||!Number.isFinite(e.outlineWidth))&&r(`${t}.outlineWidth`,"outlineWidth must be a finite number"),ji(e.outlineColor,`${t}.outlineColor`,r)}}function dx(e,t,r){if(e==null){r(t,"groundDecal is required when transformType is groundDecal");return}if(!M(e)){r(t,"groundDecal must be an object");return}lx(e,t,r)}function lx(e,t,r){if(O(e.uiKind)||r(`${t}.uiKind`,"groundDecal UI kind must be non-empty"),!M(e.size))r(`${t}.size`,"groundDecal.size must be an object");else for(let n of["width","depth"])(typeof e.size[n]!="number"||!Number.isFinite(e.size[n])||e.size[n]<=0)&&r(`${t}.size.${n}`,"groundDecal size must be a positive finite number");if(e.aspectSourceLayerId!=null&&!O(e.aspectSourceLayerId)&&r(`${t}.aspectSourceLayerId`,"aspectSourceLayerId must be non-empty when present"),e.lockAspectToBorder!=null&&typeof e.lockAspectToBorder!="boolean"&&r(`${t}.lockAspectToBorder`,"lockAspectToBorder must be boolean when present"),e.editorPreviewActive!=null&&r(`${t}.editorPreviewActive`,"editorPreviewActive is editor-only and must not appear in runtime scene data"),ux(e.mask,`${t}.mask`,r),mx(e.rendering,`${t}.rendering`,r),!Array.isArray(e.layers)){r(`${t}.layers`,"groundDecal UI layers must be an array");return}e.layers.forEach((n,o)=>fx(n,`${t}.layers[${o}]`,r)),px(e.layers,`${t}.layers`,r)}function ux(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI mask must be an object");return}e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"mask.enabled must be boolean"),e.source!=null&&e.source!=="roundedRect"&&e.source!=="borderAlpha"&&e.source!=="texture"&&r(`${t}.source`,"mask.source must be roundedRect, borderAlpha, or texture"),e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"mask.textureId must be non-empty when present");for(let n of["cornerRadius","padding"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n])||e[n]<0)&&r(`${t}.${n}`,`${n} must be a non-negative finite number`)}}function mx(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI rendering must be an object");return}for(let n of["textureWidth","textureHeight"])e[n]!=null&&(!Number.isInteger(e[n])||e[n]<=0)&&r(`${t}.${n}`,`${n} must be a positive integer`);for(let n of["alphaIndex","diffuseTextureLevel","emissiveTextureLevel"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`${n} must be a finite number`)}}function fx(e,t,r){if(!M(e)){r(t,"groundDecal UI layer must be an object");return}O(e.id)||r(`${t}.id`,"layer.id must be non-empty"),O(e.role)||r(`${t}.role`,"layer.role must be non-empty"),e.editorPreviewPercent!=null&&r(`${t}.editorPreviewPercent`,"editorPreviewPercent is editor-only and must not appear in runtime scene data"),e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"layer.enabled must be boolean"),(typeof e.zOrder!="number"||!Number.isFinite(e.zOrder))&&r(`${t}.zOrder`,"layer.zOrder must be a finite number"),e.opacity!=null&&(typeof e.opacity!="number"||!Number.isFinite(e.opacity))&&r(`${t}.opacity`,"layer.opacity must be finite"),e.rotationDeg!=null&&(typeof e.rotationDeg!="number"||!Number.isFinite(e.rotationDeg)||e.rotationDeg<=-180||e.rotationDeg>180)&&r(`${t}.rotationDeg`,"layer.rotationDeg must be in the range (-180, 180]"),gx(e.rect,`${t}.rect`,r),e.kind==="texture"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture layer imageFit must be contain or stretch"),qn(e.tint,`${t}.tint`,r)):e.kind==="textureProgress"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture progress layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture progress layer imageFit must be contain or stretch"),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"texture progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"texture progress direction is invalid"),qn(e.tint,`${t}.tint`,r)):e.kind==="color"?qn(e.color,`${t}.color`,r):e.kind==="progress"?((typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"progress direction is invalid"),qn(e.color,`${t}.color`,r)):e.kind==="text"?bx(e.text,`${t}.text`,r):r(`${t}.kind`,"layer.kind must be texture, textureProgress, color, progress, or text")}function px(e,t,r){let n=new Map;e.forEach((o,a)=>{if(!M(o)||!O(o.id))return;let i=n.get(o.id);if(i!=null){r(`${t}[${a}].id`,`layer.id must be unique; duplicate of layers[${i}]`);return}n.set(o.id,a)})}function gx(e,t,r){if(!M(e)){r(t,"layer.rect must be an object");return}for(let n of["x","z","width","depth"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`rect.${n} must be a finite number`);for(let n of["width","depth"])typeof e[n]=="number"&&e[n]<=0&&r(`${t}.${n}`,`rect.${n} must be positive`)}function bx(e,t,r){if(!M(e)){r(t,"text layer text must be an object");return}typeof e.value!="string"&&r(`${t}.value`,"text.value must be a string"),e.fontFamily!=null&&typeof e.fontFamily!="string"&&r(`${t}.fontFamily`,"fontFamily must be a string"),e.fontSize!=null&&(typeof e.fontSize!="number"||!Number.isFinite(e.fontSize)||e.fontSize<=0)&&r(`${t}.fontSize`,"fontSize must be a positive finite number"),e.fontWeight!=null&&typeof e.fontWeight!="string"&&r(`${t}.fontWeight`,"fontWeight must be a string"),qn(e.color,`${t}.color`,r),qn(e.strokeColor,`${t}.strokeColor`,r),e.strokeWidth!=null&&(typeof e.strokeWidth!="number"||!Number.isFinite(e.strokeWidth)||e.strokeWidth<0)&&r(`${t}.strokeWidth`,"strokeWidth must be a non-negative finite number")}function qn(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`color.${n} must be finite`);e.a!=null&&(typeof e.a!="number"||!Number.isFinite(e.a))&&r(`${t}.a`,"color.a must be finite")}}function Sx(e,t,r){if(e!=null){if(!M(e)){r(t,"rendering must be an object");return}e.renderingGroupId!=null&&e.renderingGroupId!==0&&e.renderingGroupId!==1&&e.renderingGroupId!==2&&e.renderingGroupId!==3&&r(`${t}.renderingGroupId`,"renderingGroupId must be 0, 1, 2, or 3"),e.alphaIndex!=null&&(typeof e.alphaIndex!="number"||!Number.isFinite(e.alphaIndex))&&r(`${t}.alphaIndex`,"alphaIndex must be a finite number")}}function Vf(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Xf(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;["albedoColor","diffuseColor","emissiveColor","outlineColor"].includes(n)&&ji(o,a,r),["metallic","roughness","contrast","brightness","saturation","hue","colorDensity","alpha","alphaCutOff","transparencyMode"].includes(n)&&(typeof o!="number"||!Number.isFinite(o))&&r(a,`${n} must be a finite number`),n==="backFaceCulling"&&typeof o!="boolean"&&r(a,"backFaceCulling must be boolean"),["albedoTexture","normalTexture","metallicTexture"].includes(n)&&(M(o)?o.url!=null&&!O(o.url)&&r(`${a}.url`,"texture url must be non-empty when present"):r(a,`${n} must be an object`)),["pbr","standard"].includes(n)&&(M(o)?Xf(o,a,r):r(a,`${n} must be an object`))}}function Uf(e,t,r){let n=JSON.stringify(e),o=CT.filter(a=>n.includes(a));o.length>0&&r(t,`contains runtime-only asset fields: ${o.join(", ")}`)}function yx(e,t,r){let n=Yf(e)??512,o=Yf(t)??512;if(!Number.isFinite(r)||r<=0)return{width:n,height:o};let a=n,i=Math.max(1,Math.round(a/r));return i>o&&(i=o,a=Math.max(1,Math.round(i*r))),{width:a,height:i}}function Fi(e){let t=e.rendering?.textureWidth??512,r=e.rendering?.textureHeight??512,n=e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:t/r;return yx(t,r,n)}function Yf(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:Math.max(64,Math.min(2048,Math.round(e)))}function Zf(e,t){let r=wd(t.ids);if(r.length===0)return J("empty-selection");for(let s of r)if(!ir(e,s))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");for(let s of n){let c=ir(e,s);if(!c)return J("missing-node");if(!rp(c))return J(c.protected?"node-protected":c.locked?"node-locked":"node-readonly")}if(t.placement==="root")return t.parentId!=null||t.beforeId!=null||t.afterId!=null?J("invalid-root-anchors"):_i();let o=ir(e,t.targetId);if(!o)return J("missing-target-node");if(n.includes(o.id))return J("cannot-parent-to-self");if(n.some(s=>ep(e,o.id,s)))return J("cannot-parent-to-descendant");if(t.placement==="inside"){if(!tp(o))return J("target-cannot-have-children");if(t.parentId!=null&&t.parentId!==o.id)return J("invalid-parent-anchor");let s=Md(e,o.id).filter(c=>!n.includes(c));return t.beforeId&&!s.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!s.includes(t.afterId)?J("invalid-after-anchor"):_i()}if(o.locked&&!o.protected)return J("target-node-locked");if(o.protected)return J("cannot-reorder-root");let a=ir(e,o.parentId);if(a?.locked&&!a.protected)return J("target-parent-locked");if((t.parentId??null)!==(o.parentId??null))return J("invalid-parent-anchor");let i=Md(e,o.parentId??null).filter(s=>!n.includes(s));return t.beforeId&&!i.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!i.includes(t.afterId)?J("invalid-after-anchor"):t.placement==="before"&&t.beforeId!==o.id?J("invalid-before-anchor"):t.placement==="after"&&t.afterId!==o.id?J("invalid-after-anchor"):_i()}function Qf(e,t){let r=wd(t.ids);if(r.length===0)return J("empty-selection");for(let i of r)if(!ir(e,i))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");if(n.length<2)return J("selection-too-small");for(let i of n){let s=ir(e,i);if(!s)return J("missing-node");if(!rp(s))return J(s.protected?"node-protected":s.locked?"node-locked":"node-readonly")}let o=ir(e,t.parentId);if(t.parentId&&!o)return J("missing-parent-node");if(o&&!tp(o))return J("parent-cannot-have-children");if(o&&n.some(i=>o.id===i||ep(e,o.id,i)))return J("cannot-parent-to-descendant");let a=Md(e,t.parentId??null).filter(i=>!n.includes(i));if(t.insertBeforeId){let i=ir(e,t.insertBeforeId);if(!a.includes(t.insertBeforeId)||i?.protected)return J("invalid-before-anchor")}return _i()}function ir(e,t){return t?e.find(r=>r.id===t)??null:null}function wd(e){let t=[],r=new Set;for(let n of e)!n||r.has(n)||(r.add(n),t.push(n));return t}function St(e,t){let r=wd(t).filter(o=>!!ir(e,o)),n=new Set(r);return r.filter(o=>!hx(e,o).some(a=>n.has(a)))}function Md(e,t){return e.filter(r=>(r.parentId??null)===(t??null)).map(r=>r.id)}function ep(e,t,r){let n=new Map(e.map(i=>[i.id,i])),o=n.get(t)??null,a=new Set;for(;o?.parentId;){if(o.parentId===r)return!0;if(a.has(o.parentId))return!1;a.add(o.parentId),o=n.get(o.parentId)??null}return!1}function tp(e){return!e||e.locked&&!e.protected?!1:e.canHaveChildren===!0}function rp(e){return!!e&&e.protected!==!0&&e.locked!==!0&&e.draggable!==!1}function hx(e,t){let r=new Map(e.map(i=>[i.id,i])),n=[],o=new Set,a=r.get(t)??null;for(;a?.parentId&&!o.has(a.parentId);)o.add(a.parentId),n.push(a.parentId),a=r.get(a.parentId)??null;return n}function _i(){return{ok:!0}}function J(e){return{ok:!1,reason:e}}var yt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),Qr={kind:"texture"},np={kind:"color"},Ex={kind:"enum",values:["lit","unlit"]},Ix={kind:"enum",values:["opaque","mask","blend"]},ip={lightingModel:Ex,baseColor:{kind:"object",properties:{color:np,texture:Qr,brightness:yt(0),saturation:yt(0),contrast:yt(0),hue:yt(-180,180)}},normal:{kind:"object",properties:{texture:Qr,strength:yt(0)}},emission:{kind:"object",properties:{color:np,intensity:yt(0),texture:Qr,maskTexture:Qr}},alpha:{kind:"object",properties:{mode:Ix,opacity:yt(0,1),cutoff:yt(0,1),texture:Qr}}},Px={kind:"object",properties:{...ip,metallic:yt(0,1),roughness:yt(0,1),metallicRoughness:{kind:"object",properties:{texture:Qr}},occlusion:{kind:"object",properties:{texture:Qr,strength:yt(0)}}}},Tx={kind:"object",properties:ip},xx={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}},Ax={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}},op=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],en={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},sp=[Xn("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Xn("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),Yn("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),ht("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),Yn("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[en]),ht("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[en,Jn("properties.normal.texture.textureAssetId","normalTexture")]}),Xn("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),ht("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),Yn("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Xn("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"}),ht("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),ht("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),Yn("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],Dx=[...sp,ht("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[en]}),ht("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[en]}),Yn("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[en]),Yn("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[en]),ht("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[en,Jn("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],Mx=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:Px,defaultProperties:xx,inspector:{sections:op,fields:Dx}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Tx,defaultProperties:Ax,inspector:{sections:op,fields:sp}}],Mr=wx(Mx);function wx(e){let t=new Map;for(let n of e){Ox(n,t);let o=Rx(n);t.set(n.shaderId,lp(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Od(e,t=Mr){return t.get(e)}function De(e){return Od(e)}function kx(e,t,r=Mr){let n=Cd(t);return r.get(e)?.inspector.fields.find(a=>a.path===n)??null}function Zn(e,t,r=Mr){let n=Od(e,r);if(!n)return null;let o=kx(e,t,r),i=(o?.schemaPath??Cd(t)).replace(/^properties\./,"").split(".").filter(Boolean);if(i.length===0)return null;let s=n.propertiesSchema;for(let c=0;c<i.length;c+=1){let d=i[c];if(s.kind==="texture"&&c===i.length-1&&(d==="url"||d==="textureAssetId"))return{kind:"string",nullable:!0};if(s.kind!=="object")return null;let u=s.properties[d];if(!u)return null;s=u}return o?.control==="texture"&&s.kind==="texture"?{kind:"string",nullable:!0}:s}function Rd(e){let t=De(e);if(!t)throw new Error(`Unknown built-in material shader: ${e}`);return structuredClone(t.defaultProperties)}function Qn(e,t,r="properties",n=Mr){let o=Od(e,n);if(!o)return[{path:"shaderId",message:`Unknown material shader: ${String(e)}`}];let a=[];return vd(o.propertiesSchema,t,r,a),a}function Xn(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function ht(e,t,r,n,o,a,i={}){return Xn(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function Yn(e,t,r,n,o,a,i,s){return Xn(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",conditions:s})}function Jn(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Ox(e,t){if(!Hn(e.shaderId)&&!ta(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(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!vx(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);cp(e.shaderId,e.propertiesSchema,"properties");let r=[];if(vd(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);Cx(e,a),o.add(a.path)}}function Rx(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=dp(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function Cx(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=dp(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function cp(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))cp(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function vx(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function Cd(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function dp(e,t){let r=Cd(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function vd(e,t,r,n){if(e.kind==="object"){if(!kd(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&vd(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];ap(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){ap(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!kd(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function ap(e,t,r,n,o){if(!kd(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function lp(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))lp(t)}return e}function kd(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function eo(e,t={}){let r=new Map;for(let n of t.builtInMarkerTypes??[])r.set(n.type,jx(n));for(let n of ra(e)){let o=r.get(n.type)??null;r.set(n.type,Nx(o,n))}return[...r.values()]}function jd(e){return structuredClone(e)}function jx(e){return{...jd(e),metadata:{...e.metadata??{},builtIn:!0}}}function Nx(e,t){let r=e??null;return{...r??{},...jd(t),type:t.type,label:t.label||r?.label||t.type,metadata:{...r?.metadata??{},...t.metadata??{},builtIn:r?.metadata?.builtIn===!0}}}function Fx(e,t,r={}){if(!pp(t)||_d(t.type,r))return e;let n=ra(e);return n.some(o=>o.type===t.type)?e:Fd(e,[...n,Nd(t,!1)])}function _x(e,t,r,n={}){let o=t.trim();if(!o)return e;let a=_d(o,n),i=ra(e),s=i.find(u=>u.type===o)??null;if(!a&&!s)return e;let c=s??a;if(!c)return e;let d=Nd({...c,...r,type:o,label:typeof r.label=="string"&&r.label.trim()?r.label.trim():c.label||o},!!a);return Fd(e,[...i.filter(u=>u.type!==o),d])}function $x(e,t,r={}){let n=t.trim();if(!n||gp(n,r)||e.markers.some(i=>i.markerType===n))return e;let o=ra(e),a=o.filter(i=>i.type!==n);return a.length===o.length?e:Fd(e,a)}function Nd(e,t){return{type:e.type.trim(),label:e.label.trim()||e.type.trim(),...e.kind?{kind:e.kind}:{},...e.description!==void 0?{description:e.description}:{},...e.defaultTags?{defaultTags:[...e.defaultTags]}:{},metadata:{...e.metadata??{},builtIn:!1,...t?{overridesBuiltIn:!0}:{}}}}function ra(e){let t=e?.metadata?.markerTypes;return Array.isArray(t)?t.map(Lx).filter(r=>!!r):[]}function Fd(e,t){let r=e.metadata?structuredClone(e.metadata):{};return t.length===0?delete r.markerTypes:r.markerTypes=t.map(jd),{...e,metadata:Object.keys(r).length>0?r:void 0}}function Lx(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.type!="string"||!t.type.trim()||typeof t.label!="string"||!t.label.trim()?null:Nd({type:t.type.trim(),label:t.label.trim(),...typeof t.kind=="string"&&t.kind?{kind:t.kind}:{},...typeof t.description=="string"?{description:t.description}:{},...Array.isArray(t.defaultTags)?{defaultTags:t.defaultTags.filter(r=>typeof r=="string")}:{},...t.metadata&&typeof t.metadata=="object"?{metadata:t.metadata}:{}},t.metadata?.overridesBuiltIn===!0)}function pp(e){return!!e.type.trim()&&!!e.label.trim()}function _d(e,t={}){let r=e.trim();return t.builtInMarkerTypes?.find(n=>n.type===r)??null}function gp(e,t={}){return!!_d(e,t)}function sr(e){let{spatial:t,...r}=structuredClone(e);return r}function $i(e){return structuredClone(e)}function bp(e,t){return{...$i(e),from:up(e.from,t),to:up(e.to,t)}}function Sp(e,t){return{...sr(e),...e.target?{target:Gd(e.target,t)}:{},geometry:zx(e.geometry,t)}}function zx(e,t){switch(e.kind){case"point":return{...structuredClone(e),...e.target?{target:Gd(e.target,t)}:{}};case"object-bounds":return{...structuredClone(e),target:Gd(e.target,t)};case"box":case"polyhedron":return structuredClone(e)}}function Gd(e,t){return e.kind!=="marker"?structuredClone(e):{...structuredClone(e),id:t.get(e.id)??e.id}}function up(e,t){return e.kind!=="marker"?{...e}:{...e,id:t.get(e.id)??e.id}}function yp(e,t){let r=new Set([t]),n=!0;for(;n;){n=!1;for(let o of e.scene.gameObjects)!o.parentId||!r.has(o.parentId)||r.has(o.id)||(r.add(o.id),n=!0)}return r}function $d(e,t){return(e.kind==="marker"||e.kind==="scene-object")&&t.has(e.id)}function na(e,t){return!e||e.kind!=="scene-object"||t.has(e.id)}function Ld(e,t,r){return e.kind==="marker"?r.has(e.id):e.kind==="scene-object"?t.has(e.id):!0}function mp(e,t){return e.kind==="marker"&&e.id===t}function cr(e){if(!e)return{schemaVersion:1,markers:[],relations:[]};let t=structuredClone(e),{metadata:r,...n}=t;return{...n,schemaVersion:1,markers:e.markers.map(sr),relations:e.relations.map($i),...r?{metadata:structuredClone(r)}:{}}}function zd(e,t){return{...e,scene:{...e.scene,markerGraph:t}}}function Bx(e,t){let r=sr(t),n=e.markers.some(o=>o.id===r.id);return{...e,markers:n?e.markers.map(o=>o.id===r.id?r:o):[...e.markers,r]}}function Vx(e,t,r){let n=!1,o=e.markers.map(a=>a.id!==t?a:(n=!0,sr({...a,...r,id:a.id})));return n?{...e,markers:o}:e}function Ux(e,t){return{...e,markers:e.markers.filter(r=>r.id!==t),relations:e.relations.filter(r=>!mp(r.from,t)&&!mp(r.to,t))}}function fp(e,t){let r=$i(t),n=e.relations.some(o=>o.id===r.id);return{...e,relations:n?e.relations.map(o=>o.id===r.id?r:o):[...e.relations,r]}}function Kx(e,t){let r=!1,n=e.relations.map(o=>o.id!==t?o:(r=!0,{...$i(o),from:{...o.to},to:{...o.from}}));return r?{...e,relations:n}:e}function hp(e,t,r={}){switch(t.type){case"marker.create-box":return Bx(e,t.marker);case"marker.update":return Vx(e,t.markerId,t.patch);case"marker.delete":return Ux(e,t.markerId);case"relation.create":return fp(e,t.relation);case"relation.create-many":return t.relations.reduce((n,o)=>fp(n,o),e);case"relation.delete":return{...e,relations:e.relations.filter(n=>n.id!==t.relationId)};case"relation.delete-many":{let n=new Set(t.relationIds);return{...e,relations:e.relations.filter(o=>!n.has(o.id))}}case"relation.reverse":return Kx(e,t.relationId);case"marker.sync-from-scene":return e;case"marker-type.create":return Fx(e,t.definition,r);case"marker-type.update":return _x(e,t.typeId,t.patch,r);case"marker-type.delete":return $x(e,t.typeId,r)}}function Ep(e,t,r={}){if(t.type!=="marker.create-box")return t;let n=sr(t.marker),o=new Set(e.scene.gameObjects.map(i=>i.id)),a=new Set(e.scene.gameObjects.map(i=>(i.name??"").trim()).filter(Boolean));return o.has(n.id)&&(n.id=Hx(n.id,o,r.sanitizeMarkerGameObjectId)),(!n.label.trim()||a.has(n.label.trim()))&&(n.label=qx(n.label||n.id,a)),{...t,marker:n}}function Hx(e,t,r){let o=(r??Wx)(e).replace(/-\d+$/,"")||"marker";if(!t.has(o))return o;let a=2;for(;t.has(`${o}-${a}`);)a+=1;return`${o}-${a}`}function Wx(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function qx(e,t){let n=(e.trim()||"Marker").replace(/\s+\d+$/,"")||"Marker";if(!t.has(n))return n;let o=2;for(;t.has(`${n} ${o}`);)o+=1;return`${n} ${o}`}function Ip(e,t,r,n={}){switch(t.type){case"marker.create-box":return Jx(e,t.marker.geometry)&&!!t.marker.id.trim()&&!e.scene.gameObjects.some(o=>o.id===t.marker.id)&&Xx(e,t.parentId??null,n);case"relation.create-many":return t.relations.length>0;case"relation.delete-many":return t.relationIds.length>0;case"relation.reverse":return r.relations.some(o=>o.id===t.relationId);case"marker-type.create":return pp(t.definition)&&!eo(e.scene.markerGraph,n).some(o=>o.type===t.definition.type);case"marker-type.update":return!!t.typeId.trim()&&eo(e.scene.markerGraph,n).some(o=>o.type===t.typeId);case"marker-type.delete":{let o=t.typeId.trim();return!o||gp(o,n)?!1:!r.markers.some(a=>a.markerType===o)&&ra(r).some(a=>a.type===o)}default:return!0}}function Jx(e,t){switch(t.kind){case"box":case"point":return!0;case"object-bounds":return na(t.target,new Set(e.scene.gameObjects.map(r=>r.id)));case"polyhedron":return!1}}function Xx(e,t,r){if(!t)return!0;let n=e.scene.gameObjects.find(o=>o.id===t)??null;return!!n&&!(r.isMarkerGameObject?.(n)??!!n.marker)}function Pp(e){switch(e.type){case"marker.create-box":return`Create marker ${e.marker.label}`;case"marker.update":return`Update marker ${e.markerId}`;case"marker.delete":return`Delete marker ${e.markerId}`;case"relation.create":return`Create relation ${e.relation.type}`;case"relation.create-many":return`Create ${e.relations.length} relations`;case"relation.delete":return`Delete relation ${e.relationId}`;case"relation.delete-many":return`Delete ${e.relationIds.length} relations`;case"relation.reverse":return`Reverse relation ${e.relationId}`;case"marker.sync-from-scene":return"Sync marker graph";case"marker-type.create":return`Create marker type ${e.definition.label}`;case"marker-type.update":return`Update marker type ${e.typeId}`;case"marker-type.delete":return`Delete marker type ${e.typeId}`}}function Tp(e){switch(e.type){case"marker.create-box":return{changedId:e.marker.id,changedIds:[e.marker.id],selectId:e.marker.id};case"marker.update":case"marker.delete":return{changedId:e.markerId,changedIds:[e.markerId]};case"relation.create":return{changedIds:[e.relation.from.id,e.relation.to.id]};case"relation.create-many":return{changedIds:[...new Set(e.relations.flatMap(t=>[t.from.id,t.to.id]))]};case"relation.delete":case"relation.delete-many":case"relation.reverse":case"marker.sync-from-scene":case"marker-type.create":case"marker-type.update":case"marker-type.delete":return{}}}function Bd(e){let t=structuredClone(e);if(t.type==="marker.create-box"&&(t.marker=sr(t.marker)),t.type==="marker.update"){let{spatial:r,...n}=t.patch;t.patch=n}return t}function oa(e,t){return JSON.stringify(e)===JSON.stringify(t)}function xp(e,t,r,n={}){let o=t.find(a=>a.path===r.path);if(!o)throw new Error(`Serialized property descriptor not found: ${r.path}`);if(o.readOnly===!0||typeof o.setValue!="function")throw new Error(`Serialized property is read-only: ${r.path}`);return o.setValue(e,r.value,{...n,targetId:r.targetId})}var Li="summary",Ap="body";function Et(){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function Yx(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Bi(e){let t=Op(e);return t&&Zx(t)?{mode:"matrix",matrix:t}:null}function Dp(e){return tt(e)?{mode:"matrix",matrix:Jd(e.matrix)}:{...e.mode==="trs"?{mode:"trs"}:{},position:zi(e.position),rotation:zi(e.rotation),scale:zi(e.scale)}}function tt(e){return e.mode==="matrix"}function It(e){return e.mode!=="matrix"}function Vi(e){return tt(e)?{x:e.matrix[12],y:e.matrix[13],z:e.matrix[14]}:zi(e.position)}function Zx(e){return!!Op(e)&&Math.abs(e[3])<=1e-6&&Math.abs(e[7])<=1e-6&&Math.abs(e[11])<=1e-6&&Math.abs(e[15]-1)<=1e-6&&!!Mp(e)}function Fe(e){if(tt(e))return Jd(e.matrix);let t=Qx(e.rotation),r=t.x,n=t.y,o=t.z,a=t.w,i=r+r,s=n+n,c=o+o,d=r*i,u=r*s,l=r*c,m=n*s,f=n*c,S=o*c,g=a*i,b=a*s,y=a*c,E=e.scale.x,I=e.scale.y,P=e.scale.z;return[(1-(m+S))*E,(u+y)*E,(l-b)*E,0,(u-y)*I,(1-(d+S))*I,(f+g)*I,0,(l+b)*P,(f-g)*P,(1-(d+m))*P,0,e.position.x,e.position.y,e.position.z,1]}function Hd(e,t){return[e[0]*t[0]+e[1]*t[4]+e[2]*t[8]+e[3]*t[12],e[0]*t[1]+e[1]*t[5]+e[2]*t[9]+e[3]*t[13],e[0]*t[2]+e[1]*t[6]+e[2]*t[10]+e[3]*t[14],e[0]*t[3]+e[1]*t[7]+e[2]*t[11]+e[3]*t[15],e[4]*t[0]+e[5]*t[4]+e[6]*t[8]+e[7]*t[12],e[4]*t[1]+e[5]*t[5]+e[6]*t[9]+e[7]*t[13],e[4]*t[2]+e[5]*t[6]+e[6]*t[10]+e[7]*t[14],e[4]*t[3]+e[5]*t[7]+e[6]*t[11]+e[7]*t[15],e[8]*t[0]+e[9]*t[4]+e[10]*t[8]+e[11]*t[12],e[8]*t[1]+e[9]*t[5]+e[10]*t[9]+e[11]*t[13],e[8]*t[2]+e[9]*t[6]+e[10]*t[10]+e[11]*t[14],e[8]*t[3]+e[9]*t[7]+e[10]*t[11]+e[11]*t[15],e[12]*t[0]+e[13]*t[4]+e[14]*t[8]+e[15]*t[12],e[12]*t[1]+e[13]*t[5]+e[14]*t[9]+e[15]*t[13],e[12]*t[2]+e[13]*t[6]+e[14]*t[10]+e[15]*t[14],e[12]*t[3]+e[13]*t[7]+e[14]*t[11]+e[15]*t[15]]}function Mp(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=t*i-r*a,E=t*s-n*a,I=t*c-o*a,P=r*s-n*i,A=r*c-o*i,$=n*c-o*s,z=d*S-u*f,p=d*g-l*f,D=d*b-m*f,h=u*g-l*S,R=u*b-m*S,K=l*b-m*g,ne=y*K-E*R+I*h+P*D-A*p+$*z;if(!Number.isFinite(ne)||Math.abs(ne)<1e-6)return null;let F=1/ne;return[(i*K-s*R+c*h)*F,(n*R-r*K-o*h)*F,(S*$-g*A+b*P)*F,(l*A-u*$-m*P)*F,(s*D-a*K-c*p)*F,(t*K-n*D+o*p)*F,(g*I-f*$-b*E)*F,(d*$-l*I+m*E)*F,(a*R-i*D+c*z)*F,(r*D-t*R-o*z)*F,(f*A-S*I+b*y)*F,(u*I-d*A-m*y)*F,(i*p-a*h-s*z)*F,(t*h-r*p+n*z)*F,(S*E-f*P-g*y)*F,(d*P-u*E+l*y)*F]}function Wd(e){let t={x:e[12],y:e[13],z:e[14]},r={x:Vd(e[0],e[1],e[2]),y:Vd(e[4],e[5],e[6]),z:Vd(e[8],e[9],e[10])};if(nA(e)<=0&&(r.y*=-1),!Kd(t)||!Kd(r)||Math.abs(r.x)<1e-6||Math.abs(r.y)<1e-6||Math.abs(r.z)<1e-6)return null;let n=1/r.x,o=1/r.y,a=1/r.z,i=[e[0]*n,e[1]*n,e[2]*n,0,e[4]*o,e[5]*o,e[6]*o,0,e[8]*a,e[9]*a,e[10]*a,0,0,0,0,1];if(!oA(i))return null;let s=rA(tA(i));if(!s)return null;let c=eA(s);if(!Kd(c))return null;let d={position:t,rotation:c,scale:r};return aa(Fe(d),e,1e-5)?d:null}function qd(e,t={}){let r=Wd(e);return r||(t.allowMatrixFallback?Bi(e):null)}function wp(e){let t=Yx();for(let r of e)t=Hd(Fe(r),t);return qd(t,{allowMatrixFallback:!0})}function kp(e,t){return qd(Hd(Fe(t),Fe(e)),{allowMatrixFallback:!0})}function to(e,t,r={}){let n=Mp(Fe(e));return n?qd(Hd(Fe(t),n),r):null}function aa(e,t,r=1e-6){return e.length===t.length&&e.every((n,o)=>Math.abs(n-t[o])<=r)}function Jd(e){return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]]}function Op(e){return e.length!==16||!e.every(Number.isFinite)?null:Jd(e)}function zi(e){return{x:e.x,y:e.y,z:e.z}}function Qx(e){let t=e.z*.5,r=e.x*.5,n=e.y*.5,o=Math.sin(t),a=Math.cos(t),i=Math.sin(r),s=Math.cos(r),c=Math.sin(n),d=Math.cos(n);return{x:d*i*a+c*s*o,y:c*s*a-d*i*o,z:d*s*o-c*i*a,w:d*s*a+c*i*o}}function eA(e){let t=e.z,r=e.x,n=e.y,o=e.w,a=n*t-r*o,i=.4999999;if(a<-i)return{x:Math.PI/2,y:2*Math.atan2(n,o),z:0};if(a>i)return{x:-Math.PI/2,y:2*Math.atan2(n,o),z:0};let s=o*o,c=t*t,d=r*r,u=n*n;return{z:Math.atan2(2*(r*n+t*o),-c-d+u+s),x:Math.asin(-2*a),y:Math.atan2(2*(t*r+n*o),c-d-u+s)}}function tA(e){let t=e[0],r=e[4],n=e[8],o=e[1],a=e[5],i=e[9],s=e[2],c=e[6],d=e[10],u=t+a+d;if(u>0){let m=.5/Math.sqrt(u+1);return{w:.25/m,x:(c-i)*m,y:(n-s)*m,z:(o-r)*m}}if(t>a&&t>d){let m=2*Math.sqrt(1+t-a-d);return{w:(c-i)/m,x:.25*m,y:(r+o)/m,z:(n+s)/m}}if(a>d){let m=2*Math.sqrt(1+a-t-d);return{w:(n-s)/m,x:(r+o)/m,y:.25*m,z:(i+c)/m}}let l=2*Math.sqrt(1+d-t-a);return{w:(o-r)/l,x:(n+s)/l,y:(i+c)/l,z:.25*l}}function rA(e){let t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w);return!Number.isFinite(t)||t<1e-6?null:{x:e.x/t,y:e.y/t,z:e.z/t,w:e.w/t}}function nA(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=l*b-g*m,E=u*b-S*m,I=u*g-S*l,P=d*b-f*m,A=d*g-l*f,$=d*S-f*u,z=+(i*y-s*E+c*I),p=-(a*y-s*P+c*A),D=+(a*E-i*P+c*$),h=-(a*I-i*A+s*$);return t*z+r*p+n*D+o*h}function Vd(e,t,r){return Math.sqrt(e*e+t*t+r*r)}function oA(e){let t={x:e[0],y:e[1],z:e[2]},r={x:e[4],y:e[5],z:e[6]},n={x:e[8],y:e[9],z:e[10]};return Math.abs(Ud(t,r))<1e-6&&Math.abs(Ud(t,n))<1e-6&&Math.abs(Ud(r,n))<1e-6}function Ud(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Kd(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}var aA={supportsShear:!1,supportsMatrixTransform:!1};function Ui(e={}){let t={...aA,...e.storageCapabilities};return{allowMatrixFallback:(e.allowMatrixFallback??!1)&&t.supportsMatrixTransform&&t.supportsShear,storageCapabilities:t}}function w(e){return typeof e=="number"&&Number.isFinite(e)}function tn(e){return e==null||typeof e=="string"}function rn(e){return e==null||typeof e=="string"&&e.trim().length>0}function Ki(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Hi(e){return e==null||typeof e=="boolean"}function qe(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)&&w(t.z)}function Wi(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)}function ia(e){if(w(e))return e>=0;if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&t.x>=0&&w(t.y)&&t.y>=0&&w(t.z)&&t.z>=0}function Ft(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.r)&&w(t.g)&&w(t.b)}function _t(e){return w(e)&&e>0}function sa(e){return w(e)&&e>=0}function qi(e){return w(e)&&e>=0&&e<=1}function Ji(e){if(!e||typeof e!="object")return!1;let t=e;return!(t.position!==void 0&&!qe(t.position)||t.rotation!==void 0&&!qe(t.rotation)||t.rotationDeg!==void 0&&!qe(t.rotationDeg)||t.scale!==void 0&&!ia(t.scale))}function Xi(e){return e==="orthographic"||e==="perspective"}function Yi(e){return e==="hemispheric"||e==="directional"}var $t=["group","instance","transform","primitive"],Rp=["instance","transform","primitive"],iA=["position","rotation","scale"],sA=["x","y","z"];function cA(e){return{path:`transform.${e}`,appliesTo:$t,validate:t=>t==null||(e==="scale"?ia(t):qe(t))}}function dA(e,t){return{path:`transform.${e}.${t}`,appliesTo:$t,...e==="scale"?{allowDelete:!1}:{},validate:r=>r==null||(e==="scale"?sa(r):w(r))}}function lA(e){return[cA(e),...sA.map(t=>dA(e,t))]}var Xd=[{path:"name",appliesTo:$t,validate:tn},{path:"parentId",appliesTo:$t,validate:tn},{path:"enabled",appliesTo:$t,validate:Hi},{path:"shadow.cast",appliesTo:Rp,validate:e=>typeof e=="boolean"},{path:"shadow.receive",appliesTo:Rp,validate:e=>typeof e=="boolean"},{path:"transform",appliesTo:$t,validate:e=>e==null||Ji(e)},...iA.flatMap(lA),{path:"transform.rotationDeg",appliesTo:$t,validate:e=>e==null||qe(e)},{path:"transform.rotationDeg.x",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.y",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.z",appliesTo:$t,validate:e=>e==null||w(e)},{path:"instance.assetId",appliesTo:["instance"],validate:e=>typeof e=="string"&&e.trim().length>0,allowDelete:!1},{path:"primitive.shape",appliesTo:["primitive"],validate:e=>e==="cube"||e==="sphere"||e==="plane"||e==="capsule",allowDelete:!1},{path:"camera.projection",appliesTo:["transform"],validate:Xi,allowDelete:!1},{path:"camera.alpha",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.beta",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.radius",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.orthoSize",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.fov",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.targetOffset",appliesTo:["transform"],validate:e=>e==null||qe(e)},{path:"camera.targetOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.minZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.maxZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.lowerBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.upperBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.lowerRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.upperRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.inertia",appliesTo:["transform"],validate:qi,allowDelete:!1},{path:"camera.targetScreenOffset",appliesTo:["transform"],validate:e=>e==null||Wi(e)},{path:"camera.targetScreenOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetScreenOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.type",appliesTo:["transform"],validate:Yi,allowDelete:!1},{path:"light.intensity",appliesTo:["transform"],validate:sa,allowDelete:!1},{path:"light.direction",appliesTo:["transform"],validate:qe,allowDelete:!1},{path:"light.direction.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.diffuseColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"light.groundColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.type",appliesTo:["transform"],validate:tn,allowDelete:!1},{path:"marker.kind",appliesTo:["transform"],validate:rn},{path:"marker.tags",appliesTo:["transform"],validate:e=>e==null||Ki(e)},{path:"marker.note",appliesTo:["transform"],validate:tn},{path:"marker.color",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.color.r",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.g",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.b",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1}];var ie=["instance","transform","primitive"];function Je(e){return{path:e,appliesTo:ie,validate:t=>t==null||Ft(t)}}function V(e){return{path:e,appliesTo:ie,validate:t=>t==null||w(t)}}function Cp(e){return{path:e,appliesTo:ie,validate:t=>t==null||typeof t=="boolean"}}function le(e){return{path:e,appliesTo:ie,validate:rn}}function mA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="opaque"||t==="mask"||t==="blend"}}function fA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="lit"||t==="unlit"}}var pA=[{path:"transformType",appliesTo:["transform"],validate:e=>e==null||typeof e=="string"},{path:"rendering.renderingGroupId",appliesTo:ie,validate:e=>e==null||e===0||e===1||e===2||e===3},{path:"rendering.alphaIndex",appliesTo:ie,validate:e=>e==null||w(e)},Je("overrides.material.albedoColor"),Je("overrides.material.diffuseColor"),Je("overrides.material.emissiveColor"),V("overrides.material.metallic"),V("overrides.material.roughness"),V("overrides.material.contrast"),V("overrides.material.brightness"),V("overrides.material.saturation"),V("overrides.material.hue"),V("overrides.material.colorDensity"),V("overrides.material.alpha"),V("overrides.material.alphaCutOff"),V("overrides.material.transparencyMode"),Cp("overrides.material.backFaceCulling"),le("overrides.material.albedoTexture.url"),le("overrides.material.normalTexture.url"),V("overrides.material.normalTexture.level"),le("overrides.material.metallicTexture.url"),le("overrides.material.occlusionTexture.url"),le("overrides.material.emissiveTexture.url"),le("overrides.material.opacityTexture.url"),Je("overrides.material.pbr.albedoColor"),V("overrides.material.pbr.baseWeight"),Je("overrides.material.pbr.reflectivityColor"),V("overrides.material.pbr.microSurface"),Je("overrides.material.pbr.emissiveColor"),Je("overrides.material.pbr.ambientColor"),V("overrides.material.pbr.lightFalloff"),V("overrides.material.pbr.directIntensity"),V("overrides.material.pbr.emissiveIntensity"),V("overrides.material.pbr.environmentIntensity"),V("overrides.material.pbr.specularIntensity"),V("overrides.material.pbr.metallicF0Factor"),V("overrides.material.pbr.indexOfRefraction"),Je("overrides.material.standard.diffuseColor"),Je("overrides.material.standard.specularColor"),V("overrides.material.standard.specularPower"),Je("overrides.material.standard.emissiveColor"),Je("overrides.material.standard.ambientColor"),Cp("overrides.material.standard.useSpecularOverAlpha"),{path:"overrides.materialBinding.materialAssetId",appliesTo:ie,validate:rn},fA("overrides.materialBinding.override.lightingModel"),Je("overrides.materialBinding.override.baseColor.color"),{path:"overrides.materialBinding.override.baseColor.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},le("overrides.materialBinding.override.baseColor.texture.url"),le("overrides.materialBinding.override.baseColor.texture.textureAssetId"),V("overrides.materialBinding.override.baseColor.brightness"),V("overrides.materialBinding.override.baseColor.saturation"),V("overrides.materialBinding.override.baseColor.contrast"),V("overrides.materialBinding.override.baseColor.hue"),le("overrides.materialBinding.override.normal.texture.url"),le("overrides.materialBinding.override.normal.texture.textureAssetId"),V("overrides.materialBinding.override.normal.strength"),V("overrides.materialBinding.override.metallic"),V("overrides.materialBinding.override.roughness"),le("overrides.materialBinding.override.metallicRoughness.texture.url"),le("overrides.materialBinding.override.metallicRoughness.texture.textureAssetId"),le("overrides.materialBinding.override.occlusion.texture.url"),le("overrides.materialBinding.override.occlusion.texture.textureAssetId"),V("overrides.materialBinding.override.occlusion.strength"),Je("overrides.materialBinding.override.emission.color"),{path:"overrides.materialBinding.override.emission.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},V("overrides.materialBinding.override.emission.intensity"),le("overrides.materialBinding.override.emission.texture.url"),le("overrides.materialBinding.override.emission.texture.textureAssetId"),le("overrides.materialBinding.override.emission.maskTexture.url"),le("overrides.materialBinding.override.emission.maskTexture.textureAssetId"),mA("overrides.materialBinding.override.alpha.mode"),V("overrides.materialBinding.override.alpha.opacity"),V("overrides.materialBinding.override.alpha.cutoff"),le("overrides.materialBinding.override.alpha.texture.url"),le("overrides.materialBinding.override.alpha.texture.textureAssetId"),{path:"overrides.outline",appliesTo:ie,validate:e=>e==null||gA(e)},{path:"overrides.outline.strategy",appliesTo:ie,validate:e=>e==null||e==="babylon-default"},{path:"overrides.outline.renderOutline",appliesTo:ie,validate:e=>e==null||typeof e=="boolean"},V("overrides.outline.outlineWidth"),{path:"overrides.outline.outlineColor",appliesTo:ie,validate:e=>e==null||Ft(e)},{path:"overrides.outline.outlineColor.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1}],vp=[...Xd,...pA];function gA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return(t.strategy==null||t.strategy==="babylon-default")&&(t.renderOutline==null||typeof t.renderOutline=="boolean")&&(t.outlineWidth==null||w(t.outlineWidth))&&(t.outlineColor==null||Ft(t.outlineColor))}function Yd(e,t){let r=vp.find(n=>n.path===e)??null;return!r||!r.appliesTo.includes(t)?null:r}var dr="scene.materialAssets.",Zd="__fps_duplicate_material_asset__:",bA="mat_";function SA(e){return String(e??"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"")}function nn(e){let t=SA(e);return`${bA}${t||"material"}`}function Qd(){let e=globalThis.crypto?.randomUUID?.();if(e)return e;let t=Math.random().toString(36).slice(2,12);return`${Date.now().toString(36)}-${t}`}function Gp(e,t=dr){if(!e.startsWith(t))return null;let r=e.slice(t.length);if(!r)return null;if(r.endsWith(".name")){let s=r.slice(0,-5);return s?{materialAssetId:s,fieldPath:"name"}:null}let n=".properties.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return!a||!i?null:{materialAssetId:a,fieldPath:`properties.${i}`}}function wr(e){return e==="overrides.materialBinding.materialAssetId"||Lt(e,"materialAssetId")!=null}function el(e){if(wr(e))return!0;let t="overrides.materialBinding.override.";if(e.startsWith(t))return Zi(`properties.${e.slice(t.length)}`);let r=yA(e);return r?Zi(`properties.${r}`):!1}function Qi(e){return e==="overrides.materialBinding.materialAssetId"||e.startsWith("overrides.materialBinding.override.")||Lt(e,"materialAssetId")!=null||Lt(e,"override")!=null}function Lt(e,t){let r="overrides.materialSlotBindings.";if(!e.startsWith(r))return null;let n=e.slice(r.length);if(t==="materialAssetId"){let c=".materialAssetId";if(!n.endsWith(c))return null;let d=n.slice(0,-c.length);return d||null}let o=".override.",a=n.lastIndexOf(o);if(a<0)return null;let i=n.slice(0,a),s=n.slice(a+o.length);return i&&s?i:null}function yA(e){let t="overrides.materialSlotBindings.";if(!e.startsWith(t))return null;let r=e.slice(t.length),n=".override.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return a&&i?i:null}function Zi(e){return e.endsWith(".texture.url")||e.endsWith(".maskTexture.url")||e.endsWith(".texture.textureAssetId")||e.endsWith(".maskTexture.textureAssetId")}function ro(e,t){if(!De(e)||!Zi(t))return!1;let r=t.endsWith(".textureAssetId")?t.slice(0,-15):t.slice(0,-4);return Zn(e,r)?.kind==="texture"}function rt(e,t){if(e==="name"&&typeof t=="string")return t.trim();if(Zi(e)&&typeof t=="string"){let r=t.trim();return r||null}return(e==="properties.alpha.mode"||e==="properties.lightingModel")&&typeof t=="string"?t.trim():t}function zt(e,t,r,n=Mr){let o=rt(e,t);if(e==="name")return typeof o=="string"&&o.length>0;let a=hA(e,r,n);return a?EA(a,o):!1}function hA(e,t,r){if(t!=null)return Zn(t,e,r);for(let n of r.list()){let o=Zn(n.shaderId,e,r);if(o)return o}return null}function EA(e,t){if(t==null)return e.kind==="texture"||e.kind==="string"&&e.nullable===!0;if(e.kind==="number")return!(!w(t)||e.min!=null&&t<e.min||e.max!=null&&t>e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"&&t.trim().length>0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return e.channels===4?PA(t):IA(t);if(e.kind==="vec2"||e.kind==="vec3"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t,n=e.kind==="vec2"?["x","y"]:["x","y","z"];return Object.keys(r).every(o=>n.includes(o))&&n.every(o=>w(r[o]))}if(e.kind==="texture"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t;return Object.keys(r).every(n=>n==="url"||n==="textureAssetId")&&["url","textureAssetId"].every(n=>r[n]===void 0||typeof r[n]=="string"&&r[n].trim().length>0)}return!1}function es(e){return typeof e!="string"||!e.startsWith(Zd)?null:e.slice(Zd.length).trim()||null}function jp(e){return e.trim().replace(/^\/+|\/+$/g,"")}function IA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b")&&w(t.r)&&w(t.g)&&w(t.b)}function PA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b"||r==="a")&&w(t.r)&&w(t.g)&&w(t.b)&&w(t.a)}var TA={r:.78,g:.78,b:.78};function Bt(e,t={}){let r=e??{},n=DA(r.baseColor?.texture,t),o=AA(r,t),a=xA(r,t);return{kind:"material-sphere",baseColor:MA(r),metallic:ca(r.metallic??0),roughness:ca(r.roughness??1),...r.emission?.color?{emissionColor:_p(r.emission.color)}:{},emissionIntensity:wA(r.emission?.intensity,0),textureUrl:n,profile:o,properties:structuredClone(e??{}),...a.length>0?{textureResources:a}:{}}}function xA(e,t){return[["baseColor",e.baseColor?.texture],["normal",e.normal?.texture],["metallicRoughness",e.metallicRoughness?.texture],["occlusion",e.occlusion?.texture],["emission",e.emission?.texture],["emissionMask",e.emission?.maskTexture],["alpha",e.alpha?.texture]].flatMap(([n,o])=>{let a=tl(o,t);return a?[{channel:n,...a}]:[]})}function AA(e,t){let r=structuredClone(e),n=on(r.baseColor?.texture,t);n&&(r.baseColor={...r.baseColor??{},texture:n});let o=on(r.normal?.texture,t);o&&(r.normal={...r.normal??{},texture:o});let a=on(r.metallicRoughness?.texture,t);a&&(r.metallicRoughness={...r.metallicRoughness??{},texture:a});let i=on(r.occlusion?.texture,t);i&&(r.occlusion={...r.occlusion??{},texture:i});let s=on(r.emission?.texture,t),c=on(r.emission?.maskTexture,t);(s||c)&&(r.emission={...r.emission??{},...s?{texture:s}:{},...c?{maskTexture:c}:{}});let d=on(r.alpha?.texture,t);return d&&(r.alpha={...r.alpha??{},texture:d}),r}function on(e,t){if(!e)return;let r=tl(e,t);if(r?.state==="missing")return{...e,url:null};let n=r?.url;return{...e,...n?{url:n}:{}}}function DA(e,t){let r=tl(e,t);return r?.state==="ready"?r.url:void 0}function tl(e,t){let r=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";if(r){let o=t.resolveTextureAssetUrl?.(r)?.trim();if(o)return{reference:r,state:"ready",url:o};let a=t.textureAssets?.find(i=>i.id===r)?.url?.trim();if(a)return{reference:r,state:"ready",url:a};if(t.resolveTextureAssetUrl||Array.isArray(t.textureAssets))return{reference:r,state:"missing"}}let n=typeof e?.url=="string"?e.url.trim():"";return n?{reference:r||n,state:"ready",url:n}:null}function Fp(e,t){let r=e??{},n=Np(r.metallic??0),o=Np(r.roughness??1);return`M ${n} / R ${o} - ${t}`}function MA(e){let r=(e.baseColor??{}).color??TA;return _p(r)}function _p(e){return{r:ca(e.r),g:ca(e.g),b:ca(e.b)}}function ca(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Np(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,"").replace(/\.$/,""):"0"}function wA(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function ee(e,t){return t?e.scene.materialAssets?.find(r=>r.id===t)??null:null}function Vt(e,t){return!!ee(e,t)}function Hp(e,t){return t?{state:"asset",materialAssetId:t.id,materialAsset:t}:e?.materialAssetId?{state:"missing-asset",materialAssetId:e.materialAssetId}:e?.override?{state:"override"}:{state:"inherit"}}function da(e,t){let r=new Set;for(let n of rl(e,t))r.add(n.gameObjectId);return[...r]}function rl(e,t){let r=t.trim();return r?an(e).filter(n=>n.materialAssetId===r):[]}function an(e){let t=[],r=new Map(e.assets.map(n=>[n.id,n]));for(let n of e.scene.gameObjects){let o=NA(n),a=ts(n.overrides?.materialBinding);a&&t.push({kind:"root",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:a,bindingPath:"overrides.materialBinding.materialAssetId",label:o});let i=lr(e,n,r),s=new Map(i.filter(d=>!!d.slotId).map(d=>[d.slotId,d])),c=n.overrides?.materialSlotBindings??{};for(let[d,u]of Object.entries(c)){let l=ts(u);if(!l)continue;let m=s.get(d),f=FA(m,d);t.push({kind:"slot",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:l,bindingPath:`overrides.materialSlotBindings.${d}.materialAssetId`,label:`${o} / ${f}`,slotId:d,ownerNodePath:Ut(m)??d})}}for(let n of e.assets)if(!(n.type!=="prefab"||!n.prefab)){$p(t,{ownerId:n.id,ownerName:n.displayName??n.id,prefabAssetId:n.id,path:`assets.${n.id}.prefab.overrides`,overrides:n.prefab.overrides});for(let o of n.prefab.nodes??[])$p(t,{ownerId:`${n.id}:${o.id}`,ownerName:`${n.displayName??n.id} / ${o.name??o.id}`,prefabAssetId:n.id,prefabNodeId:o.id,path:`assets.${n.id}.prefab.nodes.${o.id}.overrides`,overrides:o.overrides})}return t}function $p(e,t){let r=ts(t.overrides?.materialBinding);r&&e.push({kind:"root",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:r,bindingPath:`${t.path}.materialBinding.materialAssetId`,label:t.ownerName,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}});for(let[n,o]of Object.entries(t.overrides?.materialSlotBindings??{})){let a=ts(o);a&&e.push({kind:"slot",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:a,bindingPath:`${t.path}.materialSlotBindings.${n}.materialAssetId`,label:`${t.ownerName} / ${n}`,slotId:n,ownerNodePath:n,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}})}}function ns(e){let t=[...new Set((e.scene.materialAssets??[]).map(s=>s.id?.trim()).filter(s=>!!s))],r=new Set(t),n=an(e),o=n.filter(s=>!r.has(s.materialAssetId)),a=new Map;for(let s of o){let c=a.get(s.materialAssetId)??[];c.push(s),a.set(s.materialAssetId,c)}let i=[...a.entries()].map(([s,c])=>({kind:"missing-material-asset",materialAssetId:s,usages:c}));return{ok:i.length===0,materialAssetIds:t,references:n,missingMaterialAssetIds:i.map(s=>s.materialAssetId),missingReferences:o,issues:i}}function lr(e,t,r){let n=new Map;for(let o of as(e,t,r))n.set(o.slotId,o);return[...n.values()].sort((o,a)=>(o.label??o.slotId).localeCompare(a.label??a.slotId)||o.slotId.localeCompare(a.slotId))}function Wp(e,t){return as(e,t).length>0}function nt(e){return[...new Set(e.sourceSurfaces.map(t=>t.sourceMaterialIndex).filter(t=>Number.isInteger(t)))].sort((t,r)=>t-r)}function Ut(e){return e?.sourceSurfaces[0]?.ownerNodePath??null}function qp(e){return e.slotId}function os(e){return`overrides.materialSlotBindings.${e.slotId}.materialAssetId`}function nl(e,t){return e.overrides?.materialSlotBindings?.[t.slotId]}function Jp(e){let t=Xp(e);if(!t)return;let r={},n=jA(t.materialAssetId);return n&&(r.materialAssetId=n),t.override&&typeof t.override=="object"&&!Array.isArray(t.override)&&(r.override=t.override),Object.keys(r).length>0?r:void 0}function as(e,t,r){let n=ue(t);if(!n)return[];let a=(r?.get(n.assetId)??e.assets.find(s=>s.id===n.assetId))?.metadata?.materialSlots;if(!Array.isArray(a))return[];let i=[];for(let s of a){let c=no(s);c&&i.push(c)}return i}function no(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.slotId=="string"&&t.slotId.trim()?t.slotId.trim():"",n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces:null,o=kA(n);if(!r||!n||o.length===0||o.length!==n.length)return null;let a=typeof t.label=="string"&&t.label.trim()?t.label.trim():o[0].ownerNodePath,i=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",s=Array.isArray(t.materialNames)?t.materialNames.filter(d=>typeof d=="string"&&!!d.trim()).map(d=>d.trim()):void 0,c=RA(t.sourceMaterialProfiles);return{slotId:r,label:a,sourceSurfaces:o,...i?{materialName:i}:{},...s&&s.length>0?{materialNames:s}:{},...c&&c.length>0?{sourceMaterialProfiles:c}:{}}}function kA(e){return Array.isArray(e)?e.flatMap(t=>{let r=Xp(t);if(!r)return[];let n=jp(typeof r.ownerNodePath=="string"?r.ownerNodePath:""),o=Number.isInteger(r.meshIndex)&&r.meshIndex>=0?r.meshIndex:void 0,a=Number.isInteger(r.primitiveIndex)&&r.primitiveIndex>=0?r.primitiveIndex:void 0;if(!n||o==null||a==null)return[];let i=Number.isInteger(r.nodeIndex)&&r.nodeIndex>=0?r.nodeIndex:void 0,s=Array.isArray(r.nodeIndexPath)?r.nodeIndexPath.filter(m=>Number.isInteger(m)&&m>=0):void 0,c=Number.isInteger(r.sourceMaterialIndex)&&r.sourceMaterialIndex>=0?r.sourceMaterialIndex:void 0,d=typeof r.sourceMeshName=="string"&&r.sourceMeshName.trim()?r.sourceMeshName.trim():void 0,u=typeof r.triangleCount=="number"&&Number.isFinite(r.triangleCount)&&r.triangleCount>=0?r.triangleCount:void 0,l=OA(r.boundingBox);return[{ownerNodePath:n,...i!=null?{nodeIndex:i}:{},...s&&s.length>0?{nodeIndexPath:s}:{},meshIndex:o,primitiveIndex:a,...c!=null?{sourceMaterialIndex:c}:{},...d?{sourceMeshName:d}:{},...u!=null?{triangleCount:u}:{},...l?{boundingBox:l}:{}}]}):[]}function OA(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=Lp(t.min),n=Lp(t.max);if(!(!r&&!n))return{...r?{min:r}:{},...n?{max:n}:{}}}function Lp(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return typeof t=="number"&&Number.isFinite(t)&&typeof r=="number"&&Number.isFinite(r)&&typeof n=="number"&&Number.isFinite(n)?[t,r,n]:null}function RA(e){if(!Array.isArray(e))return;let t=e.map(CA).filter(r=>!!r);return t.length>0?t:void 0}function CA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(!Number.isInteger(t.sourceMaterialIndex))return null;let r=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",n=t.profile&&typeof t.profile=="object"&&!Array.isArray(t.profile)?t.profile:void 0,o=vA(t.textureHints);return{sourceMaterialIndex:t.sourceMaterialIndex,...r?{materialName:r}:{},...n?{profile:n}:{},...o&&o.length>0?{textureHints:o}:{}}}function vA(e){if(!Array.isArray(e))return;let t=e.map(GA).filter(r=>!!r);return t.length>0?t:void 0}function GA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.profilePath=="string"&&t.profilePath.trim()?t.profilePath.trim():"",n=typeof t.reason=="string"&&t.reason.trim()?t.reason.trim():"";return!r||!n?null:{profilePath:r,reason:n,...Number.isInteger(t.textureIndex)?{textureIndex:t.textureIndex}:{},...Number.isInteger(t.imageIndex)?{imageIndex:t.imageIndex}:{},...Number.isInteger(t.bufferView)?{bufferView:t.bufferView}:{},...typeof t.mimeType=="string"&&t.mimeType.trim()?{mimeType:t.mimeType.trim()}:{},...typeof t.uri=="string"&&t.uri.trim()?{uri:t.uri.trim()}:{}}}function Xp(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function jA(e){return typeof e=="string"&&e.trim()?e.trim():null}function NA(e){return e.name?.trim()||e.id}function ts(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function FA(e,t){return e?.label?.trim()||Ut(e)?.trim()||e?.slotId?.trim()||t}var rs=class{constructor(t){this.byMaterialId=new Map;this.byOwnerId=new Map;for(let r of an(t)){let n=this.byMaterialId.get(r.materialAssetId)??[];n.push(r),this.byMaterialId.set(r.materialAssetId,n);let o=this.byOwnerId.get(r.gameObjectId)??[];o.push(r),this.byOwnerId.set(r.gameObjectId,o)}}forMaterial(t){return this.byMaterialId.get(t.trim())??[]}forOwner(t){return this.byOwnerId.get(t)??[]}},zp=new WeakMap;function _A(e){let t=zp.get(e);return t||(t=new rs(e),zp.set(e,t)),t}function ol(e){return e?.system?.preset}function Bp(e,t){let r=ol(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Vp(e,t){let r=ol(e);return r==="default-pbr"?t.defaultMaterialMeta:r==="default-standard"?t.defaultStandardMaterialMeta:t.formatMaterialMeta(e.id)}function $A(e,t){let r=e.currentAsset??null,n=!!r&&!e.currentValue,o=r&&!n?Up(e.document,r.id,e.ownershipText,t):null,a=r?Vp(r,e.displayText):e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.summaryInherit,i=o?Kp(a,o):a;return{pickerKind:"material",pickerTitle:e.pickerText.materialPickerTitle,pickerTrigger:"preview",placeholder:e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.inheritNone,...r?{currentMaterialAssetId:r.id,currentMaterialShaderId:r.shaderId,...r.definitionVersion!=null?{currentMaterialDefinitionVersion:r.definitionVersion}:{}}:{},currentLabel:r?Bp(r,e.displayText):e.currentValue?e.currentValue:e.pickerText.inheritNone,currentMeta:i,...o?.usageLabel?{currentUsageLabel:o.usageLabel}:{},...o?.editImpactLabel?{currentEditImpactLabel:o.editImpactLabel}:{},...o?{currentOwnership:o}:{},currentPreview:r?Bt(r.properties,e.previewContext):void 0,candidates:[{label:e.pickerText.inheritNone,value:"",meta:e.pickerText.summaryInherit},...e.materialAssets.map(s=>{let c=Up(e.document,s.id,e.ownershipText,t);return{label:Bp(s,e.displayText),value:s.id,meta:Kp(Vp(s,e.displayText),c),kind:"material",preview:Bt(s.properties,e.previewContext),...c?.usageLabel?{usageLabel:c.usageLabel}:{},...c?{ownership:c}:{}}})]}}function Up(e,t,r,n){if(!e||!n)return null;let o=t.trim(),a=n.forMaterial(o),i=a.length;return{materialAssetId:o,usage:{count:i,items:a.map(s=>structuredClone(s))},usageCount:i,used:i>0,shared:i>1,...r?{usageLabel:r.formatUsageCount(i),editImpactLabel:r.formatEditImpact(i),duplicateImpactLabel:r.formatDuplicateImpact(i)}:{}}}function Kp(e,t){return[e,t?.usageLabel].filter(Boolean).join(" \xB7 ")}function LA(e,t,r={}){return(e.scene.materialAssets??[]).map(n=>{let o=t.forMaterial(n.id);return{id:`material:${n.id}`,assetId:n.id,kind:"material",label:n.name||n.id,meta:Fp(n.properties,n.id),preview:Bt(n.properties,r),material:{id:n.id,name:n.name||n.id,shaderId:n.shaderId,...n.definitionVersion!=null?{definitionVersion:n.definitionVersion}:{},readonly:n.system?.readonly===!0||ol(n)!=null,usage:{count:o.length,items:o.map(a=>structuredClone(a))},properties:structuredClone(n.properties)},placeable:!1}})}var zA={createUsageIndex(e){return new rs(e)},getCachedUsageIndex:_A,createPickerControlOptions:$A,createBrowserAssetItems:LA},_e=zA;var sn=1;var il="prefab.";function ua(e){let t=structuredClone(e),r={ordinaryObjects:0,prefabRoots:0,discardedFields:0},n=$e(t.scene);return n&&(Me(n,"shadowMapExperiment",r),Array.isArray(n.gameObjects)&&n.gameObjects.forEach(o=>BA(o,r))),Array.isArray(t.assets)&&t.assets.forEach(o=>VA(o,r)),{document:t,summary:r}}function dn(e){let t=$e(e);return!t||t.prefab!=null||t.transformType==="camera"||t.transformType==="light"||t.camera!=null||t.light!=null?!1:t.kind==="primitive"||$e(t.primitive)?!0:Array.isArray(t.components)&&t.components.some(r=>{let n=$e(r)?.type;return n==="ModelRenderer"||n==="ImageRenderer"})}function BA(e,t){let r=$e(e);if(!r)return;let n=$e(r.shadow);Me(r,"shadowMode",t),Me(r,"shadowMapExperiment",t),dn(r)?(r.shadow=Zp(n),t.ordinaryObjects+=1):Me(r,"shadow",t)}function VA(e,t){let r=$e(e);if(!r)return;let n=$e(r.defaults);n&&(Me(n,"shadowMode",t),Me(n,"shadow",t),Me(n,"shadowMapExperiment",t));let o=$e(r.prefab);if(!o)return;let a=$e(o.defaults);a&&Me(a,"shadowMode",t),o.defaults={...a??{},shadow:Zp(a?.shadow)},t.prefabRoots+=1;let i=$e(o.defaults);if(Me(i,"shadowMapExperiment",t),Array.isArray(o.nodes))for(let s of o.nodes){let c=$e(s);if(!c)continue;Me(c,"shadowMode",t),Me(c,"shadow",t),Me(c,"shadowMapExperiment",t);let d=$e(c.defaults);d&&(Me(d,"shadowMode",t),Me(d,"shadow",t),Me(d,"shadowMapExperiment",t))}}function Zp(e){let t=$e(e);return{cast:t?.cast==="enabled"?"enabled":"none",receive:t?.receive==="enabled"?"enabled":"none"}}function Me(e,t,r){Object.prototype.hasOwnProperty.call(e,t)&&(delete e[t],r.discardedFields+=1)}function $e(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var $F=Symbol("unsupported-editor-scene-authored-clone-value");function G(e){return e.components.find(WA)??null}function ue(e){return e.components.find(qA)??null}function kr(e){return e.components.find(JA)??null}function Xe(e){return e?.type==="prefab"&&te(e.prefab?.sourceAssetId)!=null}function Le(e,t){let r=e.assets.find(n=>n.id===t);return r&&Xe(r)?r:null}function is(e){return te(e?.prefab?.prefabId)!=null}function la(e){return te(e?.prefab?.sourceAssetId)}function Ye(e){if(!e?.prefab)return null;let t=cl(e.prefab),r=te(e.prefab.rootNodeId);if(r&&t.some(o=>o.id===r))return r;let n=t.find(o=>o.kind==="root"&&!o.parentId);return n?n.id:null}function Ze(e){return e?.prefab?cl(e.prefab):[]}function oo(e,t){let r=te(t);return r?Ze(e).find(n=>n.id===r)??null:null}function sl(e,t){let r=te(t);return Ze(e).filter(n=>{let o=te(n.parentId);return r?o===r:!o})}function Qp(e){if(!Xe(e))return al(e,!1,null,[{code:"prefab.invalidDefinition",severity:"error",message:`Asset "${e.id}" is not a valid prefab definition.`,assetId:e.id}]);let t=cl(e.prefab),r=Ye(e);if(e.prefab.compositionVersion!==sn||t.length===0||!r)return al(e,!1,null,[{code:"schema.unsupportedVersion",severity:"error",message:`Prefab asset "${e.id}" must use composition version ${sn} with an explicit root node.`,assetId:e.id}]);let n=UA(e);return al(n,JSON.stringify(n.prefab)!==JSON.stringify(e.prefab))}function al(e,t,r=null,n=[],o={}){return{ok:n.every(a=>a.severity!=="error"),changed:t,prefabAsset:e,...o.selectedNodeId?{selectedNodeId:o.selectedNodeId}:{},...o.createdNodeId?{createdNodeId:o.createdNodeId}:{},...o.deletedNodeIds?{deletedNodeIds:[...o.deletedNodeIds]}:{},...r?{node:structuredClone(r)}:{},diagnostics:n.map(a=>({...a}))}}function UA(e){let t=structuredClone(e),r=Ze(e);t.prefab=structuredClone(t.prefab),t.prefab.compositionVersion=sn,t.prefab.nodes=r;let n=Ye({...e,prefab:{...e.prefab,nodes:r}});return n?t.prefab.rootNodeId=n:delete t.prefab.rootNodeId,t}function cl(e){if(!Array.isArray(e.nodes))return[];let t=[];for(let r of e.nodes){let n=KA(r);n&&!t.some(o=>o.id===n.id)&&t.push(n)}return structuredClone(t)}function KA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=te(t.id);return!r||!HA(t.kind)?null:{id:r,...te(t.guid)?{guid:te(t.guid)}:{},...te(t.name)?{name:te(t.name)}:{},...te(t.parentId)?{parentId:te(t.parentId)}:{},kind:t.kind,...t.transform?{transform:structuredClone(t.transform)}:{},...te(t.sourceAssetId)?{sourceAssetId:te(t.sourceAssetId)}:{},...te(t.sourceNodePath)?{sourceNodePath:te(t.sourceNodePath)}:{},...te(t.childPrefabId)?{childPrefabId:te(t.childPrefabId)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.light?{light:structuredClone(t.light)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults?{defaults:structuredClone(t.defaults)}:{},...t.overrides?{overrides:structuredClone(t.overrides)}:{},...t.metadata?{metadata:structuredClone(t.metadata)}:{}}}function HA(e){return e==="root"||e==="group"||e==="model"||e==="primitive"||e==="light"||e==="prefabInstance"||e==="marker"||e==="collision"}function eg(e){let t=la(e.prefabAsset);if(!t)throw new Error(`Prefab asset "${e.prefabAsset.id}" does not define a source asset.`);let r=e.prefabAsset.prefab?.defaults;return{id:e.id,...e.guid?{guid:e.guid}:{},name:e.name??e.prefabAsset.displayName??e.prefabAsset.id,kind:"instance",...e.parentId?{parentId:e.parentId}:{},active:e.active??r?.active??!0,prefab:{prefabId:e.prefabAsset.id,...e.prefabAsset.guid?{prefabGuid:e.prefabAsset.guid}:{},sourceAssetId:t},...e.metadata?{metadata:{...e.metadata}}:{},...e.overrides!==void 0?{overrides:e.overrides}:{},components:[e.transform,{type:"ModelRenderer",assetId:t}]}}function tg(e){if(!e.startsWith(il))return null;let t=e.slice(il.length);return Qi(t)?t:null}function dl(e){return tg(e)?.endsWith(".materialAssetId")===!0}function rg(e){return e.startsWith(il)&&e.endsWith(".materialAssetId")&&dl(e)}function ng(e,t){if(t.slotId)return Jp(e.prefab?.overrides?.materialSlotBindings?.[t.slotId])}function ma(e,t,r){let n=tg(t);if(!n||!Xe(e))return e;let o=YA(n);if(!o)return e;let a=structuredClone(e);a.prefab=structuredClone(a.prefab??e.prefab),QA(a.prefab,o,r);let i=cg(a.prefab?.overrides);return i?a.prefab.overrides=i:delete a.prefab.overrides,JSON.stringify(a)===JSON.stringify(e)?e:a}function og(e,t){let r=te(e?.materialAssetId),n=te(t?.materialAssetId),o=xd(e?.override,t?.override);return ul({...n??r?{materialAssetId:n??r}:{},...cn(o)?{override:o}:{}})}function ss(e,t){let r={},n=og(e?.materialBinding,t?.materialBinding);n&&(r.materialBinding=n);let o=tD(e?.materialSlotBindings,t?.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function cs(e,t){let r=ln(e,t);if(!(!r.gameObject||!r.prefab))return ss(r.definition?.prefab?.overrides,rD(r.gameObject.overrides))}function ln(e,t){let r=typeof t=="string"?XA(e,t):t,n=typeof t=="string"?t:t.id,o=[],a=is(r)?r.prefab:null;if(!r||!a)return o.push({code:"not-prefab-instance",severity:"info",message:r?`GameObject "${r.id}" is not a prefab instance.`:`GameObject "${n}" was not found.`}),{gameObject:r,prefab:null,definition:null,sourceAsset:null,diagnostics:o};let i=e.assets.find(d=>d.id===a.prefabId&&Xe(d));i||o.push({code:"missing-prefab-definition",severity:"error",message:`Prefab definition "${a.prefabId}" was not found.`,prefabId:a.prefabId});let s=la(i)??te(a.sourceAssetId);i&&a.sourceAssetId&&s&&a.sourceAssetId!==s&&o.push({code:"source-asset-mismatch",severity:"warning",message:`Prefab instance source "${a.sourceAssetId}" does not match definition source "${s}".`,prefabId:a.prefabId,expectedSourceAssetId:s,actualSourceAssetId:a.sourceAssetId});let c=s?e.assets.find(d=>d.id===s):void 0;if(s&&!c&&o.push({code:"missing-source-asset",severity:"error",message:`Prefab source asset "${s}" was not found.`,prefabId:a.prefabId,sourceAssetId:s}),s){let d=e.assets.filter(u=>Xe(u)&&la(u)===s).map(u=>u.id);d.length>1&&o.push({code:"duplicate-source-prefab",severity:"info",message:`Source asset "${s}" is referenced by ${d.length} prefab definitions.`,prefabId:a.prefabId,sourceAssetId:s})}return{gameObject:r,prefab:a,definition:i??null,sourceAsset:c??null,diagnostics:o}}function Y(e){return e.kind==="group"||e.kind==="instance"||e.kind==="transform"||e.kind==="primitive"?e.kind:is(e)?"instance":e.primitive?"primitive":ue(e)?"instance":kr(e)||e.transformType?"transform":"group"}function ag(e){let t=e.rendering&&typeof e.rendering=="object"&&!Array.isArray(e.rendering)?e.rendering:void 0,r=ll(t?.renderingGroupId),n=sg(t?.alphaIndex),o={};return r!=null&&(o.renderingGroupId=r),n!=null&&(o.alphaIndex=n),Object.keys(o).length>0?o:void 0}function ll(e){return e===0||e===1||e===2||e===3?e:null}function ig(e){return sg(e)}function WA(e){return e.type==="Transform"}function qA(e){return e.type==="ModelRenderer"}function JA(e){return e.type==="ImageRenderer"}function sg(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function te(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function XA(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function YA(e){if(e==="overrides.materialBinding.materialAssetId")return["overrides","materialBinding","materialAssetId"];let t="overrides.materialBinding.override.";if(e.startsWith(t)){let o=e.slice(t.length);return Yp(["overrides","materialBinding","override"],o)}let r=Lt(e,"materialAssetId");if(r)return["overrides","materialSlotBindings",r,"materialAssetId"];let n=Lt(e,"override");if(n){let o=ZA(e);return o?Yp(["overrides","materialSlotBindings",n,"override"],o):null}return null}function ZA(e){let t=".override.",r=e.lastIndexOf(t);if(r<0)return null;let n=e.slice(r+t.length);return n||null}function Yp(e,t){let r=t.split(".").filter(Boolean);return r.length===0||r.some(dg)?null:[...e,...r]}function QA(e,t,r){if(t.some(dg))return;let n=e;for(let a of t.slice(0,-1)){let i=n[a];(!i||typeof i!="object"||Array.isArray(i))&&(n[a]={}),n=n[a]}let o=t[t.length-1];o&&(r==null?delete n[o]:n[o]=structuredClone(r))}function cg(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r={},n=ul(t.materialBinding);n&&(r.materialBinding=n);let o=eD(t.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function ul(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=te(t.materialAssetId),n=xd(t.override),o={...r?{materialAssetId:r}:{},...cn(n)?{override:n}:{}};return cn(o)?o:void 0}function eD(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[r,n]of Object.entries(e)){let o=te(r);if(!o)continue;let a=ul(n);a&&(t[o]=a)}return cn(t)?t:void 0}function tD(e,t){let r=new Set([...Object.keys(e??{}),...Object.keys(t??{})]),n={};for(let o of r){let a=og(e?.[o],t?.[o]);a&&(n[o]=a)}return cn(n)?n:void 0}function rD(e){return cg(e)}function cn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0}function dg(e){return e==="__proto__"||e==="prototype"||e==="constructor"}var nD=new Set(["id","guid","name","parentId","kind","transform","marker","metadata"]);function lg(e,t,r){if(e.kind!=="marker"){Object.prototype.hasOwnProperty.call(e,"marker")&&N("schema.invalidValue",`${r}.marker`);return}for(let s of Object.keys(e))nD.has(s)||N("schema.invalidValue",`${r}.${s}`);fa(e.parentId)||N("schema.invalidReference",`${r}.parentId`),sD(e.transform,`${r}.transform`),oD(e.marker,`${r}.marker`);let n=fa(e.id),o=e.marker,a=aD(o,`${r}.marker`),i=a[0]??null;for(let s of a){s.target.id===n&&N("schema.invalidReference",`${s.path}.id`),i&&(s.target.kind!==i.target.kind||s.target.id!==i.target.id)&&N("schema.invalidReference",s.path);let c=t.get(s.target.id);c&&(s.target.kind==="marker"&&c.kind!=="marker"&&N("schema.invalidReference",`${s.path}.kind`),s.target.kind==="scene-object"&&c.kind==="marker"&&N("schema.invalidReference",`${s.path}.kind`))}}function oD(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["schemaVersion","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t),r.schemaVersion!==1&&N("schema.unsupportedVersion",`${t}.schemaVersion`),fa(r.type)||N("schema.invalidValue",`${t}.type`),r.kind!==void 0&&!fa(r.kind)&&N("schema.invalidValue",`${t}.kind`),r.tags!==void 0&&lD(r.tags,`${t}.tags`),r.note!==void 0&&typeof r.note!="string"&&N("schema.invalidType",`${t}.note`),r.color!==void 0&&dD(r.color,`${t}.color`),r.target!==void 0&&ml(r.target,`${t}.target`),r.semanticFrame!==void 0&&cD(r.semanticFrame,`${t}.semanticFrame`),iD(r.geometry,`${t}.geometry`),r.metadata!==void 0&&uD(r.metadata,`${t}.metadata`)}function aD(e,t){let r=[];return e.target&&r.push({target:e.target,path:`${t}.target`}),e.geometry.kind==="point"&&e.geometry.target&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),e.geometry.kind==="object-bounds"&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),r}function iD(e,t){let r=Rr(e);if(r||N("schema.invalidType",t),r.kind==="box"){Pt(r,["kind"],t);return}if(r.kind==="point"){Pt(r,["kind","coordinateSpace","position","offset","target"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&r.coordinateSpace!=="local"&&N("schema.invalidValue",`${t}.coordinateSpace`),r.position!==void 0&&Or(r.position,`${t}.position`),r.offset!==void 0&&Or(r.offset,`${t}.offset`),r.target!==void 0&&ml(r.target,`${t}.target`);return}if(r.kind==="object-bounds"){Pt(r,["kind","target"],t),ml(r.target,`${t}.target`);return}if(r.kind==="polyhedron"){Pt(r,["kind","coordinateSpace","vertices","faces"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&N("schema.invalidValue",`${t}.coordinateSpace`),Array.isArray(r.vertices)||N("schema.invalidType",`${t}.vertices`),r.vertices.forEach((n,o)=>Or(n,`${t}.vertices[${o}]`)),r.faces!==void 0&&(Array.isArray(r.faces)||N("schema.invalidType",`${t}.faces`),r.faces.forEach((n,o)=>{Array.isArray(n)||N("schema.invalidType",`${t}.faces[${o}]`),n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&N("schema.invalidValue",`${t}.faces[${o}][${i}]`)})}));return}N("schema.invalidValue",`${t}.kind`)}function ml(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["kind","id","label"],t),r.kind!=="marker"&&r.kind!=="scene-object"&&N("schema.invalidValue",`${t}.kind`),fa(r.id)||N("schema.invalidValue",`${t}.id`),r.label!==void 0&&typeof r.label!="string"&&N("schema.invalidType",`${t}.label`)}function sD(e,t){let r=Rr(e);if(r||N("schema.invalidType",t),r.type!=="Transform"&&N("schema.invalidValue",`${t}.type`),r.mode==="matrix"){Pt(r,["type","mode","matrix"],t),(!Array.isArray(r.matrix)||r.matrix.length!==16)&&N("schema.invalidType",`${t}.matrix`),r.matrix.forEach((n,o)=>ds(n,`${t}.matrix[${o}]`));return}Pt(r,["type","mode","position","rotation","scale"],t),r.mode!==void 0&&r.mode!=="trs"&&N("schema.invalidValue",`${t}.mode`),Or(r.position,`${t}.position`),Or(r.rotation,`${t}.rotation`),r.scale!==void 0&&Or(r.scale,`${t}.scale`)}function cD(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["origin","forward","right","up","label","description"],t),Or(r.origin,`${t}.origin`);for(let n of["forward","right","up"])r[n]!==void 0&&Or(r[n],`${t}.${n}`);for(let n of["label","description"])r[n]!==void 0&&typeof r[n]!="string"&&N("schema.invalidType",`${t}.${n}`)}function dD(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["r","g","b"],t);for(let n of["r","g","b"])ds(r[n],`${t}.${n}`),(r[n]<0||r[n]>1)&&N("schema.invalidValue",`${t}.${n}`)}function Or(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["x","y","z"],t);for(let n of["x","y","z"])ds(r[n],`${t}.${n}`)}function lD(e,t){Array.isArray(e)||N("schema.invalidType",t),e.forEach((r,n)=>{typeof r!="string"&&N("schema.invalidType",`${t}[${n}]`)})}function uD(e,t){let r=Rr(e);r||N("schema.invalidType",t),fl(r,t,new Set)}function fl(e,t,r){if(e===null||typeof e=="string"||typeof e=="boolean")return;if(typeof e=="number"){ds(e,t);return}(!e||typeof e!="object")&&N("schema.invalidType",t),r.has(e)&&N("schema.invalidValue",t);let n=Object.getPrototypeOf(e);Array.isArray(e)?n!==Array.prototype&&N("schema.invalidType",t):n!==Object.prototype&&n!==null&&N("schema.invalidType",t),r.add(e);try{if(Array.isArray(e))e.forEach((o,a)=>fl(o,`${t}[${a}]`,r));else for(let[o,a]of Object.entries(e))fl(a,`${t}.${o}`,r)}finally{r.delete(e)}}function Pt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||N("schema.invalidValue",`${r}.${o}`)}function ds(e,t){(typeof e!="number"||!Number.isFinite(e))&&N("schema.invalidValue",t)}function Rr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function fa(e){return typeof e=="string"&&e.trim()?e.trim():null}function N(e,t){throw new Error(`${e}: ${t}`)}function ao(e,t){return t===e.rootNodeId?e.instanceId:`${e.instanceId}:${mD(t)}`}function mD(e){return encodeURIComponent(e)}function pl(e,t){return{...structuredClone(e),id:ao(t,e.id)}}function pa(e,t){let r=structuredClone(e);return r.target&&(r.target=pl(r.target,t)),r.geometry.kind==="point"&&r.geometry.target&&(r.geometry.target=pl(r.geometry.target,t)),r.geometry.kind==="object-bounds"&&(r.geometry.target=pl(r.geometry.target,t)),r}function B(e,t){if(ug(e))try{return e[t]}catch{return}}function ce(e,t){let r=B(e,t);return typeof r=="string"&&r.trim()?r:null}function re(e,t){let r=B(e,t);return typeof r=="number"&&Number.isFinite(r)?r:null}function Te(e,t){let r=B(e,t);return typeof r=="boolean"?r:null}function we(e,t,r=[]){let n=B(e,t);if(typeof n=="function")try{return n.apply(e,r)}catch{return}}function Kt(e){if(!ug(e))return null;let t=we(e,"getClassName");if(typeof t=="string"&&t.trim())return t;let r=B(e,"constructor"),n=r&&typeof r=="function"?r.name:"";return n&&n!=="Object"?n:null}function un(e){let t=Kt(e),r=ce(e,"name");return t&&r?`${t} \xB7 ${r}`:t??r}function ug(e){return!!e&&(typeof e=="object"||typeof e=="function")}function ls(e,t=new WeakSet,r=0){if(e==null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?fD(e):"[NonFiniteNumber]";if(typeof e=="bigint")return String(e);if(typeof e=="function")return`[Function ${e.name||"anonymous"}]`;if(typeof e=="symbol"||typeof e!="object")return String(e);if(t.has(e))return"[Circular]";if(r>6)return"[MaxDepth]";if(t.add(e),Array.isArray(e))return e.map(a=>ls(a,t,r+1));let n=e,o={};for(let a of Object.keys(n).sort())o[a]=ls(B(n,a),t,r+1);return o}function fD(e){return Math.round(e*1e6)/1e6}function Cr(e){let t=e.properties.filter(r=>!!r).map((r,n)=>r.order==null?{...r,order:n}:r);return t.length===0&&e.omitWhenEmpty!==!1?null:{id:e.id,title:e.title,order:e.order,placement:"body",summary:e.summary,persistence:e.persistence??(e.runtimeOnly?"runtime":"readonly"),runtimeOnly:e.runtimeOnly,effect:e.effect??(e.runtimeOnly?"runtime":void 0),disabledReason:e.disabledReason,collapsedByDefault:e.collapsedByDefault,tags:e.tags,properties:t}}function j(e){if(!pD(e.value))return null;let t=ls(e.value);return{path:e.path,label:e.label,valueType:e.valueType??gD(t),control:"readonly",value:t,readOnly:!0,persistence:e.persistence??"readonly",commitMode:"blur",order:e.order,tags:SD(e.source,e.tags),tooltip:e.tooltip,effect:e.effect??bD(e.source,e.persistence),disabledReason:e.disabledReason}}function gl(e,t){let r=j(t);r&&e.push(r)}function io(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.buttonLabel??e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function bl(e){let t=mn(e.value);if(!t)return[];let r=e.order??0;return["x","y","z"].map((n,o)=>j({path:`${e.basePath}.${n}`,label:`${e.label}.${n}`,value:t[n],order:r+o,persistence:e.persistence,source:e.source,tags:e.tags,effect:e.effect,disabledReason:e.disabledReason,valueType:"number"})).filter(n=>!!n)}function mn(e){if(!e||typeof e!="object")return null;let t=re(e,"x"),r=re(e,"y"),n=re(e,"z");return t==null||r==null||n==null?null:{x:t,y:r,z:n}}function pD(e){return e!=null&&!(typeof e=="number"&&!Number.isFinite(e))}function gD(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":e&&typeof e=="object"?"object":"unknown"}function bD(e,t){if(t==="runtime"||e==="Runtime")return"runtime";if(e==="Derived")return"derived"}function SD(e,t){let r=[...e?[e]:[],...t??[]];return r.length>0?[...new Set(r)]:void 0}function ga(e){let t=e.projectedRoot??e.root??null,r=fg(t),n=r.find(o=>!!B(o,"material"))??r[0]??null;return{root:t,projectionNode:e.projectionNode??null,childNodes:pg(t),meshes:r,primaryMesh:n,material:yD(t)}}function us(e){let t=we(e,"getHierarchyBoundingVectors"),r=mn(B(t,"min")),n=mn(B(t,"max"));if(r&&n)return mg(r,n);let o=we(e,"getBoundingInfo"),a=B(o,"boundingBox"),i=mn(B(a,"minimumWorld")),s=mn(B(a,"maximumWorld"));return i&&s?mg(i,s):null}function fg(e){let t=we(e,"getChildMeshes",[!1]),r=Array.isArray(t)?[...t]:[];return gg(e)&&r.unshift(e),[...new Set(r)]}function pg(e){let t=we(e,"getChildren");return Array.isArray(t)?t:[]}function gg(e){return!!e&&(!!B(e,"material")||typeof B(e,"getTotalVertices")=="function"||typeof B(e,"getBoundingInfo")=="function")}function ms(e,t){let r=0,n=0;for(let o of e){let a=we(o,t);typeof a!="number"||!Number.isFinite(a)||(r+=a,n+=1)}return n>0?r:"not available"}function so(e,t){let r=B(e,t);return Array.isArray(r)?r.length:0}function fs(e,t){let r=we(e,t);return Array.isArray(r)?r.length:"not available"}function Sl(e){let t=we(e,"isEnabled");return typeof t=="boolean"?t:null}function ba(e,t){let r=re(e,t);if(r!=null)return r;let n=we(e,"getParam",[t]);return typeof n=="number"&&Number.isFinite(n)?n:null}function mg(e,t){return{min:e,max:t,center:{x:(e.x+t.x)/2,y:(e.y+t.y)/2,z:(e.z+t.z)/2},size:{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}}function yD(e){let t=B(e,"material");if(t)return t;let r=we(e,"getChildMeshes",[!1]);if(Array.isArray(r)){let n=r.find(o=>!!B(o,"material"));if(n)return B(n,"material")}return null}var gs={x:-.3,y:-1,z:-.2},bg=-180,Sg=180,Sa=-90,ya=90;function ha(e,t=gs){let r=e&&ID(e)?e:t,n=Math.hypot(r.x,r.y,r.z);if(!Number.isFinite(n)||n<=1e-6){let o=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/o,y:t.y/o,z:t.z/o}}return{x:r.x/n,y:r.y/n,z:r.z/n}}function hl(e,t){let r=vr(Ss(e)),n=vr(Tg(t,Sa,ya)),o=Math.cos(n);return{x:yl(o*Math.cos(r)),y:yl(-Math.sin(n)),z:yl(o*Math.sin(r))}}function El(e){if(!ys(e.light))return null;let t=G(e),r=t&&"rotation"in t?t.rotation:void 0,n=Ig({direction:e.light.direction,rotation:r}),o=hl(n.horizontalAngleDeg,n.elevationAngleDeg);return{horizontalAngleDeg:n.horizontalAngleDeg,elevationAngleDeg:n.elevationAngleDeg,rotation:{x:vr(n.elevationAngleDeg),y:vr(n.horizontalAngleDeg),z:co(r?.z)?r.z:0},direction:o,source:r?"transform.rotation":"light.direction"}}function yg(e,t){if(!ys(e.light))return e;let r=El(e);if(!r)return e;let n=co(t.horizontalAngleDeg)?t.horizontalAngleDeg:r.horizontalAngleDeg,o=co(t.elevationAngleDeg)?t.elevationAngleDeg:r.elevationAngleDeg,a=hl(n,o),i={...r.rotation,x:vr(o),y:vr(n)};return{...e,light:{...e.light,direction:a},components:e.components.map(s=>s===G(e)&&"rotation"in s?{...s,rotation:i}:s)}}function hD(e,t=gs){let{horizontalAngleDeg:r,elevationAngleDeg:n}=Ig({direction:t,rotation:e});return hl(r,n)}function ED(e,t){let r=Eg(e);return{x:vr(r.elevationAngleDeg),y:vr(r.horizontalAngleDeg),z:co(t?.z)?t.z:0}}function lo(e){if(!ys(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=hD(t.rotation,e.light.direction);return Pg(r,ha(e.light.direction))?e:{...e,light:{...e.light,direction:r}}}function bs(e){if(!ys(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=ED(e.light.direction,t.rotation);return Pg(r,t.rotation)?e:{...e,components:e.components.map(n=>n===t?{...t,rotation:r}:n)}}function hg(e){let t=ha(e),r=Math.abs(t.y);return r<=1e-6?999:Math.min(999,Math.hypot(t.x,t.z)/r)}function Ss(e){let t=((e+180)%360+360)%360-180;return t===-180?180:t}function ID(e){return typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)&&typeof e.z=="number"&&Number.isFinite(e.z)}function ys(e){return e?.type==="directional"}function Eg(e){let t=ha(e);return{horizontalAngleDeg:Ss(ps(Math.atan2(t.z,t.x))),elevationAngleDeg:ps(Math.asin(Tg(-t.y,-1,1)))}}function Ig(e){let t=Eg(e.direction);return{horizontalAngleDeg:co(e.rotation?.y)?ps(e.rotation.y):t.horizontalAngleDeg,elevationAngleDeg:co(e.rotation?.x)?ps(e.rotation.x):t.elevationAngleDeg}}function co(e){return typeof e=="number"&&Number.isFinite(e)}function Pg(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function ps(e){return e*180/Math.PI}function vr(e){return e*Math.PI/180}function yl(e){return Math.round(e*1e6)/1e6}function Tg(e,t,r){return Math.min(r,Math.max(t,e))}var fn="light.directionHorizontalAngleDeg",pn="light.directionElevationAngleDeg";function uo(e){return e===fn||e===pn}function xg(e,t){if(t==null||typeof t=="string"&&!t.trim())return null;let r=PD(t);return r==null?t:e===fn?Math.round(Ss(r)):e===pn?Math.round(TD(r,Sa,ya)):t}function PD(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function TD(e,t,r){return Math.min(r,Math.max(t,e))}function gn(e){return t=>mo({...e,value:t})}function mo(e){let t=xD(e);if(t)return t;let r=Yd(e.path,e.nodeKind);return r?e.value==null&&r.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${e.path}.`}:r.validate(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`}:{ok:!1,message:`Unsupported scene node field: ${e.path}.`}}function bn(e,t){return/^overrides\.material\.(albedoTexture|normalTexture|metallicTexture)\.url$/.test(e)&&typeof t=="string"?Ag(t):t}function hs(e,t,r={}){if((r.isDirectionalLightAnglePath??Dg)(e))return xg(e,t);if(e==="marker.type"&&typeof t=="string"||e==="marker.target.objectId"&&typeof t=="string")return t.trim();if(e==="marker.tags")return DD(t);if(e==="marker.note"&&typeof t=="string"){let n=t.trim();return n||null}return el(e)&&typeof t=="string"?Ag(t):bn(e,t)}function Il(e){return t=>AD(t,e)}function xD(e){for(let t of e.extraValidators??[]){let r=t({path:e.path,nodeKind:e.nodeKind,value:e.value,document:e.document});if(r)return r}return null}function AD(e,t){if(e.path==="camera.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: camera.inspectorLanguage."};if(e.path==="light.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: light.inspectorLanguage."};if((t.isDirectionalLightAnglePath??Dg)(e.path))return typeof e.value=="number"&&Number.isFinite(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="metadata.artistMaterialInspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="instance.assetId"&&e.document&&typeof e.value=="string"&&!(e.document.assets??[]).some(r=>r.id===e.value))return{ok:!1,message:`Asset not found: ${e.value}.`};if(wr(e.path)&&e.document&&typeof e.value=="string"&&e.value&&!t.hasMaterialAsset(e.document,e.value))return{ok:!1,message:`Material asset not found: ${e.value}.`};if(wr(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(el(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="marker.target.objectId"){if(typeof e.value!="string")return{ok:!1,message:"Marker target must be a scene object id."};let r=e.value.trim();if(!r)return{ok:!0,value:""};let n=e.document?.scene?.gameObjects?.find(o=>o.id===r)??null;return n&&!t.isMarkerGameObject(n)?{ok:!0,value:r}:{ok:!1,message:`Marker target object not found: ${r}.`}}return null}function Ag(e){let t=e.trim();return t||null}function DD(e){let r=(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>typeof n=="string"?n.trim():"").filter((n,o,a)=>n.length>0&&a.indexOf(n)===o);return r.length>0?r:null}function Dg(e){return e===fn||e===pn}function Ea(e){return{...e.property,readOnly:!1,persistence:"document",document:e.document??void 0,validate:gn({path:e.property.path,nodeKind:e.nodeKind,document:e.document,extraValidators:e.extraValidators})}}function ot(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function Tt(e){return e*180/Math.PI}function Ht(e){return e*Math.PI/180}function at(e){return Math.round(e*1e6)/1e6}var Mg={zh:{title:"\u6444\u50CF\u673A",summaryOrthographic:"ArcRotate \u6B63\u4EA4",summaryPerspective:"ArcRotate \u900F\u89C6",language:"\u8BED\u8A00",projection:"\u6295\u5F71\u6A21\u5F0F",projectionOrthographic:"\u6B63\u4EA4",projectionPerspective:"\u900F\u89C6",alpha:"Alpha",beta:"Beta",radius:"\u534A\u5F84",orthoSize:"\u6B63\u4EA4\u5C3A\u5BF8",fov:"\u89C6\u91CE\u89D2\u5EA6",targetOffset:"\u76EE\u6807\u504F\u79FB",nearClip:"\u8FD1\u88C1\u526A",farClip:"\u8FDC\u88C1\u526A",minBeta:"\u6700\u5C0F Beta",maxBeta:"\u6700\u5927 Beta",minRadius:"\u6700\u5C0F\u534A\u5F84",maxRadius:"\u6700\u5927\u534A\u5F84",inertia:"\u60EF\u6027",screenOffset:"\u5C4F\u5E55\u504F\u79FB",rawCamera:"\u539F\u59CB\u6444\u50CF\u673A"},en:{title:"Camera",summaryOrthographic:"ArcRotate Orthographic",summaryPerspective:"ArcRotate Perspective",language:"Language",projection:"Projection",projectionOrthographic:"Orthographic",projectionPerspective:"Perspective",alpha:"Alpha",beta:"Beta",radius:"Radius",orthoSize:"Ortho Size",fov:"FOV",targetOffset:"Target Offset",nearClip:"Near Clip",farClip:"Far Clip",minBeta:"Min Beta",maxBeta:"Max Beta",minRadius:"Min Radius",maxRadius:"Max Radius",inertia:"Inertia",screenOffset:"Screen Offset",rawCamera:"Raw Camera"}},wg=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}];function Pl(e){return Mg[e]??Mg.zh}function MD(e){return[{label:e.projectionOrthographic,value:"orthographic"},{label:e.projectionPerspective,value:"perspective"}]}function kg(e){let{camera:t,createDocumentInspectorProperty:r,nodeKind:n,rig:o}=e,a=o.inspectorLanguage??"zh",i=Pl(a),s=[],c=0;s.push(r(null,n,{path:"camera.inspectorLanguage",label:i.language,valueType:"enum",control:"enum",value:a,commitMode:"immediate",order:c,options:wg,controlOptions:{variant:"segmented"}})),c+=1,s.push(r(null,n,{path:"camera.projection",label:i.projection,valueType:"enum",control:"enum",value:o.projection??"orthographic",commitMode:"immediate",order:c,options:MD(i),controlOptions:{variant:"segmented"}})),c+=1,s.push(ze(n,r,{path:"camera.alpha",label:i.alpha,value:o.alpha,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.beta",label:i.beta,value:o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.radius",label:i.radius,value:o.radius,order:c,min:.001,step:.1})),c+=1,(o.projection??"orthographic")==="perspective"?s.push(ze(n,r,{path:"camera.fov",label:i.fov,value:at(Tt(o.fov??.85)),order:c,min:1,max:179,step:1,coerce:d=>typeof d=="number"&&Number.isFinite(d)?Ht(d):d})):s.push(ze(n,r,{path:"camera.orthoSize",label:i.orthoSize,value:o.orthoSize??6,order:c,min:.001,step:.1})),c+=1;for(let d of["x","y","z"])s.push(ze(n,r,{path:`camera.targetOffset.${d}`,label:`${i.targetOffset} ${d.toUpperCase()}`,value:o.targetOffset?.[d]??0,order:c,step:.05})),c+=1;s.push(ze(n,r,{path:"camera.minZ",label:i.nearClip,value:o.minZ??1,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.maxZ",label:i.farClip,value:o.maxZ??1e4,order:c,min:.001,step:1})),c+=1,s.push(ze(n,r,{path:"camera.lowerBetaLimit",label:i.minBeta,value:o.lowerBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.upperBetaLimit",label:i.maxBeta,value:o.upperBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.lowerRadiusLimit",label:i.minRadius,value:o.lowerRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.upperRadiusLimit",label:i.maxRadius,value:o.upperRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.inertia",label:i.inertia,value:o.inertia??.9,order:c,min:0,max:1,step:.05})),c+=1;for(let d of["x","y"])s.push(ze(n,r,{path:`camera.targetScreenOffset.${d}`,label:`${i.screenOffset} ${d.toUpperCase()}`,value:o.targetScreenOffset?.[d]??0,order:c,step:.01})),c+=1;return gl(s,{path:"camera.raw",label:i.rawCamera,value:t??"defaults",order:s.length,source:"Document",tags:["Raw"]}),s}function Tl(e){let t=Pl(e.rig.inspectorLanguage??"zh");return{id:"camera",title:t.title,order:42,placement:"body",summary:e.rig.projection==="perspective"?t.summaryPerspective:t.summaryOrthographic,persistence:"document",collapsedByDefault:!1,properties:kg(e)}}function ze(e,t,r){return t(null,e,{path:r.path,label:r.label,valueType:"number",control:"number",value:r.value,commitMode:"live",order:r.order,min:r.min,max:r.max,step:r.step??.05,coerce:r.coerce})}var Es="scene.main",Is="scene";function Wt(e){let t=e.meta?.authoringSource;return{sourceId:t?.sourceId||Es,sourceType:t?.sourceType||Is,revision:typeof t?.revision=="number"?t.revision:1}}function Og(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Es,sourceType:Is,revision:t.revision??1}}}}function Rg(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:Es,sourceType:Is,revision:(t.revision??0)+1}}}}function Cg(e,t){let r=Wt(e),n=wD(t),o=r.revision??null;if(!n)return{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:null,reason:"missing-generated-from"};let a=typeof n.revision=="number"?n.revision:null;return n.sourceId!==r.sourceId||n.sourceType!==r.sourceType?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"source-mismatch"}:o!==a?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"revision-mismatch"}:{detected:!1,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a}}function wD(e){if(!e||typeof e!="object")return null;let t=e.meta;if(!t||typeof t!="object")return null;let r=t.generatedFrom;if(!r||typeof r!="object")return null;let n=r.sourceId,o=r.sourceType;return typeof n!="string"||typeof o!="string"?null:{sourceId:n,sourceType:o,revision:typeof r.revision=="number"?r.revision:void 0}}var kD="sun_light";function Ps(e){let t=OD(e);return t.shadows.planar.enabled?"planar":t.shadows.blob.enabled?"blob":t.shadows.staticProjected.enabled?"static":t.shadows.enabled?"dynamic":"none"}function OD(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function RD(e,t){let r=typeof t.prefab?.prefabId=="string"?t.prefab.prefabId:null,n=r?e.assets.find(a=>a.id===r)?.prefab?.defaults?.shadow:void 0,o=He(n??t.shadow);return{settings:o.shadow,diagnostics:o.diagnostics}}function CD(e){let t=new Map,r=e.casterId;for(let n of e.explicitReceiverIds??[]){let o=xs(e.document,n);!o||o.id===r||o.active===!1||t.set(o.id,{receiverId:o.id,source:"explicit",score:120,...xl(o,"explicit",120,["explicit receiver id"])})}for(let n of e.document.scene.gameObjects){if(n.id===r||n.active===!1)continue;He(n.shadow).shadow?.receive==="enabled"&&jD(t,{receiverId:n.id,source:"explicit",score:100,...xl(n,"explicit",100,["shadow.receive enabled"])})}return[...t.values()].sort((n,o)=>o.score-n.score||n.receiverId.localeCompare(o.receiverId))}function Ts(e){let t=e.caster?.id===e.casterId?e.caster:xs(e.document,e.casterId),r=[];if(!t)return{casterId:e.casterId,receiverIds:[],backend:"none",mode:"none",quality:e.fallbackQuality??"medium",params:hi(e.fallbackQuality??"medium"),diagnostics:[{code:"shadow.invalidTarget",severity:"error",message:`Shadow caster "${e.casterId}" was not found.`,casterId:e.casterId}]};let n=e.resolvedSettings!==void 0?(()=>{let f=He(e.resolvedSettings);return{settings:f.shadow,diagnostics:f.diagnostics}})():RD(e.document,t);r.push(...n.diagnostics);let a=n.settings?.cast==="enabled"?cd(n.settings,e.fallbackMode??"none"):"none",i=dd(n.settings,e.fallbackQuality??"medium"),s=hi(i,n.settings?.params),c=vD(a),d=ND(e.explicitReceiverIds),u=c==="none"?{candidates:[],diagnostics:[]}:d.length>0&&e.strictExplicitReceivers===!0?FD(e.document,t.id,d):{candidates:CD({document:e.document,casterId:t.id,explicitReceiverIds:d.length>0?d:void 0}),diagnostics:[]};r.push(...u.diagnostics);let l=u.candidates;c!=="none"&&l.length===0&&r.push({code:"shadow.receiverNotFound",severity:"warning",message:`No shadow receiver was found for caster "${t.id}".`,casterId:t.id});let m=c==="none"?null:GD(e.document,n.settings??void 0,e.defaultLightId);return m?.diagnostic&&r.push(m.diagnostic),{casterId:t.id,receiverIds:l.map(f=>f.receiverId),...m?.lightId?{lightId:m.lightId}:{},backend:c,mode:a,quality:i,params:s,diagnostics:r}}function vD(e){return e==="dynamic"?"dynamic-map":e==="static"?"static-baked":e==="blob"?"blob":e==="projected"?"projected":"none"}function GD(e,t,r){if(t?.light?.mode==="explicit"){let a=t?.light?.lightId;return a&&vg(e,a)?{lightId:a}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:a?`Explicit shadow light "${a}" was not found.`:"Shadow light mode is explicit, but no lightId was configured.",...a?{lightId:a}:{}}}}let n=r??kD;if(vg(e,n))return{lightId:n};let o=e.scene.gameObjects.find(a=>Gg(a)&&a.active!==!1);return o?{lightId:o.id}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:"No directional shadow light was found."}}}function vg(e,t){let r=xs(e,t);return!!r&&r.active!==!1&&Gg(r)}function Gg(e){return Y(e)==="transform"&&e.light?.type==="directional"}function jD(e,t){let r=e.get(t.receiverId);(!r||t.score>r.score)&&e.set(t.receiverId,t)}function ND(e){let t=new Set,r=[];for(let n of e??[]){let o=typeof n=="string"?n.trim():"";!o||t.has(o)||(t.add(o),r.push(o))}return r}function FD(e,t,r){let n=[],o=[];for(let a of r){let i=xs(e,a);if(!i){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" was not found.`,casterId:t,receiverId:a,details:{source:"explicit"}});continue}if(i.id===t){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Shadow caster "${t}" cannot be used as its own receiver.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"self"}});continue}if(i.active===!1){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" is inactive.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"inactive"}});continue}n.push({receiverId:i.id,source:"explicit",score:120,...xl(i,"explicit",120,["explicit receiver id"])})}return{candidates:n,diagnostics:o}}function xl(e,t,r,n){let o=He(e.shadow).shadow;return{active:e.active!==!1,visible:e.active!==!1,...o?.receive?{receive:o.receive}:{},suitability:{score:r,material:Y(e)==="primitive"?"primitive":t,reasons:n}}}function xs(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}var _D="main_camera",$D="environment_light",LD="sun_light";function Al(e){return Y(e)==="group"}function xt(e){return!!G(e)}function At(e){return Y(e)==="transform"&&(e.transformType==="camera"||!!e.camera)}function fo(e){return Y(e)==="transform"&&(e.transformType==="light"||!!e.light)}function Dt(e){return e.id===_D||e.id===$D||e.id===LD||At(e)||fo(e)}function Dl(e,t){if(!t)return!1;let r=e.scene.gameObjects.find(n=>n.id===t);return!!r&&Dt(r)}var Gr="root",zD="go_",Ml="GameObject";function me(e){return e===Gr}function Z(e){return me(e.id)}function kl(e){let t=new Set,r=!1,n=e.scene.gameObjects.map(o=>{let a=VD(o,t);return r=r||a!==o,a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function he(){let e=globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;return`${zD}${e}`}function it(e,t){let r=new Set(e),n=As(t)||"game_object";if(!r.has(n))return n;let o=2;for(;r.has(`${n}_${o}`);)o+=1;return`${n}_${o}`}function jg(e,t=Ml){return wl(e)??wl(t)??Ml}function st(e,t,r={}){let n=jg(t,r.fallbackName??Ml),o=new Set(e.map(s=>wl(s)).filter(s=>!!s));if(!r.alwaysAppendSuffix&&!o.has(n))return n;let a=1,i=`${n}_${a}`;for(;o.has(i);)a+=1,i=`${n}_${a}`;return i}function wl(e){let t=String(e??"").trim();return t&&t.replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||null}function As(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"asset"}function BD(e){return typeof e.guid=="string"&&e.guid.trim()?e.guid.trim():null}function VD(e,t){let r=BD(e);if(r&&!t.has(r))return t.add(r),r===e.guid?e:{...e,guid:r};let n=he();for(;t.has(n);)n=he();return t.add(n),{...e,guid:n}}var jr=Et();function ke(e,t){if(me(t))return Et();let r=_(e,t);if(!r)return null;let n=[],o=Ol(e),a=new Set,i=r;for(;i&&!a.has(i.id);)a.add(i.id),n.unshift(i),i=i.parentId?o.get(i.parentId):void 0;return wp(n.map(qt))}function _(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function Ol(e){return new Map(e.scene.gameObjects.map(t=>[t.id,t]))}function ur(e,t,r,n){let o=t?ke(e,t):Et();return o?to(o,r,n):null}function Ia(e,t,r,n={}){let o=Ui(n);return ur(e,t,r,{allowMatrixFallback:o.allowMatrixFallback})}function qt(e){return Z(e)?Et():go(e)}function Pa(e,t={}){let r=e.scene.gameObjects.find(Z);if(!r)return e;let n=go(r),o=!!G(r)&&!KD(n,jr),a=!1,i=e.scene.gameObjects.map(s=>{if(Z(s)){let l=Ng(s,t);return a=a||l!==s,l}if(!o||s.parentId!==Gr||!G(s))return s;let d=kp(n,go(s));if(!d)return s;let u=Rl(s,d);return a=!0,u});return a?{...e,scene:{...e.scene,gameObjects:i}}:e}function Ng(e,t={}){let r=!1,n=e.parentId!==void 0||t.normalizeRootActive===!0&&e.active!==!0,o=e.components.map(i=>{if(i.type!=="Transform")return i;r=!0;let s=i;return Ms(s)&&po(s.position,jr.position)&&po(s.rotation,jr.rotation)&&po(Fg(s,"scale"),jr.scale)?i:(n=!0,Ds())});if(r||(n=!0,o.unshift(Ds())),!n)return e;let a={...e,...t.normalizeRootActive===!0?{active:!0}:{},components:o};return delete a.parentId,a}function Ds(){return Mt(jr)}function go(e){let t=G(e);return t?Ee(t)?Bi(t.matrix)??Et():{position:{...t.position},rotation:{...t.rotation},scale:{...Fg(t,"scale")}}:Et()}function Rl(e,t){return{...e,components:e.components.map(r=>r.type!=="Transform"?r:mr(t)??r)}}function mr(e){let t=Sn(e);return t?tt(t)?{type:"Transform",mode:"matrix",matrix:t.matrix}:{type:"Transform",...t.mode==="trs"?{mode:"trs"}:{},position:{...t.position},rotation:{...t.rotation},scale:{...t.scale}}:null}function Sn(e){return tt(e)?Bi(e.matrix):Dp(e)}function Mt(e){let t=mr(e);if(!t)throw new Error("Invalid matrix Transform component.");return t}function Ee(e){return e.mode==="matrix"}function Ms(e){return e.mode!=="matrix"}function Fg(e,t){return UD(e)?t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]:t==="scale"?{x:1,y:1,z:1}:{x:0,y:0,z:0}}function UD(e){return!!e.position&&!!e.rotation}function KD(e,t){return!It(e)||!It(t)?aa(Fe(e),Fe(t)):po(e.position,t.position)&&po(e.rotation,t.rotation)&&po(e.scale,t.scale)}function po(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function fe(e){return e.scene.gameObjects.find(t=>t.id===Gr&&!!G(t))?.id??e.scene.gameObjects.find(t=>!t.parentId&&!!G(t))?.id}function ws(e,t){return me(e)&&/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/.test(t)}function Cl(e,t){return!t||t===Gr?!1:!!_(e,t)}function fr(e){let t=fe(e),r=new Map(e.scene.gameObjects.map(n=>[n.id,n]));return e.scene.gameObjects.filter(n=>n.id!==Gr).map(n=>{let o=Dt(n),a=xt(n),i=n.active!==!1;return{id:n.id,label:n.name??n.id,parentId:n.parentId===t?null:n.parentId??null,depth:Math.max(0,HD(r,n)-(t?1:0)),role:a&&Al(n)?"group":"object",...is(n)?{icon:"prefab"}:{},selectable:!0,enabled:i&&WD(r,n.parentId,t),directEnabled:i,canToggleEnabled:!o,enableToggleDisabledReason:o?"Protected system objects cannot be hidden from Hierarchy.":void 0,protected:o,canHaveChildren:!o&&a,renamable:!o,deletable:!o,draggable:!o}})}function HD(e,t){let r=new Set,n=0,o=t.parentId??null;for(;o;){if(r.has(o))return n;r.add(o);let a=e.get(o);if(!a)return n;n+=1,o=a.parentId??null}return n}function WD(e,t,r){let n=new Set,o=t??null;for(;o;){if(n.has(o))return!0;n.add(o);let a=e.get(o);if(!a)return!0;if(a.id!==r&&a.active===!1)return!1;o=a.parentId??null}return!0}function vl(e){let t=Pa(e,{normalizeRootActive:!0}),r=fe(t);if(!r)return t;let n=t.scene.gameObjects.find(s=>s.id===r);if(!n)return t;let o=Z(n)?null:ke(t,r);if(!Z(n)&&!o)return t;let a=!1,i=t.scene.gameObjects.map(s=>{if(s.id===r||s.parentId)return s;let c=qt(s),d=o?to(o,c,{allowMatrixFallback:!0}):c;return a=!0,{...s,parentId:r,components:d?s.components.map(u=>u.type!=="Transform"?u:Mt(d)):s.components}});return a?{...t,scene:{...t.scene,gameObjects:i}}:t}function pr(e,t){return[...wt(e,t)]}function wt(e,t){let r=new Set,n=new Map;for(let i of e.scene.gameObjects){r.add(i.id);let s=i.parentId;if(!s)continue;let c=n.get(s);c?c.push(i.id):n.set(s,[i.id])}let o=new Set,a=[];for(let i of t)!r.has(i)||o.has(i)||(o.add(i),a.push(i));for(let i=0;i<a.length;i+=1)for(let s of n.get(a[i])??[])o.has(s)||(o.add(s),a.push(s));return o}function Nl(e){let t=[_g(e)],r=Lg(e);r&&t.push(r);let n=Vg(e);n&&t.push(n);let o=Hg(e);o&&t.push(o);let a=Jg(e);a&&t.push(a);let i=XD(e);i&&t.push(i);let s=Yg(e);s&&t.push(s);let c=Zg(e);c&&t.push(c);let d=eb(e);return d&&t.push(d),t}function _g(e){return{id:"common",title:"Common",order:10,placement:"body",summary:Rs(e),persistence:"document",collapsedByDefault:!1,properties:$g(e)}}function $g(e){let{document:t,gameObject:r}=e,n=Rs(e),o=[Qe("id","ID",r.id,0),Jt(e,{document:t,path:"name",label:"Name",valueType:"string",control:"string",value:r.name??r.id,commitMode:"blur",order:1}),Jt(e,{document:t,path:"enabled",label:"Enabled",valueType:"boolean",control:"boolean",value:r.active!==!1,commitMode:"immediate",order:2}),Qe("kind.resolved","Resolved Kind",n,3),Qe("kind.explicit","Explicit Kind",r.kind??"inferred",4),Qe("common.activeField","Active Field",r.active??"default:true",5)];return n==="transform"?o.push(Jt(e,{document:t,path:"transformType",label:"Transform Type",valueType:"enum",control:"enum",value:r.transformType??"plain",commitMode:"immediate",order:6,options:e.transformTypeOptions??xa})):o.push(Qe("common.transformType","Transform Type",r.transformType??"none",6)),o}function Lg(e){return Cr({id:"hierarchySource",title:"Hierarchy / Source",order:15,summary:zg(e),collapsedByDefault:!0,tags:["Document","Derived"],properties:Bg(e)})}function zg(e){let t=e.gameObject.parentId?_(e.document,e.gameObject.parentId):null;return t?`Parent: ${t.name??t.id}`:"Scene root"}function Bg(e){let{document:t,gameObject:r}=e,n=[],o=r.parentId?_(t,r.parentId):null,a=t.scene.gameObjects.filter(d=>d.parentId===r.id),i=Math.max(pr(t,[r.id]).length-1,0),s=Wt(t),c=t.scene.gameObjects.filter(d=>d.parentId===r.parentId).findIndex(d=>d.id===r.id);return oe(n,{path:"hierarchy.parentId",label:"Parent ID",value:r.parentId??"none",order:0,source:"Document"}),oe(n,{path:"hierarchy.parentName",label:"Parent Name",value:o?o.name??o.id:r.parentId?"missing":"none",order:1,source:"Document"}),oe(n,{path:"hierarchy.childCount",label:"Children",value:a.length,order:2,source:"Derived"}),oe(n,{path:"hierarchy.descendantCount",label:"Descendants",value:i,order:3,source:"Derived"}),oe(n,{path:"hierarchy.siblingIndex",label:"Sibling Index",value:c>=0?c:"unknown",order:4,source:"Derived"}),oe(n,{path:"document.gameObjectIndex",label:"Document Index",value:t.scene.gameObjects.findIndex(d=>d.id===r.id),order:5,source:"Derived"}),oe(n,{path:"document.schemaVersion",label:"Schema Version",value:t.schemaVersion,order:6,source:"Document"}),oe(n,{path:"source.sourceId",label:"Source ID",value:s.sourceId,order:7,source:"Document"}),oe(n,{path:"source.sourceType",label:"Source Type",value:s.sourceType,order:8,source:"Document"}),oe(n,{path:"source.revision",label:"Revision",value:s.revision??"none",order:9,source:"Document"}),n}function Vg(e){return G(e.gameObject)?{id:"transform",title:"Transform",order:20,placement:"body",summary:Kg(e),persistence:"document",collapsedByDefault:!1,properties:Ug(e)}:null}function Ug(e){if(!G(e.gameObject))return[];let r=Rs(e),n=Z(e.gameObject),o=n?e.rootTransform??Et():go(e.gameObject);if(tt(o))return qD(o,0);let a=!!e.gameObject.parentId,i=[],s=0;for(let c of["position","rotation","scale"]){let d=oM(o,c);for(let u of["x","y","z"]){let l=`transform.${c}.${u}`,m=c==="rotation"?at(Tt(d[u])):d[u];n?i.push(Qe(l,`${jl(c)}.${u}`,m,s)):i.push(Jt(e,{document:null,path:l,label:`${a?`Local ${jl(c)}`:jl(c)}.${u}`,valueType:"number",control:"number",value:m,commitMode:"live",order:s,displayPrecision:c==="rotation"?2:3,precision:4,step:c==="rotation"?1:c==="scale"?.01:.1,stepPrecision:c==="rotation"?.1:c==="scale"?.001:.01},r)),s+=1}}if(a){let c=ke(e.document,e.gameObject.id);if(c&&!tt(c))for(let d of["x","y","z"])i.push(Qe(`transform.worldPosition.${d}`,`World Position.${d}`,c.position[d],s)),s+=1}return i}function Kg(e){let t=e.gameObject.parentId?_(e.document,e.gameObject.parentId):null;if(Z(e.gameObject))return"Identity Root";let r=G(e.gameObject);return r&&Ee(r)?"Matrix Transform":`Relative to: ${t?t.name??t.id:"Scene"}`}function qD(e,t){if(!tt(e))return[];let r=[Qe("transform.mode","Mode","Matrix Transform",t)],n=t+1;for(let a=0;a<4;a+=1)r.push(Qe(`transform.matrix.row${a}`,`Matrix Row ${a+1}`,e.matrix.slice(a*4,a*4+4).map(ks).join(", "),n)),n+=1;let o=Wd(e.matrix);return r.push(Qe("transform.matrix.trsApproximation","TRS Approximation",o?[`P ${Gl(o.position)}`,`R ${Gl({x:Tt(o.rotation.x),y:Tt(o.rotation.y),z:Tt(o.rotation.z)})}`,`S ${Gl(o.scale)}`].join(" | "):"Not representable as TRS",n)),r}function Hg(e){let t=ue(e.gameObject),r=kr(e.gameObject),n=t?.assetId??r?.assetId;return n?{id:"renderer",title:r?"Image Renderer / Asset":"Renderer / Asset",order:30,placement:"body",summary:qg(e.document,n),persistence:"document",collapsedByDefault:!0,properties:r?JD(e,r):Wg(e)}:null}function JD(e,t){let r=Ta(e.document,t.assetId);return[Qe("imageRenderer.assetId","Texture Asset",r?.displayName??t.assetId,0),Qe("imageRenderer.size","Image Size",`${t.size.width} \xD7 ${t.size.height}`,1),Qe("imageRenderer.assetType","Asset Type",r?.type??"texture",2)]}function Wg(e){let t=ue(e.gameObject);if(!t)return[];let{document:r}=e,n=Ta(r,t.assetId),o=[Jt(e,{document:r,path:"instance.assetId",label:"Asset",valueType:"enum",control:"enum",value:t.assetId,commitMode:"immediate",order:0,options:r.assets.map(a=>({label:a.displayName??a.id,value:a.id}))})];return oe(o,{path:"renderer.assetId",label:"Renderer Asset ID",value:t.assetId,order:1,source:"Document"}),oe(o,{path:"asset.id",label:"Asset ID",value:n?.id??"missing",order:2,source:"Asset"}),oe(o,{path:"asset.type",label:"Asset Type",value:n?.type??"missing",order:3,source:"Asset"}),oe(o,{path:"asset.guid",label:"GUID",value:n?.guid??"missing",order:4,source:"Asset"}),oe(o,{path:"asset.displayName",label:"Display Name",value:n?.displayName??"none",order:5,source:"Asset"}),oe(o,{path:"asset.category",label:"Category",value:n?.category??"none",order:6,source:"Asset"}),oe(o,{path:"asset.materialMode",label:"Material Mode",value:n?.materialMode??"none",order:7,source:"Asset"}),oe(o,{path:"asset.defaults",label:"Defaults",value:n?.defaults??"none",order:8,source:"Asset",tags:["Raw"]}),o}function qg(e,t){let r=Ta(e,t);return r?r.displayName??r.id:`Missing asset: ${t}`}function Jg(e){let t=e.gameObject.primitive;return t?{id:"primitive",title:"Primitive",order:32,placement:"body",summary:t.shape,persistence:"document",collapsedByDefault:!1,properties:Xg(e)}:null}function Xg(e){let t=e.gameObject.primitive;return t?[Jt(e,{document:e.document,path:"primitive.shape",label:"Shape",valueType:"enum",control:"enum",value:t.shape,commitMode:"immediate",order:0,options:e.primitiveShapeOptions??aM})]:[]}function XD(e){if(e.gameObject.prefab)return YD(e);if(!bo(e))return null;let t=He(e.gameObject.shadow).shadow,r=Jt(e,{document:e.document,path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.cast==="enabled",commitMode:"immediate",order:0,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u8BE5\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002"}),n=Jt(e,{document:e.document,path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.receive==="enabled",commitMode:"immediate",order:1,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002"}),o=Os(e.renderingProfile),a=e.renderingProfile!==void 0&&Ps(o)==="none";return{id:"shadow",title:"\u9634\u5F71",order:34,placement:"body",...a?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[r,n,...a?[Fl()]:[]]}}function YD(e){let t=e.gameObject.prefab?.prefabId,r=t?e.document.assets.find(i=>i.id===t)?.prefab?.defaults?.shadow:void 0,n=He(r).shadow,o=!!t,a=[{path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:0,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},{path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:1,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},...t?[io({path:"prefab.edit-definition",label:"\u8FDB\u5165 Prefab",buttonLabel:"Edit Prefab",actionId:"asset.edit-prefab",order:2,icon:"box",tooltip:"\u5728 Prefab Stage \u4E2D\u7F16\u8F91 definition root \u7684\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002",params:{assetId:t,browserAssetId:`prefab:${t}`,assetKind:"prefab"},disabled:!1})]:[]];return{id:"shadow",title:"\u9634\u5F71",order:34,summary:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B":"\u7531 Prefab definition root \u7BA1\u7406",persistence:o?"document":"readonly",collapsedByDefault:!1,properties:a}}function Fl(){return{path:"rendering.shadows.open",label:"\u6253\u5F00 Rendering / Shadows",valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:"\u6253\u5F00 Rendering / Shadows",icon:"world"},value:"\u6253\u5F00 Rendering / Shadows",readOnly:!0,persistence:"readonly",commitMode:"immediate",order:2,tags:["Rendering"],effect:"active"}}function Os(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function Yg(e){if(!ZD(e))return null;let t=Os(e.renderingProfile),r=QD(e.gameObject.rendering?.renderingGroupId),n=t.renderingGroups.slots.find(a=>a.renderingGroupId===r)??t.renderingGroups.slots[0],o=eM(e.gameObject)??null;return{id:"rendering",title:"Rendering",order:36,placement:"body",summary:tM(n,o),persistence:"document",collapsedByDefault:!1,properties:[Jt(e,{document:e.document,path:"rendering.renderingGroupId",label:"Rendering Group",valueType:"enum",control:"enum",value:r,commitMode:"immediate",order:0,options:t.renderingGroups.slots.map(a=>({label:`${a.renderingGroupId}: ${a.name}`,value:a.renderingGroupId}))}),Jt(e,{document:e.document,path:"rendering.alphaIndex",label:"Alpha Order",valueType:"enum",control:"enum",value:o,commitMode:"immediate",order:1,options:rM(n,o)})]}}function Zg(e){return Cr({id:"components",title:"Scripts / Components",order:65,summary:_l(e.gameObject),collapsedByDefault:!0,tags:["Document"],properties:Qg(e.gameObject)})}function _l(e){return e.components.map(t=>t.type).join(", ")||"none"}function Qg(e){let t=[];return oe(t,{path:"components.count",label:"Count",value:e.components.length,order:0,source:"Document"}),oe(t,{path:"components.types",label:"Types",value:_l(e),order:1,source:"Document"}),e.components.forEach((r,n)=>{oe(t,{path:`components.${n}`,label:`${r.type} ${n}`,value:r,order:n+2,source:"Document",tags:["Component","Raw"]})}),t}function eb(e){let t=e.assetId??ue(e.gameObject)?.assetId??kr(e.gameObject)?.assetId??null,r=tb({document:e.document,gameObject:e.gameObject,assetId:t});return r.length===0?null:{id:"metadata",title:"Metadata",order:80,placement:"body",summary:rb({document:e.document,gameObject:e.gameObject,assetId:t}),persistence:"readonly",collapsedByDefault:!0,tags:["Document","Asset"],properties:r}}function tb(e){let t=[],r=e.assetId?Ta(e.document,e.assetId):null;return oe(t,{path:"metadata.document",label:"Document Meta",value:e.document.meta??"none",order:0,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.gameObject",label:"GameObject Metadata",value:e.gameObject.metadata??"none",order:1,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.asset",label:"Asset Metadata",value:r?.metadata??"none",order:2,source:"Asset",tags:["Raw"]}),t}function rb(e){let t=e.assetId?Ta(e.document,e.assetId):null,r=[e.document.meta?"Document":null,e.gameObject.metadata?"GameObject":null,t?.metadata?"Asset":null].filter(n=>!!n);return r.length>0?r.join(" + "):"none"}function Jt(e,t,r=Rs(e)){let{document:n,...o}=t;return Ea({document:n??null,nodeKind:r,property:o,extraValidators:e.extraValidators})}function oe(e,t){let r=j(t);r&&e.push(r)}function Qe(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function Rs(e){return e.nodeKind??Y(e.gameObject)}function bo(e){let t=e.gameObject;return Z(t)?!1:dn(t)}function ZD(e){let t=e.gameObject;if(Z(t)||t.transformType==="camera"||t.transformType==="light"||t.camera||t.light)return!1;let r=e.nodeKind??Y(t);return r==="instance"||r==="primitive"||r==="transform"}function QD(e){return e===1||e===2||e===3?e:0}function eM(e){let t=e.rendering?.alphaIndex;if(typeof t=="number"&&Number.isFinite(t))return t}function tM(e,t){return t==null?`${e.name} \xB7 Babylon \u9ED8\u8BA4`:`${e.name} \xB7 ${nM(e,t)}`}function rM(e,t){let r=[{label:"Babylon \u9ED8\u8BA4",value:null},...e.alphaIndexPresets.map(n=>({label:`${n.name} (${n.alphaIndex})`,value:n.alphaIndex}))];return t!=null&&!e.alphaIndexPresets.some(n=>n.alphaIndex===t)&&r.push({label:`\u672A\u547D\u540D\u503C ${t}`,value:t,batchCompatibility:"ignore"}),r}function nM(e,t){let r=e.alphaIndexPresets.find(n=>n.alphaIndex===t);return r?r.name:`\u672A\u547D\u540D\u503C ${t}`}function oM(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function Gl(e){return`${ks(e.x)}, ${ks(e.y)}, ${ks(e.z)}`}function ks(e){return at(e).toString()}function jl(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function Ta(e,t){return e.assets.find(r=>r.id===t)??null}var xa=[{label:"Plain",value:"plain"},{label:"Light",value:"light"},{label:"Camera",value:"camera"}],aM=[{label:"Cube",value:"cube"},{label:"Sphere",value:"sphere"},{label:"Plane",value:"plane"},{label:"Capsule",value:"capsule"}];function nb(e){return[ib(e),sb(e.runtime),cb(e.runtime),db(e.runtime),lb(e.runtime),ub(e.runtime),mb(e.runtime),fb(e.runtime),pb(e.runtime),gb(e.runtime),bb(e.runtime),Sb(e.runtime),yb(e)].filter(t=>!!t)}function $l(e,t){if(!e.activeId)return[];let r=t.findGameObject(e.document,e.activeId);if(!r||e.targetIds&&e.targetIds.length!==1)return[];let n=ga({projectedRoot:e.projectedRoot,projectionNode:e.projectionNode??null});return nb({runtime:n,binding:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,objectId:e.activeId,component:t.hasModelRenderer(r)?"ModelRenderer":t.hasImageRenderer(r)?"ImageRenderer":t.readNodeKind(r)==="transform"?"Transform":"GameObject",projectionNodeId:ce(e.projectionNode,"id")??null,projectionName:ce(e.projectionNode,"name")??null,projectionParentId:ce(e.projectionNode,"parentId")??null,projectionAssetId:ob(e.projectionNode)},projectionAssetMetadata:ab(e.projectionNode)})}function ob(e){let t=B(e,"asset");return ce(t,"assetId")??ce(t,"id")}function ab(e){return B(B(e,"asset"),"metadata")}function ib(e){let{binding:t,runtime:r}=e,n=[];return x(n,{path:"runtime.binding.sourceId",label:"Source ID",value:t?.sourceId??"none",order:0,source:"Document"}),x(n,{path:"runtime.binding.sourceType",label:"Source Type",value:t?.sourceType??"none",order:1,source:"Document"}),x(n,{path:"runtime.binding.objectId",label:"Object ID",value:t?.objectId??"none",order:2,source:"Document"}),x(n,{path:"runtime.binding.component",label:"Component",value:t?.component??"GameObject",order:3,source:"Derived"}),x(n,{path:"runtime.projection.nodeId",label:"Projection Node ID",value:t?.projectionNodeId??"none",order:4,source:"Derived"}),x(n,{path:"runtime.projection.name",label:"Projection Name",value:t?.projectionName??"none",order:5,source:"Derived"}),x(n,{path:"runtime.projection.parentId",label:"Projection Parent",value:t?.projectionParentId??"none",order:6,source:"Derived"}),x(n,{path:"runtime.projection.assetId",label:"Projection Asset ID",value:t?.projectionAssetId??"none",order:7,source:"Asset"}),x(n,{path:"runtime.root.status",label:"Projected Root",value:r.root?"available":"not projected",order:8,source:"Runtime"}),x(n,{path:"runtime.root.className",label:"Runtime Class",value:Kt(r.root)??"none",order:9,source:"Runtime"}),x(n,{path:"runtime.root.name",label:"Runtime Name",value:ce(r.root,"name")??"none",order:10,source:"Runtime"}),x(n,{path:"runtime.binding.primaryMesh",label:"Primary Mesh",value:un(r.primaryMesh)??"none",order:11,source:"Derived"}),x(n,{path:"runtime.binding.primaryMaterial",label:"Primary Material",value:un(r.material)??"none",order:12,source:"Derived"}),x(n,{path:"runtime.material.kind",label:"Material Kind",value:Tb(r.material)??"none",order:13,source:"Runtime"}),Be({id:"runtimeBinding",title:"Runtime Binding",order:910,summary:r.root?un(r.root)??"Runtime":"not projected",collapsedByDefault:!0,properties:n})}function sb(e){let t=[],r=us(e.root)??us(e.primaryMesh);return r?(yn(t,"runtime.bounds.min","Bounds Min",r.min,t.length,"Derived"),yn(t,"runtime.bounds.max","Bounds Max",r.max,t.length,"Derived"),yn(t,"runtime.bounds.center","Bounds Center",r.center,t.length,"Derived"),yn(t,"runtime.bounds.size","Bounds Size",r.size,t.length,"Derived")):x(t,{path:"runtime.bounds.status",label:"Bounds",value:"not available",source:"Derived"}),x(t,{path:"runtime.geometry.meshCount",label:"Mesh Count",value:e.meshes.length,source:"Derived"}),x(t,{path:"runtime.geometry.childNodeCount",label:"Child Nodes",value:e.childNodes.length,source:"Derived"}),x(t,{path:"runtime.geometry.totalVertices",label:"Total Vertices",value:ms(e.meshes,"getTotalVertices"),source:"Derived"}),x(t,{path:"runtime.geometry.totalIndices",label:"Total Indices",value:ms(e.meshes,"getTotalIndices"),source:"Derived"}),x(t,{path:"runtime.geometry.subMeshCount",label:"SubMeshes",value:e.meshes.reduce((n,o)=>n+so(o,"subMeshes"),0),source:"Derived"}),Be({id:"geometryBox",title:"Geometry / Box",order:920,summary:r?`${e.meshes.length} mesh${e.meshes.length===1?"":"es"}`:"no bounds",collapsedByDefault:!1,properties:t})}function cb(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.rendering.nodeClass",label:"Node Class",value:Kt(t)??"none"}),x(r,{path:"runtime.rendering.nodeName",label:"Node Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.rendering.isEnabled",label:"Enabled",value:Sl(t)??"not available"}),x(r,{path:"runtime.rendering.isVisible",label:"Is Visible",value:Te(t,"isVisible")??"not available"}),x(r,{path:"runtime.rendering.visibility",label:"Visibility",value:re(t,"visibility")??"not available"}),x(r,{path:"runtime.rendering.layerMask",label:"Layer Mask",value:re(t,"layerMask")??"not available"}),x(r,{path:"runtime.rendering.renderingGroupId",label:"Rendering Group",value:re(t,"renderingGroupId")??"not available"}),x(r,{path:"runtime.rendering.alphaIndex",label:"Alpha Index",value:re(t,"alphaIndex")??"not available"}),x(r,{path:"runtime.rendering.alwaysSelectAsActiveMesh",label:"Always Active Mesh",value:Te(t,"alwaysSelectAsActiveMesh")??"not available"}),x(r,{path:"runtime.rendering.billboardMode",label:"Billboard Mode",value:re(t,"billboardMode")??"not available"}),Be({id:"rendering",title:"Rendering",order:930,summary:ce(t,"name")??Kt(t)??"not available",collapsedByDefault:!0,properties:r})}function db(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.collisions.checkCollisions",label:"Check Collisions",value:Te(t,"checkCollisions")??"not configured"}),x(r,{path:"runtime.collisions.collisionMask",label:"Collision Mask",value:re(t,"collisionMask")??"not configured"}),x(r,{path:"runtime.collisions.collisionGroup",label:"Collision Group",value:re(t,"collisionGroup")??"not configured"}),x(r,{path:"runtime.collisions.collisionResponse",label:"Collision Response",value:Te(t,"collisionResponse")??"not configured"}),x(r,{path:"runtime.collisions.moveWithCollisions",label:"Move With Collisions",value:typeof B(t,"moveWithCollisions")=="function"?"available":"not available"}),yn(r,"runtime.collisions.ellipsoid","Ellipsoid",B(t,"ellipsoid"),r.length,"Runtime","not configured"),yn(r,"runtime.collisions.ellipsoidOffset","Ellipsoid Offset",B(t,"ellipsoidOffset"),r.length,"Runtime","not configured"),Be({id:"collisions",title:"Collisions",order:940,summary:Te(t,"checkCollisions")===!0?"enabled":"not configured",collapsedByDefault:!0,properties:r})}function lb(e){let t=e.primaryMesh??e.root,r=B(t,"physicsBody"),n=B(t,"physicsImpostor"),o=r??n,a=[];return x(a,{path:"runtime.physics.status",label:"Physics",value:o?"configured":"not configured"}),x(a,{path:"runtime.physics.bodyClass",label:"Body Class",value:Kt(o)??"none"}),x(a,{path:"runtime.physics.bodyName",label:"Body Name",value:ce(o,"name")??ce(o,"id")??"none"}),x(a,{path:"runtime.physics.mass",label:"Mass",value:ba(o,"mass")??"not available"}),x(a,{path:"runtime.physics.friction",label:"Friction",value:ba(o,"friction")??"not available"}),x(a,{path:"runtime.physics.restitution",label:"Restitution",value:ba(o,"restitution")??"not available"}),x(a,{path:"runtime.physics.disablePreStep",label:"Disable Pre Step",value:Te(o,"disablePreStep")??"not available"}),Be({id:"physics",title:"Physics",order:950,summary:o?un(o)??"configured":"not configured",collapsedByDefault:!0,properties:a})}function ub(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.shadows.receiveShadows",label:"Receive Shadows",value:Te(t,"receiveShadows")??"not configured"}),x(r,{path:"runtime.shadows.shadowEnabled",label:"Shadow Enabled",value:we(t,"isShadowEnabled")??"not available"}),x(r,{path:"runtime.shadows.shadowDepthWrapper",label:"Shadow Depth Wrapper",value:un(B(e.material,"shadowDepthWrapper"))??"none"}),x(r,{path:"runtime.shadows.receivingMeshCount",label:"Receiving Meshes",value:e.meshes.filter(n=>Te(n,"receiveShadows")===!0).length,source:"Derived"}),Be({id:"shadows",title:"Shadows",order:960,summary:Te(t,"receiveShadows")===!0?"receiving":"not configured",collapsedByDefault:!0,properties:r})}function mb(e){let t=e.material,r=[];return x(r,{path:"runtime.material.status",label:"Material",value:t?"available":"none"}),x(r,{path:"runtime.material.className",label:"Class",value:Kt(t)??"none"}),x(r,{path:"runtime.material.name",label:"Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.material.id",label:"ID",value:ce(t,"id")??"none"}),x(r,{path:"runtime.material.uniqueId",label:"Unique ID",value:re(t,"uniqueId")??"not available"}),x(r,{path:"runtime.material.alpha",label:"Alpha",value:re(t,"alpha")??"not available"}),x(r,{path:"runtime.material.backFaceCulling",label:"Back Face Culling",value:Te(t,"backFaceCulling")??"not available"}),x(r,{path:"runtime.material.twoSidedLighting",label:"Two Sided Lighting",value:Te(t,"twoSidedLighting")??"not available"}),x(r,{path:"runtime.material.disableLighting",label:"Disable Lighting",value:Te(t,"disableLighting")??"not available"}),x(r,{path:"runtime.material.wireframe",label:"Wireframe",value:Te(t,"wireframe")??"not available"}),x(r,{path:"runtime.material.pointsCloud",label:"Points Cloud",value:Te(t,"pointsCloud")??"not available"}),x(r,{path:"runtime.material.fillMode",label:"Fill Mode",value:re(t,"fillMode")??"not available"}),x(r,{path:"runtime.material.activeTextureCount",label:"Active Textures",value:fs(t,"getActiveTextures"),source:"Derived"}),Be({id:"material",title:"Material",order:970,summary:un(t)??"none",collapsedByDefault:!0,properties:r})}function fb(e){let t=e.material,r=[];x(r,{path:"runtime.material.textures.activeCount",label:"Active Texture Count",value:fs(t,"getActiveTextures"),source:"Derived"});let n=0;for(let o of xb){let a=B(t,o);a&&(n+=1,Eb(r,`runtime.material.textures.${o}`,Aa(o),a))}return n===0&&x(r,{path:"runtime.material.textures.status",label:"Textures",value:"none"}),Be({id:"materialTextures",title:"Material Textures",order:980,summary:n>0?`${n} slot${n===1?"":"s"}`:"none",collapsedByDefault:!0,properties:r})}function pb(e){let t=[],r=0;for(let n of Ab){let o=B(e.material,n);hb(t,`runtime.material.colors.${n}`,Aa(n),o,t.length)&&(r+=1)}return r===0&&x(t,{path:"runtime.material.colors.status",label:"Colors",value:"none"}),Be({id:"materialColors",title:"Material Colors",order:990,summary:r>0?`${r} color${r===1?"":"s"}`:"none",collapsedByDefault:!0,properties:t})}function gb(e){let t=[];for(let r of Db)x(t,{path:`runtime.material.metallicRoughness.${r}`,label:Aa(r),value:re(e.material,r)??"not available"});return Be({id:"metallicRoughness",title:"Metallic / Roughness",order:1e3,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function bb(e){let t=[];for(let r of Mb)x(t,{path:`runtime.material.intensity.${r}`,label:Aa(r),value:re(e.material,r)??"not available"});return Be({id:"intensityProperties",title:"Intensity Properties",order:1010,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function Sb(e){let t=e.primaryMesh??e.root,r=B(t,"skeleton"),n=[];return x(n,{path:"runtime.animation.rootAnimationCount",label:"Root Animations",value:so(e.root,"animations"),source:"Derived"}),x(n,{path:"runtime.animation.meshAnimationCount",label:"Mesh Animations",value:so(t,"animations"),source:"Derived"}),x(n,{path:"runtime.skeleton.status",label:"Skeleton",value:r?"available":"none"}),x(n,{path:"runtime.skeleton.className",label:"Skeleton Class",value:Kt(r)??"none"}),x(n,{path:"runtime.skeleton.name",label:"Skeleton Name",value:ce(r,"name")??"none"}),x(n,{path:"runtime.skeleton.id",label:"Skeleton ID",value:ce(r,"id")??"none"}),x(n,{path:"runtime.skeleton.boneCount",label:"Bones",value:so(r,"bones"),source:"Derived"}),Be({id:"animationSkeleton",title:"Animation / Skeleton",order:1020,summary:r?ce(r,"name")??"skeleton":"none",collapsedByDefault:!0,properties:n})}function yb(e){let{runtime:t}=e,r=[];return x(r,{path:"runtime.raw.rootMetadata",label:"Root Metadata",value:B(t.root,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.primaryMeshMetadata",label:"Mesh Metadata",value:B(t.primaryMesh,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.materialMetadata",label:"Material Metadata",value:B(t.material,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.projectionAssetMetadata",label:"Projection Asset Metadata",value:e.projectionAssetMetadata??"none",source:"Asset",tags:["Raw"]}),x(r,{path:"runtime.misc.isDisposed",label:"Root Disposed",value:we(t.root,"isDisposed")??"not available"}),Be({id:"rawMisc",title:"Raw / Misc",order:1030,summary:"metadata",collapsedByDefault:!0,properties:r})}function Be(e){return Cr({id:e.id,title:e.title,order:e.order,summary:e.summary,persistence:"runtime",runtimeOnly:!0,collapsedByDefault:e.collapsedByDefault,omitWhenEmpty:!1,tags:["Runtime"],properties:e.properties})}function x(e,t){let r=j({...t,persistence:"runtime",source:t.source??"Runtime"});r&&e.push(r)}function yn(e,t,r,n,o,a="Runtime",i){let s=bl({basePath:t,label:r,value:n,order:o,persistence:"runtime",source:a});s.length>0?e.push(...s):i&&x(e,{path:`${t}.status`,label:r,value:i,order:o,source:a})}function hb(e,t,r,n,o){let a=Pb(n);return a?(x(e,{path:`${t}.r`,label:`${r}.r`,value:a.r,order:o,valueType:"number"}),x(e,{path:`${t}.g`,label:`${r}.g`,value:a.g,order:o+1,valueType:"number"}),x(e,{path:`${t}.b`,label:`${r}.b`,value:a.b,order:o+2,valueType:"number"}),a.a!=null&&x(e,{path:`${t}.a`,label:`${r}.a`,value:a.a,order:o+3,valueType:"number"}),!0):!1}function Eb(e,t,r,n){let o=e.length;x(e,{path:`${t}.className`,label:`${r} Class`,value:Kt(n)??"Texture",order:o}),x(e,{path:`${t}.name`,label:`${r} Name`,value:ce(n,"name")??"none",order:o+1}),x(e,{path:`${t}.url`,label:`${r} URL`,value:Ib(n)??"none",order:o+2}),x(e,{path:`${t}.level`,label:`${r} Level`,value:re(n,"level")??"not available",order:o+3}),x(e,{path:`${t}.coordinatesIndex`,label:`${r} UV Set`,value:re(n,"coordinatesIndex")??"not available",order:o+4}),x(e,{path:`${t}.hasAlpha`,label:`${r} Has Alpha`,value:Te(n,"hasAlpha")??"not available",order:o+5})}function Ib(e){return ce(e,"url")??ce(e,"name")??ce(we(e,"getInternalTexture"),"url")}function Pb(e){if(!e||typeof e!="object")return null;let t=re(e,"r"),r=re(e,"g"),n=re(e,"b");if(t==null||r==null||n==null)return null;let o=re(e,"a");return o==null?{r:t,g:r,b:n}:{r:t,g:r,b:n,a:o}}function Tb(e){let t=Kt(e);return t?t.includes("PBR")?"pbr":t.includes("Standard")?"standard":t:null}function Aa(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var xb=["albedoTexture","diffuseTexture","emissiveTexture","ambientTexture","opacityTexture","bumpTexture","normalTexture","metallicTexture","reflectionTexture","refractionTexture","lightmapTexture","specularTexture","roughnessTexture"],Ab=["albedoColor","diffuseColor","emissiveColor","ambientColor","specularColor","reflectivityColor"],Db=["metallic","roughness","microSurface","specularPower","baseWeight","indexOfRefraction"],Mb=["directIntensity","emissiveIntensity","environmentIntensity","specularIntensity","cameraExposure","cameraContrast"];var kb=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}],wb={zh:{hemisphericTitle:"\u73AF\u5883\u5149",directionalTitle:"\u76F4\u5C04\u5149",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"\u8BED\u8A00",type:"\u7C7B\u578B",typeHemispheric:"\u73AF\u5883\u5149",typeDirectional:"\u76F4\u5C04\u5149",intensity:"\u5F3A\u5EA6",skyLightColor:"\u5929\u7A7A\u5149\u989C\u8272",groundColor:"\u5730\u9762\u989C\u8272",lightColor:"\u5149\u7167\u989C\u8272",horizontalAngle:"\u6C34\u5E73\u89D2",elevationAngle:"\u9AD8\u5EA6\u89D2",shadowsTitle:"\u9634\u5F71",shadowsSummary:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",shadowSystem:"\u7CFB\u7EDF",shadowEnabled:"\u542F\u7528",shadowOpacity:"\u4E0D\u900F\u660E\u5EA6",shadowLength:"\u9634\u5F71\u957F\u5EA6",shadowFollowDirectional:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",openShadows:"\u6253\u5F00\u9634\u5F71\u8BBE\u7F6E",rawLight:"\u539F\u59CB\u5149\u6E90\u6570\u636E",tooltips:{language:"\u5207\u6362\u6B64\u5149\u6E90\u68C0\u67E5\u5668\u7684\u5C5E\u6027\u663E\u793A\u8BED\u8A00\u3002\u8BE5\u5B57\u6BB5\u53EA\u7528\u4E8E\u7F16\u8F91\u5668\uFF0C\u4E0D\u4F1A\u5BFC\u51FA\u5230\u8FD0\u884C\u65F6\u3002",type:"\u7CFB\u7EDF\u5149\u6E90\u7C7B\u578B\u53EA\u8BFB\u3002\u5BF9\u5E94 BabylonJS \u7684 HemisphericLight \u6216 DirectionalLight\u3002",intensity:"\u5149\u6E90\u5F3A\u5EA6\uFF0C\u5FC5\u987B\u662F\u975E\u8D1F\u6570\u3002BabylonJS \u4E0D\u8BBE\u7F6E\u786C\u4E0A\u9650\uFF1B\u767D\u8272\u6750\u8D28\u5728\u8F83\u9AD8\u5F3A\u5EA6\u4E0B\u901A\u5E38\u5DF2\u7ECF\u63A5\u8FD1\u663E\u793A\u9971\u548C\uFF0C\u7EE7\u7EED\u589E\u5927\u89C6\u89C9\u53D8\u5316\u4F1A\u4E0D\u660E\u663E\u3002",skyLightColor:"\u73AF\u5883\u5149\u6765\u81EA\u5929\u7A7A\u65B9\u5411\u7684\u6F2B\u53CD\u5C04\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.diffuse\u3002",groundColor:"\u73AF\u5883\u5149\u6765\u81EA\u5730\u9762\u53CD\u5C04\u65B9\u5411\u7684\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.groundColor\u3002",lightColor:"\u76F4\u5C04\u5149\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS DirectionalLight.diffuse\u3002",horizontalAngle:"\u76F4\u5C04\u5149\u5728 XZ \u5E73\u9762\u5185\u7684\u671D\u5411\u89D2\u5EA6\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",elevationAngle:"\u76F4\u5C04\u5149\u76F8\u5BF9\u5730\u5E73\u7EBF\u7684\u9AD8\u5EA6\u89D2\uFF1B90 \u5EA6\u8868\u793A\u4ECE\u6B63\u4E0A\u65B9\u7167\u4E0B\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",shadowSystem:"\u9634\u5F71\u7CFB\u7EDF\u53EA\u8BFB\u6458\u8981\u3002Planar \u9634\u5F71\u65B9\u5411\u6765\u81EA\u5F53\u524D\u76F4\u5C04\u5149\uFF0C\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowEnabled:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u662F\u5426\u542F\u7528\u3002\u8FD9\u91CC\u4EC5\u663E\u793A\u6458\u8981\uFF0C\u4E0D\u5728\u5149\u6E90 Inspector \u4E2D\u7F16\u8F91\u3002",shadowOpacity:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u4E0D\u900F\u660E\u5EA6\u3002\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowLength:"\u6839\u636E\u76F4\u5C04\u5149\u65B9\u5411\u4F30\u7B97\u7684\u5E73\u9762\u9634\u5F71\u957F\u5EA6\u500D\u7387\uFF1B\u9AD8\u5EA6\u89D2\u8D8A\u4F4E\uFF0C\u9634\u5F71\u8D8A\u957F\u3002",openShadows:"\u5207\u6362\u5230\u53F3\u4FA7 Rendering \u9762\u677F\uFF0C\u7F16\u8F91\u9879\u76EE\u7EA7\u9634\u5F71\u8BBE\u7F6E\u3002",rawLight:"\u7F16\u8F91\u5668\u6587\u6863\u4E2D\u7684\u5149\u6E90\u539F\u59CB\u6570\u636E\uFF0C\u53EA\u8BFB\u663E\u793A\u3002"}},en:{hemisphericTitle:"Environment Light",directionalTitle:"Directional Light",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"Language",type:"Type",typeHemispheric:"Environment Light",typeDirectional:"Directional Light",intensity:"Intensity",skyLightColor:"Sky Light Color",groundColor:"Ground Color",lightColor:"Light Color",horizontalAngle:"Horizontal Angle",elevationAngle:"Elevation Angle",shadowsTitle:"Shadows",shadowsSummary:"Planar Main / Follow Directional Light",shadowSystem:"System",shadowEnabled:"Enabled",shadowOpacity:"Opacity",shadowLength:"Shadow Length",shadowFollowDirectional:"Planar Main / Follow Directional Light",openShadows:"Open Shadows",rawLight:"Raw Light Data",tooltips:{language:"Switches the display language for this light inspector. This editor-only field is not exported to runtime.",type:"Read-only system light type. Maps to BabylonJS HemisphericLight or DirectionalLight.",intensity:"Light intensity. Must be a non-negative number. BabylonJS does not impose a hard upper limit; white surfaces often saturate at high intensity, so further increases may look subtle.",skyLightColor:"Diffuse sky color for the environment light. Maps to BabylonJS HemisphericLight.diffuse.",groundColor:"Ground bounce color for the environment light. Maps to BabylonJS HemisphericLight.groundColor.",lightColor:"Directional light color. Maps to BabylonJS DirectionalLight.diffuse.",horizontalAngle:"Directional light heading in the XZ plane. The editor converts it to BabylonJS DirectionalLight.direction.",elevationAngle:"Directional light elevation above the horizon; 90 degrees points straight down. The editor converts it to BabylonJS DirectionalLight.direction.",shadowSystem:"Read-only shadow system summary. Planar shadow direction follows this Directional Light; edit full settings in Rendering.",shadowEnabled:"Whether the project-level planar shadow system is enabled. This is summary-only in the light Inspector.",shadowOpacity:"Current project-level planar shadow opacity. Edit full settings in Rendering.",shadowLength:"Estimated planar shadow length multiplier from this light direction. Lower elevation makes longer shadows.",openShadows:"Switches the right dock to the Rendering panel for project-level shadow settings.",rawLight:"Read-only raw light data from the editor document."}}};function Ll(e){return wb[e]??wb.zh}function zl(e){return e.inspectorLanguage==="en"?"en":"zh"}function Ob(e){let{createDocumentInspectorProperty:t,gameObject:r,light:n,nodeKind:o,normalizeValue:a}=e,i=zl(n),s=Ll(i),c=[t(null,o,{path:"light.inspectorLanguage",label:s.language,valueType:"enum",control:"enum",value:i,commitMode:"immediate",order:0,options:kb,controlOptions:{variant:"segmented"},tooltip:s.tooltips.language}),j({path:"light.type",label:s.type,value:n.type==="hemispheric"?s.typeHemispheric:s.typeDirectional,order:1,source:"Document",tooltip:s.tooltips.type}),t(null,o,{path:"light.intensity",label:s.intensity,valueType:"number",control:"number",value:n.intensity,commitMode:"live",order:2,min:0,step:.05,tooltip:s.tooltips.intensity})],d=3;if(n.type==="hemispheric")c.push(t(null,o,{path:"light.diffuseColor",label:s.skyLightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.skyLightColor})),d+=1,c.push(t(null,o,{path:"light.groundColor",label:s.groundColor,valueType:"color",control:"color",value:n.groundColor??e.defaultEnvironmentGroundColor??{r:.48,g:.52,b:.62},commitMode:"immediate",order:d,tooltip:s.tooltips.groundColor})),d+=1;else{let l=El(r)??{horizontalAngleDeg:0,elevationAngleDeg:90};c.push(t(null,o,{path:fn,label:s.horizontalAngle,valueType:"number",control:"number",value:l.horizontalAngleDeg,commitMode:"live",order:d,min:bg,max:Sg,step:1,coerce:m=>a(fn,m),tooltip:s.tooltips.horizontalAngle})),d+=1,c.push(t(null,o,{path:pn,label:s.elevationAngle,valueType:"number",control:"number",value:l.elevationAngleDeg,commitMode:"live",order:d,min:Sa,max:ya,step:1,coerce:m=>a(pn,m),tooltip:s.tooltips.elevationAngle})),d+=1,c.push(t(null,o,{path:"light.diffuseColor",label:s.lightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.lightColor})),d+=1}return sM(c,{path:"light.raw",label:s.rawLight,value:n??"defaults",order:c.length,source:"Document",tags:["Raw"],tooltip:s.tooltips.rawLight}),c}function Rb(e){let t=e.renderingProfile.shadows.planar;return Cr({id:"lightShadows",title:e.text.shadowsTitle,order:46,summary:e.text.shadowsSummary,collapsedByDefault:!1,tags:["Rendering","Derived"],properties:[j({path:"rendering.shadows.summary.system",label:e.text.shadowSystem,value:e.text.shadowFollowDirectional,order:0,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowSystem,effect:"derived"}),j({path:"rendering.shadows.summary.enabled",label:e.text.shadowEnabled,value:t.enabled,order:1,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowEnabled,effect:"derived"}),j({path:"rendering.shadows.summary.opacity",label:e.text.shadowOpacity,value:at(t.appearance.color.a),order:2,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowOpacity,effect:"derived"}),j({path:"rendering.shadows.summary.length",label:e.text.shadowLength,value:dM(hg(e.light.direction)),order:3,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowLength,effect:"derived"}),cM(e.text)]})}function Bl(e){let t=Ll(zl(e.light)),r=[{id:"light",title:e.light.type==="hemispheric"?t.hemisphericTitle:t.directionalTitle,order:44,placement:"body",summary:e.light.type==="hemispheric"?t.hemisphericSummary:t.directionalSummary,persistence:"document",collapsedByDefault:!1,properties:Ob(e)}];return e.light.type==="directional"&&r.push(Rb({light:e.light,text:t,renderingProfile:iM(e.renderingProfile)})),r}function iM(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function sM(e,t){let r=j(t);r&&e.push(r)}function cM(e){return{path:"rendering.shadows.summary.open",label:e.openShadows,valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:e.openShadows,icon:"world"},value:e.openShadows,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:4,tags:["Rendering"],tooltip:e.tooltips.openShadows,effect:"active"}}function dM(e){return`x${at(e)}`}function Oe(e,t,r){let n=t.split(".").filter(Boolean);if(n.some(lM))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function lM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function Vl(e){let t=Nr(e.overrides);if(!t)return;let r=Cb(t.material);r?t.material=r:delete t.material;let n=Nr(t.materialSlotBindings);if(n){for(let[i,s]of Object.entries(n)){let c=Nr(s);if(!c){delete n[i];continue}let d=Cb(c.override);d?c.override=d:delete c.override,Object.keys(c).length===0&&delete n[i]}Object.keys(n).length===0&&delete t.materialSlotBindings}let o=Nr(t.childTransforms);o&&Object.keys(o).length===0&&delete t.childTransforms;let a=Nr(t.childOutlines);a&&Object.keys(a).length===0&&delete t.childOutlines,Object.keys(t).length===0&&delete e.overrides}function Cb(e){let t=Nr(e);if(!t)return;let r=structuredClone(t);for(let n of["albedoTexture","normalTexture","metallicTexture"]){let o=Nr(r[n]);o&&Object.keys(o).length===0&&delete r[n]}for(let n of["pbr","standard"]){let o=Nr(r[n]);o&&Object.keys(o).length===0&&delete r[n]}return Object.keys(r).length>0?r:void 0}function Nr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function hn(e,t,r){let n=e.scene.gameObjects.find(a=>a.id===t);if(!n)return e;let o=Gb(n,r);return JSON.stringify(o)===JSON.stringify(n)?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>a.id===t?o:a)}}}function Ul(e,t){if(t.length===0)return e;let r=new Map;for(let a of t)r.set(a.targetId,a.patch);let n=!1,o=e.scene.gameObjects.map(a=>{let i=r.get(a.id);if(!i)return a;let s=Gb(a,i);return JSON.stringify(s)===JSON.stringify(a)?a:(n=!0,s)});return n?{...e,scene:{...e.scene,gameObjects:o}}:e}function Gb(e,t){let r=vb(e),n=uM(e,t),o=vb(n);return r&&o&&!mM(r,o)?lo(n):n}function uM(e,t){return G(e)?{...e,components:e.components.map(r=>{if(r.type!=="Transform")return r;let n=r;return t.transform?mr(t.transform)??n:Ee(n)?n:{...n,position:t.position??n.position,rotation:t.rotation??n.rotation,scale:t.scale??n.scale}})}:e}function vb(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function mM(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function jb(e){let t=new Set(e.targetIds);if(t.size===0||!Number.isFinite(e.fromAlphaIndex)||!Number.isFinite(e.toAlphaIndex)||e.fromAlphaIndex===e.toAlphaIndex)return e.gameObjects;let r=!1,n=e.gameObjects.map(o=>!t.has(o.id)||!fM(o,e)?o:(r=!0,{...o,rendering:{...o.rendering??{},alphaIndex:e.toAlphaIndex}}));return r?n:e.gameObjects}function Kl(e){let t=jb({gameObjects:e.document.scene.gameObjects,targetIds:e.targetIds,renderingGroupId:e.renderingGroupId,fromAlphaIndex:e.fromAlphaIndex,toAlphaIndex:e.toAlphaIndex});return t===e.document.scene.gameObjects?e.document:{...e.document,scene:{...e.document.scene,gameObjects:t}}}function fM(e,t){return(ll(e.rendering?.renderingGroupId)??0)===t.renderingGroupId&&ig(e.rendering?.alphaIndex)===t.fromAlphaIndex}var So=it,yo=As;function Hl(e){let t=st(e.document.scene.gameObjects.map(n=>n.name??n.id),e.name??e.asset.displayName,{fallbackName:e.asset.assetId}),r=So(e.document.scene.gameObjects.map(n=>n.id),yo(t));return{label:`Place ${e.asset.displayName}`,patch:{kind:"game-object.create-from-asset",assetItem:e.asset,...e.name?{name:e.name}:{},placement:{position:{...e.hit.position},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}},createdId:r,changedIds:[r]}}function Nb(e){let t=e.scene.gameObjects.filter(r=>!!ue(r)||!!kr(r)||!!r.primitive).length;return{x:t%5*1.8-3.6,y:0,z:Math.floor(t/5)*1.8+1.8}}function Wl(e,t){let r=t&&It(t)?t:null;return{position:r?.position?{...r.position}:Nb(e),rotation:r?.rotation?{...r.rotation}:{x:0,y:0,z:0},scale:r?.scale?{...r.scale}:{x:1,y:1,z:1}}}function Gs(e){return e.filter(t=>hM(t.kind)&&Jl(t)).map(ql).sort(Xl)}function Ma(e){return e.filter(t=>t.kind==="model"||t.kind==="texture").map(ql).sort(Xl)}function ql(e){let t=e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"glb",r=En(e.guid),n=gM(e);return{id:e.assetId,...r?{guid:r}:{},assetId:e.assetId,type:t,kind:e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"model",displayName:e.displayName,category:e.category??pM(e),warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:vs(e.defaults),prefab:vs(e.prefab),external:vs(e.external),metadata:n,origin:e.origin??"project",dedupeKey:e.dedupeKey??r??yM(e.external)??e.assetId,placeable:Jl(e)}}function _b(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.kind==="texture"||t.type==="texture"}function Jl(e){return _b(e)?!0:!e||typeof e!="object"||Array.isArray(e)||e.placeable!==!1}function Xl(e,t){return(e.category??"").localeCompare(t.category??"")||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)||e.type.localeCompare(t.type)}function pM(e){return e.kind==="prefab"?"Prefab":e.kind==="texture"?"Texture":e.kind==="image"?"Image":e.kind==="sound"?"Sound":"Model"}function gM(e){return bM({originalFileName:e.originalFileName,relativePath:e.relativePath,codeKey:e.codeKey,contentHash:e.contentHash,byteSize:e.byteSize,...vs(e.metadata)})}function bM(e){if(!Array.isArray(e.materialSlots))return e;let t=Cs(e.assetAnalysis),r=Array.isArray(t?.meshes)?t.meshes:[],n=Array.isArray(t?.nodes)?t.nodes:[],o=new Map(r.flatMap(c=>{let d=Cs(c),u=Da(d?.meshIndex),l=En(d?.name);return u==null||!l?[]:[[u,l]]})),a=new Map(n.flatMap(c=>{let d=Cs(c),u=Da(d?.nodeIndex),l=En(d?.meshName);return u==null||!l?[]:[[u,l]]})),i=Fb(t,"meshCount",r.length)||Fb(t,"nodeCount",n.length),s=e.materialSlots.map(c=>{let d=Cs(c);if(!d||En(d.sourceMeshName))return c;let u=Da(d.meshIndex);if(u==null)return c;let l=Da(d.nodeIndex),m=o.get(u)??(l==null?void 0:a.get(l))??(i?SM(d):void 0);return m?{...d,sourceMeshName:m}:c});return{...e,materialSlots:s}}function SM(e){let t=En(e.label);if(t){let r=t.replace(/\s+\/\s+Primitive\s+\d+$/,"").trim();if(r)return r}return En(e.ownerNodePath)?.split("/").filter(Boolean).pop()}function Fb(e,t,r){let n=Da(e?.[t]);return n!=null&&n>r}function yM(e){return!e||typeof e!="object"||Array.isArray(e)?null:En(e.platformAssetId)}function En(e){return typeof e=="string"&&e.trim()?e.trim():null}function Da(e){return Number.isInteger(e)&&e>=0?e:null}function Cs(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function vs(e){return e==null?void 0:structuredClone(e)}function hM(e){return e==="model"||e==="prefab"||e==="texture"}function Yl(e,t){let r=new Map(t.filter(a=>a.type==="glb").map(a=>[a.assetId,a])),n=e.assets.map(a=>{if(a.type!=="glb")return a;let i=r.get(a.id);return i?Fr(a,i):a}),o=new Set(e.assets.map(a=>a.id));for(let a of EM(e)){if(o.has(a))continue;let i=r.get(a);i&&(n.push(Fr({id:a,type:"glb"},i)),o.add(a))}return{...e,assets:n}}function EM(e){let t=[],r=new Set,n=o=>{let a=Ve(o);!a||r.has(a)||(r.add(a),t.push(a))};for(let o of e.assets)if(o.type==="prefab"){n(o.prefab?.sourceAssetId);for(let a of o.prefab?.nodes??[])n(a.sourceAssetId)}for(let o of e.scene.gameObjects){for(let i of o.components)i.type==="ModelRenderer"&&n(i.assetId);n(o.prefab?.sourceAssetId);let a=ct(ct(o)?.instance);n(a?.assetId)}return t}function Zl(e,t){wa(e,t);let r=new Map(t.filter(n=>n.type==="glb").map(n=>[n.assetId,n]));return{...e,assets:e.assets.map(n=>{if(n.type!=="glb")return structuredClone(n);let o=r.get(n.id);if(!o)throw new Error(`asset.catalog.missing: ${n.id}`);let a=o.guid??n.guid;return{id:n.id,...a?{guid:a}:{},type:"glb"}})}}function wa(e,t){let r=new Map(t.map(o=>[o.assetId,o])),n=new Map(t.filter(o=>o.type==="glb").map(o=>[o.assetId,o]));for(let o of e.assets){if(o.type!=="glb")continue;let a=n.get(o.id);if(!a)throw new Error(`asset.catalog.missing: ${o.id}`);TM(o,a),PM(o,a),IM(a)}for(let o of $b(e)){if(o.kind!=="material.textureAssetId")continue;let a=r.get(o.assetId);if(!a||a.kind!=="texture"&&a.type!=="texture")throw new Error(`asset.catalog.missing: ${o.assetId} at ${o.path}`)}}function $b(e){let t=[],r=(o,a)=>{let i=Ve(a);i&&t.push({assetId:i,...o})};for(let o=0;o<e.scene.gameObjects.length;o+=1){let a=e.scene.gameObjects[o];for(let i=0;i<a.components.length;i+=1){let s=a.components[i];s.type!=="ModelRenderer"&&s.type!=="ImageRenderer"||r({scope:"scene-object",kind:`${s.type}.assetId`,path:`scene.gameObjects[${o}].components[${i}].assetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},s.assetId)}r({scope:"scene-object",kind:"prefab.prefabId",path:`scene.gameObjects[${o}].prefab.prefabId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.prefabId),r({scope:"scene-object",kind:"prefab.sourceAssetId",path:`scene.gameObjects[${o}].prefab.sourceAssetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.sourceAssetId),ho(a.overrides,`scene.gameObjects[${o}].overrides`,(i,s)=>r({scope:"scene-object",kind:"material.textureAssetId",path:i,objectId:a.id,...a.name?{objectName:a.name}:{}},s))}for(let o=0;o<e.assets.length;o+=1){let a=e.assets[o];if(!a.prefab)continue;let i=`assets[${o}].prefab`;r({scope:"prefab-asset",kind:"prefab.sourceAssetId",path:`${i}.sourceAssetId`,prefabAssetId:a.id},a.prefab.sourceAssetId),ho(a.prefab.overrides,`${i}.overrides`,(c,d)=>r({scope:"prefab-asset",kind:"material.textureAssetId",path:c,prefabAssetId:a.id},d));let s=Ze(a);for(let c=0;c<s.length;c+=1){let d=s[c],u=`${i}.nodes[${c}]`;r({scope:"prefab-node",kind:"node.sourceAssetId",path:`${u}.sourceAssetId`,prefabAssetId:a.id,nodeId:d.id},d.sourceAssetId),r({scope:"prefab-node",kind:"node.childPrefabId",path:`${u}.childPrefabId`,prefabAssetId:a.id,nodeId:d.id},d.childPrefabId),ho(d.overrides,`${u}.overrides`,(l,m)=>r({scope:"prefab-node",kind:"material.textureAssetId",path:l,prefabAssetId:a.id,nodeId:d.id},m))}}let n=Array.isArray(e.scene.materialAssets)?e.scene.materialAssets:[];for(let o=0;o<n.length;o+=1){let a=n[o],i=Ve(a.id)??"";r({scope:"material-asset",kind:"origin.sourceAssetId",path:`scene.materialAssets[${o}].origin.sourceAssetId`,materialAssetId:i},ct(a.origin)?.sourceAssetId),ho(a.properties,`scene.materialAssets[${o}].properties`,(s,c)=>r({scope:"material-asset",kind:"material.textureAssetId",path:s,materialAssetId:i},c))}return t.sort((o,a)=>o.path.localeCompare(a.path))}function IM(e){let t=ct(e.metadata),r=ct(e.external);if(!(Ve(t?.url)??Ve(t?.relativePath)??Ve(r?.assetUrl)))throw new Error(`asset.catalog.incomplete: ${e.assetId}.url`);let o=ct(t?.assetAnalysis),a=t?.assetAnalysisStatus==="unavailable";if(!o&&!a)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.assetAnalysisStatus`);let i=new Map((Array.isArray(o?.meshes)?o.meshes:[]).flatMap(c=>{let d=ct(c),u=d?.meshIndex,l=Number.isInteger(u)?u:void 0,m=Ve(d?.name);return l==null||!m?[]:[[l,m]]})),s=Array.isArray(t?.materialSlots)?t.materialSlots:[];for(let[c,d]of s.entries()){let u=ct(d);if(!u)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}]`);let l=Number.isInteger(u.meshIndex)?u.meshIndex:void 0;if(l!=null&&!Ve(u.sourceMeshName)&&!i.has(l))throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}].sourceMeshName`)}}function PM(e,t){let r=ct(e.metadata),n=ct(t.metadata),o=ct(e.external),a=ct(t.external),i=Ve(r?.url)??Ve(r?.relativePath)??Ve(o?.assetUrl),s=Ve(n?.url)??Ve(n?.relativePath)??Ve(a?.assetUrl);if(i&&!s)throw new Error(`asset.catalog.incomplete: ${e.id}.url`);for(let c of["materialSlots","assetAnalysis"])if(r?.[c]!==void 0&&n?.[c]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.metadata.${c}`)}function TM(e,t){for(let r of["materialMode","defaults","external","warmupCount","singleton"])if(e[r]!==void 0&&t[r]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.${r}`)}function Fr(e,t){return{...e,guid:t.guid??e.guid,displayName:t.displayName||e.displayName,category:t.category??e.category,warmupCount:t.warmupCount??e.warmupCount,singleton:t.singleton??e.singleton,materialMode:t.materialMode??e.materialMode,defaults:js(t.defaults??e.defaults),prefab:js(t.prefab??e.prefab),external:js(t.external??e.external),metadata:js(t.metadata??e.metadata)}}function js(e){return e==null?void 0:structuredClone(e)}function ho(e,t,r){if(!(!e||typeof e!="object")){if(Array.isArray(e)){e.forEach((n,o)=>ho(n,`${t}[${o}]`,r));return}for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;n==="textureAssetId"?r(a,o):ho(o,a,r)}}}function ct(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ve(e){return(typeof e=="string"?e.trim():"")||void 0}function ka(e,t=[]){return e?.system?.readonly===!0||e?.system?.preset==="default-pbr"||e?.system?.preset==="default-standard"||!!e&&t.includes(e.id)}function xM(e){let t=structuredClone(e??{});return In(t.baseColor,"texture"),t.baseColor&&Object.keys(t.baseColor).length===0&&delete t.baseColor,In(t.normal,"texture"),t.normal&&Object.keys(t.normal).length===0&&delete t.normal,In(t.metallicRoughness,"texture"),t.metallicRoughness&&Object.keys(t.metallicRoughness).length===0&&delete t.metallicRoughness,In(t.occlusion,"texture"),t.occlusion&&Object.keys(t.occlusion).length===0&&delete t.occlusion,t.emission&&(In(t.emission,"texture"),In(t.emission,"maskTexture"),Object.keys(t.emission).length===0&&delete t.emission),In(t.alpha,"texture"),t.alpha&&Object.keys(t.alpha).length===0&&delete t.alpha,t}function In(e,t){if(!e)return;let r=e,n=r[t];if(n===null||!n||typeof n!="object"||Array.isArray(n))return;let o=n,a=typeof o.url=="string"?o.url.trim():"",i=typeof o.textureAssetId=="string"?o.textureAssetId.trim():"";a?o.url=a:delete o.url,i?o.textureAssetId=i:delete o.textureAssetId,Object.keys(o).length===0&&delete r[t]}function Lb(e,t,r,n,o){if(e.system?.readonly===!0)return e;let a=o?.textureMode==="inherit",i=rt(t,r);if(a?!ro(e.shaderId,t)||!zt(t,null,e.shaderId,n):!zt(t,i,e.shaderId,n))return e;let s=structuredClone(e);if(t==="name")return typeof i!="string"?e:(s.name=i.trim(),s.name===e.name?e:s);if(!t.startsWith("properties."))return e;let c=t.slice(11);return!c||(s.properties=structuredClone(s.properties),AM(s.properties,c,i,a)||Oe(s.properties,c,i),De(s.shaderId)&&(s.properties=xM(s.properties)),Qn(s.shaderId,s.properties,"properties",n).length>0)||JSON.stringify(s)===JSON.stringify(e)?e:s}function AM(e,t,r,n){let o=t.endsWith(".textureAssetId")?"textureAssetId":t.endsWith(".url")?"url":null;if(!o)return!1;let a=t.slice(0,-`.${o}`.length);if(!a.endsWith(".texture")&&!a.endsWith(".maskTexture"))return!1;let i=a.split(".").filter(Boolean);if(i.length<2)return!1;let s=i[i.length-1],c=e;for(let l of i.slice(0,-1)){let m=c[l];if(!m||typeof m!="object"||Array.isArray(m)){if(n)return!0;let f={};c[l]=f,c=f;continue}c=m}if(n)return delete c[s],!0;if(r==null)return c[s]=null,!0;let d=c[s],u=d&&typeof d=="object"&&!Array.isArray(d)?{...d}:{};return u[o]=r,delete u[o==="url"?"textureAssetId":"url"],c[s]=u,!0}var Pn="mat_default_pbr",Eo="mat_default_standard",DM="00000000-0000-4000-8000-000000000001",MM="00000000-0000-4000-8000-000000000002",Tn=Pn,Oa={id:Pn,guid:DM,name:"Default PBR Material",shaderId:"fps.builtin.pbr",definitionVersion:1,system:{readonly:!0,preset:"default-pbr"},origin:{type:"preset"},properties:Rd("fps.builtin.pbr")},wM={id:Eo,guid:MM,name:"Default Standard Material",shaderId:"fps.builtin.standard",definitionVersion:1,system:{readonly:!0,preset:"default-standard"},origin:{type:"preset"},properties:Rd("fps.builtin.standard")};function kM(){return structuredClone(Oa)}function OM(){return structuredClone(wM)}function zb(e){let t=[kM(),OM()],r=new Set(t.map(o=>o.id)),n=[...t,...e.filter(o=>!r.has(o.id))];return JSON.stringify(n)===JSON.stringify(e)?e:n}function Bb(e){return e?.system?.preset==="default-pbr"||e?.id===Pn?"default-pbr":e?.system?.preset==="default-standard"||e?.id===Eo?"default-standard":null}function Ns(e){let t=structuredClone(Oa.properties);if(!e||typeof e!="object")return t;let r={...t,...structuredClone(e)};return r.baseColor={...t.baseColor??{},...e.baseColor??{}},(t.normal||e.normal)&&(r.normal={...t.normal??{},...e.normal??{}}),(t.metallicRoughness||e.metallicRoughness)&&(r.metallicRoughness={...t.metallicRoughness??{},...e.metallicRoughness??{}}),(t.occlusion||e.occlusion)&&(r.occlusion={...t.occlusion??{},...e.occlusion??{}}),r.emission={...t.emission??{},...e.emission??{}},(t.alpha||e.alpha)&&(r.alpha={...t.alpha??{},...e.alpha??{}}),r}function xn(e,t){let r=[...new Set(e.sourceSurfaces.map(s=>s.sourceMaterialIndex).filter(s=>Number.isInteger(s)))],n=e.materialNames??[],o=r.findIndex(s=>s===t),a=o>=0?n[o]??(r.length===1?e.materialName:null):null;if(typeof a=="string"&&a.trim())return a.trim();let i=Io(e,t)?.materialName;return typeof i=="string"&&i.trim()?i.trim():null}function Io(e,t){return e.sourceMaterialProfiles?.find(r=>r.sourceMaterialIndex===t)??null}var Ql=[Pn,Eo],RM="New Material";function Vb(e,t,r=`${t.displayName} Material`){let n=Fs(e);return{id:nn(n),guid:n,name:eu(e,r),shaderId:t.shaderId,definitionVersion:t.version,origin:{type:"created"},properties:structuredClone(t.defaultProperties)}}function CM(e,t,r){let n=t.name?.trim()||t.id,o=r.name?.trim()||r.id,a=Fs(e);return{id:nn(a),guid:a,name:`${n} - ${o}`,shaderId:r.shaderId,...r.definitionVersion!=null?{definitionVersion:r.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:r.id},properties:structuredClone(r.properties)}}function Ub(e,t,r){let n=t.name?.trim()||t.id,o=Fs(e);return{id:nn(o),guid:o,name:eu(e,r??`${n} Copy`),shaderId:t.shaderId,...t.definitionVersion!=null?{definitionVersion:t.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:t.id},properties:structuredClone(t.properties)}}function vM(e,t){let r=Fs(e);return{id:nn(r),guid:r,name:eu(e,t.name),shaderId:Oa.shaderId,definitionVersion:Oa.definitionVersion,origin:{type:"created",...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.sourceAssetGuid?{sourceAssetGuid:t.sourceAssetGuid}:{},sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,...t.sourceMaterialName?{sourceMaterialName:t.sourceMaterialName}:{}},properties:Ns(t.profile)}}function Kb(e,t,r){let n=t.trim(),o=e.scene.materialAssets?.findIndex(s=>s.id===n)??-1;if(o<0||r.id!==n)return e;let a=e.scene.materialAssets[o];if(JSON.stringify(a)===JSON.stringify(r))return e;let i=[...e.scene.materialAssets];return i[o]=structuredClone(r),{...e,scene:{...e.scene,materialAssets:i}}}function Fs(e){let t=new Set((e.scene.materialAssets??[]).map(o=>o.id)),r=Qd(),n=nn(r);for(;t.has(n);)r=Qd(),n=nn(r);return r}function eu(e,t){let r=rt("name",t),n=typeof r=="string"&&zt("name",r)?r:RM,o=new Set((e.scene.materialAssets??[]).map(s=>s.name?.trim()).filter(s=>!!s).map(s=>s.toLocaleLowerCase()));if(!o.has(n.toLocaleLowerCase()))return n;let a=2,i=`${n} ${a}`;for(;o.has(i.toLocaleLowerCase());)a+=1,i=`${n} ${a}`;return i}function Hb(e){let t=ee(e.document,e.sourceMaterialAssetId);if(!t||e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let r=CM(e.document,e.gameObject,t);return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function Wb(e){if(e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let t=`${e.gameObject.name?.trim()||e.gameObject.id} - ${e.sourceSlotId}`,r=vM(e.document,{profile:e.profile,name:e.sourceMaterialName?.trim()||t,...e.sourceAsset?.id?{sourceAssetId:e.sourceAsset.id}:{},...e.sourceAsset?.guid?{sourceAssetGuid:e.sourceAsset.guid}:{},sourceSlotId:e.sourceSlotId,sourceMaterialIndex:e.sourceMaterialIndex,...e.sourceMaterialName?.trim()?{sourceMaterialName:e.sourceMaterialName.trim()}:{}});return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function _s(e,t,r,n,o,a){let i=e.scene.materialAssets??[],s=!1,c=i.map(d=>{if(d.id!==t)return d;let u=Lb(d,r,rt(r,n),o,a);return s=s||u!==d,u});return s?{...e,scene:{...e.scene,materialAssets:c}}:e}function qb(e,t,r=[]){let n=ee(e,t),o=rl(e,t);return n?ka(n,r)?{ok:!1,reason:"readonly",materialAsset:n,usages:o}:o.length>0?{ok:!1,reason:"in-use",materialAsset:n,usages:o}:{ok:!0,materialAsset:n,usages:o}:{ok:!1,reason:"missing",usages:o}}function Jb(e,t){return qb(e,t,Ql)}function GM(e,t,r=[]){return qb(e,t,r).ok?{...e,scene:{...e.scene,materialAssets:(e.scene.materialAssets??[]).filter(o=>o.id!==t)}}:e}function tu(e){return ka(e,Ql)}function Xb(e,t){return GM(e,t,Ql)}function $s(e,t){return Vt(e,t.id)?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(t)]}}}function Yb(e,t,r,n){return Vt(e,n.id)?e:jM({...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(n)]}},t,r,n.id)}function jM(e,t,r,n){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(o=>{if(o.id!==t)return o;let a=structuredClone(o);return NM(a,r,n),a})}}}function NM(e,t,r){let n=FM(t)??t.split(".").filter(Boolean);if(n.some(_M))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function FM(e){let t=Lt(e,"materialAssetId");return t?["overrides","materialSlotBindings",t,"materialAssetId"]:null}function _M(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function zs(e,t){let r=ue(t),n=r?e.assets.find(g=>g.id===r.assetId):null,o=typeof n?.guid=="string"&&n.guid.trim()?n.guid.trim():n?.id,a=as(e,t),i=new Map(a.filter(g=>!!g.slotId).map(g=>[g.slotId,g])),s=t.overrides?.materialSlotBindings??{},c=$M({document:e,assetId:n?.id,assetGuid:o,currentSlots:a,materialSlotBindings:s}),d=c.remaps,u=new Map(d.map(g=>[g.toSlotId,g])),l=new Set([...d.map(g=>g.fromSlotId),...c.coalescedSourceSlotIds]),m=new Map;for(let[g,b]of Object.entries(s))!b||l.has(g)||m.set(g,b);for(let g of d){let b=s[g.fromSlotId];b&&m.set(g.toSlotId,b)}let f=[];for(let[g,b]of a.entries()){let y=b.slotId?m.get(b.slotId):void 0,E=Po(y),I=E?ee(e,E):null,P=Qb(b),A=P[0],$=b.slotId?u.get(b.slotId):void 0;if($){f.push({status:"changed",reason:"slot-remapped",...b.slotId?{slotId:b.slotId}:{},previousSlotId:$.fromSlotId,ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},materialAssetId:E,bindingPath:`overrides.materialSlotBindings.${b.slotId}.materialAssetId`,conflict:!1});continue}let z=eS(I,o,n?.id)?.sourceMaterialIndex;if(z!=null&&P.length>0&&!P.includes(z)){f.push(Zb({status:"changed",reason:"source-material-changed",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},previousSourceMaterialIndex:z,...E?{materialAssetId:E}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:""}));continue}if(!E&&P.length>0){f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1});continue}f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},...E?{materialAssetId:E}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1})}for(let[g,b]of Object.entries(s))!b||i.has(g)||l.has(g)||f.push(Zb({status:"removed",reason:"slot-removed",slotId:g,...Po(b)?{materialAssetId:Po(b)}:{},bindingPath:`overrides.materialSlotBindings.${g}.materialAssetId`}));let S=f.filter(zM);return{gameObjectId:t.id,...t.name?{gameObjectName:t.name}:{},...n?.id?{assetId:n.id}:{},...o?{assetGuid:o}:{},ok:S.length===0,items:f,issues:S,bindingRemaps:d,bindingRemapIssues:c.issues,counts:BM(f)}}function $M(e){let t=new Set(e.currentSlots.map(d=>d.slotId).filter(d=>!!d)),r=new Set(Object.keys(e.materialSlotBindings).filter(d=>t.has(d))),n=[],o=[],a=new Map;for(let[d,u]of Object.entries(e.materialSlotBindings)){if(!u||t.has(d))continue;let l=Po(u),m=l?ee(e.document,l):null,f=eS(m,e.assetGuid,e.assetId);if(!f){o.push({fromSlotId:d,materialAssetId:l,reason:"binding-unmatched",candidateSlotIds:[]});continue}let S=e.currentSlots.filter(g=>!!g.slotId&&Qb(g).includes(f.sourceMaterialIndex)).map(g=>g.slotId);a.set(d,{materialAssetId:l,candidateSlotIds:S,binding:u,anchored:f.sourceSlotId===d})}let i=new Map;for(let[d,u]of a){if(u.candidateSlotIds.length!==1)continue;let[l]=u.candidateSlotIds,m=i.get(l)??[];m.push(d),i.set(l,m)}let s=new Set,c=new Set;for(let[d,u]of i){u.forEach(g=>c.add(g));let l=u.filter(g=>a.get(g)?.anchored).sort((g,b)=>g.localeCompare(b));if(l.length===0){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-unmatched",candidateSlotIds:[]})}continue}let m=l[0],f=a.get(m);if(!u.every(g=>LM(f.binding,a.get(g).binding))||r.has(d)){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-ambiguous",candidateSlotIds:[d]})}continue}r.add(d),n.push({fromSlotId:m,toSlotId:d,materialAssetId:f.materialAssetId,reason:"source-material-index",...u.length>1?{coalescedFromSlotIds:u.filter(g=>g!==m).sort((g,b)=>g.localeCompare(b))}:{}});for(let g of u)g!==m&&s.add(g)}for(let[d,u]of a)c.has(d)||o.push({fromSlotId:d,materialAssetId:u.materialAssetId,reason:u.anchored&&u.candidateSlotIds.length>0?"binding-ambiguous":"binding-unmatched",candidateSlotIds:u.anchored?u.candidateSlotIds:[]});return{remaps:n,issues:o,coalescedSourceSlotIds:[...s].sort((d,u)=>d.localeCompare(u))}}function LM(e,t){return Po(e)===Po(t)&&ru(e.override,t.override)}function ru(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,s)=>ru(i,t[s]));if(!e||!t||typeof e!="object"||typeof t!="object")return!1;let r=e,n=t,o=Object.keys(r).sort(),a=Object.keys(n).sort();return o.length===a.length&&o.every((i,s)=>i===a[s]&&ru(r[i],n[i]))}function Qb(e){return nt(e)}function eS(e,t,r){if(e?.origin?.type!=="imported")return null;let n=e.origin.sourceMaterialIndex;if(typeof n!="number"||!Number.isInteger(n))return null;let o=e.origin.sourceAssetGuid,a=e.origin.sourceAssetId;if((o||a)&&!(!!t&&!!o&&o===t)&&!(!!r&&!!a&&a===r)||!o&&!a&&(t||r))return null;let c=typeof e.origin.sourceSlotId=="string"&&e.origin.sourceSlotId.trim()?e.origin.sourceSlotId.trim():void 0;return{sourceMaterialIndex:n,...c?{sourceSlotId:c}:{}}}function Ls(e,t){return e.label?.trim()||Ut(e)?.trim()||e.slotId?.trim()||`Slot ${t+1}`}function Po(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function Zb(e){return{...e,conflict:!0}}function zM(e){return e.conflict}function BM(e){return e.reduce((t,r)=>(t[r.status]+=1,t),{unchanged:0,added:0,removed:0,changed:0,conflict:0})}function Bs(e){let t=ns(e);if(t.ok)return;let r=new Error(`editor_scene_material_assets_missing: ${t.missingMaterialAssetIds.join(", ")}`);throw r.details={missingMaterialAssetIds:t.missingMaterialAssetIds,missingReferences:t.missingReferences.map(n=>({materialAssetId:n.materialAssetId,gameObjectId:n.gameObjectId,bindingPath:n.bindingPath,label:n.label,kind:n.kind,...n.slotId?{slotId:n.slotId}:{},...n.ownerNodePath?{ownerNodePath:n.ownerNodePath}:{}}))},r}function VM(e,t){let r=!1;return{gameObjects:t.map(o=>{let a=zs(e,o);if(a.bindingRemaps.length===0)return o;let i=o;for(let s of a.bindingRemaps){let c=i.overrides?.materialSlotBindings?.[s.fromSlotId];if(!(!c||i.overrides?.materialSlotBindings?.[s.toSlotId])){i=structuredClone(i),i.overrides=i.overrides??{},i.overrides.materialSlotBindings=i.overrides.materialSlotBindings??{},i.overrides.materialSlotBindings[s.toSlotId]=structuredClone(c),delete i.overrides.materialSlotBindings[s.fromSlotId];for(let d of s.coalescedFromSlotIds??[])delete i.overrides.materialSlotBindings[d];Object.keys(i.overrides.materialSlotBindings).length===0&&delete i.overrides.materialSlotBindings,r=!0}}return i}),changed:r}}function UM(e,t,r){let n=!1,o=new Map(t.filter(l=>l.origin?.type==="imported").map(l=>[l.id,l]));if(o.size===0)return{materialAssets:t,gameObjects:r,changed:!1};let a=new Map(e.assets.map(l=>[l.id,l])),i={...e,scene:{...e.scene,materialAssets:t,gameObjects:r}},s=r.map(l=>{let m=ue(l);if(!m)return l;let f=a.get(m.assetId);if(!f)return l;let S=lr(i,l,a),g=l;for(let b of S){let y=g.overrides?.materialSlotBindings?.[b.slotId],E=y?.materialAssetId?o.get(y.materialAssetId):null;if(!E||!KM(E,f))continue;let I=E.origin?.sourceMaterialIndex;if(!Number.isInteger(I)||!nt(b).includes(I))continue;g===l&&(g=structuredClone(l));let P=g.overrides?.materialSlotBindings;P&&(delete P[b.slotId],Object.keys(P).length===0&&delete g.overrides.materialSlotBindings,Object.keys(g.overrides??{}).length===0&&delete g.overrides,n=!0)}return g}),c={...i,scene:{...i.scene,gameObjects:s}},d=new Set(an(c).map(l=>l.materialAssetId)),u=t.filter(l=>l.origin?.type!=="imported"||d.has(l.id));return n=n||u.length!==t.length,{materialAssets:u,gameObjects:s,changed:n}}function tS(e,t,r){let n=VM({...e,scene:{...e.scene,materialAssets:t,gameObjects:r}},r),o=UM(e,t,n.gameObjects);return{materialAssets:o.materialAssets,gameObjects:o.gameObjects,changed:n.changed||o.changed}}function KM(e,t){let r=e.origin;return r?.type!=="imported"?!1:r.sourceAssetId===t.id||!!r.sourceAssetGuid&&!!t.guid&&r.sourceAssetGuid===t.guid}function rS(e,t){let r=new Set,n=e.properties,o=An(n)?n:{},a=An(t.defaultProperties)?t.defaultProperties:{},i=nS(t.propertiesSchema,o,a,"properties",r),s=new Set;oS(o,"properties",s);let c=[...s].filter(d=>!r.has(d)).sort();return{materialAsset:{...structuredClone(e),shaderId:t.shaderId,definitionVersion:t.version,properties:i},preservedPaths:[...r].sort(),resetPaths:c}}function nS(e,t,r,n,o){if(e.kind!=="object")return HM(e,t)?(o.add(n),structuredClone(t)):structuredClone(r);let a=An(t)?t:{},i=An(r)?r:{},s={};for(let[c,d]of Object.entries(e.properties)){let u=Object.prototype.hasOwnProperty.call(a,c),l=Object.prototype.hasOwnProperty.call(i,c);if(!u&&!l)continue;let m=nS(d,u?a[c]:void 0,l?i[c]:void 0,`${n}.${c}`,o);m!==void 0&&(s[c]=m)}return s}function HM(e,t){if(e.kind==="number")return typeof t=="number"&&Number.isFinite(t)&&(e.min==null||t>=e.min)&&(e.max==null||t<=e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"||t===null&&e.nullable===!0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return nu(t,e.channels===4?["r","g","b","a"]:["r","g","b"]);if(e.kind==="vec2")return nu(t,["x","y"]);if(e.kind==="vec3")return nu(t,["x","y","z"]);if(t===null)return!0;if(!An(t))return!1;let r=Object.keys(t);return r.every(n=>n==="url"||n==="textureAssetId")&&r.every(n=>typeof t[n]=="string"&&!!t[n].trim())}function oS(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;An(o)&&!WM(o)?oS(o,a,r):r.add(a)}}function WM(e){let t=Object.keys(e);return t.length===0?!0:t.every(r=>["r","g","b","a"].includes(r))||t.every(r=>["x","y","z"].includes(r))||t.every(r=>r==="url"||r==="textureAssetId")}function nu(e,t){return An(e)&&Object.keys(e).length===t.length&&t.every(r=>typeof e[r]=="number"&&Number.isFinite(e[r]))}function An(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function qM(e){return e?.system?.preset}function iS(e,t){let r=qM(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Vs(e,t){let r=t.trim();return r?e?.find(n=>n.url===r||n.id===r)??null:null}function aS(e,t){return{kind:"image",url:e.url,alt:e.label,fit:"contain",...t?{resourceStatusText:{loading:t.loadingTexture,failed:t.failedTexture}}:{}}}function sS(e){let t=e.currentTexture??Vs(e.textureAssets,e.currentValue),r=e.currentValue.trim(),n=!!r&&!t,o=!!t&&!t.disabled&&!!t.url.trim(),a=n?"missing":t?o?"ready":"failed":void 0,i=e.candidateValue??"url",s=(e.textureAssets??[]).filter(JM);return{pickerKind:"texture",pickerTitle:e.pickerText.texturePickerTitle,pickerTrigger:"preview",placeholder:e.pickerText.emptyTexture,currentLabel:n?e.pickerText.missingTexture:t?.label??(r||e.pickerText.emptyTexture),currentMeta:n?`${e.pickerText.missingTextureMeta} \xB7 ${r}`:t?.previewUnavailableReason??t?.meta??(r||e.pickerText.emptyTextureMeta),...a?{currentResourceState:a}:{},...r?{currentResourceReference:r}:{},resourceStatusText:{missing:e.pickerText.missingTexture,loading:e.pickerText.loadingTexture,failed:e.pickerText.failedTexture},currentPreview:o?aS(t,e.pickerText):void 0,candidates:[{label:e.pickerText.clearTexture,value:"",meta:e.pickerText.clearTextureMeta},...s.map(c=>({label:c.label,value:i==="assetId"?c.id:c.url,meta:c.meta??c.id,kind:"texture",...typeof c.width=="number"?{width:c.width}:{},...typeof c.height=="number"?{height:c.height}:{},...!c.disabled&&c.url.trim()?{preview:aS(c,e.pickerText)}:{},...c.disabled?{disabled:!0,disabledReason:c.disabledReason}:{}}))]}}function JM(e){return e.capabilities?.materialTexture===!0?!0:e.capabilities?.materialTexture===!1?!1:e.usage!=="environment"}function cS(e){return{path:`${e.pathPrefix??dr}${e.materialAsset.id}.${e.fieldPath}`,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.commitMode,order:e.order,tooltip:e.tooltip,tags:e.tags??["ArtistMaterial","MaterialAsset"],document:e.document}}var dS={zh:{title:"\u7F8E\u672F\u6750\u8D28",slotTitle:"\u6750\u8D28\u63D2\u69FD",language:"\u8BED\u8A00",materialAsset:"\u6750\u8D28\u8D44\u4EA7",materialCard:"\u5F53\u524D\u6750\u8D28",inheritNone:"\u7EE7\u627F / \u65E0",defaultMaterial:"\u9ED8\u8BA4 PBR \u6750\u8D28",defaultMaterialMeta:"BabylonJS \u9ED8\u8BA4 PBR \u6750\u8D28",defaultStandardMaterial:"\u9ED8\u8BA4 Standard \u6750\u8D28",defaultStandardMaterialMeta:"BabylonJS \u9ED8\u8BA4 Standard \u6750\u8D28",defaultMaterialReadOnly:"\u7CFB\u7EDF\u9ED8\u8BA4\u6750\u8D28\u4E3A\u53EA\u8BFB\uFF1B\u8BF7\u9009\u62E9\u53EF\u7F16\u8F91\u6750\u8D28\u7403\u540E\u8C03\u6574\u53C2\u6570\u3002",replace:"\u66FF\u6362",batchReplaceUnsupported:"\u591A\u9009\u7EDF\u4E00\u66FF\u6362\u6750\u8D28\u6682\u672A\u63A5\u5165\uFF1B\u8BF7\u5148\u5355\u9009\u5BF9\u8C61\u66FF\u6362\u6750\u8D28\u3002",duplicateForObject:"\u590D\u5236",materialPickerTitle:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7",texturePickerTitle:"\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",emptyTexture:"\u9009\u62E9\u8D34\u56FE",emptyTextureMeta:"\u70B9\u51FB\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",inheritTexture:"\u7EE7\u627F\u6E90\u8D34\u56FE",inheritTextureMeta:"\u4F7F\u7528 GLB / source material \u8D34\u56FE\uFF08\u82E5\u5B58\u5728\uFF09",clearTexture:"\u6E05\u9664\u8D34\u56FE",clearTextureMeta:"\u4E0D\u4F7F\u7528\u8D34\u56FE",missingTexture:"\u8D34\u56FE\u8D44\u4EA7\u7F3A\u5931",missingTextureMeta:"\u5F53\u524D\u5F15\u7528\u65E0\u6CD5\u5728\u9879\u76EE\u8D44\u4EA7\u5E93\u4E2D\u89E3\u6790",loadingTexture:"\u6B63\u5728\u52A0\u8F7D\u8D34\u56FE",failedTexture:"\u8D34\u56FE\u52A0\u8F7D\u5931\u8D25",assetProfile:"\u8D44\u4EA7\u53C2\u6570",assetProfileEmpty:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u540E\u53EF\u7F16\u8F91\u8D44\u4EA7\u53C2\u6570",assetName:"\u8D44\u4EA7\u540D\u79F0",assetKind:"Shader",assetKindPbr:"PBR \u6807\u51C6\u6750\u8D28\u7403",assetKindStandard:"Standard \u6807\u51C6\u6750\u8D28\u7403",assetLightingModel:"\u5149\u7167\u6A21\u578B",assetLightingModelLit:"\u53D7\u5149\u7167",assetLightingModelUnlit:"\u4E0D\u53D7\u5149\u7167",assetBaseColor:"\u57FA\u7840\u8272",assetBaseTexture:"\u57FA\u7840\u8D34\u56FE",assetBrightness:"\u8D34\u56FE\u4EAE\u5EA6",assetSaturation:"\u8D34\u56FE\u9971\u548C\u5EA6",assetContrast:"\u8D34\u56FE\u5BF9\u6BD4\u5EA6",assetHue:"\u8D34\u56FE\u8272\u76F8",assetNormalTexture:"\u6CD5\u7EBF\u8D34\u56FE",assetNormalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6",assetMetallic:"\u91D1\u5C5E\u5EA6",assetRoughness:"\u7C97\u7CD9\u5EA6",assetMetallicRoughnessTexture:"\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE",assetOcclusionTexture:"AO \u8D34\u56FE",assetOcclusionStrength:"AO \u5F3A\u5EA6",resetValue:"\u6062\u590D Shader \u9ED8\u8BA4\u503C",modifiedValue:"\u5DF2\u504F\u79BB Shader \u9ED8\u8BA4\u503C",inactiveReasons:{baseTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u57FA\u7840\u8D34\u56FE\u65F6\u751F\u6548\u3002",litMaterial:"\u4EC5\u5728\u201C\u53D7\u5149\u7167\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",normalTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\u65F6\u751F\u6548\u3002",occlusionTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9 AO \u8D34\u56FE\u65F6\u751F\u6548\u3002",alphaBlend:"\u4EC5\u5728\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaMask:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaTransparency:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6216\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002"},assetEmissionColor:"\u81EA\u53D1\u5149\u8272",assetEmissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6",assetEmissionTexture:"\u81EA\u53D1\u5149\u8D34\u56FE",assetEmissionMaskUrl:"\u906E\u7F69\u8D34\u56FE",assetAlphaMode:"\u900F\u660E\u6A21\u5F0F",assetAlphaModeOpaque:"\u4E0D\u900F\u660E",assetAlphaModeMask:"\u906E\u7F69",assetAlphaModeBlend:"\u534A\u900F\u660E",assetAlphaOpacity:"\u4E0D\u900F\u660E\u5EA6",assetAlphaCutoff:"Alpha \u9608\u503C",assetAlphaTexture:"Alpha \u8D34\u56FE",createSlotMaterial:"\u6DFB\u52A0\u6750\u8D28\u69FD",slotList:"\u69FD\u5217\u8868",slotId:"\u69FD ID",slotOwnerPath:"\u69FD\u8282\u70B9\u8DEF\u5F84",slotMaterialAsset:"\u69FD\u6750\u8D28\u8D44\u4EA7",slotSourceMaterial:"\u6E90\u6750\u8D28",slotBindingPath:"\u7ED1\u5B9A\u8DEF\u5F84",reimportConflicts:"\u91CD\u5BFC\u5165\u6750\u8D28\u51B2\u7A81",summaryAsset:e=>`\u8D44\u4EA7\uFF1A${e}`,summaryMissingAsset:"\u8D44\u4EA7\u7F3A\u5931",summaryCustomOverride:"\u81EA\u5B9A\u4E49\u53C2\u6570",summaryInherit:"\u7EE7\u627F",summaryAddSlot:"\u6DFB\u52A0\u69FD",summarySlotCount:e=>`${e} \u4E2A\u69FD`,formatUsageCount:e=>e>0?`\u88AB ${e} \u5904\u4F7F\u7528`:"\u672A\u88AB\u4F7F\u7528",formatMaterialEditImpact:e=>e<=0?"\u5F53\u524D\u672A\u88AB\u573A\u666F\u4F7F\u7528\uFF0C\u4FEE\u6539\u53EA\u4F1A\u6539\u53D8\u6750\u8D28\u8D44\u4EA7\u672C\u8EAB\u3002":e===1?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u5F53\u524D\u7ED1\u5B9A\u3002":`\u5171\u4EAB\u6750\u8D28\uFF0C\u4FEE\u6539\u4F1A\u5F71\u54CD ${e} \u5904\u7ED1\u5B9A\u3002`,formatDuplicateMaterialImpact:e=>e<=0?"\u590D\u5236\u540E\u521B\u5EFA\u4E00\u4E2A\u53EF\u72EC\u7ACB\u7F16\u8F91\u7684\u6750\u8D28\u8D44\u4EA7\u3002":e===1?"\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\u3002":`\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\uFF0C\u539F ${e} \u5904\u5171\u4EAB\u7ED1\u5B9A\u4E0D\u88AB\u7EE7\u7EED\u4FEE\u6539\u3002`,formatReimportConflictSummary:e=>`\u68C0\u6D4B\u5230 ${e} \u4E2A\u6750\u8D28\u69FD\u91CD\u5BFC\u5165\u5DEE\u5F02\uFF1B\u5DF2\u4FDD\u7559\u73B0\u6709\u7ED1\u5B9A\uFF0C\u9700\u4EBA\u5DE5\u786E\u8BA4\u4E0D\u53EF\u5339\u914D\u9879\u3002`,tooltips:{language:"\u5207\u6362\u7F8E\u672F\u6750\u8D28 Inspector \u7684\u663E\u793A\u8BED\u8A00\u3002",materialAsset:"\u9009\u62E9\u9879\u76EE\u7EA7\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\uFF0C\u6216\u4F7F\u7528\u53EA\u8BFB\u7684\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotMaterialAsset:"\u672A\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u65F6\u4FDD\u7559 GLB \u539F\u59CB\u6750\u8D28\uFF1B\u9009\u62E9\u540E\u53EA\u8986\u76D6\u5F53\u524D\u6750\u8D28\u63D2\u69FD\u3002",baseTexture:"\u9009\u62E9\u9879\u76EE\u8D34\u56FE\u4F5C\u4E3A\u57FA\u7840\u8D34\u56FE\u3002\u8D34\u56FE\u8C03\u8272\u53C2\u6570\u4F1A\u5148\u4F5C\u7528\u4E8E\u8FD9\u5F20\u8D34\u56FE\u3002",assetProfile:"\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u7684\u53C2\u6570\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u8D44\u4EA7\u7684\u8282\u70B9\u3002",assetName:"\u6750\u8D28\u8D44\u4EA7\u540D\u79F0\u53EA\u7528\u4E8E\u5C55\u793A\uFF1B\u7ED1\u5B9A\u4F7F\u7528\u7A33\u5B9A\u6750\u8D28 ID\uFF0C\u4E0D\u53D7\u91CD\u547D\u540D\u5F71\u54CD\u3002",assetKind:"\u9009\u62E9\u8BE5\u6750\u8D28\u5F15\u7528\u7684 Shader Definition\uFF1B\u5207\u6362\u65F6\u4F1A\u4FDD\u7559\u517C\u5BB9\u53C2\u6570\u3002",lightingModel:"\u53D7\u5149\u7167\u6750\u8D28\u4F1A\u54CD\u5E94\u73AF\u5883\u5149\u548C\u76F4\u5C04\u5149\uFF1B\u4E0D\u53D7\u5149\u7167\u6750\u8D28\u9002\u5408 UI\u3001\u7279\u6548\u3001\u56FE\u6807\u548C\u5BFC\u89C6\u6807\u8BB0\u3002",baseColor:"\u57FA\u7840\u8272\u4F5C\u4E3A\u989C\u8272\u56E0\u5B50\uFF0C\u4F1A\u5728\u57FA\u7840\u8D34\u56FE\u5B8C\u6210\u8C03\u8272\u540E\u53C2\u4E0E\u76F8\u4E58\u3002\u4FEE\u6539\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u6750\u8D28\u7403\u7684\u8282\u70B9\u3002",duplicateForObject:"\u590D\u5236\u5F53\u524D\u6750\u8D28\u7403\u4E3A\u8FD9\u4E2A\u5BF9\u8C61\u6216\u69FD\u7684\u72EC\u7ACB\u6750\u8D28\uFF0C\u7136\u540E\u81EA\u52A8\u66FF\u6362\u7ED1\u5B9A\u3002",brightness:"\u57FA\u7840\u8D34\u56FE\u4EAE\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",saturation:"\u57FA\u7840\u8D34\u56FE\u9971\u548C\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",contrast:"\u57FA\u7840\u8D34\u56FE\u5BF9\u6BD4\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",hue:"\u57FA\u7840\u8D34\u56FE\u8272\u76F8\u504F\u79FB\uFF0C\u5355\u4F4D\u4E3A\u5EA6\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",normalTexture:"\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\uFF0C\u8FD0\u884C\u65F6\u5E94\u7528\u5230 PBR/Standard \u6750\u8D28\u7684 bump/normal \u901A\u9053\u3002",normalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",metallic:"\u91D1\u5C5E\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",roughness:"\u7C97\u7CD9\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",metallicRoughnessTexture:"\u9009\u62E9\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE\u3002PBR \u8FD0\u884C\u65F6\u6309 GLB \u5E38\u7528\u7EA6\u5B9A\u8BFB\u53D6\u84DD\u8272\u91D1\u5C5E\u5EA6\u3001\u7EFF\u8272\u7C97\u7CD9\u5EA6\u3002",occlusionTexture:"\u9009\u62E9\u73AF\u5883\u906E\u853D AO \u8D34\u56FE\uFF0C\u53EA\u5BF9 PBR \u6750\u8D28\u751F\u6548\u3002",occlusionStrength:"AO \u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",emissionColor:"\u81EA\u53D1\u5149\u989C\u8272\uFF0C\u4F1A\u4E0E\u5F3A\u5EA6\u76F8\u4E58\u3002",emissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6\uFF0C0 \u8868\u793A\u65E0\u81EA\u53D1\u5149\u3002",emissionTexture:"\u9009\u62E9\u81EA\u53D1\u5149\u8D34\u56FE\uFF1B\u82E5\u672A\u8BBE\u7F6E\u5219\u517C\u5BB9\u4F7F\u7528\u65E7\u906E\u7F69\u8D34\u56FE\u3002",emissionMaskUrl:"\u9009\u62E9\u7070\u5EA6\u8D34\u56FE\u4F5C\u4E3A\u81EA\u53D1\u5149\u5F3A\u5EA6\u906E\u7F69\u3002",alphaMode:"\u900F\u660E\u6A21\u5F0F\uFF1A\u4E0D\u900F\u660E\u3001Alpha Test \u906E\u7F69\u6216 Alpha Blend \u534A\u900F\u660E\u3002",alphaOpacity:"\u6750\u8D28\u6574\u4F53\u4E0D\u900F\u660E\u5EA6\uFF0C1 \u4E3A\u5B8C\u5168\u4E0D\u900F\u660E\u3002",alphaCutoff:"\u906E\u7F69\u6A21\u5F0F\u7684 Alpha \u622A\u65AD\u9608\u503C\u3002",alphaTexture:"\u9009\u62E9 Alpha/Opacity \u8D34\u56FE\u3002",createSlotMaterial:"\u8F93\u5165 GLB \u5B50\u8282\u70B9\u6216 mesh \u7684 ownerNodePath \u6765\u6DFB\u52A0\u69FD\u7ED1\u5B9A\uFF0C\u521D\u59CB\u4F7F\u7528\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotList:"\u6839\u8282\u70B9\u4E0A\u7684\u6750\u8D28\u69FD\u4E3A\u53EA\u8BFB\u603B\u89C8\u3002",slotOwnerPath:"\u6750\u8D28\u69FD\u5B9A\u4F4D\u5230\u7684\u5B50\u8282\u70B9\u6216 mesh \u8DEF\u5F84\u3002",reimportConflicts:"\u6A21\u578B\u91CD\u5BFC\u5165\u540E\u65E0\u6CD5\u81EA\u52A8\u5339\u914D\u6216\u6E90\u6750\u8D28\u53D8\u5316\u7684\u69FD\u3002\u73B0\u6709\u7ED1\u5B9A\u4F1A\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u9759\u9ED8\u5220\u9664\u6216\u8986\u76D6\u3002"}},en:{title:"Artist Material",slotTitle:"Material Slots",language:"Language",materialAsset:"Material Asset",materialCard:"Current Material",inheritNone:"Inherit / None",defaultMaterial:"Default PBR Material",defaultMaterialMeta:"BabylonJS-style default PBR material",defaultStandardMaterial:"Default Standard Material",defaultStandardMaterialMeta:"BabylonJS-style default Standard material",defaultMaterialReadOnly:"The system default material is read-only. Choose an editable material asset to adjust parameters.",replace:"Replace",batchReplaceUnsupported:"Batch material replacement is not wired yet. Select one object to replace its material.",duplicateForObject:"Copy",materialPickerTitle:"Select Material Asset",texturePickerTitle:"Select Texture Asset",emptyTexture:"Select Texture",emptyTextureMeta:"Choose a texture asset",inheritTexture:"Inherit Source Texture",inheritTextureMeta:"Use the GLB / source material texture when available",clearTexture:"Clear Texture",clearTextureMeta:"Do not use a texture",missingTexture:"Missing texture asset",missingTextureMeta:"The current reference cannot be resolved in the project asset library",loadingTexture:"Loading texture",failedTexture:"Texture failed to load",assetProfile:"Asset Profile",assetProfileEmpty:"Select a material asset to edit asset parameters",assetName:"Asset Name",assetKind:"Shader",assetKindPbr:"PBR standard material",assetKindStandard:"Standard material",assetLightingModel:"Lighting Model",assetLightingModelLit:"Lit",assetLightingModelUnlit:"Unlit",assetBaseColor:"Base Color",assetBaseTexture:"Base Texture",assetBrightness:"Texture Brightness",assetSaturation:"Texture Saturation",assetContrast:"Texture Contrast",assetHue:"Texture Hue",assetNormalTexture:"Normal Texture",assetNormalStrength:"Normal Strength",assetMetallic:"Metallic",assetRoughness:"Roughness",assetMetallicRoughnessTexture:"Metallic-Roughness Texture",assetOcclusionTexture:"AO Texture",assetOcclusionStrength:"AO Strength",resetValue:"Reset to shader default",modifiedValue:"Modified from shader default",inactiveReasons:{baseTexture:"Available after assigning a base texture.",litMaterial:"Available only when the lighting model is Lit.",normalTexture:"Available after assigning a normal texture.",occlusionTexture:"Available after assigning an AO texture.",alphaBlend:"Available only in Blend alpha mode.",alphaMask:"Available only in Mask alpha mode.",alphaTransparency:"Available only in Mask or Blend alpha mode."},assetEmissionColor:"Emission Color",assetEmissionIntensity:"Emission Intensity",assetEmissionTexture:"Emission Texture",assetEmissionMaskUrl:"Mask Texture",assetAlphaMode:"Alpha Mode",assetAlphaModeOpaque:"Opaque",assetAlphaModeMask:"Mask",assetAlphaModeBlend:"Blend",assetAlphaOpacity:"Opacity",assetAlphaCutoff:"Alpha Cutoff",assetAlphaTexture:"Alpha Texture",createSlotMaterial:"Add Material Slot",slotList:"Slot List",slotId:"Slot ID",slotOwnerPath:"Slot Owner Path",slotMaterialAsset:"Slot Material Asset",slotSourceMaterial:"Source Material",slotBindingPath:"Binding Path",reimportConflicts:"Reimport Material Conflicts",summaryAsset:e=>`Asset: ${e}`,summaryMissingAsset:"Missing asset",summaryCustomOverride:"Custom override",summaryInherit:"Inherit",summaryAddSlot:"Add slot",summarySlotCount:e=>`${e} slot${e===1?"":"s"}`,formatUsageCount:e=>e>0?`Used in ${e} place${e===1?"":"s"}`:"Unused",formatMaterialEditImpact:e=>e<=0?"This material is not used in the scene; edits only change the asset.":e===1?"Edits affect the current binding.":`Shared material: edits affect ${e} bindings.`,formatDuplicateMaterialImpact:e=>e<=0?"Copying creates an independently editable material asset.":e===1?"After copying, the current object or slot uses an independent material.":`After copying, the current object or slot uses an independent material; the original ${e} shared bindings are left unchanged.`,formatReimportConflictSummary:e=>`${e} material slot reimport difference${e===1?"":"s"} detected. Existing bindings are preserved until unmatched items are resolved.`,tooltips:{language:"Switch the artist material Inspector language.",materialAsset:"Choose a project-level shared material asset, or use the read-only Default PBR material.",slotMaterialAsset:"Leave this unset to preserve the original GLB material, or choose a material asset to override only this slot.",baseTexture:"Choose a project texture as the base texture. Texture adjustment parameters are applied to this texture first.",assetProfile:"Shared asset parameters affect every node bound to this material asset.",assetName:"Material asset names are display-only for bindings; stable material IDs survive renames.",assetKind:"Select the Shader Definition referenced by this material; compatible values survive a change.",lightingModel:"Lit materials respond to environment and directional lights; unlit materials are useful for UI, VFX, icons, and markers.",baseColor:"Base color is the final color factor multiplied after base texture adjustment. Editing the shared material asset affects every bound node.",duplicateForObject:"Copy the current material as an independent material for this object or slot, then bind it automatically.",brightness:"Base texture brightness multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",saturation:"Base texture saturation multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",contrast:"Base texture contrast multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",hue:"Base texture hue offset in degrees. It only affects materials with a base texture.",normalTexture:"Choose a normal map applied to the runtime bump/normal channel for PBR and Standard materials.",normalStrength:"Normal strength. 1 keeps the texture at original strength.",metallic:"Metallic value from 0 to 1.",roughness:"Roughness value from 0 to 1.",metallicRoughnessTexture:"Choose a metallic-roughness texture. PBR runtime reads blue as metallic and green as roughness by the common GLB convention.",occlusionTexture:"Choose an ambient occlusion texture. Applies to PBR materials.",occlusionStrength:"Ambient occlusion strength. 1 keeps the texture at original strength.",emissionColor:"Emission color multiplied by emission intensity.",emissionIntensity:"Emission intensity. 0 means no emission.",emissionTexture:"Choose an emissive texture. If empty, the mask texture remains the fallback.",emissionMaskUrl:"Choose a grayscale texture to modulate emission intensity.",alphaMode:"Alpha mode: opaque, alpha-test mask, or alpha-blend transparency.",alphaOpacity:"Overall material opacity. 1 is fully opaque.",alphaCutoff:"Alpha-test cutoff threshold for mask mode.",alphaTexture:"Choose an alpha/opacity texture.",createSlotMaterial:"Enter a GLB child node or mesh ownerNodePath to add a slot binding with the Default PBR material.",slotList:"Material slots on the root object are a readonly overview.",slotOwnerPath:"Child node or mesh path targeted by this material slot.",reimportConflicts:"Slots whose source material changed or could not be matched after model reimport. Existing bindings are preserved instead of being silently deleted or overwritten."}}};function gr(e){return dS[e]??dS.zh}function Us(e){return e.metadata?.artistMaterialInspectorLanguage==="en"?"en":"zh"}var XM={},lS=new WeakMap;function uS(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function mS(e,t){return iS(e,gS(t))}function YM(e){return{materialPickerTitle:e.materialPickerTitle,replace:e.replace,duplicateForObject:e.duplicateForObject,duplicateForObjectTooltip:e.tooltips.duplicateForObject,summaryMissingAsset:e.summaryMissingAsset,summaryInherit:e.summaryInherit,inheritNone:e.inheritNone}}function ZM(e){return{formatUsageCount:e.formatUsageCount,formatEditImpact:e.formatMaterialEditImpact,formatDuplicateImpact:e.formatDuplicateMaterialImpact}}function gS(e){return{defaultMaterial:e.defaultMaterial,defaultStandardMaterial:e.defaultStandardMaterial,defaultMaterialMeta:e.defaultMaterialMeta,defaultStandardMaterialMeta:e.defaultStandardMaterialMeta,formatMaterialMeta:t=>`Material - ${t}`}}function bS(e,t,r,n,o={}){if(!t)return[];let a=o.materialShaderDefinitions?.get(t.shaderId)??De(t.shaderId),i=aw(e,t,r,n,o,a??void 0);if(yS(t,o))return[...i,j({path:`scene.materialAssets.${t.id}.properties`,label:r.assetProfile,value:r.defaultMaterialReadOnly,order:n+2,source:"Document",effect:"default",disabledReason:r.defaultMaterialReadOnly,tags:["ArtistMaterial","MaterialAsset"],tooltip:r.tooltips.assetProfile})];if(!a)return i;let s=[...a.inspector.fields].sort((c,d)=>c.order-d.order||c.path.localeCompare(d.path)).map(c=>QM({document:e,materialAsset:t,definition:a,fieldDefinition:c,text:r,context:o,orderOffset:n}));return[...i,...s]}function QM(e){let{fieldDefinition:t}=e,r=fS(e.text,t.labelKey,t.label??t.path),n=rw(e.text,t.tooltipKey,t.tooltip),o=SS(e.materialAsset.properties,t),a=t.control==="texture"&&ro(e.materialAsset.shaderId,t.path)?ew(e.materialAsset.properties,t):null,i;if(t.control==="texture")i=iw({path:`${dr}${e.materialAsset.id}.${t.path}`,label:r,value:typeof o=="string"?o:"",order:e.orderOffset+t.order,text:e.text,context:e.context,textureState:a??void 0,tooltip:n});else if(t.control==="number")i=cw(e.document,e.materialAsset,t.path,r,typeof o=="number"?o:Number(t.defaultValue),e.orderOffset+t.order,t,n,e.context.materialShaderDefinitions);else if(t.control==="enum")i=dw(e.document,e.materialAsset,t.path,r,String(o),e.orderOffset+t.order,(t.options??[]).map(d=>({value:d.value,label:fS(e.text,d.labelKey,d.label??d.value)})),n,e.context.materialShaderDefinitions);else{let d=t.control;i=qs(e.document,e.materialAsset,t.path,r,o,e.orderOffset+t.order,d,d,"immediate",n,e.context.materialShaderDefinitions)}let s=t.control==="color"?Zn(e.definition.shaderId,t.path,e.context.materialShaderDefinitions):null;i={...i,displayPrecision:t.displayPrecision,precision:t.precision,controlOptions:{...i.controlOptions,...t.control==="color"?{colorChannels:s?.kind==="color"&&s.channels===4?4:3}:{},materialShaderSectionId:t.sectionId,materialShaderUpdateClass:t.updateClass,materialShaderBinding:t.binding}};let c=t.conditions?.find(d=>!tw(e.definition,e.materialAsset.properties,d));return c&&(i=fw(i,!1,nw(e.text,c))),a?uw(i,e.text,a):lw(i,e.text,t.defaultValue)}function ew(e,t){let r=Ks(e,t.schemaPath??t.path);return r===void 0?"inherited":r===null?"cleared":"override"}function SS(e,t){if(t.control==="texture"){let n=Ks(e,t.schemaPath??t.path);return hS(n)}let r=Ks(e,t.path);return r===void 0?structuredClone(t.defaultValue):r}function Ks(e,t){let r=t.replace(/^properties\./,"").split(".").filter(Boolean),n=e;for(let o of r){if(!n||typeof n!="object"||Array.isArray(n))return;n=n[o]}return n}function tw(e,t,r){let n=e.inspector.fields.find(i=>i.path===r.path),o=n?SS(t,n):Ks(t,r.path);if(r.operator==="truthy")return!!o;let a=JSON.stringify(o??null)===JSON.stringify(r.value??null);return r.operator==="equals"?a:!a}function fS(e,t,r){let n=t?e[t]:void 0;return typeof n=="string"?n:r}function rw(e,t,r){let n=t?e.tooltips[t]:void 0;return typeof n=="string"?n:r}function nw(e,t){let r=t.inactiveReasonKey?e.inactiveReasons[t.inactiveReasonKey]:void 0;return typeof r=="string"?r:t.inactiveReason??"This field is inactive for the current material state."}function ow(e){return e.defaultMaterialAssetIds??[Pn,Eo]}function yS(e,t){return ka(e,ow(t))||e.system?.preset==="default-pbr"||e.system?.preset==="default-standard"}function aw(e,t,r,n,o,a){if(!yS(t,o)){let i=o.materialShaderDefinitions??Mr;return[qs(e,t,"name",r.assetName,mS(t,r),n,"string","string","change",r.tooltips.assetName,i),{path:`${dr}${t.id}.shaderId`,label:r.assetKind,valueType:"string",control:"enum",value:t.shaderId,readOnly:!1,persistence:"document",commitMode:"immediate",order:n+1,tooltip:r.tooltips.assetKind,tags:["ArtistMaterial","MaterialAsset","ShaderDefinition"],options:i.list().map(s=>({value:s.shaderId,label:s.displayName})),controlOptions:{materialShaderSelector:!0,shaderId:t.shaderId,shaderVersion:a?.version,shaderRuntimeKind:a?.runtimeKind,...a?.sourceFile?{shaderSourceFile:a.sourceFile}:{}},validate:s=>typeof s=="string"&&i.get(s)?{ok:!0,value:s}:{ok:!1,message:"Unknown Shader Definition."},coerce:s=>typeof s=="string"?s.trim():""}]}return[uS(`${dr}${t.id}.name`,r.assetName,mS(t,r),n,r.tooltips.assetName),uS(`${dr}${t.id}.shaderId`,r.assetKind,a?.displayName??t.shaderId,n+1,r.tooltips.assetKind)]}function iw(e){let t=ou(e.context,e.value),r=Ws(e.context,e.text,e.value,t);return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:e.value,readOnly:!1,persistence:"document",commitMode:"change",order:e.order,tooltip:e.tooltip,tags:["ArtistMaterial","TextureAsset"],controlOptions:{...r,...e.textureState?{materialTextureState:e.textureState}:{},...!e.value&&e.textureState==="inherited"?{currentLabel:e.text.inheritTexture,currentMeta:e.text.inheritTextureMeta}:!e.value&&e.textureState==="cleared"?{currentLabel:e.text.clearTexture,currentMeta:e.text.clearTextureMeta}:{}},validate:n=>{let o=pS(e.context,e.path,n);return o.ok?{ok:!0,value:o.value}:{ok:!1,message:"Invalid texture selection."}},coerce:n=>{let o=pS(e.context,e.path,n);return o.ok?o.value:null}}}function Ws(e,t,r,n){return{...sS({textureAssets:e.textureAssets,currentTexture:n,currentValue:r,pickerText:sw(t),candidateValue:"assetId"})}}function ou(e,t){return Vs(e.textureAssets,t)}function hS(e){let t=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";return t||(typeof e?.url=="string"?e.url.trim():"")}function pS(e,t,r){if(r==null||r==="")return{ok:!0,value:null};if(typeof r!="string")return{ok:!1};let n=r.trim();if(!n)return{ok:!0,value:null};if(!t.endsWith(".textureAssetId"))return{ok:!0,value:n};let o=Vs(e.textureAssets,n);return o?{ok:!0,value:o.id}:/^[A-Za-z0-9_-]+$/.test(n)?{ok:!0,value:n}:{ok:!0,value:null}}function sw(e){return{texturePickerTitle:e.texturePickerTitle,replace:e.replace,emptyTexture:e.emptyTexture,emptyTextureMeta:e.emptyTextureMeta,clearTexture:e.clearTexture,clearTextureMeta:e.clearTextureMeta,missingTexture:e.missingTexture,missingTextureMeta:e.missingTextureMeta,loadingTexture:e.loadingTexture,failedTexture:e.failedTexture}}function cw(e,t,r,n,o,a,i={},s,c){return{...qs(e,t,r,n,o,a,"number","number","live",s,c),...i.min!=null?{min:i.min}:{},...i.max!=null?{max:i.max}:{},...i.softMin!=null?{softMin:i.softMin}:{},...i.softMax!=null?{softMax:i.softMax}:{},step:i.step??.05}}function dw(e,t,r,n,o,a,i,s,c){return{...qs(e,t,r,n,o,a,"enum","enum","immediate",s,c),options:i,controlOptions:{variant:"segmented"}}}function qs(e,t,r,n,o,a,i,s,c,d,u){return{...cS({document:e,materialAsset:t,fieldPath:r,label:n,value:o,order:a,valueType:i,control:s,commitMode:c,tooltip:d,pathPrefix:dr}),validate:l=>{let m=rt(r,l);return zt(r,m,t.shaderId,u)?{ok:!0,value:m}:{ok:!1,message:`Invalid material asset field: ${r}.`}},coerce:l=>rt(r,l)}}function lw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:structuredClone(r),modified:!mw(e.value,r),resetLabel:t.resetValue,modifiedLabel:t.modifiedValue}}}function uw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:"",resetMode:"inherit",modified:r!=="inherited",resetLabel:t.inheritTexture,modifiedLabel:r==="cleared"?t.clearTexture:t.modifiedValue}}}function mw(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function fw(e,t,r){return t?e:{...e,controlOptions:{...e.controlOptions,conditionalInactive:!0,conditionalInactiveReason:r}}}function ES(e,t,r,n){let o=r.currentAsset??ee(e,r.value);return{path:r.path,label:r.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.value,readOnly:!1,persistence:"document",commitMode:"change",order:r.order,controlOptions:bw(Hs(e,o,r.text,r.value,n,r.previewContext),r.currentAction),tooltip:r.text.tooltips.materialAsset,tags:["ArtistMaterial","MaterialAsset"],document:e,validate:a=>{let i=es(a);return i&&Vt(e,i)?{ok:!0,value:a}:a==null||a===""?{ok:!0,value:a}:typeof a=="string"&&Vt(e,a)?{ok:!0,value:a}:{ok:!1,message:`Material asset not found: ${String(a)}`}},coerce:a=>typeof a=="string"?a.trim():a,effect:pw(t,r.value),validation:gw(r.value,o,r.text),disabledReason:t==="group"?"Groups do not own materials.":void 0}}function pw(e,t){return e==="group"?"unsupported":t.trim()?"override":void 0}function gw(e,t,r){let n=e.trim();if(!(!n||t))return{status:"error",code:"material.asset.missing",message:`${r.summaryMissingAsset}: ${n}`}}function bw(e,t){return t?{...e,currentActionId:t.actionId,currentActionParams:Object.fromEntries(Object.entries(t.params).filter(r=>typeof r[1]=="string"&&r[1].length>0))}:e}function Sw(e,t,r){return ES(e,t,r,_e.getCachedUsageIndex(e))}function Hs(e,t,r,n,o,a={}){return{..._e.createPickerControlOptions({materialAssets:e.scene.materialAssets??[],currentAsset:t,currentValue:n,pickerText:YM(r),displayText:gS(r),document:e,ownershipText:ZM(r),previewContext:a},o),actionDisabledReason:r.batchReplaceUnsupported}}function yw(e,t,r,n,o={}){if(o.textureAssets?.length||o.resolveTextureAssetUrl)return Hs(e,t,r,n,_e.getCachedUsageIndex(e),o);let a=lS.get(e);a||(a=new WeakMap,lS.set(e,a));let i=a.get(r);i||(i=new WeakMap,a.set(r,i));let s=t??XM,c=i.get(s);c||(c=new Map,i.set(s,c));let d=c.get(n);if(d)return d;let u=Hs(e,t,r,n,_e.getCachedUsageIndex(e),o);return c.set(n,u),u}var hw={createSelectorInspectorPropertyWithUsage:ES,createSelectorInspectorPropertyWithCachedUsage:Sw,createPickerControlOptionsWithUsage:Hs,createPickerControlOptionsWithCachedUsage:yw},Dn=hw;function IS(e,t,r){let n=Hp(e,t);if(n.state==="asset"&&n.materialAsset){let o=Bb(n.materialAsset),a=o==="default-pbr"?r.defaultMaterial:o==="default-standard"?r.defaultStandardMaterial:n.materialAsset.name??n.materialAsset.id;return r.summaryAsset(a)}return n.state==="missing-asset"?r.summaryMissingAsset:n.state==="override"?r.summaryCustomOverride:r.summaryInherit}function PS(e,t,r){let n=lr(e,t).length;return n>0?r.summarySlotCount(n):r.summaryAddSlot}function Ew(e,t,r,n,o,a={}){let i=gr(Us(t)),s=[];return lr(e,t).forEach((d,u)=>{let l=Ut(d)??d.slotId,m=nl(t,d),f=o?.materialSlotBindings?.[d.slotId]??m,S=f?.materialAssetId?ee(e,f.materialAssetId):null,g=(u+1)*100,b=os(d),y=nt(d)[0],E=y==null?null:Io(d,y)?.profile,I=Dn.createSelectorInspectorPropertyWithUsage(e,r,{path:b,label:d.label||au(l,u,i),value:m?.materialAssetId??"",order:g,text:i,currentAsset:S,currentAction:S?{actionId:"material.open-asset",params:{materialAssetId:S.id,browserAssetId:`material:${S.id}`,sourceObjectId:t.id,sourceBindingPath:b}}:E?{actionId:"material.create-from-source",params:{sourceObjectId:t.id,sourceBindingPath:b}}:void 0,previewContext:a},n);s.push(Iw(I,d,f,i,a))}),s}function Iw(e,t,r,n,o){let a=nt(t)[0],i=a==null?t.materialNames?.[0]??t.materialName??null:xn(t,a),s=a==null?null:Io(t,a)?.profile,c=s?Bt(Ns(s),o):void 0,d=i?`GLB \u6E90\u6750\u8D28\uFF1A${i}`:"GLB \u6E90\u6750\u8D28",u=e.controlOptions??{},l=Array.isArray(u.candidates)?u.candidates.map(f=>f&&typeof f=="object"&&!Array.isArray(f)&&f.value===""?{...f,label:"\u6062\u590D\u7EE7\u627F",meta:d,...c?{preview:c}:{}}:f):void 0,m=r?.materialAssetId&&typeof u.currentMeta=="string"&&u.currentMeta?`${u.currentMeta} \xB7 ${d}`:d;return{...e,tooltip:n.tooltips.slotMaterialAsset,controlOptions:{...u,...r?.materialAssetId?{}:{currentLabel:i?`\u7EE7\u627F GLB\uFF1A${i}`:"\u7EE7\u627F GLB \u539F\u6750\u8D28",...c?{currentPreview:c}:{}},currentMeta:m,...l?{candidates:l}:{},...i?{sourceMaterialName:i}:{}}}}function Pw(e,t,r,n){let o=lr(e,t);if(o.length===0)return[];let a=[],i=zs(e,t),s=cs(e,t.id)??t.overrides;i.issues.length>0&&a.push(Dw("asset.materialSlots.reimportConflicts",r.reimportConflicts,Tw(i.issues,r),-1,r.tooltips.reimportConflicts));let c=o.map((d,u)=>xw(e,t,d,u,r,n,s));return a.push({path:"asset.materialSlots",label:r.slotList,valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:o.length,slots:c},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:r.slotMaterialAsset,slotId:r.slotId,ownerNodePath:r.slotOwnerPath,sourceMaterial:r.slotSourceMaterial,primitive:"Primitive",triangles:"Triangles",bounds:"Bounds",bindingPath:r.slotBindingPath},slots:c},tags:["ArtistMaterial","MaterialSlot","Readonly"],tooltip:r.tooltips.slotList,document:e}),a}function Tw(e,t){let r=e.map(n=>{let o=n.label||n.ownerNodePath||n.slotId||n.previousSlotId||n.bindingPath||"slot";if(n.reason==="source-material-changed"){let a=n.previousSourceMaterialIndex==null?"?":`#${n.previousSourceMaterialIndex}`,i=n.sourceMaterialIndex==null?"?":`#${n.sourceMaterialIndex}`;return`${o}: source material ${a} -> ${i}; ${n.materialAssetId??t.inheritNone}`}return n.reason==="slot-removed"?`${o}: removed slot; ${n.materialAssetId??t.inheritNone}`:`${o}: ${n.status}`});return[t.formatReimportConflictSummary(e.length),...r].join(`
3
- `)}function xw(e,t,r,n,o,a,i){let s=nl(t,r),c=i?.materialSlotBindings?.[r.slotId]??s,d=ee(e,c?.materialAssetId??Tn),u=Dn.createPickerControlOptionsWithUsage(e,d,o,s?.materialAssetId??"",a),l=nt(r),m=l[0],f=m==null?null:xn(r,m),S=r.sourceSurfaces[0],g=S.ownerNodePath;return{key:qp(r),label:r.label||au(g,n,o),slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:g,materialAssetId:s?.materialAssetId??"",materialLabel:u.currentLabel??o.inheritNone,materialMeta:u.currentMeta??o.summaryInherit,...u.currentPreview?{materialPreview:u.currentPreview}:{},...m==null?{}:{sourceMaterialIndex:m},...l.length?{sourceMaterialIndices:l}:{},...f?{sourceMaterialName:f}:{},...r.materialNames?.length?{materialNames:r.materialNames}:{},...r.sourceSurfaces.length===1&&typeof S.triangleCount=="number"?{triangleCount:S.triangleCount}:{},...r.sourceSurfaces.length===1&&S.boundingBox?{boundingBox:S.boundingBox}:{},bindingPath:os(r)}}var Aw={createChildMaterialBindingInspectorPropertiesWithUsage:Ew,createReadonlyMaterialSlotListInspectorPropertiesWithUsage:Pw},TS=Aw;function au(e,t,r){let n=e.split("/").filter(Boolean).pop()??e;return`${r.slotMaterialAsset} ${t+1}: ${n}`}function Dw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var xS="materialAsset::",Mw=5;function ww(e){return e.startsWith(xS)&&e.slice(xS.length).trim()||null}function kw(e,t,r,n,o,a){let i=[],s=Us(t),c=gr(s),d=t.overrides?.materialBinding,u=cs(e,t.id)??t.overrides,l=u?.materialBinding??d,m=l?.materialAssetId??Tn,f=ee(e,m),S=l?.materialAssetId?l:{...l,materialAssetId:Tn};if(!Wp(e,t)){let y="overrides.materialBinding.materialAssetId";i.push({id:"artistMaterial",title:c.title,order:46,placement:"body",summary:IS(S,f,c),persistence:"document",collapsedByDefault:!1,properties:[Dn.createSelectorInspectorPropertyWithUsage(e,r,{path:y,label:c.materialCard,value:d?.materialAssetId??"",order:0,text:c,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,sourceBindingPath:y}},previewContext:n},a)]})}let b=r==="primitive"?[]:TS.createChildMaterialBindingInspectorPropertiesWithUsage(e,t,r,a,u,n);return b.length>0&&i.push({id:"artistMaterialSlots",title:c.slotTitle,order:48,placement:"body",summary:PS(e,t,c),persistence:"document",collapsedByDefault:!1,properties:b}),i}function Ow(e,t,r,n){let o=ww(t),a=o?ee(e,o):null;if(!a)return null;let i=gr("zh"),s=n.forMaterial(a.id),c=bS(e,a,i,0,r),d=`scene.materialAssets.${a.id}.properties`,u=`${d}.`,l=I=>I.path===d||I.path.startsWith(u),m=c.filter(I=>!l(I)),f=c.filter(l),S=[{path:`scene.materialAssets.${a.id}.preview`,label:a.name||a.id,valueType:"object",control:"custom",customControl:"asset-picker-card",value:a.id,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:-10,controlOptions:{currentMaterialAssetId:a.id,currentMaterialShaderId:a.shaderId,...a.definitionVersion!=null?{currentMaterialDefinitionVersion:a.definitionVersion}:{},currentLabel:a.name||a.id,currentMeta:a.shaderId,currentPreview:Bt(a.properties,r)},document:e},...m,Gw(`scene.materialAssets.${a.id}.usageCount`,"\u5F15\u7528",i.formatUsageCount(s.length),10)],g=[io({path:`scene.materialAssets.${a.id}.actions.locate`,label:"\u5728 Assets \u4E2D\u5B9A\u4F4D",actionId:"material.locate-asset",icon:"asset",params:{materialAssetId:a.id,browserAssetId:`material:${a.id}`},order:20,tooltip:"\u5728 Assets \u9762\u677F\u4E2D\u5B9A\u4F4D\u5F53\u524D\u6750\u8D28\u3002",disabled:!1}),io({path:`scene.materialAssets.${a.id}.actions.back`,label:"\u8FD4\u56DE\u6765\u6E90",actionId:"material.back-to-owner",icon:"chevron-left",params:{materialAssetId:a.id},order:21,tooltip:"\u8FD4\u56DE\u6253\u5F00\u5F53\u524D\u6750\u8D28\u524D\u7684\u5BF9\u8C61\u6216 Prefab Inspector\u3002",disabled:!1})],b=[{id:"materialAssetSummary",title:"Material",order:10,regionId:Li,persistence:"readonly",collapsedByDefault:!1,properties:S}];b.push({id:"materialAssetNavigation",title:"\u5BFC\u822A",order:15,placement:"body",persistence:"readonly",collapsedByDefault:!1,properties:g}),b.push({id:"materialReferences",title:`\u4F7F\u7528\u4F4D\u7F6E (${s.length})`,order:20,placement:"body",persistence:"readonly",collapsedByDefault:s.length===0,properties:[{path:`scene.materialAssets.${a.id}.references.browser`,label:"\u4F7F\u7528\u4F4D\u7F6E",valueType:"object",control:"custom",customControl:"material-reference-list",controlOptions:{previewLimit:Mw,items:s.map((I,P)=>({key:`${I.scope}:${I.gameObjectId}:${I.bindingPath}:${P}`,label:I.label,scope:I.scope,actionId:"material.open-owner",params:Object.fromEntries(Object.entries({materialAssetId:a.id,ownerScope:I.scope,sourceObjectId:I.gameObjectId,sourceBindingPath:I.bindingPath,slotId:I.slotId,ownerNodePath:I.ownerNodePath,prefabAssetId:I.prefabAssetId,prefabNodeId:I.prefabNodeId}).filter(A=>typeof A[1]=="string"&&A[1].length>0))}))},value:s.length,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:0,tooltip:s.length>0?"\u67E5\u770B\u4F7F\u7528\u5F53\u524D\u6750\u8D28\u7684 Scene \u5BF9\u8C61\u548C Prefab \u8282\u70B9\u3002":"\u5F53\u524D\u672A\u88AB\u4EFB\u4F55\u5BF9\u8C61\u6216 Prefab \u4F7F\u7528\u3002",document:e}]});let y=r.materialShaderDefinitions?.get(a.shaderId)??De(a.shaderId);for(let[I,P]of[...y?.inspector.sections??[]].sort((A,$)=>A.order-$.order||A.id.localeCompare($.id)).entries())AS(b,{id:`material${P.id.charAt(0).toUpperCase()}${P.id.slice(1)}`,title:P.title,order:P.order,properties:[...I===0?f.filter(A=>A.path===d):[],...f.filter(A=>A.controlOptions?.materialShaderSectionId===P.id)]});let E=new Set(b.flatMap(I=>I.properties.map(P=>P.path)));return AS(b,{id:"materialAdvanced",title:"Advanced",order:80,properties:f.filter(I=>!E.has(I.path))}),{targetIds:[t],activeId:t,label:a.name||a.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"materialAsset",capabilities:["material"],document:e},sections:b}}function Rw(e,t,r,n={},o){return kw(e,t,r,n,o,_e.getCachedUsageIndex(e))}function Cw(e,t,r={}){return Ow(e,t,r,_e.getCachedUsageIndex(e))}var vw={createArtistMaterialInspectorSectionsWithCachedUsage:Rw,createEditorSceneMaterialAssetInspectorObjectWithCachedUsage:Cw},iu=vw;function AS(e,t){t.properties.length!==0&&e.push({...t,placement:"body",persistence:t.properties.some(r=>r.persistence==="document")?"document":"readonly",collapsedByDefault:!1})}function Gw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var DS="modelAsset::";function jw(e){return e.startsWith(DS)&&e.slice(DS.length).trim()||null}function MS(e,t,r={}){let n=jw(t),o=n?Nw(e,n,r.modelAssets):null;if(!o)return null;let a=Lw(o),i=[Fw(o)];return i.push(_w(e,o,a,r)),{targetIds:[t],activeId:t,label:o.displayName??o.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"modelAsset",capabilities:["asset","materialSlots"],document:e},sections:i}}function Nw(e,t,r){let n=e.assets.find(a=>a.id===t);if(n&&n.type!=="glb")return null;let o=r?.find(a=>a.assetId===t&&a.type==="glb");return o?Fr(n??{id:t,type:"glb"},o):n??null}function Fw(e){let t=zw(e.metadata?.relativePath);return{id:"modelAssetSummary",title:"Model Asset",order:10,regionId:Li,persistence:"readonly",collapsedByDefault:!1,properties:[Ra(`assets.${e.id}.displayName`,"\u540D\u79F0",e.displayName??e.id,0),Ra(`assets.${e.id}.id`,"Asset ID",e.id,1),Ra(`assets.${e.id}.type`,"\u683C\u5F0F","GLB / glTF",2),...t?[Ra(`assets.${e.id}.relativePath`,"\u6E90\u6587\u4EF6",t,3)]:[]]}}function _w(e,t,r,n){let o=`\u6750\u8D28\u63D2\u69FD (${r.length})`;if(r.length===0)return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:"\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",persistence:"readonly",collapsedByDefault:!1,properties:[Ra(`assets.${t.id}.materialSlots.empty`,"\u89E3\u6790\u7ED3\u679C","\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",0)]};let a=r.map((s,c)=>$w(s,c,n)),i={path:`assets.${t.id}.materialSlots`,label:"GLB \u6E90\u6750\u8D28",valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:r.length,slots:a},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:"\u5F53\u524D\u6765\u6E90",slotId:"Slot ID",ownerNodePath:"\u8282\u70B9\u8DEF\u5F84",sourceMaterial:"\u6E90\u6750\u8D28",primitive:"Primitive",triangles:"\u4E09\u89D2\u9762",bounds:"Bounds",bindingPath:"\u7ED1\u5B9A\u8DEF\u5F84"},slots:a},tags:["Asset","MaterialSlot","Readonly"],tooltip:"GLB / glTF \u6587\u4EF6\u4E2D\u89E3\u6790\u51FA\u7684\u53EA\u8BFB\u6750\u8D28\u63D2\u69FD\u3002",document:e};return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:`${r.length} \u4E2A\u5DF2\u89E3\u6790\u6E90\u63D2\u69FD`,persistence:"readonly",collapsedByDefault:!1,properties:[i]}}function $w(e,t,r){let n=e.sourceSurfaces[0],o=nt(e),a=n.sourceMaterialIndex??o[0],i=a==null?e.materialNames?.[0]??e.materialName??null:xn(e,a),s=a==null?null:Io(e,a)?.profile??null,c=e.label||i||`Material Slot ${t+1}`;return{key:e.slotId,label:c,slotId:e.slotId,sourceSurfaces:structuredClone(e.sourceSurfaces),ownerNodePath:n.ownerNodePath,materialLabel:i??c,materialMeta:"\u7EE7\u627F GLB \u6E90\u6750\u8D28",...s?{materialPreview:Bt(s,r)}:{},...a==null?{}:{sourceMaterialIndex:a},...o.length>0?{sourceMaterialIndices:o}:{},...i?{sourceMaterialName:i}:{},...e.materialNames?.length?{materialNames:e.materialNames}:{},...e.sourceSurfaces.length===1&&typeof n.triangleCount=="number"?{triangleCount:n.triangleCount}:{},...e.sourceSurfaces.length===1&&n.boundingBox?{boundingBox:n.boundingBox}:{}}}function Lw(e){return(Array.isArray(e.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(no).filter(r=>!!r)}function Ra(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function zw(e){return typeof e=="string"&&e.trim()?e.trim():""}function Ca(e,t,r,n={}){if(t.type==="prefab"){let s=wS(e,t),c=s?Fr(s,t):su(t),d=OS(e,t,c,r,n),u=Vw(s?e.assets.map(l=>l.id===c.id?c:l):[...e.assets,c],c);return{document:{...e,assets:u,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,d]}},gameObject:d}}let o=wS(e,t),a=o?Fr(o,t):su(t),i=t.type==="texture"?Bw(e,t,a.id,r,n):kS(e,t,a.id,r,n);return{document:{...e,assets:o?e.assets.map(s=>s.id===a.id?a:s):[...e.assets,a],scene:{...e.scene,gameObjects:[...e.scene.gameObjects,i]}},gameObject:i}}function Bw(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=So(a,yo(i)),c=fe(e),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,kind:"transform",...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},metadata:{...t.metadata??{},assetId:t.assetId,assetType:"texture"},components:[Mt(d),{type:"ImageRenderer",assetId:r,size:{width:1,height:1}}]}}function su(e){return{id:e.assetId,guid:e.guid,type:e.type,displayName:e.displayName,category:e.category,warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:Js(e.defaults),prefab:Js(e.prefab),external:Js(e.external),metadata:Js(e.metadata)}}function kS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=So(a,yo(i)),c=fe(e),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},components:[Mt(d),{type:"ModelRenderer",assetId:r}]}}function OS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=So(a,yo(i)),c=fe(e),d=du(e,c,n,o);return eg({id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},prefabAsset:r,transform:Mt(d),metadata:{...t.metadata??{},assetId:t.assetId,assetType:"prefab"}})}function cu(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function wS(e,t){return e.assets.find(r=>r.id===t.assetId||r.guid&&r.guid===t.guid)}function Vw(e,t){let r=la(t);if(!r||e.some(a=>a.id===r))return[...e];let n=t.prefab?.sourceAssetGuid,o=!!n&&!e.some(a=>a.guid===n);return[...e,{id:r,...o?{guid:n}:{},type:"glb",displayName:r,category:"Model",metadata:{sourcePrefabId:t.id}}]}function du(e,t,r,n){let o=Wl(e,r);if(!t)return o;let a=n.resolveLocalTransform?.({document:e,parentId:t,worldTransform:o})??ur(e,t,o);if(!a)throw new Error(`Cannot resolve parent-local asset placement transform for ${t}.`);return a}function Js(e){return e==null?void 0:structuredClone(e)}function Uw(e){return!!e&&tt(e)}function mu(e,t,r={}){let n=t.type==="document.replace"?t.document:CS({document:e,patch:t.patch,options:r});return r.normalizeDocument?.(n,t)??n}function CS(e){let{document:t,patch:r,options:n={}}=e;if(r.kind==="serialized-property")return Ga({document:t,patch:r,validateField:n.serializedProperty?.validateField});if(r.kind==="game-object.field")return Mn(t,r.targetId,r.path,r.value,n.field);if(r.kind==="game-object.field-batch")return va(t,r.targetIds,r.path,r.value,n.field);if(r.kind==="game-object.create-from-asset")return Ca(t,r.assetItem,r.placement,{...n.assetPlacement??{},...r.name?{name:r.name}:{}}).document;if(r.kind==="game-object.transform")return me(r.targetId)?t:hn(t,r.targetId,{transform:r.transform});if(r.kind==="game-object.transform-batch")return r.targets.reduce((o,a)=>{if(me(a.targetId))return o;let i=_(o,a.targetId),s=i?G(i):null;if(!s)return o;if(Uw(a.transform))return hn(o,a.targetId,{transform:a.transform});if(Ee(s))return o;let c=a.transform;return hn(o,a.targetId,{position:c.position?{...s.position,...c.position}:void 0,rotation:c.rotation?{...s.rotation,...c.rotation}:void 0,scale:c.scale?{...ot(s,"scale"),...c.scale}:void 0})},t);if(r.kind==="game-object.duplicate-selection"){let o=new Set(t.scene.gameObjects.map(l=>l.id)),a=n.isProtectedDuplicateSource??Kw,i=new Set(t.scene.gameObjects.filter(l=>a(l,t)).map(l=>l.id)),s=new Set,c=[];for(let l of r.gameObjects)o.has(l.id)||s.has(l.id)||Z(l)||a(l,t)||(s.add(l.id),c.push(l));let d=Ww(c,o,i);if(d.length===0)return t;let u=[...t.scene.gameObjects,...d];return{...t,scene:{...t.scene,gameObjects:r.order?lu(u,r.order):u}}}if(r.kind==="game-object.rename"){let o=r.name.trim();if(!o)return t;let a=t.scene.gameObjects.find(i=>i.id===r.targetId);return!a||a.name===o?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(i=>i.id===r.targetId?{...i,name:o}:i)}}}if(r.kind==="game-object.create-group"||r.kind==="game-object.create-primitive")return t.scene.gameObjects.some(o=>o.id===r.gameObject.id)?t:{...t,scene:{...t.scene,gameObjects:[...t.scene.gameObjects,r.gameObject]}};if(r.kind==="game-object.delete-subtree"){if(r.targetIds.some(me))return t;let o=wt(t,r.targetIds);if(o.size===0)return t;let a=n.isProtectedDeleteTarget??Hw;return t.scene.gameObjects.some(i=>o.has(i.id)&&a(i,t))?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.filter(i=>!o.has(i.id))}}}if(r.kind==="game-object.reparent"){if(me(r.targetId))return t;let o=t.scene.gameObjects.find(c=>c.id===r.targetId);if(!o)return t;let a=r.transform?mr(r.transform):null;if(r.transform&&!a)return t;let i=!!a&&!RS(G(o),a);if(o.parentId===r.parentId&&!i)return t;let s={...o,parentId:r.parentId,components:i?o.components.map(c=>c.type==="Transform"?a:c):o.components};return{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(c=>c.id===r.targetId?s:c)}}}if(r.kind==="game-object.hierarchy-move"){let o=r.moves.filter(l=>!me(l.targetId)),a=new Map;for(let l of o){let m=mr(l.transform);if(!m)return t;a.set(l.targetId,m)}let i=new Map(o.map(l=>[l.targetId,l]));if(i.size===0)return t;let s=!1,c=t.scene.gameObjects.map(l=>{let m=i.get(l.id);if(!m)return l;let f=a.get(m.targetId),S=!RS(G(l),f);if(l.parentId===m.parentId&&!S)return l;let g={...l,parentId:m.parentId,components:S?l.components.map(b=>b.type==="Transform"?f:b):l.components};return s=!0,g}),d=lu(c,r.order),u=d.some((l,m)=>l!==t.scene.gameObjects[m]);return!s&&!u?t:{...t,scene:{...t.scene,gameObjects:d}}}if(r.kind==="game-object.group-selection"){if(Z(r.gameObject)||t.scene.gameObjects.some(s=>s.id===r.gameObject.id))return t;let o=new Set(r.childIds.filter(s=>!me(s)));if(o.size===0)return t;let a=new Map;for(let[s,c]of Object.entries(r.childTransforms)){if(!o.has(s))continue;let d=mr(c);if(!d)return t;a.set(s,d)}let i=t.scene.gameObjects.map(s=>{if(!o.has(s.id))return s;let c=a.get(s.id);return{...s,parentId:r.gameObject.id,components:c?s.components.map(d=>d.type!=="Transform"?d:c):s.components}});return{...t,scene:{...t.scene,gameObjects:lu([...i,r.gameObject],r.order)}}}return t}function Kw(e){return Dt(e)}function Hw(e){return At(e)}function Ww(e,t,r){let n=new Map(e.map(a=>[a.id,a])),o=!0;for(;o;){o=!1;for(let a of[...n.values()])!a.parentId||n.has(a.parentId)||t.has(a.parentId)&&!r.has(a.parentId)||(n.delete(a.id),o=!0)}return e.filter(a=>n.has(a.id))}function lu(e,t){let r=new Map(e.map(a=>[a.id,a])),n=[],o=new Set;for(let a of t){if(o.has(a))continue;let i=r.get(a);i&&(n.push(i),o.add(a))}return[...n,...e.filter(a=>!o.has(a.id))]}function RS(e,t){if(!e)return!1;let r=Ee(e),n=Ee(t);return r||n?r&&n&&e.matrix.every((o,a)=>o===t.matrix[a]):uu(e.position,t.position)&&uu(e.rotation,t.rotation)&&uu(ot(e,"scale"),ot(t,"scale"))}function uu(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}var qw="main_camera",Jw="environment_light",Xw="sun_light",Xs={projection:"orthographic",alpha:3.9269908169872414,beta:.8,radius:14,orthoSize:6,fov:.85,targetOffset:{x:0,y:0,z:0},minZ:1,maxZ:1e4,lowerBetaLimit:.8,upperBetaLimit:.8,lowerRadiusLimit:14,upperRadiusLimit:14,inertia:.9,targetScreenOffset:{x:0,y:0},inspectorLanguage:"zh"},Fa={type:"directional",intensity:2,direction:{...gs},diffuseColor:{r:1,g:1,b:1},inspectorLanguage:"zh"},wn={type:"hemispheric",intensity:.8,diffuseColor:{r:1,g:1,b:1},groundColor:{r:.48,g:.52,b:.62},inspectorLanguage:"zh"};function GS(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function jS(e){let t=bu({...e,kind:"transform",transformType:"camera",camera:_a(e.camera)});return delete t.light,delete t.primitive,Su(t,e)?e:t}function gu(e,t){let r=bu({...e,name:t==="hemispheric"?"Environment Light":"Directional Light",kind:"transform",transformType:"light",light:kn(e.light,t)});return delete r.camera,delete r.primitive,Su(r,e)?e:r}function NS(e){let t=bu({...e,kind:"transform",transformType:"plain"});return delete t.camera,delete t.light,delete t.primitive,Su(t,e)?e:t}function bu(e){return G(e)?e:{...e,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},...e.components]}}function _a(e){let t=Xs;return{...t,...e??{},projection:Yw(e?.projection),fov:ja(e?.fov,t.fov??.85),targetOffset:tk(e?.targetOffset)?{...e.targetOffset}:{...t.targetOffset??{x:0,y:0,z:0}},minZ:ja(e?.minZ,t.minZ??1),maxZ:ja(e?.maxZ,t.maxZ??1e4),lowerBetaLimit:Na(e?.lowerBetaLimit,t.lowerBetaLimit??t.beta),upperBetaLimit:Na(e?.upperBetaLimit,t.upperBetaLimit??t.beta),lowerRadiusLimit:ja(e?.lowerRadiusLimit,t.lowerRadiusLimit??t.radius),upperRadiusLimit:ja(e?.upperRadiusLimit,t.upperRadiusLimit??t.radius),inertia:Qw(e?.inertia,t.inertia??.9),targetScreenOffset:ek(e?.targetScreenOffset)?{...e.targetScreenOffset}:{...t.targetScreenOffset??{x:0,y:0}},inspectorLanguage:Zw(e?.inspectorLanguage)}}function FS(e,t){return vS(e,t,{valueField:"beta",lowerField:"lowerBetaLimit",upperField:"upperBetaLimit",minValue:Number.NEGATIVE_INFINITY}),vS(e,t,{valueField:"radius",lowerField:"lowerRadiusLimit",upperField:"upperRadiusLimit",minValue:.001}),e}function vS(e,t,r){let n=`camera.${r.valueField}`,o=`camera.${r.lowerField}`,a=`camera.${r.upperField}`,i=Na(e[r.valueField],Xs[r.valueField]),s=Na(e[r.lowerField],i),c=Na(e[r.upperField],i);Number.isFinite(r.minValue)&&(i=Math.max(r.minValue,i),s=Math.max(r.minValue,s),c=Math.max(r.minValue,c)),c<s&&(t===a?s=c:c=s),t===o||t===a?i=Math.min(c,Math.max(s,i)):t===n&&(i<s&&(s=i),i>c&&(c=i)),e[r.valueField]=i,e[r.lowerField]=s,e[r.upperField]=c}function Yw(e){return e==="perspective"?"perspective":"orthographic"}function Zw(e){return e==="en"?"en":"zh"}function _S(e){return e==="en"?"en":"zh"}function Na(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function ja(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function Qw(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:t}function ek(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)}function tk(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)&&typeof t.z=="number"&&Number.isFinite(t.z)}function $S(e){return e.maxZ!=null&&e.minZ!=null&&e.maxZ<=e.minZ||e.upperBetaLimit!=null&&e.lowerBetaLimit!=null&&e.upperBetaLimit<e.lowerBetaLimit||e.upperRadiusLimit!=null&&e.lowerRadiusLimit!=null&&e.upperRadiusLimit<e.lowerRadiusLimit}function rk(e,t){return e?.type==="hemispheric"?"hemispheric":e?.type==="directional"?"directional":t}function kn(e,t="directional"){return rk(e,t)==="hemispheric"?ok(e):nk(e)}function nk(e){let t=Fa,r=e?.type==="directional"?e:void 0;return{...t,...r??{},type:"directional",direction:{...t.direction,...r?.direction??{}},diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,inspectorLanguage:_S(LS(r))}}function ok(e){let t=wn,r=e?.type==="hemispheric"?e:void 0;return{...t,...r??{},type:"hemispheric",diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,groundColor:r?.groundColor?{...t.groundColor,...r.groundColor}:t.groundColor,inspectorLanguage:_S(LS(r))}}function LS(e){return e&&typeof e=="object"?e.inspectorLanguage:void 0}function Su(e,t){return JSON.stringify(e)===JSON.stringify(t)}function zS(e,t,r){return{id:yu(t,qw,r),guid:r.createGameObjectGuid(),name:"Main Camera",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"camera",camera:_a(void 0),components:[{type:"Transform",position:{x:0,y:5,z:-8},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function BS(e,t,r){return{id:yu(t,Xw,r),guid:r.createGameObjectGuid(),name:"Directional Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:kn(void 0,"directional"),components:[{type:"Transform",position:{x:0,y:4,z:-3},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function VS(e,t,r){return{id:yu(t,Jw,r),guid:r.createGameObjectGuid(),name:"Environment Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:kn(void 0,"hemispheric"),components:[{type:"Transform",position:{x:0,y:3,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function yu(e,t,r){let n=r.createUniqueId([...e],t);return e.add(n),n}function KS(e,t){let r=t.name.trim();if(!r)return null;let n=_(e,t.id);return!n||n.name===r?null:{label:`Rename ${n.name??n.id} to ${r}`,patch:{kind:"game-object.rename",targetId:t.id,name:r},changedId:t.id}}function HS(e,t){let r=ey(e,t);if(r===null)return null;let n=st(Qs(e),t.name,{fallbackName:"Empty"}),o=qS(e.scene.gameObjects.map(i=>i.id),t.objectId,n);if(!o)return null;let a={id:o,guid:he(),name:n,kind:"transform",transformType:"plain",...r?{parentId:r}:{},active:!0,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Create empty ${n}`,patch:{kind:"game-object.create-group",gameObject:a},createdId:o,changedIds:[o]}}function WS(e,t){let r=bk(t.shape);if(!r)return null;let n=lk(e,t);if(n===null)return null;let o=st(Qs(e),t.name,{fallbackName:Sk(r)}),a=qS(e.scene.gameObjects.map(c=>c.id),t.objectId,o);if(!a)return null;let i=yk(r),s={id:a,guid:he(),name:o,kind:"primitive",...n?{parentId:n}:{},active:!0,primitive:{shape:r},shadow:{cast:"none",receive:"none"},components:[Mt(i)]};return{label:`Create ${o}`,patch:{kind:"game-object.create-primitive",gameObject:s},createdId:a,changedIds:[a]}}function qS(e,t,r){return t===void 0?it(e,r):it([],t)===t&&!e.includes(t)?t:null}function JS(e,t){if(t.ids.some(me))return null;let r=wt(e,t.ids);if(r.size===0||e.scene.gameObjects.some(a=>r.has(a.id)&&At(a)))return null;let n=pk(e,r,t.activeId??null),o=[...r];return{label:`Delete ${o.length} GameObject${o.length===1?"":"s"}`,patch:{kind:"game-object.delete-subtree",targetIds:t.ids},deletedIds:o,fallbackSelectionId:n}}function Eu(e,t,r={}){if(t.placement!=="inside")return{ok:!1,reason:"Only inside reparent is supported."};let n=_(e,t.draggedId),o=_(e,t.targetId);return n?Z(n)?{ok:!1,reason:"Root GameObject cannot be reparented."}:o?G(n)?xt(o)?n.id===o.id?{ok:!1,reason:"GameObject cannot be parented to itself."}:gk(e,n.id,o.id)?{ok:!1,reason:"GameObject cannot be parented to its descendant."}:t.preserveWorldTransform!==!1&&!Zs(e,n.id,o.id,void 0,{preserveWorldPolicy:r})?{ok:!1,reason:"Cannot preserve world transform under the target parent."}:{ok:!0}:{ok:!1,reason:`${t.targetId} cannot have children.`}:{ok:!1,reason:`${t.draggedId} has no Transform to preserve.`}:{ok:!1,reason:`Parent GameObject not found: ${t.targetId}`}:{ok:!1,reason:`GameObject not found: ${t.draggedId}`}}function XS(e,t,r={}){if(!Eu(e,t,r).ok)return null;let o=_(e,t.draggedId);if(!o||!G(o))return null;let a=t.targetId,i=t.preserveWorldTransform===!1?qt(o):Zs(e,o.id,a,void 0,{preserveWorldPolicy:r});return!i||o.parentId===a&&iy(qt(o),i)?null:{label:`Reparent ${o.name??o.id}`,patch:{kind:"game-object.reparent",targetId:o.id,parentId:a,transform:i},changedIds:[o.id]}}function Iu(e,t,r={}){let n=fr(e),o=Zf(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(me))return{ok:!1,reason:"Root GameObject cannot be moved."};let i=xu(e,t);if(i&&!Au(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1)for(let s of a){let c=_(e,s);if(!c)return{ok:!1,reason:`GameObject not found: ${s}`};if(!G(c))return{ok:!1,reason:`${s} has no Transform to preserve.`};if(!Zs(e,s,i,t,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}return{ok:!0}}function YS(e,t,r={}){if(!Iu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids),i=xu(e,t),s=a.map(l=>{let m=_(e,l);if(!m||!G(m))return null;let f=t.preserveWorldTransform===!1?qt(m):Zs(e,l,i,t,r),S=f?Sn(f):null;return S?i?{targetId:l,parentId:i,transform:S}:{targetId:l,transform:S}:null}).filter(l=>!!l);if(s.length!==a.length)return null;let c=uk(e,a,t),d=e.scene.gameObjects.map(l=>l.id);return!s.some(l=>{let m=_(e,l.targetId);return!m||m.parentId!==l.parentId||!iy(qt(m),l.transform)})&&hk(d,c)?null:{label:`Move ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.hierarchy-move",moves:s,order:c},changedIds:a}}function Pu(e,t,r={}){let n=fr(e),o=Qf(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(me))return{ok:!1,reason:"Root GameObject cannot be grouped."};let i=ty(e,t.parentId??null);if(i&&!Au(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1){let s=ay(e,a),c=s?{position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}:null;if(!c||!Ia(e,i,c,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."};for(let d of a){let u=_(e,d);if(!u)return{ok:!1,reason:`GameObject not found: ${d}`};if(!G(u))return{ok:!1,reason:`${d} has no Transform to preserve.`};let l=ke(e,d);if(!l||!ry(c,l,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}}return{ok:!0}}function ZS(e,t,r={}){if(!Pu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids);if(a.length===0)return null;let i=ty(e,t.parentId??null),s=ay(e,a);if(!s)return null;let c={position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},d=Ia(e,i,c,r);if(!d)return null;let u=st(Qs(e),t.name,{fallbackName:"Parent"}),l=it(e.scene.gameObjects.map(g=>g.id),u),m={id:l,guid:he(),name:u,kind:"transform",transformType:"plain",...i?{parentId:i}:{},active:!0,components:[Mt(d)]},f={};for(let g of a){let b=_(e,g);if(!b)return null;if(t.preserveWorldTransform===!1){f[g]=qt(b);continue}let y=ke(e,g);if(!y)return null;let E=ry(c,y,r);if(!E)return null;f[g]=E}let S=mk(e,l,a,t.insertBeforeId??null);return{label:`Create Parent for ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.group-selection",gameObject:m,childIds:a,childTransforms:f,order:S},createdId:l,changedIds:[l,...a]}}function QS(e){let t=e.isProtectedDuplicateSource??ak,r=fr(e.document),n=new Set(St(r,e.targetIds).filter(b=>{let y=_(e.document,b);return!!y&&!Z(y)&&!t(y,e.document)&&!sk(e.document,y.id,t)})),o=Tu(e.document).filter(b=>n.has(b));if(o.length===0)return null;let a=wt(e.document,o),i=new Map,s=new Set(e.document.scene.gameObjects.map(b=>b.id)),c=new Map,d=Qs(e.document),u=ck(e.document,o,a,t);for(let b of u){let y=_(e.document,b),E=st(d,y.name,{alwaysAppendSuffix:!0,fallbackName:y.id});d.push(E);let I=it([...s],E);s.add(I),i.set(y.id,I),c.set(y.id,E)}let l=u.map(b=>_(e.document,b)).filter(b=>!!b&&i.has(b.id)).map(b=>{let y=structuredClone(b);return y.id=i.get(b.id),y.guid=he(),y.name=c.get(b.id),y.parentId&&i.has(y.parentId)&&(y.parentId=i.get(y.parentId)),y});if(l.length===0)return null;let m=l.map(b=>b.id),f=o.map(b=>i.get(b)).filter(b=>!!b),S=ik(e.document,o,e.activeId),g=S&&i.has(S)?i.get(S):f[f.length-1]??m[m.length-1]??null;return{label:`Duplicate ${m.length} object${m.length===1?"":"s"}`,patch:{kind:"game-object.duplicate-selection",gameObjects:l,order:dk(e.document,o,i)},createdIds:m,selectedIds:f,activeId:g,changedIds:m}}function ak(e){return Dt(e)}function ik(e,t,r){if(r&&t.includes(r))return r;if(r){for(let n of t)if(wt(e,[n]).has(r))return n}return t[t.length-1]??null}function sk(e,t,r){let n=new Map(e.scene.gameObjects.map(i=>[i.id,i])),o=new Set,a=n.get(t);for(;a?.parentId;){if(o.has(a.parentId))return!0;o.add(a.parentId);let i=n.get(a.parentId);if(!i)return!1;if(r(i,e))return!0;a=i}return!1}function ck(e,t,r,n){let o=Tu(e),a=new Map(o.map((l,m)=>[l,m])),i=new Map(e.scene.gameObjects.map(l=>[l.id,l])),s=new Map;for(let l of e.scene.gameObjects){let m=l.parentId&&i.has(l.parentId)?l.parentId:null,f=s.get(m)??[];f.push(l.id),s.set(m,f)}for(let l of s.values())l.sort((m,f)=>(a.get(m)??Number.MAX_SAFE_INTEGER)-(a.get(f)??Number.MAX_SAFE_INTEGER));let c=[],d=new Set,u=l=>{if(d.has(l)||!r.has(l))return;d.add(l);let m=_(e,l);if(!(!m||Z(m)||n(m,e))){c.push(m.id);for(let f of s.get(m.id)??[])u(f)}};for(let l of t)u(l);return c}function dk(e,t,r){let n=Tu(e),o=new Map;for(let i of t){let s=wt(e,[i]),c=n.filter(l=>s.has(l)),d=c.map(l=>r.get(l)).filter(l=>!!l),u=c[c.length-1];u&&d.length>0&&o.set(u,d)}let a=[];for(let i of n){a.push(i);let s=o.get(i);s&&a.push(...s)}return a}function Tu(e){let t=e.scene.gameObjects,r=new Map(t.map(c=>[c.id,c])),n=new Map;for(let c of t){let d=c.parentId&&r.has(c.parentId)?c.parentId:null,u=n.get(d)??[];u.push(c.id),n.set(d,u)}let o=[],a=new Set,i=c=>{if(!(a.has(c)||!r.has(c))){a.add(c),o.push(c);for(let d of n.get(c)??[])i(d)}},s=fe(e);s&&i(s);for(let c of n.get(null)??[])i(c);for(let c of t)i(c.id);return o}function ey(e,t){if(t.parentId){let n=_(e,t.parentId);return n&&xt(n)?n.id:null}let r=t.activeId?_(e,t.activeId):null;if(r&&xt(r))return r.id;if(r?.parentId){let n=_(e,r.parentId);if(n&&xt(n))return n.id}return fe(e)}function lk(e,t){return t.parentId===null?fe(e):ey(e,t)}function xu(e,t){if(t.placement==="root")return fe(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let r=t.targetId?_(e,t.targetId):null;return t.parentId??r?.parentId??fe(e)}function ty(e,t){return t&&Au(e,t)?t:fe(e)}function Au(e,t){let r=_(e,t);return!!r&&xt(r)}function Zs(e,t,r,n,o={}){let a=ke(e,t);if(!a)return null;let i=_(e,t);if(!i)return null;let s=n?o.resolveLocalTransform?.({document:e,intent:n,gameObject:i,parentId:r,worldTransform:a}):null;if(s)return Sn(s);let c=Ia(e,r,a,o.preserveWorldPolicy);return c?Sn(c):null}function ry(e,t,r={}){let n=Ui(r),o=to(e,t,{allowMatrixFallback:n.allowMatrixFallback});return o?Sn(o):null}function uk(e,t,r){let n=ny(e,t),o=new Set(n),a=e.scene.gameObjects.map(s=>s.id).filter(s=>!o.has(s)),i=fk(e,a,{placement:r.placement,targetId:r.targetId??null,beforeId:r.beforeId??null,afterId:r.afterId??null,parentId:xu(e,r)});return oy(a,n,i)}function mk(e,t,r,n){let o=ny(e,r),a=new Set(o),i=e.scene.gameObjects.map(l=>l.id),s=i.filter(l=>!a.has(l)),c=Math.min(...r.map(l=>i.indexOf(l)).filter(l=>l>=0)),d=Number.isFinite(c)?s.filter(l=>i.indexOf(l)<c).length:s.length,u=n?Math.max(0,s.indexOf(n)):d;return oy(s,[t,...o],u)}function ny(e,t){let r=wt(e,[...t]);return e.scene.gameObjects.map(n=>n.id).filter(n=>r.has(n))}function fk(e,t,r){return r.beforeId?US(t.indexOf(r.beforeId),t.length):r.afterId?Ys(e,t,r.afterId):r.placement==="before"&&r.targetId?US(t.indexOf(r.targetId),t.length):r.placement==="after"&&r.targetId||r.placement==="inside"&&r.targetId?Ys(e,t,r.targetId):r.placement==="root"?t.length:r.parentId?Ys(e,t,r.parentId):t.length}function Ys(e,t,r){let n=wt(e,[r]),o=t.indexOf(r);if(o<0)return t.length;for(let a=o+1;a<t.length&&n.has(t[a]);a+=1)o=a;return o+1}function oy(e,t,r){let n=Math.max(0,Math.min(r,e.length));return[...e.slice(0,n),...t,...e.slice(n)]}function US(e,t){return e>=0?e:t}function ay(e,t){let r=t.map(o=>ke(e,o)).filter(o=>!!o);if(r.length===0)return null;let n=r.map(Vi);return{x:n.reduce((o,a)=>o+a.x,0)/n.length,y:n.reduce((o,a)=>o+a.y,0)/n.length,z:n.reduce((o,a)=>o+a.z,0)/n.length}}function pk(e,t,r){let n=r?_(e,r):null;if(n?.parentId&&!t.has(n.parentId)&&_(e,n.parentId))return n.parentId;for(let o=e.scene.gameObjects.length-1;o>=0;o-=1){let a=e.scene.gameObjects[o];if(!t.has(a.id))return a.id}return null}function gk(e,t,r){let n=Ol(e),o=new Set,a=n.get(r);for(;a?.parentId&&!o.has(a.parentId);){if(a.parentId===t)return!0;o.add(a.parentId),a=n.get(a.parentId)}return!1}function bk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function Sk(e){return e[0].toUpperCase()+e.slice(1)}function yk(e){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function Qs(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function iy(e,t){return!It(e)||!It(t)?aa(Fe(e),Fe(t)):hu(e.position,t.position)&&hu(e.rotation,t.rotation)&&hu(e.scale,t.scale)}function hu(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function hk(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function Mu(e){return{getHierarchyItems(t){return Du(t,e)},normalizeHierarchyDocument(t){return vl(t)},createRenamePatch(t,r){return br(KS(t,r))},createCreateGroupPatch(t,r){return br(HS(t,r))},createCreatePrimitivePatch(t,r){return br(WS(t,r))},createDeleteSubtreePatch(t,r){let n=JS(t,r);if(!n)return null;let o=new Set(n.deletedIds);return t.scene.gameObjects.some(a=>o.has(a.id)&&e.isProtectedSystemGameObject(a))?null:br(n)},collectSubtreeIdList(t,r){return pr(t,r)},validateReparent(t,r){let n=e.findGameObject(t,r.draggedId),o=e.findGameObject(t,r.targetId);return n&&e.isProtectedSystemGameObject(n)?{ok:!1,reason:"Protected system GameObject cannot be reparented."}:o&&e.isProtectedSystemGameObject(o)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Eu(t,r)},createReparentPatch(t,r){return br(XS(t,r))},validateHierarchyMove(t,r){let n=Du(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be moved."};let a=Ek(t,r,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Iu(t,r)},createHierarchyMovePatch(t,r){return br(YS(t,r))},validateGroupSelection(t,r){let n=Du(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be grouped."};let a=Ik(t,r.parentId??null,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Pu(t,r)},createGroupSelectionPatch(t,r){return br(ZS(t,r))},createDuplicateSelectionPatch(t){let r=t.targetIds.filter(n=>{let o=e.findGameObject(t.document,n);return!!o&&!e.isProtectedSystemGameObject(o)});return br(QS({...t,targetIds:r,isProtectedDuplicateSource:n=>e.isProtectedSystemGameObject(n)}))},createPlacedAssetPatch(t){return br(Hl(t))}}}function Du(e,t){let r=fr(e),n=new Map(e.scene.gameObjects.map(a=>[a.id,a])),o=[];for(let a of r){let i=n.get(a.id)??null;o.push(t.decorateHierarchyItem?.({item:a,gameObject:i,document:e})??a),i&&o.push(...t.collectHierarchyItemChildren?.({item:a,gameObject:i,document:e})??[])}return o}function Ek(e,t,r){if(t.placement==="root")return r.resolveRootContainerId(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let n=t.targetId?r.findGameObject(e,t.targetId):null;return t.parentId??n?.parentId??r.resolveRootContainerId(e)}function Ik(e,t,r){let n=t?r.findGameObject(e,t):null;return n&&xt(n)?n.id:r.resolveRootContainerId(e)}function br(e){return e?{...e,patch:e.patch}:null}function wu(e,t){let r=t.ensureGameObjectGuids(e),n=t.resolveRootContainerId(r),o=!1,a=!1,i=!1,s=r!==e,c=t.ensureDefaultMaterialAssets(r.scene.materialAssets??[]);s=s||c!==r.scene.materialAssets;let d=r.scene.gameObjects.map(S=>{if(S.id===t.systemDefaults.environmentLightId){a=!0;let g=t.systemDefaults.normalizeEnvironmentLightGameObject(S);return s=s||g!==S,g}if(S.id===t.systemDefaults.sunLightId){i=!0;let g=t.systemDefaults.normalizeSunLightGameObject(S);return s=s||g!==S,g}if(t.isCameraGameObject(S)){if(!o){o=!0;let g=t.systemDefaults.normalizeCameraGameObject(S);return s=s||g!==S,g}return s=!0,t.systemDefaults.normalizePlainTransformGameObject(S)}if(t.isLightGameObject(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=!0,g}if(!t.isCustomTransformType?.(S.transformType)&&Pk(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=s||g!==S,g}return S}),u={createGameObjectGuid:t.createGameObjectGuid,createUniqueId:t.createUniqueId},l=new Set(d.map(S=>S.id));o||(s=!0,d.push(t.systemDefaults.createDefaultCameraGameObject(n,l,u))),a||(s=!0,d.push(t.systemDefaults.createDefaultEnvironmentLightGameObject(n,l,u))),i||(s=!0,d.push(t.systemDefaults.createDefaultSunLightGameObject(n,l,u)));let m=t.normalizeMaterialBindings({...r,scene:{...r.scene,gameObjects:d,materialAssets:c}},c,d);c=m.materialAssets,d=m.gameObjects,s=s||m.changed;let f=s?{...r,scene:{...r.scene,gameObjects:d,materialAssets:c}}:r;return t.syncMarkerGraphDocument(f)}function Pk(e){return(e.kind==="transform"||e.transformType==="plain")&&!e.camera&&!e.light&&!e.primitive&&!e.prefab&&!e.marker&&!e.components.some(t=>t.type==="ModelRenderer"||t.type==="ImageRenderer")}function ku(e,t,r){let n=r.normalizeRootTransformDocument(Tk(e,t,r));return r.syncMarkerGraphDocument(r.ensureGameObjectGuids(r.normalizeDocumentAfterCommand(n,t)))}function ec(e){return{normalizeFieldValue:e.normalizeFieldValue,validateField:({document:t,gameObject:r,path:n,value:o})=>e.validateField(t,r,n,o),blockFieldPatch:({document:t,targetId:r,path:n,value:o})=>tc(t,r,n,o,e),normalizePrimitiveShape:e.normalizePrimitiveShape,mergeCameraDefaults:e.systemDefaults.mergeCameraDefaults,normalizeCameraAfterFieldPatch:(t,r)=>t&&e.systemDefaults.normalizeCameraAfterFieldPatch(t,r),mergeLightDefaults:e.systemDefaults.mergeLightDefaults,isCustomTransformType:e.isCustomTransformType,applyCustomTransformType:e.applyCustomTransformType,clearCustomTransformState:e.clearCustomTransformState,patchCustomTransformField:e.patchCustomTransformField}}function Ou(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return e;let i=yg(a,{...r===o.systemDefaults.horizontalLightAnglePath?{horizontalAngleDeg:n}:{},...r===o.systemDefaults.elevationLightAnglePath?{elevationAngleDeg:n}:{}});return i===a?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(s=>s.id===t?i:s)}}}function tc(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return!1;let i=o.isCameraGameObject(a),s=o.isLightGameObject(a),c=o.isProtectedSystemGameObject(a),d=a.id===o.systemDefaults.sunLightId&&a.light?.type==="directional"&&(r==="transform.rotation"||r.startsWith("transform.rotation."));if(r.startsWith("transform.")&&c&&!d||r.startsWith("camera.")&&!i)return!0;if(r.startsWith("camera.")&&i){let u={camera:o.systemDefaults.mergeCameraDefaults(a.camera)};if(Oe(u,r,n),u.camera&&(u.camera=o.systemDefaults.normalizeCameraAfterFieldPatch(u.camera,r),o.systemDefaults.hasInvalidCameraRelationships(u.camera)))return!0}return!!(r.startsWith("light.")&&!s||r==="light.type"&&(a.id===o.systemDefaults.environmentLightId&&n!=="hemispheric"||a.id===o.systemDefaults.sunLightId&&n!=="directional")||r==="transformType"&&(i&&n!=="camera"||s&&n!=="light"||!s&&n==="light"||n==="camera"&&!i&&o.hasCamera(e,t)))}function Tk(e,t,r){let n=t.type==="document.replace"?null:t.patch;if(n){if(n.kind==="scene.material-asset.field")return r.patchMaterialAssetField(e,n.materialAssetId,n.path,n.value);if(n.kind==="scene.material-asset.replace")return r.replaceMaterialAsset(e,n.materialAssetId,n.materialAsset);if(n.kind==="scene.material-asset.create")return r.addMaterialAsset(e,n.materialAsset);if(n.kind==="scene.material-asset.delete")return r.deleteMaterialAsset(e,n.materialAssetId);if(n.kind==="scene.material-asset.create-and-bind")return r.addMaterialAssetAndBind(e,n.targetId,n.bindingPath,n.materialAsset);if(n.kind==="scene.prefab-asset.create")return r.addPrefabAsset(e,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-asset.create-from-game-object"||n.kind==="scene.prefab-asset.duplicate")return r.addPrefabAsset(e,n.prefabAsset);if(n.kind==="scene.prefab-asset.field")return r.patchPrefabAssetField(e,n.assetId,n.path,n.value);if(n.kind==="scene.prefab-asset.replace")return r.replacePrefabAsset(e,n.assetId,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-material-asset.duplicate-and-bind")return r.addMaterialAssetAndBindPrefabOverride(e,n.assetId,n.bindingPath,n.materialAsset);let o=r.reduceExtensionPatch?.({document:e,patch:n,command:t});if(o)return o;if(n.kind==="game-object.field"&&r.isDirectionalLightAnglePath(n.path)||n.kind==="game-object.field"&&r.isCustomFieldPatchPath?.(n.path))return r.patchGameObjectField(e,n.targetId,n.path,n.value);if(n.kind==="game-object.rendering-alpha-index-migration")return Ak(e,n);if(n.kind==="scene.marker-graph")return r.reduceMarkerGraphPatch(e,n.command)}return mu(e,t,xk(r))}function xk(e){return{field:ec(e),serializedProperty:{validateField:e.validateSerializedPropertyField},assetPlacement:{createGameObjectGuid:e.createGameObjectGuid,resolveLocalTransform:({document:t,parentId:r,worldTransform:n})=>e.resolveLocalTransform({document:t,parentId:r,worldTransform:n})},isProtectedDuplicateSource:t=>e.isProtectedSystemGameObject(t),isProtectedDeleteTarget:t=>e.isProtectedSystemGameObject(t)}}function Ak(e,t){return Kl({document:e,targetIds:t.targetIds,renderingGroupId:t.renderingGroupId,fromAlphaIndex:t.fromAlphaIndex,toAlphaIndex:t.toAlphaIndex})}function To(e,t){let r=e.path,n=t.normalizeValue(r,e.value),o=t.parseMaterialAssetFieldPath(r);if(o){let l=t.normalizeMaterialAssetValue(o.fieldPath,n);if(!t.hasMaterialAsset(e.document,o.materialAssetId)||!t.validateMaterialAssetFieldValue(e.document,o.materialAssetId,o.fieldPath,l))return null;let m=t.collectMaterialAssetBindingIds(e.document,o.materialAssetId);return{label:`Patch material asset ${o.materialAssetId} ${o.fieldPath}`,patch:t.createMaterialAssetFieldPatch(o.materialAssetId,o.fieldPath,l),changedId:m[0]??e.targetId,changedIds:m,...o.fieldPath.startsWith("properties.")?{reprojectIds:m}:{}}}let a=t.findGameObject(e.document,e.targetId);if(!a)return null;let i=a.id,s=t.parseDuplicateMaterialAssetValue(n);if(s&&t.isMaterialBindingPath(r))return Dk(e.document,a,r,s,t);if(t.isRootTransformPath(i,r))return null;if(r==="marker.target.objectId"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTargetUpdateCommand(e.document,i,n);return l?sy(i,"marker.target",l,t):null}if(!t.validateValue(e.document,a,r,n).ok||t.blockFieldPatch(e.document,i,r,n))return null;if(r==="marker.type"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTypeUpdateCommand(e.document,i,n);return l?sy(i,"marker.type",l,t):null}if(t.isDirectionalLightAnglePath(r)&&typeof n=="number"&&Number.isFinite(n))return{label:`Patch ${i} ${r}`,patch:t.createDirectionalLightPatch(i,r,n),changedId:i,changedIds:[i],reprojectIds:[i]};let c=t.createCustomInspectorPropertyPatch?.({...e,gameObject:a,path:r,value:n});if(c)return c;let d=t.collectChangedIdsForFieldPath(e.document,i,r),u=t.isProjectionShapePath(r)||t.isArtistMaterialPatchPath(r)||t.isCustomProjectionPath?.(r)?[i]:void 0;return{label:`Patch ${i} ${r}`,patch:t.createGameObjectFieldPatch(i,r,n),changedId:i,changedIds:d,...u?{reprojectIds:u}:{}}}function rc(e,t,r,n,o){let a=o.patchCustomGameObjectField?.({document:e,targetId:t,path:r,value:n});if(a)return a;if(r.startsWith("metadata.")||o.isDirectionalLightAnglePath(r)){let s=o.findGameObject(e,t);if(!s)return e;let c=o.normalizeValue(r,n);return!o.validateValue(e,s,r,c).ok||o.blockFieldPatch(e,t,r,c)?e:o.isDirectionalLightAnglePath(r)&&typeof c=="number"&&Number.isFinite(c)?o.patchDirectionalLightAngleField(e,t,r,c):Mk(e,t,r,c,o)}let i=Mn(e,t,r,n,o.fieldMutationOptions);return o.normalizeAfterFieldPatch(i,t,r,n)}function cy(e,t,r,n,o){let a=Array.from(new Set(t.filter(Boolean)));if(a.length===0)return e;let i=o.patchCustomGameObjectsField?.({document:e,targetIds:a,path:r,value:n,patchSingle:(c,d,u,l)=>rc(c,d,u,l,o)});if(i)return i;if(r.startsWith("metadata."))return wk(e,a,r,n,o);if(o.isDirectionalLightAnglePath(r))return a.reduce((c,d)=>rc(c,d,r,n,o),e);let s=va(e,a,r,n,o.fieldMutationOptions);return a.reduce((c,d)=>o.normalizeAfterFieldPatch(c,d,r,n),s)}function sy(e,t,r,n){return{label:`Patch ${e} ${t}`,patch:n.createMarkerGraphPatch(r),changedId:e,changedIds:[e],reprojectIds:[e]}}function Dk(e,t,r,n,o){let a=Hb({document:e,gameObject:t,bindingPath:r,sourceMaterialAssetId:n,isBindingPathAllowed:s=>o.isMaterialBindingPathAllowed(t,s)});return a?{label:`Duplicate material ${o.findMaterialAssetName(e,n)??n} for ${t.name??t.id}`,patch:a.patch,changedId:a.changedId,changedIds:a.changedIds,createdId:a.createdId,reprojectIds:a.reprojectIds}:null}function Mk(e,t,r,n,o){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>{if(a.id!==t)return a;let i=structuredClone(a);return Oe(i,r,n),i.metadata&&Object.keys(i.metadata).length===0&&delete i.metadata,i})}}}function wk(e,t,r,n,o){let a=new Set(t),i=o.normalizeValue(r,n),s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id))return d;let u=d;if(!o.validateValue(e,u,r,i).ok||o.blockFieldPatch(e,d.id,r,i))return d;let l=structuredClone(d);return Oe(l,r,i),l.metadata&&Object.keys(l.metadata).length===0&&delete l.metadata,s=!0,l});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function ly(e){return{applySerializedPropertyPatch(t,r){if(e.isRootTransformPath(r.targetId,r.path))return t;let n={...r,value:bn(r.path,r.value)};return Ga({document:t,patch:n,validateField:e.validateSerializedPropertyField})},canCreateSerializedMultiPropertyPatch(t){return dy({document:t.document,targetIds:t.targetIds,activeId:t.activeId,path:t.path,value:e.getSerializedMultiPropertyProbeValue(t.path),services:e}).length>0},createSerializedMultiPropertyPatch(t){if(!e.isSerializedMultiFieldPath(t.path))return null;let r=bn(t.path,t.value),n=dy({...t,value:r,services:e});return n.length===0?null:{label:`Patch ${n.length} GameObjects ${t.path}`,patch:e.createFieldBatchPatch(n.map(o=>({targetId:o,path:t.path,value:r}))),changedIds:n,...e.isSerializedMultiProjectionPath(t.path)?{reprojectIds:n}:{}}}}}function dy(e){return e.services.isSerializedMultiFieldPath(e.path)?e.targetIds.filter(t=>{let r=e.services.findGameObject(e.document,t);return e.services.canPatchCustomSerializedMultiField?.({document:e.document,targetId:t,path:e.path,value:e.value})===!1||e.services.isSerializedMultiProjectionPath(e.path)&&(!r||e.services.isCameraGameObject(r)||e.services.isLightGameObject(r))?!1:!!e.services.createInspectorPropertyPatch({document:e.document,targetId:t,path:e.path,value:e.value})}):[]}var kk=/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/,Ok=/^transform\.(position|rotation|scale)$/,Rk=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function Mn(e,t,r,n,o={}){return Ck({document:e,targetId:t,path:r,value:n,options:o})}function va(e,t,r,n,o={}){let a=new Set(t.filter(Boolean));if(a.size===0)return e;let i=o.normalizeFieldValue?.(r,n)??n,s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id)||Ru(d.id,r))return d;let u=d;if(o.validateField?.({document:e,gameObject:u,path:r,value:i})?.ok===!1||o.blockFieldPatch?.({document:e,gameObject:u,targetId:d.id,path:r,value:i}))return d;let l=pu(u,r,i,o);return l===d?d:(s=!0,l)});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function fu(e,t,r={}){let n=new Map;for(let i of t){if(!i.objectId||i.changes.length===0)continue;let s=n.get(i.objectId)??[];s.push(...i.changes),n.set(i.objectId,s)}if(n.size===0)return e;let o=!1,a=e.scene.gameObjects.map(i=>{let s=n.get(i.id);if(!s?.length)return i;let c;for(let d of s){if(Ru(i.id,d.path))continue;let u=r.normalizeFieldValue?.(d.path,d.value)??d.value;r.validateField?.({document:e,gameObject:c??i,path:d.path,value:u})?.ok!==!1&&(r.blockFieldPatch?.({document:e,gameObject:c??i,targetId:i.id,path:d.path,value:u})||(c??=structuredClone(i),c=py(c,d.path,u,r,!0)))}return!c||JSON.stringify(c)===JSON.stringify(i)?i:(o=!0,c)});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function Ck(e){if(Ru(e.targetId,e.path))return e.document;let t=_(e.document,e.targetId);if(!t)return e.document;let r=e.options?.normalizeFieldValue?.(e.path,e.value)??e.value;if(e.options?.validateField?.({document:e.document,gameObject:t,path:e.path,value:r})?.ok===!1||e.options?.blockFieldPatch?.({document:e.document,gameObject:t,targetId:e.targetId,path:e.path,value:r}))return e.document;let n=pu(t,e.path,r,e.options);return n===t?e.document:{...e.document,scene:{...e.document.scene,gameObjects:e.document.scene.gameObjects.map(o=>o.id===e.targetId?n:o)}}}function pu(e,t,r,n={}){let o=py(e,t,r,n);return JSON.stringify(o)===JSON.stringify(e)?e:o}function py(e,t,r,n,o=!1){let a=o?e:structuredClone(e),i=t.startsWith("transform.rotation")?uy(a):null,s=t==="light.direction"||t.startsWith("light.direction.")?my(a):null;if(t==="name")return typeof r=="string"&&r.trim()?a.name=r.trim():delete a.name,a;if(t==="enabled")return a.active=r!==!1,a;if(t.startsWith("shadow."))return dn(a)&&vk(a,t,r),a;if(t.startsWith("rendering.")){Y(a)==="group"&&(a.kind="instance");let c=jk(t,r);return Oe(a,t,c),Nk(a),a}if(t.startsWith("metadata."))return Oe(a,t,r),a.metadata&&Object.keys(a.metadata).length===0&&delete a.metadata,a;if(t==="instance.assetId"){let c=ue(a);return c&&typeof r=="string"&&(c.assetId=r),a.kind="instance",delete a.primitive,a}if(t==="primitive.shape"){let c=(n.normalizePrimitiveShape??Lk)(r);return c&&(a.kind="primitive",a.primitive={shape:c}),a}if(t==="transformType")return Fk(a,r,n),a;if(_k(a,t,r)){let c=i?uy(a):null;return i&&c&&!fy(i,c)?lo(a):a}if(n.patchCustomTransformField?.(a,t,r))return a;if(t.startsWith("marker."))return!a.marker||typeof a.marker!="object"||(a.kind="transform",delete a.primitive,Oe(a,t,r)),a;if(t.startsWith("camera."))return a.kind="transform",a.transformType="camera",a.camera=gy(a.camera,n),delete a.light,n.clearCustomTransformState?.(a,"camera"),delete a.primitive,Oe(a,t,r),a.camera=$k(a.camera,t,n),a;if(t.startsWith("light.")){a.kind="transform",a.transformType="light",a.light=by(a.light,n),delete a.camera,n.clearCustomTransformState?.(a,"light"),delete a.primitive,Oe(a,t,r),(t==="light.direction"||t.startsWith("light.direction."))&&a.light?.type==="directional"&&(a.light.direction=ha(a.light.direction,s??void 0));let c=s?my(a):null;return s&&c&&!fy(s,c)?bs(a):a}return t.startsWith("overrides.")&&(Y(a)==="group"&&(a.kind="instance"),Oe(a,t,r),Vl(a)),a}function uy(e){let t=G(e);return t&&!Ee(t)?{...t.rotation}:null}function my(e){return e.light?.type==="directional"?{...e.light.direction}:null}function fy(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function vk(e,t,r){if(!Gk(t,r))return;let n=e.shadow;e.shadow={cast:t==="shadow.cast"?r===!0?"enabled":"none":n?.cast==="enabled"?"enabled":"none",receive:t==="shadow.receive"?r===!0?"enabled":"none":n?.receive==="enabled"?"enabled":"none"}}function Gk(e,t){return e==="shadow.cast"||e==="shadow.receive"?typeof t=="boolean":!1}function jk(e,t){return e==="rendering.renderingGroupId"?t===1||t===2||t===3?t:0:e==="rendering.alphaIndex"?w(t)?t:null:t}function Nk(e){let t=e.rendering;if(!t||typeof t!="object"||Array.isArray(t)){delete e.rendering;return}Object.keys(t).length===0&&delete e.rendering}function Ru(e,t){return me(e)&&kk.test(t)}function Fk(e,t,r){let n=t==="plain"||t==="light"||t==="camera",o=!n&&r.isCustomTransformType?.(t)===!0;if(!n&&!o)return;let a=t;e.kind="transform",e.transformType=a,delete e.primitive,a==="camera"?e.camera=gy(e.camera,r):delete e.camera,a==="light"?e.light=by(e.light,r):delete e.light,o?r.applyCustomTransformType?.(e,a):r.clearCustomTransformState?.(e,a)}function _k(e,t,r){let n=t.match(Ok);if(n){let a=G(e);if(!a||Ee(a))return!0;let i=n[1];return i==="scale"?(w(r)?a.scale={x:r,y:r,z:r}:qe(r)&&(a.scale={...r}),!0):(qe(r)&&(a[i]=i==="rotation"?{x:Ht(r.x),y:Ht(r.y),z:Ht(r.z)}:{...r}),!0)}let o=t.match(Rk);if(o&&w(r)){let a=G(e);if(!a||Ee(a))return!0;let i=o[1],s=o[2],c=i==="rotation"?Ht(r):r;return i==="scale"?a.scale={...ot(a,"scale"),[s]:c}:a[i]={...a[i],[s]:c},!0}return!1}function gy(e,t){return t.mergeCameraDefaults?t.mergeCameraDefaults(e):Sy(e)}function $k(e,t,r){return r.normalizeCameraAfterFieldPatch?r.normalizeCameraAfterFieldPatch(e,t):e}function by(e,t){return t.mergeLightDefaults?t.mergeLightDefaults(e):Sy(e)}function Lk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function Sy(e){return zk(e)??{}}function zk(e){return e&&typeof e=="object"&&!Array.isArray(e)?structuredClone(e):null}var Iy=["position","rotation","scale"],Py=["x","y","z"],Bk=1e-6;function Cu(e){let t=[{path:"gameObject.id",label:"ID",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.id},{path:"gameObject.name",label:"Name",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.name??e.gameObject.id}],r=G(e.gameObject);if(r){let o=Z(e.gameObject),a=o?Et():Ms(r)?r:null;if(!a)return t;for(let i of Iy)for(let s of Py)t.push(Kk({gameObject:e.gameObject,vectorName:i,axis:s,rootTransform:o,displayTransform:a,validateField:e.validateField}))}let n=ue(e.gameObject);return n&&t.push({path:"modelRenderer.assetId",label:"Asset ID",valueType:"asset",readOnly:!0,getValue:()=>n.assetId}),Dy(e.gameObject)&&t.push(...Vk({gameObject:e.gameObject,validateField:e.validateField})),t}function Ty(e){let t=[];for(let r of Iy)for(let n of Py){let o=e.map(d=>{let u=G(d);return u&&!Ee(u)?ot(u,r)[n]:null}).filter(d=>typeof d=="number");if(o.length!==e.length)continue;let a=r==="rotation"?o.map(Tt):o,i=a[0]??0,s=a.some(d=>Math.abs(d-i)>Bk),c=`transform.${r}.${n}`;t.push({path:c,label:`${r}.${n}`,valueType:"number",value:at(i),mixed:s,readOnly:!1,descriptor:{path:c,valueType:"number",getValue:()=>i}})}return t}function nc(e){if(e.length===0)return[];let t=e.map(n=>n.active!==!1),r=t[0]??!0;return[{path:"enabled",label:"Enabled",valueType:"boolean",value:r,mixed:t.some(n=>n!==r),readOnly:!1,descriptor:{path:"enabled",label:"Enabled",valueType:"boolean",getValue:()=>r}}]}function $a(e){return e.length===0||e.some(r=>!Dy(r))?[]:[hy(e,{path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),hy(e,{path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Vk(e){return[yy({...e,path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),yy({...e,path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function yy(e){return{path:e.path,label:e.label,valueType:e.valueType,...e.options?{options:e.options}:{},getValue:()=>xy(e.gameObject,e.path,e.defaultValue),setValue:(t,r,n)=>{if(!n.targetId)return t;let o=bn(e.path,r),a=e.validateField?.({document:t,gameObject:e.gameObject,nodeKind:Y(e.gameObject),path:e.path,value:o});return a&&!a.ok?t:Mn(t,n.targetId,e.path,o)}}}function hy(e,t){let n=e.map(a=>xy(a,t.path,t.defaultValue))[0]??t.defaultValue,o=Uk(e,t.path);return{path:t.path,label:t.label,valueType:t.valueType,value:n,mixed:o,readOnly:!1,...t.options?{options:t.options}:{},descriptor:{path:t.path,label:t.label,valueType:t.valueType,...t.options?{options:t.options}:{},getValue:()=>n}}}function Uk(e,t){let r=e.map(n=>Ay(n)[t.slice(7)]);return r.some(n=>n!==r[0])}function xy(e,t,r){let n=Ay(e);return t==="shadow.cast"?Ey(n.cast):t==="shadow.receive"?Ey(n.receive):r}function Ey(e){return e==="enabled"}function Ay(e){return He(e.shadow).shadow??{}}function Dy(e){if(Z(e)||e.transformType==="camera"||e.transformType==="light"||e.camera||e.light)return!1;let t=Y(e);return t==="instance"||t==="primitive"||t==="transform"}function Kk(e){return{path:`transform.${e.vectorName}.${e.axis}`,label:`${e.vectorName}.${e.axis}`,valueType:"number",readOnly:e.rootTransform,getValue:()=>{let r=ot(e.displayTransform,e.vectorName)[e.axis];return e.vectorName==="rotation"?at(Tt(r)):r},...e.rootTransform?{}:{setValue:(r,n,o)=>Hk({document:r,targetId:o.targetId,vectorName:e.vectorName,axis:e.axis,value:n,validateField:e.validateField})}}}function Hk(e){let t=Number(e.value);if(!e.targetId||!Number.isFinite(t))return e.document;let r=_(e.document,e.targetId),n=r?G(r):null;if(!r||!n||Ee(n))return e.document;let o=`transform.${e.vectorName}.${e.axis}`,a=e.validateField?.({document:e.document,gameObject:r,nodeKind:Y(r),path:o,value:t});if(a&&!a.ok)return e.document;let i=e.vectorName==="rotation"?Ht(t):t,s=e.vectorName==="position"?{...n.position,[e.axis]:i}:n.position,c=e.vectorName==="rotation"?{...n.rotation,[e.axis]:i}:n.rotation,d=e.vectorName==="scale"?{...ot(n,"scale"),[e.axis]:i}:ot(n,"scale");return Wk(e.document,e.targetId,{position:s,rotation:c,scale:d})}function Wk(e,t,r){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(n=>n.id===t?Rl(n,r):n)}}}function My(e){let t=new Map(e.document.scene.gameObjects.map(o=>[o.id,o])),r=e.targetIds.map(o=>t.get(o)??null).filter(o=>!!o&&!Z(o));if(r.length===0)return null;let n=r.map(o=>o.id);return{targetIds:n,activeId:e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null,label:e.label??`${r.length} GameObjects`,properties:[...nc(r),...Ty(r),...$a(r)]}}var Gu="enabled",wy="shadow.",ky=200;function Nu(e){let t=qk(e.document,e.selectedIds);if(t.length===0)return null;let r=t.map(l=>l.id),n=e.activeId&&r.includes(e.activeId)?e.activeId:r[0]??null,o=e.largeSelectionThreshold??ky,a=Jk(t),i=$a(a),s=t.length>o,c=s?Xk({document:e.document,gameObjects:t,shadowGameObjects:a,activeId:n,label:e.label}):My({document:e.document,targetIds:r,activeId:n,label:e.label});if(!c)return null;let d=c.properties.some(l=>Ry(l.path))||i.length===0?c:{...c,properties:[...c.properties,...i]},u=Oy({document:e.document,serialized:d,shadowOnly:s,renderingProfile:e.renderingProfile});return u.length===0?null:{targetIds:d.targetIds,activeId:d.activeId,label:d.label,document:e.document,selection:{targetIds:d.targetIds,activeId:d.activeId,document:e.document},sections:u}}function Oy(e){let t=Yk(e.document,e.serialized,e.serialized.properties.filter(n=>Ry(n.path)),e.renderingProfile),r=vu("common","Common",10,e.serialized.properties.filter(n=>n.path===Gu),e.document);return e.shadowOnly?[r,t].filter(n=>!!n):[r,vu("transform","Transform",20,e.serialized.properties.filter(n=>n.path.startsWith("transform.")),e.document),t,vu("properties","Properties",90,e.serialized.properties.filter(n=>!n.path.startsWith("transform.")&&n.path!==Gu&&!n.path.startsWith(wy)),e.document)].filter(n=>!!n)}function qk(e,t){let r=new Map(e.scene.gameObjects.map(a=>[a.id,a])),n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.get(a);i&&(Z(i)||o.push(i))}return o}function Jk(e){return e.filter(t=>bo({gameObject:t,nodeKind:Y(t)}))}function Xk(e){if(e.gameObjects.length===0)return null;let t=e.shadowGameObjects.length===0?[]:$a(e.shadowGameObjects);return{targetIds:e.gameObjects.map(r=>r.id),activeId:e.activeId,label:e.label??`${e.gameObjects.length} GameObjects`,properties:[...nc(e.gameObjects),...t]}}function Yk(e,t,r,n){if(r.length===0)return null;let o=new Map(e.scene.gameObjects.map(b=>[b.id,b])),a=t.targetIds.map(b=>o.get(b)).filter(b=>!!b).filter(b=>bo({gameObject:b,nodeKind:Y(b)})),i=o.get(t.activeId??"")??a[0]??null,s=i&&bo({gameObject:i,nodeKind:Y(i)})?i:a[0]??null;if(!s)return null;let c=Y(s),d=r.find(b=>b.path==="shadow.cast"),u=r.find(b=>b.path==="shadow.receive");if(!d||!u)return null;let l=ju(d,0),m=ju(u,1),f=gn({path:d.path,nodeKind:c,document:e}),S=gn({path:u.path,nodeKind:c,document:e}),g=n!==void 0&&Ps(Os(n))==="none";return{id:"shadow",title:"\u9634\u5F71",order:25,placement:"body",...g?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[{...l,label:"\u6295\u5C04\u9634\u5F71",control:"boolean",value:l.value===!0,mixed:l.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6240\u9009\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002",validate:f},{...m,label:"\u63A5\u6536\u9634\u5F71",control:"boolean",value:m.value===!0,mixed:m.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002",validate:S},...g?[Fl()]:[]]}}function Ry(e){return e.startsWith(wy)}function vu(e,t,r,n,o){return n.length===0?null:{id:e,title:t,order:r,placement:"body",persistence:"document",properties:n.map((a,i)=>{let s=ju(a,i),c=Zk(o,a.path);return{...s,step:a.valueType==="number"?a.path.startsWith("transform.rotation.")?1:.1:s.step,validate:c?gn({path:a.path,nodeKind:c,document:o}):s.validate}})}}function ju(e,t){let r=e.readOnly===!0;return{path:e.path,label:e.label,valueType:e.valueType,control:r?"readonly":Qk(e.valueType),value:e.value,options:e.options,mixed:e.mixed,readOnly:r,persistence:r?"readonly":"document",commitMode:eO(e.valueType),order:t,source:e}}function Zk(e,t){if(t.startsWith("transform."))return"transform";if(t===Gu){let r=e.scene.gameObjects.find(n=>!Z(n));return r?Y(r):null}return null}function Qk(e){return e==="string"||e==="number"||e==="boolean"||e==="enum"||e==="asset"||e==="object"?e:"readonly"}function eO(e){return e==="number"?"live":e==="boolean"||e==="enum"||e==="asset"?"immediate":"blur"}var tO=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function Ga(e){if(me(e.patch.targetId)&&tO.test(e.patch.path))return e.document;let t=_(e.document,e.patch.targetId);if(!t)return e.document;let r=e.patch.path.startsWith("transform.rotation")?Cy(t):null,n=e.patch.path.startsWith("light.direction")?vy(t):null,o=xp(e.document,Cu({gameObject:t,validateField:e.validateField}),e.patch);if(!e.patch.path.startsWith("transform.rotation")&&!e.patch.path.startsWith("light.direction"))return o;let a=_(o,e.patch.targetId);if(!a)return o;let i=r?Cy(a):null,s=n?vy(a):null,c=r&&i&&!Gy(r,i),d=n&&s&&!Gy(n,s);return!c&&!d?o:{...o,scene:{...o.scene,gameObjects:o.scene.gameObjects.map(u=>{if(u.id!==e.patch.targetId)return u;let l=c?lo(u):u;return d?bs(l):l})}}}function Cy(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function vy(e){return e.light?.type==="directional"?e.light.direction:null}function Gy(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function _u(e){let t=e.findGameObject(e.document,e.targetId);if(!t)return null;let r=e.isMarkerGameObject(t);return{targetIds:[t.id],activeId:t.id,label:t.name??t.id,document:e.document,selection:{targetIds:[t.id],activeId:t.id,scopeType:"scene",targetKind:r?"marker":e.readNodeKind(t),...r?{capabilities:["markerGraph"]}:{},document:e.document},sections:e.createInspectorSections(e.document,t,e.context)}}function $u(e){let t=Nu({document:e.document,selectedIds:e.selectedIds,activeId:e.activeId,renderingProfile:e.renderingProfile}),r=t?{...t,selection:{...t.selection,scopeType:"scene"}}:null;if(!e.extraSection)return r;if(!r){let n=e.resolveFallbackTargetIds(),o=e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null;return{targetIds:n,activeId:o,label:e.formatFallbackLabel(n),document:e.document,selection:{targetIds:n,activeId:o,scopeType:"scene",targetKind:e.fallbackSelectionKind??"object",document:e.document},sections:[e.extraSection]}}return{...r,sections:[...r.sections.filter(n=>n.id!==e.extraSection.id),e.extraSection].sort((n,o)=>(n.order??0)-(o.order??0))}}function Lu(e){let t=[...e.createBaseSections()],r=e.isCameraGameObject(e.gameObject),n=e.isLightGameObject(e.gameObject),o=e.isMarkerGameObject(e.gameObject),a=e.nodeKind==="transform";return Fu(t,e.createCustomSections?.({document:e.document,gameObject:e.gameObject,context:e.context,nodeKind:e.nodeKind,isCamera:r,isLight:n,isMarker:o})),La(t,a&&r?e.createCameraSection?.():null),Fu(t,a&&n?e.createLightSections?.():null),La(t,a&&o?e.createMarkerSection?.():null),La(t,e.createPrefabInstanceSection?.()),(e.isMaterialInspectorCandidate?.({nodeKind:e.nodeKind,gameObject:e.gameObject,isCamera:r,isLight:n,isMarker:o})??(e.nodeKind==="instance"||e.nodeKind==="primitive"||a&&!r&&!n&&!o))&&(Fu(t,e.createMaterialSections?.()),La(t,e.createOutlineSection?.())),t.sort((s,c)=>(s.order??0)-(c.order??0))}function La(e,t){t&&e.push(t)}function Fu(e,t){if(t)for(let r of t)La(e,r)}function zu(e){let t=e.outline,r=t?"active":"default",n=r==="default"?jy:void 0;return{id:"outline",title:"Outline",order:60,placement:"body",summary:t?"Configured":"Defaults",persistence:r==="default"?"readonly":"document",effect:r,disabledReason:n,collapsedByDefault:!0,properties:nO(rO(e),r,n)}}var jy="Outline fields are showing defaults; configure an outline override before edits affect this object.";function rO(e){let t=e.outline,r=[e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.renderOutline",label:"Render Outline",valueType:"boolean",control:"boolean",value:t?.renderOutline??!1,commitMode:"immediate",order:0}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineWidth",label:"Width",valueType:"number",control:"number",value:t?.outlineWidth??.04,commitMode:"live",order:1,min:0,step:.005,displayPrecision:3,precision:3,stepPrecision:.001}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineColor",label:"Color",valueType:"color",control:"color",value:t?.outlineColor??{r:.03,g:.03,b:.03},commitMode:"immediate",order:2})],n=j({path:"overrides.outline.raw",label:"Raw Override",value:t??"not configured",order:r.length,source:"Document",tags:["Raw"]});return n&&r.push(n),r}function nO(e,t,r){return!t||t==="active"?e:e.map(n=>({...n,readOnly:!0,persistence:n.persistence==="runtime"?"runtime":"readonly",control:n.control==="custom"?n.control:"readonly",effect:n.effect??t,disabledReason:n.disabledReason??r}))}var oO={title:"\u6807\u8BB0",typeLabel:"\u6807\u8BB0\u7C7B\u578B",kindLabel:"\u7A7A\u95F4\u7C7B\u522B",tagsLabel:"\u6807\u7B7E",colorLabel:"\u989C\u8272",noteLabel:"\u5907\u6CE8",geometryLabel:"\u51E0\u4F55",targetLabel:"\u7ED1\u5B9A\u5BF9\u8C61",targetStatusLabel:"\u7ED1\u5B9A\u72B6\u6001",emptyTypeOption:"\u672A\u9009\u62E9",emptyTargetOption:"\u672A\u7ED1\u5B9A",tagsPlaceholder:"\u6807\u7B7E, \u53E6\u4E00\u4E2A\u6807\u7B7E",notePlaceholder:"\u53EF\u9009\u6807\u8BB0\u5907\u6CE8",unselectedSummary:"\u672A\u9009\u62E9",missingTargetPrefix:"\u7F3A\u5931",missingTargetStatus:"\u76EE\u6807\u7F3A\u5931",targetStatusUnbound:"\u672A\u7ED1\u5B9A",targetStatusOk:"\u6B63\u5E38",unsupportedTargetPrefix:"\u4E0D\u652F\u6301\u76EE\u6807"},aO={region:"\u533A\u57DF",point:"\u70B9",anchor:"\u951A\u70B9",object:"\u5BF9\u8C61\u7ED1\u5B9A"},iO={box:"\u76D2\u4F53",point:"\u70B9","object-bounds":"\u5BF9\u8C61\u5305\u56F4\u76D2",polyhedron:"\u591A\u9762\u4F53"};function Ku(e){let t={...oO,...e.text},r=e.gameObject.marker,n=e.resolveMarkerKind(e.document,r),o=sO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),a=mO(r),i=a?.kind==="scene-object"?a.id:"",s=cO(e.document,e.gameObject.id,i,e.isMarkerGameObject,t),c=[e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.type",label:t.typeLabel,valueType:"enum",control:o.length>0?"enum":"string",value:r.type,options:o.length>0?o:void 0,commitMode:"change",order:0}),Vu("marker.kind",t.kindLabel,lO(n,e.formatMarkerKindLabel),1),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.tags",label:t.tagsLabel,valueType:"string",control:"string",value:r.tags?.join(", ")??"",commitMode:"blur",placeholder:t.tagsPlaceholder,order:2}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.color",label:t.colorLabel,valueType:"color",control:"color",value:r.color??{r:.1,g:.85,b:1},commitMode:"immediate",order:3}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.note",label:t.noteLabel,valueType:"string",control:"string",value:r.note??"",commitMode:"blur",placeholder:t.notePlaceholder,order:4}),Vu("marker.geometry.kind",t.geometryLabel,uO(r.geometry.kind,e.formatMarkerGeometryKindLabel),5),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.target.objectId",label:t.targetLabel,valueType:"enum",control:"enum",value:i,options:s,commitMode:"change",order:6}),Vu("marker.target.status",t.targetStatusLabel,fO(e.document,a,t),7)];return{id:"marker",title:t.title,order:35,placement:"body",persistence:"document",summary:dO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),collapsedByDefault:!1,properties:c}}function sO(e,t,r,n){let o=[{label:r.emptyTypeOption,value:""},...e.map(a=>({label:Uu(a.type,a.label||a.type,n),value:a.type}))];return t&&!o.some(a=>a.value===t)&&o.push({label:Uu(t,t,n),value:t}),o}function cO(e,t,r,n,o){let a=[{label:o.emptyTargetOption,value:""},...e.scene.gameObjects.filter(i=>i.id!==t&&!n(i)).map(i=>({label:i.name||i.id,value:i.id}))];return r&&!a.some(i=>i.value===r)&&a.push({label:`${o.missingTargetPrefix}: ${r}`,value:r}),a}function dO(e,t,r,n){if(!t.trim())return r.unselectedSummary;let o=e.find(a=>a.type===t);return Uu(t,o?.label||t,n)}function Uu(e,t,r){return r?.(e,t)??t}function lO(e,t){return t?.(e)??aO[e]??e}function uO(e,t){return t?.(e)??iO[e]??e}function mO(e){return e.target?Bu(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?Bu(e.geometry.target):null}function fO(e,t,r){return t?t.kind!=="scene-object"?`${r.unsupportedTargetPrefix}: ${t.kind}`:e.scene.gameObjects.some(n=>n.id===t.id)?r.targetStatusOk:r.missingTargetStatus:r.targetStatusUnbound}function Bu(e){return{...e,...e.metadata?{metadata:{...e.metadata}}:{}}}function Vu(e,t,r,n){return j({path:e,label:t,value:r,order:n,source:"Document"})}var za={r:1,g:1,b:1,a:1};function pO(e){return{...e}}function $y(e){let t=pO(e);return{services:t,normalizeLayoutPatchValue:r=>dc(r,t),isLayoutPatchCompatibleWithDecal:(r,n)=>Ky(r,n,t),canPatchMultiField:(r,n,o,a)=>hO(r,n,o,a,t),patchLayout:(r,n,o)=>EO(r,n,o,t),patchKind:(r,n,o)=>IO(r,n,o,t),patchInspectorField:(r,n,o,a)=>PO(r,n,o,a,t),normalizeGameObject:r=>On(r,t),replaceUi:(r,n,o)=>xO(r,n,o,t),normalizeScaleAfterFieldPatch:(r,n,o,a)=>oc(r,n,o,a,t),normalizeScalesForCommand:(r,n)=>AO(r,n,t),normalizeScales:(r,n,o)=>cc(r,t,n,o),mergeDefaults:r=>dt(r,t.createDefaultGroundDecal,t)}}function Ly(e){return{...e.policy,createDocumentInspectorProperty:e.createDocumentInspectorProperty,normalizeValue:e.normalizeValue,findTarget:e.findTarget,getTargetId:e.getTargetId,getTargetNodeKind:e.getTargetNodeKind,getTargetGroundDecal:e.getTargetGroundDecal,canShowTarget:e.canShowTarget,isUiTarget:e.isUiTarget,canPatchMultiField:e.canPatchMultiField,findTextureAsset:e.findTextureAsset,resolveTextureAssetUrl:e.resolveTextureAssetUrl,getMaterialText:e.getMaterialText,createTexturePickerControlOptions:e.createTexturePickerControlOptions}}var gO=75;function Hu(e,t){if(e==="transform.scale"){let r=t;return!r||typeof r!="object"?null:Wy({x:typeof r.x=="number"?r.x:1,y:typeof r.y=="number"?r.y:1,z:typeof r.z=="number"?r.z:1})}return!/^transform\.scale\.(x|y|z)$/.test(e)||typeof t!="number"||!Number.isFinite(t)?null:Math.max(.001,Math.abs(t))}function dc(e,t={}){let r=Wa(e),n=Array.isArray(e)?e:r&&Array.isArray(r.layers)?r.layers:null;if(!n)return null;let o=n.map((a,i)=>bO(a,i,t)).filter(a=>!!a);return o.length>0?o:null}function bO(e,t,r={}){let n=Wa(e);if(!n)return null;let o=XO(n.id)??`layer_${t}`,a=Ao(n.rect),i=n.fontSize==null?null:ac(n.fontSize),s=n.rotationDeg==null?null:Mo(n.rotationDeg);return!a||n.fontSize!=null&&i==null||n.rotationDeg!=null&&s==null?null:{id:o,rect:a,...s==null?{}:{rotationDeg:s},...i==null?{}:{fontSize:_r(i)}}}function Ao(e){let t=Wa(e);if(!t)return null;let r=Xt(t.x),n=Xt(t.z),o=ac(t.width),a=ac(t.depth);return r==null||n==null||o==null||a==null?null:{x:r,z:n,width:o,depth:a}}function Xt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function ac(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function zy(e,t){if(e==="groundDecal.editorPreviewActive")return typeof t=="boolean"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(lc(e))return Ao(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(By(e)){let r=Mo(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(uc(e))return typeof t=="string"?{ok:!0,value:t.trim()}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(pc(e))return typeof t=="string"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(Vy(e)){let r=qu(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(mc(e)||Sc(e)||gc(e)){let r=Ba(t);return r?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(fc(e)||yc(e)||bc(e)){let r=Va(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(hc(e)){let r=Wu(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if($r(e)){let r=Ha(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}return null}function Ua(e){let t=e.match(/^groundDecal\.layers\.(\d+)\.(rect|rotationDeg|textureId|text\.value|text\.fontSize|color|color\.a|tint|tint\.a|text\.color|text\.color\.a|editorPreviewPercent)$/);if(!t)return null;let r=Number(t[1]);return!Number.isInteger(r)||r<0?null:{index:r,field:t[2]}}function lc(e){return/^groundDecal\.layers\.\d+\.rect$/.test(e)}function By(e){return/^groundDecal\.layers\.\d+\.rotationDeg$/.test(e)}function uc(e){return/^groundDecal\.layers\.\d+\.textureId$/.test(e)}function mc(e){return/^groundDecal\.layers\.\d+\.color$/.test(e)}function fc(e){return/^groundDecal\.layers\.\d+\.color\.a$/.test(e)}function pc(e){return/^groundDecal\.layers\.\d+\.text\.value$/.test(e)}function Vy(e){return/^groundDecal\.layers\.\d+\.text\.fontSize$/.test(e)}function gc(e){return/^groundDecal\.layers\.\d+\.text\.color$/.test(e)}function bc(e){return/^groundDecal\.layers\.\d+\.text\.color\.a$/.test(e)}function Sc(e){return/^groundDecal\.layers\.\d+\.tint$/.test(e)}function yc(e){return/^groundDecal\.layers\.\d+\.tint\.a$/.test(e)}function hc(e){return/^groundDecal\.layers\.\d+\.editorPreviewPercent$/.test(e)}function $r(e){return e==="groundDecal.rendering.textureWidth"||e==="groundDecal.rendering.textureHeight"}function Ec(e){return e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||!!Ua(e)||$r(e)}function Ka(e){return e==="groundDecal.size.width"||e==="groundDecal.size.depth"||e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||Ec(e)}function SO(e,t,r={}){return t==="rect"?Do(e,r):t==="rotationDeg"?Pc(e,r):t==="textureId"||t==="tint"||t==="tint.a"?ic(e,r):t==="text.value"||t==="text.fontSize"||t==="text.color"||t==="text.color.a"?Uy(e,r):t==="color"||t==="color.a"?sc(e,r):t==="editorPreviewPercent"?e.kind==="textureProgress"?ic(e,r):e.kind==="progress"&&sc(e,r):!1}function Ic(e,t={}){return t.isProjectEditableLayer?.(e)??e.enabled!==!1}function Do(e,t={}){return t.isLayoutEditableLayer?.(e)??e.enabled!==!1}function Pc(e,t={}){return t.isRotationEditableLayer?.(e)??!1}function ic(e,t={}){return t.isEditableTextureLayer?.(e)??(e.kind==="texture"||e.kind==="textureProgress")}function sc(e,t={}){return t.isEditableColorLayer?.(e)??(e.kind==="color"||e.kind==="progress")}function Uy(e,t={}){return t.isEditableTextLayer?.(e)??e.kind==="text"}function Ky(e,t,r={}){let n=e.layers.filter(o=>Do(o,r));return t.length!==n.length?!1:n.every((o,a)=>{let i=t[a];return i?.id===o.id&&(i.fontSize==null||o.kind==="text")&&(i.rotationDeg==null||Pc(o,r))})}function Ba(e){let t=Wa(e);if(!t)return null;let r=Xt(t.r),n=Xt(t.g),o=Xt(t.b);if(r==null||n==null||o==null)return null;let a=Xt(t.a);return{r:_r(Math.max(0,Math.min(1,r))),g:_r(Math.max(0,Math.min(1,n))),b:_r(Math.max(0,Math.min(1,o))),...a==null?{}:{a:_r(Math.max(0,Math.min(1,a)))}}}function Va(e){let t=Xt(e);return t==null?null:_r(Math.max(0,Math.min(1,t)))}function Wu(e){let t=Xt(e);return t==null?null:Math.round(Math.max(0,Math.min(100,t)))}function Mo(e){let t=Xt(e);if(t==null)return null;let r=t%360;r>180&&(r-=360),r<=-180&&(r+=360);let n=_r(r);return Object.is(n,-0)?0:n}function qu(e){let t=ac(e);return t==null?null:_r(t)}function Ha(e){let t=Xt(e);return t==null||t<=0?null:Math.max(64,Math.min(2048,Math.round(t)))}function _r(e){return Math.round(e*1e3)/1e3}function Tc(e,t){return e==="groundDecal.editorPreviewActive"?t===!0:e==="groundDecal.layers"?dc(t)??t:lc(e)?Ao(t)??t:By(e)?Mo(t)??t:uc(e)&&typeof t=="string"?t.trim():pc(e)&&typeof t=="string"?t:Vy(e)?qu(t)??t:mc(e)||Sc(e)||gc(e)?Ba(t)??t:fc(e)||yc(e)||bc(e)?Va(t)??t:hc(e)?Wu(t)??t:$r(e)?Ha(t)??t:t}function Hy(e,t,r){if(t==="rect"){let n=Ao(r);return n?yO(e.rect,n)?e:{...e,rect:n}:null}if(t==="rotationDeg"){let n=Mo(r);if(n==null)return null;if(n===0){if(e.rotationDeg==null)return e;let{rotationDeg:o,...a}=e;return a}return e.rotationDeg===n?e:{...e,rotationDeg:n}}if(t==="textureId"){if(e.kind!=="texture"&&e.kind!=="textureProgress"||typeof r!="string")return null;let n=r.trim();if(!n){if(!e.textureId)return e;let{textureId:o,...a}=e;return a}return e.textureId===n?e:{...e,textureId:n}}if(t==="text.value")return e.kind!=="text"||typeof r!="string"?null:e.text.value===r?e:{...e,text:{...e.text,value:r}};if(t==="text.fontSize"){if(e.kind!=="text")return null;let n=qu(r);return n==null?null:e.text.fontSize===n?e:{...e,text:{...e.text,fontSize:n}}}if(t==="color"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Ba(r);if(!n)return null;let o={...n,...n.a==null&&e.color.a!=null?{a:e.color.a}:{}};return xo(e.color,o)?e:{...e,color:o}}if(t==="color.a"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Va(r);if(n===null)return null;let o={...e.color,a:n};return xo(e.color,o)?e:{...e,color:o}}if(t==="editorPreviewPercent"){if(e.kind!=="progress"&&e.kind!=="textureProgress")return null;let n=Wu(r);return n===null?null:e.editorPreviewPercent===n?e:{...e,editorPreviewPercent:n}}if(t==="tint"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Ba(r);if(!n)return null;let o={...n,...n.a==null&&e.tint?.a!=null?{a:e.tint.a}:{}};return xo(e.tint??za,o)?e:{...e,tint:o}}if(t==="tint.a"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Va(r);if(n===null)return null;let o={...za,...e.tint??{},a:n};return xo(e.tint??za,o)?e:{...e,tint:o}}if(t==="text.color"){if(e.kind!=="text")return null;let n=Ba(r);if(!n)return null;let o={...n,...n.a==null&&e.text.color.a!=null?{a:e.text.color.a}:{}};return xo(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}if(t==="text.color.a"){if(e.kind!=="text")return null;let n=Va(r);if(n===null)return null;let o={...e.text.color,a:n};return xo(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}return null}function dt(e,t,r={}){let n=e&&typeof e=="object"&&!Array.isArray(e)?e:null,o=typeof n?.uiKind=="string"?n.uiKind.trim():"",a=o&&(r.isKnownUiKind?.(o)??!0)?o:r.defaultUiKind??"default",i=t(a);return n?{...i,...structuredClone(n),uiKind:a,size:{...i.size,...n.size&&typeof n.size=="object"?n.size:{}},layers:Array.isArray(n.layers)&&n.layers.length>0?structuredClone(n.layers):i.layers,mask:n.mask&&typeof n.mask=="object"?{...i.mask??{},...n.mask}:i.mask,rendering:n.rendering&&typeof n.rendering=="object"?{...i.rendering??{},...n.rendering}:i.rendering}:i}function xo(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&(e.a??1)===(t.a??1)}function yO(e,t){return e.x===t.x&&e.z===t.z&&e.width===t.width&&e.depth===t.depth}function Wy(e){let t=[e.x,e.y,e.z].filter(n=>Number.isFinite(n));if(t.length===0)return 1;let r=t.reduce((n,o)=>Math.abs(o-1)>Math.abs(n-1)?o:n,t[0]);return Math.max(.001,Math.abs(r))}function hO(e,t,r,n,o){if(!Ka(r))return!1;let a=RO(e,t);if(!a||!o.canShowGroundDecalInspector(a))return!1;let i=dt(a.groundDecal,o.createDefaultGroundDecal,o);if(r==="groundDecal.size.width"||r==="groundDecal.size.depth"||$r(r)||r==="groundDecal.editorPreviewActive")return!0;if(r==="groundDecal.layers"){let d=dc(n,o);return d?Ky(i,d,o):!1}let s=Ua(r);if(!s)return!1;let c=i.layers[s.index];return!!c&&Ic(c,o)&&SO(c,s.field,o)}function EO(e,t,r,n){let o=dc(r,n);return o?Jy(e,a=>a.id===t?DO(a,o,n):a):e}function IO(e,t,r,n){if(typeof r!="string"||!r.trim())return e;let o=r.trim();return n.isKnownUiKind&&!n.isKnownUiKind(o)?e:Jy(e,a=>a.id===t?MO(a,o,n):a)}function PO(e,t,r,n,o){if(r==="groundDecal.editorPreviewActive"){if(typeof n!="boolean")return e;let d=!1,u=e.scene.gameObjects.map(l=>{if(l.id!==t||!o.canShowGroundDecalInspector(l))return l;let m=dt(l.groundDecal,o.createDefaultGroundDecal,o);return m.editorPreviewActive===n?l:(d=!0,On({...l,groundDecal:{...m,editorPreviewActive:n}},o))});return d?{...e,scene:{...e.scene,gameObjects:u}}:e}if($r(r))return TO(e,t,r,n,o);let a=Ua(r);if(!a)return null;let i=!1,s=Tc(r,n),c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o),l=u.layers[a.index];if(!l||!Ic(l,o)||a.field==="rect"&&!Do(l,o))return d;let m=Hy(l,a.field,s);if(!m||m===l)return d;let f=[...u.layers];return f[a.index]=m,i=!0,On({...d,groundDecal:{...u,layers:f}},o)});return i?{...e,scene:{...e.scene,gameObjects:c}}:e}function TO(e,t,r,n,o){let a=Ha(n);if(a===null)return e;let i=r==="groundDecal.rendering.textureWidth"?"textureWidth":"textureHeight",s=!1,c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o);return u.rendering?.[i]===a?d:(s=!0,On({...d,groundDecal:{...u,rendering:{...u.rendering,[i]:a}}},o))});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function xO(e,t,r,n){if(!n.isGroundDecalConfig(r))return e;let o=!1,a=e.scene.gameObjects.map(i=>i.id!==t||!n.isGroundDecalUiGameObject(i)||i.groundDecal.uiKind!==r.uiKind?i:(o=!0,On({...i,kind:"transform",transformType:"groundDecal",groundDecal:dt(r,n.createDefaultGroundDecal,n)},n)));return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function oc(e,t,r,n,o){return r.startsWith("transform.scale")?cc(e,o,t,Hu(r,n)):e}function AO(e,t,r){if(t.type==="document.replace")return cc(e,r);let n=t.patch;return n.kind==="game-object.field"?oc(e,String(n.targetId??""),String(n.path??""),n.value,r):n.kind==="game-object.property-field-batch"&&Array.isArray(n.fields)?n.fields.reduce((o,a)=>{let i=Wa(a);return oc(o,String(i?.targetId??""),String(i?.path??""),i?.value,r)},e):n.kind==="game-object.field-batch"?Array.isArray(n.targetIds)?n.targetIds.reduce((o,a)=>oc(o,String(a),String(n.path??""),n.value,r),e):e:cc(e,r)}function cc(e,t,r,n){let o=!1,a=e.scene.gameObjects.map(i=>{if(r&&i.id!==r||!t.isGroundDecalUiGameObject(i))return i;let s=G(i);if(!s||!OO(s)||!s.scale)return i;let c=n??Wy(s.scale);return Math.abs(s.scale.x-c)<1e-6&&Math.abs(s.scale.y-c)<1e-6&&Math.abs(s.scale.z-c)<1e-6?i:(o=!0,{...i,components:i.components.map(d=>d===s?{...d,scale:{x:c,y:c,z:c}}:d)})});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function On(e,t){let r=wO({...e,kind:"transform",transformType:"groundDecal",groundDecal:dt(e.groundDecal,t.createDefaultGroundDecal,t)});return delete r.camera,delete r.light,delete r.primitive,r}function qy(e){return e==="groundDecal"||e.startsWith("groundDecal.")}function DO(e,t,r){let n=new Map(t.map(a=>[a.id,a])),o=dt(e.groundDecal,r.createDefaultGroundDecal,r);return On({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,layers:o.layers.map((a,i)=>{if(!Do(a,r))return a;let s=n.get(a.id)??t[i];if(!s)return a;let c=a.kind==="text"?{...a.rect,x:s.rect.x,z:s.rect.z}:s.rect,d=a.kind==="text"&&s.fontSize!=null?{...a,rect:c,text:{...a.text,fontSize:s.fontSize}}:{...a,rect:c};return s.rotationDeg!=null&&Pc(a,r)&&(d=Hy(d,"rotationDeg",s.rotationDeg)??d),d})}},r)}function MO(e,t,r){let n=dt(e.groundDecal,r.createDefaultGroundDecal,r),o=r.createDefaultGroundDecal(t);return On({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,size:n.size,mask:n.mask??o.mask,rendering:n.rendering??o.rendering}},r)}function wO(e){return e.components.some(t=>t.type==="Transform")?e:{...e,components:[kO(),...e.components]}}function kO(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function OO(e){return e.type==="Transform"&&e.mode!=="matrix"}function RO(e,t){return t?e.scene.gameObjects.find(r=>r.id===t)??null:null}function Jy(e,t){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(t)}}}function Xy(e,t,r={},n){let o=dt(t,n.createDefaultGroundDecal,n),a=[JO("groundDecal.uiKind","Type",n.createUiKindLabel?.(o.uiKind)??o.uiKind,0),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.width",label:"Width",valueType:"number",control:"number",value:o.size.width,commitMode:"live",order:1,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.depth",label:"Depth",valueType:"number",control:"number",value:o.size.depth,commitMode:"live",order:2,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureWidth",label:"Texture Width",valueType:"number",control:"number",value:o.rendering?.textureWidth??512,commitMode:"change",order:3,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureHeight",label:"Texture Height",valueType:"number",control:"number",value:o.rendering?.textureHeight??512,commitMode:"change",order:4,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.layers",label:"Layout",valueType:"object",control:"custom",customControl:"ground-decal-layout",value:th(o,r,n),commitMode:"live",order:5,coerce:s=>n.normalizeValue("groundDecal.layers",s),controlOptions:{aspectRatio:WO(o),aspectRatioUsesDecalSize:HO(o),sizeWidth:o.size.width,sizeDepth:o.size.depth}})],i=10;if((n.canShowActivePreview?.(o)??!1)&&a.push(n.createDocumentInspectorProperty(null,e,{path:"groundDecal.editorPreviewActive",label:"Preview Active Background",valueType:"boolean",control:"boolean",value:o.editorPreviewActive===!0,commitMode:"immediate",order:6,tags:["GroundDecalUI","Preview"],controlOptions:{refreshInspector:!1}})),r.enableGroundDecalUiActions&&(n.canShowLayerPairActions?.(o)??!1)&&n.layerPairActions){let s=n.getLayerPairs?.(o).length??0,c=n.canAddLayerPair?.(o)??!1,d=n.canRemoveLayerPair?.(o)??!1;a.push(_y({path:n.layerPairActions.addPath??"groundDecal.layerPairs.add",label:n.layerPairActions.addLabel??"Add item",actionId:n.layerPairActions.addActionId,order:i,icon:"asset",tooltip:n.layerPairActions.addTooltip??"Add an item.",params:{},disabled:!c,disabledReason:c?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"add",pairCount:s}),effect:c?"active":"unsupported"})),i+=1,a.push(_y({path:n.layerPairActions.removePath??"groundDecal.layerPairs.remove",label:n.layerPairActions.removeLabel??"Remove item",actionId:n.layerPairActions.removeActionId,order:i,icon:"asset",tooltip:n.layerPairActions.removeTooltip??"Remove an item.",params:{},disabled:!d,disabledReason:d?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"remove",pairCount:s}),effect:d?"active":"unsupported"})),i+=1}for(let s=0;s<o.layers.length;s+=1){let c=o.layers[s];if(!c||!Ic(c,n))continue;let d=rh(c,n);if(ic(c,n)){let u=n.resolveImageFit?.(c)??c.imageFit??"contain",l=zO(e,r,c,s,d,i,n);u!=="stretch"&&o.lockAspectToBorder===!0&&o.aspectSourceLayerId===c.id&&(l.controlOptions={...l.controlOptions,groundDecalAspectSizeWidth:o.size.width,groundDecalAspectSizeDepthPath:"groundDecal.size.depth",groundDecalAspectTextureWidth:o.rendering?.textureWidth??512,groundDecalAspectTextureHeight:o.rendering?.textureHeight??512,groundDecalAspectTextureWidthPath:"groundDecal.rendering.textureWidth",groundDecalAspectTextureHeightPath:"groundDecal.rendering.textureHeight"}),a.push(l),i+=1,a.push(UO(e,c,s,d,i,n)),i+=1}(c.kind==="progress"&&sc(c,n)||c.kind==="textureProgress"&&ic(c,n))&&(a.push(VO(e,c,s,d,i,n)),i+=1),sc(c,n)&&(a.push(BO(e,c,s,d,i,n)),i+=1),Uy(c,n)&&(a.push(n.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${s}.text.value`,label:`${d} Text`,valueType:"string",control:"string",value:c.text.value,commitMode:"blur",order:i,tags:["GroundDecalUI","Text"]})),i+=1,a.push(KO(e,c,s,d,i,n)),i+=1)}return qO(a,{path:"groundDecal.raw",label:"Raw Ground Decal",value:t??o,order:i,source:"Document",tags:["Raw"]}),a}function Yy(e,t,r,n){let o=n.getTargetGroundDecal(e),a=dt(o,n.createDefaultGroundDecal,n),i=Xy(t,a,{...r,enableGroundDecalUiActions:n.isUiTarget?.(e)??!1},n),s=i.find(d=>d.path==="groundDecal.layers");if(!s)throw new Error("Ground Decal Inspector requires the canonical layout property.");let c=i.filter(d=>d!==s).map(d=>({...d,controlOptions:{...d.controlOptions,groundDecalWorkbenchChild:!0}}));return{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:vO(a,n),persistence:"document",collapsedByDefault:!1,properties:[CO(a,[s,...c],n),...c]}}function CO(e,t,r){let n=t.find(a=>a.path==="groundDecal.layers");if(!n||!n.value||typeof n.value!="object"||Array.isArray(n.value))throw new Error("Ground Decal Inspector requires the canonical layout property.");let o={uiKind:e.uiKind,uiKindLabel:r.createUiKindLabel?.(e.uiKind)??e.uiKind,layout:n.value,properties:t.filter(a=>a!==n)};return{...n,label:"Ground Decal Editor",customControl:"ground-decal-workbench",value:o,controlOptions:{...n.controlOptions,refreshInspector:!1}}}function vO(e,t){let r=t.createUiKindLabel?.(e.uiKind)??e.uiKind,n=Math.max(1,Math.round(e.rendering?.textureWidth??512)),o=Math.max(1,Math.round(e.rendering?.textureHeight??512)),a=n===o?`${n}\xB2`:`${n}\xD7${o}`,i=t.canShowLayerPairActions?.(e)??!1?t.getLayerPairs?.(e).length??0:0;return i>0?`${r} \xB7 ${i} item${i===1?"":"s"} \xB7 ${a}`:`${r} \xB7 ${a}`}function Zy(e,t,r,n,o){let a=eh(e,t,o);if(a.length<=1)return null;let i=a.find(l=>o.getTargetId(l.target)===r)??a[0];if(!i)return null;let s=GO(a.map(l=>l.decal),o),c=o.getTargetNodeKind(i.target),d=Xy(c,i.decal,{...n,enableGroundDecalUiActions:!1},o).filter(l=>NO(l,s)).filter(l=>a.every(m=>l.readOnly||o.canPatchMultiField(e,o.getTargetId(m.target),l.path,l.value))).map(l=>({...l,mixed:FO(a,l.path,n,o)}));return d.length===0?null:{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:a.some(l=>l.decal.uiKind!==i.decal.uiKind)?"Mixed":`${a.length} ${o.createUiKindLabel?.(i.decal.uiKind)??i.decal.uiKind} UIs`,persistence:"document",collapsedByDefault:!1,properties:d}}function Qy(e,t,r){return eh(e,t,r).map(n=>r.getTargetId(n.target))}function eh(e,t,r){let n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.findTarget(e,a);!i||!r.canShowTarget(i)||o.push({target:i,decal:dt(r.getTargetGroundDecal(i),r.createDefaultGroundDecal,r)})}return o}function GO(e,t={}){if(e.length===0)return!1;let[r,...n]=e.map(o=>jO(o,t));return n.every(o=>o===r)}function jO(e,t={}){return e.layers.map((r,n)=>({layer:r,index:n})).filter(r=>Ic(r.layer,t)).map(({layer:r,index:n})=>`${n}:${r.id}:${r.role}:${r.kind}`).join("|")}function NO(e,t){return e.path==="groundDecal.raw"?!1:e.path==="groundDecal.uiKind"||e.path==="groundDecal.size.width"||e.path==="groundDecal.size.depth"||e.path==="groundDecal.editorPreviewActive"||$r(e.path)?!0:e.path==="groundDecal.layers"||Ua(e.path)?t:!1}function FO(e,t,r,n){if(e.length<=1)return!1;let[o,...a]=e.map(i=>JSON.stringify(_O(i.decal,t,r,n)));return a.some(i=>i!==o)}function _O(e,t,r,n){if(t==="groundDecal.uiKind")return e.uiKind;if(t==="groundDecal.size.width")return e.size.width;if(t==="groundDecal.size.depth")return e.size.depth;if(t==="groundDecal.editorPreviewActive")return e.editorPreviewActive===!0;if(t==="groundDecal.rendering.textureWidth")return e.rendering?.textureWidth??512;if(t==="groundDecal.rendering.textureHeight")return e.rendering?.textureHeight??512;if(t==="groundDecal.layers")return th(e,r,n).layers;let o=Ua(t);if(!o)return;let a=e.layers[o.index];if(a)return $O(a,o.field)}function $O(e,t){if(t==="rect")return e.rect;if(t==="rotationDeg")return e.rotationDeg??0;if(t==="textureId")return e.kind==="texture"||e.kind==="textureProgress"?e.textureId:void 0;if(t==="text.value")return e.kind==="text"?e.text.value:void 0;if(t==="text.fontSize")return e.kind==="text"?e.text.fontSize:void 0;if(t==="color")return e.kind==="color"||e.kind==="progress"?e.color:void 0;if(t==="color.a")return e.kind==="color"||e.kind==="progress"?e.color.a??1:void 0;if(t==="tint")return e.kind==="texture"||e.kind==="textureProgress"?e.tint??za:void 0;if(t==="tint.a")return e.kind==="texture"||e.kind==="textureProgress"?e.tint?.a??1:void 0;if(t==="text.color")return e.kind==="text"?e.text.color:void 0;if(t==="text.color.a")return e.kind==="text"?e.text.color.a??1:void 0;if(t==="editorPreviewPercent")return e.kind==="progress"||e.kind==="textureProgress"?Ju(e):void 0}function th(e,t,r){let n=Fi(e),o=e.layers.map((a,i)=>({layer:a,index:i})).filter(a=>Do(a.layer,r));return{textureSize:n,mask:e.mask,layers:o.map(({layer:a,index:i})=>Ny(t,a,i,r)),previewLayers:e.layers.map((a,i)=>{let s=Ny(t,a,i,r),c=r.getLayerPreviewVisibility?.(a,e);return c?{...s,enabled:s.enabled!==!1&&c.value,previewVisibilityPath:c.path,previewVisibilityBaseEnabled:s.enabled!==!1}:s})}}function Ny(e,t,r,n){return{index:r,id:t.id,role:t.role,kind:t.kind,label:rh(t,n),rect:t.rect,rotationDeg:t.rotationDeg??0,rotationEditable:Pc(t,n),enabled:t.enabled!==!1,editable:Do(t,n),zOrder:t.zOrder,...typeof t.opacity=="number"?{opacity:t.opacity}:{},...n.useUniformLayoutScaleMode?.(t)?{scaleMode:"uniform"}:{},...t.kind==="progress"||t.kind==="textureProgress"?{previewValuePath:`groundDecal.layers.${r}.editorPreviewPercent`}:{},...t.kind==="text"&&typeof t.text.fontSize=="number"?{fontSize:t.text.fontSize}:{},preview:LO(e,t,n)}}function rh(e,t={}){let r=t.createLayerLabel?.(e);return r||e.role.charAt(0).toUpperCase()+e.role.slice(1)}function LO(e,t,r){if(t.kind==="texture"||t.kind==="textureProgress"){if(!t.textureId)return;let n=r.findTextureAsset?.(e,t.textureId)??null,o=n?.url??e.resolveTextureAssetUrl?.(t.textureId)??r.resolveTextureAssetUrl?.(t.textureId);return o?{kind:t.kind==="textureProgress"?"imageProgress":"image",url:o,alt:n?.label??t.textureId,imageFit:r.resolveImageFit?.(t)??t.imageFit??"contain",...t.tint?{tint:t.tint}:{},...t.kind==="textureProgress"?{value:Fy(t),direction:t.direction}:{}}:void 0}if(t.kind==="color")return{kind:"color",color:t.color};if(t.kind==="progress")return{kind:"progress",value:Fy(t),direction:t.direction,color:t.color};if(t.kind==="text")return{kind:"text",text:t.text.value,fontFamily:t.text.fontFamily,fontSize:t.text.fontSize,fontWeight:t.text.fontWeight,color:t.text.color,strokeColor:t.text.strokeColor,strokeWidth:t.text.strokeWidth,align:t.text.align,baseline:t.text.baseline}}function Ju(e){let t=typeof e.editorPreviewPercent=="number"&&Number.isFinite(e.editorPreviewPercent)?e.editorPreviewPercent:gO;return Math.round(Math.max(0,Math.min(100,t)))}function Fy(e){return Ju(e)/100}function zO(e,t,r,n,o,a,i){let s=i.getMaterialText?.("zh"),c=i.findTextureAsset?.(t,r.textureId)??null,d=`groundDecal.layers.${n}.textureId`;return i.createDocumentInspectorProperty(null,e,{path:d,label:`${o} PNG`,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.textureId??"",commitMode:"change",order:a,tags:["GroundDecalUI","TextureAsset"],controlOptions:i.createTexturePickerControlOptions?.(t,s,r.textureId,c)??{currentTextureId:r.textureId,currentTexture:c},coerce:u=>i.normalizeValue(d,u)})}function BO(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function VO(e,t,r,n,o,a){let i=`groundDecal.layers.${r}.editorPreviewPercent`;return a.createDocumentInspectorProperty(null,e,{path:i,label:`${n} Preview %`,valueType:"number",control:"number",value:Ju(t),commitMode:"blur",order:o,min:0,max:100,step:1,tags:["GroundDecalUI","Progress"],controlOptions:{refreshInspector:!1},coerce:s=>a.normalizeValue(i,s)})}function UO(e,t,r,n,o,a){let i=t.tint??za;return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.tint`,label:`${n} Color`,valueType:"color",control:"color",value:i,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function KO(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.text.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.text.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function HO(e){return e.size.width>0&&e.size.depth>0}function WO(e){return e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:1}function qO(e,t){let r=j(t);r&&e.push(r)}function JO(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function _y(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Wa(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function XO(e){return typeof e=="string"&&e.trim()?e.trim():null}var Rn="groundDecal";function YO(e){if(e.id!==Rn||e.scene?.kind!==Rn||!e.config||typeof e.config!="object"||Array.isArray(e.config))return null;let t=e.config;return!Array.isArray(t.uiKinds)||t.uiKinds.length===0||t.uiKinds.some(r=>typeof r!="string"||r.trim().length===0)||!t.documentPolicy||typeof t.documentPolicy!="object"||Array.isArray(t.documentPolicy)||typeof t.documentPolicy.createDefaultGroundDecal!="function"||typeof t.documentPolicy.isGroundDecalConfig!="function"?null:t}function nh(e,t){let r=YO(e);if(!r)return null;let n=r.documentPolicy,o=ZO(n),a=s=>s?.transformType===Rn&&o.isGroundDecalConfig(s.groundDecal);return QO({features:[e],documentPolicy:o,createInspectorServices:(s,c)=>Ly({policy:{...o,...r.inspectorPolicy??{}},createDocumentInspectorProperty:s,normalizeValue:Tc,findTarget:(d,u)=>d.scene.gameObjects.find(l=>l.id===u)??null,getTargetId:d=>d.id,getTargetNodeKind:d=>d.kind??"transform",getTargetGroundDecal:d=>d.groundDecal??null,canShowTarget:a,isUiTarget:a,canPatchMultiField:c.canPatchMultiField,findTextureAsset:(d,u)=>ou(d,u??""),getMaterialText:gr,createTexturePickerControlOptions:(d,u,l,m)=>Ws(d,u,l??"",m)}),getDocumentInspectorPropertyFactory:t,createDefaultGroundDecal:o.createDefaultGroundDecal,createObjectPatch:s=>({kind:"game-object.create-primitive",gameObject:s}),isGroundDecalObject:a,createHierarchyLabel:r.createHierarchyLabel}).contribution}function ZO(e){let t=e;return{...e,createDefaultGroundDecal:r=>structuredClone(e.createDefaultGroundDecal(r)),isGroundDecalConfig(r){return e.isGroundDecalConfig(structuredClone(r))},...typeof t.isProjectEditableLayer=="function"?{isProjectEditableLayer:r=>t.isProjectEditableLayer(structuredClone(r))}:{},...typeof t.isLayoutEditableLayer=="function"?{isLayoutEditableLayer:r=>t.isLayoutEditableLayer(structuredClone(r))}:{},...typeof t.isRotationEditableLayer=="function"?{isRotationEditableLayer:r=>t.isRotationEditableLayer(structuredClone(r))}:{}}}function QO(e){let r=(e.features.find(i=>i.id===Rn)??null)?.config?.uiKinds,n=Array.isArray(r)?[...new Set(r.filter(i=>typeof i=="string"&&i.length>0))]:[],o=$y({...e.documentPolicy,canShowGroundDecalInspector:e.isGroundDecalObject,isGroundDecalUiGameObject:e.isGroundDecalObject}),a=eR({uiKinds:n,documentBridge:o,createInspectorServices:i=>e.createInspectorServices(i,o),getDocumentInspectorPropertyFactory:e.getDocumentInspectorPropertyFactory,createDefaultGroundDecal:e.createDefaultGroundDecal,createObjectPatch:e.createObjectPatch,canShowInspector:e.isGroundDecalObject,isGroundDecalObject:e.isGroundDecalObject,createHierarchyLabel:e.createHierarchyLabel});return{bridge:o,contribution:a,uiKinds:n,resolve(i){return i.id===Rn&&i.scene?.kind===Rn?a:null}}}function eR(e){let t=e.documentBridge;return{documentReducerImmutability:"preserves-input",transformTypeOptions:[{label:"Ground Decal",value:Rn}],normalizeInspectorValue:(n,o)=>n.startsWith("groundDecal.")?Tc(n,o):void 0,validateInspectorField({path:n,value:o}){if(n==="groundDecal.uiKind")return e.uiKinds.includes(String(o))?{ok:!0,value:o}:{ok:!1,message:"Invalid value for scene node field: groundDecal.uiKind."};if(n==="groundDecal.size.width"||n==="groundDecal.size.depth")return typeof o=="number"&&Number.isFinite(o)&&o>0?{ok:!0,value:o}:{ok:!1,message:`Invalid value for scene node field: ${n}.`};if(n==="groundDecal.layers"){let a=t.normalizeLayoutPatchValue(o);return a?{ok:!0,value:a}:{ok:!1,message:"Invalid value for scene node field: groundDecal.layers."}}return zy(n,o)},isInspectorPatchPath:Ec,isProjectionPath:qy,normalizeDocumentAfterCommand:t.normalizeScalesForCommand,normalizeAfterFieldPatch:t.normalizeScaleAfterFieldPatch,fieldMutation:{isCustomTransformType:n=>n==="groundDecal",applyCustomTransformType(n,o){o==="groundDecal"&&(n.groundDecal=t.mergeDefaults(n.groundDecal))},clearCustomTransformState(n,o){o!=="groundDecal"&&delete n.groundDecal},patchCustomTransformField(n,o,a){return o.startsWith("groundDecal.")?(n.kind="transform",n.transformType=n.transformType??"groundDecal",delete n.primitive,n.groundDecal=t.mergeDefaults(n.groundDecal),rR(n,o,a),!0):!1}},createInspectorPropertyPatch({gameObject:n,path:o,value:a,collectChangedIds:i}){if(!e.isGroundDecalObject(n))return null;let s=Hu(o,a);return s===null?null:{label:`Patch ${n.id} transform.scale`,patch:{kind:"game-object.field",targetId:n.id,path:"transform.scale",value:{x:s,y:s,z:s}},changedId:n.id,changedIds:i()}},patchGameObjectField:({document:n,targetId:o,path:a,value:i})=>a==="groundDecal.uiKind"?t.patchKind(n,o,i):a==="groundDecal.layers"?t.patchLayout(n,o,i):t.patchInspectorField(n,o,a,i),patchGameObjectsField:({document:n,targetIds:o,path:a,value:i,patchSingle:s})=>a==="groundDecal.uiKind"||a==="groundDecal.layers"||Ec(a)?o.reduce((c,d)=>s(c,d,a,i),n):null,reducePatch:({document:n,patch:o})=>o.kind==="game-object.ground-decal-ui.replace"?t.replaceUi(n,String(o.targetId),o.groundDecal):null,createHierarchyPatch:(n,o)=>tR(n,o,e),createInspectorSections:n=>e.canShowInspector(n.gameObject)?[Yy(n.gameObject,n.nodeKind,n.context,e.createInspectorServices(n.createDocumentInspectorProperty))]:[],createMultiInspectorSection:({document:n,targetIds:o,activeId:a,context:i})=>Zy(n,o,a,i,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),resolveMultiInspectorTargetIds:(n,o)=>Qy(n,o,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),isSerializedMultiFieldPath:Ka,isSerializedMultiProjectionPath:Ka,getSerializedMultiProbeValue:nR,canPatchSerializedMultiField:({document:n,targetId:o,path:a,value:i})=>!Ka(a)||t.canPatchMultiField(n,o,a,i)}}function tR(e,t,r){let n=t.startsWith("ground-decal:")?t.slice(13):"";if(!r.uiKinds.includes(n))return null;let o=it(e.scene.gameObjects.map(d=>d.id),`${n}_ground_decal_ui`),a=r.createHierarchyLabel?.(n)??`${n} Ground Decal UI`,i=new Set(e.scene.gameObjects.map(d=>d.name).filter(Boolean)),s=a;for(let d=2;i.has(s);d+=1)s=`${a} ${d}`;let c={id:o,guid:he(),name:s,kind:"transform",parentId:fe(e)??void 0,active:!0,transformType:"groundDecal",groundDecal:r.createDefaultGroundDecal(n),components:[{type:"Transform",position:{x:0,y:.02,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Add ${a}`,patch:r.createObjectPatch(c),createdId:o,changedIds:[o],reprojectIds:[o]}}function rR(e,t,r){let n=t.split("."),o=e;for(let a of n.slice(0,-1))o=o[a]??={};o[n[n.length-1]]=r}function nR(e){if(e.endsWith(".width")||e.endsWith(".depth"))return 1;if(e.endsWith(".rotationDeg"))return 45;if(e.endsWith("textureWidth")||e.endsWith("textureHeight"))return 512;if(e==="groundDecal.layers")return{layers:[{id:"mainLogo",rect:{x:0,z:0,width:1,depth:1}}]};if(uc(e))return"texture_probe";if(pc(e))return"30";if(mc(e)||Sc(e)||gc(e))return{r:1,g:1,b:1,a:1};if(fc(e)||yc(e)||bc(e))return 1;if(hc(e))return 75;if(lc(e))return Ao({x:0,z:0,width:1,depth:1});if($r(e))return Ha(512)}function qa(e){let t=typeof e=="string"&&e.trim()?e.trim():void 0;if(!t)return;if(t.includes("\0"))throw new Error("external_asset_path_must_be_portable");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))throw new Error("external_asset_path_must_be_portable");let n=[];for(let o of r.split("/"))if(!(!o||o===".")){if(o==="..")throw new Error("external_asset_path_must_be_portable");n.push(o)}if(n.length===0)throw new Error("external_asset_path_must_be_portable");return n.join("/")}function se(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function xc(e,t=4,r="$"){if(!Number.isInteger(t)||t<0||t>100)throw new Error(`json.number.invalidDecimalPlaces: ${t}`);let n=[],o=a=>{if(typeof a=="number"){if(!Number.isFinite(a))throw new Error(`json.number.nonFinite: ${oR(r,n)}`);if(Object.is(a,-0))return 0;if(Number.isInteger(a))return a;let i=Number(a.toFixed(t));return Object.is(i,-0)?0:i}if(Array.isArray(a)){let i;for(let s=0;s<a.length;s+=1){let c=a[s];n.push(s);let d=o(c);n.pop(),!Object.is(d,c)&&(i??=a.slice(),i[s]=d)}return i??a}if(a&&typeof a=="object"){let i=a,s;for(let[c,d]of Object.entries(i)){n.push(c);let u=o(d);n.pop(),!Object.is(u,d)&&(s??={...i},s[c]=u)}return s??a}return a};return o(e)}function oR(e,t){return t.reduce((r,n)=>typeof n=="number"?`${r}[${n}]`:`${r}.${n}`,e)}var Xu=64*1024,aR=8,oh=256,iR=8*1024,sR=new Set(["assetPath","projectAssetId","platformAssetId","guid","assetName","displayName","assetType","mimeType","assetUrl","category","placeable","warmupCount","singleton","materialMode","defaultScale","scale","metadata","external"]);function ah(e){if(!Ja(e))throw new Error("asset_import_payload_must_be_object");for(let a of Object.keys(e))if(!sR.has(a))throw new Error(`asset_import_field_not_allowed:${a}`);uR(e);let t=structuredClone(e),r=t.assetPath===void 0?void 0:dR(t.assetPath),n=wo(t.projectAssetId,"projectAssetId");if(!r&&!n)throw new Error("asset_import_asset_path_or_project_asset_id_required");if(t.assetType!==void 0&&t.assetType!=="model"&&t.assetType!=="texture")throw new Error("asset_import_asset_type_invalid");let o=["platformAssetId","guid","assetName","displayName","mimeType","assetUrl","category","materialMode"];for(let a of o){let i=wo(t[a],a);i&&(t[a]=i)}for(let a of["placeable","singleton"])if(t[a]!==void 0&&typeof t[a]!="boolean")throw new Error(`asset_import_${a}_must_be_boolean`);if(t.warmupCount!==void 0&&(!Number.isInteger(t.warmupCount)||t.warmupCount<0))throw new Error("asset_import_warmupCount_must_be_non_negative_integer");for(let a of["defaultScale","scale"])t[a]!==void 0&&(t[a]=lR(t[a],a));if(t.metadata!==void 0&&!Ja(t.metadata))throw new Error("asset_import_metadata_must_be_object");if(t.external!==void 0){if(!Ja(t.external))throw new Error("asset_import_external_must_be_object");let a=new Set(["platformAssetId","assetPath","assetUrl"]);for(let s of Object.keys(t.external))if(!a.has(s))throw new Error(`asset_import_external_field_not_allowed:${s}`);let i=t.external.assetPath===void 0?void 0:cR(t.external.assetPath,"external.assetPath");t.external={...wo(t.external.platformAssetId,"external.platformAssetId")?{platformAssetId:wo(t.external.platformAssetId,"external.platformAssetId")}:{},...i?{assetPath:i}:{},...wo(t.external.assetUrl,"external.assetUrl")?{assetUrl:wo(t.external.assetUrl,"external.assetUrl")}:{}}}return{...t,...r?{assetPath:r}:{},...n?{projectAssetId:n}:{}}}function cR(e,t){if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);try{let r=qa(e);if(!r)throw new Error("empty");if(r.length>1024)throw new Error("too_long");return r}catch{throw new Error(`asset_import_${t}_must_be_project_relative`)}}function dR(e){if(typeof e!="string")throw new Error("asset_import_assetPath_must_be_string");let t=e.trim();if(!t||t.includes("\0")||t.length>4096)throw new Error("asset_import_assetPath_invalid");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||r.startsWith("//"))return r;try{return qa(r)??""}catch{throw new Error("asset_import_assetPath_invalid")}}function wo(e,t){if(e===void 0)return;if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);let r=e.trim();if(!r)throw new Error(`asset_import_${t}_must_not_be_empty`);if(r.length>1024)throw new Error(`asset_import_${t}_too_long`);return r}function lR(e,t){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(Ja(e)&&Object.keys(e).every(r=>r==="x"||r==="y"||r==="z")&&typeof e.x=="number"&&Number.isFinite(e.x)&&e.x>0&&typeof e.y=="number"&&Number.isFinite(e.y)&&e.y>0&&typeof e.z=="number"&&Number.isFinite(e.z)&&e.z>0)return{x:e.x,y:e.y,z:e.z};throw new Error(`asset_import_${t}_invalid`)}function uR(e){let t=0,r=(n,o)=>{if(o>aR)throw new Error("asset_import_payload_too_deep");if(n===null||typeof n=="boolean")return;if(typeof n=="number"){if(!Number.isFinite(n))throw new Error("asset_import_payload_number_invalid");return}if(typeof n=="string"){if(n.length>iR)throw new Error("asset_import_payload_string_too_long");return}if(Array.isArray(n)){if(t+=n.length,t>oh)throw new Error("asset_import_payload_too_many_values");for(let i of n)r(i,o+1);return}if(!Ja(n)||Object.getPrototypeOf(n)!==Object.prototype)throw new Error("asset_import_payload_not_json_safe");let a=Object.entries(n);if(t+=a.length,t>oh)throw new Error("asset_import_payload_too_many_values");for(let[,i]of a){if(i===void 0||typeof i=="function"||typeof i=="symbol"||typeof i=="bigint")throw new Error("asset_import_payload_not_json_safe");r(i,o+1)}};if(r(e,0),new TextEncoder().encode(JSON.stringify(e)).byteLength>Xu)throw new Error("asset_import_payload_too_large")}function Ja(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Xa(){return{isCoreMaterialOverridePath:dl,isMaterialAssetIdOverridePath:rg,addMaterialAsset:$s}}function ih(e,t=[]){return e.assets.filter(Xe).flatMap(r=>{let n=r.prefab?.sourceAssetId;if(typeof n!="string"||n.length===0)return[];let o=mR(r,t);return[{id:`prefab:${r.id}`,assetId:r.id,guid:r.guid,type:"prefab",kind:"prefab",label:r.displayName??r.id,displayName:r.displayName??r.id,category:r.category??"Prefab",origin:"project",placeable:o.placeable,...o.availability?{availability:structuredClone(o.availability)}:{},dedupeKey:`prefab:${r.guid??r.id}`,prefab:{id:r.id,guid:r.guid,displayName:r.displayName??r.id,category:r.category??"Prefab",...structuredClone(r.prefab),sourceAssetId:n},metadata:structuredClone(r.metadata??{})}]})}function mR(e,t){let r=e.prefab?.sourceAssetId,n=typeof r=="string"?t.find(a=>a.assetId===r||a.id===r):void 0,o=n?.availability;return{placeable:n?.placeable!==!1&&o?.status!=="unavailable",...o?{availability:o}:{}}}function Yu(e,t,r=Xa()){if(e==="displayName"&&typeof t=="string")return t.trim();if(e==="prefab.defaults.active")return t??null;if(Qu(e))return t==null?null:e==="prefab.defaults.shadow"?t:e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"?t===!0?"enabled":t===!1?"none":t:t;if(r.isMaterialAssetIdOverridePath(e)&&typeof t=="string"){let n=t.trim();return n||null}return t}function Zu(e,t,r=Xa()){if(e==="displayName")return typeof t=="string"&&t.length>0;if(e==="prefab.defaults.active")return t==null||typeof t=="boolean";if(Qu(e)){if(e==="prefab.defaults.shadow")return!!t&&typeof t=="object"&&typeof t.cast=="boolean"&&typeof t.receive=="boolean";let n=e.slice(16);return mo({path:n,nodeKind:"instance",value:t}).ok}return r.isCoreMaterialOverridePath(e)?r.isMaterialAssetIdOverridePath(e)&&(t==null||typeof t=="string"&&t.trim().length>0):!1}function Qu(e){return e==="prefab.defaults.shadow"||e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"}function sh(e,t,r){let n=[...e.assets];r&&!n.some(a=>a.id===r.id)&&n.push(structuredClone(r));let o=Ac(t);return n.some(a=>a.id===t.id)||n.push(structuredClone(o)),n.length===e.assets.length?e:{...e,assets:n}}function em(e,t,r,n,o=Xa()){if(r==="displayName")return e;let a=e.assets.find(s=>s.id===t&&Xe(s));if(!a)return e;let i=fR(dh(a),r,n,o);return JSON.stringify(i)===JSON.stringify(a)?e:{...e,assets:e.assets.map(s=>s.id===t?i:s)}}function ch(e,t,r,n){let o=e.assets.find(s=>s.id===t&&Xe(s));if(!o)return e;let a=n&&!e.assets.some(s=>s.id===n.id)?[...e.assets,structuredClone(n)]:e.assets,i=Ac({...structuredClone(r),id:t});return JSON.stringify(i)===JSON.stringify(o)&&a===e.assets?e:{...e,assets:a.map(s=>s.id===t?i:s)}}function fR(e,t,r,n=Xa()){if(t==="displayName")return e;if(t==="prefab.defaults.active"||Qu(t)){let o=structuredClone(e),a=structuredClone(o.prefab??e.prefab);if(a.defaults={...a.defaults??{}},t==="prefab.defaults.active")r==null?delete a.defaults.active:a.defaults.active=r;else{if(t==="prefab.defaults.shadow"){if(!r||typeof r!="object")return e;let s=r.cast,c=r.receive;return typeof s!="boolean"||typeof c!="boolean"?e:(a.defaults.shadow={cast:s?"enabled":"none",receive:c?"enabled":"none"},o.prefab=a,Ac(o))}if(r!=="enabled"&&r!=="none")return e;let i=a.defaults.shadow;a.defaults.shadow={cast:t==="prefab.defaults.shadow.cast"?r:i?.cast==="enabled"?"enabled":"none",receive:t==="prefab.defaults.shadow.receive"?r:i?.receive==="enabled"?"enabled":"none"}}return Object.keys(a.defaults).length===0&&delete a.defaults,o.prefab=a,Ac(o)}return ma(e,t,r)}function dh(e){if(!Xe(e))return e;let t=Qp(e);return t.ok?t.prefabAsset:e}function Ac(e){if(!Xe(e))return e;let t=dh(e),r=Ye(t);if(!r||!Array.isArray(t.prefab?.nodes))return t;let n=t.prefab.nodes.findIndex(a=>a.id===r);if(n<0)return t;let o=structuredClone(t.prefab.nodes[n]);if(o.name=t.displayName??o.name,t.prefab.defaults){let{shadow:a,...i}=t.prefab.defaults;Object.keys(i).length>0?o.defaults=structuredClone(i):delete o.defaults}else delete o.defaults;return t.prefab.nodes=[...t.prefab.nodes],t.prefab.nodes[n]=o,t}function lh(e,t,r,n,o=Xa()){let a=o.addMaterialAsset(e,n);return em(a,t,r,n.id,o)}function mh(e,t,r,n){let o=Le(e,t.assetId),a=t.sourceAssetId??o?.prefab?.sourceAssetId,i=a?e.assets.find(l=>l.id===a):null,s=pR(i,a),c=Dc(i),d=gR(c,!!n.importStructureReady),u=ph(n.importStructure)?gh(n.importStructure):[];return Mc([s,...d?[d]:[],...u],r)}function pR(e,t){return{id:"prefab-source",label:e?.displayName??t??"Missing source asset",kind:"source",sourceAssetId:t,...e?.metadata?.relativePath?{meta:e.metadata.relativePath}:{}}}function gR(e,t){return e.length===0?null:{id:"prefab-material-slots",label:`${t?"Editable Material Slots":"Meshes / Materials"} (${e.length})`,kind:"group",children:[...e]}}function Dc(e){return(Array.isArray(e?.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(SR).filter(r=>!!r).map((r,n)=>{let o=r.sourceSurfaces[0],a=Sh(o.ownerNodePath),i=nt(r),s=i.map(m=>xn(r,m)).filter(m=>!!m);if(s.length===0&&r.materialNames?.length&&s.push(...r.materialNames.filter(m=>typeof m=="string"&&!!m.trim())),s.length===0&&r.materialName&&s.push(r.materialName),!r.slotId)return null;let c=`prefab.overrides.materialSlotBindings.${r.slotId}`,d=o.sourceMaterialIndex,u=r.label??s[0]??a.split("/").filter(Boolean).pop()??`Material Slot ${n+1}`;return{id:`prefab-material-slot:${rm(r.slotId??a,`material_slot_${n+1}`)}:${n+1}`,itemType:"prefab-material-slot",label:u,kind:"material",bindingKind:"slot",bindingPath:c,materialAssetIdPath:`${c}.materialAssetId`,profilePathPrefix:`${c}.override`,slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:a,...typeof o.nodeIndex=="number"?{nodeIndex:o.nodeIndex}:{},...o.nodeIndexPath?.length?{nodeIndexPath:o.nodeIndexPath}:{},...typeof o.meshIndex=="number"?{meshIndex:o.meshIndex}:{},...typeof o.primitiveIndex=="number"?{primitiveIndex:o.primitiveIndex}:{},...d==null?{}:{sourceMaterialIndex:d},...i.length>0?{sourceMaterialIndices:i}:{},...s[0]?{sourceMaterialName:s[0]}:{},...s.length>0?{sourceMaterialNames:s}:{},...r.sourceSurfaces.length===1&&typeof o.triangleCount=="number"?{triangleCount:o.triangleCount}:{},...r.sourceSurfaces.length===1&&o.boundingBox?{boundingBox:o.boundingBox}:{},meta:[a,r.sourceSurfaces.length===1?`primitive #${o.primitiveIndex}`:`${r.sourceSurfaces.length} source surfaces`,s.length>0?s.join(", "):null].filter(Boolean).join(" - ")}}).filter(r=>r!=null)}function fh(e){return e.map(t=>[t.label,typeof t.primitiveIndex=="number"?`primitive #${t.primitiveIndex}`:null,typeof t.sourceMaterialIndex=="number"?`material #${t.sourceMaterialIndex}`:null,typeof t.triangleCount=="number"?`${t.triangleCount} triangles`:null,bR(t.boundingBox)].filter(Boolean).join(" \xB7 ")).join(`
4
- `)}function bR(e){if(!e)return null;let t=e.min?e.min.join(", "):"",r=e.max?e.max.join(", "):"";return t&&r?`bounds min ${t}; max ${r}`:t?`bounds min ${t}`:r?`bounds max ${r}`:null}function SR(e){return no(e)}function ph(e){return["nodes","materials","textures","animations"].some(t=>Ya(e,t).length>0)}function gh(e){let t=[],r=Ya(e,"nodes");r.length>0&&t.push({id:"prefab-import-nodes",label:`Nodes (${r.length})`,kind:"group",children:yR(r)});let n=Ya(e,"materials");n.length>0&&t.push({id:"prefab-import-materials",label:`Materials (${n.length})`,kind:"group",children:n.map((i,s)=>tm(i,s,"material"))});let o=Ya(e,"textures");o.length>0&&t.push({id:"prefab-import-textures",label:`Textures (${o.length})`,kind:"group",children:o.map((i,s)=>tm(i,s,"texture"))});let a=Ya(e,"animations");return a.length>0&&t.push({id:"prefab-import-animations",label:`Animations (${a.length})`,kind:"group",children:a.map((i,s)=>tm(i,s,"animation"))}),t}function yR(e){let t=e.map((o,a)=>{let i=Re(o.id)??`runtime-node-${a+1}`,s=Re(o.kind),c={id:`prefab-import-node:${rm(i,`node_${a+1}`)}`,runtimeId:i,label:Re(o.name)??Re(o.sourceName)??i,kind:s==="mesh"?"mesh":s==="root"?"root":"group",...Re(o.ownerNodePath)?{ownerNodePath:Re(o.ownerNodePath)}:{},...Re(o.sourceName)?{sourceName:Re(o.sourceName)}:{},...Array.isArray(o.materialIds)?{materialIds:o.materialIds.filter(d=>typeof d=="string")}:{},children:[]};return{runtimeId:i,parentId:Re(o.parentId),item:c}}),r=new Map(t.map(o=>[o.runtimeId,o.item])),n=[];for(let o of t)o.parentId&&r.has(o.parentId)?r.get(o.parentId).children.push(o.item):n.push(o.item);return n}function tm(e,t,r){let n=Re(e.id)??`${r}-${t+1}`,o=Re(e.url),a=Array.isArray(e.nodeIds)?e.nodeIds.filter(s=>typeof s=="string"):[],i=Array.isArray(e.textureIds)?e.textureIds.filter(s=>typeof s=="string"):[];return{id:`prefab-import-${r}:${rm(n,`${r}_${t+1}`)}`,itemType:r==="material"?"runtime-material":r==="texture"?"runtime-texture":"runtime-animation",runtimeId:n,label:Re(e.name)??n,kind:r,...Re(e.kind)?{runtimeKind:Re(e.kind)}:{},...o?{url:o}:{},...a.length>0?{nodeIds:a}:{},...i.length>0?{textureIds:i}:{},meta:[Re(e.kind),o,a.length>0?`${a.length} node${a.length===1?"":"s"}`:null,i.length>0?`${i.length} texture${i.length===1?"":"s"}`:null].filter(Boolean).join(" - ")}}function bh(e,t,r,n){if(r.itemType==="prefab-material-slot"||r.itemType==="runtime-material"||r.itemType==="runtime-texture")return r;if(r.itemType!=="prefab-node"||r.kind!=="model")return null;let o=typeof r.sourceAssetId=="string"?r.sourceAssetId:t.sourceAssetId;if(!o)return null;let a=e.assets.find(c=>c.id===o),i=Dc(a);if(i.length>0){let c=i[0]??null;return c?{...c,...typeof r.nodeId=="string"?{prefabNodeId:r.nodeId}:{}}:null}return(ph(n.importStructure)?gh(n.importStructure).find(c=>c.id==="prefab-import-materials"):null)?.children?.[0]??null}function Mc(e,t){for(let r of e){if(r.id===t)return r;let n=r.children?Mc(r.children,t):null;if(n)return n}return null}function Sh(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join("/")}function rm(e,t){return Sh(e).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function Ya(e,t){let n=uh(e)?.[t];return Array.isArray(n)?n.map(uh).filter(o=>!!o):[]}function uh(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Re(e){return typeof e=="string"&&e.trim()?e.trim():null}function yh(e,t,r={}){let n=Le(e,t.assetId);if(!n?.prefab)return[{id:"prefab-scene",label:"Prefab Scene Tree",kind:"root",children:[]}];let o=Ye(n),a=sl(n,null);return[{id:"prefab-root",label:"Prefab Scene Tree",kind:"root",children:(o?a.filter(s=>s.id===o):a).map(s=>hh(n,s))}]}function hh(e,t){let r=sl(e,t.id).map(n=>hh(e,n));return{id:`prefab-node:${t.id}`,nodeId:t.id,label:t.name??hR(t),kind:t.kind,itemType:"prefab-node",...t.guid?{guid:t.guid}:{},...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.childPrefabId?{childPrefabId:t.childPrefabId}:{},...t.sourceNodePath?{sourceNodePath:t.sourceNodePath}:{},...t.transform?{transform:structuredClone(t.transform)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults&&Object.keys(t.defaults).length>0?{defaults:structuredClone(t.defaults)}:{},...t.overrides&&Object.keys(t.overrides).length>0?{overrides:structuredClone(t.overrides)}:{},...r.length>0?{children:r}:{}}}function hR(e){return e.kind==="model"?e.sourceAssetId??e.id:e.kind==="prefabInstance"?e.childPrefabId??e.id:e.kind==="primitive"?e.primitive?.shape??e.id:e.id}function Eh(e,t,r){if(t.itemType!=="prefab-node"||t.kind!=="model")return null;let n=typeof t.sourceAssetId=="string"?t.sourceAssetId:null;if(!n)return null;let o=e.assets.find(S=>S.id===n),a=Dc(o),i=kc(o?.metadata?.assetAnalysis),s=nm(i?.nodes),c=nm(i?.meshes),d=wc(r.importStructure,"nodes").length,u=wc(r.importStructure,"materials").length,l=wc(r.importStructure,"textures").length,m=wc(r.importStructure,"animations").length,f=[kt("prefab.sourceStructure.sourceAsset","Source Asset",o?.displayName??n,0),kt("prefab.sourceStructure.assetId","Asset ID",n,1)];return o?.metadata?.relativePath&&f.push(kt("prefab.sourceStructure.relativePath","Relative Path",String(o.metadata.relativePath),2)),f.push(kt("prefab.sourceStructure.materialSlots","Material Slots",String(a.length),10),kt("prefab.sourceStructure.modelNodes","Model Nodes",s.length>0?ER(s):"No SDK node analysis",11),kt("prefab.sourceStructure.meshPrimitives","Mesh Primitives",c.length>0?IR(c):"No SDK mesh primitive analysis",12),kt("prefab.sourceStructure.runtimeNodes","Runtime Nodes",String(d),20),kt("prefab.sourceStructure.runtimeMaterials","Runtime Materials",String(u),21),kt("prefab.sourceStructure.runtimeTextures","Runtime Textures",String(l),22),kt("prefab.sourceStructure.runtimeAnimations","Runtime Animations",String(m),23)),a.length>0&&f.push(kt("prefab.sourceStructure.materialSlotSummary","Material Slot Summary",fh(a),30)),{id:"prefab-source-structure",title:"Source Structure",summary:o?"Readonly GLB / glTF anatomy":"Missing source asset",persistence:"readonly",effect:o?"active":"unsupported",properties:f}}function ER(e){return e.slice(0,8).map((t,r)=>{let n=Oc(t.ownerNodePath)??Oc(t.name)??`node #${typeof t.nodeIndex=="number"?t.nodeIndex:r}`,o=typeof t.meshIndex=="number"?`mesh #${t.meshIndex}`:null,a=typeof t.primitiveCount=="number"?`${t.primitiveCount} primitives`:null;return[n,o,a].filter(Boolean).join(" \xB7 ")}).join(`
5
- `)}function IR(e){return e.slice(0,8).map((t,r)=>{let n=Oc(t.name)??`mesh #${typeof t.meshIndex=="number"?t.meshIndex:r}`,o=nm(t.primitives);if(o.length===0)return n;let a=o.slice(0,6).map((i,s)=>[`p${typeof i.primitiveIndex=="number"?i.primitiveIndex:s}`,typeof i.sourceMaterialIndex=="number"?`mat #${i.sourceMaterialIndex}`:null,Oc(i.materialName),typeof i.triangleCount=="number"?`${i.triangleCount} tri`:null].filter(Boolean).join(" ")).join(", ");return`${n}: ${a}`}).join(`
6
- `)}function wc(e,t){let n=kc(e)?.[t];return Array.isArray(n)?n.map(kc).filter(o=>!!o):[]}function kc(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function nm(e){return Array.isArray(e)?e.map(kc).filter(t=>!!t):[]}function Oc(e){return typeof e=="string"&&e.trim()?e.trim():null}function kt(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function Ih(e,t,r){let n=e.prefab?.defaults?.shadow;return[Za({path:"prefab.defaults.shadow.cast",label:"Cast Shadow",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",order:t+0,tooltip:"Controls shadow casting for the entire Prefab definition."},r),Za({path:"prefab.defaults.shadow.receive",label:"Receive Shadow",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",order:t+1,tooltip:"Controls shadow receiving for the entire Prefab definition."},r)]}function Za(e,t){let r=n=>t.normalizePrefabAssetFieldValue(e.path,e.coerce?e.coerce(n):n);return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,...e.mixed===!0?{mixed:!0}:{},readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},...e.tooltip?{tooltip:e.tooltip}:{},validate:n=>t.validatePrefabAssetFieldValue(e.path,r(n))?{ok:!0,value:r(n)}:{ok:!1,message:`Invalid prefab field: ${e.path}.`},coerce:r}}function PR(e,t,r,n,o,a){return r.itemType==="prefab-material-slot"?TR(e,t,r,n,o,a()):r.itemType==="runtime-material"?Ph("This runtime material has no stable slotId or ownerNodePath mapping.",r):r.itemType==="runtime-texture"?Ph("Texture nodes are inspection-only. Edit texture channels from a stable material slot.",r):null}function TR(e,t,r,n,o,a){let i=gr("en"),s=ng(t,r),c=r.prefabNodeId?oo(t,r.prefabNodeId):null,d=r.prefabNodeId&&r.slotId?c?.overrides?.materialSlotBindings?.[r.slotId]:s,u=typeof d?.materialAssetId=="string"?d.materialAssetId:"",l=u||(typeof s?.materialAssetId=="string"?s.materialAssetId:""),m=e,f=ee(m,l||Tn);return{id:"prefab-material-override-target",title:"Material Slot",order:20,placement:"body",summary:f?.name??"Unassigned",persistence:"document",effect:"active",collapsedByDefault:!1,properties:[ko("prefab.materialOverride.status","Status","Editable",0),ko("prefab.materialOverride.bindingPath","Binding Path",r.bindingPath,1),ko("prefab.materialOverride.materialAssetPath","Material Asset Path",r.materialAssetIdPath,2),Dn.createSelectorInspectorPropertyWithUsage(m,"instance",{path:r.materialAssetIdPath,label:"Material",value:u,order:10,text:i,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,ownerScope:"prefab",prefabAssetId:t.id,prefabNodeId:r.prefabNodeId,sourceBindingPath:r.materialAssetIdPath}},previewContext:n},a)]}}function xR(e,t,r,n,o){return PR(e,t,r,n,o,()=>_e.getCachedUsageIndex(e))}var AR={createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage:xR},Th=AR;function Ph(e,t){return{id:"prefab-material-override-target",title:"Prefab Material Override",order:20,placement:"body",summary:e,persistence:"readonly",effect:"unsupported",collapsedByDefault:!1,properties:[ko("prefab.materialOverride.status","Status","Read Only",0),ko("prefab.materialOverride.reason","Reason",e,1),ko("prefab.materialOverride.runtimeId","Runtime ID",t.runtimeId??t.id,2)]}}function ko(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function DR(e,t,r,n,o,a){let i=Le(e,t.assetId);if(!i)return null;let s=t.sourceAssetId?e.assets.find(b=>b.id===t.sourceAssetId)??null:null,c=r?Mc(yh(e,t,n),r)??mh(e,t,r,n):null,d=c?bh(e,t,c,n):null,u=d?a(e,i,d,n,o):null,l=c?Eh(e,c,n):null,m=typeof c?.nodeId=="string"?c.nodeId:null,f=m?oo(i,m):null,S=f&&f.kind!=="root"&&f.transform?.mode!=="matrix"?kR(i,f):null,g=f?.kind==="marker"&&f.marker?vR(i,f,o):null;return{targetIds:[i.id],activeId:i.id,label:n.importStructureReady?"Prefab Runtime Ready":t.label,document:e,selection:{targetIds:[i.id],activeId:i.id,scopeType:"prefab-stage",targetKind:"prefab",document:e},sections:[{id:"prefab-stage",title:"Prefab Stage",summary:n.importStructureReady?"Runtime Ready":"Preview",persistence:"document",properties:[Za({path:"displayName",label:"Display Name",valueType:"string",control:"string",value:i.displayName??i.id,order:0},o),j({path:"prefab.sourceAssetId",label:"Source Asset",value:s?.displayName??t.sourceAssetId??"Missing",order:1}),Za({path:"prefab.defaults.active",label:"Default Active",valueType:"boolean",control:"boolean",value:i.prefab?.defaults?.active??!0,order:2},o),...Ih(i,3,o),j({path:"prefab.selectedItem",label:"Selected Item",value:r??"Preview Root",order:90})].filter(b=>!!b)},...S?[S]:[],...g?[g]:[],...l?[l]:[],...u?[u]:[]]}}function MR(e,t,r,n={},o){return DR(e,t,r,n,o,Th.createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage)}var wR={createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage:MR},Ah=wR;function kR(e,t){let r=OR(t),n=t.parentId?oo(e,t.parentId):null,o=[],a=0;for(let i of["position","rotation","scale"])for(let s of["x","y","z"]){let c=r[i][s];o.push({path:`transform.${i}.${s}`,label:`${RR(i)}.${s}`,valueType:"number",control:"number",value:i==="rotation"?CR(c):c,readOnly:!1,persistence:"document",commitMode:"live",order:a,step:i==="rotation"?1:.1,validate:d=>typeof d=="number"&&Number.isFinite(d)?{ok:!0,value:d}:{ok:!1,message:"Transform value must be a finite number."},coerce:d=>typeof d=="number"?d:Number(d)}),a+=1}return{id:"transform",title:"Transform",summary:`Relative to: ${n?.name??n?.id??"Prefab"}`,order:20,placement:"body",persistence:"document",collapsedByDefault:!1,properties:o}}function OR(e){return e.transform?.type==="Transform"&&e.transform.mode!=="matrix"?{...e.transform,mode:e.transform.mode??"trs",scale:e.transform.scale??{x:1,y:1,z:1}}:{type:"Transform",mode:"trs",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function RR(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function CR(e){return Math.round(e*180/Math.PI*1e6)/1e6}function vR(e,t,r){let n=t.marker,o=n.target??null,a=o?xh(o):"",i=[{label:"Unbound",value:""},...Ze(e).filter(c=>c.id!==t.id).map(c=>{let d=c.kind==="marker"?"marker":"scene-object";return{label:c.name??c.id,value:xh({kind:d,id:c.id})}})];o&&a&&!i.some(c=>c.value===a)&&i.push({label:`Missing: ${o.id}`,value:a});let s=r.markerTypeCatalog.map(c=>({label:c.label||c.type,value:c.type}));return s.some(c=>c.value===n.type)||s.push({label:`Missing: ${n.type}`,value:n.type}),{id:"prefab-marker",title:"Marker",summary:r.markerTypeCatalog.find(c=>c.type===n.type)?.label??n.type,order:35,placement:"body",persistence:"document",collapsedByDefault:!1,properties:[Qa({path:"prefab.marker.type",label:"Marker Type",valueType:"enum",control:"enum",value:n.type,options:s,order:0,validate:c=>typeof c=="string"&&r.markerTypeCatalog.some(d=>d.type===c)}),j({path:"prefab.marker.kind",label:"Semantic Kind",value:n.kind??"point",order:1,source:"Derived"}),j({path:"prefab.marker.geometry",label:"Geometry",value:n.geometry.kind,order:2,source:"Derived"}),Qa({path:"prefab.marker.target",label:"Target",valueType:"enum",control:"enum",value:a,options:i,order:3,validate:c=>typeof c=="string"&&i.some(d=>d.value===c)}),j({path:"prefab.marker.targetStatus",label:"Target Status",value:o?i.some(c=>c.value===a&&!c.label.startsWith("Missing:"))?"Resolved":"Unresolved local reference":"Unbound",order:4,source:"Derived"}),Qa({path:"prefab.marker.tags",label:"Tags",valueType:"string",control:"string",value:n.tags?.join(", ")??"",order:5,validate:c=>typeof c=="string"}),Qa({path:"prefab.marker.note",label:"Note",valueType:"string",control:"string",value:n.note??"",order:6,validate:c=>typeof c=="string"}),Qa({path:"prefab.marker.color",label:"Color",valueType:"color",control:"color",value:n.color??{r:.1,g:.85,b:1},order:7,validate:GR})].filter(c=>!!c)}}function Qa(e){return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},validate:t=>e.validate(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid Prefab Marker field: ${e.path}.`}}}function xh(e){return`${e.kind}:${encodeURIComponent(e.id)}`}function GR(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return["r","g","b"].every(r=>typeof t[r]=="number"&&Number.isFinite(t[r])&&t[r]>=0&&t[r]<=1)}function Dh(e,t){let r=ln(e,t.id);if(!r.prefab)return null;let n=r.diagnostics.filter(m=>m.severity==="error").length,o=r.diagnostics.filter(m=>m.severity==="warning").length,a=r.diagnostics.filter(m=>m.severity==="info").length,i=r.diagnostics.length>0,s=n>0?"unsupported":i?"derived":"active",c=n>0?"Prefab relation is incomplete; fix the missing definition or source asset before using prefab actions.":void 0,d=r.definition?.displayName??r.definition?.id??r.prefab.prefabId,u=r.sourceAsset?.displayName??r.sourceAsset?.id??r.prefab.sourceAssetId??"Missing",l=[j({path:"prefab.relation.definition",label:"Prefab Definition",value:d,order:0,source:"Document",effect:s}),j({path:"prefab.relation.source",label:"Source Model",value:u,order:1,source:r.sourceAsset?"Asset":"Document",effect:s,disabledReason:c})].filter(m=>!!m);return i&&l.push(j({path:"prefab.relation.diagnostics",label:"Diagnostics",value:r.diagnostics.map(m=>`${m.severity}:${m.code} - ${m.message}`).join(`
7
- `),order:2,source:"Derived",effect:s,disabledReason:c})),l.push(om({path:"prefab.actions.editDefinition",label:"Edit Prefab",actionId:"prefab.edit-definition",order:10,icon:"prefab",tooltip:"Open the prefab definition stage.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(om({path:"prefab.actions.selectDefinition",label:"Select Prefab",actionId:"prefab.select-definition",order:11,icon:"prefab",tooltip:"Select the prefab asset in the asset browser.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(om({path:"prefab.actions.pingSource",label:"Ping Source",actionId:"prefab.ping-source",order:12,icon:"asset",tooltip:"Select the prefab source asset in the asset browser.",params:{assetId:r.sourceAsset?.id??r.prefab.sourceAssetId},disabled:!r.sourceAsset,disabledReason:c,effect:s})),{id:"prefab-instance",title:"Prefab",order:48,placement:"body",summary:n>0?`${n} ${n===1?"error":"errors"}`:o>0?"Warning":a>0?"Info":"Ready",persistence:"readonly",effect:s,disabledReason:c,collapsedByDefault:!1,properties:l}}function om(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Mh(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function de(e){return!!e?.marker}function im(e){return e.kind==="point"&&e.coordinateSpace!=="world"||e.kind==="object-bounds"}function Cn(e){for(let t of e.components){if(t.type!=="Transform")continue;let r=t.scale;return FR(r)?pe(r):Ie(1,1,1)}return Ie(1,1,1)}function Lr(e,t){let r=ke(e,t);return r&&It(r)?r:null}function sm(e,t,r){let n=ur(e,t??void 0,r);return n&&It(n)?n:null}function Oh(e,t){let r=ke(e,t.id);return r?Ch(r,t.name??t.id):null}function Rh(e,t){let r=lm(t);if(r?.kind!=="scene-object")return null;let n=e.scene.gameObjects.find(a=>a.id===r.id)??null,o=ke(e,r.id);return!n||!o?null:Ch(o,r.label||n.name||r.id)}function Ch(e,t){let r=Fe(e),n=Rc(Ie(r[0],r[1],r[2]));if(!n)return null;let o=Ie(r[4],r[5],r[6]),a=Rc(jR(o,am(n,wh(o,n))));if(!a)return null;let i=Rc(kh(n,a));if(!i)return null;let s=Ie(r[8],r[9],r[10]);wh(i,s)<0&&(i=am(i,-1));let c=Rc(kh(i,n));return c?{origin:Vi(e),right:n,up:c,forward:i,label:t}:null}function wh(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function kh(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function jR(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function am(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function Rc(e){let t=Math.hypot(e.x,e.y,e.z);return Number.isFinite(t)&&t>1e-6?am(e,1/t):null}function Sr(e,t,r,n={}){let o=t.trim(),a=o?eo($R(e),n).find(i=>i.type===o)?.kind:void 0;return Cc(a??r??(o?void 0:"point"))}function Cc(e){let t=e?.trim();return t?t==="object-bound"||t==="object-bounds"?"object":t:"point"}function vh(e,t){return cm(t)?"box":dm(t)&&lm(e)?"object-bounds":"point"}function vc(e,t,r,n,o={}){let a=Lr(e,t.id),i=pe(a?.position??Ie(0,0,0)),s=pe(a?.rotation??Ie(0,0,0)),c=NR(e,t,r,o)?Oo(r):pe(a?.scale??Cn(t));if(cm(r))return{kind:"box",coordinateSpace:"world",center:i,size:Nc(c),rotation:s};let d=lm(t.marker);return dm(r)&&d?{kind:"object-bounds",target:d}:n?.kind==="point"?structuredClone(n):{kind:"point",coordinateSpace:"world",position:i,...d?{target:d}:{}}}function Gh(e,t,r,n,o){if(o)return dm(n)||r.kind==="object-bounds"?{kind:"object-bounds",target:structuredClone(o)}:r.kind==="point"?{...structuredClone(r),target:structuredClone(o)}:structuredClone(r);if(r.kind==="object-bounds"){let a=Lr(e,t.id);return{kind:"point",coordinateSpace:"world",position:pe(a?.position??Ie(0,0,0))}}if(r.kind==="point"){let a=structuredClone(r);return delete a.target,a}return structuredClone(r)}function jh(e,t){let r=e.scene.gameObjects.find(n=>n.id===t)??null;return!r||de(r)?null:{kind:"scene-object",id:r.id,label:r.name||r.id}}function NR(e,t,r,n={}){let o=Sr(e,t.marker.type,t.marker.kind,n);if(o===r)return!1;let a=Lr(e,t.id)?.scale??Cn(t);return Fh(a,Oo(o))}function Nh(e,t,r,n={}){if(!de(t))return!1;let o=Sr(e,t.marker.type,t.marker.kind,n),a=Cc(r.kind);if(o===a&&t.marker.geometry.kind===r.geometry.kind)return!1;let i=Lr(e,t.id)?.scale??Cn(t);return Fh(i,Oo(o))}function Oo(e){return cm(e)?Ie(4,1,4):Ie(.5,.5,.5)}function cm(e){return Cc(e)==="region"}function dm(e){return Cc(e)==="object"}function lm(e){return e.target?structuredClone(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?structuredClone(e.geometry.target):null}function Fh(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function _h(e){switch(e.kind){case"box":return{kind:"box"};case"point":return{kind:"point",coordinateSpace:e.coordinateSpace,...e.coordinateSpace==="local"?{position:pe(e.position)}:{},...e.target?{target:structuredClone(e.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(e.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:e.coordinateSpace,vertices:e.vertices.map(pe),...e.faces?{faces:e.faces.map(t=>[...t])}:{}}}}function Gc(e){switch(e.kind){case"box":return pe(e.center);case"point":return e.coordinateSpace==="world"?pe(e.position):Ie(0,0,0);case"polyhedron":return _R(e.vertices);case"object-bounds":return Ie(0,0,0)}}function jc(e){return e.kind==="box"&&e.rotation?pe(e.rotation):Ie(0,0,0)}function um(e,t){return e.kind==="box"?Nc(e.size):pe(t)}function Nc(e){return{x:Math.max(1e-6,Math.abs(e.x)),y:Math.max(1e-6,Math.abs(e.y)),z:Math.max(1e-6,Math.abs(e.z))}}function Fc(e){return e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function pe(e){return{x:e.x,y:e.y,z:e.z}}function FR(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function Ie(e,t,r){return{x:e,y:t,z:r}}function $h(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function _R(e){if(e.length===0)return Ie(0,0,0);let t={x:Math.min(...e.map(n=>n.x)),y:Math.min(...e.map(n=>n.y)),z:Math.min(...e.map(n=>n.z))},r={x:Math.max(...e.map(n=>n.x)),y:Math.max(...e.map(n=>n.y)),z:Math.max(...e.map(n=>n.z))};return{x:(t.x+r.x)/2,y:(t.y+r.y)/2,z:(t.z+r.z)/2}}function $R(e){return e.scene.markerGraph??null}function _c(e,t={}){let r=HR(e,t);if(r!==e)return _c(r,t);let n=LR(e);if(n!==e)return _c(n,t);let o=$c(e);if(!o)return e;let a=cr(o),i=zR(e,a);return oa(o,i)?e:zd(e,i)}function LR(e){let t=$c(e),r=t?cr(t):null;if(!r||r.markers.length===0)return e;let n=new Set(e.scene.gameObjects.map(c=>c.id)),o=new Map,a=[];for(let c of r.markers){if(e.scene.gameObjects.some(u=>u.id===c.id&&de(u))){o.set(c.id,c.id);continue}let d=n.has(c.id)?YR(c.id,n):c.id;n.add(d),o.set(c.id,d),a.push({marker:c,gameObjectId:d})}let i=a.map(c=>zh(e,Sp(c.marker,o),c.gameObjectId,null)),s=cr({...r,markers:[],relations:r.relations.map(c=>bp(c,o))});return{...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,...i],markerGraph:s}}}function zR(e,t){let r=new Set(e.scene.gameObjects.map(i=>i.id)),n=t.markers.filter(i=>BR(i,r)),o=new Set([...n.map(i=>i.id),...e.scene.gameObjects.filter(de).map(i=>i.id)]),a=t.relations.filter(i=>Ld(i.from,r,o)&&Ld(i.to,r,o));return{...t,markers:n,relations:a}}function BR(e,t){if(!na(e.target,t))return!1;switch(e.geometry.kind){case"object-bounds":return na(e.geometry.target,t);case"point":return na(e.geometry.target,t);case"box":case"polyhedron":return!0}}function Lh(e,t,r={}){switch(t.type){case"marker.create-box":return VR(e,t.marker,t.parentId??null);case"marker.update":return UR(e,t.markerId,t.patch,r);case"marker.delete":return KR(e,t.markerId);default:return null}}function VR(e,t,r){if(e.scene.gameObjects.some(i=>i.id===t.id))return null;let n=cr($c(e)),o=zh(e,t,t.id,r),a={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,o]}};return zd(a,{...n,markers:n.markers.filter(i=>i.id!==t.id)})}function UR(e,t,r,n={}){let o=e.scene.gameObjects.find(d=>d.id===t)??null;if(!de(o))return null;let a=zr(e,o,n),i=sr({...a,...r,id:a.id,geometry:r.geometry??a.geometry}),s=cr(void 0);if(oa({...s,markers:[a]},{...s,markers:[i]}))return e;let c=Bh(e,o,i,n);return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(d=>d.id===t?c:d)}}}function KR(e,t){let r=e.scene.gameObjects.find(a=>a.id===t)??null;if(!de(r))return null;let n=yp(e,t),o=cr($c(e));return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.filter(a=>!n.has(a.id)),markerGraph:{...o,markers:[],relations:o.relations.filter(a=>!$d(a.from,n)&&!$d(a.to,n))}}}}function HR(e,t={}){let r=!1,n=e.scene.gameObjects.map(o=>{if(!de(o))return o;let a=WR(e,o,t);return a!==o&&(r=!0),a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function WR(e,t,r={}){return JR(e,t,r)}function zh(e,t,r,n){let o=Oo(t.kind),a={position:Gc(t.geometry),rotation:jc(t.geometry),scale:um(t.geometry,o)},i=n?sm(e,n,a)??a:a;return{id:r,name:t.label||t.id,kind:"transform",...n?{parentId:n}:{},active:!0,marker:Uh(t),components:[{type:"Transform",...i}]}}function Bh(e,t,r,n={}){let o=Lr(e,t.id)?.scale??Cn(t),a=Nh(e,t,r,n)?Oo(r.kind):o;return{...t,name:r.label||t.name||r.id,kind:"transform",marker:Uh(r),components:qR(e,t,t.components,r.geometry,a)}}function qR(e,t,r,n,o){let a=o??Cn(t),i=Lr(e,t.id),s={position:im(n)?pe(i?.position??Gc(n)):Gc(n),rotation:im(n)?pe(i?.rotation??jc(n)):jc(n),scale:um(n,a)},c=sm(e,t.parentId,s)??s,d=!1,u=r.map(l=>l.type!=="Transform"?l:(d=!0,{...l,position:c.position,rotation:c.rotation,scale:c.scale}));return d?u:[...u,{type:"Transform",position:c.position,rotation:c.rotation,scale:c.scale}]}function JR(e,t,r={}){if(t.marker.geometry.kind==="polyhedron")return t;let n=Sr(e,t.marker.type,t.marker.kind,r),o=vh(t.marker,n);if((t.marker.kind??"point")===n&&t.marker.geometry.kind===o)return t;let a=zr(e,t,r),i=sr({...a,kind:n,markerType:t.marker.type.trim(),geometry:vc(e,t,n,a.geometry,r)});return Bh(e,t,i,r)}function Vh(e,t={}){return e.scene.gameObjects.filter(de).map(r=>zr(e,r,t))}function zr(e,t,r={}){let n=t.marker,o=n.metadata?structuredClone(n.metadata):{},i=(n.geometry.kind==="object-bounds"?Rh(e,n):null)??(n.semanticFrame?structuredClone(n.semanticFrame):Oh(e,t));return n.color&&(o.color={...n.color}),n.note!==void 0&&(o.note=n.note),{id:t.id,kind:Sr(e,n.type,n.kind,r),markerType:n.type,label:t.name??t.id,geometry:XR(e,t),...n.target?{target:structuredClone(n.target)}:{},...i?{semanticFrame:i}:{},...n.tags?.length?{tags:[...n.tags]}:{},...Object.keys(o).length>0?{metadata:o}:{}}}function XR(e,t){let r=t.marker,n=Lr(e,t.id),o=n?.position??Ie(0,0,0),a=n?.rotation??Ie(0,0,0),i=n?.scale??Cn(t);switch(r.geometry.kind){case"box":return{kind:"box",coordinateSpace:"world",center:pe(o),size:Nc(i),rotation:pe(a)};case"point":return(r.geometry.coordinateSpace??"world")==="world"?{kind:"point",coordinateSpace:"world",position:r.geometry.offset?$h(o,r.geometry.offset):pe(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}}:{kind:"point",coordinateSpace:"local",position:r.geometry.position?pe(r.geometry.position):pe(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(r.geometry.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:r.geometry.coordinateSpace??"world",vertices:r.geometry.vertices.map(pe),...r.geometry.faces?{faces:r.geometry.faces.map(s=>[...s])}:{}}}}function Uh(e){let t=e.metadata?structuredClone(e.metadata):{},r=ZR(t.color),n=typeof t.note=="string",o=n?t.note:void 0;return r&&delete t.color,n&&delete t.note,{schemaVersion:1,type:e.markerType,...e.kind?{kind:e.kind}:{},...e.tags?.length?{tags:[...e.tags]}:{},...o!==void 0?{note:o}:{},...r?{color:r}:{},...e.target?{target:structuredClone(e.target)}:{},...e.semanticFrame?{semanticFrame:structuredClone(e.semanticFrame)}:{},geometry:_h(e.geometry),...Object.keys(t).length>0?{metadata:t}:{}}}function YR(e,t){let r=Fc(e)||"marker",n=1,o=`${r}-marker`;for(;t.has(o);)n+=1,o=`${r}-marker-${n}`;return o}function ZR(e){if(!e||typeof e!="object")return null;let t=e,r=mm(t.r),n=mm(t.g),o=mm(t.b);return r==null||n==null||o==null?null:{r,g:n,b:o}}function mm(e){return typeof e!="number"||!Number.isFinite(e)?null:e>=0&&e<=1?e:null}function $c(e){return e.scene.markerGraph??null}function Hh(e){let t=n=>e.getMarkerTypeCatalogFromGraph(Kh(n)),r=n=>{let o=cr(Kh(n)),a=new Map;for(let i of o.markers)a.set(i.id,i);for(let i of Vh(n,e.options))a.set(i.id,i);return{...o,markers:[...a.values()]}};return{getMarkerGraph:r,getMarkerTypeCatalog:t,createMarkerGraphPatch(n,o){let a=Ep(n,o,{sanitizeMarkerGameObjectId:Fc});return Ip(n,a,r(n),{builtInMarkerTypes:e.options.builtInMarkerTypes,isMarkerGameObject:i=>de(i)})?{patch:e.createPatch(Bd(a)),label:Pp(a),...Tp(a),...a.type==="marker.create-box"?{createdId:a.marker.id}:{},normalizedCommand:Bd(a)}:null},createMarkerTypeUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?t(n).find(m=>m.type===s)??null:null;if(s&&!c)return null;let d=Sr(n,s,i.marker.kind,e.options),u=zr(n,i,e.options),l=vc(n,i,d,u.geometry,e.options);return{type:"marker.update",markerId:o,patch:{markerType:s,kind:d,geometry:l}}},createMarkerTargetUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?jh(n,s):null;if(s&&!c)return null;let d=zr(n,i,e.options),u=Sr(n,i.marker.type,i.marker.kind,e.options),l=Gh(n,i,d.geometry,u,c);return{type:"marker.update",markerId:o,patch:{target:c??void 0,geometry:l}}},resolveMarkerKind(n,o,a){return Sr(n,o,a,e.options)},reduceMarkerGraphPatch(n,o){let a=Lh(n,o,e.options);if(a)return a;let i=r(n),s=hp(i,o,e.options);return oa(i,s)?n:{...n,scene:{...n.scene,markerGraph:s}}},syncMarkerGraphDocument(n){return _c(n,e.options)}}}function Kh(e){return e?.scene.markerGraph}function Wh(e,t=[]){return e.scene.gameObjects.flatMap(r=>{let n=r.prefab?.prefabId?Le(e,r.prefab.prefabId):null;return n?Jh(e,n,r,r.id,t):[]})}function qh(e,t,r,n=[]){let o=Le(e,t);if(!o)return[];let a={id:r,name:o.displayName??o.id,kind:"group",components:[Lc()]};return Jh(e,o,a,r,n)}function Jh(e,t,r,n,o){let a=[],i=[];Xh(e,t,{instanceId:r.id,parentId:r.parentId,rootTransform:G(r)??Lc(),isHostRoot:!0,visitedPrefabIds:new Set,derivedObjects:a,markerDescriptors:i});let s=new Set([r.id,...a.map(d=>d.id)]);for(let d of a)d.marker&&(d.marker.target&&s.add(d.marker.target.id),d.marker.geometry.kind==="point"&&d.marker.geometry.target&&s.add(d.marker.geometry.target.id),d.marker.geometry.kind==="object-bounds"&&s.add(d.marker.geometry.target.id));let c={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects.filter(d=>!s.has(d.id)),r,...a]}};return i.flatMap(d=>{let u=c.scene.gameObjects.find(l=>l.id===d.runtimeId);return u?.marker?[{ownerInstanceId:n,prefabAssetId:d.prefabAssetId,localNodeId:d.localNodeId,marker:zr(c,u,{builtInMarkerTypes:o})}]:[]})}function Xh(e,t,r){if(r.visitedPrefabIds.has(t.id))return;let n=Ze(t),o=Ye(t),a=o?n.find(d=>d.id===o):null;if(!a)return;let i=new Set(r.visitedPrefabIds).add(t.id),s={instanceId:r.instanceId,rootNodeId:a.id},c=d=>ao(s,d.id);for(let d of n){let u=c(d),l=d.id===a.id,m=d.parentId?n.find(g=>g.id===d.parentId):null,f=l?r.parentId:c(m??a);if(d.kind==="prefabInstance"&&d.childPrefabId){let g=Le(e,d.childPrefabId);g&&Xh(e,g,{instanceId:u,...f?{parentId:f}:{},rootTransform:l?r.rootTransform:d.transform??Lc(),isHostRoot:r.isHostRoot&&l,visitedPrefabIds:i,derivedObjects:r.derivedObjects,markerDescriptors:r.markerDescriptors});continue}if(r.isHostRoot&&l)continue;let S=d.kind==="marker"&&d.marker?pa({...structuredClone(d.marker),semanticFrame:void 0},s):void 0;r.derivedObjects.push({id:u,name:d.name??d.id,kind:d.kind==="marker"?"transform":"group",...f?{parentId:f}:{},...S?{marker:S}:{},components:[l?r.rootTransform:d.transform??Lc()]}),S&&r.markerDescriptors.push({prefabAssetId:t.id,localNodeId:d.id,runtimeId:u})}}function Lc(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function QR(e){return e?e.list().filter(t=>De(t.shaderId)==null).map(t=>{let r=t.inspector.sections.length,n=t.inspector.fields.length;return{id:`shader:${t.shaderId}`,assetId:t.shaderId,label:t.displayName,kind:"shader",placeable:!1,meta:`${t.shaderId} \xB7 v${t.version} \xB7 ${n} fields`,shader:{shaderId:t.shaderId,displayName:t.displayName,version:t.version,runtimeKind:t.runtimeKind,sectionCount:r,fieldCount:n,...t.sourceFile?{sourceFile:t.sourceFile}:{}}}}):[]}function Yh(e){let t=ly(e.objectCommandServices);return{getHierarchyItems:e.hierarchyFacade.getHierarchyItems,normalizeHierarchyDocument:e.hierarchyFacade.normalizeHierarchyDocument,createRenamePatch:e.hierarchyFacade.createRenamePatch,createCreateGroupPatch:e.hierarchyFacade.createCreateGroupPatch,createCreatePrimitivePatch:e.hierarchyFacade.createCreatePrimitivePatch,createDeleteSubtreePatch:e.hierarchyFacade.createDeleteSubtreePatch,collectSubtreeIdList:e.hierarchyFacade.collectSubtreeIdList,validateReparent:e.hierarchyFacade.validateReparent,createReparentPatch:e.hierarchyFacade.createReparentPatch,validateHierarchyMove:e.hierarchyFacade.validateHierarchyMove,createHierarchyMovePatch:e.hierarchyFacade.createHierarchyMovePatch,validateGroupSelection:e.hierarchyFacade.validateGroupSelection,createGroupSelectionPatch:e.hierarchyFacade.createGroupSelectionPatch,createDuplicateSelectionPatch:e.hierarchyFacade.createDuplicateSelectionPatch,createPlacedAssetPatch:e.hierarchyFacade.createPlacedAssetPatch,applySerializedPropertyPatch:t.applySerializedPropertyPatch,canCreateSerializedMultiPropertyPatch:t.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:t.createSerializedMultiPropertyPatch,createBrowserAssetItems(r,n={}){let o=_e.getCachedUsageIndex(r);return[..._e.createBrowserAssetItems(r,o,n),...QR(n.materialShaderDefinitions),...ih(r,n.assetLibraryItems)]},addAssetLibraryItemToDocument(r,n,o){let a=Ca(r,n,o,e.assetPlacementServices);return{document:a.document,gameObject:a.gameObject}}}}function eC(e,t){if(!e.scene||typeof e.scene!="object"||Array.isArray(e.scene))return null;let r=e.scene;if(r.kind!==e.id)return null;let n=tE(r.contribution);return n?fm(n):t?nh(e,t):null}function Qh(e){let t=(e.features??[]).flatMap(p=>{let D=e.resolveFeatureSceneContribution?.(p);if(D)return[fm(D)];let h=eC(p,()=>d);if(h)return[h];let R=tE(p.scene);return R?[fm(R)]:[]}),r=t.every(p=>p.documentReducerImmutability==="preserves-input")?"immutable-reference":"defensive-clone",n=MC(t),o=Hh({options:{builtInMarkerTypes:e.markerTypes},createPatch:e.createPatch.markerGraph,getMarkerTypeCatalogFromGraph:p=>PC(e.markerTypes,p)}),a=(p,D)=>D?_(p,D):null,i=()=>[p=>n?.validateInspectorField?.({document:p.document??null,gameObject:p.document?a(p.document,p.targetId):null,path:p.path,value:p.value})??null,p=>IC(e.resolveFieldSchema?.(p.path,p.nodeKind)??null,p.path,p.value),Il({hasMaterialAsset:Vt,isMarkerGameObject:de,isDirectionalLightAnglePath:uo})],s=(p,D)=>n?.normalizeInspectorValue?.(p,D)??hs(p,D,{isDirectionalLightAnglePath:uo}),c=(p,D,h,R)=>{if(uo(h)&&D.light?.type!=="directional")return{ok:!1,message:`Unsupported scene node field: ${h}.`};let K=n?.validateInspectorField?.({document:p,gameObject:D,path:h,value:R});return K||mo({document:p,path:h,nodeKind:ei(D),value:R,extraValidators:i()})},d=(p,D,h)=>Ea({document:p,nodeKind:D,property:h,extraValidators:i()}),l={systemDefaults:gC(e.clearFeatureStateFromSystemObject),normalizeFieldValue:s,validateField:c,normalizePrimitiveShape:Mh,findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isProtectedSystemGameObject:Dt,hasCamera:(p,D)=>p.scene.gameObjects.some(h=>h.id!==D&&At(h)),...n?.fieldMutation},m=SC(e,o,l,a,s,c,n),f=(p,D,h,R)=>rc(p,D,h,R,m),S=(p,D,h,R)=>cy(p,D,h,R,m),g=(p,D)=>fu(p,D,m.fieldMutationOptions),b=(p,D,h)=>hn(p,D,{transform:h}),y=(p,D)=>Ul(p,D),E=bC(e,o,l,f,S,n),I=yC(o),P={isRootTransformPath:ws,validateSerializedPropertyField:p=>c(p.document,p.gameObject,p.path,p.value),findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isSerializedMultiFieldPath:p=>xC(p,n),isSerializedMultiProjectionPath:p=>AC(p,n),getSerializedMultiPropertyProbeValue:p=>DC(p,n),canPatchCustomSerializedMultiField:p=>n?.canPatchSerializedMultiField?.(p)??!0,createInspectorPropertyPatch:p=>To(p,m),createFieldBatchPatch:e.createPatch.gameObjectFieldBatch},A=Yh({hierarchyFacade:I,objectCommandServices:P,assetPlacementServices:{createGameObjectGuid:he,resolveLocalTransform:({document:p,parentId:D,worldTransform:h})=>ur(p,D??void 0,h)}}),$={findGameObject:a,hasModelRenderer:p=>!!p.components?.some(D=>D.type==="ModelRenderer"),hasImageRenderer:p=>!!p.components?.some(D=>D.type==="ImageRenderer"),readNodeKind:ei},z={};return Object.assign(z,{historyDocumentStorage:r,defaults:{camera:Xs,sunLight:Fa,environmentLight:wn},reduceDocument:(p,D)=>ku(p,D,E),ensureEnvironmentDefaults:p=>wu(p,E),isSelectableHierarchyId:(p,D)=>Cl(p,D),resolveDiagnosticLocator:(p,D)=>{let h=D.locator;if(!h?.objectId||!h.materialSlotId)return h??null;let R=a(p,h.objectId);if(!R)return h;let K=lr(p,R).find(ne=>ne.slotId===h.materialSlotId);return K?{...h,rowId:R.id,regionId:Ap,sectionId:"artistMaterialSlots",path:`overrides.materialSlotBindings.${K.slotId}.materialAssetId`}:h},getHierarchyItems:A.getHierarchyItems,normalizeHierarchyDocument:A.normalizeHierarchyDocument,createRenamePatch:A.createRenamePatch,createCreateGroupPatch:A.createCreateGroupPatch,createCreatePrimitivePatch:A.createCreatePrimitivePatch,createDeleteSubtreePatch:A.createDeleteSubtreePatch,createReparentPatch:A.createReparentPatch,createHierarchyMovePatch:A.createHierarchyMovePatch,createGroupSelectionPatch:A.createGroupSelectionPatch,createDuplicateSelectionPatch:A.createDuplicateSelectionPatch,createPlacedAssetPatch:A.createPlacedAssetPatch,validateReparent:A.validateReparent,validateHierarchyMove:A.validateHierarchyMove,validateGroupSelection:A.validateGroupSelection,collectSubtreeIds:pr,createFeatureHierarchyPatch:(p,D)=>n?.createHierarchyPatch?.(p,D)??null,createInspectorPropertyPatch:p=>nC(m,p),createSceneMaterialBindingPatch:p=>rC(e,m,p),createPrefabMaterialBindingPatch:p=>oC(e,p),createMaterialPropertiesPatch:p=>pC(e,m,p),createMaterialAssetCreatePatch:p=>sC(e,p),createMaterialAssetRestorePatch:p=>cC(e,p),createMaterialAssetCreateFromSourceAndBindPatch:p=>dC(e,p),createMaterialAssetDuplicatePatch:p=>lC(e,p),createMaterialAssetDeletePatch:p=>uC(e,p),createMaterialAssetRenamePatch:p=>mC(e,p),createMaterialAssetSetShaderPatch:p=>fC(e,p),patchGameObjectField:f,patchGameObjectsField:S,patchGameObjectPropertiesMany:g,patchGameObjectTransform:b,patchGameObjectTransformsMany:y,createSerializedPropertyBatchPatch:p=>tC(e,m,p),canCreateSerializedMultiPropertyPatch:A.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:A.createSerializedMultiPropertyPatch,createBrowserAssetItems:A.createBrowserAssetItems,addAssetLibraryItemToDocument:A.addAssetLibraryItemToDocument,getInspectorObject:(p,D,h={})=>hC(z,e,o,p,D,Zh(e.materialShaderDefinitions,h),d,a,i,n),getInspectorMultiObject:(p,D,h,R={})=>EC(p,D,h,R,t,e.getRenderingProfile()),getPrefabStageInspectorObject:(p,D,h,R={})=>Ah.createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage(p,D,h,Zh(e.materialShaderDefinitions,R),{createIdentityTransformComponent:GS,mergeLightDefaults:kn,sunLightId:"sun_light",normalizePrefabAssetFieldValue:Yu,validatePrefabAssetFieldValue:Zu,markerTypeCatalog:o.getMarkerTypeCatalog(p)}),getRuntimeInspectorSections:p=>$l({...p,sourceRef:Wt(p.document)},$),createRuntimeInspectorSnapshot:p=>ga({projectedRoot:p.projectedRoot,projectionNode:p.projectionNode??null}),createDocumentInspectorProperty:d,getMarkerGraph:o.getMarkerGraph,getMarkerTypeCatalog:o.getMarkerTypeCatalog,getPrefabInstanceMarkerOverlays:p=>Wh(p,o.getMarkerTypeCatalog(p)),getPrefabStageMarkerOverlays:(p,D,h)=>qh(p,D,h,o.getMarkerTypeCatalog(p)),getRelationTypeCatalog:()=>e.relationTypes.map(p=>structuredClone(p)),createMarkerGraphPatch:o.createMarkerGraphPatch,reduceMarkerGraphPatch:o.reduceMarkerGraphPatch,syncMarkerGraphDocument:o.syncMarkerGraphDocument,resolveMarkerKind:o.resolveMarkerKind,assertMaterialAssetIntegrity:Bs}),z}function tC(e,t,r){if(r.changes.length<2)return null;let n=new Set,o=[],a=new Set;for(let s of r.changes){let c=`${s.targetId}\0${s.path}`;if(!s.targetId||!s.path||n.has(c))return null;n.add(c);let d=To({document:r.document,targetId:s.targetId,path:s.path,value:s.value},t),u=d?.patch;if(!d||!u||u.kind!=="game-object.field"||u.targetId!==s.targetId||u.path!==s.path)return null;o.push({targetId:s.targetId,path:s.path,value:u.value});for(let l of d.reprojectIds??[])a.add(l)}let i=[...new Set(o.map(s=>s.targetId))];return{patch:e.createPatch.gameObjectFieldBatch(o),label:`Patch ${o.length} Inspector properties`,changedIds:i,...a.size>0?{reprojectIds:[...a]}:{}}}function rC(e,t,r){if(r.targets.length===0)return null;let n=new Set,o=[];for(let s of r.targets){let c=`${s.objectId}\0${s.path}`;if(n.has(c))return null;n.add(c);let u=To({document:r.document,targetId:s.objectId,path:s.path,value:r.materialAssetId},t)?.patch;if(!u||u.kind!=="game-object.field"||u.targetId!==s.objectId||u.path!==s.path)return null;o.push({targetId:s.objectId,path:s.path,value:u.value})}let a=[...new Set(o.map(s=>s.targetId))],i=eE(r.document,r.targets,r.materialAssetId);return{patch:e.createPatch.gameObjectFieldBatch(o),label:`${r.materialAssetId?"Set":"Clear"} ${o.length} scene material binding${o.length===1?"":"s"}`,changedIds:a,reprojectIds:a,presentationImpact:i}}function nC(e,t){let r=To(t,e);if(!r||!wr(t.path))return r;let n=r.createdId??(typeof t.value=="string"&&t.value.trim()?t.value.trim():null);return{...r,presentationImpact:eE(t.document,[{objectId:t.targetId,path:t.path}],n)}}function oC(e,t){if(t.targets.length===0||t.materialAssetId&&!Vt(t.document,t.materialAssetId)||new Set(t.targets.map(s=>s.prefabAssetId)).size!==1)return null;let n=t.targets[0].prefabAssetId,o=Le(t.document,n);if(!o?.prefab)return null;let a=structuredClone(o),i=new Set;for(let s of t.targets){let c=`${s.nodeId??""}\0${s.path}`;if(i.has(c))return null;i.add(c);let d=`prefab.${s.path}`,u=Yu(d,t.materialAssetId);if(!Zu(d,u))return null;if(!s.nodeId){a=ma(a,d,u);continue}let l=a.prefab?.nodes?.findIndex(b=>b.id===s.nodeId)??-1;if(l<0||!a.prefab?.nodes)return null;let m=a.prefab.nodes[l],f={...a,prefab:{...a.prefab,overrides:structuredClone(m.overrides)}},S=ma(f,d,u),g={...m,...S.prefab?.overrides?{overrides:structuredClone(S.prefab.overrides)}:{}};S.prefab?.overrides||delete g.overrides,a.prefab.nodes=[...a.prefab.nodes],a.prefab.nodes[l]=g}return{patch:e.createPatch.prefabAssetReplace?.(n,a)??{kind:"scene.prefab-asset.replace",assetId:n,prefabAsset:a},label:`${t.materialAssetId?"Set":"Clear"} ${t.targets.length} prefab material binding${t.targets.length===1?"":"s"}`,changedId:n,changedIds:[n],reprojectIds:[n],presentationImpact:aC(t.document,t.targets,t.materialAssetId)}}function eE(e,t,r){let n=new Set(t.map(a=>`${a.objectId}\0${a.path}`)),o=new Set;r&&o.add(r);for(let a of an(e))a.scope==="scene"&&n.has(`${a.gameObjectId}\0${a.bindingPath}`)&&o.add(a.materialAssetId);return{inspector:["material"],materials:{assetIds:[...o]}}}function aC(e,t,r){let n=new Set;r&&n.add(r);for(let o of t){let a=iC(e,o);a&&n.add(a)}return{inspector:["material"],materials:{assetIds:[...n]}}}function iC(e,t){let r=Le(e,t.prefabAssetId)?.prefab,n=t.nodeId?r?.nodes?.find(a=>a.id===t.nodeId)?.overrides:r?.overrides;if(!n)return null;let o=t.path==="overrides.materialBinding.materialAssetId"?n.materialBinding?.materialAssetId:n.materialSlotBindings?.[Lt(t.path,"materialAssetId")??""]?.materialAssetId;return typeof o=="string"&&o.trim()?o.trim():null}function sC(e,t){let r=Vb(t.document,t.definition,t.name);return{patch:e.createPatch.materialAssetCreate?.(r)??{kind:"scene.material-asset.create",materialAsset:r},label:`Create material ${r.name}`,changedIds:[],createdId:r.id}}function cC(e,t){return ee(t.document,t.materialAsset.id)?null:{patch:e.createPatch.materialAssetCreate?.(t.materialAsset)??{kind:"scene.material-asset.create",materialAsset:t.materialAsset},label:`Restore material ${t.materialAsset.name}`,changedIds:[],createdId:t.materialAsset.id}}function dC(e,t){let r=Wb({document:t.document,gameObject:t.gameObject,bindingPath:t.bindingPath,profile:t.profile,sourceAsset:t.sourceAsset,sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,sourceMaterialName:t.sourceMaterialName});return r?{...r,patch:e.createPatch.materialAssetCreateAndBind?.({targetId:r.patch.targetId,bindingPath:r.patch.bindingPath,materialAsset:r.patch.materialAsset})??r.patch,label:`Create material ${r.patch.materialAsset.name} from GLB source`,presentationImpact:{inspector:["material"],materials:{assetIds:[r.createdId]}}}:null}function lC(e,t){let r=ee(t.document,t.materialAssetId);if(!r)return null;let n=Ub(t.document,r);return{patch:e.createPatch.materialAssetCreate?.(n)??{kind:"scene.material-asset.create",materialAsset:n},label:`Duplicate material ${r.name??r.id}`,changedIds:[],createdId:n.id,presentationImpact:{inspector:["material"],materials:{assetIds:[n.id]}}}}function uC(e,t){let r=Jb(t.document,t.materialAssetId);return r.ok?{patch:e.createPatch.materialAssetDelete?.(t.materialAssetId)??{kind:"scene.material-asset.delete",materialAssetId:t.materialAssetId},label:`Delete material ${r.materialAsset.name??r.materialAsset.id}`,changedIds:[],presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}:null}function mC(e,t){let r=ee(t.document,t.materialAssetId),n=rt("name",t.name);return!r||tu(r)||typeof n!="string"||!zt("name",n)?null:{patch:e.createPatch.materialAssetField(t.materialAssetId,"name",n),label:`Rename material ${r.name} to ${n}`,changedIds:da(t.document,t.materialAssetId),presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}}function fC(e,t){let r=ee(t.document,t.materialAssetId);if(!r||tu(r))return null;let n=rS(r,t.definition),o=da(t.document,t.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(t.materialAssetId,n.materialAsset)??{kind:"scene.material-asset.replace",materialAssetId:t.materialAssetId,materialAsset:n.materialAsset},label:`Set material ${r.name} shader to ${t.definition.displayName}`,changedIds:o,reprojectIds:o,presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}},preservedPaths:n.preservedPaths,resetPaths:n.resetPaths}}function pC(e,t,r){if(r.changes.length===0)return null;let n=ee(r.document,r.materialAssetId);if(!n)return null;let o=new Set,a=r.document;for(let c of r.changes){if(!c.path.startsWith("properties.")||o.has(c.path))return null;if(o.add(c.path),c.inheritTexture){if(!ro(n.shaderId,c.path))return null;a=_s(a,r.materialAssetId,c.path,null,e.materialShaderDefinitions,{textureMode:"inherit"});continue}let d=`scene.materialAssets.${r.materialAssetId}.${c.path}`,l=To({document:a,targetId:r.materialAssetId,path:d,value:c.value},t)?.patch;if(!l||l.kind!=="scene.material-asset.field"||l.materialAssetId!==r.materialAssetId||l.path!==c.path)return null;a=_s(a,r.materialAssetId,c.path,l.value,e.materialShaderDefinitions)}let i=ee(a,r.materialAssetId);if(!i)return null;let s=da(r.document,r.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(r.materialAssetId,i)??{kind:"scene.material-asset.replace",materialAssetId:r.materialAssetId,materialAsset:i},label:`Patch material ${r.materialAssetId} properties`,changedIds:s,reprojectIds:s}}function gC(e){let t=r=>n=>{let o=r(n);if(!e)return o;let a=structuredClone(o),i=structuredClone(n),s=e(a,i)??a;return JSON.stringify(s)===JSON.stringify(n)?n:s};return{environmentLightId:"environment_light",sunLightId:"sun_light",horizontalLightAnglePath:"light.directionHorizontalAngleDeg",elevationLightAnglePath:"light.directionElevationAngleDeg",normalizeEnvironmentLightGameObject:r=>t(n=>gu(n,"hemispheric"))(r),normalizeSunLightGameObject:r=>t(n=>gu(n,"directional"))(r),normalizeCameraGameObject:t(jS),normalizePlainTransformGameObject:t(NS),createDefaultCameraGameObject:zS,createDefaultEnvironmentLightGameObject:VS,createDefaultSunLightGameObject:BS,mergeCameraDefaults:_a,normalizeCameraAfterFieldPatch:FS,hasInvalidCameraRelationships:$S,mergeLightDefaults:kn}}function bC(e,t,r,n,o,a){return{...r,normalizeRootTransformDocument:Pa,syncMarkerGraphDocument:t.syncMarkerGraphDocument,ensureGameObjectGuids:kl,normalizeDocumentAfterCommand:(i,s)=>a?.normalizeDocumentAfterCommand?.(i,s)??i,patchMaterialAssetField:(i,s,c,d)=>_s(i,s,c,d,e.materialShaderDefinitions),replaceMaterialAsset:(i,s,c)=>Kb(i,s,c),addMaterialAsset:(i,s)=>$s(i,s),deleteMaterialAsset:(i,s)=>Xb(i,s),addMaterialAssetAndBind:(i,s,c,d)=>Yb(i,s,c,d),addPrefabAsset:(i,s,c)=>sh(i,s,c),patchPrefabAssetField:(i,s,c,d)=>em(i,s,c,d),replacePrefabAsset:(i,s,c,d)=>ch(i,s,c,d),addMaterialAssetAndBindPrefabOverride:(i,s,c,d)=>lh(i,s,c,d),patchGameObjectField:n,patchGameObjectsField:o,reduceExtensionPatch:({document:i,patch:s,command:c})=>s.kind==="game-object.property-field-batch"&&Array.isArray(s.fields)?s.fields.reduce((d,u)=>o(d,[u.targetId],u.path,u.value),i):a?.reducePatch?.({document:i,patch:s,command:c})??null,isCustomFieldPatchPath:a?.isInspectorPatchPath,reduceMarkerGraphPatch:(i,s)=>t.reduceMarkerGraphPatch(i,s),isDirectionalLightAnglePath:uo,validateSerializedPropertyField:i=>r.validateField(i.document,i.gameObject,i.path,i.value),createGameObjectGuid:he,createUniqueId:it,resolveLocalTransform:({document:i,parentId:s,worldTransform:c})=>ur(i,s??void 0,c),resolveRootContainerId:fe,ensureDefaultMaterialAssets:zb,normalizeMaterialBindings:tS}}function SC(e,t,r,n,o,a,i){return{fieldMutationOptions:ec(r),findGameObject:n,normalizeValue:o,validateValue:a,blockFieldPatch:(s,c,d,u)=>tc(s,c,d,u,r),isRootTransformPath:ws,parseDuplicateMaterialAssetValue:es,isMaterialBindingPath:wr,isMaterialBindingPathAllowed:(s,c)=>wr(c)&&(!!e.resolveFieldSchema?.(c,ei(s))||c.startsWith("overrides.materialSlotBindings.")),findMaterialAssetName:(s,c)=>ee(s,c)?.name??null,parseMaterialAssetFieldPath:Gp,normalizeMaterialAssetValue:rt,hasMaterialAsset:Vt,validateMaterialAssetFieldValue:(s,c,d,u)=>{let l=ee(s,c);return zt(d,u,l?.shaderId,e.materialShaderDefinitions)},collectMaterialAssetBindingIds:da,isMarkerGameObject:de,createMarkerTargetUpdateCommand:t.createMarkerTargetUpdateCommand,createMarkerTypeUpdateCommand:t.createMarkerTypeUpdateCommand,createMarkerGraphPatch:e.createPatch.markerGraph,isDirectionalLightAnglePath:uo,createDirectionalLightPatch:e.createPatch.gameObjectField,patchDirectionalLightAngleField:(s,c,d,u)=>Ou(s,c,d,u,r),createCustomInspectorPropertyPatch:({document:s,gameObject:c,path:d,value:u})=>i?.createInspectorPropertyPatch?.({document:s,gameObject:c,path:d,value:u,collectChangedIds:()=>pr(s,[c.id])})??null,patchCustomGameObjectField:i?.patchGameObjectField,patchCustomGameObjectsField:i?.patchGameObjectsField,normalizeAfterFieldPatch:(s,c,d,u)=>i?.normalizeAfterFieldPatch?.(s,c,d,u)??s,isProjectionShapePath:TC,isArtistMaterialPatchPath:Qi,isCustomProjectionPath:i?.isProjectionPath,collectChangedIdsForFieldPath:(s,c,d)=>d.startsWith("transform.")?pr(s,[c]):[c],createGameObjectFieldPatch:e.createPatch.gameObjectField,createMaterialAssetFieldPatch:e.createPatch.materialAssetField}}function yC(e){return Mu({findGameObject:(t,r)=>r?_(t,r):null,resolveRootContainerId:fe,isProtectedSystemGameObject:Dt,isProtectedSystemGameObjectId:Dl,decorateHierarchyItem:({item:t,gameObject:r})=>r&&de(r)?{...t,role:"marker",icon:"view-overlay",canHaveChildren:!1}:t})}function Zh(e,t){return{materialShaderDefinitions:e,...t}}function hC(e,t,r,n,o,a,i,s,c,d){let u=MS(n,o,a);if(u)return u;let l=iu.createEditorSceneMaterialAssetInspectorObjectWithCachedUsage(n,o,a);return l||_u({document:n,targetId:o,context:a,findGameObject:s,readNodeKind:ei,isMarkerGameObject:de,createInspectorSections:(m,f,S)=>{let g=ei(f);return Lu({document:m,gameObject:f,context:S,nodeKind:g,isCameraGameObject:At,isLightGameObject:fo,isMarkerGameObject:de,createBaseSections:()=>Nl({document:m,gameObject:f,nodeKind:g,extraValidators:c(),rootTransform:jr,renderingProfile:t.getRenderingProfile(),transformTypeOptions:rE(d?.transformTypeOptions)}),createCustomSections:()=>d?.createInspectorSections?.({document:m,gameObject:f,nodeKind:g,context:S,createDocumentInspectorProperty:i})??[],createCameraSection:()=>Tl({nodeKind:g,camera:f.camera,rig:_a(f.camera),createDocumentInspectorProperty:i}),createLightSections:()=>Bl({nodeKind:g,gameObject:f,light:kn(f.light,f.id==="environment_light"?"hemispheric":"directional"),createDocumentInspectorProperty:i,normalizeValue:(b,y)=>d?.normalizeInspectorValue?.(b,y)??hs(b,y),defaultEnvironmentGroundColor:wn.groundColor,renderingProfile:t.getRenderingProfile()}),createMarkerSection:()=>de(f)?Ku({document:m,gameObject:f,nodeKind:g,markerTypeCatalog:r.getMarkerTypeCatalog(m),resolveMarkerKind:(b,y)=>r.resolveMarkerKind(m,y.type,y.kind),isMarkerGameObject:de,formatMarkerTypeLabel:t.formatMarkerTypeLabel??((b,y)=>y),createDocumentInspectorProperty:i}):null,createPrefabInstanceSection:()=>Dh(m,f),createMaterialSections:()=>iu.createArtistMaterialInspectorSectionsWithCachedUsage(m,f,g,S,{createDocumentInspectorProperty:i}),createOutlineSection:()=>zu({nodeKind:g,outline:f.overrides?.outline,createDocumentInspectorProperty:i})})}})}function EC(e,t,r,n,o,a){let i=null,s=[];for(let c of o){let d=c.createMultiInspectorSection?.({document:e,targetIds:t,activeId:r,context:n})??null;if(d){i=d,s=c.resolveMultiInspectorTargetIds?.(e,t)??[];break}}return $u({document:e,selectedIds:t,activeId:r,renderingProfile:a,extraSection:i,resolveFallbackTargetIds:()=>s,formatFallbackLabel:c=>`${c.length} Objects`,fallbackSelectionKind:"transform"})}function IC(e,t,r){return e?r==null&&e.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${t}.`}:e.validate(r)?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${t}.`}:null}function PC(e,t){return eo(t,{builtInMarkerTypes:e})}var ei=Y;function TC(e){return e.startsWith("shadow.")||e==="transformType"||e.startsWith("rendering.")||e.startsWith("primitive.")||e.startsWith("camera.")||e.startsWith("light.")}function xC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiFieldPath?.(e)===!0}function AC(e,t){return e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiProjectionPath?.(e)===!0}function DC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"?!1:t?.getSerializedMultiProbeValue?.(e)}function tE(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return["documentReducerImmutability","transformTypeOptions","normalizeInspectorValue","validateInspectorField","isInspectorPatchPath","isProjectionPath","normalizeDocumentAfterCommand","normalizeAfterFieldPatch","fieldMutation","createInspectorPropertyPatch","patchGameObjectField","patchGameObjectsField","reducePatch","createHierarchyPatch","createInspectorSections","createMultiInspectorSection","resolveMultiInspectorTargetIds","isSerializedMultiFieldPath","isSerializedMultiProjectionPath","getSerializedMultiProbeValue","canPatchSerializedMultiField"].some(n=>t[n]!=null)?t:null}function fm(e){let{documentReducerImmutability:t,...r}=e;return r}function MC(e){if(e.length===0)return;let t=r=>{for(let n of e){let o=r(n);if(o!=null)return o}return null};return{documentReducerImmutability:e.every(r=>r.documentReducerImmutability==="preserves-input")?"preserves-input":void 0,transformTypeOptions:rE(e.flatMap(r=>r.transformTypeOptions??[])).slice(xa.length),normalizeInspectorValue(r,n){for(let o of e){let a=o.normalizeInspectorValue?.(r,n);if(a!==void 0)return a}},validateInspectorField:r=>t(n=>n.validateInspectorField?.(r)),isInspectorPatchPath:r=>e.some(n=>n.isInspectorPatchPath?.(r)),isProjectionPath:r=>e.some(n=>n.isProjectionPath?.(r)),normalizeDocumentAfterCommand:(r,n)=>e.reduce((o,a)=>a.normalizeDocumentAfterCommand?.(o,n)??o,r),normalizeAfterFieldPatch:(r,n,o,a)=>e.reduce((i,s)=>s.normalizeAfterFieldPatch?.(i,n,o,a)??i,r),fieldMutation:wC(e),createInspectorPropertyPatch:r=>t(n=>n.createInspectorPropertyPatch?.(r)),patchGameObjectField:r=>t(n=>n.patchGameObjectField?.(r)),patchGameObjectsField:r=>t(n=>n.patchGameObjectsField?.(r)),reducePatch:r=>t(n=>n.reducePatch?.(r)),createHierarchyPatch:(r,n)=>t(o=>o.createHierarchyPatch?.(r,n)),createInspectorSections:r=>e.flatMap(n=>n.createInspectorSections?.(r)??[]),isSerializedMultiFieldPath:r=>e.some(n=>n.isSerializedMultiFieldPath?.(r)),isSerializedMultiProjectionPath:r=>e.some(n=>n.isSerializedMultiProjectionPath?.(r)),getSerializedMultiProbeValue(r){for(let n of e){let o=n.getSerializedMultiProbeValue?.(r);if(o!==void 0)return o}},canPatchSerializedMultiField:r=>e.every(n=>n.canPatchSerializedMultiField?.(r)!==!1)}}function rE(e=[]){let t=[],r=new Set;for(let n of[...xa,...e])r.has(n.value)||(r.add(n.value),t.push(n));return t}function wC(e){let t=e.flatMap(r=>r.fieldMutation?[r.fieldMutation]:[]);if(t.length!==0)return{isCustomTransformType:r=>t.some(n=>n.isCustomTransformType?.(r)),applyCustomTransformType(r,n){for(let o of t)o.clearCustomTransformState?.(r,n);for(let o of t)o.applyCustomTransformType?.(r,n)},clearCustomTransformState(r,n){for(let o of t)o.clearCustomTransformState?.(r,n)},patchCustomTransformField(r,n,o){for(let a of t)if(a.patchCustomTransformField?.(r,n,o))return!0;return!1}}}var pm=["model","texture","image","sound"],zc=[".glb",".gltf"],gm=[".png",".jpg",".jpeg",".webp"],nE=[".env",".hdr",".dds",".ktx",".ktx2"],Bc=[...gm,...nE],Vc=[".mp3",".wav",".ogg",".flac",".aac",".m4a"],Ro=[...zc,...Bc,...Vc];function oE(e){return String(e??"").trim().toLowerCase().replace(/-/g,"")}function Uc(e,t){let r=oE(t);return`${e==="model"?"asset":e==="texture"?"texture":e==="sound"?"sound":"image"}_${r}`}function Kc(e){let o=String(e??"").trim().split(/[^a-zA-Z0-9_$]+/).filter(Boolean).map((a,i)=>i===0?a:`${a.charAt(0).toUpperCase()}${a.slice(1)}`).join("").replace(/[^a-zA-Z0-9_$]/g,"")||"assetUrl";return/^[a-zA-Z_$]/.test(o)?o:`asset${o}`}function Hc(e,t=""){let r=String(e??"").trim().toLowerCase();if(r==="glb"||r==="gltf"||r==="model")return"model";if(r==="groundtexture"||r==="ground-texture"||r==="texture")return"texture";if(r==="ui"||r==="image"||r==="img")return"image";if(r==="audio"||r==="sound")return"sound";let n=aE(t);return zc.includes(n)?"model":Vc.includes(n)?"sound":Bc.includes(n)?"texture":null}function aE(e){let t=e.split(/[?#]/,1)[0]??"",r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),n=t.slice(r+1),o=n.lastIndexOf(".");return o>=0?n.slice(o).toLowerCase():""}function bm(e){let t=String(e??"").trim(),r=t.toLowerCase();for(let n of[...Ro].sort((o,a)=>a.length-o.length))if(r.endsWith(n)){t=t.slice(0,-n.length);break}return t}function Sm(e,t){return String(e??"").trim()||bm(t)||"Asset"}function ym(e,t){return bm(e||t).trim().toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")||null}function hm(e){return e==="model"?zc:e==="sound"?Vc:e==="texture"?Bc:e==="image"?gm:[]}function Im(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(!e||typeof e!="object")return;let t=e,r=Em(t.x),n=Em(t.y),o=Em(t.z);if(!(r==null||n==null||o==null||r<=0||n<=0||o<=0))return{x:r,y:n,z:o}}function Em(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Pm(e){return e==="shared"||e==="instance"?e:void 0}function Tm(e){return Number.isInteger(e)&&e>=0?e:void 0}var iE="rendering",vn=Lf;function Br(e){let t=se(e);return kC(t?.companionConfigs)}function Am(e){return Br(e)[iE]??null}function sE(e){return Ar(Br(e)[vn])}function kC(e){if(e==null)return{};let t=OC(e,"$.companionConfigs"),r={};for(let[n,o]of Object.entries(t)){if(!n||n!==n.trim())throw xm("schema.invalidValue","$.companionConfigs");let a=n;if(o===null){r[a]=null;continue}let i=se(o);if(!i)throw xm("schema.invalidType",`$.companionConfigs.${a}`);a===iE&&gt(i),a===vn&&Wn(i,`$.companionConfigs.${a}`),r[a]=i}return r}function OC(e,t){let r=se(e);if(!r)throw xm("schema.invalidType",t);return r}function xm(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}var fE="@fps-games/editor.playable-sdk.scene-compiler",pE="3",RC=new Set(["shadowMode","childMaterialBindings","childMaterials"]),CC=new Set(["coordinateSpace","center","size","rotation"]),cE=new Set(["root","group","model","primitive","light","prefabInstance","marker","collision"]);function Wc(e){bE(e,!0)}function gE(e){let t=ua(e);return Wc(t.document),t}function km(e){bE(e,!1)}function bE(e,t){let r=k(e);if(!r)throw new Error("editor_scene_must_be_object");if(r.schemaVersion!==1)throw T("schema.unsupportedVersion","$.schemaVersion");if(!Array.isArray(r.assets))throw new Error("editor_scene_assets_must_be_array");let n=k(r.scene);if(!Array.isArray(n?.gameObjects))throw new Error("editor_scene_game_objects_must_be_array");if(n.materialAssets!=null&&!Array.isArray(n.materialAssets))throw new Error("editor_scene_material_assets_must_be_array");if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw T("schema.forbiddenField","$.scene.shadowMapExperiment");NC(r.assets,n.gameObjects),wm(r,"$"),FC(r.assets),jC(r.assets,n.gameObjects),_C(n.gameObjects,r.assets),$C(n.gameObjects),GC(n.materialAssets??[]),t&&LC(r.assets,n.gameObjects),Bs(r),vC(r.assets,n.gameObjects)}function vC(e,t){for(let r=0;r<t.length;r+=1){let n=k(t[r]),o=`$.scene.gameObjects[${r}]`,a=Object.prototype.hasOwnProperty.call(n,"shadow");if(k(n.prefab)){if(a)throw T("schema.forbiddenField",`${o}.shadow`)}else if(dn(n))dE(n.shadow,`${o}.shadow`);else if(a)throw T("schema.forbiddenField",`${o}.shadow`);if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw T("schema.forbiddenField",`${o}.shadowMapExperiment`)}for(let r=0;r<e.length;r+=1){let n=k(e[r]),o=`$.assets[${r}]`,a=k(n.defaults);if(a?.shadow!==void 0)throw T("schema.forbiddenField",`${o}.defaults.shadow`);if(a?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${o}.defaults.shadowMapExperiment`);let i=k(n.prefab);if(!i)continue;let s=k(i.defaults);if(dE(s?.shadow,`${o}.prefab.defaults.shadow`),s?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${o}.prefab.defaults.shadowMapExperiment`);Array.isArray(i.nodes)&&i.nodes.forEach((c,d)=>{let u=k(c),l=`${o}.prefab.nodes[${d}]`,m=k(u?.defaults);if(u?.shadow!==void 0)throw T("schema.forbiddenField",`${l}.shadow`);if(m?.shadow!==void 0)throw T("schema.forbiddenField",`${l}.defaults.shadow`);if(u?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${l}.shadowMapExperiment`);if(m?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${l}.defaults.shadowMapExperiment`)})}}function dE(e,t){let r=k(e);if(!r||r.cast===void 0||r.receive===void 0)throw T("schema.invalidType",t);if(r.cast!=="enabled"&&r.cast!=="none"||r.receive!=="enabled"&&r.receive!=="none")throw T("schema.invalidValue",t);for(let n of Object.keys(r))if(n!=="cast"&&n!=="receive")throw T("schema.forbiddenField",`${t}.${n}`)}function GC(e){let t=new Set,r=new Set;for(let n=0;n<e.length;n+=1){let o=k(e[n]),a=`$.scene.materialAssets[${n}]`;if(!o)throw T("schema.invalidType",a);if(Object.prototype.hasOwnProperty.call(o,"materialKind"))throw T("schema.deprecatedField",`${a}.materialKind`);if(Object.prototype.hasOwnProperty.call(o,"profile"))throw T("schema.deprecatedField",`${a}.profile`);let i=C(o.id);if(!i)throw T("schema.invalidType",`${a}.id`);if(t.has(i))throw T("schema.invalidValue",`${a}.id`);t.add(i);let s=C(o.guid);if(s){if(r.has(s))throw T("schema.invalidValue",`${a}.guid`);r.add(s)}if(!C(o.name))throw T("schema.invalidType",`${a}.name`);let c=C(o.shaderId);if(!c)throw T("schema.invalidValue",`${a}.shaderId`);let d=De(c),u=o.definitionVersion;if(u!=null&&(typeof u!="number"||!Number.isSafeInteger(u)||u<1))throw T("schema.invalidValue",`${a}.definitionVersion`);if(!d&&u==null)throw T("schema.invalidValue",`${a}.definitionVersion`);if(d){let l=Qn(c,o.properties,`${a}.properties`);if(l[0])throw T("schema.invalidValue",l[0].path)}else if(!k(o.properties))throw T("schema.invalidType",`${a}.properties`);for(let l of Object.keys(o))if(!["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(l))throw T("schema.unknownField",`${a}.${l}`)}}function jC(e,t){let r=new Set(e.map(k).filter(a=>a?.type==="glb").map(a=>C(a?.id)).filter(a=>!!a)),n=new Set(e.map(k).filter(a=>a?.type==="texture").map(a=>C(a?.id)).filter(a=>!!a)),o=new Map;for(let a of e.map(k)){if(a?.type!=="prefab")continue;let i=C(a.id),s=C(k(a.prefab)?.sourceAssetId);i&&s&&o.set(i,s)}for(let a=0;a<e.length;a+=1){let i=k(e[a]);if(i?.type!=="prefab")continue;let s=k(i.prefab),c=C(s?.sourceAssetId),d=C(s?.rootNodeId);if(!c||!r.has(c))throw T("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);let u=Array.isArray(s?.nodes)?s.nodes:[];for(let l=0;l<u.length;l+=1){let m=k(u[l]),f=C(m?.sourceAssetId);if(m?.kind==="model"&&(!f||!r.has(f)))throw T("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`);if(m?.kind==="prefabInstance"){let S=C(m.childPrefabId),g=S?o.get(S):null;if(C(m.id)===d&&c!==g)throw T("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);if(f&&f!==g)throw T("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`)}}}for(let a=0;a<t.length;a+=1){let i=k(t[a]),s=C(k(i?.instance)?.assetId);if(s&&!r.has(s))throw T("schema.invalidReference",`$.scene.gameObjects[${a}].instance.assetId`);let c=Array.isArray(i?.components)?i.components:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ModelRenderer")continue;let l=C(u.assetId);if(!l||!r.has(l))throw T("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`)}for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ImageRenderer")continue;let l=C(u.assetId);if(!l||!n.has(l))throw T("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`);let m=k(u.size);if(!m||!mE(m.width)||!mE(m.height))throw T("schema.invalidValue",`$.scene.gameObjects[${a}].components[${d}].size`)}}}function NC(e,t){let r=new Set;e.forEach((a,i)=>{let s=k(a);if(!s)throw T("schema.invalidType",`$.assets[${i}]`);let c=C(s.id);if(!c||!C(s.type))throw T("schema.invalidValue",`$.assets[${i}]`);if(r.has(c))throw T("schema.invalidValue",`$.assets[${i}].id`);r.add(c)});let n=new Set,o=new Map;t.forEach((a,i)=>{let s=k(a);if(!s)throw T("schema.invalidType",`$.scene.gameObjects[${i}]`);let c=C(s.id);if(!c)throw T("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.has(c))throw T("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.add(c),o.set(c,{value:s,index:i}),!Array.isArray(s.components))throw T("schema.invalidType",`$.scene.gameObjects[${i}].components`);s.components.forEach((d,u)=>{let l=k(d);if(!l)throw T("schema.invalidType",`$.scene.gameObjects[${i}].components[${u}]`);if(!C(l.type))throw T("schema.invalidValue",`$.scene.gameObjects[${i}].components[${u}].type`)})});for(let[a,i]of o){if(!("parentId"in i.value))continue;let s=C(i.value.parentId);if(!s||!o.has(s))throw T("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);let c=new Set([a]),d=s;for(;d;){if(c.has(d))throw T("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);c.add(d);let u=o.get(d)?.value;d=u&&u.parentId!=null?C(u.parentId):null}}}function wm(e,t){if(Array.isArray(e)){e.forEach((n,o)=>wm(n,`${t}[${o}]`));return}let r=k(e);if(r)for(let[n,o]of Object.entries(r)){let a=`${t}.${n}`;if(RC.has(n))throw T("schema.deprecatedField",a);n==="shadow"&&Wo(o,a),!(n==="metadata"||n==="shadowMapExperiment")&&wm(o,a)}}function FC(e){let t=new Set(e.map(k).filter(i=>i?.type==="prefab").map(i=>C(i?.id)).filter(i=>!!i)),r=new Map;for(let i=0;i<e.length;i+=1){let s=k(e[i]);if(s?.type!=="prefab")continue;let c=k(s.prefab);if(!Array.isArray(c?.nodes))throw T("schema.unsupportedVersion",`$.assets[${i}].prefab.nodes`);lE(c.defaults,`$.assets[${i}].prefab.defaults`);let d=[],u=new Set;for(let S=0;S<c.nodes.length;S+=1){let g=`$.assets[${i}].prefab.nodes[${S}]`,b=k(c.nodes[S]);if(!b)throw T("schema.invalidType",g);lE(b.defaults,`${g}.defaults`);let y=C(b.id);if(!y||!cE.has(String(b.kind)))throw T("schema.invalidValue",g);if(u.has(y))throw T("schema.invalidValue",`${g}.id`);u.add(y),d.push(b)}let l=C(c?.rootNodeId),m=l?d.find(S=>C(S?.id)===l):null,f=!!m&&cE.has(String(m.kind))&&!Object.prototype.hasOwnProperty.call(m,"parentId");if(c?.compositionVersion!==sn||d.length===0||!f)throw T("schema.unsupportedVersion",`$.assets[${i}].prefab`);r.set(C(s.id),d.flatMap((S,g)=>{let b=C(S.childPrefabId);return b?[{prefabId:b,path:`$.assets[${i}].prefab.nodes[${g}].childPrefabId`}]:[]}));for(let S=0;S<d.length;S+=1){let g=d[S];lg(g,new Map(d.map(P=>[C(P.id),P])),`$.assets[${i}].prefab.nodes[${S}]`);let b=C(g.id),y=C(g.parentId);if(b!==l&&(!y||!u.has(y)))throw T("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);if(g.kind==="prefabInstance"){let P=C(g.childPrefabId);if(!P||!t.has(P))throw T("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].childPrefabId`)}let E=new Set([b]),I=y;for(;I;){if(E.has(I))throw T("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);E.add(I);let P=d.find(A=>C(A.id)===I);I=P?C(P.parentId):null}}}let n=new Set,o=new Set,a=i=>{if(!o.has(i)){n.add(i);for(let s of r.get(i)??[]){if(n.has(s.prefabId))throw T("schema.invalidReference",s.path);a(s.prefabId)}n.delete(i),o.add(i)}};for(let i of r.keys())a(i)}function lE(e,t){if(e==null)return;let r=k(e);if(!r)throw T("schema.invalidType",t);if(Object.prototype.hasOwnProperty.call(r,"active")&&typeof r.active!="boolean")throw T("schema.invalidType",`${t}.active`)}function _C(e,t){let r=new Map;for(let n of t.map(k)){if(n?.type!=="prefab")continue;let o=C(n.id),a=C(k(n.prefab)?.sourceAssetId);o&&a&&r.set(o,a)}for(let n=0;n<e.length;n+=1){let o=k(e[n]);if(!o||o.prefab==null)continue;let a=k(o.prefab),i=C(a?.prefabId),s=i?r.get(i):null;if(!i||!s)throw T("schema.unsupportedVersion",`$.scene.gameObjects[${n}].prefab`);if(C(a?.sourceAssetId)!==s)throw T("schema.invalidReference",`$.scene.gameObjects[${n}].prefab.sourceAssetId`);let c=C(k(o.instance)?.assetId);if(c&&c!==s)throw T("schema.invalidReference",`$.scene.gameObjects[${n}].instance.assetId`);let d=Array.isArray(o.components)?o.components:[];for(let u=0;u<d.length;u+=1){let l=k(d[u]);if(l?.type==="ModelRenderer"&&C(l.assetId)!==s)throw T("schema.invalidReference",`$.scene.gameObjects[${n}].components[${u}].assetId`)}}}function $C(e){for(let t=0;t<e.length;t+=1){let r=k(k(k(e[t])?.marker)?.geometry);if(r?.kind!=="box")continue;for(let o of CC)if(Object.prototype.hasOwnProperty.call(r,o))throw T("schema.deprecatedField",`$.scene.gameObjects[${t}].marker.geometry.${o}`);if(!(Array.isArray(k(e[t])?.components)?k(e[t]).components:[]).some(o=>k(o)?.type==="Transform"))throw T("schema.invalidValue",`$.scene.gameObjects[${t}].components`)}}function LC(e,t){let r=new Map,n=new Map;for(let o=0;o<e.length;o+=1){let a=k(e[o]),i=C(a?.id);if(!a||!i)continue;if(a.type==="prefab"){let l=C(k(a.prefab)?.sourceAssetId);l&&n.set(i,l)}let s=k(a.metadata),c=s?.materialSlots;if(c==null){r.set(i,new Set);continue}if(!Array.isArray(c))throw T("schema.invalidType",`$.assets[${o}].metadata.materialSlots`);let d=zC(s?.assetAnalysis),u=new Set;for(let l=0;l<c.length;l+=1){let m=k(c[l]),f=C(m?.slotId);if(!m||!f)throw T("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}]`);let S=`$.assets[${o}].metadata.materialSlots[${l}]`;for(let g of["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMaterialIndices","sourceMeshName","triangleCount","boundingBox"])if(Object.prototype.hasOwnProperty.call(m,g))throw T("schema.deprecatedField",`${S}.${g}`);if(!Array.isArray(m.sourceSurfaces))throw T("schema.invalidType",`${S}.sourceSurfaces`);if(m.sourceSurfaces.length===0)throw T("schema.invalidValue",`${S}.sourceSurfaces`);for(let g=0;g<m.sourceSurfaces.length;g+=1){let b=`${S}.sourceSurfaces[${g}]`,y=k(m.sourceSurfaces[g]);if(!y||!C(y.ownerNodePath))throw T("schema.invalidValue",b);uE(y,"nodeIndex",b),uE(y,"sourceMaterialIndex",b);for(let I of["meshIndex","primitiveIndex"])if(!Number.isInteger(y[I])||y[I]<0)throw T("schema.invalidValue",`${b}.${I}`);if(y.nodeIndexPath!=null&&(!Array.isArray(y.nodeIndexPath)||y.nodeIndexPath.some(I=>!Number.isInteger(I)||I<0)))throw T("schema.invalidValue",`${b}.nodeIndexPath`);let E=y.meshIndex;if(!C(y.sourceMeshName)&&!d.has(E))throw T("schema.invalidValue",`${b}.sourceMeshName`)}if(u.has(f))throw T("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}].slotId`);u.add(f)}r.set(i,u)}for(let o=0;o<e.length;o+=1){let a=k(e[o]);if(a?.type!=="prefab")continue;let i=k(a.prefab),s=C(i?.sourceAssetId);Dm(i?.overrides,s?r.get(s):void 0,`$.assets[${o}].prefab.overrides`);let c=Array.isArray(i?.nodes)?i.nodes:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]),l=C(u?.childPrefabId),m=C(u?.sourceAssetId)??(l?n.get(l)??null:null);Dm(u?.overrides,m?r.get(m):void 0,`$.assets[${o}].prefab.nodes[${d}].overrides`)}}for(let o=0;o<t.length;o+=1){let a=k(t[o]),s=(Array.isArray(a?.components)?a.components:[]).map(k).find(d=>d?.type==="ModelRenderer"),c=C(s?.assetId);Dm(a?.overrides,c?r.get(c):void 0,`$.scene.gameObjects[${o}].overrides`)}}function Dm(e,t,r){let n=k(e);if(!n||n.materialSlotBindings==null)return;let o=k(n.materialSlotBindings);if(!o)throw T("schema.invalidType",`${r}.materialSlotBindings`);for(let[a,i]of Object.entries(o)){if(!t?.has(a))throw T("schema.invalidReference",`${r}.materialSlotBindings.${a}`);let s=`${r}.materialSlotBindings.${a}`,c=k(i);if(!c)throw T("schema.invalidType",s);for(let d of Object.keys(c))if(d!=="materialAssetId"&&d!=="override")throw T("schema.deprecatedField",`${s}.${d}`);if("materialAssetId"in c&&c.materialAssetId!=null&&!C(c.materialAssetId))throw T("schema.invalidValue",`${s}.materialAssetId`);if("override"in c&&!k(c.override))throw T("schema.invalidType",`${s}.override`);"override"in c&&BC(c.override,`${s}.override`)}}function uE(e,t,r){let n=e[t];if(n!=null&&(!Number.isInteger(n)||n<0))throw T("schema.invalidValue",`${r}.${t}`)}function zC(e){let t=k(e),r=Array.isArray(t?.meshes)?t.meshes:[];return new Set(r.flatMap(n=>{let o=k(n),a=o?.meshIndex,i=Number.isInteger(a)?a:null;return i!=null&&C(o?.name)?[i]:[]}))}function BC(e,t){let r=k(e);if(!r)throw T("schema.invalidType",t);if(Co(r,["lightingModel","baseColor","normal","metallic","roughness","metallicRoughness","occlusion","emission","alpha"],t),"lightingModel"in r&&!["lit","unlit"].includes(String(r.lightingModel)))throw T("schema.invalidValue",`${t}.lightingModel`);for(let n of["metallic","roughness"])ri(r,n,t);VC(r.baseColor,`${t}.baseColor`),Mm(r.normal,`${t}.normal`,["texture","strength"]),Mm(r.metallicRoughness,`${t}.metallicRoughness`,["texture"]),Mm(r.occlusion,`${t}.occlusion`,["texture","strength"]),UC(r.emission,`${t}.emission`),KC(r.alpha,`${t}.alpha`)}function VC(e,t){if(e==null)return;let r=vo(e,t);Co(r,["color","texture","brightness","saturation","contrast","hue"],t),SE(r.color,`${t}.color`),ti(r.texture,`${t}.texture`);for(let n of["brightness","saturation","contrast","hue"])ri(r,n,t)}function Mm(e,t,r){if(e==null)return;let n=vo(e,t);Co(n,r,t),ti(n.texture,`${t}.texture`),r.includes("strength")&&ri(n,"strength",t)}function UC(e,t){if(e==null)return;let r=vo(e,t);Co(r,["color","intensity","texture","maskTexture"],t),SE(r.color,`${t}.color`),ri(r,"intensity",t),ti(r.texture,`${t}.texture`),ti(r.maskTexture,`${t}.maskTexture`)}function KC(e,t){if(e==null)return;let r=vo(e,t);if(Co(r,["mode","opacity","cutoff","texture"],t),"mode"in r&&!["opaque","mask","blend"].includes(String(r.mode)))throw T("schema.invalidValue",`${t}.mode`);for(let n of["opacity","cutoff"])ri(r,n,t);ti(r.texture,`${t}.texture`)}function ti(e,t){if(e==null)return;let r=vo(e,t);Co(r,["url","textureAssetId"],t);for(let n of["url","textureAssetId"])if(n in r&&r[n]!=null&&!C(r[n]))throw T("schema.invalidValue",`${t}.${n}`)}function SE(e,t){if(e==null)return;let r=vo(e,t);for(let n of["r","g","b"])HC(r,n,t)}function Co(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw T("schema.deprecatedField",`${r}.${o}`)}function ri(e,t,r){if(t in e&&e[t]!=null&&(typeof e[t]!="number"||!Number.isFinite(e[t])))throw T("schema.invalidType",`${r}.${t}`)}function HC(e,t,r){if(!(t in e)||typeof e[t]!="number"||!Number.isFinite(e[t]))throw T("schema.invalidValue",`${r}.${t}`)}function vo(e,t){let r=k(e);if(!r)throw T("schema.invalidType",t);return r}function T(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function k(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function C(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function mE(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}var WC=Object.freeze({bash:"shell",cjs:"javascript",conf:"config",config:"config",css:"css",env:"dotenv",frag:"glsl",fs:"glsl",glsl:"glsl",htm:"html",html:"html",ini:"config",js:"javascript",json:"json",jsonc:"jsonc",jsx:"javascript",less:"less",md:"markdown",mjs:"javascript",scss:"scss",shader:"glsl",sh:"shell",toml:"toml",ts:"typescript",tsx:"typescript",txt:"text",vert:"glsl",vs:"glsl",wgsl:"wgsl",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"shell"}),qC=Object.freeze({".env":"dotenv",".eslintignore":"config",".gitignore":"config",".npmrc":"config",".prettierignore":"config",dockerfile:"dockerfile",makefile:"makefile"}),JC=Object.freeze({png:{kind:"image",mimeType:"image/png"},jpg:{kind:"image",mimeType:"image/jpeg"},jpeg:{kind:"image",mimeType:"image/jpeg"},webp:{kind:"image",mimeType:"image/webp"},gif:{kind:"image",mimeType:"image/gif"},bmp:{kind:"image",mimeType:"image/bmp"},glb:{kind:"model",mimeType:"model/gltf-binary"},mp3:{kind:"audio",mimeType:"audio/mpeg"},wav:{kind:"audio",mimeType:"audio/wav"},ogg:{kind:"audio",mimeType:"audio/ogg"},m4a:{kind:"audio",mimeType:"audio/mp4"},aac:{kind:"audio",mimeType:"audio/aac"},flac:{kind:"audio",mimeType:"audio/flac"}});function qc(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"",n=r.lastIndexOf(".");return n>0?r.slice(n+1):""}function Om(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"";return qC[r]??WC[qc(r)]??null}function yE(e){return Om(e)!==null}function Rm(e){return JC[qc(e)]??null}var XC="fps.plugin.ground-decal",hE="@fps-games/plugin-ground-decal";function EE(e){QC(e);let t=e.plugins.find(i=>i.pluginId===XC),r=t?ZC(t):null,n=r?[{id:"groundDecal",label:"Ground Decal",config:YC(r),scene:{kind:"groundDecal"}}]:[],o=e.authoring.source,a=e.authoring.assets;return Object.freeze({definition:e,plugins:e.plugins,groundDecal:r,metadata:ev(e.metadata),project:Object.freeze({projectId:e.projectId,projectName:e.projectName,source:Object.freeze({editorScene:o.document,runtimeScene:o.runtimeArtifact,...o.rendering?{rendering:o.rendering}:{},...o.shadows?{shadows:o.shadows}:{}}),assets:Object.freeze({...a}),features:Object.freeze(n),...e.metadata&&Ce(e.metadata)?{metadata:Object.freeze({...e.metadata})}:{}})})}function YC(e){let t=new Map(e.kinds.map(l=>[l.id,l])),r=new Set(e.editableLayerRoles??[]),n=new Set(e.layoutEditableLayerRoles??[]),o=new Set(e.rotationEditableLayerRoles??[]),a=new Set(e.stretchedImageRoles??[]),i=new Set(e.activePreviewKinds??[]),s=l=>t.has(l),c=l=>{let m=t.get(l)??t.get(e.defaultUiKind);if(!m)throw new Error(`Ground Decal kind is not configured: ${l}`);return structuredClone(m.defaultConfig)},d=l=>tv(l,t),u={defaultUiKind:e.defaultUiKind,isKnownUiKind:s,isProjectEditableLayer:l=>r.size===0||r.has(l.role),isLayoutEditableLayer:l=>n.has(l.role),isRotationEditableLayer:l=>o.has(l.role),createDefaultGroundDecal:c,isGroundDecalConfig:d};return{uiKinds:Object.freeze([...t.keys()]),documentPolicy:u,inspectorPolicy:{...u,isEditableTextureLayer:l=>(l.kind==="texture"||l.kind==="textureProgress")&&(r.size===0||r.has(l.role)),isEditableColorLayer:l=>(l.kind==="color"||l.kind==="progress")&&(r.size===0||r.has(l.role)),isEditableTextLayer:l=>l.kind==="text"&&(r.size===0||r.has(l.role)),useUniformLayoutScaleMode:l=>n.has(l.role),resolveImageFit:l=>"imageFit"in l&&(l.imageFit==="stretch"||l.imageFit==="contain")?l.imageFit:a.has(l.role)?"stretch":"contain",createLayerLabel:l=>rv(l.role),createUiKindLabel:l=>t.get(l)?.label??l,canShowActivePreview:l=>i.has(l.uiKind),getLayerPreviewVisibility:(l,m)=>i.has(m.uiKind)&&l.role==="activeBackground"?{path:"groundDecal.editorPreviewActive",value:m.editorPreviewActive===!0}:null},createHierarchyLabel:l=>t.get(l)?.hierarchyLabel??`${t.get(l)?.label??l} Ground Decal UI`}}function ZC(e){if(e.packageName!==hE)throw new Error(`Ground Decal Plugin package must be ${hE}.`);if(!e.targets.includes("editor"))throw new Error("Ground Decal Plugin must target editor.");let t=e.config;if(!Ce(t)||t.schemaVersion!==1)throw new Error("Ground Decal Plugin config schemaVersion must be 1.");if(typeof t.defaultUiKind!="string"||!Array.isArray(t.kinds)||t.kinds.length===0)throw new Error("Ground Decal Plugin config must define defaultUiKind and kinds.");let r=new Set;for(let n of t.kinds){if(!Ce(n)||typeof n.id!="string"||typeof n.label!="string"||!Ce(n.defaultConfig))throw new Error("Ground Decal Plugin kinds must contain id, label, and defaultConfig.");if(r.has(n.id))throw new Error(`Duplicate Ground Decal kind: ${n.id}`);if(r.add(n.id),n.defaultConfig.uiKind!==n.id)throw new Error(`Ground Decal defaultConfig.uiKind must match kind id: ${n.id}`)}if(!r.has(t.defaultUiKind))throw new Error(`Ground Decal defaultUiKind is not declared: ${t.defaultUiKind}`);for(let n of["editableLayerRoles","layoutEditableLayerRoles","rotationEditableLayerRoles","stretchedImageRoles","activePreviewKinds"]){let o=t[n];if(o!==void 0&&(!Array.isArray(o)||o.some(a=>typeof a!="string")))throw new Error(`Ground Decal Plugin config.${n} must be an array of strings.`)}return t}function QC(e){if(!Ce(e)||e.schemaVersion!==1)throw new Error("Editor Project definition schemaVersion must be 1.");if(typeof e.projectId!="string"||typeof e.projectName!="string")throw new Error("Editor Project identity is invalid.");if(!Ce(e.authoring)||!Ce(e.authoring.source)||!Ce(e.authoring.assets)||!Array.isArray(e.plugins))throw new Error("Editor Project authoring or Plugin configuration is invalid.")}function ev(e){return Ce(e)?Object.freeze({...Array.isArray(e.markerTypes)?{markerTypes:Object.freeze(e.markerTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{},...Array.isArray(e.relationTypes)?{relationTypes:Object.freeze(e.relationTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{}}):Object.freeze({})}function tv(e,t){if(!Ce(e)||typeof e.uiKind!="string"||!t.has(e.uiKind)||!Ce(e.size)||!Jc(e.size.width)||!Jc(e.size.depth)||!Array.isArray(e.layers))return!1;let r=new Set;for(let n of e.layers){if(!Ce(n)||typeof n.id!="string"||!n.id||typeof n.role!="string"||!n.role||typeof n.kind!="string"||!Ce(n.rect)||!Number.isFinite(n.rect.x)||!Number.isFinite(n.rect.z)||!Jc(n.rect.width)||!Jc(n.rect.depth)||r.has(n.id))return!1;r.add(n.id)}return!0}function Jc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ce(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function rv(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var nv=["/__fps_editor_authoring"],ov=[["manifest","/manifest"],["commit","/commit"],["editor-scene","/editor-scene"],["editor-asset-library","/editor-asset-library"],["project-files","/project-files"],["project-media","/project-media"],["project-file","/project-file"],["asset-import","/asset-import"],["save-editor-scene","/save-editor-scene"]];function IE(e,t={}){let r=new URL(e??"","http://localhost").pathname,n=t.prefixes??nv,o=av(r,n);if(!o)return null;let a=r.slice(o.length)||"/",i=iv(a);return i?{route:a,routeName:i,prefix:o}:null}function av(e,t){return t.find(r=>e===r||e.startsWith(`${r}/`))??null}function iv(e){return ov.find(([,t])=>e===t)?.[0]??null}function Pe(e,t){return{statusCode:e,body:t}}function Xc(e){return{statusCode:e,body:null}}async function PE(e,t){let r=IE(e.url);if(!r)return null;let n=(e.method??"GET").toUpperCase();if(n==="OPTIONS")return Xc(204);try{if(sv(r.routeName)){if(n!=="GET")return Pe(405,{ok:!1,error:"method_not_allowed"});if(r.routeName==="project-file"){let a=new URL(e.url??"","http://localhost").searchParams.get("path")?.trim()??"";if(!a)return Pe(400,{ok:!1,error:"missing_file_path"});let i=await t.loadProjectFile?.({path:a,route:r});return Pe(200,i??{ok:!1,error:"not_found"})}return Pe(200,await cv(r,t))}if(n!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let o=e.body??await t.readBody?.(e,r)??{};return await dv(r,o,t)}catch(o){let a=typeof o?.code=="string"?o.code:"authoring_request_failed",i=a==="asset_import_payload_too_large"?413:r.routeName==="save-editor-scene"&&a==="authoring_source_revision_mismatch"?200:r.routeName==="asset-import"?400:500;return Pe(i,{ok:!1,error:o instanceof Error?o.message:String(o),code:a,details:se(o?.details)})}}function sv(e){return e==="manifest"||e==="editor-scene"||e==="editor-asset-library"||e==="project-files"||e==="project-file"||e==="project-media"}async function cv(e,t){return e.routeName==="manifest"&&t.loadManifest?t.loadManifest(e):e.routeName==="editor-scene"&&t.loadEditorScene?t.loadEditorScene(e):e.routeName==="editor-asset-library"&&t.loadEditorAssetLibrary?t.loadEditorAssetLibrary(e):e.routeName==="project-files"&&t.loadProjectFiles?t.loadProjectFiles(e):{ok:!1,error:"not_found"}}async function dv(e,t,r){if(e.routeName==="asset-import"){let n=ah(t),o=await r.importAsset?.({payload:n,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}return e.routeName==="save-editor-scene"?lv(e,t,r):e.routeName==="commit"?Pe(410,await uv(e,t,r)):Pe(404,{ok:!1,error:"not_found"})}async function lv(e,t,r){let n=t.mode==="prepare-platform-save"?"prepare-platform-save":"local-commit-save",o=await r.saveEditorScene?.({body:t,mode:n,rawEditorScene:t.editorScene,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}async function uv(e,t,r){return r.commit?.({body:t,route:e})??{ok:!1,error:"platform_commit_route_disabled",message:"Save through /__fps_editor_authoring/save-editor-scene so scene.main remains the authoring source of truth."}}function xE(e,t,r={}){let n=gE(e).document,o=t;Object.prototype.hasOwnProperty.call(o,"staticShadows")&&o.staticShadows!=null&&Wn(o.staticShadows,"$.staticShadows");let{scene:a,...i}=t,s=structuredClone(i),c=Ue(a)?a:void 0,d=Wt(n),u={...d,compilerId:fE,compilerVersion:pE,compiledAt:new Date().toISOString()};s.schemaVersion=3,s.meta={...s.meta??{},generatedFrom:u};let l=c?.rootId||"root",m=n.scene.gameObjects.filter(E=>E.id!==l),f=bv(n,r.materialShaderDefinitions,!0),S={...n,scene:{...n.scene,materialAssets:f}},g=m.flatMap(E=>Mv(E,d,S,r)),b=g.map(AE);fv(l,b),pv(l,b);let y={rootId:l,assets:S.assets.filter(hv).map(Ev),nodes:b,materialAssets:f,materials:structuredClone(c?.materials??[]),textures:structuredClone(c?.textures??[])};return s.scene=y,s.plugins=kv(s.plugins,r.shadowMapExperimentConfig,g,l,d.revision),Ni(s),{sceneConfig:s,summary:{assetCount:y.assets.length,gameObjectCount:n.scene.gameObjects.length,nodeCount:y.nodes.length}}}function AE(e){if(!Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentInferredUpdateClass"))return e;let{shadowMapExperimentInferredUpdateClass:t,...r}=e;return r}function fv(e,t){let r=new Set([e]);for(let n=0;n<t.length;n+=1){let o=t[n].id;if(r.has(o)){let a=new Error(`schema.invalidReference: $.scene.nodes[${n}].id`);throw Object.assign(a,{code:"schema.invalidReference",path:`$.scene.nodes[${n}].id`,nodeId:o}),a}r.add(o)}}function pv(e,t){let r=new Map(t.map(n=>[n.id,n]));for(let n=0;n<t.length;n+=1){let o=t[n];if(!(o.source?.component!=="PrefabMarker"||!("marker"in o)||!o.marker))for(let a of gv(o.marker)){let i=r.get(a.target.id);if(a.target.id!==e&&(!i||i.source?.objectId===o.source.objectId))continue;let s=`$.scene.nodes[${n}].marker.${a.path}.id`,c=new Error(`schema.invalidReference: ${s}`);throw Object.assign(c,{code:"schema.invalidReference",path:s,nodeId:o.id,targetId:a.target.id}),c}}}function gv(e){let t=[];return e.target&&t.push({path:"target",target:e.target}),e.geometry.kind==="point"&&e.geometry.target&&t.push({path:"geometry.target",target:e.geometry.target}),e.geometry.kind==="object-bounds"&&t.push({path:"geometry.target",target:e.geometry.target}),t}function bv(e,t,r=!1){let n=structuredClone(e.scene.materialAssets??[]);for(let a=0;a<n.length;a+=1){let i=n[a];if(De(i.shaderId))continue;let s=t?.get(i.shaderId);if(!s){if(!r)continue;throw Cm("material.shaderDefinitionNotFound",`$.scene.materialAssets[${a}].shaderId`,`Shader Definition was not found: ${i.shaderId}`)}if(i.definitionVersion!==s.version)throw Cm("material.shaderDefinitionVersionMismatch",`$.scene.materialAssets[${a}].definitionVersion`,`Material ${i.id} uses Definition v${String(i.definitionVersion)} but ${i.shaderId} is v${s.version}.`);let c=Qn(i.shaderId,i.properties,`$.scene.materialAssets[${a}].properties`,t);if(c[0])throw Cm("material.propertiesInvalid",c[0].path,c[0].message)}let o=ns(Sv(e,n));if(!o.ok)throw new Error(`editor_scene_material_assets_missing: ${o.missingMaterialAssetIds.join(", ")}`);return n}function Cm(e,t,r){return Object.assign(new Error(`${e}: ${r}`),{code:e,path:t})}function Sv(e,t){let r={...e,scene:{...e.scene,materialAssets:t}};return{...r,scene:{...r.scene,gameObjects:[...r.scene.gameObjects.map(n=>{let o=vE(n,r);if(o)return{...n,overrides:o};if(!("overrides"in n))return n;let a={...n};return delete a.overrides,a}),...yv(r)]}}}function yv(e){let t=[];for(let r of e.scene.gameObjects){let n=ln(e,r);!n.definition||!Yc(n.definition)||t.push(...DE({editorDocument:e,prefabAsset:n.definition,hostGameObject:r,instanceOverrides:r.overrides,visitedPrefabIds:new Set}))}return t}function DE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[];e.visitedPrefabIds.add(e.prefabAsset.id);let t=RE(Ze(e.prefabAsset),Ye(e.prefabAsset)??""),r=t.find(a=>a.id===Ye(e.prefabAsset));if(!r)return e.visitedPrefabIds.delete(e.prefabAsset.id),[];let n=CE(t,e.prefabAsset),o=[];for(let a of t){if(a.kind==="prefabInstance"&&a.childPrefabId){let d=e.editorDocument.assets.find(u=>u.id===a.childPrefabId);if(d&&Yc(d)){o.push(...DE({editorDocument:e.editorDocument,prefabAsset:d,hostGameObject:e.hostGameObject,instanceOverrides:a.overrides,visitedPrefabIds:new Set(e.visitedPrefabIds)}));continue}continue}let i=$v(e.hostGameObject,a);if(!i)continue;let s=a.kind==="model"&&a.sourceAssetId?e.editorDocument.assets.find(d=>d.id===a.sourceAssetId):void 0,c=Fm({hostGameObject:i,prefabAsset:e.prefabAsset,rootNode:r,node:a,asset:s,editorDocument:e.editorDocument,instanceOverrides:a.id===n?e.instanceOverrides:void 0});c&&o.push({...i,overrides:c})}return e.visitedPrefabIds.delete(e.prefabAsset.id),o}function hv(e){return e.type==="glb"||e.type==="texture"}function Ev(e){let t=Tv(e),r=e.type==="glb"?xv(e):[],n=Pv(e.external),o=Iv(e.defaults);return{id:e.id,type:e.type,...e.guid?{guid:e.guid}:{},...t?{url:t}:{},...typeof e.warmupCount=="number"&&Number.isInteger(e.warmupCount)&&e.warmupCount>=0?{warmupCount:e.warmupCount}:{},...typeof e.singleton=="boolean"?{singleton:e.singleton}:{},...typeof e.materialMode=="string"?{materialMode:e.materialMode}:{},...o!==void 0?{defaults:o}:{},...n?{external:n}:{},...r.length>0?{materialSlots:r}:{}}}function Iv(e){if(!e)return;let t=structuredClone(e);return Ue(t)?(delete t.shadowMapExperiment,Object.keys(t).length>0?t:void 0):t}function Pv(e){let t=Ue(e)?e:void 0,r=yr(t?.platformAssetId),n=yr(t?.assetUrl);if(!(!r&&!n))return{...r?{platformAssetId:r}:{},...n?{assetUrl:n}:{}}}function Tv(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Ue(e.external)?e.external:void 0;return yr(t?.url)??yr(r?.assetUrl)??void 0}function xv(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Array.isArray(t?.materialSlots)?t.materialSlots:[],n=Av(t?.assetAnalysis);return r.flatMap(o=>{if(!Ue(o))return[];let a=yr(o.slotId);if(!a)return[];let i=yr(o.label),s=(Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[]).flatMap(c=>{if(!Ue(c))return[];let d=yr(c.ownerNodePath),u=ni(c.meshIndex),l=ni(c.primitiveIndex);if(!d||u==null||l==null)return[];let m=ni(c.nodeIndex),f=Dv(Array.isArray(c.nodeIndexPath)?c.nodeIndexPath:[]),S=ni(c.sourceMaterialIndex),g=yr(c.sourceMeshName)??n.get(u);return[{ownerNodePath:d,...m==null?{}:{nodeIndex:m},...f.length>0?{nodeIndexPath:f}:{},meshIndex:u,primitiveIndex:l,...S==null?{}:{sourceMaterialIndex:S},...g?{sourceMeshName:g}:{}}]});return s.length===0?[]:[{slotId:a,...i?{label:i}:{},sourceSurfaces:s}]})}function Av(e){let t=Ue(e)?e:void 0,r=Array.isArray(t?.meshes)?t.meshes:[];return new Map(r.flatMap(n=>{if(!Ue(n))return[];let o=ni(n.meshIndex),a=yr(n.name);return o==null||!a?[]:[[o,a]]}))}function Dv(e){return[...new Set(e.filter(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0))]}function ni(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:void 0}function Mv(e,t,r,n){let o=ln(r,e);return(o.definition&&Yc(o.definition)?Rv(e,o.definition,t,r,new Set,n):[wv(e,t,r,n)]).map(i=>{let s=i.kind==="instance"?r.assets.find(d=>d.id===i.instance.assetId):void 0,c=n.inferShadowMapExperimentUpdateClass?.({gameObject:e,runtimeNode:AE(i),...s?{asset:s}:{}})??Ov(s);return{...i,shadowMapExperimentInferredUpdateClass:c}})}function wv(e,t,r,n={}){let o=G(e),a=ue(e),i=kr(e),s=zv(e),c=Y(e),d=vE(e,r),u=ag(e),l={sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision,...e.guid?{objectGuid:e.guid}:{},objectId:e.id,component:a?"ModelRenderer":i?"ImageRenderer":s||c==="primitive"?"PrimitiveRenderer":c==="transform"?"Transform":"GameObject"},m={id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...Gv(r,e,n),...u?{rendering:u}:{},source:l,...o&&"position"in o?{transform:{position:o.position,rotation:o.rotation,...o.scale?{scale:o.scale}:{}}}:{}};if(c==="primitive")return{...m,kind:"primitive",primitive:{shape:s?.shape??"cube"},...d?{overrides:d}:{}};if(i)return{...m,kind:"image",image:{assetId:i.assetId,size:{width:i.size.width,height:i.size.height}},...d?{overrides:d}:{}};if(!a){if(c==="transform"){let f=vv(e,n),S=f.transformType;delete f.transformType;let g=TE(S)??TE(e.transformType);return{...m,kind:"transform",...g?{transformType:g}:{},...e.camera?{camera:Uv(e.camera)}:{},...e.light?{light:GE(e.light)}:{},...e.marker?{marker:{label:e.name||e.id,...structuredClone(e.marker)}}:{},...f,...d?{overrides:d}:{}}}return{...m,kind:"group"}}return{...m,kind:"instance",instance:{assetId:a.assetId},...d?{overrides:d}:{}}}function kv(e,t,r,n,o){let a=(e??[]).filter(u=>u.pluginId!==gd);if(!t)return a;let i=r.find(u=>u.id===t.lightRef),s=i?.kind==="transform"&&i.light?.type==="directional"?i:void 0;if(!i&&t.enabled)throw new Error(`shadowMapExperiment.lightMissing:${t.lightRef}`);if(i&&!s&&t.enabled)throw new Error(`shadowMapExperiment.lightUnsupported:${t.lightRef}`);let c=s?.kind==="transform"&&s.light?.type==="directional"?[s.light.direction.x,s.light.direction.y,s.light.direction.z]:[0,-1,0],d=Ef({revision:typeof o=="number"&&Number.isInteger(o)&&o>=0?o:0,scopeId:n,config:t,lightDirection:c,objects:r.filter(u=>u.kind==="instance"||u.kind==="primitive").map(u=>({entityId:u.id,renderableIds:[u.id],cast:u.shadow?.cast==="enabled",receive:u.shadow?.receive==="enabled",inferredUpdateClass:u.shadowMapExperimentInferredUpdateClass??"static"}))});return[...a,{pluginId:gd,schemaVersion:3,data:d}]}function Ov(e){let t=Ue(e?.metadata?.assetAnalysis)?e.metadata.assetAnalysis:void 0;if(!t)return"static";let r=vm(t.skinCount),n=vm(t.morphTargetCount);return r>0||n>0?"skinned":vm(t.animationCount)>0?"dynamic":"static"}function vm(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}function Rv(e,t,r,n,o,a){return ME({prefabAsset:t,sourceRef:r,editorDocument:n,hostGameObject:e,rootRuntimeId:e.id,rootParentId:e.parentId,rootName:e.name??t.displayName??t.id,rootTransform:G(e)??void 0,rootActive:e.active,instanceOverrides:e.overrides,propertyPathPrefix:`assets.${t.id}.prefab.nodes`,visitedPrefabIds:o,compilerOptions:a})}function ME(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[Gm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"PrefabCycle",propertyPath:e.propertyPathPrefix})];e.visitedPrefabIds.add(e.prefabAsset.id);let t=Ze(e.prefabAsset),r=Ye(e.prefabAsset),n=r?t.find(d=>d.id===r):null;if(!n||t.length===0)return e.visitedPrefabIds.delete(e.prefabAsset.id),[Gm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"Prefab",propertyPath:e.propertyPathPrefix})];let o={instanceId:e.rootRuntimeId,rootNodeId:n.id},a=d=>ao(o,d.id),i=RE(t,n.id),s=CE(i,e.prefabAsset),c=[];for(let d of i){let u=a(d),l=d.id===n.id?e.rootParentId:a(t.find(m=>m.id===d.parentId)??n);if(d.kind==="prefabInstance"&&d.childPrefabId){let m=e.editorDocument.assets.find(f=>f.id===d.childPrefabId);if(m&&Yc(m)){let f=d.id===n.id;c.push(...ME({prefabAsset:m,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeId:u,rootParentId:l,rootName:f?e.rootName??d.name??m.displayName??m.id:d.name??m.displayName??m.id,rootTransform:f?e.rootTransform??d.transform:d.transform,rootActive:f?e.rootActive??d.defaults?.active??e.prefabAsset.prefab?.defaults?.active:d.defaults?.active,instanceOverrides:f?oi(oi(Yt(e.prefabAsset.prefab?.overrides),Yt(d.overrides)),Yt(e.instanceOverrides)):d.overrides,propertyPathPrefix:`${e.propertyPathPrefix}.${d.id}.childPrefab.nodes`,visitedPrefabIds:new Set(e.visitedPrefabIds),compilerOptions:e.compilerOptions}));continue}c.push(Gm({id:u,name:d.name??d.childPrefabId??"Prefab Instance",parentId:l,transform:d.transform,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,component:"UnsupportedPrefabInstance",propertyPath:`${e.propertyPathPrefix}.${d.id}`}));continue}c.push(Cv({node:d,rootNode:n,identityScope:o,prefabAsset:e.prefabAsset,runtimeId:u,parentId:l,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeName:e.rootName,rootRuntimeTransform:e.rootTransform,rootRuntimeActive:e.rootActive,instanceOverrides:d.id===s?e.instanceOverrides:void 0,propertyPath:`${e.propertyPathPrefix}.${d.id}`,shadowFallbackMode:Nm(e.compilerOptions)}))}return e.visitedPrefabIds.delete(e.prefabAsset.id),Nv({compiledNodes:c,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,shadowFallbackMode:Nm(e.compilerOptions)})}function Cv(e){let t=e.node.id===e.rootNode.id,r=t?e.rootRuntimeTransform??e.node.transform:e.node.transform,n=e.node.kind==="model"&&e.node.sourceAssetId?e.editorDocument.assets.find(i=>i.id===e.node.sourceAssetId):void 0,o=e.node.kind==="model"||e.node.kind==="primitive",a=wE({id:e.runtimeId,name:t?e.rootRuntimeName??e.node.name??e.prefabAsset.displayName??e.prefabAsset.id:e.node.name,parentId:e.parentId,transform:r,active:t?e.rootRuntimeActive??e.node.defaults?.active??e.prefabAsset.prefab?.defaults?.active:e.node.defaults?.active,...o?{shadow:e.prefabAsset.prefab?.defaults?.shadow}:{},editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.node.kind==="model"?"PrefabModel":e.node.kind==="primitive"?"PrefabPrimitive":e.node.kind==="light"?"PrefabLight":e.node.kind==="marker"?"PrefabMarker":"PrefabNode",propertyPath:e.propertyPath});if(e.node.kind==="model"&&e.node.sourceAssetId){let i=Fm({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:n,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"instance",instance:{assetId:e.node.sourceAssetId},...i?{overrides:i}:{}}}if(e.node.kind==="primitive"){let i=Fm({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:void 0,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"primitive",primitive:{shape:e.node.primitive?.shape??"cube"},...i?{overrides:i}:{}}}return e.node.kind==="light"?{...a,kind:"transform",transformType:"light",...e.node.light?{light:GE(e.node.light)}:{}}:e.node.kind==="marker"&&e.node.marker?{...a,kind:"transform",marker:{label:e.node.name??e.node.id,...pa(e.node.marker,e.identityScope)}}:{...a,kind:"group"}}function Gm(e){return{...wE({id:e.id,name:e.name,parentId:e.parentId,transform:e.transform,editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.component,propertyPath:e.propertyPath}),kind:"group"}}function vv(e,t){let r=t.readCustomTransformRuntimeData?.(e);return r&&typeof r=="object"&&!Array.isArray(r)?structuredClone(r):{}}function wE(e){return{id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...jv(e),source:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,revision:e.sourceRef.revision,...e.hostGameObject.guid?{objectGuid:e.hostGameObject.guid}:{},objectId:e.hostGameObject.id,component:e.component,propertyPath:e.propertyPath},...e.transform&&"position"in e.transform?{transform:{position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}}:{}}}function Gv(e,t,r){let n=Ts({document:e,casterId:t.id,caster:t,fallbackMode:Nm(r)});return _m(n,!!t.shadow)?{shadowPlan:n}:{}}function jv(e){if(!e.editorDocument)return{};let t=He(e.shadow),r=!!e.shadow||!!t.shadow;if(!r&&t.diagnostics.length===0)return{};let n=Ts({document:e.editorDocument,casterId:e.hostGameObject.id,caster:e.hostGameObject,resolvedSettings:t.shadow,fallbackMode:e.shadowFallbackMode}),o={...n,casterId:e.id,diagnostics:[...t.diagnostics,...n.diagnostics].map(a=>({...a,casterId:a.casterId===e.hostGameObject.id||!a.casterId?e.id:a.casterId}))};return _m(o,r)?{shadowPlan:o}:{}}function _m(e,t){return t||e.backend!=="none"||e.diagnostics.length>0}function Nv(e){if(e.compiledNodes.length===0)return e.compiledNodes;let t=new Set(e.compiledNodes.map(i=>i.id)),r=e.compiledNodes.map(i=>Fv(i)),n={...e.editorDocument,scene:{...e.editorDocument.scene,gameObjects:[...e.editorDocument.scene.gameObjects.filter(i=>!t.has(i.id)),...r]}},o=e.compiledNodes.filter(i=>i.shadow?.receive==="enabled").map(i=>i.id),a=r.find(i=>i.light?.type==="directional"&&i.active!==!1)?.id;return e.compiledNodes.map((i,s)=>{let c=r[s],d=Ts({document:n,casterId:i.id,caster:c,explicitReceiverIds:o,...a?{defaultLightId:a}:{},fallbackMode:e.shadowFallbackMode}),u=!!i.shadow;if(!_m(d,u)){if(!i.shadowPlan)return i;let l={...i};return delete l.shadowPlan,l}return{...i,shadowPlan:d}})}function Nm(e){let t=Ne(e.renderingProfile).shadows,r=t.planar.enabled?"planar":t.blob.enabled?"blob":t.staticProjected.enabled?"static":t.enabled?"dynamic":"none";return r==="planar"?"projected":r}function Fv(e){let t=[];return e.transform&&t.push({type:"Transform",position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}),e.kind==="instance"&&t.push({type:"ModelRenderer",assetId:e.instance.assetId}),e.kind==="image"&&t.push({type:"ImageRenderer",assetId:e.image.assetId,size:structuredClone(e.image.size)}),{id:e.id,...e.name?{name:e.name}:{},kind:e.kind==="image"?"transform":e.kind,...e.parentId?{parentId:e.parentId}:{},...e.enabled===!1?{active:!1}:{},...e.shadow?{shadow:{cast:e.shadow.cast==="enabled"?"enabled":"none",receive:e.shadow.receive==="enabled"?"enabled":"none"}}:{},...e.kind==="primitive"?{primitive:{shape:e.primitive.shape}}:{},...e.kind==="transform"&&e.transformType?{transformType:e.transformType}:{},...e.kind==="transform"&&e.light?{light:e.light}:{},...e.kind==="transform"&&e.camera?{camera:e.camera}:{},...e.kind==="transform"&&e.marker?{marker:structuredClone(e.marker)}:{},components:t}}function Fm(e){let t=e.node.kind==="model"&&e.node.sourceAssetId?OE(e.hostGameObject,e.node,e.node.sourceAssetId):e.hostGameObject,r=e.asset?.id,n=Lv([jm(Yt(e.prefabAsset.prefab?.overrides),e.prefabAsset.prefab?.sourceAssetId,e.asset),jm(Yt(e.rootNode.overrides),e.rootNode.kind==="model"?e.rootNode.sourceAssetId:e.prefabAsset.prefab?.sourceAssetId,e.asset),e.node.id===e.rootNode.id?void 0:jm(Yt(e.node.overrides),e.node.kind==="model"?e.node.sourceAssetId:r,e.asset)]),o=Yt(e.instanceOverrides);return kE(oi(n,o),e.asset)}function jm(e,t,r){return kE(e,t&&t===r?.id?r:void 0)}function kE(e,t){if(!e?.materialSlotBindings)return e;let r=Ue(t?.metadata)&&Array.isArray(t.metadata.materialSlots)?t.metadata.materialSlots:[],n=new Set(r.flatMap(i=>{let s=Ue(i)&&typeof i.slotId=="string"?i.slotId.trim():"";return s?[s]:[]})),o=Object.fromEntries(Object.entries(e.materialSlotBindings).filter(([i])=>n.has(i))),a=structuredClone(e);return Object.keys(o).length>0?a.materialSlotBindings=o:delete a.materialSlotBindings,Object.keys(a).length>0?a:void 0}function OE(e,t,r){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"instance",components:[...t.transform?[t.transform]:[],{type:"ModelRenderer",assetId:r}]}}function _v(e,t){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"primitive",primitive:{shape:t.primitive?.shape??"cube"},components:[...t.transform?[t.transform]:[]]}}function $v(e,t){return t.kind==="model"&&t.sourceAssetId?OE(e,t,t.sourceAssetId):t.kind==="primitive"?_v(e,t):null}function Lv(e){let t;for(let r of e){let n=Yt(r);n&&(t=oi(t,n))}return t}function RE(e,t){let r=new Map;for(let s of e){if(!s.parentId)continue;let c=r.get(s.parentId)??[];c.push(s),r.set(s.parentId,c)}let n=[],o=new Set,a=s=>{if(!o.has(s.id)){o.add(s.id),n.push(s);for(let c of r.get(s.id)??[])a(c)}},i=e.find(s=>s.id===t);i&&a(i);for(let s of e)a(s);return n}function CE(e,t){let r=t.prefab?.sourceAssetId;return e.find(n=>n.kind==="model"&&n.sourceAssetId===r)?.id??e.find(n=>n.kind==="model")?.id}function Yc(e){return Xe(e)&&e.prefab.compositionVersion===sn&&Array.isArray(e.prefab.nodes)&&e.prefab.nodes.length>0&&!!Ye(e)}function zv(e){return e.primitive??null}function vE(e,t){let r=Y(e);if(r!=="instance"&&r!=="transform"&&r!=="primitive")return;let n=ue(e),o=n?t.assets.find(a=>a.id===n.assetId):void 0;return Bv(e,t,o)}function Bv(e,t,r){let n=Yt(e.overrides),o=ln(t,e),a=Yt(o.definition?.prefab?.overrides);return oi(a,n)}function oi(e,t){let r=ss(e,t);for(let n of[e,t])if(n)for(let[o,a]of Object.entries(n))Vv(o)||a===void 0||(r??={},r[o]=structuredClone(a));return r&&Object.keys(r).length>0?r:void 0}function Yt(e){if(!Ue(e))return;let t=structuredClone(e);return Object.keys(t).length>0?t:void 0}function Vv(e){return e==="materialBinding"||e==="materialSlotBindings"}function Ue(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function yr(e){return(typeof e=="string"?e.trim():"")||void 0}function TE(e){return typeof e=="string"?e:void 0}function Uv(e){let t=structuredClone(e);return delete t.inspectorLanguage,t}function GE(e){return e.type==="directional"?Vn({schemaVersion:1,type:"directional",intensity:e.intensity,direction:Zo(e.direction),diffuseColor:e.diffuseColor??Fa.diffuseColor}):Vn({schemaVersion:1,type:"hemispheric",intensity:e.intensity,diffuseColor:e.diffuseColor??wn.diffuseColor,groundColor:e.groundColor??wn.groundColor})}var Kv=new Set(["leftToRight","rightToLeft","bottomToTop","topToBottom"]);function FE(e){let t=Fi(e),r={uiKind:e.uiKind,size:{width:e.size.width,depth:e.size.depth},layers:e.layers.map((n,o)=>Hv(n,o)),rendering:{textureWidth:t.width,textureHeight:t.height}};return e.aspectSourceLayerId&&(r.aspectSourceLayerId=e.aspectSourceLayerId),typeof e.lockAspectToBorder=="boolean"&&(r.lockAspectToBorder=e.lockAspectToBorder),e.mask&&(r.mask={...typeof e.mask.enabled=="boolean"?{enabled:e.mask.enabled}:{},...e.mask.source==="roundedRect"||e.mask.source==="borderAlpha"||e.mask.source==="texture"?{source:e.mask.source}:{},...e.mask.textureId?{textureId:e.mask.textureId}:{},...typeof e.mask.cornerRadius=="number"&&Number.isFinite(e.mask.cornerRadius)?{cornerRadius:e.mask.cornerRadius}:{},...typeof e.mask.padding=="number"&&Number.isFinite(e.mask.padding)?{padding:e.mask.padding}:{}}),e.rendering&&(r.rendering={...r.rendering,...typeof e.rendering.alphaIndex=="number"&&Number.isFinite(e.rendering.alphaIndex)?{alphaIndex:e.rendering.alphaIndex}:{},...typeof e.rendering.diffuseTextureLevel=="number"&&Number.isFinite(e.rendering.diffuseTextureLevel)?{diffuseTextureLevel:e.rendering.diffuseTextureLevel}:{},...typeof e.rendering.emissiveTextureLevel=="number"&&Number.isFinite(e.rendering.emissiveTextureLevel)?{emissiveTextureLevel:e.rendering.emissiveTextureLevel}:{}}),r}function Hv(e,t){let r=Mo(e.rotationDeg??0)??0,n={id:e.id,role:e.role,zOrder:typeof e.zOrder=="number"&&Number.isFinite(e.zOrder)?e.zOrder:t,rect:Wv(e.rect),...r!==0?{rotationDeg:r}:{},...typeof e.enabled=="boolean"?{enabled:e.enabled}:{},...typeof e.opacity=="number"&&Number.isFinite(e.opacity)?{opacity:e.opacity}:{}};return e.kind==="texture"?{...n,kind:"texture",...e.textureId?{textureId:e.textureId}:{},...e.tint?{tint:Go(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{}}:e.kind==="textureProgress"?{...n,kind:"textureProgress",...e.textureId?{textureId:e.textureId}:{},value:NE(e.value),...e.tint?{tint:Go(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{},...jE(e.direction)?{direction:e.direction}:{}}:e.kind==="color"?{...n,kind:"color",color:Go(e.color)}:e.kind==="progress"?{...n,kind:"progress",value:NE(e.value??0),color:Go(e.color),...jE(e.direction)?{direction:e.direction}:{}}:{...n,kind:"text",text:{value:e.text.value,color:Go(e.text.color),...e.text.fontFamily?{fontFamily:e.text.fontFamily}:{},...typeof e.text.fontSize=="number"&&Number.isFinite(e.text.fontSize)?{fontSize:e.text.fontSize}:{},...e.text.fontWeight!=null?{fontWeight:String(e.text.fontWeight)}:{},...e.text.strokeColor?{strokeColor:Go(e.text.strokeColor)}:{},...typeof e.text.strokeWidth=="number"&&Number.isFinite(e.text.strokeWidth)?{strokeWidth:e.text.strokeWidth}:{},...e.text.align==="left"||e.text.align==="center"||e.text.align==="right"?{align:e.text.align}:{},...e.text.baseline==="top"||e.text.baseline==="middle"||e.text.baseline==="bottom"?{baseline:e.text.baseline}:{}}}}function Wv(e){return{x:e.x,z:e.z,width:e.width,depth:e.depth}}function Go(e){return{r:e.r,g:e.g,b:e.b,...typeof e.a=="number"?{a:e.a}:{}}}function jE(e){return typeof e=="string"&&Kv.has(e)}function NE(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}async function _E(e,t){let r=String(e.method??"GET").toUpperCase();if(r==="OPTIONS")return Xc(204);try{if(r==="GET"){let c=Yv(await t.loadConfig?.()),d=c.renderingConfig;gt(d);let u=Ne(d);return Pe(200,{ok:!0,...c.response,renderingConfig:Xv(d),normalized:u,summary:Bn(u)})}if(r!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let n=e.body??await t.readBody?.(e)??{},o=ai(n.renderingConfig);if(!o)return Pe(400,{ok:!1,error:"missing_rendering_config"});gt(o);let a=Ne(o),i=Bn(a),s=await t.saveConfig?.({body:n,renderingConfig:o,normalized:a,summary:i});return Pe(200,{ok:!0,...s??{},renderingConfig:o,normalized:a,summary:i})}catch(n){let o=qv(n),a=Jv(n);return Pe(o?.startsWith("schema.")?400:500,{ok:!1,error:o??(n instanceof Error?n.message:String(n)),...a?{path:a}:{},details:ai(n?.details)})}}function qv(e){let t=e?.code;return typeof t=="string"&&t?t:null}function Jv(e){let t=e?.path;return typeof t=="string"&&t?t:null}function ai(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Xv(e){return ai(e)??{}}function Yv(e){let t=ai(e);return t&&Object.prototype.hasOwnProperty.call(t,"renderingConfig")?{renderingConfig:t.renderingConfig,response:ai(t.response)??{}}:{renderingConfig:e??{},response:{}}}function $E(e,t={}){let r=t.generatedBy??"scripts/register-asset.mjs",n=t.codeKeyPolicy??"legacy",o=e.filter(d=>d.codeKey);if(n==="disabled"&&o.length>0){let d=o[0];throw Object.assign(new Error("manifest_code_key_disabled"),{name:"PlayableEditorAssetCatalogGenerationError",details:{codeKeyPolicy:n,assetId:d.assetId,codeKey:d.codeKey}})}let a=e.map(d=>`import ${Kc(d.assetId)} from ${JSON.stringify(`${d.relativePath}?url`)};`).join(`
8
- `),i=e.map(d=>{let u=Nf(d.relativePath);if(!u)throw new Error(`Generated asset catalog entry has no file extension: ${d.assetId}`);if(!Ff(u))throw new Error(`Generated asset catalog entry has unsupported format: ${d.assetId} (${u})`);let l=[`guid: ${JSON.stringify(d.guid)}`,`assetId: ${JSON.stringify(d.assetId)}`,`kind: ${JSON.stringify(d.kind)}`,`displayName: ${JSON.stringify(d.displayName)}`,`url: ${Kc(d.assetId)}`,`format: ${JSON.stringify(u)}`,`relativePath: ${JSON.stringify(d.relativePath)}`,d.originalFileName?`originalFileName: ${JSON.stringify(d.originalFileName)}`:"",d.codeKey?`codeKey: ${JSON.stringify(d.codeKey)}`:"",d.category?`category: ${JSON.stringify(d.category)}`:"",typeof d.placeable=="boolean"?`placeable: ${JSON.stringify(d.placeable)}`:"",typeof d.warmupCount=="number"?`warmupCount: ${JSON.stringify(d.warmupCount)}`:"",typeof d.singleton=="boolean"?`singleton: ${JSON.stringify(d.singleton)}`:"",d.materialMode?`materialMode: ${JSON.stringify(d.materialMode)}`:"",d.defaults?`defaults: ${JSON.stringify(d.defaults)}`:"",d.contentHash?`contentHash: ${JSON.stringify(d.contentHash)}`:"",typeof d.byteSize=="number"?`byteSize: ${JSON.stringify(d.byteSize)}`:"",d.external?`external: ${JSON.stringify(d.external)}`:"",d.metadata?`metadata: ${JSON.stringify(d.metadata)}`:"",d.createdAt?`createdAt: ${JSON.stringify(d.createdAt)}`:"",d.updatedAt?`updatedAt: ${JSON.stringify(d.updatedAt)}`:""].filter(Boolean).join(", ");return` ${JSON.stringify(d.assetId)}: { ${l} },`}).join(`
1
+ import{EventEmitter as mP}from"node:events";var Uo="medium",sd={low:{opacity:.32,softness:.25,bias:.0015,normalBias:.02,maxDistance:24,resolution:512,cascadeCount:1,bakeSamples:8,blurKernel:2},medium:{opacity:.42,softness:.4,bias:.001,normalBias:.01,maxDistance:48,resolution:1024,cascadeCount:2,bakeSamples:24,blurKernel:4},high:{opacity:.5,softness:.58,bias:8e-4,normalBias:.006,maxDistance:80,resolution:2048,cascadeCount:4,bakeSamples:64,blurKernel:8},ultra:{opacity:.56,softness:.72,bias:6e-4,normalBias:.004,maxDistance:120,resolution:4096,cascadeCount:4,bakeSamples:128,blurKernel:12}};function yi(e=Uo,t={}){let r=sd[e]??sd[Uo];return{opacity:Vo(t.opacity,r.opacity),softness:Vo(t.softness,r.softness),bias:Vo(t.bias,r.bias),normalBias:Vo(t.normalBias,r.normalBias),maxDistance:Vo(t.maxDistance,r.maxDistance),resolution:hP(t.resolution,r.resolution),cascadeCount:EP(t.cascadeCount,r.cascadeCount),bakeSamples:SP(t.bakeSamples,r.bakeSamples),blurKernel:yP(t.blurKernel,r.blurKernel)}}function Vo(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function SP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):t}function yP(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.round(e):t}function hP(e,t){return e===512||e===1024||e===2048||e===4096?e:t}function EP(e,t){return e===1||e===2||e===4?e:t}function hi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ei(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function Ii(e){return e==="inherit"||e==="none"||e==="enabled"||e==="auto"}function Pi(e){return e==="inherit"||e==="none"||e==="dynamic"||e==="static"||e==="blob"||e==="projected"||e==="auto"}function Ti(e){return e==="inherit"||e==="low"||e==="medium"||e==="high"||e==="ultra"}function xi(e){return e==="inherit"||e==="scene-main"||e==="nearest"||e==="explicit"}function hf(e){let t=hi(e);if(!t)return;let r={};Ei(t.cast)&&(r.cast=t.cast),Ii(t.receive)&&(r.receive=t.receive),Pi(t.mode)&&(r.mode=t.mode),Ti(t.quality)&&(r.quality=t.quality);let n=hi(t.light);if(n){let a={};xi(n.mode)&&(a.mode=n.mode),typeof n.lightId=="string"&&n.lightId.trim()&&(a.lightId=n.lightId.trim()),Object.keys(a).length>0&&(r.light=a)}let o=IP(t.params);return o&&(r.params=o),Object.keys(r).length>0?r:void 0}function He(e){let t=hf(e);return t?{shadow:t,diagnostics:[]}:{diagnostics:[]}}function cd(e,t="none"){let r=e?.mode;return!r||r==="inherit"||r==="auto"?t:r}function dd(e,t=Uo){let r=e?.quality;return r&&r!=="inherit"?r:t}function IP(e){let t=hi(e);if(!t)return;let r={};return typeof t.opacity=="number"&&Number.isFinite(t.opacity)&&(r.opacity=t.opacity),typeof t.softness=="number"&&Number.isFinite(t.softness)&&(r.softness=t.softness),typeof t.bias=="number"&&Number.isFinite(t.bias)&&(r.bias=t.bias),typeof t.normalBias=="number"&&Number.isFinite(t.normalBias)&&(r.normalBias=t.normalBias),typeof t.maxDistance=="number"&&Number.isFinite(t.maxDistance)&&(r.maxDistance=t.maxDistance),(t.resolution===512||t.resolution===1024||t.resolution===2048||t.resolution===4096)&&(r.resolution=t.resolution),(t.cascadeCount===1||t.cascadeCount===2||t.cascadeCount===4)&&(r.cascadeCount=t.cascadeCount),typeof t.bakeSamples=="number"&&Number.isFinite(t.bakeSamples)&&(r.bakeSamples=t.bakeSamples),typeof t.blurKernel=="number"&&Number.isFinite(t.blurKernel)&&(r.blurKernel=t.blurKernel),Object.keys(r).length>0?r:void 0}var PP=new Set(["cast","receive","mode","quality","light","params"]),TP=new Set(["mode","lightId"]),xP=new Set(["opacity","softness","bias","normalBias","maxDistance","resolution","cascadeCount","bakeSamples","blurKernel"]);function Ko(e,t="$.shadow"){let r=ud(e);if(!r)throw ve("schema.invalidType",t);if(ld(r,PP,t),"cast"in r&&!Ei(r.cast))throw ve("schema.invalidValue",`${t}.cast`);if("receive"in r&&!Ii(r.receive))throw ve("schema.invalidValue",`${t}.receive`);if("mode"in r&&!Pi(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("quality"in r&&!Ti(r.quality))throw ve("schema.invalidValue",`${t}.quality`);"light"in r&&AP(r.light,`${t}.light`),"params"in r&&DP(r.params,`${t}.params`)}function AP(e,t){let r=ud(e);if(!r)throw ve("schema.invalidType",t);if(ld(r,TP,t),"mode"in r&&!xi(r.mode))throw ve("schema.invalidValue",`${t}.mode`);if("lightId"in r&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`);if(r.mode==="explicit"&&(typeof r.lightId!="string"||!r.lightId.trim()))throw ve("schema.invalidValue",`${t}.lightId`)}function DP(e,t){let r=ud(e);if(!r)throw ve("schema.invalidType",t);if(ld(r,xP,t),Wr(r,"opacity",t,n=>n>=0&&n<=1),Wr(r,"softness",t,n=>n>=0),Wr(r,"bias",t,()=>!0),Wr(r,"normalBias",t,()=>!0),Wr(r,"maxDistance",t,n=>n>0),Wr(r,"bakeSamples",t,n=>n>0),Wr(r,"blurKernel",t,n=>n>=0),"resolution"in r&&![512,1024,2048,4096].includes(r.resolution))throw ve("schema.invalidValue",`${t}.resolution`);if("cascadeCount"in r&&![1,2,4].includes(r.cascadeCount))throw ve("schema.invalidValue",`${t}.cascadeCount`)}function Wr(e,t,r,n){if(!(t in e))return;let o=e[t];if(typeof o!="number"||!Number.isFinite(o)||!n(o))throw ve("schema.invalidValue",`${r}.${t}`)}function ld(e,t,r){for(let n of Object.keys(e))if(!t.has(n))throw ve("schema.deprecatedField",`${r}.${n}`)}function ve(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function ud(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var gd="fps.shadow-map-experiment";function MP(e,t="$.scene.shadowMapExperiment"){let r=ft(e,t);Gt(r,["qualityProfile","behaviorProfile"],t),r.qualityProfile!==void 0&&vt(r.qualityProfile,`${t}.qualityProfile`),r.behaviorProfile!==void 0&&vt(r.behaviorProfile,`${t}.behaviorProfile`)}function wP(e,t="$.shadowMapExperiment"){let r=ft(e,t);Gt(r,["behaviorProfile"],t),vt(r.behaviorProfile,`${t}.behaviorProfile`)}function Di(e,t="$"){let r=ft(e,t);Gt(r,["schemaVersion","enabled","lightRef","defaultQualityProfile","defaultBehaviorProfile","qualityProfiles","behaviorProfiles"],t),r.schemaVersion!==1&&H(`${t}.schemaVersion`,"expected 1"),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),vt(r.lightRef,`${t}.lightRef`);let n=vt(r.defaultQualityProfile,`${t}.defaultQualityProfile`),o=vt(r.defaultBehaviorProfile,`${t}.defaultBehaviorProfile`),a=If(r.qualityProfiles,`${t}.qualityProfiles`),i=If(r.behaviorProfiles,`${t}.behaviorProfiles`);for(let[s,c]of Object.entries(a))OP(c,`${t}.qualityProfiles.${s}`);for(let[s,c]of Object.entries(i))RP(c,`${t}.behaviorProfiles.${s}`);Object.prototype.hasOwnProperty.call(a,n)||H(`${t}.defaultQualityProfile`,`unknown quality profile: ${n}`),Object.prototype.hasOwnProperty.call(i,o)||H(`${t}.defaultBehaviorProfile`,`unknown behavior profile: ${o}`)}function Pf(e){Di(e.config),e.settings!==void 0&&MP(e.settings),(!Number.isInteger(e.revision)||e.revision<0)&&H("$.revision","expected a non-negative integer");let t=e.settings?.qualityProfile??e.config.defaultQualityProfile,r=e.settings?.behaviorProfile??e.config.defaultBehaviorProfile,n=fd(e.config.qualityProfiles,t,"$.settings.qualityProfile","quality");fd(e.config.behaviorProfiles,r,"$.settings.behaviorProfile","behavior");let o=e.objects.map((s,c)=>{let d=`$.objects[${c}]`;s.override!==void 0&&wP(s.override,`${d}.override`);let u=s.override?.behaviorProfile??r,l=fd(e.config.behaviorProfiles,u,`${d}.override.behaviorProfile`,"behavior");return Object.freeze({entityId:vt(s.entityId,`${d}.entityId`),renderableIds:Object.freeze($P(s.renderableIds,`${d}.renderableIds`)),cast:Ef(s.cast,`${d}.cast`)??l.cast==="enabled",receive:Ef(s.receive,`${d}.receive`)??l.receive==="enabled",updateClass:l.updateClass!=="auto"?l.updateClass:s.inferredUpdateClass??"static",behaviorProfileId:u})}).sort((s,c)=>s.entityId.localeCompare(c.entityId)),a=e.config.enabled?o:[];FP(a);let i=Object.fromEntries(Object.entries(e.config.behaviorProfiles).sort(([s],[c])=>s.localeCompare(c)).map(([s,c])=>[s,Object.freeze({cast:c.cast==="enabled",receive:c.receive==="enabled",updateClass:c.updateClass})]));return Tf({schemaVersion:3,revision:e.revision,enabled:e.config.enabled,scopeId:vt(e.scopeId,"$.scopeId"),light:{entityId:e.config.lightRef,direction:Wo(e.lightDirection,"$.lightDirection")},qualityProfileId:t,generator:{maps:{...n.maps},...n.cascadeCount===void 0?{}:{cascadeCount:n.cascadeCount},filter:n.receiverFilter,bias:n.bias,normalBias:n.normalBias,darkness:n.darkness,...n.softness===void 0?{}:{softness:n.softness},bounds:_P(n.bounds),backend:{...n.backend}},culling:{...n.culling},diagnosticThresholds:{...n.diagnostics},behaviorProfiles:i,objects:a,diagnostics:[]})}function Ef(e,t){if(e!==void 0)return typeof e!="boolean"&&H(t,"expected a boolean"),e}function kP(e,t){let r=ft(e,t);Gt(r,["mode","center","extent","near","far"],t),r.mode!=="fixed"&&H(`${t}.mode`,"expected fixed"),Wo(r.center,`${t}.center`),Wo(r.extent,`${t}.extent`).some(i=>i<=0)&&H(`${t}.extent`,"expected positive values");let o=Ai(r.near,`${t}.near`),a=Ai(r.far,`${t}.far`);(o<0||a<=o)&&H(t,"expected 0 <= near < far")}function OP(e,t){let r=ft(e,t);Gt(r,["maps","cascadeCount","receiverFilter","bias","normalBias","darkness","softness","bounds","backend","culling","diagnostics"],t),CP(r.maps,`${t}.maps`),r.cascadeCount!==void 0&&vP(r.cascadeCount,`${t}.cascadeCount`),r.receiverFilter!=="hard"&&r.receiverFilter!=="low-pcf"&&H(`${t}.receiverFilter`,"expected hard or low-pcf"),Ho(r.bias,`${t}.bias`,0,.1),Ho(r.normalBias,`${t}.normalBias`,0,1),Ho(r.darkness,`${t}.darkness`,0,1),r.softness!==void 0&&Ho(r.softness,`${t}.softness`,0,1),kP(r.bounds,`${t}.bounds`),GP(r.backend,`${t}.backend`),jP(r.culling,`${t}.culling`),NP(r.diagnostics,`${t}.diagnostics`)}function RP(e,t){let r=ft(e,t);Gt(r,["cast","receive","updateClass"],t),r.cast!=="enabled"&&r.cast!=="disabled"&&H(`${t}.cast`,"expected enabled or disabled"),r.receive!=="enabled"&&r.receive!=="disabled"&&H(`${t}.receive`,"expected enabled or disabled"),["auto","static","dynamic","skinned"].includes(String(r.updateClass))||H(`${t}.updateClass`,"expected auto, static, dynamic, or skinned")}function CP(e,t){let r=ft(e,t);Gt(r,["staticResolution","dynamicResolution","compositeResolution"],t),md(r.staticResolution,`${t}.staticResolution`),md(r.dynamicResolution,`${t}.dynamicResolution`),md(r.compositeResolution,`${t}.compositeResolution`)}function md(e,t){e!==512&&e!==1024&&e!==2048&&e!==4096&&H(t,"expected 512, 1024, 2048, or 4096")}function vP(e,t){e!==1&&e!==2&&e!==4&&H(t,"expected 1, 2, or 4")}function GP(e,t){let r=ft(e,t);Gt(r,["mode","fallback"],t),["auto","split","single"].includes(String(r.mode))||H(`${t}.mode`,"expected auto, split, or single"),r.fallback!=="single-map"&&r.fallback!=="disable"&&H(`${t}.fallback`,"expected single-map or disable")}function jP(e,t){let r=ft(e,t);Gt(r,["enabled","guardBandRatio"],t),typeof r.enabled!="boolean"&&H(`${t}.enabled`,"expected boolean"),Ho(r.guardBandRatio,`${t}.guardBandRatio`,0,4)}function NP(e,t){let r=ft(e,t);Gt(r,["staticCasterCountWarning","dynamicCasterCountWarning","renderableCountWarning"],t),pd(r.staticCasterCountWarning,`${t}.staticCasterCountWarning`),pd(r.dynamicCasterCountWarning,`${t}.dynamicCasterCountWarning`),pd(r.renderableCountWarning,`${t}.renderableCountWarning`)}function FP(e){let t=new Set,r=new Set;for(let n of e){t.has(n.entityId)&&H("$.objects",`duplicate entity id: ${n.entityId}`),t.add(n.entityId);for(let o of n.renderableIds)r.has(o)&&H("$.objects",`duplicate renderable id: ${o}`),r.add(o)}}function If(e,t){let r=ft(e,t);Object.keys(r).length===0&&H(t,"expected at least one profile");for(let n of Object.keys(r))vt(n,`${t} key`);return r}function fd(e,t,r,n){return Object.prototype.hasOwnProperty.call(e,t)||H(r,`unknown ${n} profile: ${t}`),e[t]}function _P(e){return Object.freeze({mode:"fixed",center:Wo(e.center,"$.bounds.center"),extent:Wo(e.extent,"$.bounds.extent"),near:e.near,far:e.far})}function Wo(e,t){let r=LP(e,t);return r.length!==3&&H(t,"expected exactly three numbers"),Object.freeze(r.map((n,o)=>Ai(n,`${t}[${o}]`)))}function $P(e,t){let r=e.map((n,o)=>vt(n,`${t}[${o}]`));return new Set(r).size!==r.length&&H(t,"expected unique strings"),r}function Ai(e,t){return(typeof e!="number"||!Number.isFinite(e))&&H(t,"expected a finite number"),e}function Ho(e,t,r,n){let o=Ai(e,t);return(o<r||o>n)&&H(t,`expected ${r}..${n}`),o}function pd(e,t){return(!Number.isInteger(e)||e<0)&&H(t,"expected a non-negative integer"),e}function vt(e,t){return(typeof e!="string"||!e.trim()||e!==e.trim())&&H(t,"expected a trimmed non-empty string"),e}function ft(e,t){(!e||typeof e!="object"||Array.isArray(e))&&H(t,"expected an object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&H(t,"expected a plain object"),e}function LP(e,t){return Array.isArray(e)||H(t,"expected an array"),e}function Gt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||H(`${r}.${o}`,"unknown field")}function Tf(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))Tf(t);return Object.freeze(e)}function H(e,t){throw new Error(`shadow_map_experiment_invalid:${e}:${t}`)}var xf=["useBlobShadow","blobSettings"],zP=["resolution","maxSize"],BP=new Set(["none","blob","static","planar","dynamic"]);function gt(e){let t=qr(e);if(!t)throw X("schema.invalidType","$");for(let o of xf)if(Object.prototype.hasOwnProperty.call(t,o))throw X("schema.deprecatedField",`$.${o}`);if(q(t,["globalVolume","materials","renderingGroups","shadowMeshes","shadows"],"$"),KP(t.globalVolume,"$.globalVolume"),HP(t.materials,"$.materials"),VP(t.renderingGroups,"$.renderingGroups"),UP(t.globalVolume,"$.globalVolume"),ZP(t.shadowMeshes,"$.shadowMeshes"),!Object.prototype.hasOwnProperty.call(t,"shadows"))return;let r=qr(t.shadows);if(!r)throw X("schema.invalidType","$.shadows");for(let o of xf)if(Object.prototype.hasOwnProperty.call(r,o))throw X("schema.deprecatedField",`$.shadows.${o}`);if(q(r,["defaultMode","enabled","useCsm","settings","blob","staticProjected","planar","shadowRange","shadowOrtho","csm"],"$.shadows"),"defaultMode"in r&&!BP.has(String(r.defaultMode)))throw X("schema.invalidValue","$.shadows.defaultMode");Ge(r,"enabled","$.shadows"),Ge(r,"useCsm","$.shadows");let n=qr(r.settings);if(Object.prototype.hasOwnProperty.call(r,"settings")&&!n)throw X("schema.invalidType","$.shadows.settings");if(n){q(n,["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ","useBlurExponentialShadowMap","shadowColor"],"$.shadows.settings");for(let o of["mapSize","darkness","blurKernel","bias","normalBias","shadowMinZ","shadowMaxZ"])Ae(n,o,"$.shadows.settings");Ge(n,"useBlurExponentialShadowMap","$.shadows.settings"),Mi(n.shadowColor,"$.shadows.settings.shadowColor",!1)}qP(r.blob,"$.shadows.blob"),JP(r.staticProjected,"$.shadows.staticProjected"),XP(r.planar,"$.shadows.planar"),Jr(r.shadowRange,"$.shadows.shadowRange",["minZ","maxZ"]),Jr(r.shadowOrtho,"$.shadows.shadowOrtho",["left","right","top","bottom"]),YP(r.csm,"$.shadows.csm")}function VP(e,t){if(e===void 0)return;let r=qr(e);if(!r||!Array.isArray(r.slots))throw X("schema.invalidType",t);q(r,["slots"],t),r.slots.forEach((n,o)=>{let a=`${t}.slots[${o}]`,i=qr(n);if(!i)throw X("schema.invalidType",a);if(q(i,["renderingGroupId","name","alphaIndexPresets"],a),![0,1,2,3].includes(i.renderingGroupId))throw X("schema.invalidValue",`${a}.renderingGroupId`);if(typeof i.name!="string"||!i.name.trim())throw X("schema.invalidValue",`${a}.name`);if(!Array.isArray(i.alphaIndexPresets))throw X("schema.invalidType",`${a}.alphaIndexPresets`);i.alphaIndexPresets.forEach((s,c)=>{let d=`${a}.alphaIndexPresets[${c}]`,u=qr(s);if(!u)throw X("schema.invalidType",d);if(q(u,["name","alphaIndex"],d),typeof u.name!="string"||!u.name.trim())throw X("schema.invalidValue",`${d}.name`);Sd(u,"alphaIndex",d)})})}function UP(e,t){if(e===void 0)return;let r=be(e,t);for(let a of["samples","camera","lights"])if(a in r)throw X("schema.deprecatedField",`${t}.${a}`);if(q(r,["enabled","hdr","environment","imageProcessing","toneMapping","antialiasing","postProcessing","rendering","textures"],t),Ge(r,"enabled",t),Ge(r,"hdr",t),r.environment!==void 0){let a=be(r.environment,`${t}.environment`);for(let i of["textureAssetId","textureUrl","intensity"])if(i in a)throw X("schema.deprecatedField",`${t}.environment.${i}`);if(q(a,["texture","iblIntensity","rotationY","useCocosIBL"],`${t}.environment`),a.texture!==void 0&&a.texture!==null){let i=be(a.texture,`${t}.environment.texture`);for(let s of Object.keys(i))if(s!=="textureAssetId"&&s!=="url")throw X("schema.deprecatedField",`${t}.environment.texture.${s}`);for(let s of["textureAssetId","url"])if(s in i&&i[s]!=null&&(typeof i[s]!="string"||!i[s].trim()))throw X("schema.invalidValue",`${t}.environment.texture.${s}`)}Ae(a,"iblIntensity",`${t}.environment`),Ae(a,"rotationY",`${t}.environment`),Ge(a,"useCocosIBL",`${t}.environment`)}if(Jr(r.imageProcessing,`${t}.imageProcessing`,["exposure","contrast"]),r.toneMapping!==void 0){let a=be(r.toneMapping,`${t}.toneMapping`);if(q(a,["enabled","type"],`${t}.toneMapping`),Ge(a,"enabled",`${t}.toneMapping`),"type"in a&&!["standard","aces","khr-pbr-neutral"].includes(String(a.type)))throw X("schema.invalidValue",`${t}.toneMapping.type`)}if(r.antialiasing!==void 0){let a=be(r.antialiasing,`${t}.antialiasing`);if(q(a,["samples"],`${t}.antialiasing`),"samples"in a&&![1,2,4,8].includes(a.samples))throw X("schema.invalidValue",`${t}.antialiasing.samples`)}let n=pt(r.postProcessing,`${t}.postProcessing`);n&&q(n,["bloom"],`${t}.postProcessing`);let o=n?pt(n.bloom,`${t}.postProcessing.bloom`):null;if(o){q(o,["enabled","threshold","weight","kernel","scale"],`${t}.postProcessing.bloom`),Ge(o,"enabled",`${t}.postProcessing.bloom`);for(let a of["threshold","weight","kernel","scale"])Ae(o,a,`${t}.postProcessing.bloom`)}}function KP(e,t){if(e===void 0)return;let r=be(e,t),n=pt(r.rendering,`${t}.rendering`);n&&(q(n,["maxDpr","hardwareScalingLevel"],`${t}.rendering`),Ae(n,"maxDpr",`${t}.rendering`),WP(n,"hardwareScalingLevel",`${t}.rendering`));let o=pt(r.textures,`${t}.textures`);if(o&&(q(o,["anisotropicFilteringLevel","samplingMode"],`${t}.textures`),Ae(o,"anisotropicFilteringLevel",`${t}.textures`),"samplingMode"in o&&(typeof o.samplingMode!="string"||!o.samplingMode.trim())))throw X("schema.invalidValue",`${t}.textures.samplingMode`)}function HP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["sceneMaterials","plantMaterials"],t);for(let n of["sceneMaterials","plantMaterials"])n in r&&be(r[n],`${t}.${n}`)}function WP(e,t,r){!(t in e)||e[t]==null||Ae(e,t,r)}function qP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["enabled","plane","appearance","size"],t),Ge(r,"enabled",t),Jr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);n&&(q(n,["color","edgeSoftness"],`${t}.appearance`),Mi(n.color,`${t}.appearance.color`,!0),Ae(n,"edgeSoftness",`${t}.appearance`)),Jr(r.size,`${t}.size`,["sizeMultiplier","minSize","maxSize"])}function JP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["enabled","plane","appearance","bake"],t),Ge(r,"enabled",t),Jr(r.plane,`${t}.plane`,["height","yOffset"]);let n=pt(r.appearance,`${t}.appearance`);if(n&&(q(n,["color"],`${t}.appearance`),Mi(n.color,`${t}.appearance.color`,!0)),r.bake===void 0)return;let o=be(r.bake,`${t}.bake`);for(let a of zP)if(a in o)throw X("schema.deprecatedField",`${t}.bake.${a}`);q(o,["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"],`${t}.bake`);for(let a of["padding","blur","texelsPerMeter","atlasSize","maxAtlasPages","sdfRadiusPx","spatialChunkSize","targetChunkCount"])Ae(o,a,`${t}.bake`)}function XP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["enabled","plane","appearance","projection","stencil","casters","receivers"],t),Ge(r,"enabled",t);let n=pt(r.plane,`${t}.plane`);if(n){q(n,["normal","height","bias","heightMode"],`${t}.plane`),QP(n.normal,`${t}.plane.normal`);for(let c of["height","bias"])Ae(n,c,`${t}.plane`);if("heightMode"in n&&!["fixed","receiver"].includes(String(n.heightMode)))throw X("schema.invalidValue",`${t}.plane.heightMode`)}let o=pt(r.appearance,`${t}.appearance`);o&&(q(o,["color"],`${t}.appearance`),Mi(o.color,`${t}.appearance.color`,!0)),Jr(r.projection,`${t}.projection`,["footprintScale"]);let a=pt(r.stencil,`${t}.stencil`);if(a){q(a,["enabled","receiverRenderingGroup","shadowRenderingGroup"],`${t}.stencil`),Ge(a,"enabled",`${t}.stencil`);for(let c of["receiverRenderingGroup","shadowRenderingGroup"])Ae(a,c,`${t}.stencil`)}let i=pt(r.casters,`${t}.casters`);if(i){q(i,["autoDetectAll","includePatterns","excludePatterns","rootBoundaryPatterns","minVolume"],`${t}.casters`),Ge(i,"autoDetectAll",`${t}.casters`);for(let c of["includePatterns","excludePatterns","rootBoundaryPatterns"])bd(i[c],`${t}.casters.${c}`);Ae(i,"minVolume",`${t}.casters`)}let s=pt(r.receivers,`${t}.receivers`);s&&(q(s,["patterns"],`${t}.receivers`),bd(s.patterns,`${t}.receivers.patterns`))}function YP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["numCascades","lambda","cascadeBlendPercentage","stabilizeCascades"],t);for(let n of["numCascades","lambda","cascadeBlendPercentage"])Ae(r,n,t);Ge(r,"stabilizeCascades",t)}function ZP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["shadowReceivers","shadowCasters","excludeFromShadow"],t);for(let n of["shadowReceivers","shadowCasters","excludeFromShadow"])bd(r[n],`${t}.${n}`)}function Jr(e,t,r){if(e===void 0)return;let n=be(e,t);q(n,r,t);for(let o of r)Ae(n,o,t)}function Mi(e,t,r){if(e===void 0)return;let n=be(e,t),o=r?["r","g","b","a"]:["r","g","b"];q(n,o,t);for(let a of o)Sd(n,a,t)}function QP(e,t){if(e===void 0)return;let r=be(e,t);q(r,["x","y","z"],t);for(let n of["x","y","z"])Sd(r,n,t)}function bd(e,t){if(e!==void 0&&(!Array.isArray(e)||e.some(r=>typeof r!="string")))throw X("schema.invalidType",t)}function Sd(e,t,r){if(!(t in e))throw X("schema.invalidValue",`${r}.${t}`);Ae(e,t,r)}function pt(e,t){return e===void 0?null:be(e,t)}function be(e,t){let r=qr(e);if(!r)throw X("schema.invalidType",t);return r}function Ge(e,t,r){if(t in e&&typeof e[t]!="boolean")throw X("schema.invalidValue",`${r}.${t}`)}function Ae(e,t,r){if(!(t in e))return;let n=e[t];if(typeof n!="number"||!Number.isFinite(n))throw X("schema.invalidValue",`${r}.${t}`)}function q(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw X("schema.unknownField",`${r}.${o}`)}function X(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function qr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function L(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Af(e,t){let r=L(e);return{x:Se(r.x,t.x),y:Se(r.y,t.y),z:Se(r.z,t.z)}}function yd(e,t){let r=L(e);return{r:rr(r.r,t.r,0,1),g:rr(r.g,t.g,0,1),b:rr(r.b,t.b,0,1)}}function qo(e,t){let r=L(e);return{...yd(r,t),a:rr(r.a,t.a,0,1)}}function Pr(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t.trim():"").filter((t,r,n)=>t.length>0&&n.indexOf(t)===r):[]}function hd(e){return(typeof e=="string"?e.trim():"")||null}function Ed(e,t){return(typeof e=="string"?e.trim():"")||t}function je(e,t){return typeof e=="boolean"?e:t}function Df(e){return e===0||e===1||e===2||e===3?e:null}function Mf(e,t){return e==="standard"||e==="aces"||e==="khr-pbr-neutral"?e:t}function wf(e,t){return e===1||e===2||e===4||e===8?e:t}function kf(e,t){return e==="fixed"||e==="receiver"?e:t}function Of(e,t){return e==="none"||e==="blob"||e==="static"||e==="planar"||e==="dynamic"?e:t}function Se(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Q(e,t){let r=Se(e,t);return Math.max(0,r)}function Tr(e,t){let r=Se(e,t);return r>0?r:t}function rr(e,t,r,n){let o=Se(e,t);return Math.min(n,Math.max(r,o))}var Rf=["editor","grid","gizmo","helper","camera","light","decal","texture","trigger","collision","ui","_shadow","_planarShadow"],Cf=[...Rf,"_blobShadow"],eT=[...Cf,"_staticProjectedShadow"];var vf=[{renderingGroupId:0,name:"\u666E\u901A\u573A\u666F",alphaIndexPresets:[{name:"\u9ED8\u8BA4\u900F\u660E\u987A\u5E8F",alphaIndex:0},{name:"\u5730\u8868\u8D34\u82B1",alphaIndex:100},{name:"\u8FD1\u666F\u8986\u76D6",alphaIndex:200}]},{renderingGroupId:1,name:"\u6C34\u9762 / \u900F\u660E\u5730\u8868",alphaIndexPresets:[{name:"\u6C34\u9762",alphaIndex:0},{name:"\u900F\u660E\u5730\u8868",alphaIndex:100},{name:"\u6C34\u9762\u9AD8\u5149",alphaIndex:200}]},{renderingGroupId:2,name:"\u7279\u6548",alphaIndexPresets:[{name:"\u666E\u901A\u7279\u6548",alphaIndex:0},{name:"\u524D\u666F\u7279\u6548",alphaIndex:100},{name:"\u6700\u524D\u7279\u6548",alphaIndex:200}]},{renderingGroupId:3,name:"\u4E16\u754C\u7A7A\u95F4 UI / \u5F15\u5BFC\u7BAD\u5934",alphaIndexPresets:[{name:"\u4E16\u754C\u7A7A\u95F4 UI",alphaIndex:0},{name:"\u5F15\u5BFC\u7BAD\u5934",alphaIndex:100},{name:"\u9876\u5C42\u63D0\u793A",alphaIndex:200}]}];function Ne(e){e!=null&&gt(e);let t=L(e),r=L(t.shadows),n=L(r.settings),o=L(r.blob),a=tT(o),i=nT(r.staticProjected),s=L(r.shadowRange),c=L(r.shadowOrtho),d=L(r.csm),u=L(t.shadowMeshes);return{renderingGroups:Gf(t.renderingGroups),environment:oT(t.globalVolume),postProcess:aT(t.globalVolume),shadows:{defaultMode:Of(r.defaultMode,"none"),enabled:je(r.enabled,!1),useCsm:je(r.useCsm,!1),settings:{mapSize:Q(n.mapSize,1024),darkness:Q(n.darkness,.3),blurKernel:Q(n.blurKernel,16),bias:Q(n.bias,5e-5),normalBias:Q(n.normalBias,.02),useBlurExponentialShadowMap:je(n.useBlurExponentialShadowMap,!0),shadowMinZ:Q(n.shadowMinZ,1),shadowMaxZ:Q(n.shadowMaxZ,60),shadowColor:yd(n.shadowColor,{r:0,g:0,b:0})},blob:a,staticProjected:i,shadowRange:{minZ:Q(s.minZ,1),maxZ:Q(s.maxZ,60)},shadowOrtho:{left:Se(c.left,-20),right:Se(c.right,20),top:Se(c.top,20),bottom:Se(c.bottom,-20)},csm:{numCascades:Q(d.numCascades,2),lambda:rr(d.lambda,.5,0,1),cascadeBlendPercentage:rr(d.cascadeBlendPercentage,.1,0,1),stabilizeCascades:je(d.stabilizeCascades,!0)},planar:rT(r.planar)},shadowMeshes:{shadowReceivers:Pr(u.shadowReceivers),shadowCasters:Pr(u.shadowCasters),excludeFromShadow:Pr(u.excludeFromShadow)}}}function Bn(e){let t=e?.environment?.texture!=null;return{environmentTextureAssetId:e?.environment?.texture?.textureAssetId??null,environmentTextureUrl:e?.environment?.texture?.url??null,environmentIblIntensity:t?e?.environment?.iblIntensity??null:null,postProcessEnabled:e?.postProcess?.enabled??null,postProcessExposure:e?.postProcess?.imageProcessing?.exposure??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??null,blobEnabled:e?.shadows?.blob?.enabled??null,blobOpacity:e?.shadows?.blob?.appearance?.color?.a??null,staticProjectedEnabled:e?.shadows?.staticProjected?.enabled??null,staticProjectedOpacity:e?.shadows?.staticProjected?.appearance?.color?.a??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}function tT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.size),a=qo(n.color,{r:0,g:0,b:0,a:.35});return{enabled:je(t.enabled,!0),plane:{height:Se(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:qo(n.color,a),edgeSoftness:rr(n.edgeSoftness,.55,0,.98)},size:{sizeMultiplier:Q(o.sizeMultiplier,1.25),minSize:Q(o.minSize,.25),maxSize:Tr(o.maxSize,20)}}}function Gf(e){let t=L(e),r=Array.isArray(t.slots)?t.slots:[];return{slots:vf.map(n=>{let o=r.find(i=>Df(L(i).renderingGroupId)===n.renderingGroupId),a=L(o);return{renderingGroupId:n.renderingGroupId,name:Ed(a.name,n.name),alphaIndexPresets:jf(a.alphaIndexPresets,n.alphaIndexPresets)}})}}function jf(e,t){let r=Array.isArray(e)?e:t,n=new Set,o=[];return r.forEach((a,i)=>{let s=L(a),c=Se(s.alphaIndex,Number.NaN);!Number.isFinite(c)||n.has(c)||(n.add(c),o.push({name:Ed(s.name,`Order ${i+1}`),alphaIndex:c}))}),o}function rT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.projection),a=L(t.stencil),i=L(t.casters),s=L(t.receivers);return{enabled:je(t.enabled,!0),plane:{normal:Af(r.normal,{x:0,y:1,z:0}),height:Se(r.height,0),heightMode:kf(r.heightMode,"receiver"),bias:Q(r.bias,.4)},appearance:{color:qo(n.color,{r:0,g:0,b:0,a:.35})},projection:{footprintScale:rr(o.footprintScale,1,0,2)},stencil:{enabled:je(a.enabled,!0),receiverRenderingGroup:Q(a.receiverRenderingGroup,0),shadowRenderingGroup:Q(a.shadowRenderingGroup,1)},casters:{autoDetectAll:je(i.autoDetectAll,!0),includePatterns:Pr(i.includePatterns),excludePatterns:Pr(i.excludePatterns),rootBoundaryPatterns:Pr(i.rootBoundaryPatterns),minVolume:Q(i.minVolume,.001)},receivers:{patterns:Pr(s.patterns)}}}function nT(e){let t=L(e),r=L(t.plane),n=L(t.appearance),o=L(t.bake),a=Tr(o.spatialChunkSize,16);return{enabled:je(t.enabled,!1),plane:{height:Se(r.height,0),yOffset:Q(r.yOffset,.08)},appearance:{color:qo(n.color,{r:0,g:0,b:0,a:.35})},bake:{padding:Q(o.padding,.15),blur:Q(o.blur,0),texelsPerMeter:Tr(o.texelsPerMeter,256),atlasSize:Tr(o.atlasSize,4096),maxAtlasPages:Tr(o.maxAtlasPages,8),sdfRadiusPx:Q(o.sdfRadiusPx,8),spatialChunkSize:a,targetChunkCount:Tr(o.targetChunkCount,64)}}}function oT(e){let t=L(e),r=L(t.environment),n=L(r.texture),o=hd(n.textureAssetId),a=hd(n.url);return{texture:o||a?{...o?{textureAssetId:o}:{},...a?{url:a}:{}}:null,iblIntensity:Q(r.iblIntensity,1),rotationY:Se(r.rotationY,0)}}function aT(e){let t=L(e),r=L(t.imageProcessing),n=L(t.toneMapping),o=L(t.antialiasing),a=L(t.postProcessing),i=L(a.bloom);return{enabled:je(t.enabled,!0),hdr:je(t.hdr,!0),imageProcessing:{exposure:Se(r.exposure,1),contrast:Se(r.contrast,1)},toneMapping:{enabled:je(n.enabled,!0),type:Mf(n.type,"aces")},antialiasing:{samples:wf(o.samples,4)},bloom:{enabled:je(i.enabled,!1),threshold:Q(i.threshold,.9),weight:Q(i.weight,.2),kernel:Q(i.kernel,64),scale:Tr(i.scale,.5)}}}var wi=class extends Error{path;reason;code="runtime.lighting.invalid";constructor(t,r){super(`Invalid Runtime Lighting data at ${t}: ${r}`),this.path=t,this.reason=r,this.name="FpsRuntimeLightingDataError"}},Nf=1e-6,iT=1e-4,sT=new Set(["schemaVersion","type","intensity","direction","diffuseColor"]),cT=new Set(["schemaVersion","type","intensity","diffuseColor","groundColor"]),dT=new Set(["x","y","z"]),lT=new Set(["r","g","b"]);function Xo(e,t="$.direction"){let r=Ff(e,t),n=Math.hypot(r.x,r.y,r.z);return n<=Nf&&bt(t,"expected a non-zero direction vector"),Object.freeze({x:r.x/n,y:r.y/n,z:r.z/n})}function Vn(e,t="$.light"){let r=Td(e,t);r.schemaVersion!==1&&bt(`${t}.schemaVersion`,"expected 1");let n=uT(r.intensity,`${t}.intensity`);if(r.type==="directional"){ki(r,sT,t);let o=Ff(r.direction,`${t}.direction`),a=Math.hypot(o.x,o.y,o.z);return a<=Nf&&bt(`${t}.direction`,"expected a non-zero direction vector"),Math.abs(a-1)>iT&&bt(`${t}.direction`,"expected a normalized direction vector"),Object.freeze({schemaVersion:1,type:"directional",intensity:n,direction:o,diffuseColor:Id(r.diffuseColor,`${t}.diffuseColor`)})}if(r.type==="hemispheric")return ki(r,cT,t),Object.freeze({schemaVersion:1,type:"hemispheric",intensity:n,diffuseColor:Id(r.diffuseColor,`${t}.diffuseColor`),groundColor:Id(r.groundColor,`${t}.groundColor`)});bt(`${t}.type`,"expected directional or hemispheric")}function Ff(e,t){let r=Td(e,t);return ki(r,dT,t),Object.freeze({x:Jo(r.x,`${t}.x`),y:Jo(r.y,`${t}.y`),z:Jo(r.z,`${t}.z`)})}function Id(e,t){let r=Td(e,t);return ki(r,lT,t),Object.freeze({r:Pd(r.r,`${t}.r`),g:Pd(r.g,`${t}.g`),b:Pd(r.b,`${t}.b`)})}function Td(e,t){(!e||typeof e!="object"||Array.isArray(e))&&bt(t,"expected a plain object");let r=Object.getPrototypeOf(e);return r!==Object.prototype&&r!==null&&bt(t,"expected a plain object"),e}function ki(e,t,r){for(let n of Object.keys(e))t.has(n)||bt(`${r}.${n}`,"unknown field")}function Jo(e,t){return(typeof e!="number"||!Number.isFinite(e))&&bt(t,"expected a finite number"),e}function uT(e,t){let r=Jo(e,t);return r<0&&bt(t,"expected a non-negative number"),r}function Pd(e,t){let r=Jo(e,t);return(r<0||r>1)&&bt(t,"expected a number between 0 and 1"),r}function bt(e,t){throw new wi(e,t)}var mT=new Set([".glb",".gltf",".png",".jpg",".jpeg",".webp",".env",".hdr",".dds",".ktx",".ktx2",".mp3",".wav",".ogg",".flac",".aac",".m4a"]);function _f(e){let t=String(e??"").trim().toLowerCase();if(/^\.[a-z0-9]+$/.test(t))return t;let r=t.split(/[?#]/,1)[0]??"",n=r.slice(r.lastIndexOf("/")+1),o=n.lastIndexOf(".");return o<=0||o===n.length-1?null:n.slice(o)}function $f(e){return mT.has(e)}function Hn(e){return e==="fps.builtin.pbr"||e==="fps.builtin.standard"?e:void 0}function Lf(e){if(!e||typeof e!="object")return;let t={};(e.lightingModel==="lit"||e.lightingModel==="unlit")&&(t.lightingModel=e.lightingModel);let r={},n=zf(e.baseColor?.color);n&&(r.color=n);let o=Xr(e.baseColor?.texture);o!==void 0&&(r.texture=o),nr(e.baseColor,r,"brightness"),nr(e.baseColor,r,"saturation"),nr(e.baseColor,r,"contrast"),nr(e.baseColor,r,"hue"),Object.keys(r).length>0&&(t.baseColor=r);let a={},i=Xr(e.normal?.texture);i!==void 0&&(a.texture=i),nr(e.normal,a,"strength"),Object.keys(a).length>0&&(t.normal=a),Kn(e.metallic)&&(t.metallic=e.metallic),Kn(e.roughness)&&(t.roughness=e.roughness);let s={},c=Xr(e.metallicRoughness?.texture);c!==void 0&&(s.texture=c),Object.keys(s).length>0&&(t.metallicRoughness=s);let d={},u=Xr(e.occlusion?.texture);u!==void 0&&(d.texture=u),nr(e.occlusion,d,"strength"),Object.keys(d).length>0&&(t.occlusion=d);let l={},m=zf(e.emission?.color);m&&(l.color=m),nr(e.emission,l,"intensity");let f=Xr(e.emission?.texture);f!==void 0&&(l.texture=f);let S=Xr(e.emission?.maskTexture);S!==void 0&&(l.maskTexture=S),Object.keys(l).length>0&&(t.emission=l);let g={};(e.alpha?.mode==="opaque"||e.alpha?.mode==="mask"||e.alpha?.mode==="blend")&&(g.mode=e.alpha.mode),nr(e.alpha,g,"opacity"),nr(e.alpha,g,"cutoff");let b=Xr(e.alpha?.texture);return b!==void 0&&(g.texture=b),Object.keys(g).length>0&&(t.alpha=g),Object.keys(t).length>0?t:void 0}function xd(...e){let t={};for(let r of e){let n=Lf(r);n&&(n.lightingModel&&(t.lightingModel=n.lightingModel),Un(t,n,"baseColor"),Un(t,n,"normal"),n.metallic!==void 0&&(t.metallic=n.metallic),n.roughness!==void 0&&(t.roughness=n.roughness),Un(t,n,"metallicRoughness"),Un(t,n,"occlusion"),Un(t,n,"emission"),Un(t,n,"alpha"))}return Lf(t)??{}}function Un(e,t,r){let n=t[r];n&&Object.assign(e,{[r]:{...e[r]??{},...n}})}function zf(e){return e&&Kn(e.r)&&Kn(e.g)&&Kn(e.b)?{r:e.r,g:e.g,b:e.b}:void 0}function Xr(e){if(e===null)return null;if(!e||typeof e!="object")return;let t=typeof e.url=="string"?e.url.trim():"",r=typeof e.textureAssetId=="string"?e.textureAssetId.trim():"";if(!(!t&&!r))return{...t?{url:t}:{},...r?{textureAssetId:r}:{}}}function nr(e,t,r){Kn(e?.[r])&&(t[r]=e[r])}function Kn(e){return typeof e=="number"&&Number.isFinite(e)}var Bf="staticShadows";function Ar(e){let t=ar(e);if(!t)return null;let r=pe(t.sourceHash),n=pe(t.lightHash),o=pe(t.profileHash);if(!r||!n||!o)return null;let a={sourceHash:r,lightHash:n,profileHash:o,...typeof t.generatedAt=="string"&&t.generatedAt.trim()?{generatedAt:t.generatedAt.trim()}:{},...(()=>{let u=ET(t.stats);return u?{stats:u}:{}})()};if(t.version!==2||t.format!=="sdf-atlas"||!Array.isArray(t.pages)||!Array.isArray(t.chunks))return null;let i=[],s=new Map;for(let u of t.pages){let l=fT(u);if(!l||s.has(l.id))return null;i.push(l),s.set(l.id,l)}let c=[],d=new Set;for(let u of t.chunks){let l=pT(u,s);if(!l||d.has(l.id))return null;c.push(l),d.add(l.id)}return{version:2,format:"sdf-atlas",pages:i,chunks:c,...a}}function Wn(e,t="$.staticShadows"){let r=Ar(e);if(r)return r;let n=new Error(`schema.unsupportedVersion: ${t}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:t}),n}function fT(e){let t=ar(e);if(!t)return null;let r=pe(t.id),n=vi(t.width),o=vi(t.height),a=IT(t.sdfTextureDataUrl);return!r||n==null||o==null||!a?null:{id:r,width:n,height:o,sdfTextureDataUrl:a}}function pT(e,t){let r=ar(e);if(!r)return null;let n=pe(r.id),o=yT(r.bounds),a=hT(r.plane),i=pe(r.pageId),s=bT(r.atlasRect),c=ST(r.atlasUv),d=PT(r.sourceNodeIds),u=pe(r.sourceHash),l=pe(r.lightHash),m=pe(r.profileHash);if(!n||!o||!a||!i||!s||!c||!d||!u||!l||!m)return null;let f=t.get(i);return!f||s.x+s.width>f.width||s.y+s.height>f.height?null:{id:n,bounds:o,plane:a,pageId:i,atlasRect:s,atlasUv:c,sourceNodeIds:d,sourceHash:u,lightHash:l,profileHash:m,...(()=>{let S=gT(r.binding);return S?{binding:S}:{}})()}}function gT(e){let t=ar(e);if(!t)return null;let r=pe(t.id),n=pe(t.ownerCasterId),o=pe(t.receiverId),a=pe(t.generatedAt),i=pe(t.sourceHash);if(!r||!n||!o||!a||!i||t.visibleWhenOwnerVisible!==!0||t.staleWhenOwnerTransformChanges!==!0||t.staleWhenLightChanges!==!0)return null;let s=pe(t.lightId),c=pe(t.textureAssetId),d=pe(t.projectionNodeId);return{id:r,ownerCasterId:n,receiverId:o,...s?{lightId:s}:{},...c?{textureAssetId:c}:{},...d?{projectionNodeId:d}:{},visibleWhenOwnerVisible:!0,staleWhenOwnerTransformChanges:!0,staleWhenLightChanges:!0,generatedAt:a,sourceHash:i}}function bT(e){let t=ar(e);if(!t)return null;let r=xr(t.x),n=xr(t.y),o=vi(t.width),a=vi(t.height);return r==null||n==null||o==null||a==null?null:{x:r,y:n,width:o,height:a}}function ST(e){let t=ar(e);if(!t)return null;let r=Oi(t.u0),n=Oi(t.v0),o=Oi(t.u1),a=Oi(t.v1);return r==null||n==null||o==null||a==null||o<=r||a<=n?null:{u0:r,v0:n,u1:o,v1:a}}function yT(e){let t=ar(e);if(!t)return null;let r=jt(t.minX),n=jt(t.maxX),o=jt(t.minZ),a=jt(t.maxZ),i=jt(t.y);return r==null||n==null||o==null||a==null||i==null||n<=r||a<=o?null:{minX:r,maxX:n,minZ:o,maxZ:a,y:i}}function hT(e){let t=ar(e);if(!t)return null;let r=jt(t.height),n=jt(t.yOffset);return r==null||n==null||n<0?null:{height:r,yOffset:n}}function ET(e){let t=ar(e);if(!t)return null;let r=xr(t.sourceRootCount),n=xr(t.sourceMeshCount),o=xr(t.attemptedChunkCount),a=xr(t.chunkCount),i=xr(t.textureCount);return r==null||n==null||o==null||a==null||i==null?null:{sourceRootCount:r,sourceMeshCount:n,attemptedChunkCount:o,chunkCount:a,textureCount:i,...Ri(t.skippedChunkCount,"skippedChunkCount"),...Ri(t.pageCount,"pageCount"),...or(t.resolution,"resolution"),...or(t.chunkSize,"chunkSize"),...or(t.atlasSize,"atlasSize"),...Ci(t.atlasUsedPixels,"atlasUsedPixels"),...Ci(t.atlasAllocatedPixels,"atlasAllocatedPixels"),...TT(t.atlasOccupancy,"atlasOccupancy"),...or(t.texelsPerMeter,"texelsPerMeter"),...or(t.effectiveTexelsPerMeter,"effectiveTexelsPerMeter"),...or(t.maxAtlasPages,"maxAtlasPages"),...Ci(t.sdfRadiusPx,"sdfRadiusPx"),...or(t.spatialChunkSize,"spatialChunkSize"),...or(t.effectiveSpatialChunkSize,"effectiveSpatialChunkSize"),...or(t.targetChunkCount,"targetChunkCount"),...Ri(t.bakedChunkCount,"bakedChunkCount"),...Ri(t.reusedChunkCount,"reusedChunkCount"),...Ci(t.durationMs,"durationMs")}}function IT(e){let t=pe(e);return t&&/^data:image\/png[;,]/i.test(t)?t:null}function PT(e){if(!Array.isArray(e)||e.length===0)return null;let t=[],r=new Set;for(let n of e){let o=pe(n);if(!o)return null;r.has(o)||t.push(o),r.add(o)}return t}function pe(e){return typeof e=="string"&&e.trim()?e.trim():null}function jt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function xr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function vi(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:null}function Oi(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:null}function Ri(e,t){let r=xr(e);return r==null?{}:{[t]:r}}function or(e,t){let r=jt(e);return r==null||r<=0?{}:{[t]:r}}function Ci(e,t){let r=jt(e);return r==null||r<0?{}:{[t]:r}}function TT(e,t){let r=jt(e);return r==null||r<0||r>1?{}:{[t]:r}}function ar(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var xT="@fps-games/editor.playable-sdk.scene-compiler",AT="2",DT=1e-4,et={nodeKinds:["group","instance","transform","primitive","image"],primitiveShapes:["cube","sphere","plane","capsule"],transformTypes:["plain","light","camera","groundDecal"],assetTypes:["glb","texture"],materialScopes:["sharedAsset","nodeMaterial"],materialModes:["shared","instance"],materialShaderIds:["fps.builtin.pbr","fps.builtin.standard"],materialAssetSystemPresets:["default-pbr","default-standard"],runtimeV3:{assetFields:["id","guid","type","url","external","warmupCount","singleton","materialMode","defaults","materialSlots"],materialSlotFields:["slotId","label","sourceSurfaces"],materialSlotSourceSurfaceFields:["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMeshName"]},hierarchy:{parentTargets:["root","sceneNode"]},runtimeOnlyTokens:["/@fs","assetUrl","sourceAssetUrl","sourceAssetPath"]},MT=new Set(et.nodeKinds),wT=new Set(et.primitiveShapes),kT=new Set(et.assetTypes),OT=new Set(et.materialModes),RT=new Set(et.materialScopes),CT=new Set(et.materialAssetSystemPresets),vT=new Set(et.transformTypes),Yo=new Set(et.hierarchy.parentTargets),GT=et.runtimeOnlyTokens,jT=new Set(et.runtimeV3.assetFields),NT=new Set(et.runtimeV3.materialSlotFields),FT=new Set(et.runtimeV3.materialSlotSourceSurfaceFields);function _T(e,t={}){let{allowOrphanSharedMaterials:r=!0,allowOrphanNodeMaterials:n=!0,strictAssetIds:o=[],strictNodeIds:a=[],maxErrors:i=50}=t,s=Number.isInteger(i)&&i>0?i:50,c=[],d=new Set(o),u=new Set(a),l=(p,D)=>{c.length<s&&c.push({path:p,message:D})};if(!M(e))return l("$","scene json must be an object"),c;let m=e.schemaVersion;m!==2&&m!==3&&l("$.schemaVersion","schemaVersion must be 2 or 3"),QT(e.meta?.generatedFrom,"$.meta.generatedFrom",l);let f=cx(e),S=e.scene;if(!M(S))return l("$.scene","scene must be an object"),c;if(O(S.rootId)||l("$.scene.rootId","rootId must be a non-empty string"),Array.isArray(S.assets)||l("$.scene.assets","assets must be an array"),Array.isArray(S.nodes)||l("$.scene.nodes","nodes must be an array"),Array.isArray(S.materialAssets)||l("$.scene.materialAssets","materialAssets must be an array"),Array.isArray(S.materials)||l("$.scene.materials","materials must be an array"),Array.isArray(S.textures)||l("$.scene.textures","textures must be an array"),c.length>0)return c;e.staticShadows!=null&&Vf(()=>Wn(e.staticShadows,"$.staticShadows"),"$.staticShadows",l);let g=new Set,b=new Map,y=new Map,E=new Set,I=new Set([S.rootId]),P=new Map,A=new Map,$=new Set;return S.assets.forEach((p,D)=>{let h=`$.scene.assets[${D}]`;if(!M(p)){l(h,"asset must be an object");return}if(O(p.id)?g.has(p.id)?l(`${h}.id`,`duplicate asset id: ${p.id}`):(g.add(p.id),b.set(p.id,p.type)):l(`${h}.id`,"asset.id must be a non-empty string"),kT.has(p.type)||l(`${h}.type`,"asset.type must be glb or texture"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"asset.guid must be a non-empty string when present"),p.url!=null&&!O(p.url)&&l(`${h}.url`,"url must be a non-empty string when present"),p.external!=null&&!M(p.external)&&l(`${h}.external`,"external must be an object when present"),p.warmupCount!=null&&(!Number.isInteger(p.warmupCount)||p.warmupCount<0)&&l(`${h}.warmupCount`,"warmupCount must be a non-negative integer when present"),p.singleton!=null&&typeof p.singleton!="boolean"&&l(`${h}.singleton`,"singleton must be a boolean when present"),p.materialMode!=null&&!OT.has(p.materialMode)&&l(`${h}.materialMode`,"materialMode must be shared or instance"),ZT(p.defaults,`${h}.defaults`,l),m===3)for(let F of Object.keys(p))jT.has(F)||l(`${h}.${F}`,`runtime schema v3 asset field is not allowed: ${F}`);else p.displayName!=null&&!O(p.displayName)&&l(`${h}.displayName`,"displayName must be a non-empty string when present"),p.category!=null&&!O(p.category)&&l(`${h}.category`,"category must be a non-empty string when present"),p.metadata!=null&&!M(p.metadata)&&l(`${h}.metadata`,"metadata must be an object when present");let R=m===3?p.materialSlots:M(p.metadata)?p.metadata.materialSlots:void 0,K=m===3?`${h}.materialSlots`:`${h}.metadata.materialSlots`,ne=new Set;R!=null&&(Array.isArray(R)?R.forEach((F,Ir)=>{let er=`${K}[${Ir}]`;if(!M(F)||!O(F.slotId)){l(er,m===3?"material slot must contain a stable slotId":"material slot must contain stable slotId and ownerNodePath");return}if(m!==3&&!O(F.ownerNodePath)){l(er,"material slot must contain stable slotId and ownerNodePath");return}ne.has(F.slotId)?l(`${er}.slotId`,`duplicate material slot id: ${F.slotId}`):ne.add(F.slotId),m===3&&YT(F,er,l)}):l(K,"materialSlots must be an array when present")),O(p.id)&&y.set(p.id,ne),d.has(p.id)&&Hf(p,h,l)}),S.nodes.forEach((p,D)=>{let h=`$.scene.nodes[${D}]`;if(!M(p)){l(h,"node must be an object");return}O(p.id)&&P.set(p.id,p),O(p.id)?I.has(p.id)?l(`${h}.id`,`duplicate node id: ${p.id}`):(I.add(p.id),typeof p.kind=="string"&&A.set(p.id,p.kind),p.kind==="transform"&&Object.prototype.hasOwnProperty.call(p,"marker")&&$.add(p.id)):l(`${h}.id`,"node.id must be a non-empty string"),MT.has(p.kind)||l(`${h}.kind`,"node.kind must be group, instance, transform, primitive, or image")}),S.materialAssets.forEach((p,D)=>{let h=`$.scene.materialAssets[${D}]`;if(!M(p)){l(h,"material asset must be an object");return}O(p.id)?E.has(p.id)?l(`${h}.id`,`duplicate material asset id: ${p.id}`):E.add(p.id):l(`${h}.id`,"material asset id must be a non-empty string"),p.name!=null&&!O(p.name)&&l(`${h}.name`,"material asset name must be a non-empty string when present"),p.guid!=null&&!O(p.guid)&&l(`${h}.guid`,"material asset guid must be a non-empty string when present"),Object.prototype.hasOwnProperty.call(p,"materialKind")&&l(`${h}.materialKind`,"materialKind is not supported; use shaderId"),Object.prototype.hasOwnProperty.call(p,"profile")&&l(`${h}.profile`,"profile is not supported; use properties");let R=Hn(p.shaderId),K=VT(p.shaderId);!R&&!K&&l(`${h}.shaderId`,"shaderId must be a built-in id or a namespaced lowercase project id"),p.definitionVersion!=null&&!UT(p.definitionVersion)?l(`${h}.definitionVersion`,"definitionVersion must be a positive integer when present"):K&&p.definitionVersion==null&&l(`${h}.definitionVersion`,"definitionVersion is required for project shader material assets"),R?qf(p.properties,`${h}.properties`,l):KT(p.properties,`${h}.properties`,l);for(let ne of Object.keys(p))["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(ne)||l(`${h}.${ne}`,`material asset field is not allowed: ${ne}`);HT(p.system,`${h}.system`,l),WT(p.origin,`${h}.origin`,l),qT(p,h,l)}),S.nodes.forEach((p,D)=>{if(!M(p))return;let h=`$.scene.nodes[${D}]`,R=Object.prototype.hasOwnProperty.call(p,"parentId");R&&!O(p.parentId)&&l(`${h}.parentId`,"parentId must be a non-empty string when present");let K=R?p.parentId:S.rootId;O(K)&&JT(K,S.rootId,I,`${h}.parentId`,l),O(p.id)&&XT(p.id,S.rootId,P,`${h}.parentId`,l),ex(p.source,`${h}.source`,l),Xf(p.transform,`${h}.transform`,l),hx(p.rendering,`${h}.rendering`,l),p.shadow!=null&&Vf(()=>Ko(p.shadow,`${h}.shadow`),`${h}.shadow`,l),Object.prototype.hasOwnProperty.call(p,"shadowMode")&&l(`${h}.shadowMode`,"deprecated field; use shadow.mode");let ne=null;p.kind==="instance"&&(M(p.instance)?g.has(p.instance.assetId)?b.get(p.instance.assetId)!=="glb"?l(`${h}.instance.assetId`,"instance.assetId must reference a glb asset"):ne=O(p.instance.assetId)?p.instance.assetId:null:l(`${h}.instance.assetId`,`assetId must reference scene.assets: ${p.instance.assetId}`):l(`${h}.instance`,"instance node must contain instance object")),p.kind==="primitive"&&(M(p.primitive)?wT.has(p.primitive.shape)||l(`${h}.primitive.shape`,"primitive.shape must be cube, sphere, plane, or capsule"):l(`${h}.primitive`,"primitive node must contain primitive object")),p.kind==="image"&&(M(p.image)?(g.has(p.image.assetId)?b.get(p.image.assetId)!=="texture"&&l(`${h}.image.assetId`,"image.assetId must reference a texture asset"):l(`${h}.image.assetId`,`assetId must reference scene.assets: ${p.image.assetId}`),M(p.image.size)?(Kf(p.image.size.width)||l(`${h}.image.size.width`,"image.size.width must be positive"),Kf(p.image.size.height)||l(`${h}.image.size.height`,"image.size.height must be positive")):l(`${h}.image.size`,"image.size must be an object")):l(`${h}.image`,"image node must contain image object")),p.kind==="transform"&&p.transformType!=null&&!vT.has(p.transformType)&&l(`${h}.transformType`,"transformType must be plain, light, camera, or groundDecal"),p.kind==="transform"&&p.transformType==="groundDecal"?ux(p.groundDecal,`${h}.groundDecal`,l):Object.prototype.hasOwnProperty.call(p,"groundDecal")&&l(`${h}.groundDecal`,"groundDecal is only allowed on transform nodes with transformType groundDecal"),p.kind==="transform"&&(sx(p.camera,`${h}.camera`,l),dx(p.light,`${h}.light`,l,f)),Object.prototype.hasOwnProperty.call(p,"marker")&&(p.kind!=="transform"?l(`${h}.marker`,"marker is only allowed on transform nodes"):(tx(p.marker,`${h}.marker`,l),rx(p.marker,p.id,I,$,`${h}.marker`,l))),(p.kind==="instance"||p.kind==="transform"||p.kind==="primitive"||p.kind==="image")&&LT(p.overrides,`${h}.overrides`,E,ne?y.get(ne):void 0,m===3?"materialSlots":"metadata.materialSlots",l),u.has(p.id)&&Hf(p,h,l)}),S.materials.forEach((p,D)=>{let h=`$.scene.materials[${D}]`;if(!M(p)){l(h,"material must be an object");return}if(O(p.id)||l(`${h}.id`,"material.id must be a non-empty string"),p.scope!=null&&!RT.has(p.scope)&&l(`${h}.scope`,"material scope must be sharedAsset or nodeMaterial"),p.scope==="sharedAsset"&&(!O(p.assetId)||!g.has(p.assetId))&&!r&&l(`${h}.assetId`,`shared material assetId must reference scene.assets: ${p.assetId}`),p.scope==="nodeMaterial"){if((!O(p.nodeId)||!I.has(p.nodeId))&&!n)l(`${h}.nodeId`,`node material nodeId must reference scene.nodes: ${p.nodeId}`);else if(O(p.nodeId)&&I.has(p.nodeId)){let R=A.get(p.nodeId);R!=="instance"&&R!=="transform"&&R!=="primitive"&&l(`${h}.nodeId`,`node material nodeId must reference an instance, transform, or primitive node: ${p.nodeId}`)}}O(p.materialName)||l(`${h}.materialName`,"materialName must be a non-empty string"),M(p.properties)?Zf(p.properties,`${h}.properties`,l):l(`${h}.properties`,"properties must be an object")}),c}function $T(e,t={}){let r=_T(e,t);return{ok:r.length===0,errors:r}}function Vf(e,t,r){try{e()}catch(n){let o=typeof n?.path=="string"?n.path:t,a=typeof n?.code=="string"?n.code:"schema.invalidValue";r(o,a)}}function LT(e,t,r,n,o,a){if(e!=null){if(!M(e)){a(t,"overrides must be an object when present");return}Wf(e.materialBinding,`${t}.materialBinding`,r,a),zT(e.materialSlotBindings,`${t}.materialSlotBindings`,"slotId",r,n,o,a),Object.prototype.hasOwnProperty.call(e,"childMaterialBindings")&&a(`${t}.childMaterialBindings`,"deprecated field; use materialSlotBindings keyed by slotId"),Object.prototype.hasOwnProperty.call(e,"childMaterials")&&a(`${t}.childMaterials`,"deprecated field; use materialSlotBindings keyed by slotId")}}function zT(e,t,r,n,o,a,i){if(e!=null){if(!M(e)){i(t,"material binding map must be an object when present");return}for(let[s,c]of Object.entries(e)){let d=`${t}.${s}`;O(s)||i(d,`${r} must be a non-empty string`),o?o.has(s)||i(d,`${r} must reference asset ${a}`):i(d,`${r} requires an instance asset with ${a}`),c==null?i(d,"material binding must be an object"):Wf(c,d,n,i)}}}function Wf(e,t,r,n){if(e!=null){if(!M(e)){n(t,"material binding must be an object when present");return}e.materialAssetId!=null&&(O(e.materialAssetId)?r.has(e.materialAssetId)||n(`${t}.materialAssetId`,`materialAssetId must reference scene.materialAssets: ${e.materialAssetId}`):n(`${t}.materialAssetId`,"materialAssetId must be non-empty when present")),e.override!=null&&qf(e.override,`${t}.override`,n)}}function qf(e,t,r){if(!M(e)){r(t,"material asset profile must be an object");return}if(e.lightingModel!=null&&e.lightingModel!=="lit"&&e.lightingModel!=="unlit"&&r(`${t}.lightingModel`,"lightingModel must be lit or unlit"),e.baseColor!=null)if(!M(e.baseColor))r(`${t}.baseColor`,"baseColor must be an object");else{Gi(e.baseColor.color,`${t}.baseColor.color`,r),Yr(e.baseColor.texture,`${t}.baseColor.texture`,r);for(let n of["brightness","saturation","contrast","hue"])e.baseColor[n]!=null&&!We(e.baseColor[n])&&r(`${t}.baseColor.${n}`,`${n} must be a finite number`)}for(let n of["metallic","roughness"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,`${n} must be a finite number`);e.normal!=null&&(M(e.normal)?(Yr(e.normal.texture,`${t}.normal.texture`,r),e.normal.strength!=null&&!We(e.normal.strength)&&r(`${t}.normal.strength`,"normal strength must be a finite number")):r(`${t}.normal`,"normal must be an object")),e.metallicRoughness!=null&&(M(e.metallicRoughness)?Yr(e.metallicRoughness.texture,`${t}.metallicRoughness.texture`,r):r(`${t}.metallicRoughness`,"metallicRoughness must be an object")),e.occlusion!=null&&(M(e.occlusion)?(Yr(e.occlusion.texture,`${t}.occlusion.texture`,r),e.occlusion.strength!=null&&!We(e.occlusion.strength)&&r(`${t}.occlusion.strength`,"occlusion strength must be a finite number")):r(`${t}.occlusion`,"occlusion must be an object")),e.emission!=null&&(M(e.emission)?(Gi(e.emission.color,`${t}.emission.color`,r),e.emission.intensity!=null&&!We(e.emission.intensity)&&r(`${t}.emission.intensity`,"emission intensity must be a finite number"),Yr(e.emission.texture,`${t}.emission.texture`,r),Yr(e.emission.maskTexture,`${t}.emission.maskTexture`,r)):r(`${t}.emission`,"emission must be an object")),e.alpha!=null&&(M(e.alpha)?(e.alpha.mode!=null&&e.alpha.mode!=="opaque"&&e.alpha.mode!=="mask"&&e.alpha.mode!=="blend"&&r(`${t}.alpha.mode`,"alpha mode must be opaque, mask, or blend"),e.alpha.opacity!=null&&!We(e.alpha.opacity)&&r(`${t}.alpha.opacity`,"alpha opacity must be a finite number"),e.alpha.cutoff!=null&&!We(e.alpha.cutoff)&&r(`${t}.alpha.cutoff`,"alpha cutoff must be a finite number"),Yr(e.alpha.texture,`${t}.alpha.texture`,r)):r(`${t}.alpha`,"alpha must be an object"))}var BT=/^[a-z0-9]+(?:[._-][a-z0-9]+)+$/;function Qo(e){return typeof e=="string"&&!e.startsWith("fps.builtin.")&&BT.test(e)}function VT(e){return Qo(e)?e:null}function UT(e){return Number.isSafeInteger(e)&&e>0}function KT(e,t,r){if(!M(e)){r(t,"project shader material properties must be an object");return}Ad(e,t,r)}function Ad(e,t,r){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||r(t,"project shader material numbers must be finite");return}if(Array.isArray(e)){e.forEach((n,o)=>Ad(n,`${t}[${o}]`,r));return}if(M(e)){for(let[n,o]of Object.entries(e))Ad(o,`${t}.${n}`,r);return}r(t,"project shader material properties must be JSON-safe")}}function Yr(e,t,r){if(e!=null){if(!M(e)){r(t,"texture ref must be an object");return}e.url!=null&&!O(e.url)&&r(`${t}.url`,"texture url must be non-empty when present"),e.textureAssetId!=null&&!O(e.textureAssetId)&&r(`${t}.textureAssetId`,"textureAssetId must be non-empty when present")}}function HT(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset system must be an object");return}e.readonly!=null&&typeof e.readonly!="boolean"&&r(`${t}.readonly`,"readonly must be boolean"),e.preset!=null&&!CT.has(e.preset)&&r(`${t}.preset`,"preset must be default-pbr or default-standard")}}function WT(e,t,r){if(e!=null){if(!M(e)){r(t,"material asset origin must be an object");return}e.type!=="imported"&&e.type!=="created"&&e.type!=="duplicated"&&e.type!=="preset"&&r(`${t}.type`,"origin type must be imported, created, duplicated, or preset"),e.sourceAssetGuid!=null&&!O(e.sourceAssetGuid)&&r(`${t}.sourceAssetGuid`,"sourceAssetGuid must be non-empty when present"),e.sourceAssetId!=null&&!O(e.sourceAssetId)&&r(`${t}.sourceAssetId`,"sourceAssetId must be non-empty when present"),e.sourceSlotId!=null&&!O(e.sourceSlotId)&&r(`${t}.sourceSlotId`,"sourceSlotId must be non-empty when present"),e.sourceMaterialIndex!=null&&!Number.isInteger(e.sourceMaterialIndex)&&r(`${t}.sourceMaterialIndex`,"sourceMaterialIndex must be an integer when present"),e.sourceMaterialName!=null&&!O(e.sourceMaterialName)&&r(`${t}.sourceMaterialName`,"sourceMaterialName must be non-empty when present"),e.sourceMaterialAssetId!=null&&!O(e.sourceMaterialAssetId)&&r(`${t}.sourceMaterialAssetId`,"sourceMaterialAssetId must be non-empty when present")}}function qT(e,t,r){let n=M(e.system)?e.system.preset:void 0;n==="default-pbr"&&e.shaderId!=="fps.builtin.pbr"&&r(`${t}.shaderId`,"default-pbr material assets must use shaderId fps.builtin.pbr"),n==="default-standard"&&e.shaderId!=="fps.builtin.standard"&&r(`${t}.shaderId`,"default-standard material assets must use shaderId fps.builtin.standard")}function JT(e,t,r,n,o){if(e===t){Yo.has("root")||o(n,`parentId must point to scene node: ${e}`);return}if(Yo.has("sceneNode")&&r.has(e))return;let a=Yo.has("root")&&Yo.has("sceneNode")?"root or scene node":Yo.has("sceneNode")?"scene node":"root";o(n,`parentId must point to ${a}: ${e}`)}function XT(e,t,r,n,o){if(!O(t))return;let a=new Set([e]),i=O(r.get(e)?.parentId)?r.get(e)?.parentId:t;for(;O(i)&&i!==t;){if(a.has(i)){o(n,`parentId creates a node cycle involving ${e}`);return}a.add(i);let s=r.get(i);if(!s)return;i=O(s.parentId)?s.parentId:t}}function YT(e,t,r){for(let n of Object.keys(e))NT.has(n)||r(`${t}.${n}`,`runtime schema v3 material slot field is not allowed: ${n}`);if(e.label!=null&&!O(e.label)&&r(`${t}.label`,"label must be a non-empty string when present"),!Array.isArray(e.sourceSurfaces)||e.sourceSurfaces.length===0){r(`${t}.sourceSurfaces`,"sourceSurfaces must be a non-empty array");return}for(let n=0;n<e.sourceSurfaces.length;n+=1){let o=`${t}.sourceSurfaces[${n}]`,a=e.sourceSurfaces[n];if(!M(a)){r(o,"source surface must be an object");continue}for(let i of Object.keys(a))FT.has(i)||r(`${o}.${i}`,`runtime schema v3 material slot source surface field is not allowed: ${i}`);O(a.ownerNodePath)||r(`${o}.ownerNodePath`,"ownerNodePath must be a non-empty string");for(let i of["meshIndex","primitiveIndex"])(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer`);for(let i of["nodeIndex","sourceMaterialIndex"])a[i]!=null&&(!Number.isInteger(a[i])||a[i]<0)&&r(`${o}.${i}`,`${i} must be a non-negative integer when present`);a.nodeIndexPath!=null&&(!Array.isArray(a.nodeIndexPath)||a.nodeIndexPath.some(i=>!Number.isInteger(i)||i<0))&&r(`${o}.nodeIndexPath`,"nodeIndexPath must contain non-negative integers"),O(a.sourceMeshName)||r(`${o}.sourceMeshName`,"sourceMeshName is required")}}function ZT(e,t,r){if(e!=null){if(!M(e)){r(t,"defaults must be an object");return}if(Xf(e.transform,`${t}.transform`,r),Uf(e.outline,`${t}.outline`,r),e.childOutlines!=null)if(!M(e.childOutlines))r(`${t}.childOutlines`,"childOutlines must be an object");else for(let[n,o]of Object.entries(e.childOutlines))Uf(o,`${t}.childOutlines.${n}`,r)}}function QT(e,t,r){if(e!=null){if(!M(e)){r(t,"generatedFrom must be an object when present");return}Jf(e,t,r),O(e.compilerId)||r(`${t}.compilerId`,"compilerId must be a non-empty string"),O(e.compilerVersion)||r(`${t}.compilerVersion`,"compilerVersion must be a non-empty string"),O(e.compiledAt)||r(`${t}.compiledAt`,"compiledAt must be a non-empty string")}}function ex(e,t,r){if(e!=null){if(!M(e)){r(t,"source must be an object when present");return}Jf(e,t,r),e.objectGuid!=null&&!O(e.objectGuid)&&r(`${t}.objectGuid`,"objectGuid must be a non-empty string when present"),e.objectId!=null&&!O(e.objectId)&&r(`${t}.objectId`,"objectId must be a non-empty string when present"),e.component!=null&&!O(e.component)&&r(`${t}.component`,"component must be a non-empty string when present"),e.propertyPath!=null&&!O(e.propertyPath)&&r(`${t}.propertyPath`,"propertyPath must be a non-empty string when present")}}function Jf(e,t,r){O(e.sourceId)||r(`${t}.sourceId`,"sourceId must be a non-empty string"),O(e.sourceType)||r(`${t}.sourceType`,"sourceType must be a non-empty string"),e.revision!=null&&(typeof e.revision!="number"||!Number.isFinite(e.revision))&&r(`${t}.revision`,"revision must be a finite number when present")}function ji(e,t){let r=$T(e,t);if(r.ok)return;let n=new Error(`scene_json_schema_failed:
2
+ ${JSON.stringify(r.errors,null,2)}`);throw Object.assign(n,{code:"scene_json_schema_failed",diagnostics:r.errors}),n}function M(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function O(e){return typeof e=="string"&&e.trim().length>0}function Xf(e,t,r){if(e!=null){if(!M(e)){r(t,"transform must be an object");return}Nt(e.position,`${t}.position`,r),Nt(e.rotation,`${t}.rotation`,r),Nt(e.rotationDeg,`${t}.rotationDeg`,r),typeof e.scale=="number"?Number.isFinite(e.scale)||r(`${t}.scale`,"scale number must be finite"):Nt(e.scale,`${t}.scale`,r)}}function tx(e,t,r){if(!M(e)){r(t,"marker must be an object");return}Dr(e,["schemaVersion","label","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t,r),e.schemaVersion!==1&&r(`${t}.schemaVersion`,"marker.schemaVersion must be 1"),O(e.label)||r(`${t}.label`,"marker.label must be a non-empty string"),O(e.type)||r(`${t}.type`,"marker.type must be a non-empty string"),e.kind!=null&&!O(e.kind)&&r(`${t}.kind`,"marker.kind must be a non-empty string when present"),e.tags!=null&&(Array.isArray(e.tags)?e.tags.forEach((n,o)=>{typeof n!="string"&&r(`${t}.tags[${o}]`,"marker tag must be a string")}):r(`${t}.tags`,"marker.tags must be an array when present")),e.note!=null&&typeof e.note!="string"&&r(`${t}.note`,"marker.note must be a string when present"),e.color!=null&&ax(e.color,`${t}.color`,r),e.target!=null&&Dd(e.target,`${t}.target`,r),e.semanticFrame!=null&&nx(e.semanticFrame,`${t}.semanticFrame`,r),ox(e.geometry,`${t}.geometry`,r),e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker.metadata must be an object when present")}function rx(e,t,r,n,o,a){if(!M(e))return;let i=[];e.target!=null&&i.push({value:e.target,path:`${o}.target`}),M(e.geometry)&&e.geometry.target!=null&&i.push({value:e.geometry.target,path:`${o}.geometry.target`});for(let s of i)M(s.value)&&(s.value.kind!=="scene-object"&&s.value.kind!=="marker"&&a(`${s.path}.kind`,"runtime marker target kind must be scene-object or marker"),O(s.value.id)&&(s.value.id===t?a(`${s.path}.id`,"runtime marker target must not reference its marker node"):r.has(s.value.id)?s.value.kind==="marker"&&!n.has(s.value.id)?a(`${s.path}.id`,`runtime marker target must reference a marker node: ${s.value.id}`):s.value.kind==="scene-object"&&n.has(s.value.id)&&a(`${s.path}.id`,`runtime scene-object target must not reference a marker node: ${s.value.id}`):a(`${s.path}.id`,`runtime marker target must reference scene.nodes: ${s.value.id}`)))}function Dd(e,t,r){if(!M(e)){r(t,"marker target must be an object");return}Dr(e,["kind","id","label","path","metadata"],t,r),O(e.kind)||r(`${t}.kind`,"marker target kind must be a non-empty string"),O(e.id)||r(`${t}.id`,"marker target id must be a non-empty string");for(let n of["label","path"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker target ${n} must be a string when present`);e.metadata!=null&&!M(e.metadata)&&r(`${t}.metadata`,"marker target metadata must be an object when present")}function nx(e,t,r){if(!M(e)){r(t,"marker semanticFrame must be an object");return}Dr(e,["origin","forward","right","up","label","description"],t,r),M(e.origin)?Nt(e.origin,`${t}.origin`,r):r(`${t}.origin`,"marker semanticFrame.origin must be a vector object");for(let n of["forward","right","up"])e[n]!=null&&Nt(e[n],`${t}.${n}`,r);for(let n of["label","description"])e[n]!=null&&typeof e[n]!="string"&&r(`${t}.${n}`,`marker semanticFrame ${n} must be a string when present`)}function ox(e,t,r){if(!M(e)){r(t,"marker.geometry must be an object");return}if(e.kind==="box"){Dr(e,["kind"],t,r);return}if(e.kind==="point"){Dr(e,["kind","coordinateSpace","position","offset","target"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&e.coordinateSpace!=="local"&&r(`${t}.coordinateSpace`,"point marker coordinateSpace must be world or local"),e.position!=null&&Nt(e.position,`${t}.position`,r),e.offset!=null&&Nt(e.offset,`${t}.offset`,r),e.target!=null&&Dd(e.target,`${t}.target`,r);return}if(e.kind==="object-bounds"){Dr(e,["kind","target"],t,r),Dd(e.target,`${t}.target`,r);return}if(e.kind==="polyhedron"){Dr(e,["kind","coordinateSpace","vertices","faces"],t,r),e.coordinateSpace!=null&&e.coordinateSpace!=="world"&&r(`${t}.coordinateSpace`,"polyhedron marker coordinateSpace must be world"),Array.isArray(e.vertices)?e.vertices.forEach((n,o)=>{let a=`${t}.vertices[${o}]`;M(n)?Nt(n,a,r):r(a,"polyhedron marker vertex must be a vector object")}):r(`${t}.vertices`,"polyhedron marker vertices must be an array"),e.faces!=null&&(Array.isArray(e.faces)?e.faces.forEach((n,o)=>{Array.isArray(n)?n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&r(`${t}.faces[${o}][${i}]`,"polyhedron marker index must be a non-negative integer")}):r(`${t}.faces[${o}]`,"polyhedron marker face must be an array")}):r(`${t}.faces`,"polyhedron marker faces must be an array when present"));return}r(`${t}.kind`,"marker.geometry.kind must be box, point, object-bounds, or polyhedron")}function ax(e,t,r){if(!M(e)){r(t,"marker color must be an object");return}Dr(e,["r","g","b"],t,r);for(let n of["r","g","b"])Yf(e[n])||r(`${t}.${n}`,"marker color component must be between 0 and 1")}function Dr(e,t,r,n){let o=new Set(t);for(let a of Object.keys(e))o.has(a)||n(`${r}.${a}`,`field is not allowed: ${a}`)}function Nt(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y","z"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function ix(e,t,r){if(e!=null){if(!M(e)){r(t,"value must be a vector object");return}for(let n of["x","y"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"vector component must be a finite number")}}function We(e){return typeof e=="number"&&Number.isFinite(e)}function Zr(e){return We(e)&&e>0}function Yf(e){return We(e)&&e>=0&&e<=1}function Gi(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,"color component must be a finite number")}}function sx(e,t,r){if(e!=null){if(!M(e)){r(t,"camera must be an object");return}e.projection!=null&&e.projection!=="orthographic"&&e.projection!=="perspective"&&r(`${t}.projection`,"camera projection must be orthographic or perspective");for(let n of["alpha","beta"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number when present");for(let n of["radius","orthoSize"])e[n]!=null&&!Zr(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number when present");e.fov!=null&&!Zr(e.fov)&&r(`${t}.fov`,"camera fov must be a positive finite number"),Nt(e.targetOffset,`${t}.targetOffset`,r),ix(e.targetScreenOffset,`${t}.targetScreenOffset`,r);for(let n of["minZ","maxZ","lowerRadiusLimit","upperRadiusLimit"])e[n]!=null&&!Zr(e[n])&&r(`${t}.${n}`,"camera property must be a positive finite number");for(let n of["lowerBetaLimit","upperBetaLimit"])e[n]!=null&&!We(e[n])&&r(`${t}.${n}`,"camera property must be a finite number");e.inertia!=null&&!Yf(e.inertia)&&r(`${t}.inertia`,"camera inertia must be between 0 and 1"),Zr(e.minZ)&&Zr(e.maxZ)&&e.maxZ<=e.minZ&&r(`${t}.maxZ`,"camera maxZ must be greater than minZ"),We(e.lowerBetaLimit)&&We(e.upperBetaLimit)&&e.upperBetaLimit<e.lowerBetaLimit&&r(`${t}.upperBetaLimit`,"camera upperBetaLimit must be greater than or equal to lowerBetaLimit"),Zr(e.lowerRadiusLimit)&&Zr(e.upperRadiusLimit)&&e.upperRadiusLimit<e.lowerRadiusLimit&&r(`${t}.upperRadiusLimit`,"camera upperRadiusLimit must be greater than or equal to lowerRadiusLimit")}}function cx(e){let t=e.meta?.generatedFrom;return M(t)&&t.compilerId===xT&&t.compilerVersion===AT}function dx(e,t,r,n=!1){if(e==null)return;let o=n&&M(e)&&!Object.prototype.hasOwnProperty.call(e,"schemaVersion")?lx(e,t):e;try{Vn(o,t)}catch(a){let i=a;r(typeof i.path=="string"?i.path:t,typeof i.reason=="string"?i.reason:typeof i.message=="string"?i.message:"light does not satisfy the Engine Runtime Light contract")}}function lx(e,t){let r={...e,schemaVersion:1};if(e.type!=="directional"||!M(e.direction))return r;let{x:n,y:o,z:a}=e.direction;if(![n,o,a].every(s=>typeof s=="number"&&Number.isFinite(s)))return r;let i=Math.hypot(n,o,a);return i<=0||Math.abs(i-1)>DT?r:{...r,direction:Xo(e.direction,`${t}.direction`)}}function Uf(e,t,r){if(e!=null){if(!M(e)){r(t,"outline must be an object");return}e.renderOutline!=null&&typeof e.renderOutline!="boolean"&&r(`${t}.renderOutline`,"renderOutline must be boolean"),e.outlineWidth!=null&&(typeof e.outlineWidth!="number"||!Number.isFinite(e.outlineWidth))&&r(`${t}.outlineWidth`,"outlineWidth must be a finite number"),Gi(e.outlineColor,`${t}.outlineColor`,r)}}function ux(e,t,r){if(e==null){r(t,"groundDecal is required when transformType is groundDecal");return}if(!M(e)){r(t,"groundDecal must be an object");return}mx(e,t,r)}function mx(e,t,r){if(O(e.uiKind)||r(`${t}.uiKind`,"groundDecal UI kind must be non-empty"),!M(e.size))r(`${t}.size`,"groundDecal.size must be an object");else for(let n of["width","depth"])(typeof e.size[n]!="number"||!Number.isFinite(e.size[n])||e.size[n]<=0)&&r(`${t}.size.${n}`,"groundDecal size must be a positive finite number");if(e.aspectSourceLayerId!=null&&!O(e.aspectSourceLayerId)&&r(`${t}.aspectSourceLayerId`,"aspectSourceLayerId must be non-empty when present"),e.lockAspectToBorder!=null&&typeof e.lockAspectToBorder!="boolean"&&r(`${t}.lockAspectToBorder`,"lockAspectToBorder must be boolean when present"),e.editorPreviewActive!=null&&r(`${t}.editorPreviewActive`,"editorPreviewActive is editor-only and must not appear in runtime scene data"),fx(e.mask,`${t}.mask`,r),px(e.rendering,`${t}.rendering`,r),!Array.isArray(e.layers)){r(`${t}.layers`,"groundDecal UI layers must be an array");return}e.layers.forEach((n,o)=>gx(n,`${t}.layers[${o}]`,r)),bx(e.layers,`${t}.layers`,r)}function fx(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI mask must be an object");return}e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"mask.enabled must be boolean"),e.source!=null&&e.source!=="roundedRect"&&e.source!=="borderAlpha"&&e.source!=="texture"&&r(`${t}.source`,"mask.source must be roundedRect, borderAlpha, or texture"),e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"mask.textureId must be non-empty when present");for(let n of["cornerRadius","padding"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n])||e[n]<0)&&r(`${t}.${n}`,`${n} must be a non-negative finite number`)}}function px(e,t,r){if(e!=null){if(!M(e)){r(t,"groundDecal UI rendering must be an object");return}for(let n of["textureWidth","textureHeight"])e[n]!=null&&(!Number.isInteger(e[n])||e[n]<=0)&&r(`${t}.${n}`,`${n} must be a positive integer`);for(let n of["alphaIndex","diffuseTextureLevel","emissiveTextureLevel"])e[n]!=null&&(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`${n} must be a finite number`)}}function gx(e,t,r){if(!M(e)){r(t,"groundDecal UI layer must be an object");return}O(e.id)||r(`${t}.id`,"layer.id must be non-empty"),O(e.role)||r(`${t}.role`,"layer.role must be non-empty"),e.editorPreviewPercent!=null&&r(`${t}.editorPreviewPercent`,"editorPreviewPercent is editor-only and must not appear in runtime scene data"),e.enabled!=null&&typeof e.enabled!="boolean"&&r(`${t}.enabled`,"layer.enabled must be boolean"),(typeof e.zOrder!="number"||!Number.isFinite(e.zOrder))&&r(`${t}.zOrder`,"layer.zOrder must be a finite number"),e.opacity!=null&&(typeof e.opacity!="number"||!Number.isFinite(e.opacity))&&r(`${t}.opacity`,"layer.opacity must be finite"),e.rotationDeg!=null&&(typeof e.rotationDeg!="number"||!Number.isFinite(e.rotationDeg)||e.rotationDeg<=-180||e.rotationDeg>180)&&r(`${t}.rotationDeg`,"layer.rotationDeg must be in the range (-180, 180]"),Sx(e.rect,`${t}.rect`,r),e.kind==="texture"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture layer imageFit must be contain or stretch"),qn(e.tint,`${t}.tint`,r)):e.kind==="textureProgress"?(e.textureId!=null&&!O(e.textureId)&&r(`${t}.textureId`,"texture progress layer textureId must be non-empty when present"),e.imageFit!=null&&e.imageFit!=="contain"&&e.imageFit!=="stretch"&&r(`${t}.imageFit`,"texture progress layer imageFit must be contain or stretch"),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"texture progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"texture progress direction is invalid"),qn(e.tint,`${t}.tint`,r)):e.kind==="color"?qn(e.color,`${t}.color`,r):e.kind==="progress"?((typeof e.value!="number"||!Number.isFinite(e.value)||e.value<0||e.value>1)&&r(`${t}.value`,"progress value must be between 0 and 1"),e.direction!=null&&!["leftToRight","rightToLeft","bottomToTop","topToBottom"].includes(String(e.direction))&&r(`${t}.direction`,"progress direction is invalid"),qn(e.color,`${t}.color`,r)):e.kind==="text"?yx(e.text,`${t}.text`,r):r(`${t}.kind`,"layer.kind must be texture, textureProgress, color, progress, or text")}function bx(e,t,r){let n=new Map;e.forEach((o,a)=>{if(!M(o)||!O(o.id))return;let i=n.get(o.id);if(i!=null){r(`${t}[${a}].id`,`layer.id must be unique; duplicate of layers[${i}]`);return}n.set(o.id,a)})}function Sx(e,t,r){if(!M(e)){r(t,"layer.rect must be an object");return}for(let n of["x","z","width","depth"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`rect.${n} must be a finite number`);for(let n of["width","depth"])typeof e[n]=="number"&&e[n]<=0&&r(`${t}.${n}`,`rect.${n} must be positive`)}function yx(e,t,r){if(!M(e)){r(t,"text layer text must be an object");return}typeof e.value!="string"&&r(`${t}.value`,"text.value must be a string"),e.fontFamily!=null&&typeof e.fontFamily!="string"&&r(`${t}.fontFamily`,"fontFamily must be a string"),e.fontSize!=null&&(typeof e.fontSize!="number"||!Number.isFinite(e.fontSize)||e.fontSize<=0)&&r(`${t}.fontSize`,"fontSize must be a positive finite number"),e.fontWeight!=null&&typeof e.fontWeight!="string"&&r(`${t}.fontWeight`,"fontWeight must be a string"),qn(e.color,`${t}.color`,r),qn(e.strokeColor,`${t}.strokeColor`,r),e.strokeWidth!=null&&(typeof e.strokeWidth!="number"||!Number.isFinite(e.strokeWidth)||e.strokeWidth<0)&&r(`${t}.strokeWidth`,"strokeWidth must be a non-negative finite number")}function qn(e,t,r){if(e!=null){if(!M(e)){r(t,"color must be an object");return}for(let n of["r","g","b"])(typeof e[n]!="number"||!Number.isFinite(e[n]))&&r(`${t}.${n}`,`color.${n} must be finite`);e.a!=null&&(typeof e.a!="number"||!Number.isFinite(e.a))&&r(`${t}.a`,"color.a must be finite")}}function hx(e,t,r){if(e!=null){if(!M(e)){r(t,"rendering must be an object");return}e.renderingGroupId!=null&&e.renderingGroupId!==0&&e.renderingGroupId!==1&&e.renderingGroupId!==2&&e.renderingGroupId!==3&&r(`${t}.renderingGroupId`,"renderingGroupId must be 0, 1, 2, or 3"),e.alphaIndex!=null&&(typeof e.alphaIndex!="number"||!Number.isFinite(e.alphaIndex))&&r(`${t}.alphaIndex`,"alphaIndex must be a finite number")}}function Kf(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Zf(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;["albedoColor","diffuseColor","emissiveColor","outlineColor"].includes(n)&&Gi(o,a,r),["metallic","roughness","contrast","brightness","saturation","hue","colorDensity","alpha","alphaCutOff","transparencyMode"].includes(n)&&(typeof o!="number"||!Number.isFinite(o))&&r(a,`${n} must be a finite number`),n==="backFaceCulling"&&typeof o!="boolean"&&r(a,"backFaceCulling must be boolean"),["albedoTexture","normalTexture","metallicTexture"].includes(n)&&(M(o)?o.url!=null&&!O(o.url)&&r(`${a}.url`,"texture url must be non-empty when present"):r(a,`${n} must be an object`)),["pbr","standard"].includes(n)&&(M(o)?Zf(o,a,r):r(a,`${n} must be an object`))}}function Hf(e,t,r){let n=JSON.stringify(e),o=GT.filter(a=>n.includes(a));o.length>0&&r(t,`contains runtime-only asset fields: ${o.join(", ")}`)}function Ex(e,t,r){let n=Qf(e)??512,o=Qf(t)??512;if(!Number.isFinite(r)||r<=0)return{width:n,height:o};let a=n,i=Math.max(1,Math.round(a/r));return i>o&&(i=o,a=Math.max(1,Math.round(i*r))),{width:a,height:i}}function Ni(e){let t=e.rendering?.textureWidth??512,r=e.rendering?.textureHeight??512,n=e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:t/r;return Ex(t,r,n)}function Qf(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:Math.max(64,Math.min(2048,Math.round(e)))}function ep(e,t){let r=wd(t.ids);if(r.length===0)return J("empty-selection");for(let s of r)if(!ir(e,s))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");for(let s of n){let c=ir(e,s);if(!c)return J("missing-node");if(!op(c))return J(c.protected?"node-protected":c.locked?"node-locked":"node-readonly")}if(t.placement==="root")return t.parentId!=null||t.beforeId!=null||t.afterId!=null?J("invalid-root-anchors"):Fi();let o=ir(e,t.targetId);if(!o)return J("missing-target-node");if(n.includes(o.id))return J("cannot-parent-to-self");if(n.some(s=>rp(e,o.id,s)))return J("cannot-parent-to-descendant");if(t.placement==="inside"){if(!np(o))return J("target-cannot-have-children");if(t.parentId!=null&&t.parentId!==o.id)return J("invalid-parent-anchor");let s=Md(e,o.id).filter(c=>!n.includes(c));return t.beforeId&&!s.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!s.includes(t.afterId)?J("invalid-after-anchor"):Fi()}if(o.locked&&!o.protected)return J("target-node-locked");if(o.protected)return J("cannot-reorder-root");let a=ir(e,o.parentId);if(a?.locked&&!a.protected)return J("target-parent-locked");if((t.parentId??null)!==(o.parentId??null))return J("invalid-parent-anchor");let i=Md(e,o.parentId??null).filter(s=>!n.includes(s));return t.beforeId&&!i.includes(t.beforeId)?J("invalid-before-anchor"):t.afterId&&!i.includes(t.afterId)?J("invalid-after-anchor"):t.placement==="before"&&t.beforeId!==o.id?J("invalid-before-anchor"):t.placement==="after"&&t.afterId!==o.id?J("invalid-after-anchor"):Fi()}function tp(e,t){let r=wd(t.ids);if(r.length===0)return J("empty-selection");for(let i of r)if(!ir(e,i))return J("missing-node");let n=St(e,t.ids);if(n.length===0)return J("empty-selection");if(n.length<2)return J("selection-too-small");for(let i of n){let s=ir(e,i);if(!s)return J("missing-node");if(!op(s))return J(s.protected?"node-protected":s.locked?"node-locked":"node-readonly")}let o=ir(e,t.parentId);if(t.parentId&&!o)return J("missing-parent-node");if(o&&!np(o))return J("parent-cannot-have-children");if(o&&n.some(i=>o.id===i||rp(e,o.id,i)))return J("cannot-parent-to-descendant");let a=Md(e,t.parentId??null).filter(i=>!n.includes(i));if(t.insertBeforeId){let i=ir(e,t.insertBeforeId);if(!a.includes(t.insertBeforeId)||i?.protected)return J("invalid-before-anchor")}return Fi()}function ir(e,t){return t?e.find(r=>r.id===t)??null:null}function wd(e){let t=[],r=new Set;for(let n of e)!n||r.has(n)||(r.add(n),t.push(n));return t}function St(e,t){let r=wd(t).filter(o=>!!ir(e,o)),n=new Set(r);return r.filter(o=>!Ix(e,o).some(a=>n.has(a)))}function Md(e,t){return e.filter(r=>(r.parentId??null)===(t??null)).map(r=>r.id)}function rp(e,t,r){let n=new Map(e.map(i=>[i.id,i])),o=n.get(t)??null,a=new Set;for(;o?.parentId;){if(o.parentId===r)return!0;if(a.has(o.parentId))return!1;a.add(o.parentId),o=n.get(o.parentId)??null}return!1}function np(e){return!e||e.locked&&!e.protected?!1:e.canHaveChildren===!0}function op(e){return!!e&&e.protected!==!0&&e.locked!==!0&&e.draggable!==!1}function Ix(e,t){let r=new Map(e.map(i=>[i.id,i])),n=[],o=new Set,a=r.get(t)??null;for(;a?.parentId&&!o.has(a.parentId);)o.add(a.parentId),n.push(a.parentId),a=r.get(a.parentId)??null;return n}function Fi(){return{ok:!0}}function J(e){return{ok:!1,reason:e}}var yt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),Qr={kind:"texture"},ap={kind:"color"},Px={kind:"enum",values:["lit","unlit"]},Tx={kind:"enum",values:["opaque","mask","blend"]},cp={lightingModel:Px,baseColor:{kind:"object",properties:{color:ap,texture:Qr,brightness:yt(0),saturation:yt(0),contrast:yt(0),hue:yt(-180,180)}},normal:{kind:"object",properties:{texture:Qr,strength:yt(0)}},emission:{kind:"object",properties:{color:ap,intensity:yt(0),texture:Qr,maskTexture:Qr}},alpha:{kind:"object",properties:{mode:Tx,opacity:yt(0,1),cutoff:yt(0,1),texture:Qr}}},xx={kind:"object",properties:{...cp,metallic:yt(0,1),roughness:yt(0,1),metallicRoughness:{kind:"object",properties:{texture:Qr}},occlusion:{kind:"object",properties:{texture:Qr,strength:yt(0)}}}},Ax={kind:"object",properties:cp},Dx={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}},Mx={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}},ip=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],en={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},dp=[Xn("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Xn("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),Yn("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),ht("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),ht("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[Jn("properties.baseColor.texture.textureAssetId","baseTexture")]}),Yn("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[en]),ht("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[en,Jn("properties.normal.texture.textureAssetId","normalTexture")]}),Xn("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),ht("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),Yn("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Xn("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"}),ht("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),ht("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),Yn("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],wx=[...dp,ht("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[en]}),ht("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[en]}),Yn("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[en]),Yn("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[en]),ht("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[en,Jn("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],kx=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:xx,defaultProperties:Dx,inspector:{sections:ip,fields:wx}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Ax,defaultProperties:Mx,inspector:{sections:ip,fields:dp}}],Mr=Ox(kx);function Ox(e){let t=new Map;for(let n of e){Cx(n,t);let o=vx(n);t.set(n.shaderId,mp(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Od(e,t=Mr){return t.get(e)}function De(e){return Od(e)}function Rx(e,t,r=Mr){let n=Cd(t);return r.get(e)?.inspector.fields.find(a=>a.path===n)??null}function Zn(e,t,r=Mr){let n=Od(e,r);if(!n)return null;let o=Rx(e,t,r),i=(o?.schemaPath??Cd(t)).replace(/^properties\./,"").split(".").filter(Boolean);if(i.length===0)return null;let s=n.propertiesSchema;for(let c=0;c<i.length;c+=1){let d=i[c];if(s.kind==="texture"&&c===i.length-1&&(d==="url"||d==="textureAssetId"))return{kind:"string",nullable:!0};if(s.kind!=="object")return null;let u=s.properties[d];if(!u)return null;s=u}return o?.control==="texture"&&s.kind==="texture"?{kind:"string",nullable:!0}:s}function Rd(e){let t=De(e);if(!t)throw new Error(`Unknown built-in material shader: ${e}`);return structuredClone(t.defaultProperties)}function Qn(e,t,r="properties",n=Mr){let o=Od(e,n);if(!o)return[{path:"shaderId",message:`Unknown material shader: ${String(e)}`}];let a=[];return vd(o.propertiesSchema,t,r,a),a}function Xn(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function ht(e,t,r,n,o,a,i={}){return Xn(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function Yn(e,t,r,n,o,a,i,s){return Xn(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function Jn(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Cx(e,t){if(!Hn(e.shaderId)&&!Qo(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(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!jx(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);lp(e.shaderId,e.propertiesSchema,"properties");let r=[];if(vd(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);Gx(e,a),o.add(a.path)}}function vx(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=up(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function Gx(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=up(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function lp(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))lp(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function jx(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function Cd(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function up(e,t){let r=Cd(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function vd(e,t,r,n){if(e.kind==="object"){if(!kd(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&vd(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];sp(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){sp(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!kd(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function sp(e,t,r,n,o){if(!kd(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function mp(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))mp(t)}return e}function kd(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function eo(e,t={}){let r=new Map;for(let n of t.builtInMarkerTypes??[])r.set(n.type,Fx(n));for(let n of ea(e)){let o=r.get(n.type)??null;r.set(n.type,_x(o,n))}return[...r.values()]}function jd(e){return structuredClone(e)}function Fx(e){return{...jd(e),metadata:{...e.metadata??{},builtIn:!0}}}function _x(e,t){let r=e??null;return{...r??{},...jd(t),type:t.type,label:t.label||r?.label||t.type,metadata:{...r?.metadata??{},...t.metadata??{},builtIn:r?.metadata?.builtIn===!0}}}function $x(e,t,r={}){if(!bp(t)||_d(t.type,r))return e;let n=ea(e);return n.some(o=>o.type===t.type)?e:Fd(e,[...n,Nd(t,!1)])}function Lx(e,t,r,n={}){let o=t.trim();if(!o)return e;let a=_d(o,n),i=ea(e),s=i.find(u=>u.type===o)??null;if(!a&&!s)return e;let c=s??a;if(!c)return e;let d=Nd({...c,...r,type:o,label:typeof r.label=="string"&&r.label.trim()?r.label.trim():c.label||o},!!a);return Fd(e,[...i.filter(u=>u.type!==o),d])}function zx(e,t,r={}){let n=t.trim();if(!n||Sp(n,r)||e.markers.some(i=>i.markerType===n))return e;let o=ea(e),a=o.filter(i=>i.type!==n);return a.length===o.length?e:Fd(e,a)}function Nd(e,t){return{type:e.type.trim(),label:e.label.trim()||e.type.trim(),...e.kind?{kind:e.kind}:{},...e.description!==void 0?{description:e.description}:{},...e.defaultTags?{defaultTags:[...e.defaultTags]}:{},metadata:{...e.metadata??{},builtIn:!1,...t?{overridesBuiltIn:!0}:{}}}}function ea(e){let t=e?.metadata?.markerTypes;return Array.isArray(t)?t.map(Bx).filter(r=>!!r):[]}function Fd(e,t){let r=e.metadata?structuredClone(e.metadata):{};return t.length===0?delete r.markerTypes:r.markerTypes=t.map(jd),{...e,metadata:Object.keys(r).length>0?r:void 0}}function Bx(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.type!="string"||!t.type.trim()||typeof t.label!="string"||!t.label.trim()?null:Nd({type:t.type.trim(),label:t.label.trim(),...typeof t.kind=="string"&&t.kind?{kind:t.kind}:{},...typeof t.description=="string"?{description:t.description}:{},...Array.isArray(t.defaultTags)?{defaultTags:t.defaultTags.filter(r=>typeof r=="string")}:{},...t.metadata&&typeof t.metadata=="object"?{metadata:t.metadata}:{}},t.metadata?.overridesBuiltIn===!0)}function bp(e){return!!e.type.trim()&&!!e.label.trim()}function _d(e,t={}){let r=e.trim();return t.builtInMarkerTypes?.find(n=>n.type===r)??null}function Sp(e,t={}){return!!_d(e,t)}function sr(e){let{spatial:t,...r}=structuredClone(e);return r}function _i(e){return structuredClone(e)}function yp(e,t){return{..._i(e),from:fp(e.from,t),to:fp(e.to,t)}}function hp(e,t){return{...sr(e),...e.target?{target:Gd(e.target,t)}:{},geometry:Vx(e.geometry,t)}}function Vx(e,t){switch(e.kind){case"point":return{...structuredClone(e),...e.target?{target:Gd(e.target,t)}:{}};case"object-bounds":return{...structuredClone(e),target:Gd(e.target,t)};case"box":case"polyhedron":return structuredClone(e)}}function Gd(e,t){return e.kind!=="marker"?structuredClone(e):{...structuredClone(e),id:t.get(e.id)??e.id}}function fp(e,t){return e.kind!=="marker"?{...e}:{...e,id:t.get(e.id)??e.id}}function Ep(e,t){let r=new Set([t]),n=!0;for(;n;){n=!1;for(let o of e.scene.gameObjects)!o.parentId||!r.has(o.parentId)||r.has(o.id)||(r.add(o.id),n=!0)}return r}function $d(e,t){return(e.kind==="marker"||e.kind==="scene-object")&&t.has(e.id)}function ta(e,t){return!e||e.kind!=="scene-object"||t.has(e.id)}function Ld(e,t,r){return e.kind==="marker"?r.has(e.id):e.kind==="scene-object"?t.has(e.id):!0}function pp(e,t){return e.kind==="marker"&&e.id===t}function cr(e){if(!e)return{schemaVersion:1,markers:[],relations:[]};let t=structuredClone(e),{metadata:r,...n}=t;return{...n,schemaVersion:1,markers:e.markers.map(sr),relations:e.relations.map(_i),...r?{metadata:structuredClone(r)}:{}}}function zd(e,t){return{...e,scene:{...e.scene,markerGraph:t}}}function Ux(e,t){let r=sr(t),n=e.markers.some(o=>o.id===r.id);return{...e,markers:n?e.markers.map(o=>o.id===r.id?r:o):[...e.markers,r]}}function Kx(e,t,r){let n=!1,o=e.markers.map(a=>a.id!==t?a:(n=!0,sr({...a,...r,id:a.id})));return n?{...e,markers:o}:e}function Hx(e,t){return{...e,markers:e.markers.filter(r=>r.id!==t),relations:e.relations.filter(r=>!pp(r.from,t)&&!pp(r.to,t))}}function gp(e,t){let r=_i(t),n=e.relations.some(o=>o.id===r.id);return{...e,relations:n?e.relations.map(o=>o.id===r.id?r:o):[...e.relations,r]}}function Wx(e,t){let r=!1,n=e.relations.map(o=>o.id!==t?o:(r=!0,{..._i(o),from:{...o.to},to:{...o.from}}));return r?{...e,relations:n}:e}function Ip(e,t,r={}){switch(t.type){case"marker.create-box":return Ux(e,t.marker);case"marker.update":return Kx(e,t.markerId,t.patch);case"marker.delete":return Hx(e,t.markerId);case"relation.create":return gp(e,t.relation);case"relation.create-many":return t.relations.reduce((n,o)=>gp(n,o),e);case"relation.delete":return{...e,relations:e.relations.filter(n=>n.id!==t.relationId)};case"relation.delete-many":{let n=new Set(t.relationIds);return{...e,relations:e.relations.filter(o=>!n.has(o.id))}}case"relation.reverse":return Wx(e,t.relationId);case"marker.sync-from-scene":return e;case"marker-type.create":return $x(e,t.definition,r);case"marker-type.update":return Lx(e,t.typeId,t.patch,r);case"marker-type.delete":return zx(e,t.typeId,r)}}function Pp(e,t,r={}){if(t.type!=="marker.create-box")return t;let n=sr(t.marker),o=new Set(e.scene.gameObjects.map(i=>i.id)),a=new Set(e.scene.gameObjects.map(i=>(i.name??"").trim()).filter(Boolean));return o.has(n.id)&&(n.id=qx(n.id,o,r.sanitizeMarkerGameObjectId)),(!n.label.trim()||a.has(n.label.trim()))&&(n.label=Xx(n.label||n.id,a)),{...t,marker:n}}function qx(e,t,r){let o=(r??Jx)(e).replace(/-\d+$/,"")||"marker";if(!t.has(o))return o;let a=2;for(;t.has(`${o}-${a}`);)a+=1;return`${o}-${a}`}function Jx(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function Xx(e,t){let n=(e.trim()||"Marker").replace(/\s+\d+$/,"")||"Marker";if(!t.has(n))return n;let o=2;for(;t.has(`${n} ${o}`);)o+=1;return`${n} ${o}`}function Tp(e,t,r,n={}){switch(t.type){case"marker.create-box":return Yx(e,t.marker.geometry)&&!!t.marker.id.trim()&&!e.scene.gameObjects.some(o=>o.id===t.marker.id)&&Zx(e,t.parentId??null,n);case"relation.create-many":return t.relations.length>0;case"relation.delete-many":return t.relationIds.length>0;case"relation.reverse":return r.relations.some(o=>o.id===t.relationId);case"marker-type.create":return bp(t.definition)&&!eo(e.scene.markerGraph,n).some(o=>o.type===t.definition.type);case"marker-type.update":return!!t.typeId.trim()&&eo(e.scene.markerGraph,n).some(o=>o.type===t.typeId);case"marker-type.delete":{let o=t.typeId.trim();return!o||Sp(o,n)?!1:!r.markers.some(a=>a.markerType===o)&&ea(r).some(a=>a.type===o)}default:return!0}}function Yx(e,t){switch(t.kind){case"box":case"point":return!0;case"object-bounds":return ta(t.target,new Set(e.scene.gameObjects.map(r=>r.id)));case"polyhedron":return!1}}function Zx(e,t,r){if(!t)return!0;let n=e.scene.gameObjects.find(o=>o.id===t)??null;return!!n&&!(r.isMarkerGameObject?.(n)??!!n.marker)}function xp(e){switch(e.type){case"marker.create-box":return`Create marker ${e.marker.label}`;case"marker.update":return`Update marker ${e.markerId}`;case"marker.delete":return`Delete marker ${e.markerId}`;case"relation.create":return`Create relation ${e.relation.type}`;case"relation.create-many":return`Create ${e.relations.length} relations`;case"relation.delete":return`Delete relation ${e.relationId}`;case"relation.delete-many":return`Delete ${e.relationIds.length} relations`;case"relation.reverse":return`Reverse relation ${e.relationId}`;case"marker.sync-from-scene":return"Sync marker graph";case"marker-type.create":return`Create marker type ${e.definition.label}`;case"marker-type.update":return`Update marker type ${e.typeId}`;case"marker-type.delete":return`Delete marker type ${e.typeId}`}}function Ap(e){switch(e.type){case"marker.create-box":return{changedId:e.marker.id,changedIds:[e.marker.id],selectId:e.marker.id};case"marker.update":case"marker.delete":return{changedId:e.markerId,changedIds:[e.markerId]};case"relation.create":return{changedIds:[e.relation.from.id,e.relation.to.id]};case"relation.create-many":return{changedIds:[...new Set(e.relations.flatMap(t=>[t.from.id,t.to.id]))]};case"relation.delete":case"relation.delete-many":case"relation.reverse":case"marker.sync-from-scene":case"marker-type.create":case"marker-type.update":case"marker-type.delete":return{}}}function Bd(e){let t=structuredClone(e);if(t.type==="marker.create-box"&&(t.marker=sr(t.marker)),t.type==="marker.update"){let{spatial:r,...n}=t.patch;t.patch=n}return t}function ra(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Dp(e,t,r,n={}){let o=t.find(a=>a.path===r.path);if(!o)throw new Error(`Serialized property descriptor not found: ${r.path}`);if(o.readOnly===!0||typeof o.setValue!="function")throw new Error(`Serialized property is read-only: ${r.path}`);return o.setValue(e,r.value,{...n,targetId:r.targetId})}var $i="summary",Mp="body";function Et(){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function Qx(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function zi(e){let t=Cp(e);return t&&eA(t)?{mode:"matrix",matrix:t}:null}function wp(e){return tt(e)?{mode:"matrix",matrix:Jd(e.matrix)}:{...e.mode==="trs"?{mode:"trs"}:{},position:Li(e.position),rotation:Li(e.rotation),scale:Li(e.scale)}}function tt(e){return e.mode==="matrix"}function It(e){return e.mode!=="matrix"}function Bi(e){return tt(e)?{x:e.matrix[12],y:e.matrix[13],z:e.matrix[14]}:Li(e.position)}function eA(e){return!!Cp(e)&&Math.abs(e[3])<=1e-6&&Math.abs(e[7])<=1e-6&&Math.abs(e[11])<=1e-6&&Math.abs(e[15]-1)<=1e-6&&!!kp(e)}function Fe(e){if(tt(e))return Jd(e.matrix);let t=tA(e.rotation),r=t.x,n=t.y,o=t.z,a=t.w,i=r+r,s=n+n,c=o+o,d=r*i,u=r*s,l=r*c,m=n*s,f=n*c,S=o*c,g=a*i,b=a*s,y=a*c,E=e.scale.x,I=e.scale.y,P=e.scale.z;return[(1-(m+S))*E,(u+y)*E,(l-b)*E,0,(u-y)*I,(1-(d+S))*I,(f+g)*I,0,(l+b)*P,(f-g)*P,(1-(d+m))*P,0,e.position.x,e.position.y,e.position.z,1]}function Hd(e,t){return[e[0]*t[0]+e[1]*t[4]+e[2]*t[8]+e[3]*t[12],e[0]*t[1]+e[1]*t[5]+e[2]*t[9]+e[3]*t[13],e[0]*t[2]+e[1]*t[6]+e[2]*t[10]+e[3]*t[14],e[0]*t[3]+e[1]*t[7]+e[2]*t[11]+e[3]*t[15],e[4]*t[0]+e[5]*t[4]+e[6]*t[8]+e[7]*t[12],e[4]*t[1]+e[5]*t[5]+e[6]*t[9]+e[7]*t[13],e[4]*t[2]+e[5]*t[6]+e[6]*t[10]+e[7]*t[14],e[4]*t[3]+e[5]*t[7]+e[6]*t[11]+e[7]*t[15],e[8]*t[0]+e[9]*t[4]+e[10]*t[8]+e[11]*t[12],e[8]*t[1]+e[9]*t[5]+e[10]*t[9]+e[11]*t[13],e[8]*t[2]+e[9]*t[6]+e[10]*t[10]+e[11]*t[14],e[8]*t[3]+e[9]*t[7]+e[10]*t[11]+e[11]*t[15],e[12]*t[0]+e[13]*t[4]+e[14]*t[8]+e[15]*t[12],e[12]*t[1]+e[13]*t[5]+e[14]*t[9]+e[15]*t[13],e[12]*t[2]+e[13]*t[6]+e[14]*t[10]+e[15]*t[14],e[12]*t[3]+e[13]*t[7]+e[14]*t[11]+e[15]*t[15]]}function kp(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=t*i-r*a,E=t*s-n*a,I=t*c-o*a,P=r*s-n*i,A=r*c-o*i,$=n*c-o*s,z=d*S-u*f,p=d*g-l*f,D=d*b-m*f,h=u*g-l*S,R=u*b-m*S,K=l*b-m*g,ne=y*K-E*R+I*h+P*D-A*p+$*z;if(!Number.isFinite(ne)||Math.abs(ne)<1e-6)return null;let F=1/ne;return[(i*K-s*R+c*h)*F,(n*R-r*K-o*h)*F,(S*$-g*A+b*P)*F,(l*A-u*$-m*P)*F,(s*D-a*K-c*p)*F,(t*K-n*D+o*p)*F,(g*I-f*$-b*E)*F,(d*$-l*I+m*E)*F,(a*R-i*D+c*z)*F,(r*D-t*R-o*z)*F,(f*A-S*I+b*y)*F,(u*I-d*A-m*y)*F,(i*p-a*h-s*z)*F,(t*h-r*p+n*z)*F,(S*E-f*P-g*y)*F,(d*P-u*E+l*y)*F]}function Wd(e){let t={x:e[12],y:e[13],z:e[14]},r={x:Vd(e[0],e[1],e[2]),y:Vd(e[4],e[5],e[6]),z:Vd(e[8],e[9],e[10])};if(aA(e)<=0&&(r.y*=-1),!Kd(t)||!Kd(r)||Math.abs(r.x)<1e-6||Math.abs(r.y)<1e-6||Math.abs(r.z)<1e-6)return null;let n=1/r.x,o=1/r.y,a=1/r.z,i=[e[0]*n,e[1]*n,e[2]*n,0,e[4]*o,e[5]*o,e[6]*o,0,e[8]*a,e[9]*a,e[10]*a,0,0,0,0,1];if(!iA(i))return null;let s=oA(nA(i));if(!s)return null;let c=rA(s);if(!Kd(c))return null;let d={position:t,rotation:c,scale:r};return na(Fe(d),e,1e-5)?d:null}function qd(e,t={}){let r=Wd(e);return r||(t.allowMatrixFallback?zi(e):null)}function Op(e){let t=Qx();for(let r of e)t=Hd(Fe(r),t);return qd(t,{allowMatrixFallback:!0})}function Rp(e,t){return qd(Hd(Fe(t),Fe(e)),{allowMatrixFallback:!0})}function to(e,t,r={}){let n=kp(Fe(e));return n?qd(Hd(Fe(t),n),r):null}function na(e,t,r=1e-6){return e.length===t.length&&e.every((n,o)=>Math.abs(n-t[o])<=r)}function Jd(e){return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]]}function Cp(e){return e.length!==16||!e.every(Number.isFinite)?null:Jd(e)}function Li(e){return{x:e.x,y:e.y,z:e.z}}function tA(e){let t=e.z*.5,r=e.x*.5,n=e.y*.5,o=Math.sin(t),a=Math.cos(t),i=Math.sin(r),s=Math.cos(r),c=Math.sin(n),d=Math.cos(n);return{x:d*i*a+c*s*o,y:c*s*a-d*i*o,z:d*s*o-c*i*a,w:d*s*a+c*i*o}}function rA(e){let t=e.z,r=e.x,n=e.y,o=e.w,a=n*t-r*o,i=.4999999;if(a<-i)return{x:Math.PI/2,y:2*Math.atan2(n,o),z:0};if(a>i)return{x:-Math.PI/2,y:2*Math.atan2(n,o),z:0};let s=o*o,c=t*t,d=r*r,u=n*n;return{z:Math.atan2(2*(r*n+t*o),-c-d+u+s),x:Math.asin(-2*a),y:Math.atan2(2*(t*r+n*o),c-d-u+s)}}function nA(e){let t=e[0],r=e[4],n=e[8],o=e[1],a=e[5],i=e[9],s=e[2],c=e[6],d=e[10],u=t+a+d;if(u>0){let m=.5/Math.sqrt(u+1);return{w:.25/m,x:(c-i)*m,y:(n-s)*m,z:(o-r)*m}}if(t>a&&t>d){let m=2*Math.sqrt(1+t-a-d);return{w:(c-i)/m,x:.25*m,y:(r+o)/m,z:(n+s)/m}}if(a>d){let m=2*Math.sqrt(1+a-t-d);return{w:(n-s)/m,x:(r+o)/m,y:.25*m,z:(i+c)/m}}let l=2*Math.sqrt(1+d-t-a);return{w:(o-r)/l,x:(n+s)/l,y:(i+c)/l,z:.25*l}}function oA(e){let t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w);return!Number.isFinite(t)||t<1e-6?null:{x:e.x/t,y:e.y/t,z:e.z/t,w:e.w/t}}function aA(e){let t=e[0],r=e[1],n=e[2],o=e[3],a=e[4],i=e[5],s=e[6],c=e[7],d=e[8],u=e[9],l=e[10],m=e[11],f=e[12],S=e[13],g=e[14],b=e[15],y=l*b-g*m,E=u*b-S*m,I=u*g-S*l,P=d*b-f*m,A=d*g-l*f,$=d*S-f*u,z=+(i*y-s*E+c*I),p=-(a*y-s*P+c*A),D=+(a*E-i*P+c*$),h=-(a*I-i*A+s*$);return t*z+r*p+n*D+o*h}function Vd(e,t,r){return Math.sqrt(e*e+t*t+r*r)}function iA(e){let t={x:e[0],y:e[1],z:e[2]},r={x:e[4],y:e[5],z:e[6]},n={x:e[8],y:e[9],z:e[10]};return Math.abs(Ud(t,r))<1e-6&&Math.abs(Ud(t,n))<1e-6&&Math.abs(Ud(r,n))<1e-6}function Ud(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Kd(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}var sA={supportsShear:!1,supportsMatrixTransform:!1};function Vi(e={}){let t={...sA,...e.storageCapabilities};return{allowMatrixFallback:(e.allowMatrixFallback??!1)&&t.supportsMatrixTransform&&t.supportsShear,storageCapabilities:t}}function w(e){return typeof e=="number"&&Number.isFinite(e)}function tn(e){return e==null||typeof e=="string"}function rn(e){return e==null||typeof e=="string"&&e.trim().length>0}function Ui(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Ki(e){return e==null||typeof e=="boolean"}function qe(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)&&w(t.z)}function Hi(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&w(t.y)}function oa(e){if(w(e))return e>=0;if(!e||typeof e!="object")return!1;let t=e;return w(t.x)&&t.x>=0&&w(t.y)&&t.y>=0&&w(t.z)&&t.z>=0}function Ft(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.r)&&w(t.g)&&w(t.b)}function _t(e){return w(e)&&e>0}function aa(e){return w(e)&&e>=0}function Wi(e){return w(e)&&e>=0&&e<=1}function qi(e){if(!e||typeof e!="object")return!1;let t=e;return!(t.position!==void 0&&!qe(t.position)||t.rotation!==void 0&&!qe(t.rotation)||t.rotationDeg!==void 0&&!qe(t.rotationDeg)||t.scale!==void 0&&!oa(t.scale))}function Ji(e){return e==="orthographic"||e==="perspective"}function Xi(e){return e==="hemispheric"||e==="directional"}var $t=["group","instance","transform","primitive"],vp=["instance","transform","primitive"],cA=["position","rotation","scale"],dA=["x","y","z"];function lA(e){return{path:`transform.${e}`,appliesTo:$t,validate:t=>t==null||(e==="scale"?oa(t):qe(t))}}function uA(e,t){return{path:`transform.${e}.${t}`,appliesTo:$t,...e==="scale"?{allowDelete:!1}:{},validate:r=>r==null||(e==="scale"?aa(r):w(r))}}function mA(e){return[lA(e),...dA.map(t=>uA(e,t))]}var Xd=[{path:"name",appliesTo:$t,validate:tn},{path:"parentId",appliesTo:$t,validate:tn},{path:"enabled",appliesTo:$t,validate:Ki},{path:"shadow.cast",appliesTo:vp,validate:e=>typeof e=="boolean"},{path:"shadow.receive",appliesTo:vp,validate:e=>typeof e=="boolean"},{path:"transform",appliesTo:$t,validate:e=>e==null||qi(e)},...cA.flatMap(mA),{path:"transform.rotationDeg",appliesTo:$t,validate:e=>e==null||qe(e)},{path:"transform.rotationDeg.x",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.y",appliesTo:$t,validate:e=>e==null||w(e)},{path:"transform.rotationDeg.z",appliesTo:$t,validate:e=>e==null||w(e)},{path:"instance.assetId",appliesTo:["instance"],validate:e=>typeof e=="string"&&e.trim().length>0,allowDelete:!1},{path:"primitive.shape",appliesTo:["primitive"],validate:e=>e==="cube"||e==="sphere"||e==="plane"||e==="capsule",allowDelete:!1},{path:"camera.projection",appliesTo:["transform"],validate:Ji,allowDelete:!1},{path:"camera.alpha",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.beta",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.radius",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.orthoSize",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.fov",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.targetOffset",appliesTo:["transform"],validate:e=>e==null||qe(e)},{path:"camera.targetOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetOffset.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.minZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.maxZ",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.lowerBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.upperBetaLimit",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.lowerRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.upperRadiusLimit",appliesTo:["transform"],validate:_t,allowDelete:!1},{path:"camera.inertia",appliesTo:["transform"],validate:Wi,allowDelete:!1},{path:"camera.targetScreenOffset",appliesTo:["transform"],validate:e=>e==null||Hi(e)},{path:"camera.targetScreenOffset.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"camera.targetScreenOffset.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.type",appliesTo:["transform"],validate:Xi,allowDelete:!1},{path:"light.intensity",appliesTo:["transform"],validate:aa,allowDelete:!1},{path:"light.direction",appliesTo:["transform"],validate:qe,allowDelete:!1},{path:"light.direction.x",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.y",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.direction.z",appliesTo:["transform"],validate:w,allowDelete:!1},{path:"light.diffuseColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"light.groundColor",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.type",appliesTo:["transform"],validate:tn,allowDelete:!1},{path:"marker.kind",appliesTo:["transform"],validate:rn},{path:"marker.tags",appliesTo:["transform"],validate:e=>e==null||Ui(e)},{path:"marker.note",appliesTo:["transform"],validate:tn},{path:"marker.color",appliesTo:["transform"],validate:e=>e==null||Ft(e)},{path:"marker.color.r",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.g",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1},{path:"marker.color.b",appliesTo:["transform"],validate:e=>e==null||w(e),allowDelete:!1}];var ie=["instance","transform","primitive"];function Je(e){return{path:e,appliesTo:ie,validate:t=>t==null||Ft(t)}}function V(e){return{path:e,appliesTo:ie,validate:t=>t==null||w(t)}}function Gp(e){return{path:e,appliesTo:ie,validate:t=>t==null||typeof t=="boolean"}}function le(e){return{path:e,appliesTo:ie,validate:rn}}function pA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="opaque"||t==="mask"||t==="blend"}}function gA(e){return{path:e,appliesTo:ie,validate:t=>t==null||t==="lit"||t==="unlit"}}var bA=[{path:"transformType",appliesTo:["transform"],validate:e=>e==null||typeof e=="string"},{path:"rendering.renderingGroupId",appliesTo:ie,validate:e=>e==null||e===0||e===1||e===2||e===3},{path:"rendering.alphaIndex",appliesTo:ie,validate:e=>e==null||w(e)},Je("overrides.material.albedoColor"),Je("overrides.material.diffuseColor"),Je("overrides.material.emissiveColor"),V("overrides.material.metallic"),V("overrides.material.roughness"),V("overrides.material.contrast"),V("overrides.material.brightness"),V("overrides.material.saturation"),V("overrides.material.hue"),V("overrides.material.colorDensity"),V("overrides.material.alpha"),V("overrides.material.alphaCutOff"),V("overrides.material.transparencyMode"),Gp("overrides.material.backFaceCulling"),le("overrides.material.albedoTexture.url"),le("overrides.material.normalTexture.url"),V("overrides.material.normalTexture.level"),le("overrides.material.metallicTexture.url"),le("overrides.material.occlusionTexture.url"),le("overrides.material.emissiveTexture.url"),le("overrides.material.opacityTexture.url"),Je("overrides.material.pbr.albedoColor"),V("overrides.material.pbr.baseWeight"),Je("overrides.material.pbr.reflectivityColor"),V("overrides.material.pbr.microSurface"),Je("overrides.material.pbr.emissiveColor"),Je("overrides.material.pbr.ambientColor"),V("overrides.material.pbr.lightFalloff"),V("overrides.material.pbr.directIntensity"),V("overrides.material.pbr.emissiveIntensity"),V("overrides.material.pbr.environmentIntensity"),V("overrides.material.pbr.specularIntensity"),V("overrides.material.pbr.metallicF0Factor"),V("overrides.material.pbr.indexOfRefraction"),Je("overrides.material.standard.diffuseColor"),Je("overrides.material.standard.specularColor"),V("overrides.material.standard.specularPower"),Je("overrides.material.standard.emissiveColor"),Je("overrides.material.standard.ambientColor"),Gp("overrides.material.standard.useSpecularOverAlpha"),{path:"overrides.materialBinding.materialAssetId",appliesTo:ie,validate:rn},gA("overrides.materialBinding.override.lightingModel"),Je("overrides.materialBinding.override.baseColor.color"),{path:"overrides.materialBinding.override.baseColor.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.baseColor.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},le("overrides.materialBinding.override.baseColor.texture.url"),le("overrides.materialBinding.override.baseColor.texture.textureAssetId"),V("overrides.materialBinding.override.baseColor.brightness"),V("overrides.materialBinding.override.baseColor.saturation"),V("overrides.materialBinding.override.baseColor.contrast"),V("overrides.materialBinding.override.baseColor.hue"),le("overrides.materialBinding.override.normal.texture.url"),le("overrides.materialBinding.override.normal.texture.textureAssetId"),V("overrides.materialBinding.override.normal.strength"),V("overrides.materialBinding.override.metallic"),V("overrides.materialBinding.override.roughness"),le("overrides.materialBinding.override.metallicRoughness.texture.url"),le("overrides.materialBinding.override.metallicRoughness.texture.textureAssetId"),le("overrides.materialBinding.override.occlusion.texture.url"),le("overrides.materialBinding.override.occlusion.texture.textureAssetId"),V("overrides.materialBinding.override.occlusion.strength"),Je("overrides.materialBinding.override.emission.color"),{path:"overrides.materialBinding.override.emission.color.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.materialBinding.override.emission.color.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},V("overrides.materialBinding.override.emission.intensity"),le("overrides.materialBinding.override.emission.texture.url"),le("overrides.materialBinding.override.emission.texture.textureAssetId"),le("overrides.materialBinding.override.emission.maskTexture.url"),le("overrides.materialBinding.override.emission.maskTexture.textureAssetId"),pA("overrides.materialBinding.override.alpha.mode"),V("overrides.materialBinding.override.alpha.opacity"),V("overrides.materialBinding.override.alpha.cutoff"),le("overrides.materialBinding.override.alpha.texture.url"),le("overrides.materialBinding.override.alpha.texture.textureAssetId"),{path:"overrides.outline",appliesTo:ie,validate:e=>e==null||SA(e)},{path:"overrides.outline.strategy",appliesTo:ie,validate:e=>e==null||e==="babylon-default"},{path:"overrides.outline.renderOutline",appliesTo:ie,validate:e=>e==null||typeof e=="boolean"},V("overrides.outline.outlineWidth"),{path:"overrides.outline.outlineColor",appliesTo:ie,validate:e=>e==null||Ft(e)},{path:"overrides.outline.outlineColor.r",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.g",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1},{path:"overrides.outline.outlineColor.b",appliesTo:ie,validate:e=>e==null||w(e),allowDelete:!1}],jp=[...Xd,...bA];function SA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return(t.strategy==null||t.strategy==="babylon-default")&&(t.renderOutline==null||typeof t.renderOutline=="boolean")&&(t.outlineWidth==null||w(t.outlineWidth))&&(t.outlineColor==null||Ft(t.outlineColor))}function Yd(e,t){let r=jp.find(n=>n.path===e)??null;return!r||!r.appliesTo.includes(t)?null:r}var dr="scene.materialAssets.",Zd="__fps_duplicate_material_asset__:",yA="mat_";function hA(e){return String(e??"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"")}function nn(e){let t=hA(e);return`${yA}${t||"material"}`}function Qd(){let e=globalThis.crypto?.randomUUID?.();if(e)return e;let t=Math.random().toString(36).slice(2,12);return`${Date.now().toString(36)}-${t}`}function Np(e,t=dr){if(!e.startsWith(t))return null;let r=e.slice(t.length);if(!r)return null;if(r.endsWith(".name")){let s=r.slice(0,-5);return s?{materialAssetId:s,fieldPath:"name"}:null}let n=".properties.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return!a||!i?null:{materialAssetId:a,fieldPath:`properties.${i}`}}function wr(e){return e==="overrides.materialBinding.materialAssetId"||Lt(e,"materialAssetId")!=null}function el(e){if(wr(e))return!0;let t="overrides.materialBinding.override.";if(e.startsWith(t))return Yi(`properties.${e.slice(t.length)}`);let r=EA(e);return r?Yi(`properties.${r}`):!1}function Zi(e){return e==="overrides.materialBinding.materialAssetId"||e.startsWith("overrides.materialBinding.override.")||Lt(e,"materialAssetId")!=null||Lt(e,"override")!=null}function Lt(e,t){let r="overrides.materialSlotBindings.";if(!e.startsWith(r))return null;let n=e.slice(r.length);if(t==="materialAssetId"){let c=".materialAssetId";if(!n.endsWith(c))return null;let d=n.slice(0,-c.length);return d||null}let o=".override.",a=n.lastIndexOf(o);if(a<0)return null;let i=n.slice(0,a),s=n.slice(a+o.length);return i&&s?i:null}function EA(e){let t="overrides.materialSlotBindings.";if(!e.startsWith(t))return null;let r=e.slice(t.length),n=".override.",o=r.lastIndexOf(n);if(o<0)return null;let a=r.slice(0,o),i=r.slice(o+n.length);return a&&i?i:null}function Yi(e){return e.endsWith(".texture.url")||e.endsWith(".maskTexture.url")||e.endsWith(".texture.textureAssetId")||e.endsWith(".maskTexture.textureAssetId")}function ro(e,t){if(!De(e)||!Yi(t))return!1;let r=t.endsWith(".textureAssetId")?t.slice(0,-15):t.slice(0,-4);return Zn(e,r)?.kind==="texture"}function rt(e,t){if(e==="name"&&typeof t=="string")return t.trim();if(Yi(e)&&typeof t=="string"){let r=t.trim();return r||null}return(e==="properties.alpha.mode"||e==="properties.lightingModel")&&typeof t=="string"?t.trim():t}function zt(e,t,r,n=Mr){let o=rt(e,t);if(e==="name")return typeof o=="string"&&o.length>0;let a=IA(e,r,n);return a?PA(a,o):!1}function IA(e,t,r){if(t!=null)return Zn(t,e,r);for(let n of r.list()){let o=Zn(n.shaderId,e,r);if(o)return o}return null}function PA(e,t){if(t==null)return e.kind==="texture"||e.kind==="string"&&e.nullable===!0;if(e.kind==="number")return!(!w(t)||e.min!=null&&t<e.min||e.max!=null&&t>e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"&&t.trim().length>0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return e.channels===4?xA(t):TA(t);if(e.kind==="vec2"||e.kind==="vec3"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t,n=e.kind==="vec2"?["x","y"]:["x","y","z"];return Object.keys(r).every(o=>n.includes(o))&&n.every(o=>w(r[o]))}if(e.kind==="texture"){if(!t||typeof t!="object"||Array.isArray(t))return!1;let r=t;return Object.keys(r).every(n=>n==="url"||n==="textureAssetId")&&["url","textureAssetId"].every(n=>r[n]===void 0||typeof r[n]=="string"&&r[n].trim().length>0)}return!1}function Qi(e){return typeof e!="string"||!e.startsWith(Zd)?null:e.slice(Zd.length).trim()||null}function Fp(e){return e.trim().replace(/^\/+|\/+$/g,"")}function TA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b")&&w(t.r)&&w(t.g)&&w(t.b)}function xA(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(r=>r==="r"||r==="g"||r==="b"||r==="a")&&w(t.r)&&w(t.g)&&w(t.b)&&w(t.a)}var AA={r:.78,g:.78,b:.78};function Bt(e,t={}){let r=e??{},n=wA(r.baseColor?.texture,t),o=MA(r,t),a=DA(r,t);return{kind:"material-sphere",baseColor:kA(r),metallic:ia(r.metallic??0),roughness:ia(r.roughness??1),...r.emission?.color?{emissionColor:Lp(r.emission.color)}:{},emissionIntensity:OA(r.emission?.intensity,0),textureUrl:n,profile:o,properties:structuredClone(e??{}),...a.length>0?{textureResources:a}:{}}}function DA(e,t){return[["baseColor",e.baseColor?.texture],["normal",e.normal?.texture],["metallicRoughness",e.metallicRoughness?.texture],["occlusion",e.occlusion?.texture],["emission",e.emission?.texture],["emissionMask",e.emission?.maskTexture],["alpha",e.alpha?.texture]].flatMap(([n,o])=>{let a=tl(o,t);return a?[{channel:n,...a}]:[]})}function MA(e,t){let r=structuredClone(e),n=on(r.baseColor?.texture,t);n&&(r.baseColor={...r.baseColor??{},texture:n});let o=on(r.normal?.texture,t);o&&(r.normal={...r.normal??{},texture:o});let a=on(r.metallicRoughness?.texture,t);a&&(r.metallicRoughness={...r.metallicRoughness??{},texture:a});let i=on(r.occlusion?.texture,t);i&&(r.occlusion={...r.occlusion??{},texture:i});let s=on(r.emission?.texture,t),c=on(r.emission?.maskTexture,t);(s||c)&&(r.emission={...r.emission??{},...s?{texture:s}:{},...c?{maskTexture:c}:{}});let d=on(r.alpha?.texture,t);return d&&(r.alpha={...r.alpha??{},texture:d}),r}function on(e,t){if(!e)return;let r=tl(e,t);if(r?.state==="missing")return{...e,url:null};let n=r?.url;return{...e,...n?{url:n}:{}}}function wA(e,t){let r=tl(e,t);return r?.state==="ready"?r.url:void 0}function tl(e,t){let r=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";if(r){let o=t.resolveTextureAssetUrl?.(r)?.trim();if(o)return{reference:r,state:"ready",url:o};let a=t.textureAssets?.find(i=>i.id===r)?.url?.trim();if(a)return{reference:r,state:"ready",url:a};if(t.resolveTextureAssetUrl||Array.isArray(t.textureAssets))return{reference:r,state:"missing"}}let n=typeof e?.url=="string"?e.url.trim():"";return n?{reference:r||n,state:"ready",url:n}:null}function $p(e,t){let r=e??{},n=_p(r.metallic??0),o=_p(r.roughness??1);return`M ${n} / R ${o} - ${t}`}function kA(e){let r=(e.baseColor??{}).color??AA;return Lp(r)}function Lp(e){return{r:ia(e.r),g:ia(e.g),b:ia(e.b)}}function ia(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function _p(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,"").replace(/\.$/,""):"0"}function OA(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function ee(e,t){return t?e.scene.materialAssets?.find(r=>r.id===t)??null:null}function Vt(e,t){return!!ee(e,t)}function qp(e,t){return t?{state:"asset",materialAssetId:t.id,materialAsset:t}:e?.materialAssetId?{state:"missing-asset",materialAssetId:e.materialAssetId}:e?.override?{state:"override"}:{state:"inherit"}}function sa(e,t){let r=new Set;for(let n of rl(e,t))r.add(n.gameObjectId);return[...r]}function rl(e,t){let r=t.trim();return r?an(e).filter(n=>n.materialAssetId===r):[]}function an(e){let t=[],r=new Map(e.assets.map(n=>[n.id,n]));for(let n of e.scene.gameObjects){let o=_A(n),a=es(n.overrides?.materialBinding);a&&t.push({kind:"root",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:a,bindingPath:"overrides.materialBinding.materialAssetId",label:o});let i=lr(e,n,r),s=new Map(i.filter(d=>!!d.slotId).map(d=>[d.slotId,d])),c=n.overrides?.materialSlotBindings??{};for(let[d,u]of Object.entries(c)){let l=es(u);if(!l)continue;let m=s.get(d),f=$A(m,d);t.push({kind:"slot",scope:"scene",gameObjectId:n.id,gameObjectName:n.name,materialAssetId:l,bindingPath:`overrides.materialSlotBindings.${d}.materialAssetId`,label:`${o} / ${f}`,slotId:d,ownerNodePath:Ut(m)??d})}}for(let n of e.assets)if(!(n.type!=="prefab"||!n.prefab)){zp(t,{ownerId:n.id,ownerName:n.displayName??n.id,prefabAssetId:n.id,path:`assets.${n.id}.prefab.overrides`,overrides:n.prefab.overrides});for(let o of n.prefab.nodes??[])zp(t,{ownerId:`${n.id}:${o.id}`,ownerName:`${n.displayName??n.id} / ${o.name??o.id}`,prefabAssetId:n.id,prefabNodeId:o.id,path:`assets.${n.id}.prefab.nodes.${o.id}.overrides`,overrides:o.overrides})}return t}function zp(e,t){let r=es(t.overrides?.materialBinding);r&&e.push({kind:"root",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:r,bindingPath:`${t.path}.materialBinding.materialAssetId`,label:t.ownerName,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}});for(let[n,o]of Object.entries(t.overrides?.materialSlotBindings??{})){let a=es(o);a&&e.push({kind:"slot",scope:"prefab",gameObjectId:t.ownerId,gameObjectName:t.ownerName,materialAssetId:a,bindingPath:`${t.path}.materialSlotBindings.${n}.materialAssetId`,label:`${t.ownerName} / ${n}`,slotId:n,ownerNodePath:n,prefabAssetId:t.prefabAssetId,...t.prefabNodeId?{prefabNodeId:t.prefabNodeId}:{}})}}function rs(e){let t=[...new Set((e.scene.materialAssets??[]).map(s=>s.id?.trim()).filter(s=>!!s))],r=new Set(t),n=an(e),o=n.filter(s=>!r.has(s.materialAssetId)),a=new Map;for(let s of o){let c=a.get(s.materialAssetId)??[];c.push(s),a.set(s.materialAssetId,c)}let i=[...a.entries()].map(([s,c])=>({kind:"missing-material-asset",materialAssetId:s,usages:c}));return{ok:i.length===0,materialAssetIds:t,references:n,missingMaterialAssetIds:i.map(s=>s.materialAssetId),missingReferences:o,issues:i}}function lr(e,t,r){let n=new Map;for(let o of os(e,t,r))n.set(o.slotId,o);return[...n.values()].sort((o,a)=>(o.label??o.slotId).localeCompare(a.label??a.slotId)||o.slotId.localeCompare(a.slotId))}function Jp(e,t){return os(e,t).length>0}function nt(e){return[...new Set(e.sourceSurfaces.map(t=>t.sourceMaterialIndex).filter(t=>Number.isInteger(t)))].sort((t,r)=>t-r)}function Ut(e){return e?.sourceSurfaces[0]?.ownerNodePath??null}function Xp(e){return e.slotId}function ns(e){return`overrides.materialSlotBindings.${e.slotId}.materialAssetId`}function nl(e,t){return e.overrides?.materialSlotBindings?.[t.slotId]}function Yp(e){let t=Zp(e);if(!t)return;let r={},n=FA(t.materialAssetId);return n&&(r.materialAssetId=n),t.override&&typeof t.override=="object"&&!Array.isArray(t.override)&&(r.override=t.override),Object.keys(r).length>0?r:void 0}function os(e,t,r){let n=ue(t);if(!n)return[];let a=(r?.get(n.assetId)??e.assets.find(s=>s.id===n.assetId))?.metadata?.materialSlots;if(!Array.isArray(a))return[];let i=[];for(let s of a){let c=no(s);c&&i.push(c)}return i}function no(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.slotId=="string"&&t.slotId.trim()?t.slotId.trim():"",n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces:null,o=RA(n);if(!r||!n||o.length===0||o.length!==n.length)return null;let a=typeof t.label=="string"&&t.label.trim()?t.label.trim():o[0].ownerNodePath,i=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",s=Array.isArray(t.materialNames)?t.materialNames.filter(d=>typeof d=="string"&&!!d.trim()).map(d=>d.trim()):void 0,c=vA(t.sourceMaterialProfiles);return{slotId:r,label:a,sourceSurfaces:o,...i?{materialName:i}:{},...s&&s.length>0?{materialNames:s}:{},...c&&c.length>0?{sourceMaterialProfiles:c}:{}}}function RA(e){return Array.isArray(e)?e.flatMap(t=>{let r=Zp(t);if(!r)return[];let n=Fp(typeof r.ownerNodePath=="string"?r.ownerNodePath:""),o=Number.isInteger(r.meshIndex)&&r.meshIndex>=0?r.meshIndex:void 0,a=Number.isInteger(r.primitiveIndex)&&r.primitiveIndex>=0?r.primitiveIndex:void 0;if(!n||o==null||a==null)return[];let i=Number.isInteger(r.nodeIndex)&&r.nodeIndex>=0?r.nodeIndex:void 0,s=Array.isArray(r.nodeIndexPath)?r.nodeIndexPath.filter(m=>Number.isInteger(m)&&m>=0):void 0,c=Number.isInteger(r.sourceMaterialIndex)&&r.sourceMaterialIndex>=0?r.sourceMaterialIndex:void 0,d=typeof r.sourceMeshName=="string"&&r.sourceMeshName.trim()?r.sourceMeshName.trim():void 0,u=typeof r.triangleCount=="number"&&Number.isFinite(r.triangleCount)&&r.triangleCount>=0?r.triangleCount:void 0,l=CA(r.boundingBox);return[{ownerNodePath:n,...i!=null?{nodeIndex:i}:{},...s&&s.length>0?{nodeIndexPath:s}:{},meshIndex:o,primitiveIndex:a,...c!=null?{sourceMaterialIndex:c}:{},...d?{sourceMeshName:d}:{},...u!=null?{triangleCount:u}:{},...l?{boundingBox:l}:{}}]}):[]}function CA(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=Bp(t.min),n=Bp(t.max);if(!(!r&&!n))return{...r?{min:r}:{},...n?{max:n}:{}}}function Bp(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return typeof t=="number"&&Number.isFinite(t)&&typeof r=="number"&&Number.isFinite(r)&&typeof n=="number"&&Number.isFinite(n)?[t,r,n]:null}function vA(e){if(!Array.isArray(e))return;let t=e.map(GA).filter(r=>!!r);return t.length>0?t:void 0}function GA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(!Number.isInteger(t.sourceMaterialIndex))return null;let r=typeof t.materialName=="string"&&t.materialName.trim()?t.materialName.trim():"",n=t.profile&&typeof t.profile=="object"&&!Array.isArray(t.profile)?t.profile:void 0,o=jA(t.textureHints);return{sourceMaterialIndex:t.sourceMaterialIndex,...r?{materialName:r}:{},...n?{profile:n}:{},...o&&o.length>0?{textureHints:o}:{}}}function jA(e){if(!Array.isArray(e))return;let t=e.map(NA).filter(r=>!!r);return t.length>0?t:void 0}function NA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=typeof t.profilePath=="string"&&t.profilePath.trim()?t.profilePath.trim():"",n=typeof t.reason=="string"&&t.reason.trim()?t.reason.trim():"";return!r||!n?null:{profilePath:r,reason:n,...Number.isInteger(t.textureIndex)?{textureIndex:t.textureIndex}:{},...Number.isInteger(t.imageIndex)?{imageIndex:t.imageIndex}:{},...Number.isInteger(t.bufferView)?{bufferView:t.bufferView}:{},...typeof t.mimeType=="string"&&t.mimeType.trim()?{mimeType:t.mimeType.trim()}:{},...typeof t.uri=="string"&&t.uri.trim()?{uri:t.uri.trim()}:{}}}function Zp(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function FA(e){return typeof e=="string"&&e.trim()?e.trim():null}function _A(e){return e.name?.trim()||e.id}function es(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function $A(e,t){return e?.label?.trim()||Ut(e)?.trim()||e?.slotId?.trim()||t}var ts=class{constructor(t){this.byMaterialId=new Map;this.byOwnerId=new Map;for(let r of an(t)){let n=this.byMaterialId.get(r.materialAssetId)??[];n.push(r),this.byMaterialId.set(r.materialAssetId,n);let o=this.byOwnerId.get(r.gameObjectId)??[];o.push(r),this.byOwnerId.set(r.gameObjectId,o)}}forMaterial(t){return this.byMaterialId.get(t.trim())??[]}forOwner(t){return this.byOwnerId.get(t)??[]}},Vp=new WeakMap;function LA(e){let t=Vp.get(e);return t||(t=new ts(e),Vp.set(e,t)),t}function ol(e){return e?.system?.preset}function Up(e,t){let r=ol(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Kp(e,t){let r=ol(e);return r==="default-pbr"?t.defaultMaterialMeta:r==="default-standard"?t.defaultStandardMaterialMeta:t.formatMaterialMeta(e.id)}function zA(e,t){let r=e.currentAsset??null,n=!!r&&!e.currentValue,o=r&&!n?Hp(e.document,r.id,e.ownershipText,t):null,a=r?Kp(r,e.displayText):e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.summaryInherit,i=o?Wp(a,o):a;return{pickerKind:"material",pickerTitle:e.pickerText.materialPickerTitle,pickerTrigger:"preview",placeholder:e.currentValue?e.pickerText.summaryMissingAsset:e.pickerText.inheritNone,...r?{currentMaterialAssetId:r.id,currentMaterialShaderId:r.shaderId,...r.definitionVersion!=null?{currentMaterialDefinitionVersion:r.definitionVersion}:{}}:{},currentLabel:r?Up(r,e.displayText):e.currentValue?e.currentValue:e.pickerText.inheritNone,currentMeta:i,...o?.usageLabel?{currentUsageLabel:o.usageLabel}:{},...o?.editImpactLabel?{currentEditImpactLabel:o.editImpactLabel}:{},...o?{currentOwnership:o}:{},currentPreview:r?Bt(r.properties,e.previewContext):void 0,candidates:[{label:e.pickerText.inheritNone,value:"",meta:e.pickerText.summaryInherit},...e.materialAssets.map(s=>{let c=Hp(e.document,s.id,e.ownershipText,t);return{label:Up(s,e.displayText),value:s.id,meta:Wp(Kp(s,e.displayText),c),kind:"material",preview:Bt(s.properties,e.previewContext),...c?.usageLabel?{usageLabel:c.usageLabel}:{},...c?{ownership:c}:{}}})]}}function Hp(e,t,r,n){if(!e||!n)return null;let o=t.trim(),a=n.forMaterial(o),i=a.length;return{materialAssetId:o,usage:{count:i,items:a.map(s=>structuredClone(s))},usageCount:i,used:i>0,shared:i>1,...r?{usageLabel:r.formatUsageCount(i),editImpactLabel:r.formatEditImpact(i),duplicateImpactLabel:r.formatDuplicateImpact(i)}:{}}}function Wp(e,t){return[e,t?.usageLabel].filter(Boolean).join(" \xB7 ")}function BA(e,t,r={}){return(e.scene.materialAssets??[]).map(n=>{let o=t.forMaterial(n.id);return{id:`material:${n.id}`,assetId:n.id,kind:"material",label:n.name||n.id,meta:$p(n.properties,n.id),preview:Bt(n.properties,r),material:{id:n.id,name:n.name||n.id,shaderId:n.shaderId,...n.definitionVersion!=null?{definitionVersion:n.definitionVersion}:{},readonly:n.system?.readonly===!0||ol(n)!=null,usage:{count:o.length,items:o.map(a=>structuredClone(a))},properties:structuredClone(n.properties)},placeable:!1}})}var VA={createUsageIndex(e){return new ts(e)},getCachedUsageIndex:LA,createPickerControlOptions:zA,createBrowserAssetItems:BA},_e=VA;var sn=1;var il="prefab.";function da(e){let t=structuredClone(e),r={ordinaryObjects:0,prefabRoots:0,discardedFields:0},n=$e(t.scene);return n&&(Me(n,"shadowMapExperiment",r),Array.isArray(n.gameObjects)&&n.gameObjects.forEach(o=>UA(o,r))),Array.isArray(t.assets)&&t.assets.forEach(o=>KA(o,r)),{document:t,summary:r}}function dn(e){let t=$e(e);return!t||t.prefab!=null||t.transformType==="camera"||t.transformType==="light"||t.camera!=null||t.light!=null?!1:t.kind==="primitive"||$e(t.primitive)?!0:Array.isArray(t.components)&&t.components.some(r=>{let n=$e(r)?.type;return n==="ModelRenderer"||n==="ImageRenderer"})}function UA(e,t){let r=$e(e);if(!r)return;let n=$e(r.shadow);Me(r,"shadowMode",t),Me(r,"shadowMapExperiment",t),dn(r)?(r.shadow=eg(n),t.ordinaryObjects+=1):Me(r,"shadow",t)}function KA(e,t){let r=$e(e);if(!r)return;let n=$e(r.defaults);n&&(Me(n,"shadowMode",t),Me(n,"shadow",t),Me(n,"shadowMapExperiment",t));let o=$e(r.prefab);if(!o)return;let a=$e(o.defaults);a&&Me(a,"shadowMode",t),o.defaults={...a??{},shadow:eg(a?.shadow)},t.prefabRoots+=1;let i=$e(o.defaults);if(Me(i,"shadowMapExperiment",t),Array.isArray(o.nodes))for(let s of o.nodes){let c=$e(s);if(!c)continue;Me(c,"shadowMode",t),Me(c,"shadow",t),Me(c,"shadowMapExperiment",t);let d=$e(c.defaults);d&&(Me(d,"shadowMode",t),Me(d,"shadow",t),Me(d,"shadowMapExperiment",t))}}function eg(e){let t=$e(e);return{cast:t?.cast==="enabled"?"enabled":"none",receive:t?.receive==="enabled"?"enabled":"none"}}function Me(e,t,r){Object.prototype.hasOwnProperty.call(e,t)&&(delete e[t],r.discardedFields+=1)}function $e(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}var zF=Symbol("unsupported-editor-scene-authored-clone-value");function G(e){return e.components.find(JA)??null}function ue(e){return e.components.find(XA)??null}function kr(e){return e.components.find(YA)??null}function Xe(e){return e?.type==="prefab"&&te(e.prefab?.sourceAssetId)!=null}function Le(e,t){let r=e.assets.find(n=>n.id===t);return r&&Xe(r)?r:null}function as(e){return te(e?.prefab?.prefabId)!=null}function ca(e){return te(e?.prefab?.sourceAssetId)}function Ye(e){if(!e?.prefab)return null;let t=cl(e.prefab),r=te(e.prefab.rootNodeId);if(r&&t.some(o=>o.id===r))return r;let n=t.find(o=>o.kind==="root"&&!o.parentId);return n?n.id:null}function Ze(e){return e?.prefab?cl(e.prefab):[]}function oo(e,t){let r=te(t);return r?Ze(e).find(n=>n.id===r)??null:null}function sl(e,t){let r=te(t);return Ze(e).filter(n=>{let o=te(n.parentId);return r?o===r:!o})}function tg(e){if(!Xe(e))return al(e,!1,null,[{code:"prefab.invalidDefinition",severity:"error",message:`Asset "${e.id}" is not a valid prefab definition.`,assetId:e.id}]);let t=cl(e.prefab),r=Ye(e);if(e.prefab.compositionVersion!==sn||t.length===0||!r)return al(e,!1,null,[{code:"schema.unsupportedVersion",severity:"error",message:`Prefab asset "${e.id}" must use composition version ${sn} with an explicit root node.`,assetId:e.id}]);let n=HA(e);return al(n,JSON.stringify(n.prefab)!==JSON.stringify(e.prefab))}function al(e,t,r=null,n=[],o={}){return{ok:n.every(a=>a.severity!=="error"),changed:t,prefabAsset:e,...o.selectedNodeId?{selectedNodeId:o.selectedNodeId}:{},...o.createdNodeId?{createdNodeId:o.createdNodeId}:{},...o.deletedNodeIds?{deletedNodeIds:[...o.deletedNodeIds]}:{},...r?{node:structuredClone(r)}:{},diagnostics:n.map(a=>({...a}))}}function HA(e){let t=structuredClone(e),r=Ze(e);t.prefab=structuredClone(t.prefab),t.prefab.compositionVersion=sn,t.prefab.nodes=r;let n=Ye({...e,prefab:{...e.prefab,nodes:r}});return n?t.prefab.rootNodeId=n:delete t.prefab.rootNodeId,t}function cl(e){if(!Array.isArray(e.nodes))return[];let t=[];for(let r of e.nodes){let n=WA(r);n&&!t.some(o=>o.id===n.id)&&t.push(n)}return structuredClone(t)}function WA(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=te(t.id);return!r||!qA(t.kind)?null:{id:r,...te(t.guid)?{guid:te(t.guid)}:{},...te(t.name)?{name:te(t.name)}:{},...te(t.parentId)?{parentId:te(t.parentId)}:{},kind:t.kind,...t.transform?{transform:structuredClone(t.transform)}:{},...te(t.sourceAssetId)?{sourceAssetId:te(t.sourceAssetId)}:{},...te(t.sourceNodePath)?{sourceNodePath:te(t.sourceNodePath)}:{},...te(t.childPrefabId)?{childPrefabId:te(t.childPrefabId)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.light?{light:structuredClone(t.light)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults?{defaults:structuredClone(t.defaults)}:{},...t.overrides?{overrides:structuredClone(t.overrides)}:{},...t.metadata?{metadata:structuredClone(t.metadata)}:{}}}function qA(e){return e==="root"||e==="group"||e==="model"||e==="primitive"||e==="light"||e==="prefabInstance"||e==="marker"||e==="collision"}function rg(e){let t=ca(e.prefabAsset);if(!t)throw new Error(`Prefab asset "${e.prefabAsset.id}" does not define a source asset.`);let r=e.prefabAsset.prefab?.defaults;return{id:e.id,...e.guid?{guid:e.guid}:{},name:e.name??e.prefabAsset.displayName??e.prefabAsset.id,kind:"instance",...e.parentId?{parentId:e.parentId}:{},active:e.active??r?.active??!0,prefab:{prefabId:e.prefabAsset.id,...e.prefabAsset.guid?{prefabGuid:e.prefabAsset.guid}:{},sourceAssetId:t},...e.metadata?{metadata:{...e.metadata}}:{},...e.overrides!==void 0?{overrides:e.overrides}:{},components:[e.transform,{type:"ModelRenderer",assetId:t}]}}function ng(e){if(!e.startsWith(il))return null;let t=e.slice(il.length);return Zi(t)?t:null}function dl(e){return ng(e)?.endsWith(".materialAssetId")===!0}function og(e){return e.startsWith(il)&&e.endsWith(".materialAssetId")&&dl(e)}function ag(e,t){if(t.slotId)return Yp(e.prefab?.overrides?.materialSlotBindings?.[t.slotId])}function la(e,t,r){let n=ng(t);if(!n||!Xe(e))return e;let o=QA(n);if(!o)return e;let a=structuredClone(e);a.prefab=structuredClone(a.prefab??e.prefab),tD(a.prefab,o,r);let i=lg(a.prefab?.overrides);return i?a.prefab.overrides=i:delete a.prefab.overrides,JSON.stringify(a)===JSON.stringify(e)?e:a}function ig(e,t){let r=te(e?.materialAssetId),n=te(t?.materialAssetId),o=xd(e?.override,t?.override);return ul({...n??r?{materialAssetId:n??r}:{},...cn(o)?{override:o}:{}})}function is(e,t){let r={},n=ig(e?.materialBinding,t?.materialBinding);n&&(r.materialBinding=n);let o=nD(e?.materialSlotBindings,t?.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function ss(e,t){let r=ln(e,t);if(!(!r.gameObject||!r.prefab))return is(r.definition?.prefab?.overrides,oD(r.gameObject.overrides))}function ln(e,t){let r=typeof t=="string"?ZA(e,t):t,n=typeof t=="string"?t:t.id,o=[],a=as(r)?r.prefab:null;if(!r||!a)return o.push({code:"not-prefab-instance",severity:"info",message:r?`GameObject "${r.id}" is not a prefab instance.`:`GameObject "${n}" was not found.`}),{gameObject:r,prefab:null,definition:null,sourceAsset:null,diagnostics:o};let i=e.assets.find(d=>d.id===a.prefabId&&Xe(d));i||o.push({code:"missing-prefab-definition",severity:"error",message:`Prefab definition "${a.prefabId}" was not found.`,prefabId:a.prefabId});let s=ca(i)??te(a.sourceAssetId);i&&a.sourceAssetId&&s&&a.sourceAssetId!==s&&o.push({code:"source-asset-mismatch",severity:"warning",message:`Prefab instance source "${a.sourceAssetId}" does not match definition source "${s}".`,prefabId:a.prefabId,expectedSourceAssetId:s,actualSourceAssetId:a.sourceAssetId});let c=s?e.assets.find(d=>d.id===s):void 0;if(s&&!c&&o.push({code:"missing-source-asset",severity:"error",message:`Prefab source asset "${s}" was not found.`,prefabId:a.prefabId,sourceAssetId:s}),s){let d=e.assets.filter(u=>Xe(u)&&ca(u)===s).map(u=>u.id);d.length>1&&o.push({code:"duplicate-source-prefab",severity:"info",message:`Source asset "${s}" is referenced by ${d.length} prefab definitions.`,prefabId:a.prefabId,sourceAssetId:s})}return{gameObject:r,prefab:a,definition:i??null,sourceAsset:c??null,diagnostics:o}}function Y(e){return e.kind==="group"||e.kind==="instance"||e.kind==="transform"||e.kind==="primitive"?e.kind:as(e)?"instance":e.primitive?"primitive":ue(e)?"instance":kr(e)||e.transformType?"transform":"group"}function sg(e){let t=e.rendering&&typeof e.rendering=="object"&&!Array.isArray(e.rendering)?e.rendering:void 0,r=ll(t?.renderingGroupId),n=dg(t?.alphaIndex),o={};return r!=null&&(o.renderingGroupId=r),n!=null&&(o.alphaIndex=n),Object.keys(o).length>0?o:void 0}function ll(e){return e===0||e===1||e===2||e===3?e:null}function cg(e){return dg(e)}function JA(e){return e.type==="Transform"}function XA(e){return e.type==="ModelRenderer"}function YA(e){return e.type==="ImageRenderer"}function dg(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function te(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function ZA(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function QA(e){if(e==="overrides.materialBinding.materialAssetId")return["overrides","materialBinding","materialAssetId"];let t="overrides.materialBinding.override.";if(e.startsWith(t)){let o=e.slice(t.length);return Qp(["overrides","materialBinding","override"],o)}let r=Lt(e,"materialAssetId");if(r)return["overrides","materialSlotBindings",r,"materialAssetId"];let n=Lt(e,"override");if(n){let o=eD(e);return o?Qp(["overrides","materialSlotBindings",n,"override"],o):null}return null}function eD(e){let t=".override.",r=e.lastIndexOf(t);if(r<0)return null;let n=e.slice(r+t.length);return n||null}function Qp(e,t){let r=t.split(".").filter(Boolean);return r.length===0||r.some(ug)?null:[...e,...r]}function tD(e,t,r){if(t.some(ug))return;let n=e;for(let a of t.slice(0,-1)){let i=n[a];(!i||typeof i!="object"||Array.isArray(i))&&(n[a]={}),n=n[a]}let o=t[t.length-1];o&&(r==null?delete n[o]:n[o]=structuredClone(r))}function lg(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r={},n=ul(t.materialBinding);n&&(r.materialBinding=n);let o=rD(t.materialSlotBindings);return o&&(r.materialSlotBindings=o),cn(r)?r:void 0}function ul(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,r=te(t.materialAssetId),n=xd(t.override),o={...r?{materialAssetId:r}:{},...cn(n)?{override:n}:{}};return cn(o)?o:void 0}function rD(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[r,n]of Object.entries(e)){let o=te(r);if(!o)continue;let a=ul(n);a&&(t[o]=a)}return cn(t)?t:void 0}function nD(e,t){let r=new Set([...Object.keys(e??{}),...Object.keys(t??{})]),n={};for(let o of r){let a=ig(e?.[o],t?.[o]);a&&(n[o]=a)}return cn(n)?n:void 0}function oD(e){return lg(e)}function cn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0}function ug(e){return e==="__proto__"||e==="prototype"||e==="constructor"}var aD=new Set(["id","guid","name","parentId","kind","transform","marker","metadata"]);function mg(e,t,r){if(e.kind!=="marker"){Object.prototype.hasOwnProperty.call(e,"marker")&&N("schema.invalidValue",`${r}.marker`);return}for(let s of Object.keys(e))aD.has(s)||N("schema.invalidValue",`${r}.${s}`);ua(e.parentId)||N("schema.invalidReference",`${r}.parentId`),dD(e.transform,`${r}.transform`),iD(e.marker,`${r}.marker`);let n=ua(e.id),o=e.marker,a=sD(o,`${r}.marker`),i=a[0]??null;for(let s of a){s.target.id===n&&N("schema.invalidReference",`${s.path}.id`),i&&(s.target.kind!==i.target.kind||s.target.id!==i.target.id)&&N("schema.invalidReference",s.path);let c=t.get(s.target.id);c&&(s.target.kind==="marker"&&c.kind!=="marker"&&N("schema.invalidReference",`${s.path}.kind`),s.target.kind==="scene-object"&&c.kind==="marker"&&N("schema.invalidReference",`${s.path}.kind`))}}function iD(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["schemaVersion","type","kind","tags","note","color","target","semanticFrame","geometry","metadata"],t),r.schemaVersion!==1&&N("schema.unsupportedVersion",`${t}.schemaVersion`),ua(r.type)||N("schema.invalidValue",`${t}.type`),r.kind!==void 0&&!ua(r.kind)&&N("schema.invalidValue",`${t}.kind`),r.tags!==void 0&&mD(r.tags,`${t}.tags`),r.note!==void 0&&typeof r.note!="string"&&N("schema.invalidType",`${t}.note`),r.color!==void 0&&uD(r.color,`${t}.color`),r.target!==void 0&&ml(r.target,`${t}.target`),r.semanticFrame!==void 0&&lD(r.semanticFrame,`${t}.semanticFrame`),cD(r.geometry,`${t}.geometry`),r.metadata!==void 0&&fD(r.metadata,`${t}.metadata`)}function sD(e,t){let r=[];return e.target&&r.push({target:e.target,path:`${t}.target`}),e.geometry.kind==="point"&&e.geometry.target&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),e.geometry.kind==="object-bounds"&&r.push({target:e.geometry.target,path:`${t}.geometry.target`}),r}function cD(e,t){let r=Rr(e);if(r||N("schema.invalidType",t),r.kind==="box"){Pt(r,["kind"],t);return}if(r.kind==="point"){Pt(r,["kind","coordinateSpace","position","offset","target"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&r.coordinateSpace!=="local"&&N("schema.invalidValue",`${t}.coordinateSpace`),r.position!==void 0&&Or(r.position,`${t}.position`),r.offset!==void 0&&Or(r.offset,`${t}.offset`),r.target!==void 0&&ml(r.target,`${t}.target`);return}if(r.kind==="object-bounds"){Pt(r,["kind","target"],t),ml(r.target,`${t}.target`);return}if(r.kind==="polyhedron"){Pt(r,["kind","coordinateSpace","vertices","faces"],t),r.coordinateSpace!==void 0&&r.coordinateSpace!=="world"&&N("schema.invalidValue",`${t}.coordinateSpace`),Array.isArray(r.vertices)||N("schema.invalidType",`${t}.vertices`),r.vertices.forEach((n,o)=>Or(n,`${t}.vertices[${o}]`)),r.faces!==void 0&&(Array.isArray(r.faces)||N("schema.invalidType",`${t}.faces`),r.faces.forEach((n,o)=>{Array.isArray(n)||N("schema.invalidType",`${t}.faces[${o}]`),n.forEach((a,i)=>{(!Number.isInteger(a)||a<0)&&N("schema.invalidValue",`${t}.faces[${o}][${i}]`)})}));return}N("schema.invalidValue",`${t}.kind`)}function ml(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["kind","id","label"],t),r.kind!=="marker"&&r.kind!=="scene-object"&&N("schema.invalidValue",`${t}.kind`),ua(r.id)||N("schema.invalidValue",`${t}.id`),r.label!==void 0&&typeof r.label!="string"&&N("schema.invalidType",`${t}.label`)}function dD(e,t){let r=Rr(e);if(r||N("schema.invalidType",t),r.type!=="Transform"&&N("schema.invalidValue",`${t}.type`),r.mode==="matrix"){Pt(r,["type","mode","matrix"],t),(!Array.isArray(r.matrix)||r.matrix.length!==16)&&N("schema.invalidType",`${t}.matrix`),r.matrix.forEach((n,o)=>cs(n,`${t}.matrix[${o}]`));return}Pt(r,["type","mode","position","rotation","scale"],t),r.mode!==void 0&&r.mode!=="trs"&&N("schema.invalidValue",`${t}.mode`),Or(r.position,`${t}.position`),Or(r.rotation,`${t}.rotation`),r.scale!==void 0&&Or(r.scale,`${t}.scale`)}function lD(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["origin","forward","right","up","label","description"],t),Or(r.origin,`${t}.origin`);for(let n of["forward","right","up"])r[n]!==void 0&&Or(r[n],`${t}.${n}`);for(let n of["label","description"])r[n]!==void 0&&typeof r[n]!="string"&&N("schema.invalidType",`${t}.${n}`)}function uD(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["r","g","b"],t);for(let n of["r","g","b"])cs(r[n],`${t}.${n}`),(r[n]<0||r[n]>1)&&N("schema.invalidValue",`${t}.${n}`)}function Or(e,t){let r=Rr(e);r||N("schema.invalidType",t),Pt(r,["x","y","z"],t);for(let n of["x","y","z"])cs(r[n],`${t}.${n}`)}function mD(e,t){Array.isArray(e)||N("schema.invalidType",t),e.forEach((r,n)=>{typeof r!="string"&&N("schema.invalidType",`${t}[${n}]`)})}function fD(e,t){let r=Rr(e);r||N("schema.invalidType",t),fl(r,t,new Set)}function fl(e,t,r){if(e===null||typeof e=="string"||typeof e=="boolean")return;if(typeof e=="number"){cs(e,t);return}(!e||typeof e!="object")&&N("schema.invalidType",t),r.has(e)&&N("schema.invalidValue",t);let n=Object.getPrototypeOf(e);Array.isArray(e)?n!==Array.prototype&&N("schema.invalidType",t):n!==Object.prototype&&n!==null&&N("schema.invalidType",t),r.add(e);try{if(Array.isArray(e))e.forEach((o,a)=>fl(o,`${t}[${a}]`,r));else for(let[o,a]of Object.entries(e))fl(a,`${t}.${o}`,r)}finally{r.delete(e)}}function Pt(e,t,r){let n=new Set(t);for(let o of Object.keys(e))n.has(o)||N("schema.invalidValue",`${r}.${o}`)}function cs(e,t){(typeof e!="number"||!Number.isFinite(e))&&N("schema.invalidValue",t)}function Rr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ua(e){return typeof e=="string"&&e.trim()?e.trim():null}function N(e,t){throw new Error(`${e}: ${t}`)}function ao(e,t){return t===e.rootNodeId?e.instanceId:`${e.instanceId}:${pD(t)}`}function pD(e){return encodeURIComponent(e)}function pl(e,t){return{...structuredClone(e),id:ao(t,e.id)}}function ma(e,t){let r=structuredClone(e);return r.target&&(r.target=pl(r.target,t)),r.geometry.kind==="point"&&r.geometry.target&&(r.geometry.target=pl(r.geometry.target,t)),r.geometry.kind==="object-bounds"&&(r.geometry.target=pl(r.geometry.target,t)),r}function B(e,t){if(fg(e))try{return e[t]}catch{return}}function ce(e,t){let r=B(e,t);return typeof r=="string"&&r.trim()?r:null}function re(e,t){let r=B(e,t);return typeof r=="number"&&Number.isFinite(r)?r:null}function Te(e,t){let r=B(e,t);return typeof r=="boolean"?r:null}function we(e,t,r=[]){let n=B(e,t);if(typeof n=="function")try{return n.apply(e,r)}catch{return}}function Kt(e){if(!fg(e))return null;let t=we(e,"getClassName");if(typeof t=="string"&&t.trim())return t;let r=B(e,"constructor"),n=r&&typeof r=="function"?r.name:"";return n&&n!=="Object"?n:null}function un(e){let t=Kt(e),r=ce(e,"name");return t&&r?`${t} \xB7 ${r}`:t??r}function fg(e){return!!e&&(typeof e=="object"||typeof e=="function")}function ds(e,t=new WeakSet,r=0){if(e==null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?gD(e):"[NonFiniteNumber]";if(typeof e=="bigint")return String(e);if(typeof e=="function")return`[Function ${e.name||"anonymous"}]`;if(typeof e=="symbol"||typeof e!="object")return String(e);if(t.has(e))return"[Circular]";if(r>6)return"[MaxDepth]";if(t.add(e),Array.isArray(e))return e.map(a=>ds(a,t,r+1));let n=e,o={};for(let a of Object.keys(n).sort())o[a]=ds(B(n,a),t,r+1);return o}function gD(e){return Math.round(e*1e6)/1e6}function Cr(e){let t=e.properties.filter(r=>!!r).map((r,n)=>r.order==null?{...r,order:n}:r);return t.length===0&&e.omitWhenEmpty!==!1?null:{id:e.id,title:e.title,order:e.order,placement:"body",summary:e.summary,persistence:e.persistence??(e.runtimeOnly?"runtime":"readonly"),runtimeOnly:e.runtimeOnly,effect:e.effect??(e.runtimeOnly?"runtime":void 0),disabledReason:e.disabledReason,collapsedByDefault:e.collapsedByDefault,tags:e.tags,properties:t}}function j(e){if(!bD(e.value))return null;let t=ds(e.value);return{path:e.path,label:e.label,valueType:e.valueType??SD(t),control:"readonly",value:t,readOnly:!0,persistence:e.persistence??"readonly",commitMode:"blur",order:e.order,tags:hD(e.source,e.tags),tooltip:e.tooltip,effect:e.effect??yD(e.source,e.persistence),disabledReason:e.disabledReason}}function gl(e,t){let r=j(t);r&&e.push(r)}function io(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.buttonLabel??e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function bl(e){let t=mn(e.value);if(!t)return[];let r=e.order??0;return["x","y","z"].map((n,o)=>j({path:`${e.basePath}.${n}`,label:`${e.label}.${n}`,value:t[n],order:r+o,persistence:e.persistence,source:e.source,tags:e.tags,effect:e.effect,disabledReason:e.disabledReason,valueType:"number"})).filter(n=>!!n)}function mn(e){if(!e||typeof e!="object")return null;let t=re(e,"x"),r=re(e,"y"),n=re(e,"z");return t==null||r==null||n==null?null:{x:t,y:r,z:n}}function bD(e){return e!=null&&!(typeof e=="number"&&!Number.isFinite(e))}function SD(e){return typeof e=="string"?"string":typeof e=="number"?"number":typeof e=="boolean"?"boolean":e&&typeof e=="object"?"object":"unknown"}function yD(e,t){if(t==="runtime"||e==="Runtime")return"runtime";if(e==="Derived")return"derived"}function hD(e,t){let r=[...e?[e]:[],...t??[]];return r.length>0?[...new Set(r)]:void 0}function fa(e){let t=e.projectedRoot??e.root??null,r=gg(t),n=r.find(o=>!!B(o,"material"))??r[0]??null;return{root:t,projectionNode:e.projectionNode??null,childNodes:bg(t),meshes:r,primaryMesh:n,material:ED(t)}}function ls(e){let t=we(e,"getHierarchyBoundingVectors"),r=mn(B(t,"min")),n=mn(B(t,"max"));if(r&&n)return pg(r,n);let o=we(e,"getBoundingInfo"),a=B(o,"boundingBox"),i=mn(B(a,"minimumWorld")),s=mn(B(a,"maximumWorld"));return i&&s?pg(i,s):null}function gg(e){let t=we(e,"getChildMeshes",[!1]),r=Array.isArray(t)?[...t]:[];return Sg(e)&&r.unshift(e),[...new Set(r)]}function bg(e){let t=we(e,"getChildren");return Array.isArray(t)?t:[]}function Sg(e){return!!e&&(!!B(e,"material")||typeof B(e,"getTotalVertices")=="function"||typeof B(e,"getBoundingInfo")=="function")}function us(e,t){let r=0,n=0;for(let o of e){let a=we(o,t);typeof a!="number"||!Number.isFinite(a)||(r+=a,n+=1)}return n>0?r:"not available"}function so(e,t){let r=B(e,t);return Array.isArray(r)?r.length:0}function ms(e,t){let r=we(e,t);return Array.isArray(r)?r.length:"not available"}function Sl(e){let t=we(e,"isEnabled");return typeof t=="boolean"?t:null}function pa(e,t){let r=re(e,t);if(r!=null)return r;let n=we(e,"getParam",[t]);return typeof n=="number"&&Number.isFinite(n)?n:null}function pg(e,t){return{min:e,max:t,center:{x:(e.x+t.x)/2,y:(e.y+t.y)/2,z:(e.z+t.z)/2},size:{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}}function ED(e){let t=B(e,"material");if(t)return t;let r=we(e,"getChildMeshes",[!1]);if(Array.isArray(r)){let n=r.find(o=>!!B(o,"material"));if(n)return B(n,"material")}return null}var ps={x:-.3,y:-1,z:-.2},yg=-180,hg=180,ga=-90,ba=90;function Sa(e,t=ps){let r=e&&TD(e)?e:t,n=Math.hypot(r.x,r.y,r.z);if(!Number.isFinite(n)||n<=1e-6){let o=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/o,y:t.y/o,z:t.z/o}}return{x:r.x/n,y:r.y/n,z:r.z/n}}function hl(e,t){let r=vr(bs(e)),n=vr(Ag(t,ga,ba)),o=Math.cos(n);return{x:yl(o*Math.cos(r)),y:yl(-Math.sin(n)),z:yl(o*Math.sin(r))}}function El(e){if(!Ss(e.light))return null;let t=G(e),r=t&&"rotation"in t?t.rotation:void 0,n=Tg({direction:e.light.direction,rotation:r}),o=hl(n.horizontalAngleDeg,n.elevationAngleDeg);return{horizontalAngleDeg:n.horizontalAngleDeg,elevationAngleDeg:n.elevationAngleDeg,rotation:{x:vr(n.elevationAngleDeg),y:vr(n.horizontalAngleDeg),z:co(r?.z)?r.z:0},direction:o,source:r?"transform.rotation":"light.direction"}}function Eg(e,t){if(!Ss(e.light))return e;let r=El(e);if(!r)return e;let n=co(t.horizontalAngleDeg)?t.horizontalAngleDeg:r.horizontalAngleDeg,o=co(t.elevationAngleDeg)?t.elevationAngleDeg:r.elevationAngleDeg,a=hl(n,o),i={...r.rotation,x:vr(o),y:vr(n)};return{...e,light:{...e.light,direction:a},components:e.components.map(s=>s===G(e)&&"rotation"in s?{...s,rotation:i}:s)}}function ID(e,t=ps){let{horizontalAngleDeg:r,elevationAngleDeg:n}=Tg({direction:t,rotation:e});return hl(r,n)}function PD(e,t){let r=Pg(e);return{x:vr(r.elevationAngleDeg),y:vr(r.horizontalAngleDeg),z:co(t?.z)?t.z:0}}function lo(e){if(!Ss(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=ID(t.rotation,e.light.direction);return xg(r,Sa(e.light.direction))?e:{...e,light:{...e.light,direction:r}}}function gs(e){if(!Ss(e.light))return e;let t=G(e);if(!t||!("rotation"in t))return e;let r=PD(e.light.direction,t.rotation);return xg(r,t.rotation)?e:{...e,components:e.components.map(n=>n===t?{...t,rotation:r}:n)}}function Ig(e){let t=Sa(e),r=Math.abs(t.y);return r<=1e-6?999:Math.min(999,Math.hypot(t.x,t.z)/r)}function bs(e){let t=((e+180)%360+360)%360-180;return t===-180?180:t}function TD(e){return typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)&&typeof e.z=="number"&&Number.isFinite(e.z)}function Ss(e){return e?.type==="directional"}function Pg(e){let t=Sa(e);return{horizontalAngleDeg:bs(fs(Math.atan2(t.z,t.x))),elevationAngleDeg:fs(Math.asin(Ag(-t.y,-1,1)))}}function Tg(e){let t=Pg(e.direction);return{horizontalAngleDeg:co(e.rotation?.y)?fs(e.rotation.y):t.horizontalAngleDeg,elevationAngleDeg:co(e.rotation?.x)?fs(e.rotation.x):t.elevationAngleDeg}}function co(e){return typeof e=="number"&&Number.isFinite(e)}function xg(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function fs(e){return e*180/Math.PI}function vr(e){return e*Math.PI/180}function yl(e){return Math.round(e*1e6)/1e6}function Ag(e,t,r){return Math.min(r,Math.max(t,e))}var fn="light.directionHorizontalAngleDeg",pn="light.directionElevationAngleDeg";function uo(e){return e===fn||e===pn}function Dg(e,t){if(t==null||typeof t=="string"&&!t.trim())return null;let r=xD(t);return r==null?t:e===fn?Math.round(bs(r)):e===pn?Math.round(AD(r,ga,ba)):t}function xD(e){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&!e.trim())return null;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function AD(e,t,r){return Math.min(r,Math.max(t,e))}function gn(e){return t=>mo({...e,value:t})}function mo(e){let t=DD(e);if(t)return t;let r=Yd(e.path,e.nodeKind);return r?e.value==null&&r.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${e.path}.`}:r.validate(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`}:{ok:!1,message:`Unsupported scene node field: ${e.path}.`}}function bn(e,t){return/^overrides\.material\.(albedoTexture|normalTexture|metallicTexture)\.url$/.test(e)&&typeof t=="string"?Mg(t):t}function ys(e,t,r={}){if((r.isDirectionalLightAnglePath??wg)(e))return Dg(e,t);if(e==="marker.type"&&typeof t=="string"||e==="marker.target.objectId"&&typeof t=="string")return t.trim();if(e==="marker.tags")return wD(t);if(e==="marker.note"&&typeof t=="string"){let n=t.trim();return n||null}return el(e)&&typeof t=="string"?Mg(t):bn(e,t)}function Il(e){return t=>MD(t,e)}function DD(e){for(let t of e.extraValidators??[]){let r=t({path:e.path,nodeKind:e.nodeKind,value:e.value,document:e.document});if(r)return r}return null}function MD(e,t){if(e.path==="camera.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: camera.inspectorLanguage."};if(e.path==="light.inspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:"Invalid value for scene node field: light.inspectorLanguage."};if((t.isDirectionalLightAnglePath??wg)(e.path))return typeof e.value=="number"&&Number.isFinite(e.value)?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="metadata.artistMaterialInspectorLanguage")return e.value==="zh"||e.value==="en"?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="instance.assetId"&&e.document&&typeof e.value=="string"&&!(e.document.assets??[]).some(r=>r.id===e.value))return{ok:!1,message:`Asset not found: ${e.value}.`};if(wr(e.path)&&e.document&&typeof e.value=="string"&&e.value&&!t.hasMaterialAsset(e.document,e.value))return{ok:!1,message:`Material asset not found: ${e.value}.`};if(wr(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(el(e.path))return e.value==null||typeof e.value=="string"&&e.value.trim().length>0?{ok:!0,value:e.value}:{ok:!1,message:`Invalid value for scene node field: ${e.path}.`};if(e.path==="marker.target.objectId"){if(typeof e.value!="string")return{ok:!1,message:"Marker target must be a scene object id."};let r=e.value.trim();if(!r)return{ok:!0,value:""};let n=e.document?.scene?.gameObjects?.find(o=>o.id===r)??null;return n&&!t.isMarkerGameObject(n)?{ok:!0,value:r}:{ok:!1,message:`Marker target object not found: ${r}.`}}return null}function Mg(e){let t=e.trim();return t||null}function wD(e){let r=(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>typeof n=="string"?n.trim():"").filter((n,o,a)=>n.length>0&&a.indexOf(n)===o);return r.length>0?r:null}function wg(e){return e===fn||e===pn}function ya(e){return{...e.property,readOnly:!1,persistence:"document",document:e.document??void 0,validate:gn({path:e.property.path,nodeKind:e.nodeKind,document:e.document,extraValidators:e.extraValidators})}}function ot(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function Tt(e){return e*180/Math.PI}function Ht(e){return e*Math.PI/180}function at(e){return Math.round(e*1e6)/1e6}var kg={zh:{title:"\u6444\u50CF\u673A",summaryOrthographic:"ArcRotate \u6B63\u4EA4",summaryPerspective:"ArcRotate \u900F\u89C6",language:"\u8BED\u8A00",projection:"\u6295\u5F71\u6A21\u5F0F",projectionOrthographic:"\u6B63\u4EA4",projectionPerspective:"\u900F\u89C6",alpha:"Alpha",beta:"Beta",radius:"\u534A\u5F84",orthoSize:"\u6B63\u4EA4\u5C3A\u5BF8",fov:"\u89C6\u91CE\u89D2\u5EA6",targetOffset:"\u76EE\u6807\u504F\u79FB",nearClip:"\u8FD1\u88C1\u526A",farClip:"\u8FDC\u88C1\u526A",minBeta:"\u6700\u5C0F Beta",maxBeta:"\u6700\u5927 Beta",minRadius:"\u6700\u5C0F\u534A\u5F84",maxRadius:"\u6700\u5927\u534A\u5F84",inertia:"\u60EF\u6027",screenOffset:"\u5C4F\u5E55\u504F\u79FB",rawCamera:"\u539F\u59CB\u6444\u50CF\u673A"},en:{title:"Camera",summaryOrthographic:"ArcRotate Orthographic",summaryPerspective:"ArcRotate Perspective",language:"Language",projection:"Projection",projectionOrthographic:"Orthographic",projectionPerspective:"Perspective",alpha:"Alpha",beta:"Beta",radius:"Radius",orthoSize:"Ortho Size",fov:"FOV",targetOffset:"Target Offset",nearClip:"Near Clip",farClip:"Far Clip",minBeta:"Min Beta",maxBeta:"Max Beta",minRadius:"Min Radius",maxRadius:"Max Radius",inertia:"Inertia",screenOffset:"Screen Offset",rawCamera:"Raw Camera"}},Og=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}];function Pl(e){return kg[e]??kg.zh}function kD(e){return[{label:e.projectionOrthographic,value:"orthographic"},{label:e.projectionPerspective,value:"perspective"}]}function Rg(e){let{camera:t,createDocumentInspectorProperty:r,nodeKind:n,rig:o}=e,a=o.inspectorLanguage??"zh",i=Pl(a),s=[],c=0;s.push(r(null,n,{path:"camera.inspectorLanguage",label:i.language,valueType:"enum",control:"enum",value:a,commitMode:"immediate",order:c,options:Og,controlOptions:{variant:"segmented"}})),c+=1,s.push(r(null,n,{path:"camera.projection",label:i.projection,valueType:"enum",control:"enum",value:o.projection??"orthographic",commitMode:"immediate",order:c,options:kD(i),controlOptions:{variant:"segmented"}})),c+=1,s.push(ze(n,r,{path:"camera.alpha",label:i.alpha,value:o.alpha,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.beta",label:i.beta,value:o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.radius",label:i.radius,value:o.radius,order:c,min:.001,step:.1})),c+=1,(o.projection??"orthographic")==="perspective"?s.push(ze(n,r,{path:"camera.fov",label:i.fov,value:at(Tt(o.fov??.85)),order:c,min:1,max:179,step:1,coerce:d=>typeof d=="number"&&Number.isFinite(d)?Ht(d):d})):s.push(ze(n,r,{path:"camera.orthoSize",label:i.orthoSize,value:o.orthoSize??6,order:c,min:.001,step:.1})),c+=1;for(let d of["x","y","z"])s.push(ze(n,r,{path:`camera.targetOffset.${d}`,label:`${i.targetOffset} ${d.toUpperCase()}`,value:o.targetOffset?.[d]??0,order:c,step:.05})),c+=1;s.push(ze(n,r,{path:"camera.minZ",label:i.nearClip,value:o.minZ??1,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.maxZ",label:i.farClip,value:o.maxZ??1e4,order:c,min:.001,step:1})),c+=1,s.push(ze(n,r,{path:"camera.lowerBetaLimit",label:i.minBeta,value:o.lowerBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.upperBetaLimit",label:i.maxBeta,value:o.upperBetaLimit??o.beta,order:c,step:.01})),c+=1,s.push(ze(n,r,{path:"camera.lowerRadiusLimit",label:i.minRadius,value:o.lowerRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.upperRadiusLimit",label:i.maxRadius,value:o.upperRadiusLimit??o.radius,order:c,min:.001,step:.1})),c+=1,s.push(ze(n,r,{path:"camera.inertia",label:i.inertia,value:o.inertia??.9,order:c,min:0,max:1,step:.05})),c+=1;for(let d of["x","y"])s.push(ze(n,r,{path:`camera.targetScreenOffset.${d}`,label:`${i.screenOffset} ${d.toUpperCase()}`,value:o.targetScreenOffset?.[d]??0,order:c,step:.01})),c+=1;return gl(s,{path:"camera.raw",label:i.rawCamera,value:t??"defaults",order:s.length,source:"Document",tags:["Raw"]}),s}function Tl(e){let t=Pl(e.rig.inspectorLanguage??"zh");return{id:"camera",title:t.title,order:42,placement:"body",summary:e.rig.projection==="perspective"?t.summaryPerspective:t.summaryOrthographic,persistence:"document",collapsedByDefault:!1,properties:Rg(e)}}function ze(e,t,r){return t(null,e,{path:r.path,label:r.label,valueType:"number",control:"number",value:r.value,commitMode:"live",order:r.order,min:r.min,max:r.max,step:r.step??.05,coerce:r.coerce})}var hs="scene.main",Es="scene";function Wt(e){let t=e.meta?.authoringSource;return{sourceId:t?.sourceId||hs,sourceType:t?.sourceType||Es,revision:typeof t?.revision=="number"?t.revision:1}}function Cg(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:hs,sourceType:Es,revision:t.revision??1}}}}function vg(e){let t=Wt(e);return{...e,meta:{...e.meta,authoringSource:{sourceId:hs,sourceType:Es,revision:(t.revision??0)+1}}}}function Gg(e,t){let r=Wt(e),n=OD(t),o=r.revision??null;if(!n)return{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:null,reason:"missing-generated-from"};let a=typeof n.revision=="number"?n.revision:null;return n.sourceId!==r.sourceId||n.sourceType!==r.sourceType?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"source-mismatch"}:o!==a?{detected:!0,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a,reason:"revision-mismatch"}:{detected:!1,sourceId:r.sourceId,sourceType:r.sourceType,sourceRevision:o,generatedRevision:a}}function OD(e){if(!e||typeof e!="object")return null;let t=e.meta;if(!t||typeof t!="object")return null;let r=t.generatedFrom;if(!r||typeof r!="object")return null;let n=r.sourceId,o=r.sourceType;return typeof n!="string"||typeof o!="string"?null:{sourceId:n,sourceType:o,revision:typeof r.revision=="number"?r.revision:void 0}}var RD="sun_light";function Is(e){let t=CD(e);return t.shadows.planar.enabled?"planar":t.shadows.blob.enabled?"blob":t.shadows.staticProjected.enabled?"static":t.shadows.enabled?"dynamic":"none"}function CD(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function vD(e,t){let r=typeof t.prefab?.prefabId=="string"?t.prefab.prefabId:null,n=r?e.assets.find(a=>a.id===r)?.prefab?.defaults?.shadow:void 0,o=He(n??t.shadow);return{settings:o.shadow,diagnostics:o.diagnostics}}function GD(e){let t=new Map,r=e.casterId;for(let n of e.explicitReceiverIds??[]){let o=Ts(e.document,n);!o||o.id===r||o.active===!1||t.set(o.id,{receiverId:o.id,source:"explicit",score:120,...xl(o,"explicit",120,["explicit receiver id"])})}for(let n of e.document.scene.gameObjects){if(n.id===r||n.active===!1)continue;He(n.shadow).shadow?.receive==="enabled"&&FD(t,{receiverId:n.id,source:"explicit",score:100,...xl(n,"explicit",100,["shadow.receive enabled"])})}return[...t.values()].sort((n,o)=>o.score-n.score||n.receiverId.localeCompare(o.receiverId))}function Ps(e){let t=e.caster?.id===e.casterId?e.caster:Ts(e.document,e.casterId),r=[];if(!t)return{casterId:e.casterId,receiverIds:[],backend:"none",mode:"none",quality:e.fallbackQuality??"medium",params:yi(e.fallbackQuality??"medium"),diagnostics:[{code:"shadow.invalidTarget",severity:"error",message:`Shadow caster "${e.casterId}" was not found.`,casterId:e.casterId}]};let n=e.resolvedSettings!==void 0?(()=>{let f=He(e.resolvedSettings);return{settings:f.shadow,diagnostics:f.diagnostics}})():vD(e.document,t);r.push(...n.diagnostics);let a=n.settings?.cast==="enabled"?cd(n.settings,e.fallbackMode??"none"):"none",i=dd(n.settings,e.fallbackQuality??"medium"),s=yi(i,n.settings?.params),c=jD(a),d=_D(e.explicitReceiverIds),u=c==="none"?{candidates:[],diagnostics:[]}:d.length>0&&e.strictExplicitReceivers===!0?$D(e.document,t.id,d):{candidates:GD({document:e.document,casterId:t.id,explicitReceiverIds:d.length>0?d:void 0}),diagnostics:[]};r.push(...u.diagnostics);let l=u.candidates;c!=="none"&&l.length===0&&r.push({code:"shadow.receiverNotFound",severity:"warning",message:`No shadow receiver was found for caster "${t.id}".`,casterId:t.id});let m=c==="none"?null:ND(e.document,n.settings??void 0,e.defaultLightId);return m?.diagnostic&&r.push(m.diagnostic),{casterId:t.id,receiverIds:l.map(f=>f.receiverId),...m?.lightId?{lightId:m.lightId}:{},backend:c,mode:a,quality:i,params:s,diagnostics:r}}function jD(e){return e==="dynamic"?"dynamic-map":e==="static"?"static-baked":e==="blob"?"blob":e==="projected"?"projected":"none"}function ND(e,t,r){if(t?.light?.mode==="explicit"){let a=t?.light?.lightId;return a&&jg(e,a)?{lightId:a}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:a?`Explicit shadow light "${a}" was not found.`:"Shadow light mode is explicit, but no lightId was configured.",...a?{lightId:a}:{}}}}let n=r??RD;if(jg(e,n))return{lightId:n};let o=e.scene.gameObjects.find(a=>Ng(a)&&a.active!==!1);return o?{lightId:o.id}:{diagnostic:{code:"shadow.lightNotFound",severity:"warning",message:"No directional shadow light was found."}}}function jg(e,t){let r=Ts(e,t);return!!r&&r.active!==!1&&Ng(r)}function Ng(e){return Y(e)==="transform"&&e.light?.type==="directional"}function FD(e,t){let r=e.get(t.receiverId);(!r||t.score>r.score)&&e.set(t.receiverId,t)}function _D(e){let t=new Set,r=[];for(let n of e??[]){let o=typeof n=="string"?n.trim():"";!o||t.has(o)||(t.add(o),r.push(o))}return r}function $D(e,t,r){let n=[],o=[];for(let a of r){let i=Ts(e,a);if(!i){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" was not found.`,casterId:t,receiverId:a,details:{source:"explicit"}});continue}if(i.id===t){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Shadow caster "${t}" cannot be used as its own receiver.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"self"}});continue}if(i.active===!1){o.push({code:"shadow.receiverNotFound",severity:"warning",message:`Explicit shadow receiver "${a}" is inactive.`,casterId:t,receiverId:a,details:{source:"explicit",reason:"inactive"}});continue}n.push({receiverId:i.id,source:"explicit",score:120,...xl(i,"explicit",120,["explicit receiver id"])})}return{candidates:n,diagnostics:o}}function xl(e,t,r,n){let o=He(e.shadow).shadow;return{active:e.active!==!1,visible:e.active!==!1,...o?.receive?{receive:o.receive}:{},suitability:{score:r,material:Y(e)==="primitive"?"primitive":t,reasons:n}}}function Ts(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}var LD="main_camera",zD="environment_light",BD="sun_light";function Al(e){return Y(e)==="group"}function xt(e){return!!G(e)}function At(e){return Y(e)==="transform"&&(e.transformType==="camera"||!!e.camera)}function fo(e){return Y(e)==="transform"&&(e.transformType==="light"||!!e.light)}function Dt(e){return e.id===LD||e.id===zD||e.id===BD||At(e)||fo(e)}function Dl(e,t){if(!t)return!1;let r=e.scene.gameObjects.find(n=>n.id===t);return!!r&&Dt(r)}var Gr="root",VD="go_",Ml="GameObject";function me(e){return e===Gr}function Z(e){return me(e.id)}function kl(e){let t=new Set,r=!1,n=e.scene.gameObjects.map(o=>{let a=KD(o,t);return r=r||a!==o,a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function he(){let e=globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;return`${VD}${e}`}function it(e,t){let r=new Set(e),n=xs(t)||"game_object";if(!r.has(n))return n;let o=2;for(;r.has(`${n}_${o}`);)o+=1;return`${n}_${o}`}function Fg(e,t=Ml){return wl(e)??wl(t)??Ml}function st(e,t,r={}){let n=Fg(t,r.fallbackName??Ml),o=new Set(e.map(s=>wl(s)).filter(s=>!!s));if(!r.alwaysAppendSuffix&&!o.has(n))return n;let a=1,i=`${n}_${a}`;for(;o.has(i);)a+=1,i=`${n}_${a}`;return i}function wl(e){let t=String(e??"").trim();return t&&t.replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||null}function xs(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"asset"}function UD(e){return typeof e.guid=="string"&&e.guid.trim()?e.guid.trim():null}function KD(e,t){let r=UD(e);if(r&&!t.has(r))return t.add(r),r===e.guid?e:{...e,guid:r};let n=he();for(;t.has(n);)n=he();return t.add(n),{...e,guid:n}}var jr=Et();function ke(e,t){if(me(t))return Et();let r=_(e,t);if(!r)return null;let n=[],o=Ol(e),a=new Set,i=r;for(;i&&!a.has(i.id);)a.add(i.id),n.unshift(i),i=i.parentId?o.get(i.parentId):void 0;return Op(n.map(qt))}function _(e,t){return e.scene.gameObjects.find(r=>r.id===t)??null}function Ol(e){return new Map(e.scene.gameObjects.map(t=>[t.id,t]))}function ur(e,t,r,n){let o=t?ke(e,t):Et();return o?to(o,r,n):null}function ha(e,t,r,n={}){let o=Vi(n);return ur(e,t,r,{allowMatrixFallback:o.allowMatrixFallback})}function qt(e){return Z(e)?Et():go(e)}function Ea(e,t={}){let r=e.scene.gameObjects.find(Z);if(!r)return e;let n=go(r),o=!!G(r)&&!WD(n,jr),a=!1,i=e.scene.gameObjects.map(s=>{if(Z(s)){let l=_g(s,t);return a=a||l!==s,l}if(!o||s.parentId!==Gr||!G(s))return s;let d=Rp(n,go(s));if(!d)return s;let u=Rl(s,d);return a=!0,u});return a?{...e,scene:{...e.scene,gameObjects:i}}:e}function _g(e,t={}){let r=!1,n=e.parentId!==void 0||t.normalizeRootActive===!0&&e.active!==!0,o=e.components.map(i=>{if(i.type!=="Transform")return i;r=!0;let s=i;return Ds(s)&&po(s.position,jr.position)&&po(s.rotation,jr.rotation)&&po($g(s,"scale"),jr.scale)?i:(n=!0,As())});if(r||(n=!0,o.unshift(As())),!n)return e;let a={...e,...t.normalizeRootActive===!0?{active:!0}:{},components:o};return delete a.parentId,a}function As(){return Mt(jr)}function go(e){let t=G(e);return t?Ee(t)?zi(t.matrix)??Et():{position:{...t.position},rotation:{...t.rotation},scale:{...$g(t,"scale")}}:Et()}function Rl(e,t){return{...e,components:e.components.map(r=>r.type!=="Transform"?r:mr(t)??r)}}function mr(e){let t=Sn(e);return t?tt(t)?{type:"Transform",mode:"matrix",matrix:t.matrix}:{type:"Transform",...t.mode==="trs"?{mode:"trs"}:{},position:{...t.position},rotation:{...t.rotation},scale:{...t.scale}}:null}function Sn(e){return tt(e)?zi(e.matrix):wp(e)}function Mt(e){let t=mr(e);if(!t)throw new Error("Invalid matrix Transform component.");return t}function Ee(e){return e.mode==="matrix"}function Ds(e){return e.mode!=="matrix"}function $g(e,t){return HD(e)?t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]:t==="scale"?{x:1,y:1,z:1}:{x:0,y:0,z:0}}function HD(e){return!!e.position&&!!e.rotation}function WD(e,t){return!It(e)||!It(t)?na(Fe(e),Fe(t)):po(e.position,t.position)&&po(e.rotation,t.rotation)&&po(e.scale,t.scale)}function po(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function ye(e){return e.scene.gameObjects.find(t=>t.id===Gr&&!!G(t))?.id??e.scene.gameObjects.find(t=>!t.parentId&&!!G(t))?.id}function Ms(e,t){return me(e)&&/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/.test(t)}function Cl(e,t){return!t||t===Gr?!1:!!_(e,t)}function fr(e){let t=ye(e),r=new Map(e.scene.gameObjects.map(n=>[n.id,n]));return e.scene.gameObjects.filter(n=>n.id!==Gr).map(n=>{let o=Dt(n),a=xt(n),i=n.active!==!1;return{id:n.id,label:n.name??n.id,parentId:n.parentId===t?null:n.parentId??null,depth:Math.max(0,qD(r,n)-(t?1:0)),role:a&&Al(n)?"group":"object",...as(n)?{icon:"prefab"}:{},selectable:!0,enabled:i&&JD(r,n.parentId,t),directEnabled:i,canToggleEnabled:!o,enableToggleDisabledReason:o?"Protected system objects cannot be hidden from Hierarchy.":void 0,protected:o,canHaveChildren:!o&&a,renamable:!o,deletable:!o,draggable:!o}})}function qD(e,t){let r=new Set,n=0,o=t.parentId??null;for(;o;){if(r.has(o))return n;r.add(o);let a=e.get(o);if(!a)return n;n+=1,o=a.parentId??null}return n}function JD(e,t,r){let n=new Set,o=t??null;for(;o;){if(n.has(o))return!0;n.add(o);let a=e.get(o);if(!a)return!0;if(a.id!==r&&a.active===!1)return!1;o=a.parentId??null}return!0}function vl(e){let t=Ea(e,{normalizeRootActive:!0}),r=ye(t);if(!r)return t;let n=t.scene.gameObjects.find(s=>s.id===r);if(!n)return t;let o=Z(n)?null:ke(t,r);if(!Z(n)&&!o)return t;let a=!1,i=t.scene.gameObjects.map(s=>{if(s.id===r||s.parentId)return s;let c=qt(s),d=o?to(o,c,{allowMatrixFallback:!0}):c;return a=!0,{...s,parentId:r,components:d?s.components.map(u=>u.type!=="Transform"?u:Mt(d)):s.components}});return a?{...t,scene:{...t.scene,gameObjects:i}}:t}function pr(e,t){return[...wt(e,t)]}function wt(e,t){let r=new Set,n=new Map;for(let i of e.scene.gameObjects){r.add(i.id);let s=i.parentId;if(!s)continue;let c=n.get(s);c?c.push(i.id):n.set(s,[i.id])}let o=new Set,a=[];for(let i of t)!r.has(i)||o.has(i)||(o.add(i),a.push(i));for(let i=0;i<a.length;i+=1)for(let s of n.get(a[i])??[])o.has(s)||(o.add(s),a.push(s));return o}function Nl(e){let t=[Lg(e)],r=Bg(e);r&&t.push(r);let n=Kg(e);n&&t.push(n);let o=qg(e);o&&t.push(o);let a=Yg(e);a&&t.push(a);let i=ZD(e);i&&t.push(i);let s=Qg(e);s&&t.push(s);let c=eb(e);c&&t.push(c);let d=rb(e);return d&&t.push(d),t}function Lg(e){return{id:"common",title:"Common",order:10,placement:"body",summary:Os(e),persistence:"document",collapsedByDefault:!1,properties:zg(e)}}function zg(e){let{document:t,gameObject:r}=e,n=Os(e),o=[Qe("id","ID",r.id,0),Jt(e,{document:t,path:"name",label:"Name",valueType:"string",control:"string",value:r.name??r.id,commitMode:"blur",order:1}),Jt(e,{document:t,path:"enabled",label:"Enabled",valueType:"boolean",control:"boolean",value:r.active!==!1,commitMode:"immediate",order:2}),Qe("kind.resolved","Resolved Kind",n,3),Qe("kind.explicit","Explicit Kind",r.kind??"inferred",4),Qe("common.activeField","Active Field",r.active??"default:true",5)];return n==="transform"?o.push(Jt(e,{document:t,path:"transformType",label:"Transform Type",valueType:"enum",control:"enum",value:r.transformType??"plain",commitMode:"immediate",order:6,options:e.transformTypeOptions??Pa})):o.push(Qe("common.transformType","Transform Type",r.transformType??"none",6)),o}function Bg(e){return Cr({id:"hierarchySource",title:"Hierarchy / Source",order:15,summary:Vg(e),collapsedByDefault:!0,tags:["Document","Derived"],properties:Ug(e)})}function Vg(e){let t=e.gameObject.parentId?_(e.document,e.gameObject.parentId):null;return t?`Parent: ${t.name??t.id}`:"Scene root"}function Ug(e){let{document:t,gameObject:r}=e,n=[],o=r.parentId?_(t,r.parentId):null,a=t.scene.gameObjects.filter(d=>d.parentId===r.id),i=Math.max(pr(t,[r.id]).length-1,0),s=Wt(t),c=t.scene.gameObjects.filter(d=>d.parentId===r.parentId).findIndex(d=>d.id===r.id);return oe(n,{path:"hierarchy.parentId",label:"Parent ID",value:r.parentId??"none",order:0,source:"Document"}),oe(n,{path:"hierarchy.parentName",label:"Parent Name",value:o?o.name??o.id:r.parentId?"missing":"none",order:1,source:"Document"}),oe(n,{path:"hierarchy.childCount",label:"Children",value:a.length,order:2,source:"Derived"}),oe(n,{path:"hierarchy.descendantCount",label:"Descendants",value:i,order:3,source:"Derived"}),oe(n,{path:"hierarchy.siblingIndex",label:"Sibling Index",value:c>=0?c:"unknown",order:4,source:"Derived"}),oe(n,{path:"document.gameObjectIndex",label:"Document Index",value:t.scene.gameObjects.findIndex(d=>d.id===r.id),order:5,source:"Derived"}),oe(n,{path:"document.schemaVersion",label:"Schema Version",value:t.schemaVersion,order:6,source:"Document"}),oe(n,{path:"source.sourceId",label:"Source ID",value:s.sourceId,order:7,source:"Document"}),oe(n,{path:"source.sourceType",label:"Source Type",value:s.sourceType,order:8,source:"Document"}),oe(n,{path:"source.revision",label:"Revision",value:s.revision??"none",order:9,source:"Document"}),n}function Kg(e){return G(e.gameObject)?{id:"transform",title:"Transform",order:20,placement:"body",summary:Wg(e),persistence:"document",collapsedByDefault:!1,properties:Hg(e)}:null}function Hg(e){if(!G(e.gameObject))return[];let r=Os(e),n=Z(e.gameObject),o=n?e.rootTransform??Et():go(e.gameObject);if(tt(o))return XD(o,0);let a=!!e.gameObject.parentId,i=[],s=0;for(let c of["position","rotation","scale"]){let d=iM(o,c);for(let u of["x","y","z"]){let l=`transform.${c}.${u}`,m=c==="rotation"?at(Tt(d[u])):d[u];n?i.push(Qe(l,`${jl(c)}.${u}`,m,s)):i.push(Jt(e,{document:null,path:l,label:`${a?`Local ${jl(c)}`:jl(c)}.${u}`,valueType:"number",control:"number",value:m,commitMode:"live",order:s,displayPrecision:c==="rotation"?2:3,precision:4,step:c==="rotation"?1:c==="scale"?.01:.1,stepPrecision:c==="rotation"?.1:c==="scale"?.001:.01},r)),s+=1}}if(a){let c=ke(e.document,e.gameObject.id);if(c&&!tt(c))for(let d of["x","y","z"])i.push(Qe(`transform.worldPosition.${d}`,`World Position.${d}`,c.position[d],s)),s+=1}return i}function Wg(e){let t=e.gameObject.parentId?_(e.document,e.gameObject.parentId):null;if(Z(e.gameObject))return"Identity Root";let r=G(e.gameObject);return r&&Ee(r)?"Matrix Transform":`Relative to: ${t?t.name??t.id:"Scene"}`}function XD(e,t){if(!tt(e))return[];let r=[Qe("transform.mode","Mode","Matrix Transform",t)],n=t+1;for(let a=0;a<4;a+=1)r.push(Qe(`transform.matrix.row${a}`,`Matrix Row ${a+1}`,e.matrix.slice(a*4,a*4+4).map(ws).join(", "),n)),n+=1;let o=Wd(e.matrix);return r.push(Qe("transform.matrix.trsApproximation","TRS Approximation",o?[`P ${Gl(o.position)}`,`R ${Gl({x:Tt(o.rotation.x),y:Tt(o.rotation.y),z:Tt(o.rotation.z)})}`,`S ${Gl(o.scale)}`].join(" | "):"Not representable as TRS",n)),r}function qg(e){let t=ue(e.gameObject),r=kr(e.gameObject),n=t?.assetId??r?.assetId;return n?{id:"renderer",title:r?"Image Renderer / Asset":"Renderer / Asset",order:30,placement:"body",summary:Xg(e.document,n),persistence:"document",collapsedByDefault:!0,properties:r?YD(e,r):Jg(e)}:null}function YD(e,t){let r=Ia(e.document,t.assetId);return[Qe("imageRenderer.assetId","Texture Asset",r?.displayName??t.assetId,0),Qe("imageRenderer.size","Image Size",`${t.size.width} \xD7 ${t.size.height}`,1),Qe("imageRenderer.assetType","Asset Type",r?.type??"texture",2)]}function Jg(e){let t=ue(e.gameObject);if(!t)return[];let{document:r}=e,n=Ia(r,t.assetId),o=[Jt(e,{document:r,path:"instance.assetId",label:"Asset",valueType:"enum",control:"enum",value:t.assetId,commitMode:"immediate",order:0,options:r.assets.map(a=>({label:a.displayName??a.id,value:a.id}))})];return oe(o,{path:"renderer.assetId",label:"Renderer Asset ID",value:t.assetId,order:1,source:"Document"}),oe(o,{path:"asset.id",label:"Asset ID",value:n?.id??"missing",order:2,source:"Asset"}),oe(o,{path:"asset.type",label:"Asset Type",value:n?.type??"missing",order:3,source:"Asset"}),oe(o,{path:"asset.guid",label:"GUID",value:n?.guid??"missing",order:4,source:"Asset"}),oe(o,{path:"asset.displayName",label:"Display Name",value:n?.displayName??"none",order:5,source:"Asset"}),oe(o,{path:"asset.category",label:"Category",value:n?.category??"none",order:6,source:"Asset"}),oe(o,{path:"asset.materialMode",label:"Material Mode",value:n?.materialMode??"none",order:7,source:"Asset"}),oe(o,{path:"asset.defaults",label:"Defaults",value:n?.defaults??"none",order:8,source:"Asset",tags:["Raw"]}),o}function Xg(e,t){let r=Ia(e,t);return r?r.displayName??r.id:`Missing asset: ${t}`}function Yg(e){let t=e.gameObject.primitive;return t?{id:"primitive",title:"Primitive",order:32,placement:"body",summary:t.shape,persistence:"document",collapsedByDefault:!1,properties:Zg(e)}:null}function Zg(e){let t=e.gameObject.primitive;return t?[Jt(e,{document:e.document,path:"primitive.shape",label:"Shape",valueType:"enum",control:"enum",value:t.shape,commitMode:"immediate",order:0,options:e.primitiveShapeOptions??sM})]:[]}function ZD(e){if(e.gameObject.prefab)return QD(e);if(!bo(e))return null;let t=He(e.gameObject.shadow).shadow,r=Jt(e,{document:e.document,path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.cast==="enabled",commitMode:"immediate",order:0,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u8BE5\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002"}),n=Jt(e,{document:e.document,path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:t?.receive==="enabled",commitMode:"immediate",order:1,tooltip:"\u5F00\u542F\u540E\u8BE5\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002"}),o=ks(e.renderingProfile),a=e.renderingProfile!==void 0&&Is(o)==="none";return{id:"shadow",title:"\u9634\u5F71",order:34,placement:"body",...a?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[r,n,...a?[Fl()]:[]]}}function QD(e){let t=e.gameObject.prefab?.prefabId,r=t?e.document.assets.find(i=>i.id===t)?.prefab?.defaults?.shadow:void 0,n=He(r).shadow,o=!!t,a=[{path:"shadow.cast",label:"\u6295\u5C04\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:0,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},{path:"shadow.receive",label:"\u63A5\u6536\u9634\u5F71",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",readOnly:!o,persistence:o?"document":"readonly",commitMode:"immediate",order:1,tooltip:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B\uFF1B\u8BBE\u7F6E\u4FDD\u5B58\u5728 Prefab definition root\u3002":"\u53EA\u8BFB\uFF1A\u7F3A\u5C11 Prefab definition\uFF0C\u65E0\u6CD5\u4FEE\u6539\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002"},...t?[io({path:"prefab.edit-definition",label:"\u8FDB\u5165 Prefab",buttonLabel:"Edit Prefab",actionId:"asset.edit-prefab",order:2,icon:"box",tooltip:"\u5728 Prefab Stage \u4E2D\u7F16\u8F91 definition root \u7684\u9634\u5F71\u53C2\u4E0E\u8D44\u683C\u3002",params:{assetId:t,browserAssetId:`prefab:${t}`,assetKind:"prefab"},disabled:!1})]:[]];return{id:"shadow",title:"\u9634\u5F71",order:34,summary:o?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u8BE5 Prefab \u7684\u5168\u90E8\u5B9E\u4F8B":"\u7531 Prefab definition root \u7BA1\u7406",persistence:o?"document":"readonly",collapsedByDefault:!1,properties:a}}function Fl(){return{path:"rendering.shadows.open",label:"\u6253\u5F00 Rendering / Shadows",valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:"\u6253\u5F00 Rendering / Shadows",icon:"world"},value:"\u6253\u5F00 Rendering / Shadows",readOnly:!0,persistence:"readonly",commitMode:"immediate",order:2,tags:["Rendering"],effect:"active"}}function ks(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function Qg(e){if(!eM(e))return null;let t=ks(e.renderingProfile),r=tM(e.gameObject.rendering?.renderingGroupId),n=t.renderingGroups.slots.find(a=>a.renderingGroupId===r)??t.renderingGroups.slots[0],o=rM(e.gameObject)??null;return{id:"rendering",title:"Rendering",order:36,placement:"body",summary:nM(n,o),persistence:"document",collapsedByDefault:!1,properties:[Jt(e,{document:e.document,path:"rendering.renderingGroupId",label:"Rendering Group",valueType:"enum",control:"enum",value:r,commitMode:"immediate",order:0,options:t.renderingGroups.slots.map(a=>({label:`${a.renderingGroupId}: ${a.name}`,value:a.renderingGroupId}))}),Jt(e,{document:e.document,path:"rendering.alphaIndex",label:"Alpha Order",valueType:"enum",control:"enum",value:o,commitMode:"immediate",order:1,options:oM(n,o)})]}}function eb(e){return Cr({id:"components",title:"Scripts / Components",order:65,summary:_l(e.gameObject),collapsedByDefault:!0,tags:["Document"],properties:tb(e.gameObject)})}function _l(e){return e.components.map(t=>t.type).join(", ")||"none"}function tb(e){let t=[];return oe(t,{path:"components.count",label:"Count",value:e.components.length,order:0,source:"Document"}),oe(t,{path:"components.types",label:"Types",value:_l(e),order:1,source:"Document"}),e.components.forEach((r,n)=>{oe(t,{path:`components.${n}`,label:`${r.type} ${n}`,value:r,order:n+2,source:"Document",tags:["Component","Raw"]})}),t}function rb(e){let t=e.assetId??ue(e.gameObject)?.assetId??kr(e.gameObject)?.assetId??null,r=nb({document:e.document,gameObject:e.gameObject,assetId:t});return r.length===0?null:{id:"metadata",title:"Metadata",order:80,placement:"body",summary:ob({document:e.document,gameObject:e.gameObject,assetId:t}),persistence:"readonly",collapsedByDefault:!0,tags:["Document","Asset"],properties:r}}function nb(e){let t=[],r=e.assetId?Ia(e.document,e.assetId):null;return oe(t,{path:"metadata.document",label:"Document Meta",value:e.document.meta??"none",order:0,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.gameObject",label:"GameObject Metadata",value:e.gameObject.metadata??"none",order:1,source:"Document",tags:["Raw"]}),oe(t,{path:"metadata.asset",label:"Asset Metadata",value:r?.metadata??"none",order:2,source:"Asset",tags:["Raw"]}),t}function ob(e){let t=e.assetId?Ia(e.document,e.assetId):null,r=[e.document.meta?"Document":null,e.gameObject.metadata?"GameObject":null,t?.metadata?"Asset":null].filter(n=>!!n);return r.length>0?r.join(" + "):"none"}function Jt(e,t,r=Os(e)){let{document:n,...o}=t;return ya({document:n??null,nodeKind:r,property:o,extraValidators:e.extraValidators})}function oe(e,t){let r=j(t);r&&e.push(r)}function Qe(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function Os(e){return e.nodeKind??Y(e.gameObject)}function bo(e){let t=e.gameObject;return Z(t)?!1:dn(t)}function eM(e){let t=e.gameObject;if(Z(t)||t.transformType==="camera"||t.transformType==="light"||t.camera||t.light)return!1;let r=e.nodeKind??Y(t);return r==="instance"||r==="primitive"||r==="transform"}function tM(e){return e===1||e===2||e===3?e:0}function rM(e){let t=e.rendering?.alphaIndex;if(typeof t=="number"&&Number.isFinite(t))return t}function nM(e,t){return t==null?`${e.name} \xB7 Babylon \u9ED8\u8BA4`:`${e.name} \xB7 ${aM(e,t)}`}function oM(e,t){let r=[{label:"Babylon \u9ED8\u8BA4",value:null},...e.alphaIndexPresets.map(n=>({label:`${n.name} (${n.alphaIndex})`,value:n.alphaIndex}))];return t!=null&&!e.alphaIndexPresets.some(n=>n.alphaIndex===t)&&r.push({label:`\u672A\u547D\u540D\u503C ${t}`,value:t,batchCompatibility:"ignore"}),r}function aM(e,t){let r=e.alphaIndexPresets.find(n=>n.alphaIndex===t);return r?r.name:`\u672A\u547D\u540D\u503C ${t}`}function iM(e,t){return t==="scale"?e.scale??{x:1,y:1,z:1}:e[t]}function Gl(e){return`${ws(e.x)}, ${ws(e.y)}, ${ws(e.z)}`}function ws(e){return at(e).toString()}function jl(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function Ia(e,t){return e.assets.find(r=>r.id===t)??null}var Pa=[{label:"Plain",value:"plain"},{label:"Light",value:"light"},{label:"Camera",value:"camera"}],sM=[{label:"Cube",value:"cube"},{label:"Sphere",value:"sphere"},{label:"Plane",value:"plane"},{label:"Capsule",value:"capsule"}];function ab(e){return[cb(e),db(e.runtime),lb(e.runtime),ub(e.runtime),mb(e.runtime),fb(e.runtime),pb(e.runtime),gb(e.runtime),bb(e.runtime),Sb(e.runtime),yb(e.runtime),hb(e.runtime),Eb(e)].filter(t=>!!t)}function $l(e,t){if(!e.activeId)return[];let r=t.findGameObject(e.document,e.activeId);if(!r||e.targetIds&&e.targetIds.length!==1)return[];let n=fa({projectedRoot:e.projectedRoot,projectionNode:e.projectionNode??null});return ab({runtime:n,binding:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,objectId:e.activeId,component:t.hasModelRenderer(r)?"ModelRenderer":t.hasImageRenderer(r)?"ImageRenderer":t.readNodeKind(r)==="transform"?"Transform":"GameObject",projectionNodeId:ce(e.projectionNode,"id")??null,projectionName:ce(e.projectionNode,"name")??null,projectionParentId:ce(e.projectionNode,"parentId")??null,projectionAssetId:ib(e.projectionNode)},projectionAssetMetadata:sb(e.projectionNode)})}function ib(e){let t=B(e,"asset");return ce(t,"assetId")??ce(t,"id")}function sb(e){return B(B(e,"asset"),"metadata")}function cb(e){let{binding:t,runtime:r}=e,n=[];return x(n,{path:"runtime.binding.sourceId",label:"Source ID",value:t?.sourceId??"none",order:0,source:"Document"}),x(n,{path:"runtime.binding.sourceType",label:"Source Type",value:t?.sourceType??"none",order:1,source:"Document"}),x(n,{path:"runtime.binding.objectId",label:"Object ID",value:t?.objectId??"none",order:2,source:"Document"}),x(n,{path:"runtime.binding.component",label:"Component",value:t?.component??"GameObject",order:3,source:"Derived"}),x(n,{path:"runtime.projection.nodeId",label:"Projection Node ID",value:t?.projectionNodeId??"none",order:4,source:"Derived"}),x(n,{path:"runtime.projection.name",label:"Projection Name",value:t?.projectionName??"none",order:5,source:"Derived"}),x(n,{path:"runtime.projection.parentId",label:"Projection Parent",value:t?.projectionParentId??"none",order:6,source:"Derived"}),x(n,{path:"runtime.projection.assetId",label:"Projection Asset ID",value:t?.projectionAssetId??"none",order:7,source:"Asset"}),x(n,{path:"runtime.root.status",label:"Projected Root",value:r.root?"available":"not projected",order:8,source:"Runtime"}),x(n,{path:"runtime.root.className",label:"Runtime Class",value:Kt(r.root)??"none",order:9,source:"Runtime"}),x(n,{path:"runtime.root.name",label:"Runtime Name",value:ce(r.root,"name")??"none",order:10,source:"Runtime"}),x(n,{path:"runtime.binding.primaryMesh",label:"Primary Mesh",value:un(r.primaryMesh)??"none",order:11,source:"Derived"}),x(n,{path:"runtime.binding.primaryMaterial",label:"Primary Material",value:un(r.material)??"none",order:12,source:"Derived"}),x(n,{path:"runtime.material.kind",label:"Material Kind",value:Ab(r.material)??"none",order:13,source:"Runtime"}),Be({id:"runtimeBinding",title:"Runtime Binding",order:910,summary:r.root?un(r.root)??"Runtime":"not projected",collapsedByDefault:!0,properties:n})}function db(e){let t=[],r=ls(e.root)??ls(e.primaryMesh);return r?(yn(t,"runtime.bounds.min","Bounds Min",r.min,t.length,"Derived"),yn(t,"runtime.bounds.max","Bounds Max",r.max,t.length,"Derived"),yn(t,"runtime.bounds.center","Bounds Center",r.center,t.length,"Derived"),yn(t,"runtime.bounds.size","Bounds Size",r.size,t.length,"Derived")):x(t,{path:"runtime.bounds.status",label:"Bounds",value:"not available",source:"Derived"}),x(t,{path:"runtime.geometry.meshCount",label:"Mesh Count",value:e.meshes.length,source:"Derived"}),x(t,{path:"runtime.geometry.childNodeCount",label:"Child Nodes",value:e.childNodes.length,source:"Derived"}),x(t,{path:"runtime.geometry.totalVertices",label:"Total Vertices",value:us(e.meshes,"getTotalVertices"),source:"Derived"}),x(t,{path:"runtime.geometry.totalIndices",label:"Total Indices",value:us(e.meshes,"getTotalIndices"),source:"Derived"}),x(t,{path:"runtime.geometry.subMeshCount",label:"SubMeshes",value:e.meshes.reduce((n,o)=>n+so(o,"subMeshes"),0),source:"Derived"}),Be({id:"geometryBox",title:"Geometry / Box",order:920,summary:r?`${e.meshes.length} mesh${e.meshes.length===1?"":"es"}`:"no bounds",collapsedByDefault:!1,properties:t})}function lb(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.rendering.nodeClass",label:"Node Class",value:Kt(t)??"none"}),x(r,{path:"runtime.rendering.nodeName",label:"Node Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.rendering.isEnabled",label:"Enabled",value:Sl(t)??"not available"}),x(r,{path:"runtime.rendering.isVisible",label:"Is Visible",value:Te(t,"isVisible")??"not available"}),x(r,{path:"runtime.rendering.visibility",label:"Visibility",value:re(t,"visibility")??"not available"}),x(r,{path:"runtime.rendering.layerMask",label:"Layer Mask",value:re(t,"layerMask")??"not available"}),x(r,{path:"runtime.rendering.renderingGroupId",label:"Rendering Group",value:re(t,"renderingGroupId")??"not available"}),x(r,{path:"runtime.rendering.alphaIndex",label:"Alpha Index",value:re(t,"alphaIndex")??"not available"}),x(r,{path:"runtime.rendering.alwaysSelectAsActiveMesh",label:"Always Active Mesh",value:Te(t,"alwaysSelectAsActiveMesh")??"not available"}),x(r,{path:"runtime.rendering.billboardMode",label:"Billboard Mode",value:re(t,"billboardMode")??"not available"}),Be({id:"rendering",title:"Rendering",order:930,summary:ce(t,"name")??Kt(t)??"not available",collapsedByDefault:!0,properties:r})}function ub(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.collisions.checkCollisions",label:"Check Collisions",value:Te(t,"checkCollisions")??"not configured"}),x(r,{path:"runtime.collisions.collisionMask",label:"Collision Mask",value:re(t,"collisionMask")??"not configured"}),x(r,{path:"runtime.collisions.collisionGroup",label:"Collision Group",value:re(t,"collisionGroup")??"not configured"}),x(r,{path:"runtime.collisions.collisionResponse",label:"Collision Response",value:Te(t,"collisionResponse")??"not configured"}),x(r,{path:"runtime.collisions.moveWithCollisions",label:"Move With Collisions",value:typeof B(t,"moveWithCollisions")=="function"?"available":"not available"}),yn(r,"runtime.collisions.ellipsoid","Ellipsoid",B(t,"ellipsoid"),r.length,"Runtime","not configured"),yn(r,"runtime.collisions.ellipsoidOffset","Ellipsoid Offset",B(t,"ellipsoidOffset"),r.length,"Runtime","not configured"),Be({id:"collisions",title:"Collisions",order:940,summary:Te(t,"checkCollisions")===!0?"enabled":"not configured",collapsedByDefault:!0,properties:r})}function mb(e){let t=e.primaryMesh??e.root,r=B(t,"physicsBody"),n=B(t,"physicsImpostor"),o=r??n,a=[];return x(a,{path:"runtime.physics.status",label:"Physics",value:o?"configured":"not configured"}),x(a,{path:"runtime.physics.bodyClass",label:"Body Class",value:Kt(o)??"none"}),x(a,{path:"runtime.physics.bodyName",label:"Body Name",value:ce(o,"name")??ce(o,"id")??"none"}),x(a,{path:"runtime.physics.mass",label:"Mass",value:pa(o,"mass")??"not available"}),x(a,{path:"runtime.physics.friction",label:"Friction",value:pa(o,"friction")??"not available"}),x(a,{path:"runtime.physics.restitution",label:"Restitution",value:pa(o,"restitution")??"not available"}),x(a,{path:"runtime.physics.disablePreStep",label:"Disable Pre Step",value:Te(o,"disablePreStep")??"not available"}),Be({id:"physics",title:"Physics",order:950,summary:o?un(o)??"configured":"not configured",collapsedByDefault:!0,properties:a})}function fb(e){let t=e.primaryMesh??e.root,r=[];return x(r,{path:"runtime.shadows.receiveShadows",label:"Receive Shadows",value:Te(t,"receiveShadows")??"not configured"}),x(r,{path:"runtime.shadows.shadowEnabled",label:"Shadow Enabled",value:we(t,"isShadowEnabled")??"not available"}),x(r,{path:"runtime.shadows.shadowDepthWrapper",label:"Shadow Depth Wrapper",value:un(B(e.material,"shadowDepthWrapper"))??"none"}),x(r,{path:"runtime.shadows.receivingMeshCount",label:"Receiving Meshes",value:e.meshes.filter(n=>Te(n,"receiveShadows")===!0).length,source:"Derived"}),Be({id:"shadows",title:"Shadows",order:960,summary:Te(t,"receiveShadows")===!0?"receiving":"not configured",collapsedByDefault:!0,properties:r})}function pb(e){let t=e.material,r=[];return x(r,{path:"runtime.material.status",label:"Material",value:t?"available":"none"}),x(r,{path:"runtime.material.className",label:"Class",value:Kt(t)??"none"}),x(r,{path:"runtime.material.name",label:"Name",value:ce(t,"name")??"none"}),x(r,{path:"runtime.material.id",label:"ID",value:ce(t,"id")??"none"}),x(r,{path:"runtime.material.uniqueId",label:"Unique ID",value:re(t,"uniqueId")??"not available"}),x(r,{path:"runtime.material.alpha",label:"Alpha",value:re(t,"alpha")??"not available"}),x(r,{path:"runtime.material.backFaceCulling",label:"Back Face Culling",value:Te(t,"backFaceCulling")??"not available"}),x(r,{path:"runtime.material.twoSidedLighting",label:"Two Sided Lighting",value:Te(t,"twoSidedLighting")??"not available"}),x(r,{path:"runtime.material.disableLighting",label:"Disable Lighting",value:Te(t,"disableLighting")??"not available"}),x(r,{path:"runtime.material.wireframe",label:"Wireframe",value:Te(t,"wireframe")??"not available"}),x(r,{path:"runtime.material.pointsCloud",label:"Points Cloud",value:Te(t,"pointsCloud")??"not available"}),x(r,{path:"runtime.material.fillMode",label:"Fill Mode",value:re(t,"fillMode")??"not available"}),x(r,{path:"runtime.material.activeTextureCount",label:"Active Textures",value:ms(t,"getActiveTextures"),source:"Derived"}),Be({id:"material",title:"Material",order:970,summary:un(t)??"none",collapsedByDefault:!0,properties:r})}function gb(e){let t=e.material,r=[];x(r,{path:"runtime.material.textures.activeCount",label:"Active Texture Count",value:ms(t,"getActiveTextures"),source:"Derived"});let n=0;for(let o of Db){let a=B(t,o);a&&(n+=1,Pb(r,`runtime.material.textures.${o}`,Ta(o),a))}return n===0&&x(r,{path:"runtime.material.textures.status",label:"Textures",value:"none"}),Be({id:"materialTextures",title:"Material Textures",order:980,summary:n>0?`${n} slot${n===1?"":"s"}`:"none",collapsedByDefault:!0,properties:r})}function bb(e){let t=[],r=0;for(let n of Mb){let o=B(e.material,n);Ib(t,`runtime.material.colors.${n}`,Ta(n),o,t.length)&&(r+=1)}return r===0&&x(t,{path:"runtime.material.colors.status",label:"Colors",value:"none"}),Be({id:"materialColors",title:"Material Colors",order:990,summary:r>0?`${r} color${r===1?"":"s"}`:"none",collapsedByDefault:!0,properties:t})}function Sb(e){let t=[];for(let r of wb)x(t,{path:`runtime.material.metallicRoughness.${r}`,label:Ta(r),value:re(e.material,r)??"not available"});return Be({id:"metallicRoughness",title:"Metallic / Roughness",order:1e3,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function yb(e){let t=[];for(let r of kb)x(t,{path:`runtime.material.intensity.${r}`,label:Ta(r),value:re(e.material,r)??"not available"});return Be({id:"intensityProperties",title:"Intensity Properties",order:1010,summary:e.material?"runtime material":"none",collapsedByDefault:!0,properties:t})}function hb(e){let t=e.primaryMesh??e.root,r=B(t,"skeleton"),n=[];return x(n,{path:"runtime.animation.rootAnimationCount",label:"Root Animations",value:so(e.root,"animations"),source:"Derived"}),x(n,{path:"runtime.animation.meshAnimationCount",label:"Mesh Animations",value:so(t,"animations"),source:"Derived"}),x(n,{path:"runtime.skeleton.status",label:"Skeleton",value:r?"available":"none"}),x(n,{path:"runtime.skeleton.className",label:"Skeleton Class",value:Kt(r)??"none"}),x(n,{path:"runtime.skeleton.name",label:"Skeleton Name",value:ce(r,"name")??"none"}),x(n,{path:"runtime.skeleton.id",label:"Skeleton ID",value:ce(r,"id")??"none"}),x(n,{path:"runtime.skeleton.boneCount",label:"Bones",value:so(r,"bones"),source:"Derived"}),Be({id:"animationSkeleton",title:"Animation / Skeleton",order:1020,summary:r?ce(r,"name")??"skeleton":"none",collapsedByDefault:!0,properties:n})}function Eb(e){let{runtime:t}=e,r=[];return x(r,{path:"runtime.raw.rootMetadata",label:"Root Metadata",value:B(t.root,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.primaryMeshMetadata",label:"Mesh Metadata",value:B(t.primaryMesh,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.materialMetadata",label:"Material Metadata",value:B(t.material,"metadata")??"none",tags:["Raw"]}),x(r,{path:"runtime.raw.projectionAssetMetadata",label:"Projection Asset Metadata",value:e.projectionAssetMetadata??"none",source:"Asset",tags:["Raw"]}),x(r,{path:"runtime.misc.isDisposed",label:"Root Disposed",value:we(t.root,"isDisposed")??"not available"}),Be({id:"rawMisc",title:"Raw / Misc",order:1030,summary:"metadata",collapsedByDefault:!0,properties:r})}function Be(e){return Cr({id:e.id,title:e.title,order:e.order,summary:e.summary,persistence:"runtime",runtimeOnly:!0,collapsedByDefault:e.collapsedByDefault,omitWhenEmpty:!1,tags:["Runtime"],properties:e.properties})}function x(e,t){let r=j({...t,persistence:"runtime",source:t.source??"Runtime"});r&&e.push(r)}function yn(e,t,r,n,o,a="Runtime",i){let s=bl({basePath:t,label:r,value:n,order:o,persistence:"runtime",source:a});s.length>0?e.push(...s):i&&x(e,{path:`${t}.status`,label:r,value:i,order:o,source:a})}function Ib(e,t,r,n,o){let a=xb(n);return a?(x(e,{path:`${t}.r`,label:`${r}.r`,value:a.r,order:o,valueType:"number"}),x(e,{path:`${t}.g`,label:`${r}.g`,value:a.g,order:o+1,valueType:"number"}),x(e,{path:`${t}.b`,label:`${r}.b`,value:a.b,order:o+2,valueType:"number"}),a.a!=null&&x(e,{path:`${t}.a`,label:`${r}.a`,value:a.a,order:o+3,valueType:"number"}),!0):!1}function Pb(e,t,r,n){let o=e.length;x(e,{path:`${t}.className`,label:`${r} Class`,value:Kt(n)??"Texture",order:o}),x(e,{path:`${t}.name`,label:`${r} Name`,value:ce(n,"name")??"none",order:o+1}),x(e,{path:`${t}.url`,label:`${r} URL`,value:Tb(n)??"none",order:o+2}),x(e,{path:`${t}.level`,label:`${r} Level`,value:re(n,"level")??"not available",order:o+3}),x(e,{path:`${t}.coordinatesIndex`,label:`${r} UV Set`,value:re(n,"coordinatesIndex")??"not available",order:o+4}),x(e,{path:`${t}.hasAlpha`,label:`${r} Has Alpha`,value:Te(n,"hasAlpha")??"not available",order:o+5})}function Tb(e){return ce(e,"url")??ce(e,"name")??ce(we(e,"getInternalTexture"),"url")}function xb(e){if(!e||typeof e!="object")return null;let t=re(e,"r"),r=re(e,"g"),n=re(e,"b");if(t==null||r==null||n==null)return null;let o=re(e,"a");return o==null?{r:t,g:r,b:n}:{r:t,g:r,b:n,a:o}}function Ab(e){let t=Kt(e);return t?t.includes("PBR")?"pbr":t.includes("Standard")?"standard":t:null}function Ta(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var Db=["albedoTexture","diffuseTexture","emissiveTexture","ambientTexture","opacityTexture","bumpTexture","normalTexture","metallicTexture","reflectionTexture","refractionTexture","lightmapTexture","specularTexture","roughnessTexture"],Mb=["albedoColor","diffuseColor","emissiveColor","ambientColor","specularColor","reflectivityColor"],wb=["metallic","roughness","microSurface","specularPower","baseWeight","indexOfRefraction"],kb=["directIntensity","emissiveIntensity","environmentIntensity","specularIntensity","cameraExposure","cameraContrast"];var Rb=[{label:"\u4E2D\u6587",value:"zh"},{label:"English",value:"en"}],Ob={zh:{hemisphericTitle:"\u73AF\u5883\u5149",directionalTitle:"\u76F4\u5C04\u5149",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"\u8BED\u8A00",type:"\u7C7B\u578B",typeHemispheric:"\u73AF\u5883\u5149",typeDirectional:"\u76F4\u5C04\u5149",intensity:"\u5F3A\u5EA6",skyLightColor:"\u5929\u7A7A\u5149\u989C\u8272",groundColor:"\u5730\u9762\u989C\u8272",lightColor:"\u5149\u7167\u989C\u8272",horizontalAngle:"\u6C34\u5E73\u89D2",elevationAngle:"\u9AD8\u5EA6\u89D2",shadowsTitle:"\u9634\u5F71",shadowsSummary:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",shadowSystem:"\u7CFB\u7EDF",shadowEnabled:"\u542F\u7528",shadowOpacity:"\u4E0D\u900F\u660E\u5EA6",shadowLength:"\u9634\u5F71\u957F\u5EA6",shadowFollowDirectional:"Planar Main / \u8DDF\u968F\u76F4\u5C04\u5149",openShadows:"\u6253\u5F00\u9634\u5F71\u8BBE\u7F6E",rawLight:"\u539F\u59CB\u5149\u6E90\u6570\u636E",tooltips:{language:"\u5207\u6362\u6B64\u5149\u6E90\u68C0\u67E5\u5668\u7684\u5C5E\u6027\u663E\u793A\u8BED\u8A00\u3002\u8BE5\u5B57\u6BB5\u53EA\u7528\u4E8E\u7F16\u8F91\u5668\uFF0C\u4E0D\u4F1A\u5BFC\u51FA\u5230\u8FD0\u884C\u65F6\u3002",type:"\u7CFB\u7EDF\u5149\u6E90\u7C7B\u578B\u53EA\u8BFB\u3002\u5BF9\u5E94 BabylonJS \u7684 HemisphericLight \u6216 DirectionalLight\u3002",intensity:"\u5149\u6E90\u5F3A\u5EA6\uFF0C\u5FC5\u987B\u662F\u975E\u8D1F\u6570\u3002BabylonJS \u4E0D\u8BBE\u7F6E\u786C\u4E0A\u9650\uFF1B\u767D\u8272\u6750\u8D28\u5728\u8F83\u9AD8\u5F3A\u5EA6\u4E0B\u901A\u5E38\u5DF2\u7ECF\u63A5\u8FD1\u663E\u793A\u9971\u548C\uFF0C\u7EE7\u7EED\u589E\u5927\u89C6\u89C9\u53D8\u5316\u4F1A\u4E0D\u660E\u663E\u3002",skyLightColor:"\u73AF\u5883\u5149\u6765\u81EA\u5929\u7A7A\u65B9\u5411\u7684\u6F2B\u53CD\u5C04\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.diffuse\u3002",groundColor:"\u73AF\u5883\u5149\u6765\u81EA\u5730\u9762\u53CD\u5C04\u65B9\u5411\u7684\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS HemisphericLight.groundColor\u3002",lightColor:"\u76F4\u5C04\u5149\u989C\u8272\uFF0C\u5BF9\u5E94 BabylonJS DirectionalLight.diffuse\u3002",horizontalAngle:"\u76F4\u5C04\u5149\u5728 XZ \u5E73\u9762\u5185\u7684\u671D\u5411\u89D2\u5EA6\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",elevationAngle:"\u76F4\u5C04\u5149\u76F8\u5BF9\u5730\u5E73\u7EBF\u7684\u9AD8\u5EA6\u89D2\uFF1B90 \u5EA6\u8868\u793A\u4ECE\u6B63\u4E0A\u65B9\u7167\u4E0B\u3002\u7F16\u8F91\u5668\u4F1A\u628A\u5B83\u8F6C\u6362\u4E3A BabylonJS DirectionalLight.direction\u3002",shadowSystem:"\u9634\u5F71\u7CFB\u7EDF\u53EA\u8BFB\u6458\u8981\u3002Planar \u9634\u5F71\u65B9\u5411\u6765\u81EA\u5F53\u524D\u76F4\u5C04\u5149\uFF0C\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowEnabled:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u662F\u5426\u542F\u7528\u3002\u8FD9\u91CC\u4EC5\u663E\u793A\u6458\u8981\uFF0C\u4E0D\u5728\u5149\u6E90 Inspector \u4E2D\u7F16\u8F91\u3002",shadowOpacity:"\u5F53\u524D\u9879\u76EE\u7EA7 Planar \u9634\u5F71\u4E0D\u900F\u660E\u5EA6\u3002\u5B8C\u6574\u53C2\u6570\u5728 Rendering \u9762\u677F\u8C03\u6574\u3002",shadowLength:"\u6839\u636E\u76F4\u5C04\u5149\u65B9\u5411\u4F30\u7B97\u7684\u5E73\u9762\u9634\u5F71\u957F\u5EA6\u500D\u7387\uFF1B\u9AD8\u5EA6\u89D2\u8D8A\u4F4E\uFF0C\u9634\u5F71\u8D8A\u957F\u3002",openShadows:"\u5207\u6362\u5230\u53F3\u4FA7 Rendering \u9762\u677F\uFF0C\u7F16\u8F91\u9879\u76EE\u7EA7\u9634\u5F71\u8BBE\u7F6E\u3002",rawLight:"\u7F16\u8F91\u5668\u6587\u6863\u4E2D\u7684\u5149\u6E90\u539F\u59CB\u6570\u636E\uFF0C\u53EA\u8BFB\u663E\u793A\u3002"}},en:{hemisphericTitle:"Environment Light",directionalTitle:"Directional Light",hemisphericSummary:"Hemispheric",directionalSummary:"Directional",language:"Language",type:"Type",typeHemispheric:"Environment Light",typeDirectional:"Directional Light",intensity:"Intensity",skyLightColor:"Sky Light Color",groundColor:"Ground Color",lightColor:"Light Color",horizontalAngle:"Horizontal Angle",elevationAngle:"Elevation Angle",shadowsTitle:"Shadows",shadowsSummary:"Planar Main / Follow Directional Light",shadowSystem:"System",shadowEnabled:"Enabled",shadowOpacity:"Opacity",shadowLength:"Shadow Length",shadowFollowDirectional:"Planar Main / Follow Directional Light",openShadows:"Open Shadows",rawLight:"Raw Light Data",tooltips:{language:"Switches the display language for this light inspector. This editor-only field is not exported to runtime.",type:"Read-only system light type. Maps to BabylonJS HemisphericLight or DirectionalLight.",intensity:"Light intensity. Must be a non-negative number. BabylonJS does not impose a hard upper limit; white surfaces often saturate at high intensity, so further increases may look subtle.",skyLightColor:"Diffuse sky color for the environment light. Maps to BabylonJS HemisphericLight.diffuse.",groundColor:"Ground bounce color for the environment light. Maps to BabylonJS HemisphericLight.groundColor.",lightColor:"Directional light color. Maps to BabylonJS DirectionalLight.diffuse.",horizontalAngle:"Directional light heading in the XZ plane. The editor converts it to BabylonJS DirectionalLight.direction.",elevationAngle:"Directional light elevation above the horizon; 90 degrees points straight down. The editor converts it to BabylonJS DirectionalLight.direction.",shadowSystem:"Read-only shadow system summary. Planar shadow direction follows this Directional Light; edit full settings in Rendering.",shadowEnabled:"Whether the project-level planar shadow system is enabled. This is summary-only in the light Inspector.",shadowOpacity:"Current project-level planar shadow opacity. Edit full settings in Rendering.",shadowLength:"Estimated planar shadow length multiplier from this light direction. Lower elevation makes longer shadows.",openShadows:"Switches the right dock to the Rendering panel for project-level shadow settings.",rawLight:"Read-only raw light data from the editor document."}}};function Ll(e){return Ob[e]??Ob.zh}function zl(e){return e.inspectorLanguage==="en"?"en":"zh"}function Cb(e){let{createDocumentInspectorProperty:t,gameObject:r,light:n,nodeKind:o,normalizeValue:a}=e,i=zl(n),s=Ll(i),c=[t(null,o,{path:"light.inspectorLanguage",label:s.language,valueType:"enum",control:"enum",value:i,commitMode:"immediate",order:0,options:Rb,controlOptions:{variant:"segmented"},tooltip:s.tooltips.language}),j({path:"light.type",label:s.type,value:n.type==="hemispheric"?s.typeHemispheric:s.typeDirectional,order:1,source:"Document",tooltip:s.tooltips.type}),t(null,o,{path:"light.intensity",label:s.intensity,valueType:"number",control:"number",value:n.intensity,commitMode:"live",order:2,min:0,step:.05,tooltip:s.tooltips.intensity})],d=3;if(n.type==="hemispheric")c.push(t(null,o,{path:"light.diffuseColor",label:s.skyLightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.skyLightColor})),d+=1,c.push(t(null,o,{path:"light.groundColor",label:s.groundColor,valueType:"color",control:"color",value:n.groundColor??e.defaultEnvironmentGroundColor??{r:.48,g:.52,b:.62},commitMode:"immediate",order:d,tooltip:s.tooltips.groundColor})),d+=1;else{let l=El(r)??{horizontalAngleDeg:0,elevationAngleDeg:90};c.push(t(null,o,{path:fn,label:s.horizontalAngle,valueType:"number",control:"number",value:l.horizontalAngleDeg,commitMode:"live",order:d,min:yg,max:hg,step:1,coerce:m=>a(fn,m),tooltip:s.tooltips.horizontalAngle})),d+=1,c.push(t(null,o,{path:pn,label:s.elevationAngle,valueType:"number",control:"number",value:l.elevationAngleDeg,commitMode:"live",order:d,min:ga,max:ba,step:1,coerce:m=>a(pn,m),tooltip:s.tooltips.elevationAngle})),d+=1,c.push(t(null,o,{path:"light.diffuseColor",label:s.lightColor,valueType:"color",control:"color",value:n.diffuseColor??{r:1,g:1,b:1},commitMode:"immediate",order:d,tooltip:s.tooltips.lightColor})),d+=1}return dM(c,{path:"light.raw",label:s.rawLight,value:n??"defaults",order:c.length,source:"Document",tags:["Raw"],tooltip:s.tooltips.rawLight}),c}function vb(e){let t=e.renderingProfile.shadows.planar;return Cr({id:"lightShadows",title:e.text.shadowsTitle,order:46,summary:e.text.shadowsSummary,collapsedByDefault:!1,tags:["Rendering","Derived"],properties:[j({path:"rendering.shadows.summary.system",label:e.text.shadowSystem,value:e.text.shadowFollowDirectional,order:0,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowSystem,effect:"derived"}),j({path:"rendering.shadows.summary.enabled",label:e.text.shadowEnabled,value:t.enabled,order:1,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowEnabled,effect:"derived"}),j({path:"rendering.shadows.summary.opacity",label:e.text.shadowOpacity,value:at(t.appearance.color.a),order:2,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowOpacity,effect:"derived"}),j({path:"rendering.shadows.summary.length",label:e.text.shadowLength,value:uM(Ig(e.light.direction)),order:3,source:"Document",tags:["Rendering"],tooltip:e.text.tooltips.shadowLength,effect:"derived"}),lM(e.text)]})}function Bl(e){let t=Ll(zl(e.light)),r=[{id:"light",title:e.light.type==="hemispheric"?t.hemisphericTitle:t.directionalTitle,order:44,placement:"body",summary:e.light.type==="hemispheric"?t.hemisphericSummary:t.directionalSummary,persistence:"document",collapsedByDefault:!1,properties:Cb(e)}];return e.light.type==="directional"&&r.push(vb({light:e.light,text:t,renderingProfile:cM(e.renderingProfile)})),r}function cM(e){return e&&typeof e=="object"&&"environment"in e&&"postProcess"in e&&"shadows"in e&&"renderingGroups"in e&&"shadowMeshes"in e?e:Ne(e)}function dM(e,t){let r=j(t);r&&e.push(r)}function lM(e){return{path:"rendering.shadows.summary.open",label:e.openShadows,valueType:"string",control:"custom",customControl:"open-right-dock-tab",controlOptions:{targetTab:"rendering",label:e.openShadows,icon:"world"},value:e.openShadows,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:4,tags:["Rendering"],tooltip:e.tooltips.openShadows,effect:"active"}}function uM(e){return`x${at(e)}`}function Oe(e,t,r){let n=t.split(".").filter(Boolean);if(n.some(mM))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function mM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function Vl(e){let t=Nr(e.overrides);if(!t)return;let r=Gb(t.material);r?t.material=r:delete t.material;let n=Nr(t.materialSlotBindings);if(n){for(let[i,s]of Object.entries(n)){let c=Nr(s);if(!c){delete n[i];continue}let d=Gb(c.override);d?c.override=d:delete c.override,Object.keys(c).length===0&&delete n[i]}Object.keys(n).length===0&&delete t.materialSlotBindings}let o=Nr(t.childTransforms);o&&Object.keys(o).length===0&&delete t.childTransforms;let a=Nr(t.childOutlines);a&&Object.keys(a).length===0&&delete t.childOutlines,Object.keys(t).length===0&&delete e.overrides}function Gb(e){let t=Nr(e);if(!t)return;let r=structuredClone(t);for(let n of["albedoTexture","normalTexture","metallicTexture"]){let o=Nr(r[n]);o&&Object.keys(o).length===0&&delete r[n]}for(let n of["pbr","standard"]){let o=Nr(r[n]);o&&Object.keys(o).length===0&&delete r[n]}return Object.keys(r).length>0?r:void 0}function Nr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function hn(e,t,r){let n=e.scene.gameObjects.find(a=>a.id===t);if(!n)return e;let o=Nb(n,r);return JSON.stringify(o)===JSON.stringify(n)?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>a.id===t?o:a)}}}function Ul(e,t){if(t.length===0)return e;let r=new Map;for(let a of t)r.set(a.targetId,a.patch);let n=!1,o=e.scene.gameObjects.map(a=>{let i=r.get(a.id);if(!i)return a;let s=Nb(a,i);return JSON.stringify(s)===JSON.stringify(a)?a:(n=!0,s)});return n?{...e,scene:{...e.scene,gameObjects:o}}:e}function Nb(e,t){let r=jb(e),n=fM(e,t),o=jb(n);return r&&o&&!pM(r,o)?lo(n):n}function fM(e,t){return G(e)?{...e,components:e.components.map(r=>{if(r.type!=="Transform")return r;let n=r;return t.transform?mr(t.transform)??n:Ee(n)?n:{...n,position:t.position??n.position,rotation:t.rotation??n.rotation,scale:t.scale??n.scale}})}:e}function jb(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function pM(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Fb(e){let t=new Set(e.targetIds);if(t.size===0||!Number.isFinite(e.fromAlphaIndex)||!Number.isFinite(e.toAlphaIndex)||e.fromAlphaIndex===e.toAlphaIndex)return e.gameObjects;let r=!1,n=e.gameObjects.map(o=>!t.has(o.id)||!gM(o,e)?o:(r=!0,{...o,rendering:{...o.rendering??{},alphaIndex:e.toAlphaIndex}}));return r?n:e.gameObjects}function Kl(e){let t=Fb({gameObjects:e.document.scene.gameObjects,targetIds:e.targetIds,renderingGroupId:e.renderingGroupId,fromAlphaIndex:e.fromAlphaIndex,toAlphaIndex:e.toAlphaIndex});return t===e.document.scene.gameObjects?e.document:{...e.document,scene:{...e.document.scene,gameObjects:t}}}function gM(e,t){return(ll(e.rendering?.renderingGroupId)??0)===t.renderingGroupId&&cg(e.rendering?.alphaIndex)===t.fromAlphaIndex}var xa=it,Rs=xs;function Hl(e){let t=st(e.document.scene.gameObjects.map(n=>n.name??n.id),e.name??e.asset.displayName,{fallbackName:e.asset.assetId}),r=xa(e.document.scene.gameObjects.map(n=>n.id),Rs(t));return{label:`Place ${e.asset.displayName}`,patch:{kind:"game-object.create-from-asset",assetItem:e.asset,...e.name?{name:e.name}:{},placement:{position:{...e.hit.position},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}},createdId:r,changedIds:[r]}}function _b(e){let t=e.scene.gameObjects.filter(r=>!!ue(r)||!!kr(r)||!!r.primitive).length;return{x:t%5*1.8-3.6,y:0,z:Math.floor(t/5)*1.8+1.8}}function Wl(e,t){let r=t&&It(t)?t:null;return{position:r?.position?{...r.position}:_b(e),rotation:r?.rotation?{...r.rotation}:{x:0,y:0,z:0},scale:r?.scale?{...r.scale}:{x:1,y:1,z:1}}}function Gs(e){return e.filter(t=>IM(t.kind)&&Jl(t)).map(ql).sort(Xl)}function Da(e){return e.filter(t=>t.kind==="model"||t.kind==="texture").map(ql).sort(Xl)}function ql(e){let t=e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"glb",r=En(e.guid),n=SM(e);return{id:e.assetId,...r?{guid:r}:{},assetId:e.assetId,type:t,kind:e.kind==="texture"?"texture":e.kind==="prefab"?"prefab":"model",displayName:e.displayName,category:e.category??bM(e),warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:vs(e.defaults),prefab:vs(e.prefab),external:vs(e.external),metadata:n,origin:e.origin??"project",dedupeKey:e.dedupeKey??r??EM(e.external)??e.assetId,placeable:Jl(e)}}function Lb(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.kind==="texture"||t.type==="texture"}function Jl(e){return Lb(e)?!0:!e||typeof e!="object"||Array.isArray(e)||e.placeable!==!1}function Xl(e,t){return(e.category??"").localeCompare(t.category??"")||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)||e.type.localeCompare(t.type)}function bM(e){return e.kind==="prefab"?"Prefab":e.kind==="texture"?"Texture":e.kind==="image"?"Image":e.kind==="sound"?"Sound":"Model"}function SM(e){return yM({originalFileName:e.originalFileName,relativePath:e.relativePath,codeKey:e.codeKey,contentHash:e.contentHash,byteSize:e.byteSize,...vs(e.metadata)})}function yM(e){if(!Array.isArray(e.materialSlots))return e;let t=Cs(e.assetAnalysis),r=Array.isArray(t?.meshes)?t.meshes:[],n=Array.isArray(t?.nodes)?t.nodes:[],o=new Map(r.flatMap(c=>{let d=Cs(c),u=Aa(d?.meshIndex),l=En(d?.name);return u==null||!l?[]:[[u,l]]})),a=new Map(n.flatMap(c=>{let d=Cs(c),u=Aa(d?.nodeIndex),l=En(d?.meshName);return u==null||!l?[]:[[u,l]]})),i=$b(t,"meshCount",r.length)||$b(t,"nodeCount",n.length),s=e.materialSlots.map(c=>{let d=Cs(c);if(!d||En(d.sourceMeshName))return c;let u=Aa(d.meshIndex);if(u==null)return c;let l=Aa(d.nodeIndex),m=o.get(u)??(l==null?void 0:a.get(l))??(i?hM(d):void 0);return m?{...d,sourceMeshName:m}:c});return{...e,materialSlots:s}}function hM(e){let t=En(e.label);if(t){let r=t.replace(/\s+\/\s+Primitive\s+\d+$/,"").trim();if(r)return r}return En(e.ownerNodePath)?.split("/").filter(Boolean).pop()}function $b(e,t,r){let n=Aa(e?.[t]);return n!=null&&n>r}function EM(e){return!e||typeof e!="object"||Array.isArray(e)?null:En(e.platformAssetId)}function En(e){return typeof e=="string"&&e.trim()?e.trim():null}function Aa(e){return Number.isInteger(e)&&e>=0?e:null}function Cs(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function vs(e){return e==null?void 0:structuredClone(e)}function IM(e){return e==="model"||e==="prefab"||e==="texture"}function Yl(e,t){let r=new Map(t.filter(a=>a.type==="glb").map(a=>[a.assetId,a])),n=e.assets.map(a=>{if(a.type!=="glb")return a;let i=r.get(a.id);return i?Fr(a,i):a}),o=new Set(e.assets.map(a=>a.id));for(let a of PM(e)){if(o.has(a))continue;let i=r.get(a);i&&(n.push(Fr({id:a,type:"glb"},i)),o.add(a))}return{...e,assets:n}}function PM(e){let t=[],r=new Set,n=o=>{let a=Ve(o);!a||r.has(a)||(r.add(a),t.push(a))};for(let o of e.assets)if(o.type==="prefab"){n(o.prefab?.sourceAssetId);for(let a of o.prefab?.nodes??[])n(a.sourceAssetId)}for(let o of e.scene.gameObjects){for(let i of o.components)i.type==="ModelRenderer"&&n(i.assetId);n(o.prefab?.sourceAssetId);let a=ct(ct(o)?.instance);n(a?.assetId)}return t}function Zl(e,t){Ma(e,t);let r=new Map(t.filter(n=>n.type==="glb").map(n=>[n.assetId,n]));return{...e,assets:e.assets.map(n=>{if(n.type!=="glb")return structuredClone(n);let o=r.get(n.id);if(!o)throw new Error(`asset.catalog.missing: ${n.id}`);let a=o.guid??n.guid;return{id:n.id,...a?{guid:a}:{},type:"glb"}})}}function Ma(e,t){let r=new Map(t.map(o=>[o.assetId,o])),n=new Map(t.filter(o=>o.type==="glb").map(o=>[o.assetId,o]));for(let o of e.assets){if(o.type!=="glb")continue;let a=n.get(o.id);if(!a)throw new Error(`asset.catalog.missing: ${o.id}`);AM(o,a),xM(o,a),TM(a)}for(let o of zb(e)){if(o.kind!=="material.textureAssetId")continue;let a=r.get(o.assetId);if(!a||a.kind!=="texture"&&a.type!=="texture")throw new Error(`asset.catalog.missing: ${o.assetId} at ${o.path}`)}}function zb(e){let t=[],r=(o,a)=>{let i=Ve(a);i&&t.push({assetId:i,...o})};for(let o=0;o<e.scene.gameObjects.length;o+=1){let a=e.scene.gameObjects[o];for(let i=0;i<a.components.length;i+=1){let s=a.components[i];s.type!=="ModelRenderer"&&s.type!=="ImageRenderer"||r({scope:"scene-object",kind:`${s.type}.assetId`,path:`scene.gameObjects[${o}].components[${i}].assetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},s.assetId)}r({scope:"scene-object",kind:"prefab.prefabId",path:`scene.gameObjects[${o}].prefab.prefabId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.prefabId),r({scope:"scene-object",kind:"prefab.sourceAssetId",path:`scene.gameObjects[${o}].prefab.sourceAssetId`,objectId:a.id,...a.name?{objectName:a.name}:{}},a.prefab?.sourceAssetId),So(a.overrides,`scene.gameObjects[${o}].overrides`,(i,s)=>r({scope:"scene-object",kind:"material.textureAssetId",path:i,objectId:a.id,...a.name?{objectName:a.name}:{}},s))}for(let o=0;o<e.assets.length;o+=1){let a=e.assets[o];if(!a.prefab)continue;let i=`assets[${o}].prefab`;r({scope:"prefab-asset",kind:"prefab.sourceAssetId",path:`${i}.sourceAssetId`,prefabAssetId:a.id},a.prefab.sourceAssetId),So(a.prefab.overrides,`${i}.overrides`,(c,d)=>r({scope:"prefab-asset",kind:"material.textureAssetId",path:c,prefabAssetId:a.id},d));let s=Ze(a);for(let c=0;c<s.length;c+=1){let d=s[c],u=`${i}.nodes[${c}]`;r({scope:"prefab-node",kind:"node.sourceAssetId",path:`${u}.sourceAssetId`,prefabAssetId:a.id,nodeId:d.id},d.sourceAssetId),r({scope:"prefab-node",kind:"node.childPrefabId",path:`${u}.childPrefabId`,prefabAssetId:a.id,nodeId:d.id},d.childPrefabId),So(d.overrides,`${u}.overrides`,(l,m)=>r({scope:"prefab-node",kind:"material.textureAssetId",path:l,prefabAssetId:a.id,nodeId:d.id},m))}}let n=Array.isArray(e.scene.materialAssets)?e.scene.materialAssets:[];for(let o=0;o<n.length;o+=1){let a=n[o],i=Ve(a.id)??"";r({scope:"material-asset",kind:"origin.sourceAssetId",path:`scene.materialAssets[${o}].origin.sourceAssetId`,materialAssetId:i},ct(a.origin)?.sourceAssetId),So(a.properties,`scene.materialAssets[${o}].properties`,(s,c)=>r({scope:"material-asset",kind:"material.textureAssetId",path:s,materialAssetId:i},c))}return t.sort((o,a)=>o.path.localeCompare(a.path))}function TM(e){let t=ct(e.metadata),r=ct(e.external);if(!(Ve(t?.url)??Ve(t?.relativePath)??Ve(r?.assetUrl)))throw new Error(`asset.catalog.incomplete: ${e.assetId}.url`);let o=ct(t?.assetAnalysis),a=t?.assetAnalysisStatus==="unavailable";if(!o&&!a)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.assetAnalysisStatus`);let i=new Map((Array.isArray(o?.meshes)?o.meshes:[]).flatMap(c=>{let d=ct(c),u=d?.meshIndex,l=Number.isInteger(u)?u:void 0,m=Ve(d?.name);return l==null||!m?[]:[[l,m]]})),s=Array.isArray(t?.materialSlots)?t.materialSlots:[];for(let[c,d]of s.entries()){let u=ct(d);if(!u)throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}]`);let l=Number.isInteger(u.meshIndex)?u.meshIndex:void 0;if(l!=null&&!Ve(u.sourceMeshName)&&!i.has(l))throw new Error(`asset.catalog.incomplete: ${e.assetId}.metadata.materialSlots[${c}].sourceMeshName`)}}function xM(e,t){let r=ct(e.metadata),n=ct(t.metadata),o=ct(e.external),a=ct(t.external),i=Ve(r?.url)??Ve(r?.relativePath)??Ve(o?.assetUrl),s=Ve(n?.url)??Ve(n?.relativePath)??Ve(a?.assetUrl);if(i&&!s)throw new Error(`asset.catalog.incomplete: ${e.id}.url`);for(let c of["materialSlots","assetAnalysis"])if(r?.[c]!==void 0&&n?.[c]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.metadata.${c}`)}function AM(e,t){for(let r of["materialMode","defaults","external","warmupCount","singleton"])if(e[r]!==void 0&&t[r]===void 0)throw new Error(`asset.catalog.incomplete: ${e.id}.${r}`)}function Fr(e,t){return{...e,guid:t.guid??e.guid,displayName:t.displayName||e.displayName,category:t.category??e.category,warmupCount:t.warmupCount??e.warmupCount,singleton:t.singleton??e.singleton,materialMode:t.materialMode??e.materialMode,defaults:js(t.defaults??e.defaults),prefab:js(t.prefab??e.prefab),external:js(t.external??e.external),metadata:js(t.metadata??e.metadata)}}function js(e){return e==null?void 0:structuredClone(e)}function So(e,t,r){if(!(!e||typeof e!="object")){if(Array.isArray(e)){e.forEach((n,o)=>So(n,`${t}[${o}]`,r));return}for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;n==="textureAssetId"?r(a,o):So(o,a,r)}}}function ct(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Ve(e){return(typeof e=="string"?e.trim():"")||void 0}function wa(e,t=[]){return e?.system?.readonly===!0||e?.system?.preset==="default-pbr"||e?.system?.preset==="default-standard"||!!e&&t.includes(e.id)}function DM(e){let t=structuredClone(e??{});return In(t.baseColor,"texture"),t.baseColor&&Object.keys(t.baseColor).length===0&&delete t.baseColor,In(t.normal,"texture"),t.normal&&Object.keys(t.normal).length===0&&delete t.normal,In(t.metallicRoughness,"texture"),t.metallicRoughness&&Object.keys(t.metallicRoughness).length===0&&delete t.metallicRoughness,In(t.occlusion,"texture"),t.occlusion&&Object.keys(t.occlusion).length===0&&delete t.occlusion,t.emission&&(In(t.emission,"texture"),In(t.emission,"maskTexture"),Object.keys(t.emission).length===0&&delete t.emission),In(t.alpha,"texture"),t.alpha&&Object.keys(t.alpha).length===0&&delete t.alpha,t}function In(e,t){if(!e)return;let r=e,n=r[t];if(n===null||!n||typeof n!="object"||Array.isArray(n))return;let o=n,a=typeof o.url=="string"?o.url.trim():"",i=typeof o.textureAssetId=="string"?o.textureAssetId.trim():"";a?o.url=a:delete o.url,i?o.textureAssetId=i:delete o.textureAssetId,Object.keys(o).length===0&&delete r[t]}function Bb(e,t,r,n,o){if(e.system?.readonly===!0)return e;let a=o?.textureMode==="inherit",i=rt(t,r);if(a?!ro(e.shaderId,t)||!zt(t,null,e.shaderId,n):!zt(t,i,e.shaderId,n))return e;let s=structuredClone(e);if(t==="name")return typeof i!="string"?e:(s.name=i.trim(),s.name===e.name?e:s);if(!t.startsWith("properties."))return e;let c=t.slice(11);return!c||(s.properties=structuredClone(s.properties),MM(s.properties,c,i,a)||Oe(s.properties,c,i),De(s.shaderId)&&(s.properties=DM(s.properties)),Qn(s.shaderId,s.properties,"properties",n).length>0)||JSON.stringify(s)===JSON.stringify(e)?e:s}function MM(e,t,r,n){let o=t.endsWith(".textureAssetId")?"textureAssetId":t.endsWith(".url")?"url":null;if(!o)return!1;let a=t.slice(0,-`.${o}`.length);if(!a.endsWith(".texture")&&!a.endsWith(".maskTexture"))return!1;let i=a.split(".").filter(Boolean);if(i.length<2)return!1;let s=i[i.length-1],c=e;for(let l of i.slice(0,-1)){let m=c[l];if(!m||typeof m!="object"||Array.isArray(m)){if(n)return!0;let f={};c[l]=f,c=f;continue}c=m}if(n)return delete c[s],!0;if(r==null)return c[s]=null,!0;let d=c[s],u=d&&typeof d=="object"&&!Array.isArray(d)?{...d}:{};return u[o]=r,delete u[o==="url"?"textureAssetId":"url"],c[s]=u,!0}var Pn="mat_default_pbr",yo="mat_default_standard",wM="00000000-0000-4000-8000-000000000001",kM="00000000-0000-4000-8000-000000000002",Tn=Pn,ka={id:Pn,guid:wM,name:"Default PBR Material",shaderId:"fps.builtin.pbr",definitionVersion:1,system:{readonly:!0,preset:"default-pbr"},origin:{type:"preset"},properties:Rd("fps.builtin.pbr")},OM={id:yo,guid:kM,name:"Default Standard Material",shaderId:"fps.builtin.standard",definitionVersion:1,system:{readonly:!0,preset:"default-standard"},origin:{type:"preset"},properties:Rd("fps.builtin.standard")};function RM(){return structuredClone(ka)}function CM(){return structuredClone(OM)}function Vb(e){let t=[RM(),CM()],r=new Set(t.map(o=>o.id)),n=[...t,...e.filter(o=>!r.has(o.id))];return JSON.stringify(n)===JSON.stringify(e)?e:n}function Ub(e){return e?.system?.preset==="default-pbr"||e?.id===Pn?"default-pbr":e?.system?.preset==="default-standard"||e?.id===yo?"default-standard":null}function Ns(e){let t=structuredClone(ka.properties);if(!e||typeof e!="object")return t;let r={...t,...structuredClone(e)};return r.baseColor={...t.baseColor??{},...e.baseColor??{}},(t.normal||e.normal)&&(r.normal={...t.normal??{},...e.normal??{}}),(t.metallicRoughness||e.metallicRoughness)&&(r.metallicRoughness={...t.metallicRoughness??{},...e.metallicRoughness??{}}),(t.occlusion||e.occlusion)&&(r.occlusion={...t.occlusion??{},...e.occlusion??{}}),r.emission={...t.emission??{},...e.emission??{}},(t.alpha||e.alpha)&&(r.alpha={...t.alpha??{},...e.alpha??{}}),r}function xn(e,t){let r=[...new Set(e.sourceSurfaces.map(s=>s.sourceMaterialIndex).filter(s=>Number.isInteger(s)))],n=e.materialNames??[],o=r.findIndex(s=>s===t),a=o>=0?n[o]??(r.length===1?e.materialName:null):null;if(typeof a=="string"&&a.trim())return a.trim();let i=ho(e,t)?.materialName;return typeof i=="string"&&i.trim()?i.trim():null}function ho(e,t){return e.sourceMaterialProfiles?.find(r=>r.sourceMaterialIndex===t)??null}var Ql=[Pn,yo],vM="New Material";function Kb(e,t,r=`${t.displayName} Material`){let n=Fs(e);return{id:nn(n),guid:n,name:eu(e,r),shaderId:t.shaderId,definitionVersion:t.version,origin:{type:"created"},properties:structuredClone(t.defaultProperties)}}function GM(e,t,r){let n=t.name?.trim()||t.id,o=r.name?.trim()||r.id,a=Fs(e);return{id:nn(a),guid:a,name:`${n} - ${o}`,shaderId:r.shaderId,...r.definitionVersion!=null?{definitionVersion:r.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:r.id},properties:structuredClone(r.properties)}}function Hb(e,t,r){let n=t.name?.trim()||t.id,o=Fs(e);return{id:nn(o),guid:o,name:eu(e,r??`${n} Copy`),shaderId:t.shaderId,...t.definitionVersion!=null?{definitionVersion:t.definitionVersion}:{},origin:{type:"duplicated",sourceMaterialAssetId:t.id},properties:structuredClone(t.properties)}}function jM(e,t){let r=Fs(e);return{id:nn(r),guid:r,name:eu(e,t.name),shaderId:ka.shaderId,definitionVersion:ka.definitionVersion,origin:{type:"created",...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.sourceAssetGuid?{sourceAssetGuid:t.sourceAssetGuid}:{},sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,...t.sourceMaterialName?{sourceMaterialName:t.sourceMaterialName}:{}},properties:Ns(t.profile)}}function Wb(e,t,r){let n=t.trim(),o=e.scene.materialAssets?.findIndex(s=>s.id===n)??-1;if(o<0||r.id!==n)return e;let a=e.scene.materialAssets[o];if(JSON.stringify(a)===JSON.stringify(r))return e;let i=[...e.scene.materialAssets];return i[o]=structuredClone(r),{...e,scene:{...e.scene,materialAssets:i}}}function Fs(e){let t=new Set((e.scene.materialAssets??[]).map(o=>o.id)),r=Qd(),n=nn(r);for(;t.has(n);)r=Qd(),n=nn(r);return r}function eu(e,t){let r=rt("name",t),n=typeof r=="string"&&zt("name",r)?r:vM,o=new Set((e.scene.materialAssets??[]).map(s=>s.name?.trim()).filter(s=>!!s).map(s=>s.toLocaleLowerCase()));if(!o.has(n.toLocaleLowerCase()))return n;let a=2,i=`${n} ${a}`;for(;o.has(i.toLocaleLowerCase());)a+=1,i=`${n} ${a}`;return i}function qb(e){let t=ee(e.document,e.sourceMaterialAssetId);if(!t||e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let r=GM(e.document,e.gameObject,t);return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function Jb(e){if(e.isBindingPathAllowed&&!e.isBindingPathAllowed(e.bindingPath))return null;let t=`${e.gameObject.name?.trim()||e.gameObject.id} - ${e.sourceSlotId}`,r=jM(e.document,{profile:e.profile,name:e.sourceMaterialName?.trim()||t,...e.sourceAsset?.id?{sourceAssetId:e.sourceAsset.id}:{},...e.sourceAsset?.guid?{sourceAssetGuid:e.sourceAsset.guid}:{},sourceSlotId:e.sourceSlotId,sourceMaterialIndex:e.sourceMaterialIndex,...e.sourceMaterialName?.trim()?{sourceMaterialName:e.sourceMaterialName.trim()}:{}});return{patch:{kind:"scene.material-asset.create-and-bind",targetId:e.gameObject.id,bindingPath:e.bindingPath,materialAsset:r},changedId:e.gameObject.id,changedIds:[e.gameObject.id],createdId:r.id,reprojectIds:[e.gameObject.id]}}function _s(e,t,r,n,o,a){let i=e.scene.materialAssets??[],s=!1,c=i.map(d=>{if(d.id!==t)return d;let u=Bb(d,r,rt(r,n),o,a);return s=s||u!==d,u});return s?{...e,scene:{...e.scene,materialAssets:c}}:e}function Xb(e,t,r=[]){let n=ee(e,t),o=rl(e,t);return n?wa(n,r)?{ok:!1,reason:"readonly",materialAsset:n,usages:o}:o.length>0?{ok:!1,reason:"in-use",materialAsset:n,usages:o}:{ok:!0,materialAsset:n,usages:o}:{ok:!1,reason:"missing",usages:o}}function Yb(e,t){return Xb(e,t,Ql)}function NM(e,t,r=[]){return Xb(e,t,r).ok?{...e,scene:{...e.scene,materialAssets:(e.scene.materialAssets??[]).filter(o=>o.id!==t)}}:e}function tu(e){return wa(e,Ql)}function Zb(e,t){return NM(e,t,Ql)}function $s(e,t){return Vt(e,t.id)?e:{...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(t)]}}}function Qb(e,t,r,n){return Vt(e,n.id)?e:FM({...e,scene:{...e.scene,materialAssets:[...e.scene.materialAssets??[],structuredClone(n)]}},t,r,n.id)}function FM(e,t,r,n){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(o=>{if(o.id!==t)return o;let a=structuredClone(o);return _M(a,r,n),a})}}}function _M(e,t,r){let n=$M(t)??t.split(".").filter(Boolean);if(n.some(LM))return;let o=e;for(let i of n.slice(0,-1)){let s=o[i];(!s||typeof s!="object"||Array.isArray(s))&&(o[i]={}),o=o[i]}let a=n[n.length-1];a&&(r==null?delete o[a]:o[a]=structuredClone(r))}function $M(e){let t=Lt(e,"materialAssetId");return t?["overrides","materialSlotBindings",t,"materialAssetId"]:null}function LM(e){return e==="__proto__"||e==="prototype"||e==="constructor"}function zs(e,t){let r=ue(t),n=r?e.assets.find(g=>g.id===r.assetId):null,o=typeof n?.guid=="string"&&n.guid.trim()?n.guid.trim():n?.id,a=os(e,t),i=new Map(a.filter(g=>!!g.slotId).map(g=>[g.slotId,g])),s=t.overrides?.materialSlotBindings??{},c=zM({document:e,assetId:n?.id,assetGuid:o,currentSlots:a,materialSlotBindings:s}),d=c.remaps,u=new Map(d.map(g=>[g.toSlotId,g])),l=new Set([...d.map(g=>g.fromSlotId),...c.coalescedSourceSlotIds]),m=new Map;for(let[g,b]of Object.entries(s))!b||l.has(g)||m.set(g,b);for(let g of d){let b=s[g.fromSlotId];b&&m.set(g.toSlotId,b)}let f=[];for(let[g,b]of a.entries()){let y=b.slotId?m.get(b.slotId):void 0,E=Eo(y),I=E?ee(e,E):null,P=tS(b),A=P[0],$=b.slotId?u.get(b.slotId):void 0;if($){f.push({status:"changed",reason:"slot-remapped",...b.slotId?{slotId:b.slotId}:{},previousSlotId:$.fromSlotId,ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},materialAssetId:E,bindingPath:`overrides.materialSlotBindings.${b.slotId}.materialAssetId`,conflict:!1});continue}let z=rS(I,o,n?.id)?.sourceMaterialIndex;if(z!=null&&P.length>0&&!P.includes(z)){f.push(eS({status:"changed",reason:"source-material-changed",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},previousSourceMaterialIndex:z,...E?{materialAssetId:E}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:""}));continue}if(!E&&P.length>0){f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1});continue}f.push({status:"unchanged",reason:"slot-current",...b.slotId?{slotId:b.slotId}:{},ownerNodePath:Ut(b)??void 0,label:Ls(b,g),...A==null?{}:{sourceMaterialIndex:A},...P.length>0?{sourceMaterialIndices:P}:{},...E?{materialAssetId:E}:{},bindingPath:b.slotId?`overrides.materialSlotBindings.${b.slotId}.materialAssetId`:"",conflict:!1})}for(let[g,b]of Object.entries(s))!b||i.has(g)||l.has(g)||f.push(eS({status:"removed",reason:"slot-removed",slotId:g,...Eo(b)?{materialAssetId:Eo(b)}:{},bindingPath:`overrides.materialSlotBindings.${g}.materialAssetId`}));let S=f.filter(VM);return{gameObjectId:t.id,...t.name?{gameObjectName:t.name}:{},...n?.id?{assetId:n.id}:{},...o?{assetGuid:o}:{},ok:S.length===0,items:f,issues:S,bindingRemaps:d,bindingRemapIssues:c.issues,counts:UM(f)}}function zM(e){let t=new Set(e.currentSlots.map(d=>d.slotId).filter(d=>!!d)),r=new Set(Object.keys(e.materialSlotBindings).filter(d=>t.has(d))),n=[],o=[],a=new Map;for(let[d,u]of Object.entries(e.materialSlotBindings)){if(!u||t.has(d))continue;let l=Eo(u),m=l?ee(e.document,l):null,f=rS(m,e.assetGuid,e.assetId);if(!f){o.push({fromSlotId:d,materialAssetId:l,reason:"binding-unmatched",candidateSlotIds:[]});continue}let S=e.currentSlots.filter(g=>!!g.slotId&&tS(g).includes(f.sourceMaterialIndex)).map(g=>g.slotId);a.set(d,{materialAssetId:l,candidateSlotIds:S,binding:u,anchored:f.sourceSlotId===d})}let i=new Map;for(let[d,u]of a){if(u.candidateSlotIds.length!==1)continue;let[l]=u.candidateSlotIds,m=i.get(l)??[];m.push(d),i.set(l,m)}let s=new Set,c=new Set;for(let[d,u]of i){u.forEach(g=>c.add(g));let l=u.filter(g=>a.get(g)?.anchored).sort((g,b)=>g.localeCompare(b));if(l.length===0){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-unmatched",candidateSlotIds:[]})}continue}let m=l[0],f=a.get(m);if(!u.every(g=>BM(f.binding,a.get(g).binding))||r.has(d)){for(let g of u){let b=a.get(g);o.push({fromSlotId:g,materialAssetId:b.materialAssetId,reason:"binding-ambiguous",candidateSlotIds:[d]})}continue}r.add(d),n.push({fromSlotId:m,toSlotId:d,materialAssetId:f.materialAssetId,reason:"source-material-index",...u.length>1?{coalescedFromSlotIds:u.filter(g=>g!==m).sort((g,b)=>g.localeCompare(b))}:{}});for(let g of u)g!==m&&s.add(g)}for(let[d,u]of a)c.has(d)||o.push({fromSlotId:d,materialAssetId:u.materialAssetId,reason:u.anchored&&u.candidateSlotIds.length>0?"binding-ambiguous":"binding-unmatched",candidateSlotIds:u.anchored?u.candidateSlotIds:[]});return{remaps:n,issues:o,coalescedSourceSlotIds:[...s].sort((d,u)=>d.localeCompare(u))}}function BM(e,t){return Eo(e)===Eo(t)&&ru(e.override,t.override)}function ru(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((i,s)=>ru(i,t[s]));if(!e||!t||typeof e!="object"||typeof t!="object")return!1;let r=e,n=t,o=Object.keys(r).sort(),a=Object.keys(n).sort();return o.length===a.length&&o.every((i,s)=>i===a[s]&&ru(r[i],n[i]))}function tS(e){return nt(e)}function rS(e,t,r){if(e?.origin?.type!=="imported")return null;let n=e.origin.sourceMaterialIndex;if(typeof n!="number"||!Number.isInteger(n))return null;let o=e.origin.sourceAssetGuid,a=e.origin.sourceAssetId;if((o||a)&&!(!!t&&!!o&&o===t)&&!(!!r&&!!a&&a===r)||!o&&!a&&(t||r))return null;let c=typeof e.origin.sourceSlotId=="string"&&e.origin.sourceSlotId.trim()?e.origin.sourceSlotId.trim():void 0;return{sourceMaterialIndex:n,...c?{sourceSlotId:c}:{}}}function Ls(e,t){return e.label?.trim()||Ut(e)?.trim()||e.slotId?.trim()||`Slot ${t+1}`}function Eo(e){return typeof e?.materialAssetId=="string"?e.materialAssetId.trim():""}function eS(e){return{...e,conflict:!0}}function VM(e){return e.conflict}function UM(e){return e.reduce((t,r)=>(t[r.status]+=1,t),{unchanged:0,added:0,removed:0,changed:0,conflict:0})}function Bs(e){let t=rs(e);if(t.ok)return;let r=new Error(`editor_scene_material_assets_missing: ${t.missingMaterialAssetIds.join(", ")}`);throw r.details={missingMaterialAssetIds:t.missingMaterialAssetIds,missingReferences:t.missingReferences.map(n=>({materialAssetId:n.materialAssetId,gameObjectId:n.gameObjectId,bindingPath:n.bindingPath,label:n.label,kind:n.kind,...n.slotId?{slotId:n.slotId}:{},...n.ownerNodePath?{ownerNodePath:n.ownerNodePath}:{}}))},r}function KM(e,t){let r=!1;return{gameObjects:t.map(o=>{let a=zs(e,o);if(a.bindingRemaps.length===0)return o;let i=o;for(let s of a.bindingRemaps){let c=i.overrides?.materialSlotBindings?.[s.fromSlotId];if(!(!c||i.overrides?.materialSlotBindings?.[s.toSlotId])){i=structuredClone(i),i.overrides=i.overrides??{},i.overrides.materialSlotBindings=i.overrides.materialSlotBindings??{},i.overrides.materialSlotBindings[s.toSlotId]=structuredClone(c),delete i.overrides.materialSlotBindings[s.fromSlotId];for(let d of s.coalescedFromSlotIds??[])delete i.overrides.materialSlotBindings[d];Object.keys(i.overrides.materialSlotBindings).length===0&&delete i.overrides.materialSlotBindings,r=!0}}return i}),changed:r}}function HM(e,t,r){let n=!1,o=new Map(t.filter(l=>l.origin?.type==="imported").map(l=>[l.id,l]));if(o.size===0)return{materialAssets:t,gameObjects:r,changed:!1};let a=new Map(e.assets.map(l=>[l.id,l])),i={...e,scene:{...e.scene,materialAssets:t,gameObjects:r}},s=r.map(l=>{let m=ue(l);if(!m)return l;let f=a.get(m.assetId);if(!f)return l;let S=lr(i,l,a),g=l;for(let b of S){let y=g.overrides?.materialSlotBindings?.[b.slotId],E=y?.materialAssetId?o.get(y.materialAssetId):null;if(!E||!WM(E,f))continue;let I=E.origin?.sourceMaterialIndex;if(!Number.isInteger(I)||!nt(b).includes(I))continue;g===l&&(g=structuredClone(l));let P=g.overrides?.materialSlotBindings;P&&(delete P[b.slotId],Object.keys(P).length===0&&delete g.overrides.materialSlotBindings,Object.keys(g.overrides??{}).length===0&&delete g.overrides,n=!0)}return g}),c={...i,scene:{...i.scene,gameObjects:s}},d=new Set(an(c).map(l=>l.materialAssetId)),u=t.filter(l=>l.origin?.type!=="imported"||d.has(l.id));return n=n||u.length!==t.length,{materialAssets:u,gameObjects:s,changed:n}}function nS(e,t,r){let n=KM({...e,scene:{...e.scene,materialAssets:t,gameObjects:r}},r),o=HM(e,t,n.gameObjects);return{materialAssets:o.materialAssets,gameObjects:o.gameObjects,changed:n.changed||o.changed}}function WM(e,t){let r=e.origin;return r?.type!=="imported"?!1:r.sourceAssetId===t.id||!!r.sourceAssetGuid&&!!t.guid&&r.sourceAssetGuid===t.guid}function oS(e,t){let r=new Set,n=e.properties,o=An(n)?n:{},a=An(t.defaultProperties)?t.defaultProperties:{},i=aS(t.propertiesSchema,o,a,"properties",r),s=new Set;iS(o,"properties",s);let c=[...s].filter(d=>!r.has(d)).sort();return{materialAsset:{...structuredClone(e),shaderId:t.shaderId,definitionVersion:t.version,properties:i},preservedPaths:[...r].sort(),resetPaths:c}}function aS(e,t,r,n,o){if(e.kind!=="object")return qM(e,t)?(o.add(n),structuredClone(t)):structuredClone(r);let a=An(t)?t:{},i=An(r)?r:{},s={};for(let[c,d]of Object.entries(e.properties)){let u=Object.prototype.hasOwnProperty.call(a,c),l=Object.prototype.hasOwnProperty.call(i,c);if(!u&&!l)continue;let m=aS(d,u?a[c]:void 0,l?i[c]:void 0,`${n}.${c}`,o);m!==void 0&&(s[c]=m)}return s}function qM(e,t){if(e.kind==="number")return typeof t=="number"&&Number.isFinite(t)&&(e.min==null||t>=e.min)&&(e.max==null||t<=e.max);if(e.kind==="boolean")return typeof t=="boolean";if(e.kind==="string")return typeof t=="string"||t===null&&e.nullable===!0;if(e.kind==="enum")return typeof t=="string"&&e.values.includes(t);if(e.kind==="color")return nu(t,e.channels===4?["r","g","b","a"]:["r","g","b"]);if(e.kind==="vec2")return nu(t,["x","y"]);if(e.kind==="vec3")return nu(t,["x","y","z"]);if(t===null)return!0;if(!An(t))return!1;let r=Object.keys(t);return r.every(n=>n==="url"||n==="textureAssetId")&&r.every(n=>typeof t[n]=="string"&&!!t[n].trim())}function iS(e,t,r){for(let[n,o]of Object.entries(e)){let a=`${t}.${n}`;An(o)&&!JM(o)?iS(o,a,r):r.add(a)}}function JM(e){let t=Object.keys(e);return t.length===0?!0:t.every(r=>["r","g","b","a"].includes(r))||t.every(r=>["x","y","z"].includes(r))||t.every(r=>r==="url"||r==="textureAssetId")}function nu(e,t){return An(e)&&Object.keys(e).length===t.length&&t.every(r=>typeof e[r]=="number"&&Number.isFinite(e[r]))}function An(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function XM(e){return e?.system?.preset}function cS(e,t){let r=XM(e);return r==="default-pbr"?t.defaultMaterial:r==="default-standard"?t.defaultStandardMaterial:e.name||e.id}function Vs(e,t){let r=t.trim();return r?e?.find(n=>n.url===r||n.id===r)??null:null}function sS(e,t){return{kind:"image",url:e.url,alt:e.label,fit:"contain",...t?{resourceStatusText:{loading:t.loadingTexture,failed:t.failedTexture}}:{}}}function dS(e){let t=e.currentTexture??Vs(e.textureAssets,e.currentValue),r=e.currentValue.trim(),n=!!r&&!t,o=!!t&&!t.disabled&&!!t.url.trim(),a=n?"missing":t?o?"ready":"failed":void 0,i=e.candidateValue??"url",s=(e.textureAssets??[]).filter(YM);return{pickerKind:"texture",pickerTitle:e.pickerText.texturePickerTitle,pickerTrigger:"preview",placeholder:e.pickerText.emptyTexture,currentLabel:n?e.pickerText.missingTexture:t?.label??(r||e.pickerText.emptyTexture),currentMeta:n?`${e.pickerText.missingTextureMeta} \xB7 ${r}`:t?.previewUnavailableReason??t?.meta??(r||e.pickerText.emptyTextureMeta),...a?{currentResourceState:a}:{},...r?{currentResourceReference:r}:{},resourceStatusText:{missing:e.pickerText.missingTexture,loading:e.pickerText.loadingTexture,failed:e.pickerText.failedTexture},currentPreview:o?sS(t,e.pickerText):void 0,candidates:[{label:e.pickerText.clearTexture,value:"",meta:e.pickerText.clearTextureMeta},...s.map(c=>({label:c.label,value:i==="assetId"?c.id:c.url,meta:c.meta??c.id,kind:"texture",...typeof c.width=="number"?{width:c.width}:{},...typeof c.height=="number"?{height:c.height}:{},...!c.disabled&&c.url.trim()?{preview:sS(c,e.pickerText)}:{},...c.disabled?{disabled:!0,disabledReason:c.disabledReason}:{}}))]}}function YM(e){return e.capabilities?.materialTexture===!0?!0:e.capabilities?.materialTexture===!1?!1:e.usage!=="environment"}function lS(e){return{path:`${e.pathPrefix??dr}${e.materialAsset.id}.${e.fieldPath}`,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.commitMode,order:e.order,tooltip:e.tooltip,tags:e.tags??["ArtistMaterial","MaterialAsset"],document:e.document}}var uS={zh:{title:"\u7F8E\u672F\u6750\u8D28",slotTitle:"\u6750\u8D28\u63D2\u69FD",language:"\u8BED\u8A00",materialAsset:"\u6750\u8D28\u8D44\u4EA7",materialCard:"\u5F53\u524D\u6750\u8D28",inheritNone:"\u7EE7\u627F / \u65E0",defaultMaterial:"\u9ED8\u8BA4 PBR \u6750\u8D28",defaultMaterialMeta:"BabylonJS \u9ED8\u8BA4 PBR \u6750\u8D28",defaultStandardMaterial:"\u9ED8\u8BA4 Standard \u6750\u8D28",defaultStandardMaterialMeta:"BabylonJS \u9ED8\u8BA4 Standard \u6750\u8D28",defaultMaterialReadOnly:"\u7CFB\u7EDF\u9ED8\u8BA4\u6750\u8D28\u4E3A\u53EA\u8BFB\uFF1B\u8BF7\u9009\u62E9\u53EF\u7F16\u8F91\u6750\u8D28\u7403\u540E\u8C03\u6574\u53C2\u6570\u3002",replace:"\u66FF\u6362",batchReplaceUnsupported:"\u591A\u9009\u7EDF\u4E00\u66FF\u6362\u6750\u8D28\u6682\u672A\u63A5\u5165\uFF1B\u8BF7\u5148\u5355\u9009\u5BF9\u8C61\u66FF\u6362\u6750\u8D28\u3002",duplicateForObject:"\u590D\u5236",materialPickerTitle:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7",texturePickerTitle:"\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",emptyTexture:"\u9009\u62E9\u8D34\u56FE",emptyTextureMeta:"\u70B9\u51FB\u9009\u62E9\u8D34\u56FE\u8D44\u4EA7",inheritTexture:"\u7EE7\u627F\u6E90\u8D34\u56FE",inheritTextureMeta:"\u4F7F\u7528 GLB / source material \u8D34\u56FE\uFF08\u82E5\u5B58\u5728\uFF09",clearTexture:"\u6E05\u9664\u8D34\u56FE",clearTextureMeta:"\u4E0D\u4F7F\u7528\u8D34\u56FE",missingTexture:"\u8D34\u56FE\u8D44\u4EA7\u7F3A\u5931",missingTextureMeta:"\u5F53\u524D\u5F15\u7528\u65E0\u6CD5\u5728\u9879\u76EE\u8D44\u4EA7\u5E93\u4E2D\u89E3\u6790",loadingTexture:"\u6B63\u5728\u52A0\u8F7D\u8D34\u56FE",failedTexture:"\u8D34\u56FE\u52A0\u8F7D\u5931\u8D25",assetProfile:"\u8D44\u4EA7\u53C2\u6570",assetProfileEmpty:"\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u540E\u53EF\u7F16\u8F91\u8D44\u4EA7\u53C2\u6570",assetName:"\u8D44\u4EA7\u540D\u79F0",assetKind:"Shader",assetKindPbr:"PBR \u6807\u51C6\u6750\u8D28\u7403",assetKindStandard:"Standard \u6807\u51C6\u6750\u8D28\u7403",assetLightingModel:"\u5149\u7167\u6A21\u578B",assetLightingModelLit:"\u53D7\u5149\u7167",assetLightingModelUnlit:"\u4E0D\u53D7\u5149\u7167",assetBaseColor:"\u57FA\u7840\u8272",assetBaseTexture:"\u57FA\u7840\u8D34\u56FE",assetBrightness:"\u8D34\u56FE\u4EAE\u5EA6",assetSaturation:"\u8D34\u56FE\u9971\u548C\u5EA6",assetContrast:"\u8D34\u56FE\u5BF9\u6BD4\u5EA6",assetHue:"\u8D34\u56FE\u8272\u76F8",assetNormalTexture:"\u6CD5\u7EBF\u8D34\u56FE",assetNormalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6",assetMetallic:"\u91D1\u5C5E\u5EA6",assetRoughness:"\u7C97\u7CD9\u5EA6",assetMetallicRoughnessTexture:"\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE",assetOcclusionTexture:"AO \u8D34\u56FE",assetOcclusionStrength:"AO \u5F3A\u5EA6",resetValue:"\u6062\u590D Shader \u9ED8\u8BA4\u503C",modifiedValue:"\u5DF2\u504F\u79BB Shader \u9ED8\u8BA4\u503C",inactiveReasons:{baseTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u57FA\u7840\u8D34\u56FE\u65F6\u751F\u6548\u3002",litMaterial:"\u4EC5\u5728\u201C\u53D7\u5149\u7167\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",normalTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\u65F6\u751F\u6548\u3002",occlusionTexture:"\u4EC5\u5728\u5DF2\u9009\u62E9 AO \u8D34\u56FE\u65F6\u751F\u6548\u3002",alphaBlend:"\u4EC5\u5728\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaMask:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002",alphaTransparency:"\u4EC5\u5728\u201C\u906E\u7F69\u201D\u6216\u201C\u534A\u900F\u660E\u201D\u6A21\u5F0F\u4E0B\u751F\u6548\u3002"},assetEmissionColor:"\u81EA\u53D1\u5149\u8272",assetEmissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6",assetEmissionTexture:"\u81EA\u53D1\u5149\u8D34\u56FE",assetEmissionMaskUrl:"\u906E\u7F69\u8D34\u56FE",assetAlphaMode:"\u900F\u660E\u6A21\u5F0F",assetAlphaModeOpaque:"\u4E0D\u900F\u660E",assetAlphaModeMask:"\u906E\u7F69",assetAlphaModeBlend:"\u534A\u900F\u660E",assetAlphaOpacity:"\u4E0D\u900F\u660E\u5EA6",assetAlphaCutoff:"Alpha \u9608\u503C",assetAlphaTexture:"Alpha \u8D34\u56FE",createSlotMaterial:"\u6DFB\u52A0\u6750\u8D28\u69FD",slotList:"\u69FD\u5217\u8868",slotId:"\u69FD ID",slotOwnerPath:"\u69FD\u8282\u70B9\u8DEF\u5F84",slotMaterialAsset:"\u69FD\u6750\u8D28\u8D44\u4EA7",slotSourceMaterial:"\u6E90\u6750\u8D28",slotBindingPath:"\u7ED1\u5B9A\u8DEF\u5F84",reimportConflicts:"\u91CD\u5BFC\u5165\u6750\u8D28\u51B2\u7A81",summaryAsset:e=>`\u8D44\u4EA7\uFF1A${e}`,summaryMissingAsset:"\u8D44\u4EA7\u7F3A\u5931",summaryCustomOverride:"\u81EA\u5B9A\u4E49\u53C2\u6570",summaryInherit:"\u7EE7\u627F",summaryAddSlot:"\u6DFB\u52A0\u69FD",summarySlotCount:e=>`${e} \u4E2A\u69FD`,formatUsageCount:e=>e>0?`\u88AB ${e} \u5904\u4F7F\u7528`:"\u672A\u88AB\u4F7F\u7528",formatMaterialEditImpact:e=>e<=0?"\u5F53\u524D\u672A\u88AB\u573A\u666F\u4F7F\u7528\uFF0C\u4FEE\u6539\u53EA\u4F1A\u6539\u53D8\u6750\u8D28\u8D44\u4EA7\u672C\u8EAB\u3002":e===1?"\u4FEE\u6539\u4F1A\u5F71\u54CD\u5F53\u524D\u7ED1\u5B9A\u3002":`\u5171\u4EAB\u6750\u8D28\uFF0C\u4FEE\u6539\u4F1A\u5F71\u54CD ${e} \u5904\u7ED1\u5B9A\u3002`,formatDuplicateMaterialImpact:e=>e<=0?"\u590D\u5236\u540E\u521B\u5EFA\u4E00\u4E2A\u53EF\u72EC\u7ACB\u7F16\u8F91\u7684\u6750\u8D28\u8D44\u4EA7\u3002":e===1?"\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\u3002":`\u590D\u5236\u540E\u5F53\u524D\u5BF9\u8C61\u6216\u69FD\u4F1A\u4F7F\u7528\u72EC\u7ACB\u6750\u8D28\uFF0C\u539F ${e} \u5904\u5171\u4EAB\u7ED1\u5B9A\u4E0D\u88AB\u7EE7\u7EED\u4FEE\u6539\u3002`,formatReimportConflictSummary:e=>`\u68C0\u6D4B\u5230 ${e} \u4E2A\u6750\u8D28\u69FD\u91CD\u5BFC\u5165\u5DEE\u5F02\uFF1B\u5DF2\u4FDD\u7559\u73B0\u6709\u7ED1\u5B9A\uFF0C\u9700\u4EBA\u5DE5\u786E\u8BA4\u4E0D\u53EF\u5339\u914D\u9879\u3002`,tooltips:{language:"\u5207\u6362\u7F8E\u672F\u6750\u8D28 Inspector \u7684\u663E\u793A\u8BED\u8A00\u3002",materialAsset:"\u9009\u62E9\u9879\u76EE\u7EA7\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\uFF0C\u6216\u4F7F\u7528\u53EA\u8BFB\u7684\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotMaterialAsset:"\u672A\u9009\u62E9\u6750\u8D28\u8D44\u4EA7\u65F6\u4FDD\u7559 GLB \u539F\u59CB\u6750\u8D28\uFF1B\u9009\u62E9\u540E\u53EA\u8986\u76D6\u5F53\u524D\u6750\u8D28\u63D2\u69FD\u3002",baseTexture:"\u9009\u62E9\u9879\u76EE\u8D34\u56FE\u4F5C\u4E3A\u57FA\u7840\u8D34\u56FE\u3002\u8D34\u56FE\u8C03\u8272\u53C2\u6570\u4F1A\u5148\u4F5C\u7528\u4E8E\u8FD9\u5F20\u8D34\u56FE\u3002",assetProfile:"\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u7684\u53C2\u6570\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u8D44\u4EA7\u7684\u8282\u70B9\u3002",assetName:"\u6750\u8D28\u8D44\u4EA7\u540D\u79F0\u53EA\u7528\u4E8E\u5C55\u793A\uFF1B\u7ED1\u5B9A\u4F7F\u7528\u7A33\u5B9A\u6750\u8D28 ID\uFF0C\u4E0D\u53D7\u91CD\u547D\u540D\u5F71\u54CD\u3002",assetKind:"\u9009\u62E9\u8BE5\u6750\u8D28\u5F15\u7528\u7684 Shader Definition\uFF1B\u5207\u6362\u65F6\u4F1A\u4FDD\u7559\u517C\u5BB9\u53C2\u6570\u3002",lightingModel:"\u53D7\u5149\u7167\u6750\u8D28\u4F1A\u54CD\u5E94\u73AF\u5883\u5149\u548C\u76F4\u5C04\u5149\uFF1B\u4E0D\u53D7\u5149\u7167\u6750\u8D28\u9002\u5408 UI\u3001\u7279\u6548\u3001\u56FE\u6807\u548C\u5BFC\u89C6\u6807\u8BB0\u3002",baseColor:"\u57FA\u7840\u8272\u4F5C\u4E3A\u989C\u8272\u56E0\u5B50\uFF0C\u4F1A\u5728\u57FA\u7840\u8D34\u56FE\u5B8C\u6210\u8C03\u8272\u540E\u53C2\u4E0E\u76F8\u4E58\u3002\u4FEE\u6539\u5171\u4EAB\u6750\u8D28\u8D44\u4EA7\u4F1A\u5F71\u54CD\u6240\u6709\u7ED1\u5B9A\u8BE5\u6750\u8D28\u7403\u7684\u8282\u70B9\u3002",duplicateForObject:"\u590D\u5236\u5F53\u524D\u6750\u8D28\u7403\u4E3A\u8FD9\u4E2A\u5BF9\u8C61\u6216\u69FD\u7684\u72EC\u7ACB\u6750\u8D28\uFF0C\u7136\u540E\u81EA\u52A8\u66FF\u6362\u7ED1\u5B9A\u3002",brightness:"\u57FA\u7840\u8D34\u56FE\u4EAE\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",saturation:"\u57FA\u7840\u8D34\u56FE\u9971\u548C\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",contrast:"\u57FA\u7840\u8D34\u56FE\u5BF9\u6BD4\u5EA6\u500D\u7387\uFF0C1 \u4E3A\u4E0D\u6539\u53D8\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",hue:"\u57FA\u7840\u8D34\u56FE\u8272\u76F8\u504F\u79FB\uFF0C\u5355\u4F4D\u4E3A\u5EA6\uFF1B\u4EC5\u5728\u6709\u57FA\u7840\u8D34\u56FE\u65F6\u5F71\u54CD\u8D34\u56FE\u3002",normalTexture:"\u9009\u62E9\u6CD5\u7EBF\u8D34\u56FE\uFF0C\u8FD0\u884C\u65F6\u5E94\u7528\u5230 PBR/Standard \u6750\u8D28\u7684 bump/normal \u901A\u9053\u3002",normalStrength:"\u6CD5\u7EBF\u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",metallic:"\u91D1\u5C5E\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",roughness:"\u7C97\u7CD9\u5EA6\uFF0C\u8303\u56F4 0 \u5230 1\u3002",metallicRoughnessTexture:"\u9009\u62E9\u91D1\u5C5E\u7C97\u7CD9\u8D34\u56FE\u3002PBR \u8FD0\u884C\u65F6\u6309 GLB \u5E38\u7528\u7EA6\u5B9A\u8BFB\u53D6\u84DD\u8272\u91D1\u5C5E\u5EA6\u3001\u7EFF\u8272\u7C97\u7CD9\u5EA6\u3002",occlusionTexture:"\u9009\u62E9\u73AF\u5883\u906E\u853D AO \u8D34\u56FE\uFF0C\u53EA\u5BF9 PBR \u6750\u8D28\u751F\u6548\u3002",occlusionStrength:"AO \u5F3A\u5EA6\uFF0C1 \u4E3A\u8D34\u56FE\u539F\u59CB\u5F3A\u5EA6\u3002",emissionColor:"\u81EA\u53D1\u5149\u989C\u8272\uFF0C\u4F1A\u4E0E\u5F3A\u5EA6\u76F8\u4E58\u3002",emissionIntensity:"\u81EA\u53D1\u5149\u5F3A\u5EA6\uFF0C0 \u8868\u793A\u65E0\u81EA\u53D1\u5149\u3002",emissionTexture:"\u9009\u62E9\u81EA\u53D1\u5149\u8D34\u56FE\uFF1B\u82E5\u672A\u8BBE\u7F6E\u5219\u517C\u5BB9\u4F7F\u7528\u65E7\u906E\u7F69\u8D34\u56FE\u3002",emissionMaskUrl:"\u9009\u62E9\u7070\u5EA6\u8D34\u56FE\u4F5C\u4E3A\u81EA\u53D1\u5149\u5F3A\u5EA6\u906E\u7F69\u3002",alphaMode:"\u900F\u660E\u6A21\u5F0F\uFF1A\u4E0D\u900F\u660E\u3001Alpha Test \u906E\u7F69\u6216 Alpha Blend \u534A\u900F\u660E\u3002",alphaOpacity:"\u6750\u8D28\u6574\u4F53\u4E0D\u900F\u660E\u5EA6\uFF0C1 \u4E3A\u5B8C\u5168\u4E0D\u900F\u660E\u3002",alphaCutoff:"\u906E\u7F69\u6A21\u5F0F\u7684 Alpha \u622A\u65AD\u9608\u503C\u3002",alphaTexture:"\u9009\u62E9 Alpha/Opacity \u8D34\u56FE\u3002",createSlotMaterial:"\u8F93\u5165 GLB \u5B50\u8282\u70B9\u6216 mesh \u7684 ownerNodePath \u6765\u6DFB\u52A0\u69FD\u7ED1\u5B9A\uFF0C\u521D\u59CB\u4F7F\u7528\u9ED8\u8BA4 PBR \u6750\u8D28\u3002",slotList:"\u6839\u8282\u70B9\u4E0A\u7684\u6750\u8D28\u69FD\u4E3A\u53EA\u8BFB\u603B\u89C8\u3002",slotOwnerPath:"\u6750\u8D28\u69FD\u5B9A\u4F4D\u5230\u7684\u5B50\u8282\u70B9\u6216 mesh \u8DEF\u5F84\u3002",reimportConflicts:"\u6A21\u578B\u91CD\u5BFC\u5165\u540E\u65E0\u6CD5\u81EA\u52A8\u5339\u914D\u6216\u6E90\u6750\u8D28\u53D8\u5316\u7684\u69FD\u3002\u73B0\u6709\u7ED1\u5B9A\u4F1A\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u9759\u9ED8\u5220\u9664\u6216\u8986\u76D6\u3002"}},en:{title:"Artist Material",slotTitle:"Material Slots",language:"Language",materialAsset:"Material Asset",materialCard:"Current Material",inheritNone:"Inherit / None",defaultMaterial:"Default PBR Material",defaultMaterialMeta:"BabylonJS-style default PBR material",defaultStandardMaterial:"Default Standard Material",defaultStandardMaterialMeta:"BabylonJS-style default Standard material",defaultMaterialReadOnly:"The system default material is read-only. Choose an editable material asset to adjust parameters.",replace:"Replace",batchReplaceUnsupported:"Batch material replacement is not wired yet. Select one object to replace its material.",duplicateForObject:"Copy",materialPickerTitle:"Select Material Asset",texturePickerTitle:"Select Texture Asset",emptyTexture:"Select Texture",emptyTextureMeta:"Choose a texture asset",inheritTexture:"Inherit Source Texture",inheritTextureMeta:"Use the GLB / source material texture when available",clearTexture:"Clear Texture",clearTextureMeta:"Do not use a texture",missingTexture:"Missing texture asset",missingTextureMeta:"The current reference cannot be resolved in the project asset library",loadingTexture:"Loading texture",failedTexture:"Texture failed to load",assetProfile:"Asset Profile",assetProfileEmpty:"Select a material asset to edit asset parameters",assetName:"Asset Name",assetKind:"Shader",assetKindPbr:"PBR standard material",assetKindStandard:"Standard material",assetLightingModel:"Lighting Model",assetLightingModelLit:"Lit",assetLightingModelUnlit:"Unlit",assetBaseColor:"Base Color",assetBaseTexture:"Base Texture",assetBrightness:"Texture Brightness",assetSaturation:"Texture Saturation",assetContrast:"Texture Contrast",assetHue:"Texture Hue",assetNormalTexture:"Normal Texture",assetNormalStrength:"Normal Strength",assetMetallic:"Metallic",assetRoughness:"Roughness",assetMetallicRoughnessTexture:"Metallic-Roughness Texture",assetOcclusionTexture:"AO Texture",assetOcclusionStrength:"AO Strength",resetValue:"Reset to shader default",modifiedValue:"Modified from shader default",inactiveReasons:{baseTexture:"Available after assigning a base texture.",litMaterial:"Available only when the lighting model is Lit.",normalTexture:"Available after assigning a normal texture.",occlusionTexture:"Available after assigning an AO texture.",alphaBlend:"Available only in Blend alpha mode.",alphaMask:"Available only in Mask alpha mode.",alphaTransparency:"Available only in Mask or Blend alpha mode."},assetEmissionColor:"Emission Color",assetEmissionIntensity:"Emission Intensity",assetEmissionTexture:"Emission Texture",assetEmissionMaskUrl:"Mask Texture",assetAlphaMode:"Alpha Mode",assetAlphaModeOpaque:"Opaque",assetAlphaModeMask:"Mask",assetAlphaModeBlend:"Blend",assetAlphaOpacity:"Opacity",assetAlphaCutoff:"Alpha Cutoff",assetAlphaTexture:"Alpha Texture",createSlotMaterial:"Add Material Slot",slotList:"Slot List",slotId:"Slot ID",slotOwnerPath:"Slot Owner Path",slotMaterialAsset:"Slot Material Asset",slotSourceMaterial:"Source Material",slotBindingPath:"Binding Path",reimportConflicts:"Reimport Material Conflicts",summaryAsset:e=>`Asset: ${e}`,summaryMissingAsset:"Missing asset",summaryCustomOverride:"Custom override",summaryInherit:"Inherit",summaryAddSlot:"Add slot",summarySlotCount:e=>`${e} slot${e===1?"":"s"}`,formatUsageCount:e=>e>0?`Used in ${e} place${e===1?"":"s"}`:"Unused",formatMaterialEditImpact:e=>e<=0?"This material is not used in the scene; edits only change the asset.":e===1?"Edits affect the current binding.":`Shared material: edits affect ${e} bindings.`,formatDuplicateMaterialImpact:e=>e<=0?"Copying creates an independently editable material asset.":e===1?"After copying, the current object or slot uses an independent material.":`After copying, the current object or slot uses an independent material; the original ${e} shared bindings are left unchanged.`,formatReimportConflictSummary:e=>`${e} material slot reimport difference${e===1?"":"s"} detected. Existing bindings are preserved until unmatched items are resolved.`,tooltips:{language:"Switch the artist material Inspector language.",materialAsset:"Choose a project-level shared material asset, or use the read-only Default PBR material.",slotMaterialAsset:"Leave this unset to preserve the original GLB material, or choose a material asset to override only this slot.",baseTexture:"Choose a project texture as the base texture. Texture adjustment parameters are applied to this texture first.",assetProfile:"Shared asset parameters affect every node bound to this material asset.",assetName:"Material asset names are display-only for bindings; stable material IDs survive renames.",assetKind:"Select the Shader Definition referenced by this material; compatible values survive a change.",lightingModel:"Lit materials respond to environment and directional lights; unlit materials are useful for UI, VFX, icons, and markers.",baseColor:"Base color is the final color factor multiplied after base texture adjustment. Editing the shared material asset affects every bound node.",duplicateForObject:"Copy the current material as an independent material for this object or slot, then bind it automatically.",brightness:"Base texture brightness multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",saturation:"Base texture saturation multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",contrast:"Base texture contrast multiplier. It only affects materials with a base texture; 1 leaves the texture unchanged.",hue:"Base texture hue offset in degrees. It only affects materials with a base texture.",normalTexture:"Choose a normal map applied to the runtime bump/normal channel for PBR and Standard materials.",normalStrength:"Normal strength. 1 keeps the texture at original strength.",metallic:"Metallic value from 0 to 1.",roughness:"Roughness value from 0 to 1.",metallicRoughnessTexture:"Choose a metallic-roughness texture. PBR runtime reads blue as metallic and green as roughness by the common GLB convention.",occlusionTexture:"Choose an ambient occlusion texture. Applies to PBR materials.",occlusionStrength:"Ambient occlusion strength. 1 keeps the texture at original strength.",emissionColor:"Emission color multiplied by emission intensity.",emissionIntensity:"Emission intensity. 0 means no emission.",emissionTexture:"Choose an emissive texture. If empty, the mask texture remains the fallback.",emissionMaskUrl:"Choose a grayscale texture to modulate emission intensity.",alphaMode:"Alpha mode: opaque, alpha-test mask, or alpha-blend transparency.",alphaOpacity:"Overall material opacity. 1 is fully opaque.",alphaCutoff:"Alpha-test cutoff threshold for mask mode.",alphaTexture:"Choose an alpha/opacity texture.",createSlotMaterial:"Enter a GLB child node or mesh ownerNodePath to add a slot binding with the Default PBR material.",slotList:"Material slots on the root object are a readonly overview.",slotOwnerPath:"Child node or mesh path targeted by this material slot.",reimportConflicts:"Slots whose source material changed or could not be matched after model reimport. Existing bindings are preserved instead of being silently deleted or overwritten."}}};function gr(e){return uS[e]??uS.zh}function Us(e){return e.metadata?.artistMaterialInspectorLanguage==="en"?"en":"zh"}var ZM={},mS=new WeakMap;function fS(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function pS(e,t){return cS(e,SS(t))}function QM(e){return{materialPickerTitle:e.materialPickerTitle,replace:e.replace,duplicateForObject:e.duplicateForObject,duplicateForObjectTooltip:e.tooltips.duplicateForObject,summaryMissingAsset:e.summaryMissingAsset,summaryInherit:e.summaryInherit,inheritNone:e.inheritNone}}function ew(e){return{formatUsageCount:e.formatUsageCount,formatEditImpact:e.formatMaterialEditImpact,formatDuplicateImpact:e.formatDuplicateMaterialImpact}}function SS(e){return{defaultMaterial:e.defaultMaterial,defaultStandardMaterial:e.defaultStandardMaterial,defaultMaterialMeta:e.defaultMaterialMeta,defaultStandardMaterialMeta:e.defaultStandardMaterialMeta,formatMaterialMeta:t=>`Material - ${t}`}}function yS(e,t,r,n,o={}){if(!t)return[];let a=o.materialShaderDefinitions?.get(t.shaderId)??De(t.shaderId),i=sw(e,t,r,n,o,a??void 0);if(ES(t,o))return[...i,j({path:`scene.materialAssets.${t.id}.properties`,label:r.assetProfile,value:r.defaultMaterialReadOnly,order:n+2,source:"Document",effect:"default",disabledReason:r.defaultMaterialReadOnly,tags:["ArtistMaterial","MaterialAsset"],tooltip:r.tooltips.assetProfile})];if(!a)return i;let s=[...a.inspector.fields].sort((c,d)=>c.order-d.order||c.path.localeCompare(d.path)).map(c=>tw({document:e,materialAsset:t,definition:a,fieldDefinition:c,text:r,context:o,orderOffset:n}));return[...i,...s]}function tw(e){let{fieldDefinition:t}=e,r=gS(e.text,t.labelKey,t.label??t.path),n=ow(e.text,t.tooltipKey,t.tooltip),o=hS(e.materialAsset.properties,t),a=t.control==="texture"&&ro(e.materialAsset.shaderId,t.path)?rw(e.materialAsset.properties,t):null,i;if(t.control==="texture")i=cw({path:`${dr}${e.materialAsset.id}.${t.path}`,label:r,value:typeof o=="string"?o:"",order:e.orderOffset+t.order,text:e.text,context:e.context,textureState:a??void 0,tooltip:n});else if(t.control==="number")i=lw(e.document,e.materialAsset,t.path,r,typeof o=="number"?o:Number(t.defaultValue),e.orderOffset+t.order,t,n,e.context.materialShaderDefinitions);else if(t.control==="enum")i=uw(e.document,e.materialAsset,t.path,r,String(o),e.orderOffset+t.order,(t.options??[]).map(d=>({value:d.value,label:gS(e.text,d.labelKey,d.label??d.value)})),n,e.context.materialShaderDefinitions);else{let d=t.control;i=qs(e.document,e.materialAsset,t.path,r,o,e.orderOffset+t.order,d,d,"immediate",n,e.context.materialShaderDefinitions)}let s=t.control==="color"?Zn(e.definition.shaderId,t.path,e.context.materialShaderDefinitions):null;i={...i,displayPrecision:t.displayPrecision,precision:t.precision,controlOptions:{...i.controlOptions,...t.control==="color"?{colorChannels:s?.kind==="color"&&s.channels===4?4:3}:{},materialShaderSectionId:t.sectionId,materialShaderUpdateClass:t.updateClass,materialShaderBinding:t.binding}};let c=t.conditions?.find(d=>!nw(e.definition,e.materialAsset.properties,d));return c&&(i=gw(i,!1,aw(e.text,c))),a?fw(i,e.text,a):mw(i,e.text,t.defaultValue)}function rw(e,t){let r=Ks(e,t.schemaPath??t.path);return r===void 0?"inherited":r===null?"cleared":"override"}function hS(e,t){if(t.control==="texture"){let n=Ks(e,t.schemaPath??t.path);return IS(n)}let r=Ks(e,t.path);return r===void 0?structuredClone(t.defaultValue):r}function Ks(e,t){let r=t.replace(/^properties\./,"").split(".").filter(Boolean),n=e;for(let o of r){if(!n||typeof n!="object"||Array.isArray(n))return;n=n[o]}return n}function nw(e,t,r){let n=e.inspector.fields.find(i=>i.path===r.path),o=n?hS(t,n):Ks(t,r.path);if(r.operator==="truthy")return!!o;let a=JSON.stringify(o??null)===JSON.stringify(r.value??null);return r.operator==="equals"?a:!a}function gS(e,t,r){let n=t?e[t]:void 0;return typeof n=="string"?n:r}function ow(e,t,r){let n=t?e.tooltips[t]:void 0;return typeof n=="string"?n:r}function aw(e,t){let r=t.inactiveReasonKey?e.inactiveReasons[t.inactiveReasonKey]:void 0;return typeof r=="string"?r:t.inactiveReason??"This field is inactive for the current material state."}function iw(e){return e.defaultMaterialAssetIds??[Pn,yo]}function ES(e,t){return wa(e,iw(t))||e.system?.preset==="default-pbr"||e.system?.preset==="default-standard"}function sw(e,t,r,n,o,a){if(!ES(t,o)){let i=o.materialShaderDefinitions??Mr;return[qs(e,t,"name",r.assetName,pS(t,r),n,"string","string","change",r.tooltips.assetName,i),{path:`${dr}${t.id}.shaderId`,label:r.assetKind,valueType:"string",control:"enum",value:t.shaderId,readOnly:!1,persistence:"document",commitMode:"immediate",order:n+1,tooltip:r.tooltips.assetKind,tags:["ArtistMaterial","MaterialAsset","ShaderDefinition"],options:i.list().map(s=>({value:s.shaderId,label:s.displayName})),controlOptions:{materialShaderSelector:!0,shaderId:t.shaderId,shaderVersion:a?.version,shaderRuntimeKind:a?.runtimeKind,...a?.sourceFile?{shaderSourceFile:a.sourceFile}:{}},validate:s=>typeof s=="string"&&i.get(s)?{ok:!0,value:s}:{ok:!1,message:"Unknown Shader Definition."},coerce:s=>typeof s=="string"?s.trim():""}]}return[fS(`${dr}${t.id}.name`,r.assetName,pS(t,r),n,r.tooltips.assetName),fS(`${dr}${t.id}.shaderId`,r.assetKind,a?.displayName??t.shaderId,n+1,r.tooltips.assetKind)]}function cw(e){let t=ou(e.context,e.value),r=Ws(e.context,e.text,e.value,t);return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:e.value,readOnly:!1,persistence:"document",commitMode:"change",order:e.order,tooltip:e.tooltip,tags:["ArtistMaterial","TextureAsset"],controlOptions:{...r,...e.textureState?{materialTextureState:e.textureState}:{},...!e.value&&e.textureState==="inherited"?{currentLabel:e.text.inheritTexture,currentMeta:e.text.inheritTextureMeta}:!e.value&&e.textureState==="cleared"?{currentLabel:e.text.clearTexture,currentMeta:e.text.clearTextureMeta}:{}},validate:n=>{let o=bS(e.context,e.path,n);return o.ok?{ok:!0,value:o.value}:{ok:!1,message:"Invalid texture selection."}},coerce:n=>{let o=bS(e.context,e.path,n);return o.ok?o.value:null}}}function Ws(e,t,r,n){return{...dS({textureAssets:e.textureAssets,currentTexture:n,currentValue:r,pickerText:dw(t),candidateValue:"assetId"})}}function ou(e,t){return Vs(e.textureAssets,t)}function IS(e){let t=typeof e?.textureAssetId=="string"?e.textureAssetId.trim():"";return t||(typeof e?.url=="string"?e.url.trim():"")}function bS(e,t,r){if(r==null||r==="")return{ok:!0,value:null};if(typeof r!="string")return{ok:!1};let n=r.trim();if(!n)return{ok:!0,value:null};if(!t.endsWith(".textureAssetId"))return{ok:!0,value:n};let o=Vs(e.textureAssets,n);return o?{ok:!0,value:o.id}:/^[A-Za-z0-9_-]+$/.test(n)?{ok:!0,value:n}:{ok:!0,value:null}}function dw(e){return{texturePickerTitle:e.texturePickerTitle,replace:e.replace,emptyTexture:e.emptyTexture,emptyTextureMeta:e.emptyTextureMeta,clearTexture:e.clearTexture,clearTextureMeta:e.clearTextureMeta,missingTexture:e.missingTexture,missingTextureMeta:e.missingTextureMeta,loadingTexture:e.loadingTexture,failedTexture:e.failedTexture}}function lw(e,t,r,n,o,a,i={},s,c){return{...qs(e,t,r,n,o,a,"number","number","live",s,c),...i.min!=null?{min:i.min}:{},...i.max!=null?{max:i.max}:{},...i.softMin!=null?{softMin:i.softMin}:{},...i.softMax!=null?{softMax:i.softMax}:{},step:i.step??.05}}function uw(e,t,r,n,o,a,i,s,c){return{...qs(e,t,r,n,o,a,"enum","enum","immediate",s,c),options:i,controlOptions:{variant:"segmented"}}}function qs(e,t,r,n,o,a,i,s,c,d,u){return{...lS({document:e,materialAsset:t,fieldPath:r,label:n,value:o,order:a,valueType:i,control:s,commitMode:c,tooltip:d,pathPrefix:dr}),validate:l=>{let m=rt(r,l);return zt(r,m,t.shaderId,u)?{ok:!0,value:m}:{ok:!1,message:`Invalid material asset field: ${r}.`}},coerce:l=>rt(r,l)}}function mw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:structuredClone(r),modified:!pw(e.value,r),resetLabel:t.resetValue,modifiedLabel:t.modifiedValue}}}function fw(e,t,r){return e.readOnly?e:{...e,controlOptions:{...e.controlOptions,resetValue:"",resetMode:"inherit",modified:r!=="inherited",resetLabel:t.inheritTexture,modifiedLabel:r==="cleared"?t.clearTexture:t.modifiedValue}}}function pw(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function gw(e,t,r){return t?e:{...e,controlOptions:{...e.controlOptions,conditionalInactive:!0,conditionalInactiveReason:r}}}function PS(e,t,r,n){let o=r.currentAsset??ee(e,r.value);return{path:r.path,label:r.label,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.value,readOnly:!1,persistence:"document",commitMode:"change",order:r.order,controlOptions:yw(Hs(e,o,r.text,r.value,n,r.previewContext),r.currentAction),tooltip:r.text.tooltips.materialAsset,tags:["ArtistMaterial","MaterialAsset"],document:e,validate:a=>{let i=Qi(a);return i&&Vt(e,i)?{ok:!0,value:a}:a==null||a===""?{ok:!0,value:a}:typeof a=="string"&&Vt(e,a)?{ok:!0,value:a}:{ok:!1,message:`Material asset not found: ${String(a)}`}},coerce:a=>typeof a=="string"?a.trim():a,effect:bw(t,r.value),validation:Sw(r.value,o,r.text),disabledReason:t==="group"?"Groups do not own materials.":void 0}}function bw(e,t){return e==="group"?"unsupported":t.trim()?"override":void 0}function Sw(e,t,r){let n=e.trim();if(!(!n||t))return{status:"error",code:"material.asset.missing",message:`${r.summaryMissingAsset}: ${n}`}}function yw(e,t){return t?{...e,currentActionId:t.actionId,currentActionParams:Object.fromEntries(Object.entries(t.params).filter(r=>typeof r[1]=="string"&&r[1].length>0))}:e}function hw(e,t,r){return PS(e,t,r,_e.getCachedUsageIndex(e))}function Hs(e,t,r,n,o,a={}){return{..._e.createPickerControlOptions({materialAssets:e.scene.materialAssets??[],currentAsset:t,currentValue:n,pickerText:QM(r),displayText:SS(r),document:e,ownershipText:ew(r),previewContext:a},o),actionDisabledReason:r.batchReplaceUnsupported}}function Ew(e,t,r,n,o={}){if(o.textureAssets?.length||o.resolveTextureAssetUrl)return Hs(e,t,r,n,_e.getCachedUsageIndex(e),o);let a=mS.get(e);a||(a=new WeakMap,mS.set(e,a));let i=a.get(r);i||(i=new WeakMap,a.set(r,i));let s=t??ZM,c=i.get(s);c||(c=new Map,i.set(s,c));let d=c.get(n);if(d)return d;let u=Hs(e,t,r,n,_e.getCachedUsageIndex(e),o);return c.set(n,u),u}var Iw={createSelectorInspectorPropertyWithUsage:PS,createSelectorInspectorPropertyWithCachedUsage:hw,createPickerControlOptionsWithUsage:Hs,createPickerControlOptionsWithCachedUsage:Ew},Dn=Iw;function TS(e,t,r){let n=qp(e,t);if(n.state==="asset"&&n.materialAsset){let o=Ub(n.materialAsset),a=o==="default-pbr"?r.defaultMaterial:o==="default-standard"?r.defaultStandardMaterial:n.materialAsset.name??n.materialAsset.id;return r.summaryAsset(a)}return n.state==="missing-asset"?r.summaryMissingAsset:n.state==="override"?r.summaryCustomOverride:r.summaryInherit}function xS(e,t,r){let n=lr(e,t).length;return n>0?r.summarySlotCount(n):r.summaryAddSlot}function Pw(e,t,r,n,o,a={}){let i=gr(Us(t)),s=[];return lr(e,t).forEach((d,u)=>{let l=Ut(d)??d.slotId,m=nl(t,d),f=o?.materialSlotBindings?.[d.slotId]??m,S=f?.materialAssetId?ee(e,f.materialAssetId):null,g=(u+1)*100,b=ns(d),y=nt(d)[0],E=y==null?null:ho(d,y)?.profile,I=Dn.createSelectorInspectorPropertyWithUsage(e,r,{path:b,label:d.label||au(l,u,i),value:m?.materialAssetId??"",order:g,text:i,currentAsset:S,currentAction:S?{actionId:"material.open-asset",params:{materialAssetId:S.id,browserAssetId:`material:${S.id}`,sourceObjectId:t.id,sourceBindingPath:b}}:E?{actionId:"material.create-from-source",params:{sourceObjectId:t.id,sourceBindingPath:b}}:void 0,previewContext:a},n);s.push(Tw(I,d,f,i,a))}),s}function Tw(e,t,r,n,o){let a=nt(t)[0],i=a==null?t.materialNames?.[0]??t.materialName??null:xn(t,a),s=a==null?null:ho(t,a)?.profile,c=s?Bt(Ns(s),o):void 0,d=i?`GLB \u6E90\u6750\u8D28\uFF1A${i}`:"GLB \u6E90\u6750\u8D28",u=e.controlOptions??{},l=Array.isArray(u.candidates)?u.candidates.map(f=>f&&typeof f=="object"&&!Array.isArray(f)&&f.value===""?{...f,label:"\u6062\u590D\u7EE7\u627F",meta:d,...c?{preview:c}:{}}:f):void 0,m=r?.materialAssetId&&typeof u.currentMeta=="string"&&u.currentMeta?`${u.currentMeta} \xB7 ${d}`:d;return{...e,tooltip:n.tooltips.slotMaterialAsset,controlOptions:{...u,...r?.materialAssetId?{}:{currentLabel:i?`\u7EE7\u627F GLB\uFF1A${i}`:"\u7EE7\u627F GLB \u539F\u6750\u8D28",...c?{currentPreview:c}:{}},currentMeta:m,...l?{candidates:l}:{},...i?{sourceMaterialName:i}:{}}}}function xw(e,t,r,n){let o=lr(e,t);if(o.length===0)return[];let a=[],i=zs(e,t),s=ss(e,t.id)??t.overrides;i.issues.length>0&&a.push(ww("asset.materialSlots.reimportConflicts",r.reimportConflicts,Aw(i.issues,r),-1,r.tooltips.reimportConflicts));let c=o.map((d,u)=>Dw(e,t,d,u,r,n,s));return a.push({path:"asset.materialSlots",label:r.slotList,valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:o.length,slots:c},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:r.slotMaterialAsset,slotId:r.slotId,ownerNodePath:r.slotOwnerPath,sourceMaterial:r.slotSourceMaterial,primitive:"Primitive",triangles:"Triangles",bounds:"Bounds",bindingPath:r.slotBindingPath},slots:c},tags:["ArtistMaterial","MaterialSlot","Readonly"],tooltip:r.tooltips.slotList,document:e}),a}function Aw(e,t){let r=e.map(n=>{let o=n.label||n.ownerNodePath||n.slotId||n.previousSlotId||n.bindingPath||"slot";if(n.reason==="source-material-changed"){let a=n.previousSourceMaterialIndex==null?"?":`#${n.previousSourceMaterialIndex}`,i=n.sourceMaterialIndex==null?"?":`#${n.sourceMaterialIndex}`;return`${o}: source material ${a} -> ${i}; ${n.materialAssetId??t.inheritNone}`}return n.reason==="slot-removed"?`${o}: removed slot; ${n.materialAssetId??t.inheritNone}`:`${o}: ${n.status}`});return[t.formatReimportConflictSummary(e.length),...r].join(`
3
+ `)}function Dw(e,t,r,n,o,a,i){let s=nl(t,r),c=i?.materialSlotBindings?.[r.slotId]??s,d=ee(e,c?.materialAssetId??Tn),u=Dn.createPickerControlOptionsWithUsage(e,d,o,s?.materialAssetId??"",a),l=nt(r),m=l[0],f=m==null?null:xn(r,m),S=r.sourceSurfaces[0],g=S.ownerNodePath;return{key:Xp(r),label:r.label||au(g,n,o),slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:g,materialAssetId:s?.materialAssetId??"",materialLabel:u.currentLabel??o.inheritNone,materialMeta:u.currentMeta??o.summaryInherit,...u.currentPreview?{materialPreview:u.currentPreview}:{},...m==null?{}:{sourceMaterialIndex:m},...l.length?{sourceMaterialIndices:l}:{},...f?{sourceMaterialName:f}:{},...r.materialNames?.length?{materialNames:r.materialNames}:{},...r.sourceSurfaces.length===1&&typeof S.triangleCount=="number"?{triangleCount:S.triangleCount}:{},...r.sourceSurfaces.length===1&&S.boundingBox?{boundingBox:S.boundingBox}:{},bindingPath:ns(r)}}var Mw={createChildMaterialBindingInspectorPropertiesWithUsage:Pw,createReadonlyMaterialSlotListInspectorPropertiesWithUsage:xw},AS=Mw;function au(e,t,r){let n=e.split("/").filter(Boolean).pop()??e;return`${r.slotMaterialAsset} ${t+1}: ${n}`}function ww(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var DS="materialAsset::",kw=5;function Ow(e){return e.startsWith(DS)&&e.slice(DS.length).trim()||null}function Rw(e,t,r,n,o,a){let i=[],s=Us(t),c=gr(s),d=t.overrides?.materialBinding,u=ss(e,t.id)??t.overrides,l=u?.materialBinding??d,m=l?.materialAssetId??Tn,f=ee(e,m),S=l?.materialAssetId?l:{...l,materialAssetId:Tn};if(!Jp(e,t)){let y="overrides.materialBinding.materialAssetId";i.push({id:"artistMaterial",title:c.title,order:46,placement:"body",summary:TS(S,f,c),persistence:"document",collapsedByDefault:!1,properties:[Dn.createSelectorInspectorPropertyWithUsage(e,r,{path:y,label:c.materialCard,value:d?.materialAssetId??"",order:0,text:c,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,sourceBindingPath:y}},previewContext:n},a)]})}let b=r==="primitive"?[]:AS.createChildMaterialBindingInspectorPropertiesWithUsage(e,t,r,a,u,n);return b.length>0&&i.push({id:"artistMaterialSlots",title:c.slotTitle,order:48,placement:"body",summary:xS(e,t,c),persistence:"document",collapsedByDefault:!1,properties:b}),i}function Cw(e,t,r,n){let o=Ow(t),a=o?ee(e,o):null;if(!a)return null;let i=gr("zh"),s=n.forMaterial(a.id),c=yS(e,a,i,0,r),d=`scene.materialAssets.${a.id}.properties`,u=`${d}.`,l=I=>I.path===d||I.path.startsWith(u),m=c.filter(I=>!l(I)),f=c.filter(l),S=[{path:`scene.materialAssets.${a.id}.preview`,label:a.name||a.id,valueType:"object",control:"custom",customControl:"asset-picker-card",value:a.id,readOnly:!0,persistence:"readonly",commitMode:"immediate",order:-10,controlOptions:{currentMaterialAssetId:a.id,currentMaterialShaderId:a.shaderId,...a.definitionVersion!=null?{currentMaterialDefinitionVersion:a.definitionVersion}:{},currentLabel:a.name||a.id,currentMeta:a.shaderId,currentPreview:Bt(a.properties,r)},document:e},...m,Nw(`scene.materialAssets.${a.id}.usageCount`,"\u5F15\u7528",i.formatUsageCount(s.length),10)],g=[io({path:`scene.materialAssets.${a.id}.actions.locate`,label:"\u5728 Assets \u4E2D\u5B9A\u4F4D",actionId:"material.locate-asset",icon:"asset",params:{materialAssetId:a.id,browserAssetId:`material:${a.id}`},order:20,tooltip:"\u5728 Assets \u9762\u677F\u4E2D\u5B9A\u4F4D\u5F53\u524D\u6750\u8D28\u3002",disabled:!1}),io({path:`scene.materialAssets.${a.id}.actions.back`,label:"\u8FD4\u56DE\u6765\u6E90",actionId:"material.back-to-owner",icon:"chevron-left",params:{materialAssetId:a.id},order:21,tooltip:"\u8FD4\u56DE\u6253\u5F00\u5F53\u524D\u6750\u8D28\u524D\u7684\u5BF9\u8C61\u6216 Prefab Inspector\u3002",disabled:!1})],b=[{id:"materialAssetSummary",title:"Material",order:10,regionId:$i,persistence:"readonly",collapsedByDefault:!1,properties:S}];b.push({id:"materialAssetNavigation",title:"\u5BFC\u822A",order:15,placement:"body",persistence:"readonly",collapsedByDefault:!1,properties:g}),b.push({id:"materialReferences",title:`\u4F7F\u7528\u4F4D\u7F6E (${s.length})`,order:20,placement:"body",persistence:"readonly",collapsedByDefault:s.length===0,properties:[{path:`scene.materialAssets.${a.id}.references.browser`,label:"\u4F7F\u7528\u4F4D\u7F6E",valueType:"object",control:"custom",customControl:"material-reference-list",controlOptions:{previewLimit:kw,items:s.map((I,P)=>({key:`${I.scope}:${I.gameObjectId}:${I.bindingPath}:${P}`,label:I.label,scope:I.scope,actionId:"material.open-owner",params:Object.fromEntries(Object.entries({materialAssetId:a.id,ownerScope:I.scope,sourceObjectId:I.gameObjectId,sourceBindingPath:I.bindingPath,slotId:I.slotId,ownerNodePath:I.ownerNodePath,prefabAssetId:I.prefabAssetId,prefabNodeId:I.prefabNodeId}).filter(A=>typeof A[1]=="string"&&A[1].length>0))}))},value:s.length,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:0,tooltip:s.length>0?"\u67E5\u770B\u4F7F\u7528\u5F53\u524D\u6750\u8D28\u7684 Scene \u5BF9\u8C61\u548C Prefab \u8282\u70B9\u3002":"\u5F53\u524D\u672A\u88AB\u4EFB\u4F55\u5BF9\u8C61\u6216 Prefab \u4F7F\u7528\u3002",document:e}]});let y=r.materialShaderDefinitions?.get(a.shaderId)??De(a.shaderId);for(let[I,P]of[...y?.inspector.sections??[]].sort((A,$)=>A.order-$.order||A.id.localeCompare($.id)).entries())MS(b,{id:`material${P.id.charAt(0).toUpperCase()}${P.id.slice(1)}`,title:P.title,order:P.order,properties:[...I===0?f.filter(A=>A.path===d):[],...f.filter(A=>A.controlOptions?.materialShaderSectionId===P.id)]});let E=new Set(b.flatMap(I=>I.properties.map(P=>P.path)));return MS(b,{id:"materialAdvanced",title:"Advanced",order:80,properties:f.filter(I=>!E.has(I.path))}),{targetIds:[t],activeId:t,label:a.name||a.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"materialAsset",capabilities:["material"],document:e},sections:b}}function vw(e,t,r,n={},o){return Rw(e,t,r,n,o,_e.getCachedUsageIndex(e))}function Gw(e,t,r={}){return Cw(e,t,r,_e.getCachedUsageIndex(e))}var jw={createArtistMaterialInspectorSectionsWithCachedUsage:vw,createEditorSceneMaterialAssetInspectorObjectWithCachedUsage:Gw},iu=jw;function MS(e,t){t.properties.length!==0&&e.push({...t,placement:"body",persistence:t.properties.some(r=>r.persistence==="document")?"document":"readonly",collapsedByDefault:!1})}function Nw(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}var wS="modelAsset::";function Fw(e){return e.startsWith(wS)&&e.slice(wS.length).trim()||null}function kS(e,t,r={}){let n=Fw(t),o=n?_w(e,n,r.modelAssets):null;if(!o)return null;let a=Bw(o),i=[$w(o)];return i.push(Lw(e,o,a,r)),{targetIds:[t],activeId:t,label:o.displayName??o.id,document:e,selection:{targetIds:[t],activeId:t,scopeType:"scene",targetKind:"modelAsset",capabilities:["asset","materialSlots"],document:e},sections:i}}function _w(e,t,r){let n=e.assets.find(a=>a.id===t);if(n&&n.type!=="glb")return null;let o=r?.find(a=>a.assetId===t&&a.type==="glb");return o?Fr(n??{id:t,type:"glb"},o):n??null}function $w(e){let t=Vw(e.metadata?.relativePath);return{id:"modelAssetSummary",title:"Model Asset",order:10,regionId:$i,persistence:"readonly",collapsedByDefault:!1,properties:[Oa(`assets.${e.id}.displayName`,"\u540D\u79F0",e.displayName??e.id,0),Oa(`assets.${e.id}.id`,"Asset ID",e.id,1),Oa(`assets.${e.id}.type`,"\u683C\u5F0F","GLB / glTF",2),...t?[Oa(`assets.${e.id}.relativePath`,"\u6E90\u6587\u4EF6",t,3)]:[]]}}function Lw(e,t,r,n){let o=`\u6750\u8D28\u63D2\u69FD (${r.length})`;if(r.length===0)return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:"\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",persistence:"readonly",collapsedByDefault:!1,properties:[Oa(`assets.${t.id}.materialSlots.empty`,"\u89E3\u6790\u7ED3\u679C","\u672A\u68C0\u6D4B\u5230\u6750\u8D28\u63D2\u69FD",0)]};let a=r.map((s,c)=>zw(s,c,n)),i={path:`assets.${t.id}.materialSlots`,label:"GLB \u6E90\u6750\u8D28",valueType:"object",control:"custom",customControl:"material-slot-list",value:{count:r.length,slots:a},readOnly:!0,persistence:"readonly",commitMode:"immediate",order:0,controlOptions:{labels:{material:"\u5F53\u524D\u6765\u6E90",slotId:"Slot ID",ownerNodePath:"\u8282\u70B9\u8DEF\u5F84",sourceMaterial:"\u6E90\u6750\u8D28",primitive:"Primitive",triangles:"\u4E09\u89D2\u9762",bounds:"Bounds",bindingPath:"\u7ED1\u5B9A\u8DEF\u5F84"},slots:a},tags:["Asset","MaterialSlot","Readonly"],tooltip:"GLB / glTF \u6587\u4EF6\u4E2D\u89E3\u6790\u51FA\u7684\u53EA\u8BFB\u6750\u8D28\u63D2\u69FD\u3002",document:e};return{id:"modelAssetMaterialSlots",title:o,order:20,placement:"body",summary:`${r.length} \u4E2A\u5DF2\u89E3\u6790\u6E90\u63D2\u69FD`,persistence:"readonly",collapsedByDefault:!1,properties:[i]}}function zw(e,t,r){let n=e.sourceSurfaces[0],o=nt(e),a=n.sourceMaterialIndex??o[0],i=a==null?e.materialNames?.[0]??e.materialName??null:xn(e,a),s=a==null?null:ho(e,a)?.profile??null,c=e.label||i||`Material Slot ${t+1}`;return{key:e.slotId,label:c,slotId:e.slotId,sourceSurfaces:structuredClone(e.sourceSurfaces),ownerNodePath:n.ownerNodePath,materialLabel:i??c,materialMeta:"\u7EE7\u627F GLB \u6E90\u6750\u8D28",...s?{materialPreview:Bt(s,r)}:{},...a==null?{}:{sourceMaterialIndex:a},...o.length>0?{sourceMaterialIndices:o}:{},...i?{sourceMaterialName:i}:{},...e.materialNames?.length?{materialNames:e.materialNames}:{},...e.sourceSurfaces.length===1&&typeof n.triangleCount=="number"?{triangleCount:n.triangleCount}:{},...e.sourceSurfaces.length===1&&n.boundingBox?{boundingBox:n.boundingBox}:{}}}function Bw(e){return(Array.isArray(e.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(no).filter(r=>!!r)}function Oa(e,t,r,n){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document"})}function Vw(e){return typeof e=="string"&&e.trim()?e.trim():""}function Ra(e,t,r,n={}){if(t.type==="prefab"){let s=OS(e,t),c=s?Fr(s,t):su(t),d=CS(e,t,c,r,n),u=Kw(s?e.assets.map(l=>l.id===c.id?c:l):[...e.assets,c],c);return{document:{...e,assets:u,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,d]}},gameObject:d}}let o=OS(e,t),a=o?Fr(o,t):su(t),i=t.type==="texture"?Uw(e,t,a.id,r,n):RS(e,t,a.id,r,n);return{document:{...e,assets:o?e.assets.map(s=>s.id===a.id?a:s):[...e.assets,a],scene:{...e.scene,gameObjects:[...e.scene.gameObjects,i]}},gameObject:i}}function Uw(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,kind:"transform",...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},metadata:{...t.metadata??{},assetId:t.assetId,assetType:"texture"},components:[Mt(d),{type:"ImageRenderer",assetId:r,size:{width:1,height:1}}]}}function su(e){return{id:e.assetId,guid:e.guid,type:e.type,displayName:e.displayName,category:e.category,warmupCount:e.warmupCount,singleton:e.singleton,materialMode:e.materialMode,defaults:Js(e.defaults),prefab:Js(e.prefab),external:Js(e.external),metadata:Js(e.metadata)}}function RS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return{id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},active:!0,shadow:{cast:"none",receive:"none"},components:[Mt(d),{type:"ModelRenderer",assetId:r}]}}function CS(e,t,r,n,o={}){let a=e.scene.gameObjects.map(u=>u.id),i=st(cu(e),o.name??t.displayName,{fallbackName:t.assetId}),s=lu(a,o.objectId,i),c=uu(e,o.parentId),d=du(e,c,n,o);return rg({id:s,guid:(o.createGameObjectGuid??he)(),name:i,...c?{parentId:c}:{},prefabAsset:r,transform:Mt(d),metadata:{...t.metadata??{},assetId:t.assetId,assetType:"prefab"}})}function cu(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function OS(e,t){return e.assets.find(r=>r.id===t.assetId||r.guid&&r.guid===t.guid)}function Kw(e,t){let r=ca(t);if(!r||e.some(a=>a.id===r))return[...e];let n=t.prefab?.sourceAssetGuid,o=!!n&&!e.some(a=>a.guid===n);return[...e,{id:r,...o?{guid:n}:{},type:"glb",displayName:r,category:"Model",metadata:{sourcePrefabId:t.id}}]}function du(e,t,r,n){if(n.localTransform)return structuredClone(n.localTransform);let o=Wl(e,r);if(!t)return o;let a=n.resolveLocalTransform?.({document:e,parentId:t,worldTransform:o})??ur(e,t,o);if(!a)throw new Error(`Cannot resolve parent-local asset placement transform for ${t}.`);return a}function lu(e,t,r){if(t===void 0)return xa(e,Rs(r));if(xa([],t)!==t||e.includes(t))throw new Error(`Requested asset instance id is invalid or already used: ${t}`);return t}function uu(e,t){let r=t??ye(e);if(r){if(!e.scene.gameObjects.some(n=>n.id===r))throw new Error(`Requested asset instance parent does not exist: ${r}`);return r}}function Js(e){return e==null?void 0:structuredClone(e)}function Hw(e){return!!e&&tt(e)}function pu(e,t,r={}){let n=t.type==="document.replace"?t.document:GS({document:e,patch:t.patch,options:r});return r.normalizeDocument?.(n,t)??n}function GS(e){let{document:t,patch:r,options:n={}}=e;if(r.kind==="serialized-property")return va({document:t,patch:r,validateField:n.serializedProperty?.validateField});if(r.kind==="game-object.field")return Mn(t,r.targetId,r.path,r.value,n.field);if(r.kind==="game-object.field-batch")return Ca(t,r.targetIds,r.path,r.value,n.field);if(r.kind==="game-object.create-from-asset")return Ra(t,r.assetItem,r.placement,{...n.assetPlacement??{},...r.name?{name:r.name}:{}}).document;if(r.kind==="game-object.transform")return me(r.targetId)?t:hn(t,r.targetId,{transform:r.transform});if(r.kind==="game-object.transform-batch")return r.targets.reduce((o,a)=>{if(me(a.targetId))return o;let i=_(o,a.targetId),s=i?G(i):null;if(!s)return o;if(Hw(a.transform))return hn(o,a.targetId,{transform:a.transform});if(Ee(s))return o;let c=a.transform;return hn(o,a.targetId,{position:c.position?{...s.position,...c.position}:void 0,rotation:c.rotation?{...s.rotation,...c.rotation}:void 0,scale:c.scale?{...ot(s,"scale"),...c.scale}:void 0})},t);if(r.kind==="game-object.duplicate-selection"){let o=new Set(t.scene.gameObjects.map(l=>l.id)),a=n.isProtectedDuplicateSource??Ww,i=new Set(t.scene.gameObjects.filter(l=>a(l,t)).map(l=>l.id)),s=new Set,c=[];for(let l of r.gameObjects)o.has(l.id)||s.has(l.id)||Z(l)||a(l,t)||(s.add(l.id),c.push(l));let d=Jw(c,o,i);if(d.length===0)return t;let u=[...t.scene.gameObjects,...d];return{...t,scene:{...t.scene,gameObjects:r.order?mu(u,r.order):u}}}if(r.kind==="game-object.rename"){let o=r.name.trim();if(!o)return t;let a=t.scene.gameObjects.find(i=>i.id===r.targetId);return!a||a.name===o?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(i=>i.id===r.targetId?{...i,name:o}:i)}}}if(r.kind==="game-object.create-group"||r.kind==="game-object.create-primitive")return t.scene.gameObjects.some(o=>o.id===r.gameObject.id)?t:{...t,scene:{...t.scene,gameObjects:[...t.scene.gameObjects,r.gameObject]}};if(r.kind==="game-object.delete-subtree"){if(r.targetIds.some(me))return t;let o=wt(t,r.targetIds);if(o.size===0)return t;let a=n.isProtectedDeleteTarget??qw;return t.scene.gameObjects.some(i=>o.has(i.id)&&a(i,t))?t:{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.filter(i=>!o.has(i.id))}}}if(r.kind==="game-object.reparent"){if(me(r.targetId))return t;let o=t.scene.gameObjects.find(c=>c.id===r.targetId);if(!o)return t;let a=r.transform?mr(r.transform):null;if(r.transform&&!a)return t;let i=!!a&&!vS(G(o),a);if(o.parentId===r.parentId&&!i)return t;let s={...o,parentId:r.parentId,components:i?o.components.map(c=>c.type==="Transform"?a:c):o.components};return{...t,scene:{...t.scene,gameObjects:t.scene.gameObjects.map(c=>c.id===r.targetId?s:c)}}}if(r.kind==="game-object.hierarchy-move"){let o=r.moves.filter(l=>!me(l.targetId)),a=new Map;for(let l of o){let m=mr(l.transform);if(!m)return t;a.set(l.targetId,m)}let i=new Map(o.map(l=>[l.targetId,l]));if(i.size===0)return t;let s=!1,c=t.scene.gameObjects.map(l=>{let m=i.get(l.id);if(!m)return l;let f=a.get(m.targetId),S=!vS(G(l),f);if(l.parentId===m.parentId&&!S)return l;let g={...l,parentId:m.parentId,components:S?l.components.map(b=>b.type==="Transform"?f:b):l.components};return s=!0,g}),d=mu(c,r.order),u=d.some((l,m)=>l!==t.scene.gameObjects[m]);return!s&&!u?t:{...t,scene:{...t.scene,gameObjects:d}}}if(r.kind==="game-object.group-selection"){if(Z(r.gameObject)||t.scene.gameObjects.some(s=>s.id===r.gameObject.id))return t;let o=new Set(r.childIds.filter(s=>!me(s)));if(o.size===0)return t;let a=new Map;for(let[s,c]of Object.entries(r.childTransforms)){if(!o.has(s))continue;let d=mr(c);if(!d)return t;a.set(s,d)}let i=t.scene.gameObjects.map(s=>{if(!o.has(s.id))return s;let c=a.get(s.id);return{...s,parentId:r.gameObject.id,components:c?s.components.map(d=>d.type!=="Transform"?d:c):s.components}});return{...t,scene:{...t.scene,gameObjects:mu([...i,r.gameObject],r.order)}}}return t}function Ww(e){return Dt(e)}function qw(e){return At(e)}function Jw(e,t,r){let n=new Map(e.map(a=>[a.id,a])),o=!0;for(;o;){o=!1;for(let a of[...n.values()])!a.parentId||n.has(a.parentId)||t.has(a.parentId)&&!r.has(a.parentId)||(n.delete(a.id),o=!0)}return e.filter(a=>n.has(a.id))}function mu(e,t){let r=new Map(e.map(a=>[a.id,a])),n=[],o=new Set;for(let a of t){if(o.has(a))continue;let i=r.get(a);i&&(n.push(i),o.add(a))}return[...n,...e.filter(a=>!o.has(a.id))]}function vS(e,t){if(!e)return!1;let r=Ee(e),n=Ee(t);return r||n?r&&n&&e.matrix.every((o,a)=>o===t.matrix[a]):fu(e.position,t.position)&&fu(e.rotation,t.rotation)&&fu(ot(e,"scale"),ot(t,"scale"))}function fu(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z}var Xw="main_camera",Yw="environment_light",Zw="sun_light",Xs={projection:"orthographic",alpha:3.9269908169872414,beta:.8,radius:14,orthoSize:6,fov:.85,targetOffset:{x:0,y:0,z:0},minZ:1,maxZ:1e4,lowerBetaLimit:.8,upperBetaLimit:.8,lowerRadiusLimit:14,upperRadiusLimit:14,inertia:.9,targetScreenOffset:{x:0,y:0},inspectorLanguage:"zh"},Na={type:"directional",intensity:2,direction:{...ps},diffuseColor:{r:1,g:1,b:1},inspectorLanguage:"zh"},wn={type:"hemispheric",intensity:.8,diffuseColor:{r:1,g:1,b:1},groundColor:{r:.48,g:.52,b:.62},inspectorLanguage:"zh"};function NS(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function FS(e){let t=yu({...e,kind:"transform",transformType:"camera",camera:Fa(e.camera)});return delete t.light,delete t.primitive,hu(t,e)?e:t}function Su(e,t){let r=yu({...e,name:t==="hemispheric"?"Environment Light":"Directional Light",kind:"transform",transformType:"light",light:kn(e.light,t)});return delete r.camera,delete r.primitive,hu(r,e)?e:r}function _S(e){let t=yu({...e,kind:"transform",transformType:"plain"});return delete t.camera,delete t.light,delete t.primitive,hu(t,e)?e:t}function yu(e){return G(e)?e:{...e,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},...e.components]}}function Fa(e){let t=Xs;return{...t,...e??{},projection:Qw(e?.projection),fov:Ga(e?.fov,t.fov??.85),targetOffset:nk(e?.targetOffset)?{...e.targetOffset}:{...t.targetOffset??{x:0,y:0,z:0}},minZ:Ga(e?.minZ,t.minZ??1),maxZ:Ga(e?.maxZ,t.maxZ??1e4),lowerBetaLimit:ja(e?.lowerBetaLimit,t.lowerBetaLimit??t.beta),upperBetaLimit:ja(e?.upperBetaLimit,t.upperBetaLimit??t.beta),lowerRadiusLimit:Ga(e?.lowerRadiusLimit,t.lowerRadiusLimit??t.radius),upperRadiusLimit:Ga(e?.upperRadiusLimit,t.upperRadiusLimit??t.radius),inertia:tk(e?.inertia,t.inertia??.9),targetScreenOffset:rk(e?.targetScreenOffset)?{...e.targetScreenOffset}:{...t.targetScreenOffset??{x:0,y:0}},inspectorLanguage:ek(e?.inspectorLanguage)}}function $S(e,t){return jS(e,t,{valueField:"beta",lowerField:"lowerBetaLimit",upperField:"upperBetaLimit",minValue:Number.NEGATIVE_INFINITY}),jS(e,t,{valueField:"radius",lowerField:"lowerRadiusLimit",upperField:"upperRadiusLimit",minValue:.001}),e}function jS(e,t,r){let n=`camera.${r.valueField}`,o=`camera.${r.lowerField}`,a=`camera.${r.upperField}`,i=ja(e[r.valueField],Xs[r.valueField]),s=ja(e[r.lowerField],i),c=ja(e[r.upperField],i);Number.isFinite(r.minValue)&&(i=Math.max(r.minValue,i),s=Math.max(r.minValue,s),c=Math.max(r.minValue,c)),c<s&&(t===a?s=c:c=s),t===o||t===a?i=Math.min(c,Math.max(s,i)):t===n&&(i<s&&(s=i),i>c&&(c=i)),e[r.valueField]=i,e[r.lowerField]=s,e[r.upperField]=c}function Qw(e){return e==="perspective"?"perspective":"orthographic"}function ek(e){return e==="en"?"en":"zh"}function LS(e){return e==="en"?"en":"zh"}function ja(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Ga(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function tk(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:t}function rk(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)}function nk(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)&&typeof t.z=="number"&&Number.isFinite(t.z)}function zS(e){return e.maxZ!=null&&e.minZ!=null&&e.maxZ<=e.minZ||e.upperBetaLimit!=null&&e.lowerBetaLimit!=null&&e.upperBetaLimit<e.lowerBetaLimit||e.upperRadiusLimit!=null&&e.lowerRadiusLimit!=null&&e.upperRadiusLimit<e.lowerRadiusLimit}function ok(e,t){return e?.type==="hemispheric"?"hemispheric":e?.type==="directional"?"directional":t}function kn(e,t="directional"){return ok(e,t)==="hemispheric"?ik(e):ak(e)}function ak(e){let t=Na,r=e?.type==="directional"?e:void 0;return{...t,...r??{},type:"directional",direction:{...t.direction,...r?.direction??{}},diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,inspectorLanguage:LS(BS(r))}}function ik(e){let t=wn,r=e?.type==="hemispheric"?e:void 0;return{...t,...r??{},type:"hemispheric",diffuseColor:r?.diffuseColor?{...t.diffuseColor,...r.diffuseColor}:t.diffuseColor,groundColor:r?.groundColor?{...t.groundColor,...r.groundColor}:t.groundColor,inspectorLanguage:LS(BS(r))}}function BS(e){return e&&typeof e=="object"?e.inspectorLanguage:void 0}function hu(e,t){return JSON.stringify(e)===JSON.stringify(t)}function VS(e,t,r){return{id:Eu(t,Xw,r),guid:r.createGameObjectGuid(),name:"Main Camera",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"camera",camera:Fa(void 0),components:[{type:"Transform",position:{x:0,y:5,z:-8},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function US(e,t,r){return{id:Eu(t,Zw,r),guid:r.createGameObjectGuid(),name:"Directional Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:kn(void 0,"directional"),components:[{type:"Transform",position:{x:0,y:4,z:-3},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function KS(e,t,r){return{id:Eu(t,Yw,r),guid:r.createGameObjectGuid(),name:"Environment Light",kind:"transform",...e?{parentId:e}:{},active:!0,transformType:"light",light:kn(void 0,"hemispheric"),components:[{type:"Transform",position:{x:0,y:3,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]}}function Eu(e,t,r){let n=r.createUniqueId([...e],t);return e.add(n),n}function WS(e,t){let r=t.name.trim();if(!r)return null;let n=_(e,t.id);return!n||n.name===r?null:{label:`Rename ${n.name??n.id} to ${r}`,patch:{kind:"game-object.rename",targetId:t.id,name:r},changedId:t.id}}function qS(e,t){let r=ry(e,t);if(r===null)return null;let n=st(Qs(e),t.name,{fallbackName:"Empty"}),o=XS(e.scene.gameObjects.map(i=>i.id),t.objectId,n);if(!o)return null;let a={id:o,guid:he(),name:n,kind:"transform",transformType:"plain",...r?{parentId:r}:{},active:!0,components:[{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Create empty ${n}`,patch:{kind:"game-object.create-group",gameObject:a},createdId:o,changedIds:[o]}}function JS(e,t){let r=yk(t.shape);if(!r)return null;let n=mk(e,t);if(n===null)return null;let o=st(Qs(e),t.name,{fallbackName:hk(r)}),a=XS(e.scene.gameObjects.map(c=>c.id),t.objectId,o);if(!a)return null;let i=Ek(r),s={id:a,guid:he(),name:o,kind:"primitive",...n?{parentId:n}:{},active:!0,primitive:{shape:r},shadow:{cast:"none",receive:"none"},components:[Mt(i)]};return{label:`Create ${o}`,patch:{kind:"game-object.create-primitive",gameObject:s},createdId:a,changedIds:[a]}}function XS(e,t,r){return t===void 0?it(e,r):it([],t)===t&&!e.includes(t)?t:null}function YS(e,t){if(t.ids.some(me))return null;let r=wt(e,t.ids);if(r.size===0||e.scene.gameObjects.some(a=>r.has(a.id)&&At(a)))return null;let n=bk(e,r,t.activeId??null),o=[...r];return{label:`Delete ${o.length} GameObject${o.length===1?"":"s"}`,patch:{kind:"game-object.delete-subtree",targetIds:t.ids},deletedIds:o,fallbackSelectionId:n}}function Pu(e,t,r={}){if(t.placement!=="inside")return{ok:!1,reason:"Only inside reparent is supported."};let n=_(e,t.draggedId),o=_(e,t.targetId);return n?Z(n)?{ok:!1,reason:"Root GameObject cannot be reparented."}:o?G(n)?xt(o)?n.id===o.id?{ok:!1,reason:"GameObject cannot be parented to itself."}:Sk(e,n.id,o.id)?{ok:!1,reason:"GameObject cannot be parented to its descendant."}:t.preserveWorldTransform!==!1&&!Zs(e,n.id,o.id,void 0,{preserveWorldPolicy:r})?{ok:!1,reason:"Cannot preserve world transform under the target parent."}:{ok:!0}:{ok:!1,reason:`${t.targetId} cannot have children.`}:{ok:!1,reason:`${t.draggedId} has no Transform to preserve.`}:{ok:!1,reason:`Parent GameObject not found: ${t.targetId}`}:{ok:!1,reason:`GameObject not found: ${t.draggedId}`}}function ZS(e,t,r={}){if(!Pu(e,t,r).ok)return null;let o=_(e,t.draggedId);if(!o||!G(o))return null;let a=t.targetId,i=t.preserveWorldTransform===!1?qt(o):Zs(e,o.id,a,void 0,{preserveWorldPolicy:r});return!i||o.parentId===a&&cy(qt(o),i)?null:{label:`Reparent ${o.name??o.id}`,patch:{kind:"game-object.reparent",targetId:o.id,parentId:a,transform:i},changedIds:[o.id]}}function Tu(e,t,r={}){let n=fr(e),o=ep(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(me))return{ok:!1,reason:"Root GameObject cannot be moved."};let i=Du(e,t);if(i&&!Mu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1)for(let s of a){let c=_(e,s);if(!c)return{ok:!1,reason:`GameObject not found: ${s}`};if(!G(c))return{ok:!1,reason:`${s} has no Transform to preserve.`};if(!Zs(e,s,i,t,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}return{ok:!0}}function QS(e,t,r={}){if(!Tu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids),i=Du(e,t),s=a.map(l=>{let m=_(e,l);if(!m||!G(m))return null;let f=t.preserveWorldTransform===!1?qt(m):Zs(e,l,i,t,r),S=f?Sn(f):null;return S?i?{targetId:l,parentId:i,transform:S}:{targetId:l,transform:S}:null}).filter(l=>!!l);if(s.length!==a.length)return null;let c=fk(e,a,t),d=e.scene.gameObjects.map(l=>l.id);return!s.some(l=>{let m=_(e,l.targetId);return!m||m.parentId!==l.parentId||!cy(qt(m),l.transform)})&&Ik(d,c)?null:{label:`Move ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.hierarchy-move",moves:s,order:c},changedIds:a}}function xu(e,t,r={}){let n=fr(e),o=tp(n,t);if(!o.ok)return o;let a=St(n,t.ids);if(a.some(me))return{ok:!1,reason:"Root GameObject cannot be grouped."};let i=ny(e,t.parentId??null);if(i&&!Mu(e,i))return{ok:!1,reason:`${i} cannot have children.`};if(t.preserveWorldTransform!==!1){let s=sy(e,a),c=s?{position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}:null;if(!c||!ha(e,i,c,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."};for(let d of a){let u=_(e,d);if(!u)return{ok:!1,reason:`GameObject not found: ${d}`};if(!G(u))return{ok:!1,reason:`${d} has no Transform to preserve.`};let l=ke(e,d);if(!l||!oy(c,l,r))return{ok:!1,reason:"Cannot preserve world transform under the target parent."}}}return{ok:!0}}function ey(e,t,r={}){if(!xu(e,t,r).ok)return null;let o=fr(e),a=St(o,t.ids);if(a.length===0)return null;let i=ny(e,t.parentId??null),s=sy(e,a);if(!s)return null;let c={position:s,rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}},d=ha(e,i,c,r);if(!d)return null;let u=st(Qs(e),t.name,{fallbackName:"Parent"}),l=it(e.scene.gameObjects.map(g=>g.id),u),m={id:l,guid:he(),name:u,kind:"transform",transformType:"plain",...i?{parentId:i}:{},active:!0,components:[Mt(d)]},f={};for(let g of a){let b=_(e,g);if(!b)return null;if(t.preserveWorldTransform===!1){f[g]=qt(b);continue}let y=ke(e,g);if(!y)return null;let E=oy(c,y,r);if(!E)return null;f[g]=E}let S=pk(e,l,a,t.insertBeforeId??null);return{label:`Create Parent for ${a.length} GameObject${a.length===1?"":"s"}`,patch:{kind:"game-object.group-selection",gameObject:m,childIds:a,childTransforms:f,order:S},createdId:l,changedIds:[l,...a]}}function ty(e){let t=e.isProtectedDuplicateSource??sk,r=fr(e.document),n=new Set(St(r,e.targetIds).filter(b=>{let y=_(e.document,b);return!!y&&!Z(y)&&!t(y,e.document)&&!dk(e.document,y.id,t)})),o=Au(e.document).filter(b=>n.has(b));if(o.length===0)return null;let a=wt(e.document,o),i=new Map,s=new Set(e.document.scene.gameObjects.map(b=>b.id)),c=new Map,d=Qs(e.document),u=lk(e.document,o,a,t);for(let b of u){let y=_(e.document,b),E=st(d,y.name,{alwaysAppendSuffix:!0,fallbackName:y.id});d.push(E);let I=it([...s],E);s.add(I),i.set(y.id,I),c.set(y.id,E)}let l=u.map(b=>_(e.document,b)).filter(b=>!!b&&i.has(b.id)).map(b=>{let y=structuredClone(b);return y.id=i.get(b.id),y.guid=he(),y.name=c.get(b.id),y.parentId&&i.has(y.parentId)&&(y.parentId=i.get(y.parentId)),y});if(l.length===0)return null;let m=l.map(b=>b.id),f=o.map(b=>i.get(b)).filter(b=>!!b),S=ck(e.document,o,e.activeId),g=S&&i.has(S)?i.get(S):f[f.length-1]??m[m.length-1]??null;return{label:`Duplicate ${m.length} object${m.length===1?"":"s"}`,patch:{kind:"game-object.duplicate-selection",gameObjects:l,order:uk(e.document,o,i)},createdIds:m,selectedIds:f,activeId:g,changedIds:m}}function sk(e){return Dt(e)}function ck(e,t,r){if(r&&t.includes(r))return r;if(r){for(let n of t)if(wt(e,[n]).has(r))return n}return t[t.length-1]??null}function dk(e,t,r){let n=new Map(e.scene.gameObjects.map(i=>[i.id,i])),o=new Set,a=n.get(t);for(;a?.parentId;){if(o.has(a.parentId))return!0;o.add(a.parentId);let i=n.get(a.parentId);if(!i)return!1;if(r(i,e))return!0;a=i}return!1}function lk(e,t,r,n){let o=Au(e),a=new Map(o.map((l,m)=>[l,m])),i=new Map(e.scene.gameObjects.map(l=>[l.id,l])),s=new Map;for(let l of e.scene.gameObjects){let m=l.parentId&&i.has(l.parentId)?l.parentId:null,f=s.get(m)??[];f.push(l.id),s.set(m,f)}for(let l of s.values())l.sort((m,f)=>(a.get(m)??Number.MAX_SAFE_INTEGER)-(a.get(f)??Number.MAX_SAFE_INTEGER));let c=[],d=new Set,u=l=>{if(d.has(l)||!r.has(l))return;d.add(l);let m=_(e,l);if(!(!m||Z(m)||n(m,e))){c.push(m.id);for(let f of s.get(m.id)??[])u(f)}};for(let l of t)u(l);return c}function uk(e,t,r){let n=Au(e),o=new Map;for(let i of t){let s=wt(e,[i]),c=n.filter(l=>s.has(l)),d=c.map(l=>r.get(l)).filter(l=>!!l),u=c[c.length-1];u&&d.length>0&&o.set(u,d)}let a=[];for(let i of n){a.push(i);let s=o.get(i);s&&a.push(...s)}return a}function Au(e){let t=e.scene.gameObjects,r=new Map(t.map(c=>[c.id,c])),n=new Map;for(let c of t){let d=c.parentId&&r.has(c.parentId)?c.parentId:null,u=n.get(d)??[];u.push(c.id),n.set(d,u)}let o=[],a=new Set,i=c=>{if(!(a.has(c)||!r.has(c))){a.add(c),o.push(c);for(let d of n.get(c)??[])i(d)}},s=ye(e);s&&i(s);for(let c of n.get(null)??[])i(c);for(let c of t)i(c.id);return o}function ry(e,t){if(t.parentId){let n=_(e,t.parentId);return n&&xt(n)?n.id:null}let r=t.activeId?_(e,t.activeId):null;if(r&&xt(r))return r.id;if(r?.parentId){let n=_(e,r.parentId);if(n&&xt(n))return n.id}return ye(e)}function mk(e,t){return t.parentId===null?ye(e):ry(e,t)}function Du(e,t){if(t.placement==="root")return ye(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let r=t.targetId?_(e,t.targetId):null;return t.parentId??r?.parentId??ye(e)}function ny(e,t){return t&&Mu(e,t)?t:ye(e)}function Mu(e,t){let r=_(e,t);return!!r&&xt(r)}function Zs(e,t,r,n,o={}){let a=ke(e,t);if(!a)return null;let i=_(e,t);if(!i)return null;let s=n?o.resolveLocalTransform?.({document:e,intent:n,gameObject:i,parentId:r,worldTransform:a}):null;if(s)return Sn(s);let c=ha(e,r,a,o.preserveWorldPolicy);return c?Sn(c):null}function oy(e,t,r={}){let n=Vi(r),o=to(e,t,{allowMatrixFallback:n.allowMatrixFallback});return o?Sn(o):null}function fk(e,t,r){let n=ay(e,t),o=new Set(n),a=e.scene.gameObjects.map(s=>s.id).filter(s=>!o.has(s)),i=gk(e,a,{placement:r.placement,targetId:r.targetId??null,beforeId:r.beforeId??null,afterId:r.afterId??null,parentId:Du(e,r)});return iy(a,n,i)}function pk(e,t,r,n){let o=ay(e,r),a=new Set(o),i=e.scene.gameObjects.map(l=>l.id),s=i.filter(l=>!a.has(l)),c=Math.min(...r.map(l=>i.indexOf(l)).filter(l=>l>=0)),d=Number.isFinite(c)?s.filter(l=>i.indexOf(l)<c).length:s.length,u=n?Math.max(0,s.indexOf(n)):d;return iy(s,[t,...o],u)}function ay(e,t){let r=wt(e,[...t]);return e.scene.gameObjects.map(n=>n.id).filter(n=>r.has(n))}function gk(e,t,r){return r.beforeId?HS(t.indexOf(r.beforeId),t.length):r.afterId?Ys(e,t,r.afterId):r.placement==="before"&&r.targetId?HS(t.indexOf(r.targetId),t.length):r.placement==="after"&&r.targetId||r.placement==="inside"&&r.targetId?Ys(e,t,r.targetId):r.placement==="root"?t.length:r.parentId?Ys(e,t,r.parentId):t.length}function Ys(e,t,r){let n=wt(e,[r]),o=t.indexOf(r);if(o<0)return t.length;for(let a=o+1;a<t.length&&n.has(t[a]);a+=1)o=a;return o+1}function iy(e,t,r){let n=Math.max(0,Math.min(r,e.length));return[...e.slice(0,n),...t,...e.slice(n)]}function HS(e,t){return e>=0?e:t}function sy(e,t){let r=t.map(o=>ke(e,o)).filter(o=>!!o);if(r.length===0)return null;let n=r.map(Bi);return{x:n.reduce((o,a)=>o+a.x,0)/n.length,y:n.reduce((o,a)=>o+a.y,0)/n.length,z:n.reduce((o,a)=>o+a.z,0)/n.length}}function bk(e,t,r){let n=r?_(e,r):null;if(n?.parentId&&!t.has(n.parentId)&&_(e,n.parentId))return n.parentId;for(let o=e.scene.gameObjects.length-1;o>=0;o-=1){let a=e.scene.gameObjects[o];if(!t.has(a.id))return a.id}return null}function Sk(e,t,r){let n=Ol(e),o=new Set,a=n.get(r);for(;a?.parentId&&!o.has(a.parentId);){if(a.parentId===t)return!0;o.add(a.parentId),a=n.get(a.parentId)}return!1}function yk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function hk(e){return e[0].toUpperCase()+e.slice(1)}function Ek(e){return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function Qs(e){return e.scene.gameObjects.map(t=>t.name??t.id)}function cy(e,t){return!It(e)||!It(t)?na(Fe(e),Fe(t)):Iu(e.position,t.position)&&Iu(e.rotation,t.rotation)&&Iu(e.scale,t.scale)}function Iu(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function Ik(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function ku(e){return{getHierarchyItems(t){return wu(t,e)},normalizeHierarchyDocument(t){return vl(t)},createRenamePatch(t,r){return br(WS(t,r))},createCreateGroupPatch(t,r){return br(qS(t,r))},createCreatePrimitivePatch(t,r){return br(JS(t,r))},createDeleteSubtreePatch(t,r){let n=YS(t,r);if(!n)return null;let o=new Set(n.deletedIds);return t.scene.gameObjects.some(a=>o.has(a.id)&&e.isProtectedSystemGameObject(a))?null:br(n)},collectSubtreeIdList(t,r){return pr(t,r)},validateReparent(t,r){let n=e.findGameObject(t,r.draggedId),o=e.findGameObject(t,r.targetId);return n&&e.isProtectedSystemGameObject(n)?{ok:!1,reason:"Protected system GameObject cannot be reparented."}:o&&e.isProtectedSystemGameObject(o)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Pu(t,r)},createReparentPatch(t,r){return br(ZS(t,r))},validateHierarchyMove(t,r){let n=wu(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be moved."};let a=Pk(t,r,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:Tu(t,r)},createHierarchyMovePatch(t,r){return br(QS(t,r))},validateGroupSelection(t,r){let n=wu(t,e);if(St(n,r.ids).some(i=>e.isProtectedSystemGameObjectId(t,i)))return{ok:!1,reason:"Protected system GameObject cannot be grouped."};let a=Tk(t,r.parentId??null,e);return e.isProtectedSystemGameObjectId(t,a)?{ok:!1,reason:"Protected system GameObject cannot have children."}:xu(t,r)},createGroupSelectionPatch(t,r){return br(ey(t,r))},createDuplicateSelectionPatch(t){let r=t.targetIds.filter(n=>{let o=e.findGameObject(t.document,n);return!!o&&!e.isProtectedSystemGameObject(o)});return br(ty({...t,targetIds:r,isProtectedDuplicateSource:n=>e.isProtectedSystemGameObject(n)}))},createPlacedAssetPatch(t){return br(Hl(t))}}}function wu(e,t){let r=fr(e),n=new Map(e.scene.gameObjects.map(a=>[a.id,a])),o=[];for(let a of r){let i=n.get(a.id)??null;o.push(t.decorateHierarchyItem?.({item:a,gameObject:i,document:e})??a),i&&o.push(...t.collectHierarchyItemChildren?.({item:a,gameObject:i,document:e})??[])}return o}function Pk(e,t,r){if(t.placement==="root")return r.resolveRootContainerId(e);if(t.placement==="inside"&&t.targetId)return t.targetId;let n=t.targetId?r.findGameObject(e,t.targetId):null;return t.parentId??n?.parentId??r.resolveRootContainerId(e)}function Tk(e,t,r){let n=t?r.findGameObject(e,t):null;return n&&xt(n)?n.id:r.resolveRootContainerId(e)}function br(e){return e?{...e,patch:e.patch}:null}function Ou(e,t){let r=t.ensureGameObjectGuids(e),n=t.resolveRootContainerId(r),o=!1,a=!1,i=!1,s=r!==e,c=t.ensureDefaultMaterialAssets(r.scene.materialAssets??[]);s=s||c!==r.scene.materialAssets;let d=r.scene.gameObjects.map(S=>{if(S.id===t.systemDefaults.environmentLightId){a=!0;let g=t.systemDefaults.normalizeEnvironmentLightGameObject(S);return s=s||g!==S,g}if(S.id===t.systemDefaults.sunLightId){i=!0;let g=t.systemDefaults.normalizeSunLightGameObject(S);return s=s||g!==S,g}if(t.isCameraGameObject(S)){if(!o){o=!0;let g=t.systemDefaults.normalizeCameraGameObject(S);return s=s||g!==S,g}return s=!0,t.systemDefaults.normalizePlainTransformGameObject(S)}if(t.isLightGameObject(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=!0,g}if(!t.isCustomTransformType?.(S.transformType)&&xk(S)){let g=t.systemDefaults.normalizePlainTransformGameObject(S);return s=s||g!==S,g}return S}),u={createGameObjectGuid:t.createGameObjectGuid,createUniqueId:t.createUniqueId},l=new Set(d.map(S=>S.id));o||(s=!0,d.push(t.systemDefaults.createDefaultCameraGameObject(n,l,u))),a||(s=!0,d.push(t.systemDefaults.createDefaultEnvironmentLightGameObject(n,l,u))),i||(s=!0,d.push(t.systemDefaults.createDefaultSunLightGameObject(n,l,u)));let m=t.normalizeMaterialBindings({...r,scene:{...r.scene,gameObjects:d,materialAssets:c}},c,d);c=m.materialAssets,d=m.gameObjects,s=s||m.changed;let f=s?{...r,scene:{...r.scene,gameObjects:d,materialAssets:c}}:r;return t.syncMarkerGraphDocument(f)}function xk(e){return(e.kind==="transform"||e.transformType==="plain")&&!e.camera&&!e.light&&!e.primitive&&!e.prefab&&!e.marker&&!e.components.some(t=>t.type==="ModelRenderer"||t.type==="ImageRenderer")}function Ru(e,t,r){let n=r.normalizeRootTransformDocument(Ak(e,t,r));return r.syncMarkerGraphDocument(r.ensureGameObjectGuids(r.normalizeDocumentAfterCommand(n,t)))}function ec(e){return{normalizeFieldValue:e.normalizeFieldValue,validateField:({document:t,gameObject:r,path:n,value:o})=>e.validateField(t,r,n,o),blockFieldPatch:({document:t,targetId:r,path:n,value:o})=>tc(t,r,n,o,e),normalizePrimitiveShape:e.normalizePrimitiveShape,mergeCameraDefaults:e.systemDefaults.mergeCameraDefaults,normalizeCameraAfterFieldPatch:(t,r)=>t&&e.systemDefaults.normalizeCameraAfterFieldPatch(t,r),mergeLightDefaults:e.systemDefaults.mergeLightDefaults,isCustomTransformType:e.isCustomTransformType,applyCustomTransformType:e.applyCustomTransformType,clearCustomTransformState:e.clearCustomTransformState,patchCustomTransformField:e.patchCustomTransformField}}function Cu(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return e;let i=Eg(a,{...r===o.systemDefaults.horizontalLightAnglePath?{horizontalAngleDeg:n}:{},...r===o.systemDefaults.elevationLightAnglePath?{elevationAngleDeg:n}:{}});return i===a?e:{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(s=>s.id===t?i:s)}}}function tc(e,t,r,n,o){let a=o.findGameObject(e,t);if(!a)return!1;let i=o.isCameraGameObject(a),s=o.isLightGameObject(a),c=o.isProtectedSystemGameObject(a),d=a.id===o.systemDefaults.sunLightId&&a.light?.type==="directional"&&(r==="transform.rotation"||r.startsWith("transform.rotation."));if(r.startsWith("transform.")&&c&&!d||r.startsWith("camera.")&&!i)return!0;if(r.startsWith("camera.")&&i){let u={camera:o.systemDefaults.mergeCameraDefaults(a.camera)};if(Oe(u,r,n),u.camera&&(u.camera=o.systemDefaults.normalizeCameraAfterFieldPatch(u.camera,r),o.systemDefaults.hasInvalidCameraRelationships(u.camera)))return!0}return!!(r.startsWith("light.")&&!s||r==="light.type"&&(a.id===o.systemDefaults.environmentLightId&&n!=="hemispheric"||a.id===o.systemDefaults.sunLightId&&n!=="directional")||r==="transformType"&&(i&&n!=="camera"||s&&n!=="light"||!s&&n==="light"||n==="camera"&&!i&&o.hasCamera(e,t)))}function Ak(e,t,r){let n=t.type==="document.replace"?null:t.patch;if(n){if(n.kind==="scene.material-asset.field")return r.patchMaterialAssetField(e,n.materialAssetId,n.path,n.value);if(n.kind==="scene.material-asset.replace")return r.replaceMaterialAsset(e,n.materialAssetId,n.materialAsset);if(n.kind==="scene.material-asset.create")return r.addMaterialAsset(e,n.materialAsset);if(n.kind==="scene.material-asset.delete")return r.deleteMaterialAsset(e,n.materialAssetId);if(n.kind==="scene.material-asset.create-and-bind")return r.addMaterialAssetAndBind(e,n.targetId,n.bindingPath,n.materialAsset);if(n.kind==="scene.prefab-asset.create")return r.addPrefabAsset(e,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-asset.create-from-game-object"||n.kind==="scene.prefab-asset.duplicate")return r.addPrefabAsset(e,n.prefabAsset);if(n.kind==="scene.prefab-asset.field")return r.patchPrefabAssetField(e,n.assetId,n.path,n.value);if(n.kind==="scene.prefab-asset.replace")return r.replacePrefabAsset(e,n.assetId,n.prefabAsset,n.sourceAsset);if(n.kind==="scene.prefab-material-asset.duplicate-and-bind")return r.addMaterialAssetAndBindPrefabOverride(e,n.assetId,n.bindingPath,n.materialAsset);let o=r.reduceExtensionPatch?.({document:e,patch:n,command:t});if(o)return o;if(n.kind==="game-object.field"&&r.isDirectionalLightAnglePath(n.path)||n.kind==="game-object.field"&&r.isCustomFieldPatchPath?.(n.path))return r.patchGameObjectField(e,n.targetId,n.path,n.value);if(n.kind==="game-object.rendering-alpha-index-migration")return Mk(e,n);if(n.kind==="scene.marker-graph")return r.reduceMarkerGraphPatch(e,n.command)}return pu(e,t,Dk(r))}function Dk(e){return{field:ec(e),serializedProperty:{validateField:e.validateSerializedPropertyField},assetPlacement:{createGameObjectGuid:e.createGameObjectGuid,resolveLocalTransform:({document:t,parentId:r,worldTransform:n})=>e.resolveLocalTransform({document:t,parentId:r,worldTransform:n})},isProtectedDuplicateSource:t=>e.isProtectedSystemGameObject(t),isProtectedDeleteTarget:t=>e.isProtectedSystemGameObject(t)}}function Mk(e,t){return Kl({document:e,targetIds:t.targetIds,renderingGroupId:t.renderingGroupId,fromAlphaIndex:t.fromAlphaIndex,toAlphaIndex:t.toAlphaIndex})}function Io(e,t){let r=e.path,n=t.normalizeValue(r,e.value),o=t.parseMaterialAssetFieldPath(r);if(o){let l=t.normalizeMaterialAssetValue(o.fieldPath,n);if(!t.hasMaterialAsset(e.document,o.materialAssetId)||!t.validateMaterialAssetFieldValue(e.document,o.materialAssetId,o.fieldPath,l))return null;let m=t.collectMaterialAssetBindingIds(e.document,o.materialAssetId);return{label:`Patch material asset ${o.materialAssetId} ${o.fieldPath}`,patch:t.createMaterialAssetFieldPatch(o.materialAssetId,o.fieldPath,l),changedId:m[0]??e.targetId,changedIds:m,...o.fieldPath.startsWith("properties.")?{reprojectIds:m}:{}}}let a=t.findGameObject(e.document,e.targetId);if(!a)return null;let i=a.id,s=t.parseDuplicateMaterialAssetValue(n);if(s&&t.isMaterialBindingPath(r))return wk(e.document,a,r,s,t);if(t.isRootTransformPath(i,r))return null;if(r==="marker.target.objectId"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTargetUpdateCommand(e.document,i,n);return l?dy(i,"marker.target",l,t):null}if(!t.validateValue(e.document,a,r,n).ok||t.blockFieldPatch(e.document,i,r,n))return null;if(r==="marker.type"&&t.isMarkerGameObject(a)&&typeof n=="string"){let l=t.createMarkerTypeUpdateCommand(e.document,i,n);return l?dy(i,"marker.type",l,t):null}if(t.isDirectionalLightAnglePath(r)&&typeof n=="number"&&Number.isFinite(n))return{label:`Patch ${i} ${r}`,patch:t.createDirectionalLightPatch(i,r,n),changedId:i,changedIds:[i],reprojectIds:[i]};let c=t.createCustomInspectorPropertyPatch?.({...e,gameObject:a,path:r,value:n});if(c)return c;let d=t.collectChangedIdsForFieldPath(e.document,i,r),u=t.isProjectionShapePath(r)||t.isArtistMaterialPatchPath(r)||t.isCustomProjectionPath?.(r)?[i]:void 0;return{label:`Patch ${i} ${r}`,patch:t.createGameObjectFieldPatch(i,r,n),changedId:i,changedIds:d,...u?{reprojectIds:u}:{}}}function rc(e,t,r,n,o){let a=o.patchCustomGameObjectField?.({document:e,targetId:t,path:r,value:n});if(a)return a;if(r.startsWith("metadata.")||o.isDirectionalLightAnglePath(r)){let s=o.findGameObject(e,t);if(!s)return e;let c=o.normalizeValue(r,n);return!o.validateValue(e,s,r,c).ok||o.blockFieldPatch(e,t,r,c)?e:o.isDirectionalLightAnglePath(r)&&typeof c=="number"&&Number.isFinite(c)?o.patchDirectionalLightAngleField(e,t,r,c):kk(e,t,r,c,o)}let i=Mn(e,t,r,n,o.fieldMutationOptions);return o.normalizeAfterFieldPatch(i,t,r,n)}function ly(e,t,r,n,o){let a=Array.from(new Set(t.filter(Boolean)));if(a.length===0)return e;let i=o.patchCustomGameObjectsField?.({document:e,targetIds:a,path:r,value:n,patchSingle:(c,d,u,l)=>rc(c,d,u,l,o)});if(i)return i;if(r.startsWith("metadata."))return Ok(e,a,r,n,o);if(o.isDirectionalLightAnglePath(r))return a.reduce((c,d)=>rc(c,d,r,n,o),e);let s=Ca(e,a,r,n,o.fieldMutationOptions);return a.reduce((c,d)=>o.normalizeAfterFieldPatch(c,d,r,n),s)}function dy(e,t,r,n){return{label:`Patch ${e} ${t}`,patch:n.createMarkerGraphPatch(r),changedId:e,changedIds:[e],reprojectIds:[e]}}function wk(e,t,r,n,o){let a=qb({document:e,gameObject:t,bindingPath:r,sourceMaterialAssetId:n,isBindingPathAllowed:s=>o.isMaterialBindingPathAllowed(t,s)});return a?{label:`Duplicate material ${o.findMaterialAssetName(e,n)??n} for ${t.name??t.id}`,patch:a.patch,changedId:a.changedId,changedIds:a.changedIds,createdId:a.createdId,reprojectIds:a.reprojectIds}:null}function kk(e,t,r,n,o){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(a=>{if(a.id!==t)return a;let i=structuredClone(a);return Oe(i,r,n),i.metadata&&Object.keys(i.metadata).length===0&&delete i.metadata,i})}}}function Ok(e,t,r,n,o){let a=new Set(t),i=o.normalizeValue(r,n),s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id))return d;let u=d;if(!o.validateValue(e,u,r,i).ok||o.blockFieldPatch(e,d.id,r,i))return d;let l=structuredClone(d);return Oe(l,r,i),l.metadata&&Object.keys(l.metadata).length===0&&delete l.metadata,s=!0,l});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function my(e){return{applySerializedPropertyPatch(t,r){if(e.isRootTransformPath(r.targetId,r.path))return t;let n={...r,value:bn(r.path,r.value)};return va({document:t,patch:n,validateField:e.validateSerializedPropertyField})},canCreateSerializedMultiPropertyPatch(t){return uy({document:t.document,targetIds:t.targetIds,activeId:t.activeId,path:t.path,value:e.getSerializedMultiPropertyProbeValue(t.path),services:e}).length>0},createSerializedMultiPropertyPatch(t){if(!e.isSerializedMultiFieldPath(t.path))return null;let r=bn(t.path,t.value),n=uy({...t,value:r,services:e});return n.length===0?null:{label:`Patch ${n.length} GameObjects ${t.path}`,patch:e.createFieldBatchPatch(n.map(o=>({targetId:o,path:t.path,value:r}))),changedIds:n,...e.isSerializedMultiProjectionPath(t.path)?{reprojectIds:n}:{}}}}}function uy(e){return e.services.isSerializedMultiFieldPath(e.path)?e.targetIds.filter(t=>{let r=e.services.findGameObject(e.document,t);return e.services.canPatchCustomSerializedMultiField?.({document:e.document,targetId:t,path:e.path,value:e.value})===!1||e.services.isSerializedMultiProjectionPath(e.path)&&(!r||e.services.isCameraGameObject(r)||e.services.isLightGameObject(r))?!1:!!e.services.createInspectorPropertyPatch({document:e.document,targetId:t,path:e.path,value:e.value})}):[]}var Rk=/^transform(?:\.(position|rotation|scale)(?:\.(x|y|z))?)?$/,Ck=/^transform\.(position|rotation|scale)$/,vk=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function Mn(e,t,r,n,o={}){return Gk({document:e,targetId:t,path:r,value:n,options:o})}function Ca(e,t,r,n,o={}){let a=new Set(t.filter(Boolean));if(a.size===0)return e;let i=o.normalizeFieldValue?.(r,n)??n,s=!1,c=e.scene.gameObjects.map(d=>{if(!a.has(d.id)||vu(d.id,r))return d;let u=d;if(o.validateField?.({document:e,gameObject:u,path:r,value:i})?.ok===!1||o.blockFieldPatch?.({document:e,gameObject:u,targetId:d.id,path:r,value:i}))return d;let l=bu(u,r,i,o);return l===d?d:(s=!0,l)});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function gu(e,t,r={}){let n=new Map;for(let i of t){if(!i.objectId||i.changes.length===0)continue;let s=n.get(i.objectId)??[];s.push(...i.changes),n.set(i.objectId,s)}if(n.size===0)return e;let o=!1,a=e.scene.gameObjects.map(i=>{let s=n.get(i.id);if(!s?.length)return i;let c;for(let d of s){if(vu(i.id,d.path))continue;let u=r.normalizeFieldValue?.(d.path,d.value)??d.value;r.validateField?.({document:e,gameObject:c??i,path:d.path,value:u})?.ok!==!1&&(r.blockFieldPatch?.({document:e,gameObject:c??i,targetId:i.id,path:d.path,value:u})||(c??=structuredClone(i),c=by(c,d.path,u,r,!0)))}return!c||JSON.stringify(c)===JSON.stringify(i)?i:(o=!0,c)});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function Gk(e){if(vu(e.targetId,e.path))return e.document;let t=_(e.document,e.targetId);if(!t)return e.document;let r=e.options?.normalizeFieldValue?.(e.path,e.value)??e.value;if(e.options?.validateField?.({document:e.document,gameObject:t,path:e.path,value:r})?.ok===!1||e.options?.blockFieldPatch?.({document:e.document,gameObject:t,targetId:e.targetId,path:e.path,value:r}))return e.document;let n=bu(t,e.path,r,e.options);return n===t?e.document:{...e.document,scene:{...e.document.scene,gameObjects:e.document.scene.gameObjects.map(o=>o.id===e.targetId?n:o)}}}function bu(e,t,r,n={}){let o=by(e,t,r,n);return JSON.stringify(o)===JSON.stringify(e)?e:o}function by(e,t,r,n,o=!1){let a=o?e:structuredClone(e),i=t.startsWith("transform.rotation")?fy(a):null,s=t==="light.direction"||t.startsWith("light.direction.")?py(a):null;if(t==="name")return typeof r=="string"&&r.trim()?a.name=r.trim():delete a.name,a;if(t==="enabled")return a.active=r!==!1,a;if(t.startsWith("shadow."))return dn(a)&&jk(a,t,r),a;if(t.startsWith("rendering.")){Y(a)==="group"&&(a.kind="instance");let c=Fk(t,r);return Oe(a,t,c),_k(a),a}if(t.startsWith("metadata."))return Oe(a,t,r),a.metadata&&Object.keys(a.metadata).length===0&&delete a.metadata,a;if(t==="instance.assetId"){let c=ue(a);return c&&typeof r=="string"&&(c.assetId=r),a.kind="instance",delete a.primitive,a}if(t==="primitive.shape"){let c=(n.normalizePrimitiveShape??Bk)(r);return c&&(a.kind="primitive",a.primitive={shape:c}),a}if(t==="transformType")return $k(a,r,n),a;if(Lk(a,t,r)){let c=i?fy(a):null;return i&&c&&!gy(i,c)?lo(a):a}if(n.patchCustomTransformField?.(a,t,r))return a;if(t.startsWith("marker."))return!a.marker||typeof a.marker!="object"||(a.kind="transform",delete a.primitive,Oe(a,t,r)),a;if(t.startsWith("camera."))return a.kind="transform",a.transformType="camera",a.camera=Sy(a.camera,n),delete a.light,n.clearCustomTransformState?.(a,"camera"),delete a.primitive,Oe(a,t,r),a.camera=zk(a.camera,t,n),a;if(t.startsWith("light.")){a.kind="transform",a.transformType="light",a.light=yy(a.light,n),delete a.camera,n.clearCustomTransformState?.(a,"light"),delete a.primitive,Oe(a,t,r),(t==="light.direction"||t.startsWith("light.direction."))&&a.light?.type==="directional"&&(a.light.direction=Sa(a.light.direction,s??void 0));let c=s?py(a):null;return s&&c&&!gy(s,c)?gs(a):a}return t.startsWith("overrides.")&&(Y(a)==="group"&&(a.kind="instance"),Oe(a,t,r),Vl(a)),a}function fy(e){let t=G(e);return t&&!Ee(t)?{...t.rotation}:null}function py(e){return e.light?.type==="directional"?{...e.light.direction}:null}function gy(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function jk(e,t,r){if(!Nk(t,r))return;let n=e.shadow;e.shadow={cast:t==="shadow.cast"?r===!0?"enabled":"none":n?.cast==="enabled"?"enabled":"none",receive:t==="shadow.receive"?r===!0?"enabled":"none":n?.receive==="enabled"?"enabled":"none"}}function Nk(e,t){return e==="shadow.cast"||e==="shadow.receive"?typeof t=="boolean":!1}function Fk(e,t){return e==="rendering.renderingGroupId"?t===1||t===2||t===3?t:0:e==="rendering.alphaIndex"?w(t)?t:null:t}function _k(e){let t=e.rendering;if(!t||typeof t!="object"||Array.isArray(t)){delete e.rendering;return}Object.keys(t).length===0&&delete e.rendering}function vu(e,t){return me(e)&&Rk.test(t)}function $k(e,t,r){let n=t==="plain"||t==="light"||t==="camera",o=!n&&r.isCustomTransformType?.(t)===!0;if(!n&&!o)return;let a=t;e.kind="transform",e.transformType=a,delete e.primitive,a==="camera"?e.camera=Sy(e.camera,r):delete e.camera,a==="light"?e.light=yy(e.light,r):delete e.light,o?r.applyCustomTransformType?.(e,a):r.clearCustomTransformState?.(e,a)}function Lk(e,t,r){let n=t.match(Ck);if(n){let a=G(e);if(!a||Ee(a))return!0;let i=n[1];return i==="scale"?(w(r)?a.scale={x:r,y:r,z:r}:qe(r)&&(a.scale={...r}),!0):(qe(r)&&(a[i]=i==="rotation"?{x:Ht(r.x),y:Ht(r.y),z:Ht(r.z)}:{...r}),!0)}let o=t.match(vk);if(o&&w(r)){let a=G(e);if(!a||Ee(a))return!0;let i=o[1],s=o[2],c=i==="rotation"?Ht(r):r;return i==="scale"?a.scale={...ot(a,"scale"),[s]:c}:a[i]={...a[i],[s]:c},!0}return!1}function Sy(e,t){return t.mergeCameraDefaults?t.mergeCameraDefaults(e):hy(e)}function zk(e,t,r){return r.normalizeCameraAfterFieldPatch?r.normalizeCameraAfterFieldPatch(e,t):e}function yy(e,t){return t.mergeLightDefaults?t.mergeLightDefaults(e):hy(e)}function Bk(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function hy(e){return Vk(e)??{}}function Vk(e){return e&&typeof e=="object"&&!Array.isArray(e)?structuredClone(e):null}var Ty=["position","rotation","scale"],xy=["x","y","z"],Uk=1e-6;function Gu(e){let t=[{path:"gameObject.id",label:"ID",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.id},{path:"gameObject.name",label:"Name",valueType:"string",readOnly:!0,getValue:()=>e.gameObject.name??e.gameObject.id}],r=G(e.gameObject);if(r){let o=Z(e.gameObject),a=o?Et():Ds(r)?r:null;if(!a)return t;for(let i of Ty)for(let s of xy)t.push(Wk({gameObject:e.gameObject,vectorName:i,axis:s,rootTransform:o,displayTransform:a,validateField:e.validateField}))}let n=ue(e.gameObject);return n&&t.push({path:"modelRenderer.assetId",label:"Asset ID",valueType:"asset",readOnly:!0,getValue:()=>n.assetId}),wy(e.gameObject)&&t.push(...Kk({gameObject:e.gameObject,validateField:e.validateField})),t}function Ay(e){let t=[];for(let r of Ty)for(let n of xy){let o=e.map(d=>{let u=G(d);return u&&!Ee(u)?ot(u,r)[n]:null}).filter(d=>typeof d=="number");if(o.length!==e.length)continue;let a=r==="rotation"?o.map(Tt):o,i=a[0]??0,s=a.some(d=>Math.abs(d-i)>Uk),c=`transform.${r}.${n}`;t.push({path:c,label:`${r}.${n}`,valueType:"number",value:at(i),mixed:s,readOnly:!1,descriptor:{path:c,valueType:"number",getValue:()=>i}})}return t}function nc(e){if(e.length===0)return[];let t=e.map(n=>n.active!==!1),r=t[0]??!0;return[{path:"enabled",label:"Enabled",valueType:"boolean",value:r,mixed:t.some(n=>n!==r),readOnly:!1,descriptor:{path:"enabled",label:"Enabled",valueType:"boolean",getValue:()=>r}}]}function _a(e){return e.length===0||e.some(r=>!wy(r))?[]:[Iy(e,{path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Iy(e,{path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Kk(e){return[Ey({...e,path:"shadow.cast",label:"Caster",valueType:"boolean",defaultValue:!1}),Ey({...e,path:"shadow.receive",label:"Receiver",valueType:"boolean",defaultValue:!1})]}function Ey(e){return{path:e.path,label:e.label,valueType:e.valueType,...e.options?{options:e.options}:{},getValue:()=>Dy(e.gameObject,e.path,e.defaultValue),setValue:(t,r,n)=>{if(!n.targetId)return t;let o=bn(e.path,r),a=e.validateField?.({document:t,gameObject:e.gameObject,nodeKind:Y(e.gameObject),path:e.path,value:o});return a&&!a.ok?t:Mn(t,n.targetId,e.path,o)}}}function Iy(e,t){let n=e.map(a=>Dy(a,t.path,t.defaultValue))[0]??t.defaultValue,o=Hk(e,t.path);return{path:t.path,label:t.label,valueType:t.valueType,value:n,mixed:o,readOnly:!1,...t.options?{options:t.options}:{},descriptor:{path:t.path,label:t.label,valueType:t.valueType,...t.options?{options:t.options}:{},getValue:()=>n}}}function Hk(e,t){let r=e.map(n=>My(n)[t.slice(7)]);return r.some(n=>n!==r[0])}function Dy(e,t,r){let n=My(e);return t==="shadow.cast"?Py(n.cast):t==="shadow.receive"?Py(n.receive):r}function Py(e){return e==="enabled"}function My(e){return He(e.shadow).shadow??{}}function wy(e){if(Z(e)||e.transformType==="camera"||e.transformType==="light"||e.camera||e.light)return!1;let t=Y(e);return t==="instance"||t==="primitive"||t==="transform"}function Wk(e){return{path:`transform.${e.vectorName}.${e.axis}`,label:`${e.vectorName}.${e.axis}`,valueType:"number",readOnly:e.rootTransform,getValue:()=>{let r=ot(e.displayTransform,e.vectorName)[e.axis];return e.vectorName==="rotation"?at(Tt(r)):r},...e.rootTransform?{}:{setValue:(r,n,o)=>qk({document:r,targetId:o.targetId,vectorName:e.vectorName,axis:e.axis,value:n,validateField:e.validateField})}}}function qk(e){let t=Number(e.value);if(!e.targetId||!Number.isFinite(t))return e.document;let r=_(e.document,e.targetId),n=r?G(r):null;if(!r||!n||Ee(n))return e.document;let o=`transform.${e.vectorName}.${e.axis}`,a=e.validateField?.({document:e.document,gameObject:r,nodeKind:Y(r),path:o,value:t});if(a&&!a.ok)return e.document;let i=e.vectorName==="rotation"?Ht(t):t,s=e.vectorName==="position"?{...n.position,[e.axis]:i}:n.position,c=e.vectorName==="rotation"?{...n.rotation,[e.axis]:i}:n.rotation,d=e.vectorName==="scale"?{...ot(n,"scale"),[e.axis]:i}:ot(n,"scale");return Jk(e.document,e.targetId,{position:s,rotation:c,scale:d})}function Jk(e,t,r){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(n=>n.id===t?Rl(n,r):n)}}}function ky(e){let t=new Map(e.document.scene.gameObjects.map(o=>[o.id,o])),r=e.targetIds.map(o=>t.get(o)??null).filter(o=>!!o&&!Z(o));if(r.length===0)return null;let n=r.map(o=>o.id);return{targetIds:n,activeId:e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null,label:e.label??`${r.length} GameObjects`,properties:[...nc(r),...Ay(r),..._a(r)]}}var Nu="enabled",Oy="shadow.",Ry=200;function _u(e){let t=Xk(e.document,e.selectedIds);if(t.length===0)return null;let r=t.map(l=>l.id),n=e.activeId&&r.includes(e.activeId)?e.activeId:r[0]??null,o=e.largeSelectionThreshold??Ry,a=Yk(t),i=_a(a),s=t.length>o,c=s?Zk({document:e.document,gameObjects:t,shadowGameObjects:a,activeId:n,label:e.label}):ky({document:e.document,targetIds:r,activeId:n,label:e.label});if(!c)return null;let d=c.properties.some(l=>vy(l.path))||i.length===0?c:{...c,properties:[...c.properties,...i]},u=Cy({document:e.document,serialized:d,shadowOnly:s,renderingProfile:e.renderingProfile});return u.length===0?null:{targetIds:d.targetIds,activeId:d.activeId,label:d.label,document:e.document,selection:{targetIds:d.targetIds,activeId:d.activeId,document:e.document},sections:u}}function Cy(e){let t=Qk(e.document,e.serialized,e.serialized.properties.filter(n=>vy(n.path)),e.renderingProfile),r=ju("common","Common",10,e.serialized.properties.filter(n=>n.path===Nu),e.document);return e.shadowOnly?[r,t].filter(n=>!!n):[r,ju("transform","Transform",20,e.serialized.properties.filter(n=>n.path.startsWith("transform.")),e.document),t,ju("properties","Properties",90,e.serialized.properties.filter(n=>!n.path.startsWith("transform.")&&n.path!==Nu&&!n.path.startsWith(Oy)),e.document)].filter(n=>!!n)}function Xk(e,t){let r=new Map(e.scene.gameObjects.map(a=>[a.id,a])),n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.get(a);i&&(Z(i)||o.push(i))}return o}function Yk(e){return e.filter(t=>bo({gameObject:t,nodeKind:Y(t)}))}function Zk(e){if(e.gameObjects.length===0)return null;let t=e.shadowGameObjects.length===0?[]:_a(e.shadowGameObjects);return{targetIds:e.gameObjects.map(r=>r.id),activeId:e.activeId,label:e.label??`${e.gameObjects.length} GameObjects`,properties:[...nc(e.gameObjects),...t]}}function Qk(e,t,r,n){if(r.length===0)return null;let o=new Map(e.scene.gameObjects.map(b=>[b.id,b])),a=t.targetIds.map(b=>o.get(b)).filter(b=>!!b).filter(b=>bo({gameObject:b,nodeKind:Y(b)})),i=o.get(t.activeId??"")??a[0]??null,s=i&&bo({gameObject:i,nodeKind:Y(i)})?i:a[0]??null;if(!s)return null;let c=Y(s),d=r.find(b=>b.path==="shadow.cast"),u=r.find(b=>b.path==="shadow.receive");if(!d||!u)return null;let l=Fu(d,0),m=Fu(u,1),f=gn({path:d.path,nodeKind:c,document:e}),S=gn({path:u.path,nodeKind:c,document:e}),g=n!==void 0&&Is(ks(n))==="none";return{id:"shadow",title:"\u9634\u5F71",order:25,placement:"body",...g?{summary:"\u9879\u76EE\u9634\u5F71\u540E\u7AEF\u5F53\u524D\u5DF2\u5173\u95ED\uFF1B\u53C2\u4E0E\u8D44\u683C\u4ECD\u4F1A\u4FDD\u5B58\u3002"}:{},persistence:"document",collapsedByDefault:!1,properties:[{...l,label:"\u6295\u5C04\u9634\u5F71",control:"boolean",value:l.value===!0,mixed:l.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u6295\u5C04\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6240\u9009\u7269\u4F53\u4E0D\u8FDB\u5165\u9634\u5F71\u6295\u5C04\u5019\u9009\u96C6\u3002",validate:f},{...m,label:"\u63A5\u6536\u9634\u5F71",control:"boolean",value:m.value===!0,mixed:m.mixed===!0,options:void 0,tooltip:"\u5F00\u542F\u540E\u6240\u9009\u7269\u4F53\u63A5\u6536\u9634\u5F71\uFF1B\u5173\u95ED\u540E\u6750\u8D28\u4E0D\u91C7\u6837\u9634\u5F71\u7ED3\u679C\u3002",validate:S},...g?[Fl()]:[]]}}function vy(e){return e.startsWith(Oy)}function ju(e,t,r,n,o){return n.length===0?null:{id:e,title:t,order:r,placement:"body",persistence:"document",properties:n.map((a,i)=>{let s=Fu(a,i),c=eO(o,a.path);return{...s,step:a.valueType==="number"?a.path.startsWith("transform.rotation.")?1:.1:s.step,validate:c?gn({path:a.path,nodeKind:c,document:o}):s.validate}})}}function Fu(e,t){let r=e.readOnly===!0;return{path:e.path,label:e.label,valueType:e.valueType,control:r?"readonly":tO(e.valueType),value:e.value,options:e.options,mixed:e.mixed,readOnly:r,persistence:r?"readonly":"document",commitMode:rO(e.valueType),order:t,source:e}}function eO(e,t){if(t.startsWith("transform."))return"transform";if(t===Nu){let r=e.scene.gameObjects.find(n=>!Z(n));return r?Y(r):null}return null}function tO(e){return e==="string"||e==="number"||e==="boolean"||e==="enum"||e==="asset"||e==="object"?e:"readonly"}function rO(e){return e==="number"?"live":e==="boolean"||e==="enum"||e==="asset"?"immediate":"blur"}var nO=/^transform\.(position|rotation|scale)\.(x|y|z)$/;function va(e){if(me(e.patch.targetId)&&nO.test(e.patch.path))return e.document;let t=_(e.document,e.patch.targetId);if(!t)return e.document;let r=e.patch.path.startsWith("transform.rotation")?Gy(t):null,n=e.patch.path.startsWith("light.direction")?jy(t):null,o=Dp(e.document,Gu({gameObject:t,validateField:e.validateField}),e.patch);if(!e.patch.path.startsWith("transform.rotation")&&!e.patch.path.startsWith("light.direction"))return o;let a=_(o,e.patch.targetId);if(!a)return o;let i=r?Gy(a):null,s=n?jy(a):null,c=r&&i&&!Ny(r,i),d=n&&s&&!Ny(n,s);return!c&&!d?o:{...o,scene:{...o.scene,gameObjects:o.scene.gameObjects.map(u=>{if(u.id!==e.patch.targetId)return u;let l=c?lo(u):u;return d?gs(l):l})}}}function Gy(e){let t=G(e);return t&&"rotation"in t?t.rotation:null}function jy(e){return e.light?.type==="directional"?e.light.direction:null}function Ny(e,t,r=1e-6){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r&&Math.abs(e.z-t.z)<=r}function Lu(e){let t=e.findGameObject(e.document,e.targetId);if(!t)return null;let r=e.isMarkerGameObject(t);return{targetIds:[t.id],activeId:t.id,label:t.name??t.id,document:e.document,selection:{targetIds:[t.id],activeId:t.id,scopeType:"scene",targetKind:r?"marker":e.readNodeKind(t),...r?{capabilities:["markerGraph"]}:{},document:e.document},sections:e.createInspectorSections(e.document,t,e.context)}}function zu(e){let t=_u({document:e.document,selectedIds:e.selectedIds,activeId:e.activeId,renderingProfile:e.renderingProfile}),r=t?{...t,selection:{...t.selection,scopeType:"scene"}}:null;if(!e.extraSection)return r;if(!r){let n=e.resolveFallbackTargetIds(),o=e.activeId&&n.includes(e.activeId)?e.activeId:n[0]??null;return{targetIds:n,activeId:o,label:e.formatFallbackLabel(n),document:e.document,selection:{targetIds:n,activeId:o,scopeType:"scene",targetKind:e.fallbackSelectionKind??"object",document:e.document},sections:[e.extraSection]}}return{...r,sections:[...r.sections.filter(n=>n.id!==e.extraSection.id),e.extraSection].sort((n,o)=>(n.order??0)-(o.order??0))}}function Bu(e){let t=[...e.createBaseSections()],r=e.isCameraGameObject(e.gameObject),n=e.isLightGameObject(e.gameObject),o=e.isMarkerGameObject(e.gameObject),a=e.nodeKind==="transform";return $u(t,e.createCustomSections?.({document:e.document,gameObject:e.gameObject,context:e.context,nodeKind:e.nodeKind,isCamera:r,isLight:n,isMarker:o})),$a(t,a&&r?e.createCameraSection?.():null),$u(t,a&&n?e.createLightSections?.():null),$a(t,a&&o?e.createMarkerSection?.():null),$a(t,e.createPrefabInstanceSection?.()),(e.isMaterialInspectorCandidate?.({nodeKind:e.nodeKind,gameObject:e.gameObject,isCamera:r,isLight:n,isMarker:o})??(e.nodeKind==="instance"||e.nodeKind==="primitive"||a&&!r&&!n&&!o))&&($u(t,e.createMaterialSections?.()),$a(t,e.createOutlineSection?.())),t.sort((s,c)=>(s.order??0)-(c.order??0))}function $a(e,t){t&&e.push(t)}function $u(e,t){if(t)for(let r of t)$a(e,r)}function Vu(e){let t=e.outline,r=t?"active":"default",n=r==="default"?Fy:void 0;return{id:"outline",title:"Outline",order:60,placement:"body",summary:t?"Configured":"Defaults",persistence:r==="default"?"readonly":"document",effect:r,disabledReason:n,collapsedByDefault:!0,properties:aO(oO(e),r,n)}}var Fy="Outline fields are showing defaults; configure an outline override before edits affect this object.";function oO(e){let t=e.outline,r=[e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.renderOutline",label:"Render Outline",valueType:"boolean",control:"boolean",value:t?.renderOutline??!1,commitMode:"immediate",order:0}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineWidth",label:"Width",valueType:"number",control:"number",value:t?.outlineWidth??.04,commitMode:"live",order:1,min:0,step:.005,displayPrecision:3,precision:3,stepPrecision:.001}),e.createDocumentInspectorProperty(null,e.nodeKind,{path:"overrides.outline.outlineColor",label:"Color",valueType:"color",control:"color",value:t?.outlineColor??{r:.03,g:.03,b:.03},commitMode:"immediate",order:2})],n=j({path:"overrides.outline.raw",label:"Raw Override",value:t??"not configured",order:r.length,source:"Document",tags:["Raw"]});return n&&r.push(n),r}function aO(e,t,r){return!t||t==="active"?e:e.map(n=>({...n,readOnly:!0,persistence:n.persistence==="runtime"?"runtime":"readonly",control:n.control==="custom"?n.control:"readonly",effect:n.effect??t,disabledReason:n.disabledReason??r}))}var iO={title:"\u6807\u8BB0",typeLabel:"\u6807\u8BB0\u7C7B\u578B",kindLabel:"\u7A7A\u95F4\u7C7B\u522B",tagsLabel:"\u6807\u7B7E",colorLabel:"\u989C\u8272",noteLabel:"\u5907\u6CE8",geometryLabel:"\u51E0\u4F55",targetLabel:"\u7ED1\u5B9A\u5BF9\u8C61",targetStatusLabel:"\u7ED1\u5B9A\u72B6\u6001",emptyTypeOption:"\u672A\u9009\u62E9",emptyTargetOption:"\u672A\u7ED1\u5B9A",tagsPlaceholder:"\u6807\u7B7E, \u53E6\u4E00\u4E2A\u6807\u7B7E",notePlaceholder:"\u53EF\u9009\u6807\u8BB0\u5907\u6CE8",unselectedSummary:"\u672A\u9009\u62E9",missingTargetPrefix:"\u7F3A\u5931",missingTargetStatus:"\u76EE\u6807\u7F3A\u5931",targetStatusUnbound:"\u672A\u7ED1\u5B9A",targetStatusOk:"\u6B63\u5E38",unsupportedTargetPrefix:"\u4E0D\u652F\u6301\u76EE\u6807"},sO={region:"\u533A\u57DF",point:"\u70B9",anchor:"\u951A\u70B9",object:"\u5BF9\u8C61\u7ED1\u5B9A"},cO={box:"\u76D2\u4F53",point:"\u70B9","object-bounds":"\u5BF9\u8C61\u5305\u56F4\u76D2",polyhedron:"\u591A\u9762\u4F53"};function Wu(e){let t={...iO,...e.text},r=e.gameObject.marker,n=e.resolveMarkerKind(e.document,r),o=dO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),a=pO(r),i=a?.kind==="scene-object"?a.id:"",s=lO(e.document,e.gameObject.id,i,e.isMarkerGameObject,t),c=[e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.type",label:t.typeLabel,valueType:"enum",control:o.length>0?"enum":"string",value:r.type,options:o.length>0?o:void 0,commitMode:"change",order:0}),Ku("marker.kind",t.kindLabel,mO(n,e.formatMarkerKindLabel),1),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.tags",label:t.tagsLabel,valueType:"string",control:"string",value:r.tags?.join(", ")??"",commitMode:"blur",placeholder:t.tagsPlaceholder,order:2}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.color",label:t.colorLabel,valueType:"color",control:"color",value:r.color??{r:.1,g:.85,b:1},commitMode:"immediate",order:3}),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.note",label:t.noteLabel,valueType:"string",control:"string",value:r.note??"",commitMode:"blur",placeholder:t.notePlaceholder,order:4}),Ku("marker.geometry.kind",t.geometryLabel,fO(r.geometry.kind,e.formatMarkerGeometryKindLabel),5),e.createDocumentInspectorProperty(e.document,e.nodeKind,{path:"marker.target.objectId",label:t.targetLabel,valueType:"enum",control:"enum",value:i,options:s,commitMode:"change",order:6}),Ku("marker.target.status",t.targetStatusLabel,gO(e.document,a,t),7)];return{id:"marker",title:t.title,order:35,placement:"body",persistence:"document",summary:uO(e.markerTypeCatalog,r.type,t,e.formatMarkerTypeLabel),collapsedByDefault:!1,properties:c}}function dO(e,t,r,n){let o=[{label:r.emptyTypeOption,value:""},...e.map(a=>({label:Hu(a.type,a.label||a.type,n),value:a.type}))];return t&&!o.some(a=>a.value===t)&&o.push({label:Hu(t,t,n),value:t}),o}function lO(e,t,r,n,o){let a=[{label:o.emptyTargetOption,value:""},...e.scene.gameObjects.filter(i=>i.id!==t&&!n(i)).map(i=>({label:i.name||i.id,value:i.id}))];return r&&!a.some(i=>i.value===r)&&a.push({label:`${o.missingTargetPrefix}: ${r}`,value:r}),a}function uO(e,t,r,n){if(!t.trim())return r.unselectedSummary;let o=e.find(a=>a.type===t);return Hu(t,o?.label||t,n)}function Hu(e,t,r){return r?.(e,t)??t}function mO(e,t){return t?.(e)??sO[e]??e}function fO(e,t){return t?.(e)??cO[e]??e}function pO(e){return e.target?Uu(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?Uu(e.geometry.target):null}function gO(e,t,r){return t?t.kind!=="scene-object"?`${r.unsupportedTargetPrefix}: ${t.kind}`:e.scene.gameObjects.some(n=>n.id===t.id)?r.targetStatusOk:r.missingTargetStatus:r.targetStatusUnbound}function Uu(e){return{...e,...e.metadata?{metadata:{...e.metadata}}:{}}}function Ku(e,t,r,n){return j({path:e,label:t,value:r,order:n,source:"Document"})}var La={r:1,g:1,b:1,a:1};function bO(e){return{...e}}function zy(e){let t=bO(e);return{services:t,normalizeLayoutPatchValue:r=>dc(r,t),isLayoutPatchCompatibleWithDecal:(r,n)=>Wy(r,n,t),canPatchMultiField:(r,n,o,a)=>IO(r,n,o,a,t),patchLayout:(r,n,o)=>PO(r,n,o,t),patchKind:(r,n,o)=>TO(r,n,o,t),patchInspectorField:(r,n,o,a)=>xO(r,n,o,a,t),normalizeGameObject:r=>On(r,t),replaceUi:(r,n,o)=>DO(r,n,o,t),normalizeScaleAfterFieldPatch:(r,n,o,a)=>oc(r,n,o,a,t),normalizeScalesForCommand:(r,n)=>MO(r,n,t),normalizeScales:(r,n,o)=>cc(r,t,n,o),mergeDefaults:r=>dt(r,t.createDefaultGroundDecal,t)}}function By(e){return{...e.policy,createDocumentInspectorProperty:e.createDocumentInspectorProperty,normalizeValue:e.normalizeValue,findTarget:e.findTarget,getTargetId:e.getTargetId,getTargetNodeKind:e.getTargetNodeKind,getTargetGroundDecal:e.getTargetGroundDecal,canShowTarget:e.canShowTarget,isUiTarget:e.isUiTarget,canPatchMultiField:e.canPatchMultiField,findTextureAsset:e.findTextureAsset,resolveTextureAssetUrl:e.resolveTextureAssetUrl,getMaterialText:e.getMaterialText,createTexturePickerControlOptions:e.createTexturePickerControlOptions}}var SO=75;function qu(e,t){if(e==="transform.scale"){let r=t;return!r||typeof r!="object"?null:Jy({x:typeof r.x=="number"?r.x:1,y:typeof r.y=="number"?r.y:1,z:typeof r.z=="number"?r.z:1})}return!/^transform\.scale\.(x|y|z)$/.test(e)||typeof t!="number"||!Number.isFinite(t)?null:Math.max(.001,Math.abs(t))}function dc(e,t={}){let r=Ha(e),n=Array.isArray(e)?e:r&&Array.isArray(r.layers)?r.layers:null;if(!n)return null;let o=n.map((a,i)=>yO(a,i,t)).filter(a=>!!a);return o.length>0?o:null}function yO(e,t,r={}){let n=Ha(e);if(!n)return null;let o=ZO(n.id)??`layer_${t}`,a=To(n.rect),i=n.fontSize==null?null:ac(n.fontSize),s=n.rotationDeg==null?null:Ao(n.rotationDeg);return!a||n.fontSize!=null&&i==null||n.rotationDeg!=null&&s==null?null:{id:o,rect:a,...s==null?{}:{rotationDeg:s},...i==null?{}:{fontSize:_r(i)}}}function To(e){let t=Ha(e);if(!t)return null;let r=Xt(t.x),n=Xt(t.z),o=ac(t.width),a=ac(t.depth);return r==null||n==null||o==null||a==null?null:{x:r,z:n,width:o,depth:a}}function Xt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function ac(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Vy(e,t){if(e==="groundDecal.editorPreviewActive")return typeof t=="boolean"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(lc(e))return To(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(Uy(e)){let r=Ao(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(uc(e))return typeof t=="string"?{ok:!0,value:t.trim()}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(pc(e))return typeof t=="string"?{ok:!0,value:t}:{ok:!1,message:`Invalid value for scene node field: ${e}.`};if(Ky(e)){let r=Xu(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(mc(e)||Sc(e)||gc(e)){let r=za(t);return r?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(fc(e)||yc(e)||bc(e)){let r=Ba(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if(hc(e)){let r=Ju(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}if($r(e)){let r=Ka(t);return r!==null?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${e}.`}}return null}function Va(e){let t=e.match(/^groundDecal\.layers\.(\d+)\.(rect|rotationDeg|textureId|text\.value|text\.fontSize|color|color\.a|tint|tint\.a|text\.color|text\.color\.a|editorPreviewPercent)$/);if(!t)return null;let r=Number(t[1]);return!Number.isInteger(r)||r<0?null:{index:r,field:t[2]}}function lc(e){return/^groundDecal\.layers\.\d+\.rect$/.test(e)}function Uy(e){return/^groundDecal\.layers\.\d+\.rotationDeg$/.test(e)}function uc(e){return/^groundDecal\.layers\.\d+\.textureId$/.test(e)}function mc(e){return/^groundDecal\.layers\.\d+\.color$/.test(e)}function fc(e){return/^groundDecal\.layers\.\d+\.color\.a$/.test(e)}function pc(e){return/^groundDecal\.layers\.\d+\.text\.value$/.test(e)}function Ky(e){return/^groundDecal\.layers\.\d+\.text\.fontSize$/.test(e)}function gc(e){return/^groundDecal\.layers\.\d+\.text\.color$/.test(e)}function bc(e){return/^groundDecal\.layers\.\d+\.text\.color\.a$/.test(e)}function Sc(e){return/^groundDecal\.layers\.\d+\.tint$/.test(e)}function yc(e){return/^groundDecal\.layers\.\d+\.tint\.a$/.test(e)}function hc(e){return/^groundDecal\.layers\.\d+\.editorPreviewPercent$/.test(e)}function $r(e){return e==="groundDecal.rendering.textureWidth"||e==="groundDecal.rendering.textureHeight"}function Ec(e){return e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||!!Va(e)||$r(e)}function Ua(e){return e==="groundDecal.size.width"||e==="groundDecal.size.depth"||e==="groundDecal.editorPreviewActive"||e==="groundDecal.layers"||Ec(e)}function hO(e,t,r={}){return t==="rect"?xo(e,r):t==="rotationDeg"?Pc(e,r):t==="textureId"||t==="tint"||t==="tint.a"?ic(e,r):t==="text.value"||t==="text.fontSize"||t==="text.color"||t==="text.color.a"?Hy(e,r):t==="color"||t==="color.a"?sc(e,r):t==="editorPreviewPercent"?e.kind==="textureProgress"?ic(e,r):e.kind==="progress"&&sc(e,r):!1}function Ic(e,t={}){return t.isProjectEditableLayer?.(e)??e.enabled!==!1}function xo(e,t={}){return t.isLayoutEditableLayer?.(e)??e.enabled!==!1}function Pc(e,t={}){return t.isRotationEditableLayer?.(e)??!1}function ic(e,t={}){return t.isEditableTextureLayer?.(e)??(e.kind==="texture"||e.kind==="textureProgress")}function sc(e,t={}){return t.isEditableColorLayer?.(e)??(e.kind==="color"||e.kind==="progress")}function Hy(e,t={}){return t.isEditableTextLayer?.(e)??e.kind==="text"}function Wy(e,t,r={}){let n=e.layers.filter(o=>xo(o,r));return t.length!==n.length?!1:n.every((o,a)=>{let i=t[a];return i?.id===o.id&&(i.fontSize==null||o.kind==="text")&&(i.rotationDeg==null||Pc(o,r))})}function za(e){let t=Ha(e);if(!t)return null;let r=Xt(t.r),n=Xt(t.g),o=Xt(t.b);if(r==null||n==null||o==null)return null;let a=Xt(t.a);return{r:_r(Math.max(0,Math.min(1,r))),g:_r(Math.max(0,Math.min(1,n))),b:_r(Math.max(0,Math.min(1,o))),...a==null?{}:{a:_r(Math.max(0,Math.min(1,a)))}}}function Ba(e){let t=Xt(e);return t==null?null:_r(Math.max(0,Math.min(1,t)))}function Ju(e){let t=Xt(e);return t==null?null:Math.round(Math.max(0,Math.min(100,t)))}function Ao(e){let t=Xt(e);if(t==null)return null;let r=t%360;r>180&&(r-=360),r<=-180&&(r+=360);let n=_r(r);return Object.is(n,-0)?0:n}function Xu(e){let t=ac(e);return t==null?null:_r(t)}function Ka(e){let t=Xt(e);return t==null||t<=0?null:Math.max(64,Math.min(2048,Math.round(t)))}function _r(e){return Math.round(e*1e3)/1e3}function Tc(e,t){return e==="groundDecal.editorPreviewActive"?t===!0:e==="groundDecal.layers"?dc(t)??t:lc(e)?To(t)??t:Uy(e)?Ao(t)??t:uc(e)&&typeof t=="string"?t.trim():pc(e)&&typeof t=="string"?t:Ky(e)?Xu(t)??t:mc(e)||Sc(e)||gc(e)?za(t)??t:fc(e)||yc(e)||bc(e)?Ba(t)??t:hc(e)?Ju(t)??t:$r(e)?Ka(t)??t:t}function qy(e,t,r){if(t==="rect"){let n=To(r);return n?EO(e.rect,n)?e:{...e,rect:n}:null}if(t==="rotationDeg"){let n=Ao(r);if(n==null)return null;if(n===0){if(e.rotationDeg==null)return e;let{rotationDeg:o,...a}=e;return a}return e.rotationDeg===n?e:{...e,rotationDeg:n}}if(t==="textureId"){if(e.kind!=="texture"&&e.kind!=="textureProgress"||typeof r!="string")return null;let n=r.trim();if(!n){if(!e.textureId)return e;let{textureId:o,...a}=e;return a}return e.textureId===n?e:{...e,textureId:n}}if(t==="text.value")return e.kind!=="text"||typeof r!="string"?null:e.text.value===r?e:{...e,text:{...e.text,value:r}};if(t==="text.fontSize"){if(e.kind!=="text")return null;let n=Xu(r);return n==null?null:e.text.fontSize===n?e:{...e,text:{...e.text,fontSize:n}}}if(t==="color"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=za(r);if(!n)return null;let o={...n,...n.a==null&&e.color.a!=null?{a:e.color.a}:{}};return Po(e.color,o)?e:{...e,color:o}}if(t==="color.a"){if(e.kind!=="color"&&e.kind!=="progress")return null;let n=Ba(r);if(n===null)return null;let o={...e.color,a:n};return Po(e.color,o)?e:{...e,color:o}}if(t==="editorPreviewPercent"){if(e.kind!=="progress"&&e.kind!=="textureProgress")return null;let n=Ju(r);return n===null?null:e.editorPreviewPercent===n?e:{...e,editorPreviewPercent:n}}if(t==="tint"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=za(r);if(!n)return null;let o={...n,...n.a==null&&e.tint?.a!=null?{a:e.tint.a}:{}};return Po(e.tint??La,o)?e:{...e,tint:o}}if(t==="tint.a"){if(e.kind!=="texture"&&e.kind!=="textureProgress")return null;let n=Ba(r);if(n===null)return null;let o={...La,...e.tint??{},a:n};return Po(e.tint??La,o)?e:{...e,tint:o}}if(t==="text.color"){if(e.kind!=="text")return null;let n=za(r);if(!n)return null;let o={...n,...n.a==null&&e.text.color.a!=null?{a:e.text.color.a}:{}};return Po(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}if(t==="text.color.a"){if(e.kind!=="text")return null;let n=Ba(r);if(n===null)return null;let o={...e.text.color,a:n};return Po(e.text.color,o)?e:{...e,text:{...e.text,color:o}}}return null}function dt(e,t,r={}){let n=e&&typeof e=="object"&&!Array.isArray(e)?e:null,o=typeof n?.uiKind=="string"?n.uiKind.trim():"",a=o&&(r.isKnownUiKind?.(o)??!0)?o:r.defaultUiKind??"default",i=t(a);return n?{...i,...structuredClone(n),uiKind:a,size:{...i.size,...n.size&&typeof n.size=="object"?n.size:{}},layers:Array.isArray(n.layers)&&n.layers.length>0?structuredClone(n.layers):i.layers,mask:n.mask&&typeof n.mask=="object"?{...i.mask??{},...n.mask}:i.mask,rendering:n.rendering&&typeof n.rendering=="object"?{...i.rendering??{},...n.rendering}:i.rendering}:i}function Po(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&(e.a??1)===(t.a??1)}function EO(e,t){return e.x===t.x&&e.z===t.z&&e.width===t.width&&e.depth===t.depth}function Jy(e){let t=[e.x,e.y,e.z].filter(n=>Number.isFinite(n));if(t.length===0)return 1;let r=t.reduce((n,o)=>Math.abs(o-1)>Math.abs(n-1)?o:n,t[0]);return Math.max(.001,Math.abs(r))}function IO(e,t,r,n,o){if(!Ua(r))return!1;let a=vO(e,t);if(!a||!o.canShowGroundDecalInspector(a))return!1;let i=dt(a.groundDecal,o.createDefaultGroundDecal,o);if(r==="groundDecal.size.width"||r==="groundDecal.size.depth"||$r(r)||r==="groundDecal.editorPreviewActive")return!0;if(r==="groundDecal.layers"){let d=dc(n,o);return d?Wy(i,d,o):!1}let s=Va(r);if(!s)return!1;let c=i.layers[s.index];return!!c&&Ic(c,o)&&hO(c,s.field,o)}function PO(e,t,r,n){let o=dc(r,n);return o?Yy(e,a=>a.id===t?wO(a,o,n):a):e}function TO(e,t,r,n){if(typeof r!="string"||!r.trim())return e;let o=r.trim();return n.isKnownUiKind&&!n.isKnownUiKind(o)?e:Yy(e,a=>a.id===t?kO(a,o,n):a)}function xO(e,t,r,n,o){if(r==="groundDecal.editorPreviewActive"){if(typeof n!="boolean")return e;let d=!1,u=e.scene.gameObjects.map(l=>{if(l.id!==t||!o.canShowGroundDecalInspector(l))return l;let m=dt(l.groundDecal,o.createDefaultGroundDecal,o);return m.editorPreviewActive===n?l:(d=!0,On({...l,groundDecal:{...m,editorPreviewActive:n}},o))});return d?{...e,scene:{...e.scene,gameObjects:u}}:e}if($r(r))return AO(e,t,r,n,o);let a=Va(r);if(!a)return null;let i=!1,s=Tc(r,n),c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o),l=u.layers[a.index];if(!l||!Ic(l,o)||a.field==="rect"&&!xo(l,o))return d;let m=qy(l,a.field,s);if(!m||m===l)return d;let f=[...u.layers];return f[a.index]=m,i=!0,On({...d,groundDecal:{...u,layers:f}},o)});return i?{...e,scene:{...e.scene,gameObjects:c}}:e}function AO(e,t,r,n,o){let a=Ka(n);if(a===null)return e;let i=r==="groundDecal.rendering.textureWidth"?"textureWidth":"textureHeight",s=!1,c=e.scene.gameObjects.map(d=>{if(d.id!==t||!o.canShowGroundDecalInspector(d))return d;let u=dt(d.groundDecal,o.createDefaultGroundDecal,o);return u.rendering?.[i]===a?d:(s=!0,On({...d,groundDecal:{...u,rendering:{...u.rendering,[i]:a}}},o))});return s?{...e,scene:{...e.scene,gameObjects:c}}:e}function DO(e,t,r,n){if(!n.isGroundDecalConfig(r))return e;let o=!1,a=e.scene.gameObjects.map(i=>i.id!==t||!n.isGroundDecalUiGameObject(i)||i.groundDecal.uiKind!==r.uiKind?i:(o=!0,On({...i,kind:"transform",transformType:"groundDecal",groundDecal:dt(r,n.createDefaultGroundDecal,n)},n)));return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function oc(e,t,r,n,o){return r.startsWith("transform.scale")?cc(e,o,t,qu(r,n)):e}function MO(e,t,r){if(t.type==="document.replace")return cc(e,r);let n=t.patch;return n.kind==="game-object.field"?oc(e,String(n.targetId??""),String(n.path??""),n.value,r):n.kind==="game-object.property-field-batch"&&Array.isArray(n.fields)?n.fields.reduce((o,a)=>{let i=Ha(a);return oc(o,String(i?.targetId??""),String(i?.path??""),i?.value,r)},e):n.kind==="game-object.field-batch"?Array.isArray(n.targetIds)?n.targetIds.reduce((o,a)=>oc(o,String(a),String(n.path??""),n.value,r),e):e:cc(e,r)}function cc(e,t,r,n){let o=!1,a=e.scene.gameObjects.map(i=>{if(r&&i.id!==r||!t.isGroundDecalUiGameObject(i))return i;let s=G(i);if(!s||!CO(s)||!s.scale)return i;let c=n??Jy(s.scale);return Math.abs(s.scale.x-c)<1e-6&&Math.abs(s.scale.y-c)<1e-6&&Math.abs(s.scale.z-c)<1e-6?i:(o=!0,{...i,components:i.components.map(d=>d===s?{...d,scale:{x:c,y:c,z:c}}:d)})});return o?{...e,scene:{...e.scene,gameObjects:a}}:e}function On(e,t){let r=OO({...e,kind:"transform",transformType:"groundDecal",groundDecal:dt(e.groundDecal,t.createDefaultGroundDecal,t)});return delete r.camera,delete r.light,delete r.primitive,r}function Xy(e){return e==="groundDecal"||e.startsWith("groundDecal.")}function wO(e,t,r){let n=new Map(t.map(a=>[a.id,a])),o=dt(e.groundDecal,r.createDefaultGroundDecal,r);return On({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,layers:o.layers.map((a,i)=>{if(!xo(a,r))return a;let s=n.get(a.id)??t[i];if(!s)return a;let c=a.kind==="text"?{...a.rect,x:s.rect.x,z:s.rect.z}:s.rect,d=a.kind==="text"&&s.fontSize!=null?{...a,rect:c,text:{...a.text,fontSize:s.fontSize}}:{...a,rect:c};return s.rotationDeg!=null&&Pc(a,r)&&(d=qy(d,"rotationDeg",s.rotationDeg)??d),d})}},r)}function kO(e,t,r){let n=dt(e.groundDecal,r.createDefaultGroundDecal,r),o=r.createDefaultGroundDecal(t);return On({...e,kind:"transform",transformType:"groundDecal",groundDecal:{...o,size:n.size,mask:n.mask??o.mask,rendering:n.rendering??o.rendering}},r)}function OO(e){return e.components.some(t=>t.type==="Transform")?e:{...e,components:[RO(),...e.components]}}function RO(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function CO(e){return e.type==="Transform"&&e.mode!=="matrix"}function vO(e,t){return t?e.scene.gameObjects.find(r=>r.id===t)??null:null}function Yy(e,t){return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(t)}}}function Zy(e,t,r={},n){let o=dt(t,n.createDefaultGroundDecal,n),a=[YO("groundDecal.uiKind","Type",n.createUiKindLabel?.(o.uiKind)??o.uiKind,0),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.width",label:"Width",valueType:"number",control:"number",value:o.size.width,commitMode:"live",order:1,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.size.depth",label:"Depth",valueType:"number",control:"number",value:o.size.depth,commitMode:"live",order:2,min:.001,step:.1,controlOptions:{refreshInspector:!1}}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureWidth",label:"Texture Width",valueType:"number",control:"number",value:o.rendering?.textureWidth??512,commitMode:"change",order:3,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.rendering.textureHeight",label:"Texture Height",valueType:"number",control:"number",value:o.rendering?.textureHeight??512,commitMode:"change",order:4,min:64,max:2048,step:64}),n.createDocumentInspectorProperty(null,e,{path:"groundDecal.layers",label:"Layout",valueType:"object",control:"custom",customControl:"ground-decal-layout",value:nh(o,r,n),commitMode:"live",order:5,coerce:s=>n.normalizeValue("groundDecal.layers",s),controlOptions:{aspectRatio:JO(o),aspectRatioUsesDecalSize:qO(o),sizeWidth:o.size.width,sizeDepth:o.size.depth}})],i=10;if((n.canShowActivePreview?.(o)??!1)&&a.push(n.createDocumentInspectorProperty(null,e,{path:"groundDecal.editorPreviewActive",label:"Preview Active Background",valueType:"boolean",control:"boolean",value:o.editorPreviewActive===!0,commitMode:"immediate",order:6,tags:["GroundDecalUI","Preview"],controlOptions:{refreshInspector:!1}})),r.enableGroundDecalUiActions&&(n.canShowLayerPairActions?.(o)??!1)&&n.layerPairActions){let s=n.getLayerPairs?.(o).length??0,c=n.canAddLayerPair?.(o)??!1,d=n.canRemoveLayerPair?.(o)??!1;a.push(Ly({path:n.layerPairActions.addPath??"groundDecal.layerPairs.add",label:n.layerPairActions.addLabel??"Add item",actionId:n.layerPairActions.addActionId,order:i,icon:"asset",tooltip:n.layerPairActions.addTooltip??"Add an item.",params:{},disabled:!c,disabledReason:c?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"add",pairCount:s}),effect:c?"active":"unsupported"})),i+=1,a.push(Ly({path:n.layerPairActions.removePath??"groundDecal.layerPairs.remove",label:n.layerPairActions.removeLabel??"Remove item",actionId:n.layerPairActions.removeActionId,order:i,icon:"asset",tooltip:n.layerPairActions.removeTooltip??"Remove an item.",params:{},disabled:!d,disabledReason:d?void 0:n.createLayerPairDisabledReason?.({decal:o,action:"remove",pairCount:s}),effect:d?"active":"unsupported"})),i+=1}for(let s=0;s<o.layers.length;s+=1){let c=o.layers[s];if(!c||!Ic(c,n))continue;let d=oh(c,n);if(ic(c,n)){let u=n.resolveImageFit?.(c)??c.imageFit??"contain",l=VO(e,r,c,s,d,i,n);u!=="stretch"&&o.lockAspectToBorder===!0&&o.aspectSourceLayerId===c.id&&(l.controlOptions={...l.controlOptions,groundDecalAspectSizeWidth:o.size.width,groundDecalAspectSizeDepthPath:"groundDecal.size.depth",groundDecalAspectTextureWidth:o.rendering?.textureWidth??512,groundDecalAspectTextureHeight:o.rendering?.textureHeight??512,groundDecalAspectTextureWidthPath:"groundDecal.rendering.textureWidth",groundDecalAspectTextureHeightPath:"groundDecal.rendering.textureHeight"}),a.push(l),i+=1,a.push(HO(e,c,s,d,i,n)),i+=1}(c.kind==="progress"&&sc(c,n)||c.kind==="textureProgress"&&ic(c,n))&&(a.push(KO(e,c,s,d,i,n)),i+=1),sc(c,n)&&(a.push(UO(e,c,s,d,i,n)),i+=1),Hy(c,n)&&(a.push(n.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${s}.text.value`,label:`${d} Text`,valueType:"string",control:"string",value:c.text.value,commitMode:"blur",order:i,tags:["GroundDecalUI","Text"]})),i+=1,a.push(WO(e,c,s,d,i,n)),i+=1)}return XO(a,{path:"groundDecal.raw",label:"Raw Ground Decal",value:t??o,order:i,source:"Document",tags:["Raw"]}),a}function Qy(e,t,r,n){let o=n.getTargetGroundDecal(e),a=dt(o,n.createDefaultGroundDecal,n),i=Zy(t,a,{...r,enableGroundDecalUiActions:n.isUiTarget?.(e)??!1},n),s=i.find(d=>d.path==="groundDecal.layers");if(!s)throw new Error("Ground Decal Inspector requires the canonical layout property.");let c=i.filter(d=>d!==s).map(d=>({...d,controlOptions:{...d.controlOptions,groundDecalWorkbenchChild:!0}}));return{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:jO(a,n),persistence:"document",collapsedByDefault:!1,properties:[GO(a,[s,...c],n),...c]}}function GO(e,t,r){let n=t.find(a=>a.path==="groundDecal.layers");if(!n||!n.value||typeof n.value!="object"||Array.isArray(n.value))throw new Error("Ground Decal Inspector requires the canonical layout property.");let o={uiKind:e.uiKind,uiKindLabel:r.createUiKindLabel?.(e.uiKind)??e.uiKind,layout:n.value,properties:t.filter(a=>a!==n)};return{...n,label:"Ground Decal Editor",customControl:"ground-decal-workbench",value:o,controlOptions:{...n.controlOptions,refreshInspector:!1}}}function jO(e,t){let r=t.createUiKindLabel?.(e.uiKind)??e.uiKind,n=Math.max(1,Math.round(e.rendering?.textureWidth??512)),o=Math.max(1,Math.round(e.rendering?.textureHeight??512)),a=n===o?`${n}\xB2`:`${n}\xD7${o}`,i=t.canShowLayerPairActions?.(e)??!1?t.getLayerPairs?.(e).length??0:0;return i>0?`${r} \xB7 ${i} item${i===1?"":"s"} \xB7 ${a}`:`${r} \xB7 ${a}`}function eh(e,t,r,n,o){let a=rh(e,t,o);if(a.length<=1)return null;let i=a.find(l=>o.getTargetId(l.target)===r)??a[0];if(!i)return null;let s=NO(a.map(l=>l.decal),o),c=o.getTargetNodeKind(i.target),d=Zy(c,i.decal,{...n,enableGroundDecalUiActions:!1},o).filter(l=>_O(l,s)).filter(l=>a.every(m=>l.readOnly||o.canPatchMultiField(e,o.getTargetId(m.target),l.path,l.value))).map(l=>({...l,mixed:$O(a,l.path,n,o)}));return d.length===0?null:{id:"groundDecal",title:"Ground Decal",order:40,placement:"body",summary:a.some(l=>l.decal.uiKind!==i.decal.uiKind)?"Mixed":`${a.length} ${o.createUiKindLabel?.(i.decal.uiKind)??i.decal.uiKind} UIs`,persistence:"document",collapsedByDefault:!1,properties:d}}function th(e,t,r){return rh(e,t,r).map(n=>r.getTargetId(n.target))}function rh(e,t,r){let n=new Set,o=[];for(let a of t){if(!a||n.has(a))continue;n.add(a);let i=r.findTarget(e,a);!i||!r.canShowTarget(i)||o.push({target:i,decal:dt(r.getTargetGroundDecal(i),r.createDefaultGroundDecal,r)})}return o}function NO(e,t={}){if(e.length===0)return!1;let[r,...n]=e.map(o=>FO(o,t));return n.every(o=>o===r)}function FO(e,t={}){return e.layers.map((r,n)=>({layer:r,index:n})).filter(r=>Ic(r.layer,t)).map(({layer:r,index:n})=>`${n}:${r.id}:${r.role}:${r.kind}`).join("|")}function _O(e,t){return e.path==="groundDecal.raw"?!1:e.path==="groundDecal.uiKind"||e.path==="groundDecal.size.width"||e.path==="groundDecal.size.depth"||e.path==="groundDecal.editorPreviewActive"||$r(e.path)?!0:e.path==="groundDecal.layers"||Va(e.path)?t:!1}function $O(e,t,r,n){if(e.length<=1)return!1;let[o,...a]=e.map(i=>JSON.stringify(LO(i.decal,t,r,n)));return a.some(i=>i!==o)}function LO(e,t,r,n){if(t==="groundDecal.uiKind")return e.uiKind;if(t==="groundDecal.size.width")return e.size.width;if(t==="groundDecal.size.depth")return e.size.depth;if(t==="groundDecal.editorPreviewActive")return e.editorPreviewActive===!0;if(t==="groundDecal.rendering.textureWidth")return e.rendering?.textureWidth??512;if(t==="groundDecal.rendering.textureHeight")return e.rendering?.textureHeight??512;if(t==="groundDecal.layers")return nh(e,r,n).layers;let o=Va(t);if(!o)return;let a=e.layers[o.index];if(a)return zO(a,o.field)}function zO(e,t){if(t==="rect")return e.rect;if(t==="rotationDeg")return e.rotationDeg??0;if(t==="textureId")return e.kind==="texture"||e.kind==="textureProgress"?e.textureId:void 0;if(t==="text.value")return e.kind==="text"?e.text.value:void 0;if(t==="text.fontSize")return e.kind==="text"?e.text.fontSize:void 0;if(t==="color")return e.kind==="color"||e.kind==="progress"?e.color:void 0;if(t==="color.a")return e.kind==="color"||e.kind==="progress"?e.color.a??1:void 0;if(t==="tint")return e.kind==="texture"||e.kind==="textureProgress"?e.tint??La:void 0;if(t==="tint.a")return e.kind==="texture"||e.kind==="textureProgress"?e.tint?.a??1:void 0;if(t==="text.color")return e.kind==="text"?e.text.color:void 0;if(t==="text.color.a")return e.kind==="text"?e.text.color.a??1:void 0;if(t==="editorPreviewPercent")return e.kind==="progress"||e.kind==="textureProgress"?Yu(e):void 0}function nh(e,t,r){let n=Ni(e),o=e.layers.map((a,i)=>({layer:a,index:i})).filter(a=>xo(a.layer,r));return{textureSize:n,mask:e.mask,layers:o.map(({layer:a,index:i})=>_y(t,a,i,r)),previewLayers:e.layers.map((a,i)=>{let s=_y(t,a,i,r),c=r.getLayerPreviewVisibility?.(a,e);return c?{...s,enabled:s.enabled!==!1&&c.value,previewVisibilityPath:c.path,previewVisibilityBaseEnabled:s.enabled!==!1}:s})}}function _y(e,t,r,n){return{index:r,id:t.id,role:t.role,kind:t.kind,label:oh(t,n),rect:t.rect,rotationDeg:t.rotationDeg??0,rotationEditable:Pc(t,n),enabled:t.enabled!==!1,editable:xo(t,n),zOrder:t.zOrder,...typeof t.opacity=="number"?{opacity:t.opacity}:{},...n.useUniformLayoutScaleMode?.(t)?{scaleMode:"uniform"}:{},...t.kind==="progress"||t.kind==="textureProgress"?{previewValuePath:`groundDecal.layers.${r}.editorPreviewPercent`}:{},...t.kind==="text"&&typeof t.text.fontSize=="number"?{fontSize:t.text.fontSize}:{},preview:BO(e,t,n)}}function oh(e,t={}){let r=t.createLayerLabel?.(e);return r||e.role.charAt(0).toUpperCase()+e.role.slice(1)}function BO(e,t,r){if(t.kind==="texture"||t.kind==="textureProgress"){if(!t.textureId)return;let n=r.findTextureAsset?.(e,t.textureId)??null,o=n?.url??e.resolveTextureAssetUrl?.(t.textureId)??r.resolveTextureAssetUrl?.(t.textureId);return o?{kind:t.kind==="textureProgress"?"imageProgress":"image",url:o,alt:n?.label??t.textureId,imageFit:r.resolveImageFit?.(t)??t.imageFit??"contain",...t.tint?{tint:t.tint}:{},...t.kind==="textureProgress"?{value:$y(t),direction:t.direction}:{}}:void 0}if(t.kind==="color")return{kind:"color",color:t.color};if(t.kind==="progress")return{kind:"progress",value:$y(t),direction:t.direction,color:t.color};if(t.kind==="text")return{kind:"text",text:t.text.value,fontFamily:t.text.fontFamily,fontSize:t.text.fontSize,fontWeight:t.text.fontWeight,color:t.text.color,strokeColor:t.text.strokeColor,strokeWidth:t.text.strokeWidth,align:t.text.align,baseline:t.text.baseline}}function Yu(e){let t=typeof e.editorPreviewPercent=="number"&&Number.isFinite(e.editorPreviewPercent)?e.editorPreviewPercent:SO;return Math.round(Math.max(0,Math.min(100,t)))}function $y(e){return Yu(e)/100}function VO(e,t,r,n,o,a,i){let s=i.getMaterialText?.("zh"),c=i.findTextureAsset?.(t,r.textureId)??null,d=`groundDecal.layers.${n}.textureId`;return i.createDocumentInspectorProperty(null,e,{path:d,label:`${o} PNG`,valueType:"string",control:"custom",customControl:"asset-picker-card",value:r.textureId??"",commitMode:"change",order:a,tags:["GroundDecalUI","TextureAsset"],controlOptions:i.createTexturePickerControlOptions?.(t,s,r.textureId,c)??{currentTextureId:r.textureId,currentTexture:c},coerce:u=>i.normalizeValue(d,u)})}function UO(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function KO(e,t,r,n,o,a){let i=`groundDecal.layers.${r}.editorPreviewPercent`;return a.createDocumentInspectorProperty(null,e,{path:i,label:`${n} Preview %`,valueType:"number",control:"number",value:Yu(t),commitMode:"blur",order:o,min:0,max:100,step:1,tags:["GroundDecalUI","Progress"],controlOptions:{refreshInspector:!1},coerce:s=>a.normalizeValue(i,s)})}function HO(e,t,r,n,o,a){let i=t.tint??La;return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.tint`,label:`${n} Color`,valueType:"color",control:"color",value:i,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function WO(e,t,r,n,o,a){return a.createDocumentInspectorProperty(null,e,{path:`groundDecal.layers.${r}.text.color`,label:`${n} Color`,valueType:"color",control:"color",value:t.text.color,commitMode:"immediate",order:o,tags:["GroundDecalUI","Color"],controlOptions:{refreshInspector:!1,colorChannelDisplay:"normalized",colorChannelPrecision:2}})}function qO(e){return e.size.width>0&&e.size.depth>0}function JO(e){return e.size.width>0&&e.size.depth>0?e.size.width/e.size.depth:1}function XO(e,t){let r=j(t);r&&e.push(r)}function YO(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function Ly(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function Ha(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function ZO(e){return typeof e=="string"&&e.trim()?e.trim():null}var Rn="groundDecal";function QO(e){if(e.id!==Rn||e.scene?.kind!==Rn||!e.config||typeof e.config!="object"||Array.isArray(e.config))return null;let t=e.config;return!Array.isArray(t.uiKinds)||t.uiKinds.length===0||t.uiKinds.some(r=>typeof r!="string"||r.trim().length===0)||!t.documentPolicy||typeof t.documentPolicy!="object"||Array.isArray(t.documentPolicy)||typeof t.documentPolicy.createDefaultGroundDecal!="function"||typeof t.documentPolicy.isGroundDecalConfig!="function"?null:t}function ah(e,t){let r=QO(e);if(!r)return null;let n=r.documentPolicy,o=eR(n),a=s=>s?.transformType===Rn&&o.isGroundDecalConfig(s.groundDecal);return tR({features:[e],documentPolicy:o,createInspectorServices:(s,c)=>By({policy:{...o,...r.inspectorPolicy??{}},createDocumentInspectorProperty:s,normalizeValue:Tc,findTarget:(d,u)=>d.scene.gameObjects.find(l=>l.id===u)??null,getTargetId:d=>d.id,getTargetNodeKind:d=>d.kind??"transform",getTargetGroundDecal:d=>d.groundDecal??null,canShowTarget:a,isUiTarget:a,canPatchMultiField:c.canPatchMultiField,findTextureAsset:(d,u)=>ou(d,u??""),getMaterialText:gr,createTexturePickerControlOptions:(d,u,l,m)=>Ws(d,u,l??"",m)}),getDocumentInspectorPropertyFactory:t,createDefaultGroundDecal:o.createDefaultGroundDecal,createObjectPatch:s=>({kind:"game-object.create-primitive",gameObject:s}),isGroundDecalObject:a,createHierarchyLabel:r.createHierarchyLabel}).contribution}function eR(e){let t=e;return{...e,createDefaultGroundDecal:r=>structuredClone(e.createDefaultGroundDecal(r)),isGroundDecalConfig(r){return e.isGroundDecalConfig(structuredClone(r))},...typeof t.isProjectEditableLayer=="function"?{isProjectEditableLayer:r=>t.isProjectEditableLayer(structuredClone(r))}:{},...typeof t.isLayoutEditableLayer=="function"?{isLayoutEditableLayer:r=>t.isLayoutEditableLayer(structuredClone(r))}:{},...typeof t.isRotationEditableLayer=="function"?{isRotationEditableLayer:r=>t.isRotationEditableLayer(structuredClone(r))}:{}}}function tR(e){let r=(e.features.find(i=>i.id===Rn)??null)?.config?.uiKinds,n=Array.isArray(r)?[...new Set(r.filter(i=>typeof i=="string"&&i.length>0))]:[],o=zy({...e.documentPolicy,canShowGroundDecalInspector:e.isGroundDecalObject,isGroundDecalUiGameObject:e.isGroundDecalObject}),a=rR({uiKinds:n,documentBridge:o,createInspectorServices:i=>e.createInspectorServices(i,o),getDocumentInspectorPropertyFactory:e.getDocumentInspectorPropertyFactory,createDefaultGroundDecal:e.createDefaultGroundDecal,createObjectPatch:e.createObjectPatch,canShowInspector:e.isGroundDecalObject,isGroundDecalObject:e.isGroundDecalObject,createHierarchyLabel:e.createHierarchyLabel});return{bridge:o,contribution:a,uiKinds:n,resolve(i){return i.id===Rn&&i.scene?.kind===Rn?a:null}}}function rR(e){let t=e.documentBridge;return{documentReducerImmutability:"preserves-input",transformTypeOptions:[{label:"Ground Decal",value:Rn}],normalizeInspectorValue:(n,o)=>n.startsWith("groundDecal.")?Tc(n,o):void 0,validateInspectorField({path:n,value:o}){if(n==="groundDecal.uiKind")return e.uiKinds.includes(String(o))?{ok:!0,value:o}:{ok:!1,message:"Invalid value for scene node field: groundDecal.uiKind."};if(n==="groundDecal.size.width"||n==="groundDecal.size.depth")return typeof o=="number"&&Number.isFinite(o)&&o>0?{ok:!0,value:o}:{ok:!1,message:`Invalid value for scene node field: ${n}.`};if(n==="groundDecal.layers"){let a=t.normalizeLayoutPatchValue(o);return a?{ok:!0,value:a}:{ok:!1,message:"Invalid value for scene node field: groundDecal.layers."}}return Vy(n,o)},isInspectorPatchPath:Ec,isProjectionPath:Xy,normalizeDocumentAfterCommand:t.normalizeScalesForCommand,normalizeAfterFieldPatch:t.normalizeScaleAfterFieldPatch,fieldMutation:{isCustomTransformType:n=>n==="groundDecal",applyCustomTransformType(n,o){o==="groundDecal"&&(n.groundDecal=t.mergeDefaults(n.groundDecal))},clearCustomTransformState(n,o){o!=="groundDecal"&&delete n.groundDecal},patchCustomTransformField(n,o,a){return o.startsWith("groundDecal.")?(n.kind="transform",n.transformType=n.transformType??"groundDecal",delete n.primitive,n.groundDecal=t.mergeDefaults(n.groundDecal),oR(n,o,a),!0):!1}},createInspectorPropertyPatch({gameObject:n,path:o,value:a,collectChangedIds:i}){if(!e.isGroundDecalObject(n))return null;let s=qu(o,a);return s===null?null:{label:`Patch ${n.id} transform.scale`,patch:{kind:"game-object.field",targetId:n.id,path:"transform.scale",value:{x:s,y:s,z:s}},changedId:n.id,changedIds:i()}},patchGameObjectField:({document:n,targetId:o,path:a,value:i})=>a==="groundDecal.uiKind"?t.patchKind(n,o,i):a==="groundDecal.layers"?t.patchLayout(n,o,i):t.patchInspectorField(n,o,a,i),patchGameObjectsField:({document:n,targetIds:o,path:a,value:i,patchSingle:s})=>a==="groundDecal.uiKind"||a==="groundDecal.layers"||Ec(a)?o.reduce((c,d)=>s(c,d,a,i),n):null,reducePatch:({document:n,patch:o})=>o.kind==="game-object.ground-decal-ui.replace"?t.replaceUi(n,String(o.targetId),o.groundDecal):null,createHierarchyPatch:(n,o)=>nR(n,o,e),createInspectorSections:n=>e.canShowInspector(n.gameObject)?[Qy(n.gameObject,n.nodeKind,n.context,e.createInspectorServices(n.createDocumentInspectorProperty))]:[],createMultiInspectorSection:({document:n,targetIds:o,activeId:a,context:i})=>eh(n,o,a,i,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),resolveMultiInspectorTargetIds:(n,o)=>th(n,o,e.createInspectorServices(e.getDocumentInspectorPropertyFactory())),isSerializedMultiFieldPath:Ua,isSerializedMultiProjectionPath:Ua,getSerializedMultiProbeValue:aR,canPatchSerializedMultiField:({document:n,targetId:o,path:a,value:i})=>!Ua(a)||t.canPatchMultiField(n,o,a,i)}}function nR(e,t,r){let n=t.startsWith("ground-decal:")?t.slice(13):"";if(!r.uiKinds.includes(n))return null;let o=it(e.scene.gameObjects.map(d=>d.id),`${n}_ground_decal_ui`),a=r.createHierarchyLabel?.(n)??`${n} Ground Decal UI`,i=new Set(e.scene.gameObjects.map(d=>d.name).filter(Boolean)),s=a;for(let d=2;i.has(s);d+=1)s=`${a} ${d}`;let c={id:o,guid:he(),name:s,kind:"transform",parentId:ye(e)??void 0,active:!0,transformType:"groundDecal",groundDecal:r.createDefaultGroundDecal(n),components:[{type:"Transform",position:{x:0,y:.02,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}]};return{label:`Add ${a}`,patch:r.createObjectPatch(c),createdId:o,changedIds:[o],reprojectIds:[o]}}function oR(e,t,r){let n=t.split("."),o=e;for(let a of n.slice(0,-1))o=o[a]??={};o[n[n.length-1]]=r}function aR(e){if(e.endsWith(".width")||e.endsWith(".depth"))return 1;if(e.endsWith(".rotationDeg"))return 45;if(e.endsWith("textureWidth")||e.endsWith("textureHeight"))return 512;if(e==="groundDecal.layers")return{layers:[{id:"mainLogo",rect:{x:0,z:0,width:1,depth:1}}]};if(uc(e))return"texture_probe";if(pc(e))return"30";if(mc(e)||Sc(e)||gc(e))return{r:1,g:1,b:1,a:1};if(fc(e)||yc(e)||bc(e))return 1;if(hc(e))return 75;if(lc(e))return To({x:0,z:0,width:1,depth:1});if($r(e))return Ka(512)}function Wa(e){let t=typeof e=="string"&&e.trim()?e.trim():void 0;if(!t)return;if(t.includes("\0"))throw new Error("external_asset_path_must_be_portable");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||/^[a-z][a-z0-9+.-]*:/i.test(r))throw new Error("external_asset_path_must_be_portable");let n=[];for(let o of r.split("/"))if(!(!o||o===".")){if(o==="..")throw new Error("external_asset_path_must_be_portable");n.push(o)}if(n.length===0)throw new Error("external_asset_path_must_be_portable");return n.join("/")}function se(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function xc(e,t=4,r="$"){if(!Number.isInteger(t)||t<0||t>100)throw new Error(`json.number.invalidDecimalPlaces: ${t}`);let n=[],o=a=>{if(typeof a=="number"){if(!Number.isFinite(a))throw new Error(`json.number.nonFinite: ${iR(r,n)}`);if(Object.is(a,-0))return 0;if(Number.isInteger(a))return a;let i=Number(a.toFixed(t));return Object.is(i,-0)?0:i}if(Array.isArray(a)){let i;for(let s=0;s<a.length;s+=1){let c=a[s];n.push(s);let d=o(c);n.pop(),!Object.is(d,c)&&(i??=a.slice(),i[s]=d)}return i??a}if(a&&typeof a=="object"){let i=a,s;for(let[c,d]of Object.entries(i)){n.push(c);let u=o(d);n.pop(),!Object.is(u,d)&&(s??={...i},s[c]=u)}return s??a}return a};return o(e)}function iR(e,t){return t.reduce((r,n)=>typeof n=="number"?`${r}[${n}]`:`${r}.${n}`,e)}var Zu=64*1024,sR=8,ih=256,cR=8*1024,dR=new Set(["assetPath","projectAssetId","platformAssetId","guid","assetName","displayName","assetType","mimeType","assetUrl","category","placeable","warmupCount","singleton","materialMode","defaultScale","scale","metadata","external"]);function sh(e){if(!qa(e))throw new Error("asset_import_payload_must_be_object");for(let a of Object.keys(e))if(!dR.has(a))throw new Error(`asset_import_field_not_allowed:${a}`);fR(e);let t=structuredClone(e),r=t.assetPath===void 0?void 0:uR(t.assetPath),n=Do(t.projectAssetId,"projectAssetId");if(!r&&!n)throw new Error("asset_import_asset_path_or_project_asset_id_required");if(t.assetType!==void 0&&t.assetType!=="model"&&t.assetType!=="texture")throw new Error("asset_import_asset_type_invalid");let o=["platformAssetId","guid","assetName","displayName","mimeType","assetUrl","category","materialMode"];for(let a of o){let i=Do(t[a],a);i&&(t[a]=i)}for(let a of["placeable","singleton"])if(t[a]!==void 0&&typeof t[a]!="boolean")throw new Error(`asset_import_${a}_must_be_boolean`);if(t.warmupCount!==void 0&&(!Number.isInteger(t.warmupCount)||t.warmupCount<0))throw new Error("asset_import_warmupCount_must_be_non_negative_integer");for(let a of["defaultScale","scale"])t[a]!==void 0&&(t[a]=mR(t[a],a));if(t.metadata!==void 0&&!qa(t.metadata))throw new Error("asset_import_metadata_must_be_object");if(t.external!==void 0){if(!qa(t.external))throw new Error("asset_import_external_must_be_object");let a=new Set(["platformAssetId","assetPath","assetUrl"]);for(let s of Object.keys(t.external))if(!a.has(s))throw new Error(`asset_import_external_field_not_allowed:${s}`);let i=t.external.assetPath===void 0?void 0:lR(t.external.assetPath,"external.assetPath");t.external={...Do(t.external.platformAssetId,"external.platformAssetId")?{platformAssetId:Do(t.external.platformAssetId,"external.platformAssetId")}:{},...i?{assetPath:i}:{},...Do(t.external.assetUrl,"external.assetUrl")?{assetUrl:Do(t.external.assetUrl,"external.assetUrl")}:{}}}return{...t,...r?{assetPath:r}:{},...n?{projectAssetId:n}:{}}}function lR(e,t){if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);try{let r=Wa(e);if(!r)throw new Error("empty");if(r.length>1024)throw new Error("too_long");return r}catch{throw new Error(`asset_import_${t}_must_be_project_relative`)}}function uR(e){if(typeof e!="string")throw new Error("asset_import_assetPath_must_be_string");let t=e.trim();if(!t||t.includes("\0")||t.length>4096)throw new Error("asset_import_assetPath_invalid");let r=t.replace(/\\/g,"/");if(r.startsWith("/")||/^[a-z]:\//i.test(r)||r.startsWith("//"))return r;try{return Wa(r)??""}catch{throw new Error("asset_import_assetPath_invalid")}}function Do(e,t){if(e===void 0)return;if(typeof e!="string")throw new Error(`asset_import_${t}_must_be_string`);let r=e.trim();if(!r)throw new Error(`asset_import_${t}_must_not_be_empty`);if(r.length>1024)throw new Error(`asset_import_${t}_too_long`);return r}function mR(e,t){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(qa(e)&&Object.keys(e).every(r=>r==="x"||r==="y"||r==="z")&&typeof e.x=="number"&&Number.isFinite(e.x)&&e.x>0&&typeof e.y=="number"&&Number.isFinite(e.y)&&e.y>0&&typeof e.z=="number"&&Number.isFinite(e.z)&&e.z>0)return{x:e.x,y:e.y,z:e.z};throw new Error(`asset_import_${t}_invalid`)}function fR(e){let t=0,r=(n,o)=>{if(o>sR)throw new Error("asset_import_payload_too_deep");if(n===null||typeof n=="boolean")return;if(typeof n=="number"){if(!Number.isFinite(n))throw new Error("asset_import_payload_number_invalid");return}if(typeof n=="string"){if(n.length>cR)throw new Error("asset_import_payload_string_too_long");return}if(Array.isArray(n)){if(t+=n.length,t>ih)throw new Error("asset_import_payload_too_many_values");for(let i of n)r(i,o+1);return}if(!qa(n)||Object.getPrototypeOf(n)!==Object.prototype)throw new Error("asset_import_payload_not_json_safe");let a=Object.entries(n);if(t+=a.length,t>ih)throw new Error("asset_import_payload_too_many_values");for(let[,i]of a){if(i===void 0||typeof i=="function"||typeof i=="symbol"||typeof i=="bigint")throw new Error("asset_import_payload_not_json_safe");r(i,o+1)}};if(r(e,0),new TextEncoder().encode(JSON.stringify(e)).byteLength>Zu)throw new Error("asset_import_payload_too_large")}function qa(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ja(){return{isCoreMaterialOverridePath:dl,isMaterialAssetIdOverridePath:og,addMaterialAsset:$s}}function ch(e,t=[]){return e.assets.filter(Xe).flatMap(r=>{let n=r.prefab?.sourceAssetId;if(typeof n!="string"||n.length===0)return[];let o=pR(r,t);return[{id:`prefab:${r.id}`,assetId:r.id,guid:r.guid,type:"prefab",kind:"prefab",label:r.displayName??r.id,displayName:r.displayName??r.id,category:r.category??"Prefab",origin:"project",placeable:o.placeable,...o.availability?{availability:structuredClone(o.availability)}:{},dedupeKey:`prefab:${r.guid??r.id}`,prefab:{id:r.id,guid:r.guid,displayName:r.displayName??r.id,category:r.category??"Prefab",...structuredClone(r.prefab),sourceAssetId:n},metadata:structuredClone(r.metadata??{})}]})}function pR(e,t){let r=e.prefab?.sourceAssetId,n=typeof r=="string"?t.find(a=>a.assetId===r||a.id===r):void 0,o=n?.availability;return{placeable:n?.placeable!==!1&&o?.status!=="unavailable",...o?{availability:o}:{}}}function Qu(e,t,r=Ja()){if(e==="displayName"&&typeof t=="string")return t.trim();if(e==="prefab.defaults.active")return t??null;if(tm(e))return t==null?null:e==="prefab.defaults.shadow"?t:e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"?t===!0?"enabled":t===!1?"none":t:t;if(r.isMaterialAssetIdOverridePath(e)&&typeof t=="string"){let n=t.trim();return n||null}return t}function em(e,t,r=Ja()){if(e==="displayName")return typeof t=="string"&&t.length>0;if(e==="prefab.defaults.active")return t==null||typeof t=="boolean";if(tm(e)){if(e==="prefab.defaults.shadow")return!!t&&typeof t=="object"&&typeof t.cast=="boolean"&&typeof t.receive=="boolean";let n=e.slice(16);return mo({path:n,nodeKind:"instance",value:t}).ok}return r.isCoreMaterialOverridePath(e)?r.isMaterialAssetIdOverridePath(e)&&(t==null||typeof t=="string"&&t.trim().length>0):!1}function tm(e){return e==="prefab.defaults.shadow"||e==="prefab.defaults.shadow.cast"||e==="prefab.defaults.shadow.receive"}function dh(e,t,r){let n=[...e.assets];r&&!n.some(a=>a.id===r.id)&&n.push(structuredClone(r));let o=Ac(t);return n.some(a=>a.id===t.id)||n.push(structuredClone(o)),n.length===e.assets.length?e:{...e,assets:n}}function rm(e,t,r,n,o=Ja()){if(r==="displayName")return e;let a=e.assets.find(s=>s.id===t&&Xe(s));if(!a)return e;let i=gR(uh(a),r,n,o);return JSON.stringify(i)===JSON.stringify(a)?e:{...e,assets:e.assets.map(s=>s.id===t?i:s)}}function lh(e,t,r,n){let o=e.assets.find(s=>s.id===t&&Xe(s));if(!o)return e;let a=n&&!e.assets.some(s=>s.id===n.id)?[...e.assets,structuredClone(n)]:e.assets,i=Ac({...structuredClone(r),id:t});return JSON.stringify(i)===JSON.stringify(o)&&a===e.assets?e:{...e,assets:a.map(s=>s.id===t?i:s)}}function gR(e,t,r,n=Ja()){if(t==="displayName")return e;if(t==="prefab.defaults.active"||tm(t)){let o=structuredClone(e),a=structuredClone(o.prefab??e.prefab);if(a.defaults={...a.defaults??{}},t==="prefab.defaults.active")r==null?delete a.defaults.active:a.defaults.active=r;else{if(t==="prefab.defaults.shadow"){if(!r||typeof r!="object")return e;let s=r.cast,c=r.receive;return typeof s!="boolean"||typeof c!="boolean"?e:(a.defaults.shadow={cast:s?"enabled":"none",receive:c?"enabled":"none"},o.prefab=a,Ac(o))}if(r!=="enabled"&&r!=="none")return e;let i=a.defaults.shadow;a.defaults.shadow={cast:t==="prefab.defaults.shadow.cast"?r:i?.cast==="enabled"?"enabled":"none",receive:t==="prefab.defaults.shadow.receive"?r:i?.receive==="enabled"?"enabled":"none"}}return Object.keys(a.defaults).length===0&&delete a.defaults,o.prefab=a,Ac(o)}return la(e,t,r)}function uh(e){if(!Xe(e))return e;let t=tg(e);return t.ok?t.prefabAsset:e}function Ac(e){if(!Xe(e))return e;let t=uh(e),r=Ye(t);if(!r||!Array.isArray(t.prefab?.nodes))return t;let n=t.prefab.nodes.findIndex(a=>a.id===r);if(n<0)return t;let o=structuredClone(t.prefab.nodes[n]);if(o.name=t.displayName??o.name,t.prefab.defaults){let{shadow:a,...i}=t.prefab.defaults;Object.keys(i).length>0?o.defaults=structuredClone(i):delete o.defaults}else delete o.defaults;return t.prefab.nodes=[...t.prefab.nodes],t.prefab.nodes[n]=o,t}function mh(e,t,r,n,o=Ja()){let a=o.addMaterialAsset(e,n);return rm(a,t,r,n.id,o)}function ph(e,t,r,n){let o=Le(e,t.assetId),a=t.sourceAssetId??o?.prefab?.sourceAssetId,i=a?e.assets.find(l=>l.id===a):null,s=bR(i,a),c=Dc(i),d=SR(c,!!n.importStructureReady),u=bh(n.importStructure)?Sh(n.importStructure):[];return Mc([s,...d?[d]:[],...u],r)}function bR(e,t){return{id:"prefab-source",label:e?.displayName??t??"Missing source asset",kind:"source",sourceAssetId:t,...e?.metadata?.relativePath?{meta:e.metadata.relativePath}:{}}}function SR(e,t){return e.length===0?null:{id:"prefab-material-slots",label:`${t?"Editable Material Slots":"Meshes / Materials"} (${e.length})`,kind:"group",children:[...e]}}function Dc(e){return(Array.isArray(e?.metadata?.materialSlots)?e.metadata.materialSlots:[]).map(hR).filter(r=>!!r).map((r,n)=>{let o=r.sourceSurfaces[0],a=hh(o.ownerNodePath),i=nt(r),s=i.map(m=>xn(r,m)).filter(m=>!!m);if(s.length===0&&r.materialNames?.length&&s.push(...r.materialNames.filter(m=>typeof m=="string"&&!!m.trim())),s.length===0&&r.materialName&&s.push(r.materialName),!r.slotId)return null;let c=`prefab.overrides.materialSlotBindings.${r.slotId}`,d=o.sourceMaterialIndex,u=r.label??s[0]??a.split("/").filter(Boolean).pop()??`Material Slot ${n+1}`;return{id:`prefab-material-slot:${om(r.slotId??a,`material_slot_${n+1}`)}:${n+1}`,itemType:"prefab-material-slot",label:u,kind:"material",bindingKind:"slot",bindingPath:c,materialAssetIdPath:`${c}.materialAssetId`,profilePathPrefix:`${c}.override`,slotId:r.slotId,sourceSurfaces:structuredClone(r.sourceSurfaces),ownerNodePath:a,...typeof o.nodeIndex=="number"?{nodeIndex:o.nodeIndex}:{},...o.nodeIndexPath?.length?{nodeIndexPath:o.nodeIndexPath}:{},...typeof o.meshIndex=="number"?{meshIndex:o.meshIndex}:{},...typeof o.primitiveIndex=="number"?{primitiveIndex:o.primitiveIndex}:{},...d==null?{}:{sourceMaterialIndex:d},...i.length>0?{sourceMaterialIndices:i}:{},...s[0]?{sourceMaterialName:s[0]}:{},...s.length>0?{sourceMaterialNames:s}:{},...r.sourceSurfaces.length===1&&typeof o.triangleCount=="number"?{triangleCount:o.triangleCount}:{},...r.sourceSurfaces.length===1&&o.boundingBox?{boundingBox:o.boundingBox}:{},meta:[a,r.sourceSurfaces.length===1?`primitive #${o.primitiveIndex}`:`${r.sourceSurfaces.length} source surfaces`,s.length>0?s.join(", "):null].filter(Boolean).join(" - ")}}).filter(r=>r!=null)}function gh(e){return e.map(t=>[t.label,typeof t.primitiveIndex=="number"?`primitive #${t.primitiveIndex}`:null,typeof t.sourceMaterialIndex=="number"?`material #${t.sourceMaterialIndex}`:null,typeof t.triangleCount=="number"?`${t.triangleCount} triangles`:null,yR(t.boundingBox)].filter(Boolean).join(" \xB7 ")).join(`
4
+ `)}function yR(e){if(!e)return null;let t=e.min?e.min.join(", "):"",r=e.max?e.max.join(", "):"";return t&&r?`bounds min ${t}; max ${r}`:t?`bounds min ${t}`:r?`bounds max ${r}`:null}function hR(e){return no(e)}function bh(e){return["nodes","materials","textures","animations"].some(t=>Xa(e,t).length>0)}function Sh(e){let t=[],r=Xa(e,"nodes");r.length>0&&t.push({id:"prefab-import-nodes",label:`Nodes (${r.length})`,kind:"group",children:ER(r)});let n=Xa(e,"materials");n.length>0&&t.push({id:"prefab-import-materials",label:`Materials (${n.length})`,kind:"group",children:n.map((i,s)=>nm(i,s,"material"))});let o=Xa(e,"textures");o.length>0&&t.push({id:"prefab-import-textures",label:`Textures (${o.length})`,kind:"group",children:o.map((i,s)=>nm(i,s,"texture"))});let a=Xa(e,"animations");return a.length>0&&t.push({id:"prefab-import-animations",label:`Animations (${a.length})`,kind:"group",children:a.map((i,s)=>nm(i,s,"animation"))}),t}function ER(e){let t=e.map((o,a)=>{let i=Re(o.id)??`runtime-node-${a+1}`,s=Re(o.kind),c={id:`prefab-import-node:${om(i,`node_${a+1}`)}`,runtimeId:i,label:Re(o.name)??Re(o.sourceName)??i,kind:s==="mesh"?"mesh":s==="root"?"root":"group",...Re(o.ownerNodePath)?{ownerNodePath:Re(o.ownerNodePath)}:{},...Re(o.sourceName)?{sourceName:Re(o.sourceName)}:{},...Array.isArray(o.materialIds)?{materialIds:o.materialIds.filter(d=>typeof d=="string")}:{},children:[]};return{runtimeId:i,parentId:Re(o.parentId),item:c}}),r=new Map(t.map(o=>[o.runtimeId,o.item])),n=[];for(let o of t)o.parentId&&r.has(o.parentId)?r.get(o.parentId).children.push(o.item):n.push(o.item);return n}function nm(e,t,r){let n=Re(e.id)??`${r}-${t+1}`,o=Re(e.url),a=Array.isArray(e.nodeIds)?e.nodeIds.filter(s=>typeof s=="string"):[],i=Array.isArray(e.textureIds)?e.textureIds.filter(s=>typeof s=="string"):[];return{id:`prefab-import-${r}:${om(n,`${r}_${t+1}`)}`,itemType:r==="material"?"runtime-material":r==="texture"?"runtime-texture":"runtime-animation",runtimeId:n,label:Re(e.name)??n,kind:r,...Re(e.kind)?{runtimeKind:Re(e.kind)}:{},...o?{url:o}:{},...a.length>0?{nodeIds:a}:{},...i.length>0?{textureIds:i}:{},meta:[Re(e.kind),o,a.length>0?`${a.length} node${a.length===1?"":"s"}`:null,i.length>0?`${i.length} texture${i.length===1?"":"s"}`:null].filter(Boolean).join(" - ")}}function yh(e,t,r,n){if(r.itemType==="prefab-material-slot"||r.itemType==="runtime-material"||r.itemType==="runtime-texture")return r;if(r.itemType!=="prefab-node"||r.kind!=="model")return null;let o=typeof r.sourceAssetId=="string"?r.sourceAssetId:t.sourceAssetId;if(!o)return null;let a=e.assets.find(c=>c.id===o),i=Dc(a);if(i.length>0){let c=i[0]??null;return c?{...c,...typeof r.nodeId=="string"?{prefabNodeId:r.nodeId}:{}}:null}return(bh(n.importStructure)?Sh(n.importStructure).find(c=>c.id==="prefab-import-materials"):null)?.children?.[0]??null}function Mc(e,t){for(let r of e){if(r.id===t)return r;let n=r.children?Mc(r.children,t):null;if(n)return n}return null}function hh(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join("/")}function om(e,t){return hh(e).toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function Xa(e,t){let n=fh(e)?.[t];return Array.isArray(n)?n.map(fh).filter(o=>!!o):[]}function fh(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Re(e){return typeof e=="string"&&e.trim()?e.trim():null}function Eh(e,t,r={}){let n=Le(e,t.assetId);if(!n?.prefab)return[{id:"prefab-scene",label:"Prefab Scene Tree",kind:"root",children:[]}];let o=Ye(n),a=sl(n,null);return[{id:"prefab-root",label:"Prefab Scene Tree",kind:"root",children:(o?a.filter(s=>s.id===o):a).map(s=>Ih(n,s))}]}function Ih(e,t){let r=sl(e,t.id).map(n=>Ih(e,n));return{id:`prefab-node:${t.id}`,nodeId:t.id,label:t.name??IR(t),kind:t.kind,itemType:"prefab-node",...t.guid?{guid:t.guid}:{},...t.sourceAssetId?{sourceAssetId:t.sourceAssetId}:{},...t.childPrefabId?{childPrefabId:t.childPrefabId}:{},...t.sourceNodePath?{sourceNodePath:t.sourceNodePath}:{},...t.transform?{transform:structuredClone(t.transform)}:{},...t.primitive?{primitive:structuredClone(t.primitive)}:{},...t.marker?{marker:structuredClone(t.marker)}:{},...t.defaults&&Object.keys(t.defaults).length>0?{defaults:structuredClone(t.defaults)}:{},...t.overrides&&Object.keys(t.overrides).length>0?{overrides:structuredClone(t.overrides)}:{},...r.length>0?{children:r}:{}}}function IR(e){return e.kind==="model"?e.sourceAssetId??e.id:e.kind==="prefabInstance"?e.childPrefabId??e.id:e.kind==="primitive"?e.primitive?.shape??e.id:e.id}function Ph(e,t,r){if(t.itemType!=="prefab-node"||t.kind!=="model")return null;let n=typeof t.sourceAssetId=="string"?t.sourceAssetId:null;if(!n)return null;let o=e.assets.find(S=>S.id===n),a=Dc(o),i=kc(o?.metadata?.assetAnalysis),s=am(i?.nodes),c=am(i?.meshes),d=wc(r.importStructure,"nodes").length,u=wc(r.importStructure,"materials").length,l=wc(r.importStructure,"textures").length,m=wc(r.importStructure,"animations").length,f=[kt("prefab.sourceStructure.sourceAsset","Source Asset",o?.displayName??n,0),kt("prefab.sourceStructure.assetId","Asset ID",n,1)];return o?.metadata?.relativePath&&f.push(kt("prefab.sourceStructure.relativePath","Relative Path",String(o.metadata.relativePath),2)),f.push(kt("prefab.sourceStructure.materialSlots","Material Slots",String(a.length),10),kt("prefab.sourceStructure.modelNodes","Model Nodes",s.length>0?PR(s):"No SDK node analysis",11),kt("prefab.sourceStructure.meshPrimitives","Mesh Primitives",c.length>0?TR(c):"No SDK mesh primitive analysis",12),kt("prefab.sourceStructure.runtimeNodes","Runtime Nodes",String(d),20),kt("prefab.sourceStructure.runtimeMaterials","Runtime Materials",String(u),21),kt("prefab.sourceStructure.runtimeTextures","Runtime Textures",String(l),22),kt("prefab.sourceStructure.runtimeAnimations","Runtime Animations",String(m),23)),a.length>0&&f.push(kt("prefab.sourceStructure.materialSlotSummary","Material Slot Summary",gh(a),30)),{id:"prefab-source-structure",title:"Source Structure",summary:o?"Readonly GLB / glTF anatomy":"Missing source asset",persistence:"readonly",effect:o?"active":"unsupported",properties:f}}function PR(e){return e.slice(0,8).map((t,r)=>{let n=Oc(t.ownerNodePath)??Oc(t.name)??`node #${typeof t.nodeIndex=="number"?t.nodeIndex:r}`,o=typeof t.meshIndex=="number"?`mesh #${t.meshIndex}`:null,a=typeof t.primitiveCount=="number"?`${t.primitiveCount} primitives`:null;return[n,o,a].filter(Boolean).join(" \xB7 ")}).join(`
5
+ `)}function TR(e){return e.slice(0,8).map((t,r)=>{let n=Oc(t.name)??`mesh #${typeof t.meshIndex=="number"?t.meshIndex:r}`,o=am(t.primitives);if(o.length===0)return n;let a=o.slice(0,6).map((i,s)=>[`p${typeof i.primitiveIndex=="number"?i.primitiveIndex:s}`,typeof i.sourceMaterialIndex=="number"?`mat #${i.sourceMaterialIndex}`:null,Oc(i.materialName),typeof i.triangleCount=="number"?`${i.triangleCount} tri`:null].filter(Boolean).join(" ")).join(", ");return`${n}: ${a}`}).join(`
6
+ `)}function wc(e,t){let n=kc(e)?.[t];return Array.isArray(n)?n.map(kc).filter(o=>!!o):[]}function kc(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function am(e){return Array.isArray(e)?e.map(kc).filter(t=>!!t):[]}function Oc(e){return typeof e=="string"&&e.trim()?e.trim():null}function kt(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function Th(e,t,r){let n=e.prefab?.defaults?.shadow;return[Ya({path:"prefab.defaults.shadow.cast",label:"Cast Shadow",valueType:"boolean",control:"boolean",value:n?.cast==="enabled",order:t+0,tooltip:"Controls shadow casting for the entire Prefab definition."},r),Ya({path:"prefab.defaults.shadow.receive",label:"Receive Shadow",valueType:"boolean",control:"boolean",value:n?.receive==="enabled",order:t+1,tooltip:"Controls shadow receiving for the entire Prefab definition."},r)]}function Ya(e,t){let r=n=>t.normalizePrefabAssetFieldValue(e.path,e.coerce?e.coerce(n):n);return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,...e.mixed===!0?{mixed:!0}:{},readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},...e.tooltip?{tooltip:e.tooltip}:{},validate:n=>t.validatePrefabAssetFieldValue(e.path,r(n))?{ok:!0,value:r(n)}:{ok:!1,message:`Invalid prefab field: ${e.path}.`},coerce:r}}function xR(e,t,r,n,o,a){return r.itemType==="prefab-material-slot"?AR(e,t,r,n,o,a()):r.itemType==="runtime-material"?xh("This runtime material has no stable slotId or ownerNodePath mapping.",r):r.itemType==="runtime-texture"?xh("Texture nodes are inspection-only. Edit texture channels from a stable material slot.",r):null}function AR(e,t,r,n,o,a){let i=gr("en"),s=ag(t,r),c=r.prefabNodeId?oo(t,r.prefabNodeId):null,d=r.prefabNodeId&&r.slotId?c?.overrides?.materialSlotBindings?.[r.slotId]:s,u=typeof d?.materialAssetId=="string"?d.materialAssetId:"",l=u||(typeof s?.materialAssetId=="string"?s.materialAssetId:""),m=e,f=ee(m,l||Tn);return{id:"prefab-material-override-target",title:"Material Slot",order:20,placement:"body",summary:f?.name??"Unassigned",persistence:"document",effect:"active",collapsedByDefault:!1,properties:[Mo("prefab.materialOverride.status","Status","Editable",0),Mo("prefab.materialOverride.bindingPath","Binding Path",r.bindingPath,1),Mo("prefab.materialOverride.materialAssetPath","Material Asset Path",r.materialAssetIdPath,2),Dn.createSelectorInspectorPropertyWithUsage(m,"instance",{path:r.materialAssetIdPath,label:"Material",value:u,order:10,text:i,currentAsset:f,currentAction:{actionId:"material.open-asset",params:{materialAssetId:f?.id,browserAssetId:f?`material:${f.id}`:void 0,sourceObjectId:t.id,ownerScope:"prefab",prefabAssetId:t.id,prefabNodeId:r.prefabNodeId,sourceBindingPath:r.materialAssetIdPath}},previewContext:n},a)]}}function DR(e,t,r,n,o){return xR(e,t,r,n,o,()=>_e.getCachedUsageIndex(e))}var MR={createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage:DR},Ah=MR;function xh(e,t){return{id:"prefab-material-override-target",title:"Prefab Material Override",order:20,placement:"body",summary:e,persistence:"readonly",effect:"unsupported",collapsedByDefault:!1,properties:[Mo("prefab.materialOverride.status","Status","Read Only",0),Mo("prefab.materialOverride.reason","Reason",e,1),Mo("prefab.materialOverride.runtimeId","Runtime ID",t.runtimeId??t.id,2)]}}function Mo(e,t,r,n,o){return j({path:e,label:t,value:r,order:n,persistence:"readonly",source:"Document",tooltip:o})}function wR(e,t,r,n,o,a){let i=Le(e,t.assetId);if(!i)return null;let s=t.sourceAssetId?e.assets.find(b=>b.id===t.sourceAssetId)??null:null,c=r?Mc(Eh(e,t,n),r)??ph(e,t,r,n):null,d=c?yh(e,t,c,n):null,u=d?a(e,i,d,n,o):null,l=c?Ph(e,c,n):null,m=typeof c?.nodeId=="string"?c.nodeId:null,f=m?oo(i,m):null,S=f&&f.kind!=="root"&&f.transform?.mode!=="matrix"?RR(i,f):null,g=f?.kind==="marker"&&f.marker?jR(i,f,o):null;return{targetIds:[i.id],activeId:i.id,label:n.importStructureReady?"Prefab Runtime Ready":t.label,document:e,selection:{targetIds:[i.id],activeId:i.id,scopeType:"prefab-stage",targetKind:"prefab",document:e},sections:[{id:"prefab-stage",title:"Prefab Stage",summary:n.importStructureReady?"Runtime Ready":"Preview",persistence:"document",properties:[Ya({path:"displayName",label:"Display Name",valueType:"string",control:"string",value:i.displayName??i.id,order:0},o),j({path:"prefab.sourceAssetId",label:"Source Asset",value:s?.displayName??t.sourceAssetId??"Missing",order:1}),Ya({path:"prefab.defaults.active",label:"Default Active",valueType:"boolean",control:"boolean",value:i.prefab?.defaults?.active??!0,order:2},o),...Th(i,3,o),j({path:"prefab.selectedItem",label:"Selected Item",value:r??"Preview Root",order:90})].filter(b=>!!b)},...S?[S]:[],...g?[g]:[],...l?[l]:[],...u?[u]:[]]}}function kR(e,t,r,n={},o){return wR(e,t,r,n,o,Ah.createEditorScenePrefabMaterialOverrideInspectorSectionWithCachedUsage)}var OR={createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage:kR},Mh=OR;function RR(e,t){let r=CR(t),n=t.parentId?oo(e,t.parentId):null,o=[],a=0;for(let i of["position","rotation","scale"])for(let s of["x","y","z"]){let c=r[i][s];o.push({path:`transform.${i}.${s}`,label:`${vR(i)}.${s}`,valueType:"number",control:"number",value:i==="rotation"?GR(c):c,readOnly:!1,persistence:"document",commitMode:"live",order:a,step:i==="rotation"?1:.1,validate:d=>typeof d=="number"&&Number.isFinite(d)?{ok:!0,value:d}:{ok:!1,message:"Transform value must be a finite number."},coerce:d=>typeof d=="number"?d:Number(d)}),a+=1}return{id:"transform",title:"Transform",summary:`Relative to: ${n?.name??n?.id??"Prefab"}`,order:20,placement:"body",persistence:"document",collapsedByDefault:!1,properties:o}}function CR(e){return e.transform?.type==="Transform"&&e.transform.mode!=="matrix"?{...e.transform,mode:e.transform.mode??"trs",scale:e.transform.scale??{x:1,y:1,z:1}}:{type:"Transform",mode:"trs",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function vR(e){return e==="position"?"Position":e==="rotation"?"Rotation":"Scale"}function GR(e){return Math.round(e*180/Math.PI*1e6)/1e6}function jR(e,t,r){let n=t.marker,o=n.target??null,a=o?Dh(o):"",i=[{label:"Unbound",value:""},...Ze(e).filter(c=>c.id!==t.id).map(c=>{let d=c.kind==="marker"?"marker":"scene-object";return{label:c.name??c.id,value:Dh({kind:d,id:c.id})}})];o&&a&&!i.some(c=>c.value===a)&&i.push({label:`Missing: ${o.id}`,value:a});let s=r.markerTypeCatalog.map(c=>({label:c.label||c.type,value:c.type}));return s.some(c=>c.value===n.type)||s.push({label:`Missing: ${n.type}`,value:n.type}),{id:"prefab-marker",title:"Marker",summary:r.markerTypeCatalog.find(c=>c.type===n.type)?.label??n.type,order:35,placement:"body",persistence:"document",collapsedByDefault:!1,properties:[Za({path:"prefab.marker.type",label:"Marker Type",valueType:"enum",control:"enum",value:n.type,options:s,order:0,validate:c=>typeof c=="string"&&r.markerTypeCatalog.some(d=>d.type===c)}),j({path:"prefab.marker.kind",label:"Semantic Kind",value:n.kind??"point",order:1,source:"Derived"}),j({path:"prefab.marker.geometry",label:"Geometry",value:n.geometry.kind,order:2,source:"Derived"}),Za({path:"prefab.marker.target",label:"Target",valueType:"enum",control:"enum",value:a,options:i,order:3,validate:c=>typeof c=="string"&&i.some(d=>d.value===c)}),j({path:"prefab.marker.targetStatus",label:"Target Status",value:o?i.some(c=>c.value===a&&!c.label.startsWith("Missing:"))?"Resolved":"Unresolved local reference":"Unbound",order:4,source:"Derived"}),Za({path:"prefab.marker.tags",label:"Tags",valueType:"string",control:"string",value:n.tags?.join(", ")??"",order:5,validate:c=>typeof c=="string"}),Za({path:"prefab.marker.note",label:"Note",valueType:"string",control:"string",value:n.note??"",order:6,validate:c=>typeof c=="string"}),Za({path:"prefab.marker.color",label:"Color",valueType:"color",control:"color",value:n.color??{r:.1,g:.85,b:1},order:7,validate:NR})].filter(c=>!!c)}}function Za(e){return{path:e.path,label:e.label,valueType:e.valueType,control:e.control,value:e.value,readOnly:!1,persistence:"document",commitMode:e.control==="string"?"blur":"immediate",order:e.order,...e.options?{options:e.options}:{},validate:t=>e.validate(t)?{ok:!0,value:t}:{ok:!1,message:`Invalid Prefab Marker field: ${e.path}.`}}}function Dh(e){return`${e.kind}:${encodeURIComponent(e.id)}`}function NR(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return["r","g","b"].every(r=>typeof t[r]=="number"&&Number.isFinite(t[r])&&t[r]>=0&&t[r]<=1)}function wh(e,t){let r=ln(e,t.id);if(!r.prefab)return null;let n=r.diagnostics.filter(m=>m.severity==="error").length,o=r.diagnostics.filter(m=>m.severity==="warning").length,a=r.diagnostics.filter(m=>m.severity==="info").length,i=r.diagnostics.length>0,s=n>0?"unsupported":i?"derived":"active",c=n>0?"Prefab relation is incomplete; fix the missing definition or source asset before using prefab actions.":void 0,d=r.definition?.displayName??r.definition?.id??r.prefab.prefabId,u=r.sourceAsset?.displayName??r.sourceAsset?.id??r.prefab.sourceAssetId??"Missing",l=[j({path:"prefab.relation.definition",label:"Prefab Definition",value:d,order:0,source:"Document",effect:s}),j({path:"prefab.relation.source",label:"Source Model",value:u,order:1,source:r.sourceAsset?"Asset":"Document",effect:s,disabledReason:c})].filter(m=>!!m);return i&&l.push(j({path:"prefab.relation.diagnostics",label:"Diagnostics",value:r.diagnostics.map(m=>`${m.severity}:${m.code} - ${m.message}`).join(`
7
+ `),order:2,source:"Derived",effect:s,disabledReason:c})),l.push(im({path:"prefab.actions.editDefinition",label:"Edit Prefab",actionId:"prefab.edit-definition",order:10,icon:"prefab",tooltip:"Open the prefab definition stage.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(im({path:"prefab.actions.selectDefinition",label:"Select Prefab",actionId:"prefab.select-definition",order:11,icon:"prefab",tooltip:"Select the prefab asset in the asset browser.",params:{assetId:r.definition?.id??r.prefab.prefabId,browserAssetId:r.definition?`prefab:${r.definition.id}`:void 0},disabled:!r.definition,disabledReason:c,effect:s})),l.push(im({path:"prefab.actions.pingSource",label:"Ping Source",actionId:"prefab.ping-source",order:12,icon:"asset",tooltip:"Select the prefab source asset in the asset browser.",params:{assetId:r.sourceAsset?.id??r.prefab.sourceAssetId},disabled:!r.sourceAsset,disabledReason:c,effect:s})),{id:"prefab-instance",title:"Prefab",order:48,placement:"body",summary:n>0?`${n} ${n===1?"error":"errors"}`:o>0?"Warning":a>0?"Info":"Ready",persistence:"readonly",effect:s,disabledReason:c,collapsedByDefault:!1,properties:l}}function im(e){let t=Object.fromEntries(Object.entries(e.params).filter(r=>typeof r[1]=="string"&&r[1].length>0));return{path:e.path,label:e.label,valueType:"string",control:"custom",customControl:"inspector-action-button",controlOptions:{actionId:e.actionId,label:e.label,icon:e.icon,params:t,...e.disabled?{disabled:!0}:{},...e.disabledReason?{disabledReason:e.disabledReason}:{}},value:e.actionId,readOnly:!1,persistence:"readonly",commitMode:"immediate",order:e.order,tooltip:e.disabledReason??e.tooltip,effect:e.effect,disabledReason:e.disabled?e.disabledReason:void 0}}function kh(e){return e==="cube"||e==="sphere"||e==="plane"||e==="capsule"?e:null}function de(e){return!!e?.marker}function cm(e){return e.kind==="point"&&e.coordinateSpace!=="world"||e.kind==="object-bounds"}function Cn(e){for(let t of e.components){if(t.type!=="Transform")continue;let r=t.scale;return $R(r)?fe(r):Ie(1,1,1)}return Ie(1,1,1)}function Lr(e,t){let r=ke(e,t);return r&&It(r)?r:null}function dm(e,t,r){let n=ur(e,t??void 0,r);return n&&It(n)?n:null}function Ch(e,t){let r=ke(e,t.id);return r?Gh(r,t.name??t.id):null}function vh(e,t){let r=mm(t);if(r?.kind!=="scene-object")return null;let n=e.scene.gameObjects.find(a=>a.id===r.id)??null,o=ke(e,r.id);return!n||!o?null:Gh(o,r.label||n.name||r.id)}function Gh(e,t){let r=Fe(e),n=Rc(Ie(r[0],r[1],r[2]));if(!n)return null;let o=Ie(r[4],r[5],r[6]),a=Rc(FR(o,sm(n,Oh(o,n))));if(!a)return null;let i=Rc(Rh(n,a));if(!i)return null;let s=Ie(r[8],r[9],r[10]);Oh(i,s)<0&&(i=sm(i,-1));let c=Rc(Rh(i,n));return c?{origin:Bi(e),right:n,up:c,forward:i,label:t}:null}function Oh(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function Rh(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function FR(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function sm(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}function Rc(e){let t=Math.hypot(e.x,e.y,e.z);return Number.isFinite(t)&&t>1e-6?sm(e,1/t):null}function Sr(e,t,r,n={}){let o=t.trim(),a=o?eo(zR(e),n).find(i=>i.type===o)?.kind:void 0;return Cc(a??r??(o?void 0:"point"))}function Cc(e){let t=e?.trim();return t?t==="object-bound"||t==="object-bounds"?"object":t:"point"}function jh(e,t){return lm(t)?"box":um(t)&&mm(e)?"object-bounds":"point"}function vc(e,t,r,n,o={}){let a=Lr(e,t.id),i=fe(a?.position??Ie(0,0,0)),s=fe(a?.rotation??Ie(0,0,0)),c=_R(e,t,r,o)?wo(r):fe(a?.scale??Cn(t));if(lm(r))return{kind:"box",coordinateSpace:"world",center:i,size:Nc(c),rotation:s};let d=mm(t.marker);return um(r)&&d?{kind:"object-bounds",target:d}:n?.kind==="point"?structuredClone(n):{kind:"point",coordinateSpace:"world",position:i,...d?{target:d}:{}}}function Nh(e,t,r,n,o){if(o)return um(n)||r.kind==="object-bounds"?{kind:"object-bounds",target:structuredClone(o)}:r.kind==="point"?{...structuredClone(r),target:structuredClone(o)}:structuredClone(r);if(r.kind==="object-bounds"){let a=Lr(e,t.id);return{kind:"point",coordinateSpace:"world",position:fe(a?.position??Ie(0,0,0))}}if(r.kind==="point"){let a=structuredClone(r);return delete a.target,a}return structuredClone(r)}function Fh(e,t){let r=e.scene.gameObjects.find(n=>n.id===t)??null;return!r||de(r)?null:{kind:"scene-object",id:r.id,label:r.name||r.id}}function _R(e,t,r,n={}){let o=Sr(e,t.marker.type,t.marker.kind,n);if(o===r)return!1;let a=Lr(e,t.id)?.scale??Cn(t);return $h(a,wo(o))}function _h(e,t,r,n={}){if(!de(t))return!1;let o=Sr(e,t.marker.type,t.marker.kind,n),a=Cc(r.kind);if(o===a&&t.marker.geometry.kind===r.geometry.kind)return!1;let i=Lr(e,t.id)?.scale??Cn(t);return $h(i,wo(o))}function wo(e){return lm(e)?Ie(4,1,4):Ie(.5,.5,.5)}function lm(e){return Cc(e)==="region"}function um(e){return Cc(e)==="object"}function mm(e){return e.target?structuredClone(e.target):e.geometry.kind==="point"&&e.geometry.target||e.geometry.kind==="object-bounds"?structuredClone(e.geometry.target):null}function $h(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.z-t.z)<1e-6}function Lh(e){switch(e.kind){case"box":return{kind:"box"};case"point":return{kind:"point",coordinateSpace:e.coordinateSpace,...e.coordinateSpace==="local"?{position:fe(e.position)}:{},...e.target?{target:structuredClone(e.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(e.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:e.coordinateSpace,vertices:e.vertices.map(fe),...e.faces?{faces:e.faces.map(t=>[...t])}:{}}}}function Gc(e){switch(e.kind){case"box":return fe(e.center);case"point":return e.coordinateSpace==="world"?fe(e.position):Ie(0,0,0);case"polyhedron":return LR(e.vertices);case"object-bounds":return Ie(0,0,0)}}function jc(e){return e.kind==="box"&&e.rotation?fe(e.rotation):Ie(0,0,0)}function fm(e,t){return e.kind==="box"?Nc(e.size):fe(t)}function Nc(e){return{x:Math.max(1e-6,Math.abs(e.x)),y:Math.max(1e-6,Math.abs(e.y)),z:Math.max(1e-6,Math.abs(e.z))}}function Fc(e){return e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}function fe(e){return{x:e.x,y:e.y,z:e.z}}function $R(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function Ie(e,t,r){return{x:e,y:t,z:r}}function zh(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function LR(e){if(e.length===0)return Ie(0,0,0);let t={x:Math.min(...e.map(n=>n.x)),y:Math.min(...e.map(n=>n.y)),z:Math.min(...e.map(n=>n.z))},r={x:Math.max(...e.map(n=>n.x)),y:Math.max(...e.map(n=>n.y)),z:Math.max(...e.map(n=>n.z))};return{x:(t.x+r.x)/2,y:(t.y+r.y)/2,z:(t.z+r.z)/2}}function zR(e){return e.scene.markerGraph??null}function _c(e,t={}){let r=qR(e,t);if(r!==e)return _c(r,t);let n=BR(e);if(n!==e)return _c(n,t);let o=$c(e);if(!o)return e;let a=cr(o),i=VR(e,a);return ra(o,i)?e:zd(e,i)}function BR(e){let t=$c(e),r=t?cr(t):null;if(!r||r.markers.length===0)return e;let n=new Set(e.scene.gameObjects.map(c=>c.id)),o=new Map,a=[];for(let c of r.markers){if(e.scene.gameObjects.some(u=>u.id===c.id&&de(u))){o.set(c.id,c.id);continue}let d=n.has(c.id)?QR(c.id,n):c.id;n.add(d),o.set(c.id,d),a.push({marker:c,gameObjectId:d})}let i=a.map(c=>Vh(e,hp(c.marker,o),c.gameObjectId,null)),s=cr({...r,markers:[],relations:r.relations.map(c=>yp(c,o))});return{...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,...i],markerGraph:s}}}function VR(e,t){let r=new Set(e.scene.gameObjects.map(i=>i.id)),n=t.markers.filter(i=>UR(i,r)),o=new Set([...n.map(i=>i.id),...e.scene.gameObjects.filter(de).map(i=>i.id)]),a=t.relations.filter(i=>Ld(i.from,r,o)&&Ld(i.to,r,o));return{...t,markers:n,relations:a}}function UR(e,t){if(!ta(e.target,t))return!1;switch(e.geometry.kind){case"object-bounds":return ta(e.geometry.target,t);case"point":return ta(e.geometry.target,t);case"box":case"polyhedron":return!0}}function Bh(e,t,r={}){switch(t.type){case"marker.create-box":return KR(e,t.marker,t.parentId??null);case"marker.update":return HR(e,t.markerId,t.patch,r);case"marker.delete":return WR(e,t.markerId);default:return null}}function KR(e,t,r){if(e.scene.gameObjects.some(i=>i.id===t.id))return null;let n=cr($c(e)),o=Vh(e,t,t.id,r),a={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects,o]}};return zd(a,{...n,markers:n.markers.filter(i=>i.id!==t.id)})}function HR(e,t,r,n={}){let o=e.scene.gameObjects.find(d=>d.id===t)??null;if(!de(o))return null;let a=zr(e,o,n),i=sr({...a,...r,id:a.id,geometry:r.geometry??a.geometry}),s=cr(void 0);if(ra({...s,markers:[a]},{...s,markers:[i]}))return e;let c=Uh(e,o,i,n);return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.map(d=>d.id===t?c:d)}}}function WR(e,t){let r=e.scene.gameObjects.find(a=>a.id===t)??null;if(!de(r))return null;let n=Ep(e,t),o=cr($c(e));return{...e,scene:{...e.scene,gameObjects:e.scene.gameObjects.filter(a=>!n.has(a.id)),markerGraph:{...o,markers:[],relations:o.relations.filter(a=>!$d(a.from,n)&&!$d(a.to,n))}}}}function qR(e,t={}){let r=!1,n=e.scene.gameObjects.map(o=>{if(!de(o))return o;let a=JR(e,o,t);return a!==o&&(r=!0),a});return r?{...e,scene:{...e.scene,gameObjects:n}}:e}function JR(e,t,r={}){return YR(e,t,r)}function Vh(e,t,r,n){let o=wo(t.kind),a={position:Gc(t.geometry),rotation:jc(t.geometry),scale:fm(t.geometry,o)},i=n?dm(e,n,a)??a:a;return{id:r,name:t.label||t.id,kind:"transform",...n?{parentId:n}:{},active:!0,marker:Hh(t),components:[{type:"Transform",...i}]}}function Uh(e,t,r,n={}){let o=Lr(e,t.id)?.scale??Cn(t),a=_h(e,t,r,n)?wo(r.kind):o;return{...t,name:r.label||t.name||r.id,kind:"transform",marker:Hh(r),components:XR(e,t,t.components,r.geometry,a)}}function XR(e,t,r,n,o){let a=o??Cn(t),i=Lr(e,t.id),s={position:cm(n)?fe(i?.position??Gc(n)):Gc(n),rotation:cm(n)?fe(i?.rotation??jc(n)):jc(n),scale:fm(n,a)},c=dm(e,t.parentId,s)??s,d=!1,u=r.map(l=>l.type!=="Transform"?l:(d=!0,{...l,position:c.position,rotation:c.rotation,scale:c.scale}));return d?u:[...u,{type:"Transform",position:c.position,rotation:c.rotation,scale:c.scale}]}function YR(e,t,r={}){if(t.marker.geometry.kind==="polyhedron")return t;let n=Sr(e,t.marker.type,t.marker.kind,r),o=jh(t.marker,n);if((t.marker.kind??"point")===n&&t.marker.geometry.kind===o)return t;let a=zr(e,t,r),i=sr({...a,kind:n,markerType:t.marker.type.trim(),geometry:vc(e,t,n,a.geometry,r)});return Uh(e,t,i,r)}function Kh(e,t={}){return e.scene.gameObjects.filter(de).map(r=>zr(e,r,t))}function zr(e,t,r={}){let n=t.marker,o=n.metadata?structuredClone(n.metadata):{},i=(n.geometry.kind==="object-bounds"?vh(e,n):null)??(n.semanticFrame?structuredClone(n.semanticFrame):Ch(e,t));return n.color&&(o.color={...n.color}),n.note!==void 0&&(o.note=n.note),{id:t.id,kind:Sr(e,n.type,n.kind,r),markerType:n.type,label:t.name??t.id,geometry:ZR(e,t),...n.target?{target:structuredClone(n.target)}:{},...i?{semanticFrame:i}:{},...n.tags?.length?{tags:[...n.tags]}:{},...Object.keys(o).length>0?{metadata:o}:{}}}function ZR(e,t){let r=t.marker,n=Lr(e,t.id),o=n?.position??Ie(0,0,0),a=n?.rotation??Ie(0,0,0),i=n?.scale??Cn(t);switch(r.geometry.kind){case"box":return{kind:"box",coordinateSpace:"world",center:fe(o),size:Nc(i),rotation:fe(a)};case"point":return(r.geometry.coordinateSpace??"world")==="world"?{kind:"point",coordinateSpace:"world",position:r.geometry.offset?zh(o,r.geometry.offset):fe(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}}:{kind:"point",coordinateSpace:"local",position:r.geometry.position?fe(r.geometry.position):fe(o),...r.geometry.target?{target:structuredClone(r.geometry.target)}:{}};case"object-bounds":return{kind:"object-bounds",target:structuredClone(r.geometry.target)};case"polyhedron":return{kind:"polyhedron",coordinateSpace:r.geometry.coordinateSpace??"world",vertices:r.geometry.vertices.map(fe),...r.geometry.faces?{faces:r.geometry.faces.map(s=>[...s])}:{}}}}function Hh(e){let t=e.metadata?structuredClone(e.metadata):{},r=eC(t.color),n=typeof t.note=="string",o=n?t.note:void 0;return r&&delete t.color,n&&delete t.note,{schemaVersion:1,type:e.markerType,...e.kind?{kind:e.kind}:{},...e.tags?.length?{tags:[...e.tags]}:{},...o!==void 0?{note:o}:{},...r?{color:r}:{},...e.target?{target:structuredClone(e.target)}:{},...e.semanticFrame?{semanticFrame:structuredClone(e.semanticFrame)}:{},geometry:Lh(e.geometry),...Object.keys(t).length>0?{metadata:t}:{}}}function QR(e,t){let r=Fc(e)||"marker",n=1,o=`${r}-marker`;for(;t.has(o);)n+=1,o=`${r}-marker-${n}`;return o}function eC(e){if(!e||typeof e!="object")return null;let t=e,r=pm(t.r),n=pm(t.g),o=pm(t.b);return r==null||n==null||o==null?null:{r,g:n,b:o}}function pm(e){return typeof e!="number"||!Number.isFinite(e)?null:e>=0&&e<=1?e:null}function $c(e){return e.scene.markerGraph??null}function qh(e){let t=n=>e.getMarkerTypeCatalogFromGraph(Wh(n)),r=n=>{let o=cr(Wh(n)),a=new Map;for(let i of o.markers)a.set(i.id,i);for(let i of Kh(n,e.options))a.set(i.id,i);return{...o,markers:[...a.values()]}};return{getMarkerGraph:r,getMarkerTypeCatalog:t,createMarkerGraphPatch(n,o){let a=Pp(n,o,{sanitizeMarkerGameObjectId:Fc});return Tp(n,a,r(n),{builtInMarkerTypes:e.options.builtInMarkerTypes,isMarkerGameObject:i=>de(i)})?{patch:e.createPatch(Bd(a)),label:xp(a),...Ap(a),...a.type==="marker.create-box"?{createdId:a.marker.id}:{},normalizedCommand:Bd(a)}:null},createMarkerTypeUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?t(n).find(m=>m.type===s)??null:null;if(s&&!c)return null;let d=Sr(n,s,i.marker.kind,e.options),u=zr(n,i,e.options),l=vc(n,i,d,u.geometry,e.options);return{type:"marker.update",markerId:o,patch:{markerType:s,kind:d,geometry:l}}},createMarkerTargetUpdateCommand(n,o,a){let i=n.scene.gameObjects.find(m=>m.id===o)??null;if(!de(i))return null;let s=a.trim(),c=s?Fh(n,s):null;if(s&&!c)return null;let d=zr(n,i,e.options),u=Sr(n,i.marker.type,i.marker.kind,e.options),l=Nh(n,i,d.geometry,u,c);return{type:"marker.update",markerId:o,patch:{target:c??void 0,geometry:l}}},resolveMarkerKind(n,o,a){return Sr(n,o,a,e.options)},reduceMarkerGraphPatch(n,o){let a=Bh(n,o,e.options);if(a)return a;let i=r(n),s=Ip(i,o,e.options);return ra(i,s)?n:{...n,scene:{...n.scene,markerGraph:s}}},syncMarkerGraphDocument(n){return _c(n,e.options)}}}function Wh(e){return e?.scene.markerGraph}function Jh(e,t=[]){return e.scene.gameObjects.flatMap(r=>{let n=r.prefab?.prefabId?Le(e,r.prefab.prefabId):null;return n?Yh(e,n,r,r.id,t):[]})}function Xh(e,t,r,n=[]){let o=Le(e,t);if(!o)return[];let a={id:r,name:o.displayName??o.id,kind:"group",components:[Lc()]};return Yh(e,o,a,r,n)}function Yh(e,t,r,n,o){let a=[],i=[];Zh(e,t,{instanceId:r.id,parentId:r.parentId,rootTransform:G(r)??Lc(),isHostRoot:!0,visitedPrefabIds:new Set,derivedObjects:a,markerDescriptors:i});let s=new Set([r.id,...a.map(d=>d.id)]);for(let d of a)d.marker&&(d.marker.target&&s.add(d.marker.target.id),d.marker.geometry.kind==="point"&&d.marker.geometry.target&&s.add(d.marker.geometry.target.id),d.marker.geometry.kind==="object-bounds"&&s.add(d.marker.geometry.target.id));let c={...e,scene:{...e.scene,gameObjects:[...e.scene.gameObjects.filter(d=>!s.has(d.id)),r,...a]}};return i.flatMap(d=>{let u=c.scene.gameObjects.find(l=>l.id===d.runtimeId);return u?.marker?[{ownerInstanceId:n,prefabAssetId:d.prefabAssetId,localNodeId:d.localNodeId,marker:zr(c,u,{builtInMarkerTypes:o})}]:[]})}function Zh(e,t,r){if(r.visitedPrefabIds.has(t.id))return;let n=Ze(t),o=Ye(t),a=o?n.find(d=>d.id===o):null;if(!a)return;let i=new Set(r.visitedPrefabIds).add(t.id),s={instanceId:r.instanceId,rootNodeId:a.id},c=d=>ao(s,d.id);for(let d of n){let u=c(d),l=d.id===a.id,m=d.parentId?n.find(g=>g.id===d.parentId):null,f=l?r.parentId:c(m??a);if(d.kind==="prefabInstance"&&d.childPrefabId){let g=Le(e,d.childPrefabId);g&&Zh(e,g,{instanceId:u,...f?{parentId:f}:{},rootTransform:l?r.rootTransform:d.transform??Lc(),isHostRoot:r.isHostRoot&&l,visitedPrefabIds:i,derivedObjects:r.derivedObjects,markerDescriptors:r.markerDescriptors});continue}if(r.isHostRoot&&l)continue;let S=d.kind==="marker"&&d.marker?ma({...structuredClone(d.marker),semanticFrame:void 0},s):void 0;r.derivedObjects.push({id:u,name:d.name??d.id,kind:d.kind==="marker"?"transform":"group",...f?{parentId:f}:{},...S?{marker:S}:{},components:[l?r.rootTransform:d.transform??Lc()]}),S&&r.markerDescriptors.push({prefabAssetId:t.id,localNodeId:d.id,runtimeId:u})}}function Lc(){return{type:"Transform",position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1}}}function tC(e){return e?e.list().filter(t=>De(t.shaderId)==null).map(t=>{let r=t.inspector.sections.length,n=t.inspector.fields.length;return{id:`shader:${t.shaderId}`,assetId:t.shaderId,label:t.displayName,kind:"shader",placeable:!1,meta:`${t.shaderId} \xB7 v${t.version} \xB7 ${n} fields`,shader:{shaderId:t.shaderId,displayName:t.displayName,version:t.version,runtimeKind:t.runtimeKind,sectionCount:r,fieldCount:n,...t.sourceFile?{sourceFile:t.sourceFile}:{}}}}):[]}function Qh(e){let t=my(e.objectCommandServices);return{getHierarchyItems:e.hierarchyFacade.getHierarchyItems,normalizeHierarchyDocument:e.hierarchyFacade.normalizeHierarchyDocument,createRenamePatch:e.hierarchyFacade.createRenamePatch,createCreateGroupPatch:e.hierarchyFacade.createCreateGroupPatch,createCreatePrimitivePatch:e.hierarchyFacade.createCreatePrimitivePatch,createDeleteSubtreePatch:e.hierarchyFacade.createDeleteSubtreePatch,collectSubtreeIdList:e.hierarchyFacade.collectSubtreeIdList,validateReparent:e.hierarchyFacade.validateReparent,createReparentPatch:e.hierarchyFacade.createReparentPatch,validateHierarchyMove:e.hierarchyFacade.validateHierarchyMove,createHierarchyMovePatch:e.hierarchyFacade.createHierarchyMovePatch,validateGroupSelection:e.hierarchyFacade.validateGroupSelection,createGroupSelectionPatch:e.hierarchyFacade.createGroupSelectionPatch,createDuplicateSelectionPatch:e.hierarchyFacade.createDuplicateSelectionPatch,createPlacedAssetPatch:e.hierarchyFacade.createPlacedAssetPatch,applySerializedPropertyPatch:t.applySerializedPropertyPatch,canCreateSerializedMultiPropertyPatch:t.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:t.createSerializedMultiPropertyPatch,createBrowserAssetItems(r,n={}){let o=_e.getCachedUsageIndex(r);return[..._e.createBrowserAssetItems(r,o,n),...tC(n.materialShaderDefinitions),...ch(r,n.assetLibraryItems)]},addAssetLibraryItemToDocument(r,n,o,a){let i=Ra(r,n,o,{...e.assetPlacementServices,...a});return{document:i.document,gameObject:i.gameObject}}}}function rC(e,t){if(!e.scene||typeof e.scene!="object"||Array.isArray(e.scene))return null;let r=e.scene;if(r.kind!==e.id)return null;let n=nE(r.contribution);return n?gm(n):t?ah(e,t):null}function tE(e){let t=(e.features??[]).flatMap(p=>{let D=e.resolveFeatureSceneContribution?.(p);if(D)return[gm(D)];let h=rC(p,()=>d);if(h)return[h];let R=nE(p.scene);return R?[gm(R)]:[]}),r=t.every(p=>p.documentReducerImmutability==="preserves-input")?"immutable-reference":"defensive-clone",n=kC(t),o=qh({options:{builtInMarkerTypes:e.markerTypes},createPatch:e.createPatch.markerGraph,getMarkerTypeCatalogFromGraph:p=>xC(e.markerTypes,p)}),a=(p,D)=>D?_(p,D):null,i=()=>[p=>n?.validateInspectorField?.({document:p.document??null,gameObject:p.document?a(p.document,p.targetId):null,path:p.path,value:p.value})??null,p=>TC(e.resolveFieldSchema?.(p.path,p.nodeKind)??null,p.path,p.value),Il({hasMaterialAsset:Vt,isMarkerGameObject:de,isDirectionalLightAnglePath:uo})],s=(p,D)=>n?.normalizeInspectorValue?.(p,D)??ys(p,D,{isDirectionalLightAnglePath:uo}),c=(p,D,h,R)=>{if(uo(h)&&D.light?.type!=="directional")return{ok:!1,message:`Unsupported scene node field: ${h}.`};let K=n?.validateInspectorField?.({document:p,gameObject:D,path:h,value:R});return K||mo({document:p,path:h,nodeKind:Qa(D),value:R,extraValidators:i()})},d=(p,D,h)=>ya({document:p,nodeKind:D,property:h,extraValidators:i()}),l={systemDefaults:SC(e.clearFeatureStateFromSystemObject),normalizeFieldValue:s,validateField:c,normalizePrimitiveShape:kh,findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isProtectedSystemGameObject:Dt,hasCamera:(p,D)=>p.scene.gameObjects.some(h=>h.id!==D&&At(h)),...n?.fieldMutation},m=hC(e,o,l,a,s,c,n),f=(p,D,h,R)=>rc(p,D,h,R,m),S=(p,D,h,R)=>ly(p,D,h,R,m),g=(p,D)=>gu(p,D,m.fieldMutationOptions),b=(p,D,h)=>hn(p,D,{transform:h}),y=(p,D)=>Ul(p,D),E=yC(e,o,l,f,S,n),I=EC(o),P={isRootTransformPath:Ms,validateSerializedPropertyField:p=>c(p.document,p.gameObject,p.path,p.value),findGameObject:a,isCameraGameObject:At,isLightGameObject:fo,isSerializedMultiFieldPath:p=>DC(p,n),isSerializedMultiProjectionPath:p=>MC(p,n),getSerializedMultiPropertyProbeValue:p=>wC(p,n),canPatchCustomSerializedMultiField:p=>n?.canPatchSerializedMultiField?.(p)??!0,createInspectorPropertyPatch:p=>Io(p,m),createFieldBatchPatch:e.createPatch.gameObjectFieldBatch},A=Qh({hierarchyFacade:I,objectCommandServices:P,assetPlacementServices:{createGameObjectGuid:he,resolveLocalTransform:({document:p,parentId:D,worldTransform:h})=>ur(p,D??void 0,h)}}),$={findGameObject:a,hasModelRenderer:p=>!!p.components?.some(D=>D.type==="ModelRenderer"),hasImageRenderer:p=>!!p.components?.some(D=>D.type==="ImageRenderer"),readNodeKind:Qa},z={};return Object.assign(z,{historyDocumentStorage:r,defaults:{camera:Xs,sunLight:Na,environmentLight:wn},reduceDocument:(p,D)=>Ru(p,D,E),ensureEnvironmentDefaults:p=>Ou(p,E),isSelectableHierarchyId:(p,D)=>Cl(p,D),resolveDiagnosticLocator:(p,D)=>{let h=D.locator;if(!h?.objectId||!h.materialSlotId)return h??null;let R=a(p,h.objectId);if(!R)return h;let K=lr(p,R).find(ne=>ne.slotId===h.materialSlotId);return K?{...h,rowId:R.id,regionId:Mp,sectionId:"artistMaterialSlots",path:`overrides.materialSlotBindings.${K.slotId}.materialAssetId`}:h},getHierarchyItems:A.getHierarchyItems,normalizeHierarchyDocument:A.normalizeHierarchyDocument,createRenamePatch:A.createRenamePatch,createCreateGroupPatch:A.createCreateGroupPatch,createCreatePrimitivePatch:A.createCreatePrimitivePatch,createDeleteSubtreePatch:A.createDeleteSubtreePatch,createReparentPatch:A.createReparentPatch,createHierarchyMovePatch:A.createHierarchyMovePatch,createGroupSelectionPatch:A.createGroupSelectionPatch,createDuplicateSelectionPatch:A.createDuplicateSelectionPatch,createPlacedAssetPatch:A.createPlacedAssetPatch,validateReparent:A.validateReparent,validateHierarchyMove:A.validateHierarchyMove,validateGroupSelection:A.validateGroupSelection,collectSubtreeIds:pr,createFeatureHierarchyPatch:(p,D)=>n?.createHierarchyPatch?.(p,D)??null,createInspectorPropertyPatch:p=>aC(m,p),createSceneMaterialBindingPatch:p=>oC(e,m,p),createPrefabMaterialBindingPatch:p=>iC(e,p),createMaterialPropertiesPatch:p=>bC(e,m,p),createMaterialAssetCreatePatch:p=>dC(e,p),createMaterialAssetRestorePatch:p=>lC(e,p),createMaterialAssetCreateFromSourceAndBindPatch:p=>uC(e,p),createMaterialAssetDuplicatePatch:p=>mC(e,p),createMaterialAssetDeletePatch:p=>fC(e,p),createMaterialAssetRenamePatch:p=>pC(e,p),createMaterialAssetSetShaderPatch:p=>gC(e,p),patchGameObjectField:f,patchGameObjectsField:S,patchGameObjectPropertiesMany:g,patchGameObjectTransform:b,patchGameObjectTransformsMany:y,createSerializedPropertyBatchPatch:p=>nC(e,m,p),canCreateSerializedMultiPropertyPatch:A.canCreateSerializedMultiPropertyPatch,createSerializedMultiPropertyPatch:A.createSerializedMultiPropertyPatch,createBrowserAssetItems:A.createBrowserAssetItems,addAssetLibraryItemToDocument:A.addAssetLibraryItemToDocument,getInspectorObject:(p,D,h={})=>IC(z,e,o,p,D,eE(e.materialShaderDefinitions,h),d,a,i,n),getInspectorMultiObject:(p,D,h,R={})=>PC(p,D,h,R,t,e.getRenderingProfile()),getPrefabStageInspectorObject:(p,D,h,R={})=>Mh.createEditorScenePrefabStageInspectorObjectWithCachedMaterialUsage(p,D,h,eE(e.materialShaderDefinitions,R),{createIdentityTransformComponent:NS,mergeLightDefaults:kn,sunLightId:"sun_light",normalizePrefabAssetFieldValue:Qu,validatePrefabAssetFieldValue:em,markerTypeCatalog:o.getMarkerTypeCatalog(p)}),getRuntimeInspectorSections:p=>$l({...p,sourceRef:Wt(p.document)},$),createRuntimeInspectorSnapshot:p=>fa({projectedRoot:p.projectedRoot,projectionNode:p.projectionNode??null}),createDocumentInspectorProperty:d,getMarkerGraph:o.getMarkerGraph,getMarkerTypeCatalog:o.getMarkerTypeCatalog,getPrefabInstanceMarkerOverlays:p=>Jh(p,o.getMarkerTypeCatalog(p)),getPrefabStageMarkerOverlays:(p,D,h)=>Xh(p,D,h,o.getMarkerTypeCatalog(p)),getRelationTypeCatalog:()=>e.relationTypes.map(p=>structuredClone(p)),createMarkerGraphPatch:o.createMarkerGraphPatch,reduceMarkerGraphPatch:o.reduceMarkerGraphPatch,syncMarkerGraphDocument:o.syncMarkerGraphDocument,resolveMarkerKind:o.resolveMarkerKind,assertMaterialAssetIntegrity:Bs}),z}function nC(e,t,r){if(r.changes.length<2)return null;let n=new Set,o=[],a=new Set;for(let s of r.changes){let c=`${s.targetId}\0${s.path}`;if(!s.targetId||!s.path||n.has(c))return null;n.add(c);let d=Io({document:r.document,targetId:s.targetId,path:s.path,value:s.value},t),u=d?.patch;if(!d||!u||u.kind!=="game-object.field"||u.targetId!==s.targetId||u.path!==s.path)return null;o.push({targetId:s.targetId,path:s.path,value:u.value});for(let l of d.reprojectIds??[])a.add(l)}let i=[...new Set(o.map(s=>s.targetId))];return{patch:e.createPatch.gameObjectFieldBatch(o),label:`Patch ${o.length} Inspector properties`,changedIds:i,...a.size>0?{reprojectIds:[...a]}:{}}}function oC(e,t,r){if(r.targets.length===0)return null;let n=new Set,o=[];for(let s of r.targets){let c=`${s.objectId}\0${s.path}`;if(n.has(c))return null;n.add(c);let u=Io({document:r.document,targetId:s.objectId,path:s.path,value:r.materialAssetId},t)?.patch;if(!u||u.kind!=="game-object.field"||u.targetId!==s.objectId||u.path!==s.path)return null;o.push({targetId:s.objectId,path:s.path,value:u.value})}let a=[...new Set(o.map(s=>s.targetId))],i=rE(r.document,r.targets,r.materialAssetId);return{patch:e.createPatch.gameObjectFieldBatch(o),label:`${r.materialAssetId?"Set":"Clear"} ${o.length} scene material binding${o.length===1?"":"s"}`,changedIds:a,reprojectIds:a,presentationImpact:i}}function aC(e,t){let r=Io(t,e);if(!r||!wr(t.path))return r;let n=r.createdId??(typeof t.value=="string"&&t.value.trim()?t.value.trim():null);return{...r,presentationImpact:rE(t.document,[{objectId:t.targetId,path:t.path}],n)}}function iC(e,t){if(t.targets.length===0||t.materialAssetId&&!Vt(t.document,t.materialAssetId)||new Set(t.targets.map(s=>s.prefabAssetId)).size!==1)return null;let n=t.targets[0].prefabAssetId,o=Le(t.document,n);if(!o?.prefab)return null;let a=structuredClone(o),i=new Set;for(let s of t.targets){let c=`${s.nodeId??""}\0${s.path}`;if(i.has(c))return null;i.add(c);let d=`prefab.${s.path}`,u=Qu(d,t.materialAssetId);if(!em(d,u))return null;if(!s.nodeId){a=la(a,d,u);continue}let l=a.prefab?.nodes?.findIndex(b=>b.id===s.nodeId)??-1;if(l<0||!a.prefab?.nodes)return null;let m=a.prefab.nodes[l],f={...a,prefab:{...a.prefab,overrides:structuredClone(m.overrides)}},S=la(f,d,u),g={...m,...S.prefab?.overrides?{overrides:structuredClone(S.prefab.overrides)}:{}};S.prefab?.overrides||delete g.overrides,a.prefab.nodes=[...a.prefab.nodes],a.prefab.nodes[l]=g}return{patch:e.createPatch.prefabAssetReplace?.(n,a)??{kind:"scene.prefab-asset.replace",assetId:n,prefabAsset:a},label:`${t.materialAssetId?"Set":"Clear"} ${t.targets.length} prefab material binding${t.targets.length===1?"":"s"}`,changedId:n,changedIds:[n],reprojectIds:[n],presentationImpact:sC(t.document,t.targets,t.materialAssetId)}}function rE(e,t,r){let n=new Set(t.map(a=>`${a.objectId}\0${a.path}`)),o=new Set;r&&o.add(r);for(let a of an(e))a.scope==="scene"&&n.has(`${a.gameObjectId}\0${a.bindingPath}`)&&o.add(a.materialAssetId);return{inspector:["material"],materials:{assetIds:[...o]}}}function sC(e,t,r){let n=new Set;r&&n.add(r);for(let o of t){let a=cC(e,o);a&&n.add(a)}return{inspector:["material"],materials:{assetIds:[...n]}}}function cC(e,t){let r=Le(e,t.prefabAssetId)?.prefab,n=t.nodeId?r?.nodes?.find(a=>a.id===t.nodeId)?.overrides:r?.overrides;if(!n)return null;let o=t.path==="overrides.materialBinding.materialAssetId"?n.materialBinding?.materialAssetId:n.materialSlotBindings?.[Lt(t.path,"materialAssetId")??""]?.materialAssetId;return typeof o=="string"&&o.trim()?o.trim():null}function dC(e,t){let r=Kb(t.document,t.definition,t.name);return{patch:e.createPatch.materialAssetCreate?.(r)??{kind:"scene.material-asset.create",materialAsset:r},label:`Create material ${r.name}`,changedIds:[],createdId:r.id}}function lC(e,t){return ee(t.document,t.materialAsset.id)?null:{patch:e.createPatch.materialAssetCreate?.(t.materialAsset)??{kind:"scene.material-asset.create",materialAsset:t.materialAsset},label:`Restore material ${t.materialAsset.name}`,changedIds:[],createdId:t.materialAsset.id}}function uC(e,t){let r=Jb({document:t.document,gameObject:t.gameObject,bindingPath:t.bindingPath,profile:t.profile,sourceAsset:t.sourceAsset,sourceSlotId:t.sourceSlotId,sourceMaterialIndex:t.sourceMaterialIndex,sourceMaterialName:t.sourceMaterialName});return r?{...r,patch:e.createPatch.materialAssetCreateAndBind?.({targetId:r.patch.targetId,bindingPath:r.patch.bindingPath,materialAsset:r.patch.materialAsset})??r.patch,label:`Create material ${r.patch.materialAsset.name} from GLB source`,presentationImpact:{inspector:["material"],materials:{assetIds:[r.createdId]}}}:null}function mC(e,t){let r=ee(t.document,t.materialAssetId);if(!r)return null;let n=Hb(t.document,r);return{patch:e.createPatch.materialAssetCreate?.(n)??{kind:"scene.material-asset.create",materialAsset:n},label:`Duplicate material ${r.name??r.id}`,changedIds:[],createdId:n.id,presentationImpact:{inspector:["material"],materials:{assetIds:[n.id]}}}}function fC(e,t){let r=Yb(t.document,t.materialAssetId);return r.ok?{patch:e.createPatch.materialAssetDelete?.(t.materialAssetId)??{kind:"scene.material-asset.delete",materialAssetId:t.materialAssetId},label:`Delete material ${r.materialAsset.name??r.materialAsset.id}`,changedIds:[],presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}:null}function pC(e,t){let r=ee(t.document,t.materialAssetId),n=rt("name",t.name);return!r||tu(r)||typeof n!="string"||!zt("name",n)?null:{patch:e.createPatch.materialAssetField(t.materialAssetId,"name",n),label:`Rename material ${r.name} to ${n}`,changedIds:sa(t.document,t.materialAssetId),presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}}}}function gC(e,t){let r=ee(t.document,t.materialAssetId);if(!r||tu(r))return null;let n=oS(r,t.definition),o=sa(t.document,t.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(t.materialAssetId,n.materialAsset)??{kind:"scene.material-asset.replace",materialAssetId:t.materialAssetId,materialAsset:n.materialAsset},label:`Set material ${r.name} shader to ${t.definition.displayName}`,changedIds:o,reprojectIds:o,presentationImpact:{inspector:["material"],materials:{assetIds:[t.materialAssetId]}},preservedPaths:n.preservedPaths,resetPaths:n.resetPaths}}function bC(e,t,r){if(r.changes.length===0)return null;let n=ee(r.document,r.materialAssetId);if(!n)return null;let o=new Set,a=r.document;for(let c of r.changes){if(!c.path.startsWith("properties.")||o.has(c.path))return null;if(o.add(c.path),c.inheritTexture){if(!ro(n.shaderId,c.path))return null;a=_s(a,r.materialAssetId,c.path,null,e.materialShaderDefinitions,{textureMode:"inherit"});continue}let d=`scene.materialAssets.${r.materialAssetId}.${c.path}`,l=Io({document:a,targetId:r.materialAssetId,path:d,value:c.value},t)?.patch;if(!l||l.kind!=="scene.material-asset.field"||l.materialAssetId!==r.materialAssetId||l.path!==c.path)return null;a=_s(a,r.materialAssetId,c.path,l.value,e.materialShaderDefinitions)}let i=ee(a,r.materialAssetId);if(!i)return null;let s=sa(r.document,r.materialAssetId);return{patch:e.createPatch.materialAssetReplace?.(r.materialAssetId,i)??{kind:"scene.material-asset.replace",materialAssetId:r.materialAssetId,materialAsset:i},label:`Patch material ${r.materialAssetId} properties`,changedIds:s,reprojectIds:s}}function SC(e){let t=r=>n=>{let o=r(n);if(!e)return o;let a=structuredClone(o),i=structuredClone(n),s=e(a,i)??a;return JSON.stringify(s)===JSON.stringify(n)?n:s};return{environmentLightId:"environment_light",sunLightId:"sun_light",horizontalLightAnglePath:"light.directionHorizontalAngleDeg",elevationLightAnglePath:"light.directionElevationAngleDeg",normalizeEnvironmentLightGameObject:r=>t(n=>Su(n,"hemispheric"))(r),normalizeSunLightGameObject:r=>t(n=>Su(n,"directional"))(r),normalizeCameraGameObject:t(FS),normalizePlainTransformGameObject:t(_S),createDefaultCameraGameObject:VS,createDefaultEnvironmentLightGameObject:KS,createDefaultSunLightGameObject:US,mergeCameraDefaults:Fa,normalizeCameraAfterFieldPatch:$S,hasInvalidCameraRelationships:zS,mergeLightDefaults:kn}}function yC(e,t,r,n,o,a){return{...r,normalizeRootTransformDocument:Ea,syncMarkerGraphDocument:t.syncMarkerGraphDocument,ensureGameObjectGuids:kl,normalizeDocumentAfterCommand:(i,s)=>a?.normalizeDocumentAfterCommand?.(i,s)??i,patchMaterialAssetField:(i,s,c,d)=>_s(i,s,c,d,e.materialShaderDefinitions),replaceMaterialAsset:(i,s,c)=>Wb(i,s,c),addMaterialAsset:(i,s)=>$s(i,s),deleteMaterialAsset:(i,s)=>Zb(i,s),addMaterialAssetAndBind:(i,s,c,d)=>Qb(i,s,c,d),addPrefabAsset:(i,s,c)=>dh(i,s,c),patchPrefabAssetField:(i,s,c,d)=>rm(i,s,c,d),replacePrefabAsset:(i,s,c,d)=>lh(i,s,c,d),addMaterialAssetAndBindPrefabOverride:(i,s,c,d)=>mh(i,s,c,d),patchGameObjectField:n,patchGameObjectsField:o,reduceExtensionPatch:({document:i,patch:s,command:c})=>s.kind==="game-object.property-field-batch"&&Array.isArray(s.fields)?s.fields.reduce((d,u)=>o(d,[u.targetId],u.path,u.value),i):a?.reducePatch?.({document:i,patch:s,command:c})??null,isCustomFieldPatchPath:a?.isInspectorPatchPath,reduceMarkerGraphPatch:(i,s)=>t.reduceMarkerGraphPatch(i,s),isDirectionalLightAnglePath:uo,validateSerializedPropertyField:i=>r.validateField(i.document,i.gameObject,i.path,i.value),createGameObjectGuid:he,createUniqueId:it,resolveLocalTransform:({document:i,parentId:s,worldTransform:c})=>ur(i,s??void 0,c),resolveRootContainerId:ye,ensureDefaultMaterialAssets:Vb,normalizeMaterialBindings:nS}}function hC(e,t,r,n,o,a,i){return{fieldMutationOptions:ec(r),findGameObject:n,normalizeValue:o,validateValue:a,blockFieldPatch:(s,c,d,u)=>tc(s,c,d,u,r),isRootTransformPath:Ms,parseDuplicateMaterialAssetValue:Qi,isMaterialBindingPath:wr,isMaterialBindingPathAllowed:(s,c)=>wr(c)&&(!!e.resolveFieldSchema?.(c,Qa(s))||c.startsWith("overrides.materialSlotBindings.")),findMaterialAssetName:(s,c)=>ee(s,c)?.name??null,parseMaterialAssetFieldPath:Np,normalizeMaterialAssetValue:rt,hasMaterialAsset:Vt,validateMaterialAssetFieldValue:(s,c,d,u)=>{let l=ee(s,c);return zt(d,u,l?.shaderId,e.materialShaderDefinitions)},collectMaterialAssetBindingIds:sa,isMarkerGameObject:de,createMarkerTargetUpdateCommand:t.createMarkerTargetUpdateCommand,createMarkerTypeUpdateCommand:t.createMarkerTypeUpdateCommand,createMarkerGraphPatch:e.createPatch.markerGraph,isDirectionalLightAnglePath:uo,createDirectionalLightPatch:e.createPatch.gameObjectField,patchDirectionalLightAngleField:(s,c,d,u)=>Cu(s,c,d,u,r),createCustomInspectorPropertyPatch:({document:s,gameObject:c,path:d,value:u})=>i?.createInspectorPropertyPatch?.({document:s,gameObject:c,path:d,value:u,collectChangedIds:()=>pr(s,[c.id])})??null,patchCustomGameObjectField:i?.patchGameObjectField,patchCustomGameObjectsField:i?.patchGameObjectsField,normalizeAfterFieldPatch:(s,c,d,u)=>i?.normalizeAfterFieldPatch?.(s,c,d,u)??s,isProjectionShapePath:AC,isArtistMaterialPatchPath:Zi,isCustomProjectionPath:i?.isProjectionPath,collectChangedIdsForFieldPath:(s,c,d)=>d.startsWith("transform.")?pr(s,[c]):[c],createGameObjectFieldPatch:e.createPatch.gameObjectField,createMaterialAssetFieldPatch:e.createPatch.materialAssetField}}function EC(e){return ku({findGameObject:(t,r)=>r?_(t,r):null,resolveRootContainerId:ye,isProtectedSystemGameObject:Dt,isProtectedSystemGameObjectId:Dl,decorateHierarchyItem:({item:t,gameObject:r})=>r&&de(r)?{...t,role:"marker",icon:"view-overlay",canHaveChildren:!1}:t})}function eE(e,t){return{materialShaderDefinitions:e,...t}}function IC(e,t,r,n,o,a,i,s,c,d){let u=kS(n,o,a);if(u)return u;let l=iu.createEditorSceneMaterialAssetInspectorObjectWithCachedUsage(n,o,a);return l||Lu({document:n,targetId:o,context:a,findGameObject:s,readNodeKind:Qa,isMarkerGameObject:de,createInspectorSections:(m,f,S)=>{let g=Qa(f);return Bu({document:m,gameObject:f,context:S,nodeKind:g,isCameraGameObject:At,isLightGameObject:fo,isMarkerGameObject:de,createBaseSections:()=>Nl({document:m,gameObject:f,nodeKind:g,extraValidators:c(),rootTransform:jr,renderingProfile:t.getRenderingProfile(),transformTypeOptions:oE(d?.transformTypeOptions)}),createCustomSections:()=>d?.createInspectorSections?.({document:m,gameObject:f,nodeKind:g,context:S,createDocumentInspectorProperty:i})??[],createCameraSection:()=>Tl({nodeKind:g,camera:f.camera,rig:Fa(f.camera),createDocumentInspectorProperty:i}),createLightSections:()=>Bl({nodeKind:g,gameObject:f,light:kn(f.light,f.id==="environment_light"?"hemispheric":"directional"),createDocumentInspectorProperty:i,normalizeValue:(b,y)=>d?.normalizeInspectorValue?.(b,y)??ys(b,y),defaultEnvironmentGroundColor:wn.groundColor,renderingProfile:t.getRenderingProfile()}),createMarkerSection:()=>de(f)?Wu({document:m,gameObject:f,nodeKind:g,markerTypeCatalog:r.getMarkerTypeCatalog(m),resolveMarkerKind:(b,y)=>r.resolveMarkerKind(m,y.type,y.kind),isMarkerGameObject:de,formatMarkerTypeLabel:t.formatMarkerTypeLabel??((b,y)=>y),createDocumentInspectorProperty:i}):null,createPrefabInstanceSection:()=>wh(m,f),createMaterialSections:()=>iu.createArtistMaterialInspectorSectionsWithCachedUsage(m,f,g,S,{createDocumentInspectorProperty:i}),createOutlineSection:()=>Vu({nodeKind:g,outline:f.overrides?.outline,createDocumentInspectorProperty:i})})}})}function PC(e,t,r,n,o,a){let i=null,s=[];for(let c of o){let d=c.createMultiInspectorSection?.({document:e,targetIds:t,activeId:r,context:n})??null;if(d){i=d,s=c.resolveMultiInspectorTargetIds?.(e,t)??[];break}}return zu({document:e,selectedIds:t,activeId:r,renderingProfile:a,extraSection:i,resolveFallbackTargetIds:()=>s,formatFallbackLabel:c=>`${c.length} Objects`,fallbackSelectionKind:"transform"})}function TC(e,t,r){return e?r==null&&e.allowDelete===!1?{ok:!1,message:`Scene node field cannot be deleted: ${t}.`}:e.validate(r)?{ok:!0,value:r}:{ok:!1,message:`Invalid value for scene node field: ${t}.`}:null}function xC(e,t){return eo(t,{builtInMarkerTypes:e})}var Qa=Y;function AC(e){return e.startsWith("shadow.")||e==="transformType"||e.startsWith("rendering.")||e.startsWith("primitive.")||e.startsWith("camera.")||e.startsWith("light.")}function DC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiFieldPath?.(e)===!0}function MC(e,t){return e==="shadow.cast"||e==="shadow.receive"||t?.isSerializedMultiProjectionPath?.(e)===!0}function wC(e,t){return e==="enabled"||e==="shadow.cast"||e==="shadow.receive"?!1:t?.getSerializedMultiProbeValue?.(e)}function nE(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return["documentReducerImmutability","transformTypeOptions","normalizeInspectorValue","validateInspectorField","isInspectorPatchPath","isProjectionPath","normalizeDocumentAfterCommand","normalizeAfterFieldPatch","fieldMutation","createInspectorPropertyPatch","patchGameObjectField","patchGameObjectsField","reducePatch","createHierarchyPatch","createInspectorSections","createMultiInspectorSection","resolveMultiInspectorTargetIds","isSerializedMultiFieldPath","isSerializedMultiProjectionPath","getSerializedMultiProbeValue","canPatchSerializedMultiField"].some(n=>t[n]!=null)?t:null}function gm(e){let{documentReducerImmutability:t,...r}=e;return r}function kC(e){if(e.length===0)return;let t=r=>{for(let n of e){let o=r(n);if(o!=null)return o}return null};return{documentReducerImmutability:e.every(r=>r.documentReducerImmutability==="preserves-input")?"preserves-input":void 0,transformTypeOptions:oE(e.flatMap(r=>r.transformTypeOptions??[])).slice(Pa.length),normalizeInspectorValue(r,n){for(let o of e){let a=o.normalizeInspectorValue?.(r,n);if(a!==void 0)return a}},validateInspectorField:r=>t(n=>n.validateInspectorField?.(r)),isInspectorPatchPath:r=>e.some(n=>n.isInspectorPatchPath?.(r)),isProjectionPath:r=>e.some(n=>n.isProjectionPath?.(r)),normalizeDocumentAfterCommand:(r,n)=>e.reduce((o,a)=>a.normalizeDocumentAfterCommand?.(o,n)??o,r),normalizeAfterFieldPatch:(r,n,o,a)=>e.reduce((i,s)=>s.normalizeAfterFieldPatch?.(i,n,o,a)??i,r),fieldMutation:OC(e),createInspectorPropertyPatch:r=>t(n=>n.createInspectorPropertyPatch?.(r)),patchGameObjectField:r=>t(n=>n.patchGameObjectField?.(r)),patchGameObjectsField:r=>t(n=>n.patchGameObjectsField?.(r)),reducePatch:r=>t(n=>n.reducePatch?.(r)),createHierarchyPatch:(r,n)=>t(o=>o.createHierarchyPatch?.(r,n)),createInspectorSections:r=>e.flatMap(n=>n.createInspectorSections?.(r)??[]),isSerializedMultiFieldPath:r=>e.some(n=>n.isSerializedMultiFieldPath?.(r)),isSerializedMultiProjectionPath:r=>e.some(n=>n.isSerializedMultiProjectionPath?.(r)),getSerializedMultiProbeValue(r){for(let n of e){let o=n.getSerializedMultiProbeValue?.(r);if(o!==void 0)return o}},canPatchSerializedMultiField:r=>e.every(n=>n.canPatchSerializedMultiField?.(r)!==!1)}}function oE(e=[]){let t=[],r=new Set;for(let n of[...Pa,...e])r.has(n.value)||(r.add(n.value),t.push(n));return t}function OC(e){let t=e.flatMap(r=>r.fieldMutation?[r.fieldMutation]:[]);if(t.length!==0)return{isCustomTransformType:r=>t.some(n=>n.isCustomTransformType?.(r)),applyCustomTransformType(r,n){for(let o of t)o.clearCustomTransformState?.(r,n);for(let o of t)o.applyCustomTransformType?.(r,n)},clearCustomTransformState(r,n){for(let o of t)o.clearCustomTransformState?.(r,n)},patchCustomTransformField(r,n,o){for(let a of t)if(a.patchCustomTransformField?.(r,n,o))return!0;return!1}}}var bm=["model","texture","image","sound"],zc=[".glb",".gltf"],Sm=[".png",".jpg",".jpeg",".webp"],aE=[".env",".hdr",".dds",".ktx",".ktx2"],Bc=[...Sm,...aE],Vc=[".mp3",".wav",".ogg",".flac",".aac",".m4a"],ko=[...zc,...Bc,...Vc];function iE(e){return String(e??"").trim().toLowerCase().replace(/-/g,"")}function Uc(e,t){let r=iE(t);return`${e==="model"?"asset":e==="texture"?"texture":e==="sound"?"sound":"image"}_${r}`}function Kc(e){let o=String(e??"").trim().split(/[^a-zA-Z0-9_$]+/).filter(Boolean).map((a,i)=>i===0?a:`${a.charAt(0).toUpperCase()}${a.slice(1)}`).join("").replace(/[^a-zA-Z0-9_$]/g,"")||"assetUrl";return/^[a-zA-Z_$]/.test(o)?o:`asset${o}`}function Hc(e,t=""){let r=String(e??"").trim().toLowerCase();if(r==="glb"||r==="gltf"||r==="model")return"model";if(r==="groundtexture"||r==="ground-texture"||r==="texture")return"texture";if(r==="ui"||r==="image"||r==="img")return"image";if(r==="audio"||r==="sound")return"sound";let n=sE(t);return zc.includes(n)?"model":Vc.includes(n)?"sound":Bc.includes(n)?"texture":null}function sE(e){let t=e.split(/[?#]/,1)[0]??"",r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),n=t.slice(r+1),o=n.lastIndexOf(".");return o>=0?n.slice(o).toLowerCase():""}function ym(e){let t=String(e??"").trim(),r=t.toLowerCase();for(let n of[...ko].sort((o,a)=>a.length-o.length))if(r.endsWith(n)){t=t.slice(0,-n.length);break}return t}function hm(e,t){return String(e??"").trim()||ym(t)||"Asset"}function Em(e,t){return ym(e||t).trim().toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_{2,}/g,"_")||null}function Im(e){return e==="model"?zc:e==="sound"?Vc:e==="texture"?Bc:e==="image"?Sm:[]}function Tm(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(!e||typeof e!="object")return;let t=e,r=Pm(t.x),n=Pm(t.y),o=Pm(t.z);if(!(r==null||n==null||o==null||r<=0||n<=0||o<=0))return{x:r,y:n,z:o}}function Pm(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function xm(e){return e==="shared"||e==="instance"?e:void 0}function Am(e){return Number.isInteger(e)&&e>=0?e:void 0}var cE="rendering",vn=Bf;function Br(e){let t=se(e);return RC(t?.companionConfigs)}function Mm(e){return Br(e)[cE]??null}function dE(e){return Ar(Br(e)[vn])}function RC(e){if(e==null)return{};let t=CC(e,"$.companionConfigs"),r={};for(let[n,o]of Object.entries(t)){if(!n||n!==n.trim())throw Dm("schema.invalidValue","$.companionConfigs");let a=n;if(o===null){r[a]=null;continue}let i=se(o);if(!i)throw Dm("schema.invalidType",`$.companionConfigs.${a}`);a===cE&&gt(i),a===vn&&Wn(i,`$.companionConfigs.${a}`),r[a]=i}return r}function CC(e,t){let r=se(e);if(!r)throw Dm("schema.invalidType",t);return r}function Dm(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}var gE="@fps-games/editor.playable-sdk.scene-compiler",bE="3",vC=new Set(["shadowMode","childMaterialBindings","childMaterials"]),GC=new Set(["coordinateSpace","center","size","rotation"]),lE=new Set(["root","group","model","primitive","light","prefabInstance","marker","collision"]);function Wc(e){yE(e,!0)}function SE(e){let t=da(e);return Wc(t.document),t}function Rm(e){yE(e,!1)}function yE(e,t){let r=k(e);if(!r)throw new Error("editor_scene_must_be_object");if(r.schemaVersion!==1)throw T("schema.unsupportedVersion","$.schemaVersion");if(!Array.isArray(r.assets))throw new Error("editor_scene_assets_must_be_array");let n=k(r.scene);if(!Array.isArray(n?.gameObjects))throw new Error("editor_scene_game_objects_must_be_array");if(n.materialAssets!=null&&!Array.isArray(n.materialAssets))throw new Error("editor_scene_material_assets_must_be_array");if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw T("schema.forbiddenField","$.scene.shadowMapExperiment");_C(r.assets,n.gameObjects),Om(r,"$"),$C(r.assets),FC(r.assets,n.gameObjects),LC(n.gameObjects,r.assets),zC(n.gameObjects),NC(n.materialAssets??[]),t&&BC(r.assets,n.gameObjects),Bs(r),jC(r.assets,n.gameObjects)}function jC(e,t){for(let r=0;r<t.length;r+=1){let n=k(t[r]),o=`$.scene.gameObjects[${r}]`,a=Object.prototype.hasOwnProperty.call(n,"shadow");if(k(n.prefab)){if(a)throw T("schema.forbiddenField",`${o}.shadow`)}else if(dn(n))uE(n.shadow,`${o}.shadow`);else if(a)throw T("schema.forbiddenField",`${o}.shadow`);if(Object.prototype.hasOwnProperty.call(n,"shadowMapExperiment"))throw T("schema.forbiddenField",`${o}.shadowMapExperiment`)}for(let r=0;r<e.length;r+=1){let n=k(e[r]),o=`$.assets[${r}]`,a=k(n.defaults);if(a?.shadow!==void 0)throw T("schema.forbiddenField",`${o}.defaults.shadow`);if(a?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${o}.defaults.shadowMapExperiment`);let i=k(n.prefab);if(!i)continue;let s=k(i.defaults);if(uE(s?.shadow,`${o}.prefab.defaults.shadow`),s?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${o}.prefab.defaults.shadowMapExperiment`);Array.isArray(i.nodes)&&i.nodes.forEach((c,d)=>{let u=k(c),l=`${o}.prefab.nodes[${d}]`,m=k(u?.defaults);if(u?.shadow!==void 0)throw T("schema.forbiddenField",`${l}.shadow`);if(m?.shadow!==void 0)throw T("schema.forbiddenField",`${l}.defaults.shadow`);if(u?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${l}.shadowMapExperiment`);if(m?.shadowMapExperiment!==void 0)throw T("schema.forbiddenField",`${l}.defaults.shadowMapExperiment`)})}}function uE(e,t){let r=k(e);if(!r||r.cast===void 0||r.receive===void 0)throw T("schema.invalidType",t);if(r.cast!=="enabled"&&r.cast!=="none"||r.receive!=="enabled"&&r.receive!=="none")throw T("schema.invalidValue",t);for(let n of Object.keys(r))if(n!=="cast"&&n!=="receive")throw T("schema.forbiddenField",`${t}.${n}`)}function NC(e){let t=new Set,r=new Set;for(let n=0;n<e.length;n+=1){let o=k(e[n]),a=`$.scene.materialAssets[${n}]`;if(!o)throw T("schema.invalidType",a);if(Object.prototype.hasOwnProperty.call(o,"materialKind"))throw T("schema.deprecatedField",`${a}.materialKind`);if(Object.prototype.hasOwnProperty.call(o,"profile"))throw T("schema.deprecatedField",`${a}.profile`);let i=C(o.id);if(!i)throw T("schema.invalidType",`${a}.id`);if(t.has(i))throw T("schema.invalidValue",`${a}.id`);t.add(i);let s=C(o.guid);if(s){if(r.has(s))throw T("schema.invalidValue",`${a}.guid`);r.add(s)}if(!C(o.name))throw T("schema.invalidType",`${a}.name`);let c=C(o.shaderId);if(!c)throw T("schema.invalidValue",`${a}.shaderId`);let d=De(c),u=o.definitionVersion;if(u!=null&&(typeof u!="number"||!Number.isSafeInteger(u)||u<1))throw T("schema.invalidValue",`${a}.definitionVersion`);if(!d&&u==null)throw T("schema.invalidValue",`${a}.definitionVersion`);if(d){let l=Qn(c,o.properties,`${a}.properties`);if(l[0])throw T("schema.invalidValue",l[0].path)}else if(!k(o.properties))throw T("schema.invalidType",`${a}.properties`);for(let l of Object.keys(o))if(!["id","guid","name","shaderId","definitionVersion","properties","system","origin"].includes(l))throw T("schema.unknownField",`${a}.${l}`)}}function FC(e,t){let r=new Set(e.map(k).filter(a=>a?.type==="glb").map(a=>C(a?.id)).filter(a=>!!a)),n=new Set(e.map(k).filter(a=>a?.type==="texture").map(a=>C(a?.id)).filter(a=>!!a)),o=new Map;for(let a of e.map(k)){if(a?.type!=="prefab")continue;let i=C(a.id),s=C(k(a.prefab)?.sourceAssetId);i&&s&&o.set(i,s)}for(let a=0;a<e.length;a+=1){let i=k(e[a]);if(i?.type!=="prefab")continue;let s=k(i.prefab),c=C(s?.sourceAssetId),d=C(s?.rootNodeId);if(!c||!r.has(c))throw T("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);let u=Array.isArray(s?.nodes)?s.nodes:[];for(let l=0;l<u.length;l+=1){let m=k(u[l]),f=C(m?.sourceAssetId);if(m?.kind==="model"&&(!f||!r.has(f)))throw T("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`);if(m?.kind==="prefabInstance"){let S=C(m.childPrefabId),g=S?o.get(S):null;if(C(m.id)===d&&c!==g)throw T("schema.invalidReference",`$.assets[${a}].prefab.sourceAssetId`);if(f&&f!==g)throw T("schema.invalidReference",`$.assets[${a}].prefab.nodes[${l}].sourceAssetId`)}}}for(let a=0;a<t.length;a+=1){let i=k(t[a]),s=C(k(i?.instance)?.assetId);if(s&&!r.has(s))throw T("schema.invalidReference",`$.scene.gameObjects[${a}].instance.assetId`);let c=Array.isArray(i?.components)?i.components:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ModelRenderer")continue;let l=C(u.assetId);if(!l||!r.has(l))throw T("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`)}for(let d=0;d<c.length;d+=1){let u=k(c[d]);if(u?.type!=="ImageRenderer")continue;let l=C(u.assetId);if(!l||!n.has(l))throw T("schema.invalidReference",`$.scene.gameObjects[${a}].components[${d}].assetId`);let m=k(u.size);if(!m||!pE(m.width)||!pE(m.height))throw T("schema.invalidValue",`$.scene.gameObjects[${a}].components[${d}].size`)}}}function _C(e,t){let r=new Set;e.forEach((a,i)=>{let s=k(a);if(!s)throw T("schema.invalidType",`$.assets[${i}]`);let c=C(s.id);if(!c||!C(s.type))throw T("schema.invalidValue",`$.assets[${i}]`);if(r.has(c))throw T("schema.invalidValue",`$.assets[${i}].id`);r.add(c)});let n=new Set,o=new Map;t.forEach((a,i)=>{let s=k(a);if(!s)throw T("schema.invalidType",`$.scene.gameObjects[${i}]`);let c=C(s.id);if(!c)throw T("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.has(c))throw T("schema.invalidValue",`$.scene.gameObjects[${i}].id`);if(n.add(c),o.set(c,{value:s,index:i}),!Array.isArray(s.components))throw T("schema.invalidType",`$.scene.gameObjects[${i}].components`);s.components.forEach((d,u)=>{let l=k(d);if(!l)throw T("schema.invalidType",`$.scene.gameObjects[${i}].components[${u}]`);if(!C(l.type))throw T("schema.invalidValue",`$.scene.gameObjects[${i}].components[${u}].type`)})});for(let[a,i]of o){if(!("parentId"in i.value))continue;let s=C(i.value.parentId);if(!s||!o.has(s))throw T("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);let c=new Set([a]),d=s;for(;d;){if(c.has(d))throw T("schema.invalidReference",`$.scene.gameObjects[${i.index}].parentId`);c.add(d);let u=o.get(d)?.value;d=u&&u.parentId!=null?C(u.parentId):null}}}function Om(e,t){if(Array.isArray(e)){e.forEach((n,o)=>Om(n,`${t}[${o}]`));return}let r=k(e);if(r)for(let[n,o]of Object.entries(r)){let a=`${t}.${n}`;if(vC.has(n))throw T("schema.deprecatedField",a);n==="shadow"&&Ko(o,a),!(n==="metadata"||n==="shadowMapExperiment")&&Om(o,a)}}function $C(e){let t=new Set(e.map(k).filter(i=>i?.type==="prefab").map(i=>C(i?.id)).filter(i=>!!i)),r=new Map;for(let i=0;i<e.length;i+=1){let s=k(e[i]);if(s?.type!=="prefab")continue;let c=k(s.prefab);if(!Array.isArray(c?.nodes))throw T("schema.unsupportedVersion",`$.assets[${i}].prefab.nodes`);mE(c.defaults,`$.assets[${i}].prefab.defaults`);let d=[],u=new Set;for(let S=0;S<c.nodes.length;S+=1){let g=`$.assets[${i}].prefab.nodes[${S}]`,b=k(c.nodes[S]);if(!b)throw T("schema.invalidType",g);mE(b.defaults,`${g}.defaults`);let y=C(b.id);if(!y||!lE.has(String(b.kind)))throw T("schema.invalidValue",g);if(u.has(y))throw T("schema.invalidValue",`${g}.id`);u.add(y),d.push(b)}let l=C(c?.rootNodeId),m=l?d.find(S=>C(S?.id)===l):null,f=!!m&&lE.has(String(m.kind))&&!Object.prototype.hasOwnProperty.call(m,"parentId");if(c?.compositionVersion!==sn||d.length===0||!f)throw T("schema.unsupportedVersion",`$.assets[${i}].prefab`);r.set(C(s.id),d.flatMap((S,g)=>{let b=C(S.childPrefabId);return b?[{prefabId:b,path:`$.assets[${i}].prefab.nodes[${g}].childPrefabId`}]:[]}));for(let S=0;S<d.length;S+=1){let g=d[S];mg(g,new Map(d.map(P=>[C(P.id),P])),`$.assets[${i}].prefab.nodes[${S}]`);let b=C(g.id),y=C(g.parentId);if(b!==l&&(!y||!u.has(y)))throw T("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);if(g.kind==="prefabInstance"){let P=C(g.childPrefabId);if(!P||!t.has(P))throw T("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].childPrefabId`)}let E=new Set([b]),I=y;for(;I;){if(E.has(I))throw T("schema.invalidReference",`$.assets[${i}].prefab.nodes[${S}].parentId`);E.add(I);let P=d.find(A=>C(A.id)===I);I=P?C(P.parentId):null}}}let n=new Set,o=new Set,a=i=>{if(!o.has(i)){n.add(i);for(let s of r.get(i)??[]){if(n.has(s.prefabId))throw T("schema.invalidReference",s.path);a(s.prefabId)}n.delete(i),o.add(i)}};for(let i of r.keys())a(i)}function mE(e,t){if(e==null)return;let r=k(e);if(!r)throw T("schema.invalidType",t);if(Object.prototype.hasOwnProperty.call(r,"active")&&typeof r.active!="boolean")throw T("schema.invalidType",`${t}.active`)}function LC(e,t){let r=new Map;for(let n of t.map(k)){if(n?.type!=="prefab")continue;let o=C(n.id),a=C(k(n.prefab)?.sourceAssetId);o&&a&&r.set(o,a)}for(let n=0;n<e.length;n+=1){let o=k(e[n]);if(!o||o.prefab==null)continue;let a=k(o.prefab),i=C(a?.prefabId),s=i?r.get(i):null;if(!i||!s)throw T("schema.unsupportedVersion",`$.scene.gameObjects[${n}].prefab`);if(C(a?.sourceAssetId)!==s)throw T("schema.invalidReference",`$.scene.gameObjects[${n}].prefab.sourceAssetId`);let c=C(k(o.instance)?.assetId);if(c&&c!==s)throw T("schema.invalidReference",`$.scene.gameObjects[${n}].instance.assetId`);let d=Array.isArray(o.components)?o.components:[];for(let u=0;u<d.length;u+=1){let l=k(d[u]);if(l?.type==="ModelRenderer"&&C(l.assetId)!==s)throw T("schema.invalidReference",`$.scene.gameObjects[${n}].components[${u}].assetId`)}}}function zC(e){for(let t=0;t<e.length;t+=1){let r=k(k(k(e[t])?.marker)?.geometry);if(r?.kind!=="box")continue;for(let o of GC)if(Object.prototype.hasOwnProperty.call(r,o))throw T("schema.deprecatedField",`$.scene.gameObjects[${t}].marker.geometry.${o}`);if(!(Array.isArray(k(e[t])?.components)?k(e[t]).components:[]).some(o=>k(o)?.type==="Transform"))throw T("schema.invalidValue",`$.scene.gameObjects[${t}].components`)}}function BC(e,t){let r=new Map,n=new Map;for(let o=0;o<e.length;o+=1){let a=k(e[o]),i=C(a?.id);if(!a||!i)continue;if(a.type==="prefab"){let l=C(k(a.prefab)?.sourceAssetId);l&&n.set(i,l)}let s=k(a.metadata),c=s?.materialSlots;if(c==null){r.set(i,new Set);continue}if(!Array.isArray(c))throw T("schema.invalidType",`$.assets[${o}].metadata.materialSlots`);let d=VC(s?.assetAnalysis),u=new Set;for(let l=0;l<c.length;l+=1){let m=k(c[l]),f=C(m?.slotId);if(!m||!f)throw T("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}]`);let S=`$.assets[${o}].metadata.materialSlots[${l}]`;for(let g of["ownerNodePath","nodeIndex","nodeIndexPath","meshIndex","primitiveIndex","sourceMaterialIndex","sourceMaterialIndices","sourceMeshName","triangleCount","boundingBox"])if(Object.prototype.hasOwnProperty.call(m,g))throw T("schema.deprecatedField",`${S}.${g}`);if(!Array.isArray(m.sourceSurfaces))throw T("schema.invalidType",`${S}.sourceSurfaces`);if(m.sourceSurfaces.length===0)throw T("schema.invalidValue",`${S}.sourceSurfaces`);for(let g=0;g<m.sourceSurfaces.length;g+=1){let b=`${S}.sourceSurfaces[${g}]`,y=k(m.sourceSurfaces[g]);if(!y||!C(y.ownerNodePath))throw T("schema.invalidValue",b);fE(y,"nodeIndex",b),fE(y,"sourceMaterialIndex",b);for(let I of["meshIndex","primitiveIndex"])if(!Number.isInteger(y[I])||y[I]<0)throw T("schema.invalidValue",`${b}.${I}`);if(y.nodeIndexPath!=null&&(!Array.isArray(y.nodeIndexPath)||y.nodeIndexPath.some(I=>!Number.isInteger(I)||I<0)))throw T("schema.invalidValue",`${b}.nodeIndexPath`);let E=y.meshIndex;if(!C(y.sourceMeshName)&&!d.has(E))throw T("schema.invalidValue",`${b}.sourceMeshName`)}if(u.has(f))throw T("schema.invalidValue",`$.assets[${o}].metadata.materialSlots[${l}].slotId`);u.add(f)}r.set(i,u)}for(let o=0;o<e.length;o+=1){let a=k(e[o]);if(a?.type!=="prefab")continue;let i=k(a.prefab),s=C(i?.sourceAssetId);wm(i?.overrides,s?r.get(s):void 0,`$.assets[${o}].prefab.overrides`);let c=Array.isArray(i?.nodes)?i.nodes:[];for(let d=0;d<c.length;d+=1){let u=k(c[d]),l=C(u?.childPrefabId),m=C(u?.sourceAssetId)??(l?n.get(l)??null:null);wm(u?.overrides,m?r.get(m):void 0,`$.assets[${o}].prefab.nodes[${d}].overrides`)}}for(let o=0;o<t.length;o+=1){let a=k(t[o]),s=(Array.isArray(a?.components)?a.components:[]).map(k).find(d=>d?.type==="ModelRenderer"),c=C(s?.assetId);wm(a?.overrides,c?r.get(c):void 0,`$.scene.gameObjects[${o}].overrides`)}}function wm(e,t,r){let n=k(e);if(!n||n.materialSlotBindings==null)return;let o=k(n.materialSlotBindings);if(!o)throw T("schema.invalidType",`${r}.materialSlotBindings`);for(let[a,i]of Object.entries(o)){if(!t?.has(a))throw T("schema.invalidReference",`${r}.materialSlotBindings.${a}`);let s=`${r}.materialSlotBindings.${a}`,c=k(i);if(!c)throw T("schema.invalidType",s);for(let d of Object.keys(c))if(d!=="materialAssetId"&&d!=="override")throw T("schema.deprecatedField",`${s}.${d}`);if("materialAssetId"in c&&c.materialAssetId!=null&&!C(c.materialAssetId))throw T("schema.invalidValue",`${s}.materialAssetId`);if("override"in c&&!k(c.override))throw T("schema.invalidType",`${s}.override`);"override"in c&&UC(c.override,`${s}.override`)}}function fE(e,t,r){let n=e[t];if(n!=null&&(!Number.isInteger(n)||n<0))throw T("schema.invalidValue",`${r}.${t}`)}function VC(e){let t=k(e),r=Array.isArray(t?.meshes)?t.meshes:[];return new Set(r.flatMap(n=>{let o=k(n),a=o?.meshIndex,i=Number.isInteger(a)?a:null;return i!=null&&C(o?.name)?[i]:[]}))}function UC(e,t){let r=k(e);if(!r)throw T("schema.invalidType",t);if(Oo(r,["lightingModel","baseColor","normal","metallic","roughness","metallicRoughness","occlusion","emission","alpha"],t),"lightingModel"in r&&!["lit","unlit"].includes(String(r.lightingModel)))throw T("schema.invalidValue",`${t}.lightingModel`);for(let n of["metallic","roughness"])ti(r,n,t);KC(r.baseColor,`${t}.baseColor`),km(r.normal,`${t}.normal`,["texture","strength"]),km(r.metallicRoughness,`${t}.metallicRoughness`,["texture"]),km(r.occlusion,`${t}.occlusion`,["texture","strength"]),HC(r.emission,`${t}.emission`),WC(r.alpha,`${t}.alpha`)}function KC(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["color","texture","brightness","saturation","contrast","hue"],t),hE(r.color,`${t}.color`),ei(r.texture,`${t}.texture`);for(let n of["brightness","saturation","contrast","hue"])ti(r,n,t)}function km(e,t,r){if(e==null)return;let n=Ro(e,t);Oo(n,r,t),ei(n.texture,`${t}.texture`),r.includes("strength")&&ti(n,"strength",t)}function HC(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["color","intensity","texture","maskTexture"],t),hE(r.color,`${t}.color`),ti(r,"intensity",t),ei(r.texture,`${t}.texture`),ei(r.maskTexture,`${t}.maskTexture`)}function WC(e,t){if(e==null)return;let r=Ro(e,t);if(Oo(r,["mode","opacity","cutoff","texture"],t),"mode"in r&&!["opaque","mask","blend"].includes(String(r.mode)))throw T("schema.invalidValue",`${t}.mode`);for(let n of["opacity","cutoff"])ti(r,n,t);ei(r.texture,`${t}.texture`)}function ei(e,t){if(e==null)return;let r=Ro(e,t);Oo(r,["url","textureAssetId"],t);for(let n of["url","textureAssetId"])if(n in r&&r[n]!=null&&!C(r[n]))throw T("schema.invalidValue",`${t}.${n}`)}function hE(e,t){if(e==null)return;let r=Ro(e,t);for(let n of["r","g","b"])qC(r,n,t)}function Oo(e,t,r){let n=new Set(t);for(let o of Object.keys(e))if(!n.has(o))throw T("schema.deprecatedField",`${r}.${o}`)}function ti(e,t,r){if(t in e&&e[t]!=null&&(typeof e[t]!="number"||!Number.isFinite(e[t])))throw T("schema.invalidType",`${r}.${t}`)}function qC(e,t,r){if(!(t in e)||typeof e[t]!="number"||!Number.isFinite(e[t]))throw T("schema.invalidValue",`${r}.${t}`)}function Ro(e,t){let r=k(e);if(!r)throw T("schema.invalidType",t);return r}function T(e,t){let r=new Error(`${e}: ${t}`);return Object.assign(r,{code:e,path:t}),r}function k(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function C(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function pE(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}var JC=Object.freeze({bash:"shell",cjs:"javascript",conf:"config",config:"config",css:"css",env:"dotenv",frag:"glsl",fs:"glsl",glsl:"glsl",htm:"html",html:"html",ini:"config",js:"javascript",json:"json",jsonc:"jsonc",jsx:"javascript",less:"less",md:"markdown",mjs:"javascript",scss:"scss",shader:"glsl",sh:"shell",toml:"toml",ts:"typescript",tsx:"typescript",txt:"text",vert:"glsl",vs:"glsl",wgsl:"wgsl",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"shell"}),XC=Object.freeze({".env":"dotenv",".eslintignore":"config",".gitignore":"config",".npmrc":"config",".prettierignore":"config",dockerfile:"dockerfile",makefile:"makefile"}),YC=Object.freeze({png:{kind:"image",mimeType:"image/png"},jpg:{kind:"image",mimeType:"image/jpeg"},jpeg:{kind:"image",mimeType:"image/jpeg"},webp:{kind:"image",mimeType:"image/webp"},gif:{kind:"image",mimeType:"image/gif"},bmp:{kind:"image",mimeType:"image/bmp"},glb:{kind:"model",mimeType:"model/gltf-binary"},mp3:{kind:"audio",mimeType:"audio/mpeg"},wav:{kind:"audio",mimeType:"audio/wav"},ogg:{kind:"audio",mimeType:"audio/ogg"},m4a:{kind:"audio",mimeType:"audio/mp4"},aac:{kind:"audio",mimeType:"audio/aac"},flac:{kind:"audio",mimeType:"audio/flac"}});function qc(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"",n=r.lastIndexOf(".");return n>0?r.slice(n+1):""}function Cm(e){let t=e.replace(/\\/g,"/").split("/"),r=t[t.length-1]?.toLowerCase()??"";return XC[r]??JC[qc(r)]??null}function EE(e){return Cm(e)!==null}function vm(e){return YC[qc(e)]??null}var ZC="fps.plugin.ground-decal",IE="@fps-games/plugin-ground-decal";function PE(e){tv(e);let t=e.plugins.find(i=>i.pluginId===ZC),r=t?ev(t):null,n=r?[{id:"groundDecal",label:"Ground Decal",config:QC(r),scene:{kind:"groundDecal"}}]:[],o=e.authoring.source,a=e.authoring.assets;return Object.freeze({definition:e,plugins:e.plugins,groundDecal:r,metadata:rv(e.metadata),project:Object.freeze({projectId:e.projectId,projectName:e.projectName,source:Object.freeze({editorScene:o.document,runtimeScene:o.runtimeArtifact,...o.rendering?{rendering:o.rendering}:{},...o.shadows?{shadows:o.shadows}:{}}),assets:Object.freeze({...a}),features:Object.freeze(n),...e.metadata&&Ce(e.metadata)?{metadata:Object.freeze({...e.metadata})}:{}})})}function QC(e){let t=new Map(e.kinds.map(l=>[l.id,l])),r=new Set(e.editableLayerRoles??[]),n=new Set(e.layoutEditableLayerRoles??[]),o=new Set(e.rotationEditableLayerRoles??[]),a=new Set(e.stretchedImageRoles??[]),i=new Set(e.activePreviewKinds??[]),s=l=>t.has(l),c=l=>{let m=t.get(l)??t.get(e.defaultUiKind);if(!m)throw new Error(`Ground Decal kind is not configured: ${l}`);return structuredClone(m.defaultConfig)},d=l=>nv(l,t),u={defaultUiKind:e.defaultUiKind,isKnownUiKind:s,isProjectEditableLayer:l=>r.size===0||r.has(l.role),isLayoutEditableLayer:l=>n.has(l.role),isRotationEditableLayer:l=>o.has(l.role),createDefaultGroundDecal:c,isGroundDecalConfig:d};return{uiKinds:Object.freeze([...t.keys()]),documentPolicy:u,inspectorPolicy:{...u,isEditableTextureLayer:l=>(l.kind==="texture"||l.kind==="textureProgress")&&(r.size===0||r.has(l.role)),isEditableColorLayer:l=>(l.kind==="color"||l.kind==="progress")&&(r.size===0||r.has(l.role)),isEditableTextLayer:l=>l.kind==="text"&&(r.size===0||r.has(l.role)),useUniformLayoutScaleMode:l=>n.has(l.role),resolveImageFit:l=>"imageFit"in l&&(l.imageFit==="stretch"||l.imageFit==="contain")?l.imageFit:a.has(l.role)?"stretch":"contain",createLayerLabel:l=>ov(l.role),createUiKindLabel:l=>t.get(l)?.label??l,canShowActivePreview:l=>i.has(l.uiKind),getLayerPreviewVisibility:(l,m)=>i.has(m.uiKind)&&l.role==="activeBackground"?{path:"groundDecal.editorPreviewActive",value:m.editorPreviewActive===!0}:null},createHierarchyLabel:l=>t.get(l)?.hierarchyLabel??`${t.get(l)?.label??l} Ground Decal UI`}}function ev(e){if(e.packageName!==IE)throw new Error(`Ground Decal Plugin package must be ${IE}.`);if(!e.targets.includes("editor"))throw new Error("Ground Decal Plugin must target editor.");let t=e.config;if(!Ce(t)||t.schemaVersion!==1)throw new Error("Ground Decal Plugin config schemaVersion must be 1.");if(typeof t.defaultUiKind!="string"||!Array.isArray(t.kinds)||t.kinds.length===0)throw new Error("Ground Decal Plugin config must define defaultUiKind and kinds.");let r=new Set;for(let n of t.kinds){if(!Ce(n)||typeof n.id!="string"||typeof n.label!="string"||!Ce(n.defaultConfig))throw new Error("Ground Decal Plugin kinds must contain id, label, and defaultConfig.");if(r.has(n.id))throw new Error(`Duplicate Ground Decal kind: ${n.id}`);if(r.add(n.id),n.defaultConfig.uiKind!==n.id)throw new Error(`Ground Decal defaultConfig.uiKind must match kind id: ${n.id}`)}if(!r.has(t.defaultUiKind))throw new Error(`Ground Decal defaultUiKind is not declared: ${t.defaultUiKind}`);for(let n of["editableLayerRoles","layoutEditableLayerRoles","rotationEditableLayerRoles","stretchedImageRoles","activePreviewKinds"]){let o=t[n];if(o!==void 0&&(!Array.isArray(o)||o.some(a=>typeof a!="string")))throw new Error(`Ground Decal Plugin config.${n} must be an array of strings.`)}return t}function tv(e){if(!Ce(e)||e.schemaVersion!==1)throw new Error("Editor Project definition schemaVersion must be 1.");if(typeof e.projectId!="string"||typeof e.projectName!="string")throw new Error("Editor Project identity is invalid.");if(!Ce(e.authoring)||!Ce(e.authoring.source)||!Ce(e.authoring.assets)||!Array.isArray(e.plugins))throw new Error("Editor Project authoring or Plugin configuration is invalid.")}function rv(e){return Ce(e)?Object.freeze({...Array.isArray(e.markerTypes)?{markerTypes:Object.freeze(e.markerTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{},...Array.isArray(e.relationTypes)?{relationTypes:Object.freeze(e.relationTypes.filter(Ce).map(t=>Object.freeze({...t})))}:{}}):Object.freeze({})}function nv(e,t){if(!Ce(e)||typeof e.uiKind!="string"||!t.has(e.uiKind)||!Ce(e.size)||!Jc(e.size.width)||!Jc(e.size.depth)||!Array.isArray(e.layers))return!1;let r=new Set;for(let n of e.layers){if(!Ce(n)||typeof n.id!="string"||!n.id||typeof n.role!="string"||!n.role||typeof n.kind!="string"||!Ce(n.rect)||!Number.isFinite(n.rect.x)||!Number.isFinite(n.rect.z)||!Jc(n.rect.width)||!Jc(n.rect.depth)||r.has(n.id))return!1;r.add(n.id)}return!0}function Jc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ce(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ov(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/^./,t=>t.toUpperCase())}var av=["/__fps_editor_authoring"],iv=[["manifest","/manifest"],["commit","/commit"],["editor-scene","/editor-scene"],["editor-asset-library","/editor-asset-library"],["project-files","/project-files"],["project-media","/project-media"],["project-file","/project-file"],["asset-import","/asset-import"],["save-editor-scene","/save-editor-scene"]];function TE(e,t={}){let r=new URL(e??"","http://localhost").pathname,n=t.prefixes??av,o=sv(r,n);if(!o)return null;let a=r.slice(o.length)||"/",i=cv(a);return i?{route:a,routeName:i,prefix:o}:null}function sv(e,t){return t.find(r=>e===r||e.startsWith(`${r}/`))??null}function cv(e){return iv.find(([,t])=>e===t)?.[0]??null}function Pe(e,t){return{statusCode:e,body:t}}function Xc(e){return{statusCode:e,body:null}}async function xE(e,t){let r=TE(e.url);if(!r)return null;let n=(e.method??"GET").toUpperCase();if(n==="OPTIONS")return Xc(204);try{if(dv(r.routeName)){if(n!=="GET")return Pe(405,{ok:!1,error:"method_not_allowed"});if(r.routeName==="project-file"){let a=new URL(e.url??"","http://localhost").searchParams.get("path")?.trim()??"";if(!a)return Pe(400,{ok:!1,error:"missing_file_path"});let i=await t.loadProjectFile?.({path:a,route:r});return Pe(200,i??{ok:!1,error:"not_found"})}return Pe(200,await lv(r,t))}if(n!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let o=e.body??await t.readBody?.(e,r)??{};return await uv(r,o,t)}catch(o){let a=typeof o?.code=="string"?o.code:"authoring_request_failed",i=a==="asset_import_payload_too_large"?413:r.routeName==="save-editor-scene"&&a==="authoring_source_revision_mismatch"?200:r.routeName==="asset-import"?400:500;return Pe(i,{ok:!1,error:o instanceof Error?o.message:String(o),code:a,details:se(o?.details)})}}function dv(e){return e==="manifest"||e==="editor-scene"||e==="editor-asset-library"||e==="project-files"||e==="project-file"||e==="project-media"}async function lv(e,t){return e.routeName==="manifest"&&t.loadManifest?t.loadManifest(e):e.routeName==="editor-scene"&&t.loadEditorScene?t.loadEditorScene(e):e.routeName==="editor-asset-library"&&t.loadEditorAssetLibrary?t.loadEditorAssetLibrary(e):e.routeName==="project-files"&&t.loadProjectFiles?t.loadProjectFiles(e):{ok:!1,error:"not_found"}}async function uv(e,t,r){if(e.routeName==="asset-import"){let n=sh(t),o=await r.importAsset?.({payload:n,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}return e.routeName==="save-editor-scene"?mv(e,t,r):e.routeName==="commit"?Pe(410,await fv(e,t,r)):Pe(404,{ok:!1,error:"not_found"})}async function mv(e,t,r){let n=t.mode==="prepare-platform-save"?"prepare-platform-save":"local-commit-save",o=await r.saveEditorScene?.({body:t,mode:n,rawEditorScene:t.editorScene,route:e});return Pe(200,o??{ok:!1,error:"not_found"})}async function fv(e,t,r){return r.commit?.({body:t,route:e})??{ok:!1,error:"platform_commit_route_disabled",message:"Save through /__fps_editor_authoring/save-editor-scene so scene.main remains the authoring source of truth."}}function DE(e,t,r={}){let n=SE(e).document,o=t;Object.prototype.hasOwnProperty.call(o,"staticShadows")&&o.staticShadows!=null&&Wn(o.staticShadows,"$.staticShadows");let{scene:a,...i}=t,s=structuredClone(i),c=Ue(a)?a:void 0,d=Wt(n),u={...d,compilerId:gE,compilerVersion:bE,compiledAt:new Date().toISOString()};s.schemaVersion=3,s.meta={...s.meta??{},generatedFrom:u};let l=c?.rootId||"root",m=n.scene.gameObjects.filter(E=>E.id!==l),f=yv(n,r.materialShaderDefinitions,!0),S={...n,scene:{...n.scene,materialAssets:f}},g=m.flatMap(E=>kv(E,d,S,r)),b=g.map(ME);gv(l,b),bv(l,b);let y={rootId:l,assets:S.assets.filter(Iv).map(Pv),nodes:b,materialAssets:f,materials:structuredClone(c?.materials??[]),textures:structuredClone(c?.textures??[])};return s.scene=y,s.plugins=Rv(s.plugins,r.shadowMapExperimentConfig,g,l,d.revision),ji(s),{sceneConfig:s,summary:{assetCount:y.assets.length,gameObjectCount:n.scene.gameObjects.length,nodeCount:y.nodes.length}}}function ME(e){if(!Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentInferredUpdateClass"))return e;let{shadowMapExperimentInferredUpdateClass:t,...r}=e;return r}function gv(e,t){let r=new Set([e]);for(let n=0;n<t.length;n+=1){let o=t[n].id;if(r.has(o)){let a=new Error(`schema.invalidReference: $.scene.nodes[${n}].id`);throw Object.assign(a,{code:"schema.invalidReference",path:`$.scene.nodes[${n}].id`,nodeId:o}),a}r.add(o)}}function bv(e,t){let r=new Map(t.map(n=>[n.id,n]));for(let n=0;n<t.length;n+=1){let o=t[n];if(!(o.source?.component!=="PrefabMarker"||!("marker"in o)||!o.marker))for(let a of Sv(o.marker)){let i=r.get(a.target.id);if(a.target.id!==e&&(!i||i.source?.objectId===o.source.objectId))continue;let s=`$.scene.nodes[${n}].marker.${a.path}.id`,c=new Error(`schema.invalidReference: ${s}`);throw Object.assign(c,{code:"schema.invalidReference",path:s,nodeId:o.id,targetId:a.target.id}),c}}}function Sv(e){let t=[];return e.target&&t.push({path:"target",target:e.target}),e.geometry.kind==="point"&&e.geometry.target&&t.push({path:"geometry.target",target:e.geometry.target}),e.geometry.kind==="object-bounds"&&t.push({path:"geometry.target",target:e.geometry.target}),t}function yv(e,t,r=!1){let n=structuredClone(e.scene.materialAssets??[]);for(let a=0;a<n.length;a+=1){let i=n[a];if(De(i.shaderId))continue;let s=t?.get(i.shaderId);if(!s){if(!r)continue;throw Gm("material.shaderDefinitionNotFound",`$.scene.materialAssets[${a}].shaderId`,`Shader Definition was not found: ${i.shaderId}`)}if(i.definitionVersion!==s.version)throw Gm("material.shaderDefinitionVersionMismatch",`$.scene.materialAssets[${a}].definitionVersion`,`Material ${i.id} uses Definition v${String(i.definitionVersion)} but ${i.shaderId} is v${s.version}.`);let c=Qn(i.shaderId,i.properties,`$.scene.materialAssets[${a}].properties`,t);if(c[0])throw Gm("material.propertiesInvalid",c[0].path,c[0].message)}let o=rs(hv(e,n));if(!o.ok)throw new Error(`editor_scene_material_assets_missing: ${o.missingMaterialAssetIds.join(", ")}`);return n}function Gm(e,t,r){return Object.assign(new Error(`${e}: ${r}`),{code:e,path:t})}function hv(e,t){let r={...e,scene:{...e.scene,materialAssets:t}};return{...r,scene:{...r.scene,gameObjects:[...r.scene.gameObjects.map(n=>{let o=jE(n,r);if(o)return{...n,overrides:o};if(!("overrides"in n))return n;let a={...n};return delete a.overrides,a}),...Ev(r)]}}}function Ev(e){let t=[];for(let r of e.scene.gameObjects){let n=ln(e,r);!n.definition||!Yc(n.definition)||t.push(...wE({editorDocument:e,prefabAsset:n.definition,hostGameObject:r,instanceOverrides:r.overrides,visitedPrefabIds:new Set}))}return t}function wE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[];e.visitedPrefabIds.add(e.prefabAsset.id);let t=vE(Ze(e.prefabAsset),Ye(e.prefabAsset)??""),r=t.find(a=>a.id===Ye(e.prefabAsset));if(!r)return e.visitedPrefabIds.delete(e.prefabAsset.id),[];let n=GE(t,e.prefabAsset),o=[];for(let a of t){if(a.kind==="prefabInstance"&&a.childPrefabId){let d=e.editorDocument.assets.find(u=>u.id===a.childPrefabId);if(d&&Yc(d)){o.push(...wE({editorDocument:e.editorDocument,prefabAsset:d,hostGameObject:e.hostGameObject,instanceOverrides:a.overrides,visitedPrefabIds:new Set(e.visitedPrefabIds)}));continue}continue}let i=zv(e.hostGameObject,a);if(!i)continue;let s=a.kind==="model"&&a.sourceAssetId?e.editorDocument.assets.find(d=>d.id===a.sourceAssetId):void 0,c=$m({hostGameObject:i,prefabAsset:e.prefabAsset,rootNode:r,node:a,asset:s,editorDocument:e.editorDocument,instanceOverrides:a.id===n?e.instanceOverrides:void 0});c&&o.push({...i,overrides:c})}return e.visitedPrefabIds.delete(e.prefabAsset.id),o}function Iv(e){return e.type==="glb"||e.type==="texture"}function Pv(e){let t=Av(e),r=e.type==="glb"?Dv(e):[],n=xv(e.external),o=Tv(e.defaults);return{id:e.id,type:e.type,...e.guid?{guid:e.guid}:{},...t?{url:t}:{},...typeof e.warmupCount=="number"&&Number.isInteger(e.warmupCount)&&e.warmupCount>=0?{warmupCount:e.warmupCount}:{},...typeof e.singleton=="boolean"?{singleton:e.singleton}:{},...typeof e.materialMode=="string"?{materialMode:e.materialMode}:{},...o!==void 0?{defaults:o}:{},...n?{external:n}:{},...r.length>0?{materialSlots:r}:{}}}function Tv(e){if(!e)return;let t=structuredClone(e);return Ue(t)?(delete t.shadowMapExperiment,Object.keys(t).length>0?t:void 0):t}function xv(e){let t=Ue(e)?e:void 0,r=yr(t?.platformAssetId),n=yr(t?.assetUrl);if(!(!r&&!n))return{...r?{platformAssetId:r}:{},...n?{assetUrl:n}:{}}}function Av(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Ue(e.external)?e.external:void 0;return yr(t?.url)??yr(r?.assetUrl)??void 0}function Dv(e){let t=Ue(e.metadata)?e.metadata:void 0,r=Array.isArray(t?.materialSlots)?t.materialSlots:[],n=Mv(t?.assetAnalysis);return r.flatMap(o=>{if(!Ue(o))return[];let a=yr(o.slotId);if(!a)return[];let i=yr(o.label),s=(Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[]).flatMap(c=>{if(!Ue(c))return[];let d=yr(c.ownerNodePath),u=ri(c.meshIndex),l=ri(c.primitiveIndex);if(!d||u==null||l==null)return[];let m=ri(c.nodeIndex),f=wv(Array.isArray(c.nodeIndexPath)?c.nodeIndexPath:[]),S=ri(c.sourceMaterialIndex),g=yr(c.sourceMeshName)??n.get(u);return[{ownerNodePath:d,...m==null?{}:{nodeIndex:m},...f.length>0?{nodeIndexPath:f}:{},meshIndex:u,primitiveIndex:l,...S==null?{}:{sourceMaterialIndex:S},...g?{sourceMeshName:g}:{}}]});return s.length===0?[]:[{slotId:a,...i?{label:i}:{},sourceSurfaces:s}]})}function Mv(e){let t=Ue(e)?e:void 0,r=Array.isArray(t?.meshes)?t.meshes:[];return new Map(r.flatMap(n=>{if(!Ue(n))return[];let o=ri(n.meshIndex),a=yr(n.name);return o==null||!a?[]:[[o,a]]}))}function wv(e){return[...new Set(e.filter(t=>typeof t=="number"&&Number.isInteger(t)&&t>=0))]}function ri(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:void 0}function kv(e,t,r,n){let o=ln(r,e);return(o.definition&&Yc(o.definition)?vv(e,o.definition,t,r,new Set,n):[Ov(e,t,r,n)]).map(i=>{let s=i.kind==="instance"?r.assets.find(d=>d.id===i.instance.assetId):void 0,c=n.inferShadowMapExperimentUpdateClass?.({gameObject:e,runtimeNode:ME(i),...s?{asset:s}:{}})??Cv(s);return{...i,shadowMapExperimentInferredUpdateClass:c}})}function Ov(e,t,r,n={}){let o=G(e),a=ue(e),i=kr(e),s=Vv(e),c=Y(e),d=jE(e,r),u=sg(e),l={sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision,...e.guid?{objectGuid:e.guid}:{},objectId:e.id,component:a?"ModelRenderer":i?"ImageRenderer":s||c==="primitive"?"PrimitiveRenderer":c==="transform"?"Transform":"GameObject"},m={id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...Nv(r,e,n),...u?{rendering:u}:{},source:l,...o&&"position"in o?{transform:{position:o.position,rotation:o.rotation,...o.scale?{scale:o.scale}:{}}}:{}};if(c==="primitive")return{...m,kind:"primitive",primitive:{shape:s?.shape??"cube"},...d?{overrides:d}:{}};if(i)return{...m,kind:"image",image:{assetId:i.assetId,size:{width:i.size.width,height:i.size.height}},...d?{overrides:d}:{}};if(!a){if(c==="transform"){let f=jv(e,n),S=f.transformType;delete f.transformType;let g=AE(S)??AE(e.transformType);return{...m,kind:"transform",...g?{transformType:g}:{},...e.camera?{camera:Hv(e.camera)}:{},...e.light?{light:NE(e.light)}:{},...e.marker?{marker:{label:e.name||e.id,...structuredClone(e.marker)}}:{},...f,...d?{overrides:d}:{}}}return{...m,kind:"group"}}return{...m,kind:"instance",instance:{assetId:a.assetId},...d?{overrides:d}:{}}}function Rv(e,t,r,n,o){let a=(e??[]).filter(u=>u.pluginId!==gd);if(!t)return a;let i=r.find(u=>u.id===t.lightRef),s=i?.kind==="transform"&&i.light?.type==="directional"?i:void 0;if(!i&&t.enabled)throw new Error(`shadowMapExperiment.lightMissing:${t.lightRef}`);if(i&&!s&&t.enabled)throw new Error(`shadowMapExperiment.lightUnsupported:${t.lightRef}`);let c=s?.kind==="transform"&&s.light?.type==="directional"?[s.light.direction.x,s.light.direction.y,s.light.direction.z]:[0,-1,0],d=Pf({revision:typeof o=="number"&&Number.isInteger(o)&&o>=0?o:0,scopeId:n,config:t,lightDirection:c,objects:r.filter(u=>u.kind==="instance"||u.kind==="primitive").map(u=>({entityId:u.id,renderableIds:[u.id],cast:u.shadow?.cast==="enabled",receive:u.shadow?.receive==="enabled",inferredUpdateClass:u.shadowMapExperimentInferredUpdateClass??"static"}))});return[...a,{pluginId:gd,schemaVersion:3,data:d}]}function Cv(e){let t=Ue(e?.metadata?.assetAnalysis)?e.metadata.assetAnalysis:void 0;if(!t)return"static";let r=jm(t.skinCount),n=jm(t.morphTargetCount);return r>0||n>0?"skinned":jm(t.animationCount)>0?"dynamic":"static"}function jm(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:0}function vv(e,t,r,n,o,a){return kE({prefabAsset:t,sourceRef:r,editorDocument:n,hostGameObject:e,rootRuntimeId:e.id,rootParentId:e.parentId,rootName:e.name??t.displayName??t.id,rootTransform:G(e)??void 0,rootActive:e.active,instanceOverrides:e.overrides,propertyPathPrefix:`assets.${t.id}.prefab.nodes`,visitedPrefabIds:o,compilerOptions:a})}function kE(e){if(e.visitedPrefabIds.has(e.prefabAsset.id))return[Nm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"PrefabCycle",propertyPath:e.propertyPathPrefix})];e.visitedPrefabIds.add(e.prefabAsset.id);let t=Ze(e.prefabAsset),r=Ye(e.prefabAsset),n=r?t.find(d=>d.id===r):null;if(!n||t.length===0)return e.visitedPrefabIds.delete(e.prefabAsset.id),[Nm({id:e.rootRuntimeId,name:e.rootName??e.prefabAsset.displayName??e.prefabAsset.id,parentId:e.rootParentId,transform:e.rootTransform,editorDocument:e.editorDocument,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:"Prefab",propertyPath:e.propertyPathPrefix})];let o={instanceId:e.rootRuntimeId,rootNodeId:n.id},a=d=>ao(o,d.id),i=vE(t,n.id),s=GE(i,e.prefabAsset),c=[];for(let d of i){let u=a(d),l=d.id===n.id?e.rootParentId:a(t.find(m=>m.id===d.parentId)??n);if(d.kind==="prefabInstance"&&d.childPrefabId){let m=e.editorDocument.assets.find(f=>f.id===d.childPrefabId);if(m&&Yc(m)){let f=d.id===n.id;c.push(...kE({prefabAsset:m,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeId:u,rootParentId:l,rootName:f?e.rootName??d.name??m.displayName??m.id:d.name??m.displayName??m.id,rootTransform:f?e.rootTransform??d.transform:d.transform,rootActive:f?e.rootActive??d.defaults?.active??e.prefabAsset.prefab?.defaults?.active:d.defaults?.active,instanceOverrides:f?ni(ni(Yt(e.prefabAsset.prefab?.overrides),Yt(d.overrides)),Yt(e.instanceOverrides)):d.overrides,propertyPathPrefix:`${e.propertyPathPrefix}.${d.id}.childPrefab.nodes`,visitedPrefabIds:new Set(e.visitedPrefabIds),compilerOptions:e.compilerOptions}));continue}c.push(Nm({id:u,name:d.name??d.childPrefabId??"Prefab Instance",parentId:l,transform:d.transform,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,component:"UnsupportedPrefabInstance",propertyPath:`${e.propertyPathPrefix}.${d.id}`}));continue}c.push(Gv({node:d,rootNode:n,identityScope:o,prefabAsset:e.prefabAsset,runtimeId:u,parentId:l,sourceRef:e.sourceRef,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,rootRuntimeName:e.rootName,rootRuntimeTransform:e.rootTransform,rootRuntimeActive:e.rootActive,instanceOverrides:d.id===s?e.instanceOverrides:void 0,propertyPath:`${e.propertyPathPrefix}.${d.id}`,shadowFallbackMode:_m(e.compilerOptions)}))}return e.visitedPrefabIds.delete(e.prefabAsset.id),_v({compiledNodes:c,editorDocument:e.editorDocument,hostGameObject:e.hostGameObject,shadowFallbackMode:_m(e.compilerOptions)})}function Gv(e){let t=e.node.id===e.rootNode.id,r=t?e.rootRuntimeTransform??e.node.transform:e.node.transform,n=e.node.kind==="model"&&e.node.sourceAssetId?e.editorDocument.assets.find(i=>i.id===e.node.sourceAssetId):void 0,o=e.node.kind==="model"||e.node.kind==="primitive",a=OE({id:e.runtimeId,name:t?e.rootRuntimeName??e.node.name??e.prefabAsset.displayName??e.prefabAsset.id:e.node.name,parentId:e.parentId,transform:r,active:t?e.rootRuntimeActive??e.node.defaults?.active??e.prefabAsset.prefab?.defaults?.active:e.node.defaults?.active,...o?{shadow:e.prefabAsset.prefab?.defaults?.shadow}:{},editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.node.kind==="model"?"PrefabModel":e.node.kind==="primitive"?"PrefabPrimitive":e.node.kind==="light"?"PrefabLight":e.node.kind==="marker"?"PrefabMarker":"PrefabNode",propertyPath:e.propertyPath});if(e.node.kind==="model"&&e.node.sourceAssetId){let i=$m({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:n,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"instance",instance:{assetId:e.node.sourceAssetId},...i?{overrides:i}:{}}}if(e.node.kind==="primitive"){let i=$m({hostGameObject:e.hostGameObject,prefabAsset:e.prefabAsset,rootNode:e.rootNode,node:e.node,asset:void 0,editorDocument:e.editorDocument,instanceOverrides:e.instanceOverrides});return{...a,kind:"primitive",primitive:{shape:e.node.primitive?.shape??"cube"},...i?{overrides:i}:{}}}return e.node.kind==="light"?{...a,kind:"transform",transformType:"light",...e.node.light?{light:NE(e.node.light)}:{}}:e.node.kind==="marker"&&e.node.marker?{...a,kind:"transform",marker:{label:e.node.name??e.node.id,...ma(e.node.marker,e.identityScope)}}:{...a,kind:"group"}}function Nm(e){return{...OE({id:e.id,name:e.name,parentId:e.parentId,transform:e.transform,editorDocument:e.editorDocument,shadowFallbackMode:e.shadowFallbackMode,sourceRef:e.sourceRef,hostGameObject:e.hostGameObject,component:e.component,propertyPath:e.propertyPath}),kind:"group"}}function jv(e,t){let r=t.readCustomTransformRuntimeData?.(e);return r&&typeof r=="object"&&!Array.isArray(r)?structuredClone(r):{}}function OE(e){return{id:e.id,...e.name?{name:e.name}:{},...e.parentId?{parentId:e.parentId}:{},...e.active===!1?{enabled:!1}:{},...e.shadow?{shadow:structuredClone(e.shadow)}:{},...Fv(e),source:{sourceId:e.sourceRef.sourceId,sourceType:e.sourceRef.sourceType,revision:e.sourceRef.revision,...e.hostGameObject.guid?{objectGuid:e.hostGameObject.guid}:{},objectId:e.hostGameObject.id,component:e.component,propertyPath:e.propertyPath},...e.transform&&"position"in e.transform?{transform:{position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}}:{}}}function Nv(e,t,r){let n=Ps({document:e,casterId:t.id,caster:t,fallbackMode:_m(r)});return Lm(n,!!t.shadow)?{shadowPlan:n}:{}}function Fv(e){if(!e.editorDocument)return{};let t=He(e.shadow),r=!!e.shadow||!!t.shadow;if(!r&&t.diagnostics.length===0)return{};let n=Ps({document:e.editorDocument,casterId:e.hostGameObject.id,caster:e.hostGameObject,resolvedSettings:t.shadow,fallbackMode:e.shadowFallbackMode}),o={...n,casterId:e.id,diagnostics:[...t.diagnostics,...n.diagnostics].map(a=>({...a,casterId:a.casterId===e.hostGameObject.id||!a.casterId?e.id:a.casterId}))};return Lm(o,r)?{shadowPlan:o}:{}}function Lm(e,t){return t||e.backend!=="none"||e.diagnostics.length>0}function _v(e){if(e.compiledNodes.length===0)return e.compiledNodes;let t=new Set(e.compiledNodes.map(i=>i.id)),r=e.compiledNodes.map(i=>$v(i)),n={...e.editorDocument,scene:{...e.editorDocument.scene,gameObjects:[...e.editorDocument.scene.gameObjects.filter(i=>!t.has(i.id)),...r]}},o=e.compiledNodes.filter(i=>i.shadow?.receive==="enabled").map(i=>i.id),a=r.find(i=>i.light?.type==="directional"&&i.active!==!1)?.id;return e.compiledNodes.map((i,s)=>{let c=r[s],d=Ps({document:n,casterId:i.id,caster:c,explicitReceiverIds:o,...a?{defaultLightId:a}:{},fallbackMode:e.shadowFallbackMode}),u=!!i.shadow;if(!Lm(d,u)){if(!i.shadowPlan)return i;let l={...i};return delete l.shadowPlan,l}return{...i,shadowPlan:d}})}function _m(e){let t=Ne(e.renderingProfile).shadows,r=t.planar.enabled?"planar":t.blob.enabled?"blob":t.staticProjected.enabled?"static":t.enabled?"dynamic":"none";return r==="planar"?"projected":r}function $v(e){let t=[];return e.transform&&t.push({type:"Transform",position:e.transform.position,rotation:e.transform.rotation,...e.transform.scale?{scale:e.transform.scale}:{}}),e.kind==="instance"&&t.push({type:"ModelRenderer",assetId:e.instance.assetId}),e.kind==="image"&&t.push({type:"ImageRenderer",assetId:e.image.assetId,size:structuredClone(e.image.size)}),{id:e.id,...e.name?{name:e.name}:{},kind:e.kind==="image"?"transform":e.kind,...e.parentId?{parentId:e.parentId}:{},...e.enabled===!1?{active:!1}:{},...e.shadow?{shadow:{cast:e.shadow.cast==="enabled"?"enabled":"none",receive:e.shadow.receive==="enabled"?"enabled":"none"}}:{},...e.kind==="primitive"?{primitive:{shape:e.primitive.shape}}:{},...e.kind==="transform"&&e.transformType?{transformType:e.transformType}:{},...e.kind==="transform"&&e.light?{light:e.light}:{},...e.kind==="transform"&&e.camera?{camera:e.camera}:{},...e.kind==="transform"&&e.marker?{marker:structuredClone(e.marker)}:{},components:t}}function $m(e){let t=e.node.kind==="model"&&e.node.sourceAssetId?CE(e.hostGameObject,e.node,e.node.sourceAssetId):e.hostGameObject,r=e.asset?.id,n=Bv([Fm(Yt(e.prefabAsset.prefab?.overrides),e.prefabAsset.prefab?.sourceAssetId,e.asset),Fm(Yt(e.rootNode.overrides),e.rootNode.kind==="model"?e.rootNode.sourceAssetId:e.prefabAsset.prefab?.sourceAssetId,e.asset),e.node.id===e.rootNode.id?void 0:Fm(Yt(e.node.overrides),e.node.kind==="model"?e.node.sourceAssetId:r,e.asset)]),o=Yt(e.instanceOverrides);return RE(ni(n,o),e.asset)}function Fm(e,t,r){return RE(e,t&&t===r?.id?r:void 0)}function RE(e,t){if(!e?.materialSlotBindings)return e;let r=Ue(t?.metadata)&&Array.isArray(t.metadata.materialSlots)?t.metadata.materialSlots:[],n=new Set(r.flatMap(i=>{let s=Ue(i)&&typeof i.slotId=="string"?i.slotId.trim():"";return s?[s]:[]})),o=Object.fromEntries(Object.entries(e.materialSlotBindings).filter(([i])=>n.has(i))),a=structuredClone(e);return Object.keys(o).length>0?a.materialSlotBindings=o:delete a.materialSlotBindings,Object.keys(a).length>0?a:void 0}function CE(e,t,r){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"instance",components:[...t.transform?[t.transform]:[],{type:"ModelRenderer",assetId:r}]}}function Lv(e,t){return{id:`${e.id}:${t.id}`,...t.name?{name:t.name}:{},kind:"primitive",primitive:{shape:t.primitive?.shape??"cube"},components:[...t.transform?[t.transform]:[]]}}function zv(e,t){return t.kind==="model"&&t.sourceAssetId?CE(e,t,t.sourceAssetId):t.kind==="primitive"?Lv(e,t):null}function Bv(e){let t;for(let r of e){let n=Yt(r);n&&(t=ni(t,n))}return t}function vE(e,t){let r=new Map;for(let s of e){if(!s.parentId)continue;let c=r.get(s.parentId)??[];c.push(s),r.set(s.parentId,c)}let n=[],o=new Set,a=s=>{if(!o.has(s.id)){o.add(s.id),n.push(s);for(let c of r.get(s.id)??[])a(c)}},i=e.find(s=>s.id===t);i&&a(i);for(let s of e)a(s);return n}function GE(e,t){let r=t.prefab?.sourceAssetId;return e.find(n=>n.kind==="model"&&n.sourceAssetId===r)?.id??e.find(n=>n.kind==="model")?.id}function Yc(e){return Xe(e)&&e.prefab.compositionVersion===sn&&Array.isArray(e.prefab.nodes)&&e.prefab.nodes.length>0&&!!Ye(e)}function Vv(e){return e.primitive??null}function jE(e,t){let r=Y(e);if(r!=="instance"&&r!=="transform"&&r!=="primitive")return;let n=ue(e),o=n?t.assets.find(a=>a.id===n.assetId):void 0;return Uv(e,t,o)}function Uv(e,t,r){let n=Yt(e.overrides),o=ln(t,e),a=Yt(o.definition?.prefab?.overrides);return ni(a,n)}function ni(e,t){let r=is(e,t);for(let n of[e,t])if(n)for(let[o,a]of Object.entries(n))Kv(o)||a===void 0||(r??={},r[o]=structuredClone(a));return r&&Object.keys(r).length>0?r:void 0}function Yt(e){if(!Ue(e))return;let t=structuredClone(e);return Object.keys(t).length>0?t:void 0}function Kv(e){return e==="materialBinding"||e==="materialSlotBindings"}function Ue(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function yr(e){return(typeof e=="string"?e.trim():"")||void 0}function AE(e){return typeof e=="string"?e:void 0}function Hv(e){let t=structuredClone(e);return delete t.inspectorLanguage,t}function NE(e){return e.type==="directional"?Vn({schemaVersion:1,type:"directional",intensity:e.intensity,direction:Xo(e.direction),diffuseColor:e.diffuseColor??Na.diffuseColor}):Vn({schemaVersion:1,type:"hemispheric",intensity:e.intensity,diffuseColor:e.diffuseColor??wn.diffuseColor,groundColor:e.groundColor??wn.groundColor})}var Wv=new Set(["leftToRight","rightToLeft","bottomToTop","topToBottom"]);function $E(e){let t=Ni(e),r={uiKind:e.uiKind,size:{width:e.size.width,depth:e.size.depth},layers:e.layers.map((n,o)=>qv(n,o)),rendering:{textureWidth:t.width,textureHeight:t.height}};return e.aspectSourceLayerId&&(r.aspectSourceLayerId=e.aspectSourceLayerId),typeof e.lockAspectToBorder=="boolean"&&(r.lockAspectToBorder=e.lockAspectToBorder),e.mask&&(r.mask={...typeof e.mask.enabled=="boolean"?{enabled:e.mask.enabled}:{},...e.mask.source==="roundedRect"||e.mask.source==="borderAlpha"||e.mask.source==="texture"?{source:e.mask.source}:{},...e.mask.textureId?{textureId:e.mask.textureId}:{},...typeof e.mask.cornerRadius=="number"&&Number.isFinite(e.mask.cornerRadius)?{cornerRadius:e.mask.cornerRadius}:{},...typeof e.mask.padding=="number"&&Number.isFinite(e.mask.padding)?{padding:e.mask.padding}:{}}),e.rendering&&(r.rendering={...r.rendering,...typeof e.rendering.alphaIndex=="number"&&Number.isFinite(e.rendering.alphaIndex)?{alphaIndex:e.rendering.alphaIndex}:{},...typeof e.rendering.diffuseTextureLevel=="number"&&Number.isFinite(e.rendering.diffuseTextureLevel)?{diffuseTextureLevel:e.rendering.diffuseTextureLevel}:{},...typeof e.rendering.emissiveTextureLevel=="number"&&Number.isFinite(e.rendering.emissiveTextureLevel)?{emissiveTextureLevel:e.rendering.emissiveTextureLevel}:{}}),r}function qv(e,t){let r=Ao(e.rotationDeg??0)??0,n={id:e.id,role:e.role,zOrder:typeof e.zOrder=="number"&&Number.isFinite(e.zOrder)?e.zOrder:t,rect:Jv(e.rect),...r!==0?{rotationDeg:r}:{},...typeof e.enabled=="boolean"?{enabled:e.enabled}:{},...typeof e.opacity=="number"&&Number.isFinite(e.opacity)?{opacity:e.opacity}:{}};return e.kind==="texture"?{...n,kind:"texture",...e.textureId?{textureId:e.textureId}:{},...e.tint?{tint:Co(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{}}:e.kind==="textureProgress"?{...n,kind:"textureProgress",...e.textureId?{textureId:e.textureId}:{},value:_E(e.value),...e.tint?{tint:Co(e.tint)}:{},...e.imageFit?{imageFit:e.imageFit}:{},...FE(e.direction)?{direction:e.direction}:{}}:e.kind==="color"?{...n,kind:"color",color:Co(e.color)}:e.kind==="progress"?{...n,kind:"progress",value:_E(e.value??0),color:Co(e.color),...FE(e.direction)?{direction:e.direction}:{}}:{...n,kind:"text",text:{value:e.text.value,color:Co(e.text.color),...e.text.fontFamily?{fontFamily:e.text.fontFamily}:{},...typeof e.text.fontSize=="number"&&Number.isFinite(e.text.fontSize)?{fontSize:e.text.fontSize}:{},...e.text.fontWeight!=null?{fontWeight:String(e.text.fontWeight)}:{},...e.text.strokeColor?{strokeColor:Co(e.text.strokeColor)}:{},...typeof e.text.strokeWidth=="number"&&Number.isFinite(e.text.strokeWidth)?{strokeWidth:e.text.strokeWidth}:{},...e.text.align==="left"||e.text.align==="center"||e.text.align==="right"?{align:e.text.align}:{},...e.text.baseline==="top"||e.text.baseline==="middle"||e.text.baseline==="bottom"?{baseline:e.text.baseline}:{}}}}function Jv(e){return{x:e.x,z:e.z,width:e.width,depth:e.depth}}function Co(e){return{r:e.r,g:e.g,b:e.b,...typeof e.a=="number"?{a:e.a}:{}}}function FE(e){return typeof e=="string"&&Wv.has(e)}function _E(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}async function LE(e,t){let r=String(e.method??"GET").toUpperCase();if(r==="OPTIONS")return Xc(204);try{if(r==="GET"){let c=Qv(await t.loadConfig?.()),d=c.renderingConfig;gt(d);let u=Ne(d);return Pe(200,{ok:!0,...c.response,renderingConfig:Zv(d),normalized:u,summary:Bn(u)})}if(r!=="POST")return Pe(405,{ok:!1,error:"method_not_allowed"});let n=e.body??await t.readBody?.(e)??{},o=oi(n.renderingConfig);if(!o)return Pe(400,{ok:!1,error:"missing_rendering_config"});gt(o);let a=Ne(o),i=Bn(a),s=await t.saveConfig?.({body:n,renderingConfig:o,normalized:a,summary:i});return Pe(200,{ok:!0,...s??{},renderingConfig:o,normalized:a,summary:i})}catch(n){let o=Xv(n),a=Yv(n);return Pe(o?.startsWith("schema.")?400:500,{ok:!1,error:o??(n instanceof Error?n.message:String(n)),...a?{path:a}:{},details:oi(n?.details)})}}function Xv(e){let t=e?.code;return typeof t=="string"&&t?t:null}function Yv(e){let t=e?.path;return typeof t=="string"&&t?t:null}function oi(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Zv(e){return oi(e)??{}}function Qv(e){let t=oi(e);return t&&Object.prototype.hasOwnProperty.call(t,"renderingConfig")?{renderingConfig:t.renderingConfig,response:oi(t.response)??{}}:{renderingConfig:e??{},response:{}}}function zE(e,t={}){let r=t.generatedBy??"scripts/register-asset.mjs",n=t.codeKeyPolicy??"legacy",o=e.filter(d=>d.codeKey);if(n==="disabled"&&o.length>0){let d=o[0];throw Object.assign(new Error("manifest_code_key_disabled"),{name:"PlayableEditorAssetCatalogGenerationError",details:{codeKeyPolicy:n,assetId:d.assetId,codeKey:d.codeKey}})}let a=e.map(d=>`import ${Kc(d.assetId)} from ${JSON.stringify(`${d.relativePath}?url`)};`).join(`
8
+ `),i=e.map(d=>{let u=_f(d.relativePath);if(!u)throw new Error(`Generated asset catalog entry has no file extension: ${d.assetId}`);if(!$f(u))throw new Error(`Generated asset catalog entry has unsupported format: ${d.assetId} (${u})`);let l=[`guid: ${JSON.stringify(d.guid)}`,`assetId: ${JSON.stringify(d.assetId)}`,`kind: ${JSON.stringify(d.kind)}`,`displayName: ${JSON.stringify(d.displayName)}`,`url: ${Kc(d.assetId)}`,`format: ${JSON.stringify(u)}`,`relativePath: ${JSON.stringify(d.relativePath)}`,d.originalFileName?`originalFileName: ${JSON.stringify(d.originalFileName)}`:"",d.codeKey?`codeKey: ${JSON.stringify(d.codeKey)}`:"",d.category?`category: ${JSON.stringify(d.category)}`:"",typeof d.placeable=="boolean"?`placeable: ${JSON.stringify(d.placeable)}`:"",typeof d.warmupCount=="number"?`warmupCount: ${JSON.stringify(d.warmupCount)}`:"",typeof d.singleton=="boolean"?`singleton: ${JSON.stringify(d.singleton)}`:"",d.materialMode?`materialMode: ${JSON.stringify(d.materialMode)}`:"",d.defaults?`defaults: ${JSON.stringify(d.defaults)}`:"",d.contentHash?`contentHash: ${JSON.stringify(d.contentHash)}`:"",typeof d.byteSize=="number"?`byteSize: ${JSON.stringify(d.byteSize)}`:"",d.external?`external: ${JSON.stringify(d.external)}`:"",d.metadata?`metadata: ${JSON.stringify(d.metadata)}`:"",d.createdAt?`createdAt: ${JSON.stringify(d.createdAt)}`:"",d.updatedAt?`updatedAt: ${JSON.stringify(d.updatedAt)}`:""].filter(Boolean).join(", ");return` ${JSON.stringify(d.assetId)}: { ${l} },`}).join(`
9
9
  `),s=new Map;for(let d of o)s.set(d.codeKey,d.assetId);let c=[...s].map(([d,u])=>` ${JSON.stringify(d)}: ${JSON.stringify(u)},`).join(`
10
10
  `);return[`// This file is generated by ${r}.`,"// Do not edit by hand.","",a,"",'export type GeneratedAssetCatalogKind = "model" | "texture" | "image" | "sound";',"","export interface GeneratedAssetCatalogEntry {"," guid: string;"," assetId: string;"," kind: GeneratedAssetCatalogKind;"," displayName: string;"," url: string;"," format: `.${string}`;"," relativePath: string;"," originalFileName?: string;",...n==="legacy"?[" /** @deprecated Use the canonical assetId for persisted and runtime identity. */"," codeKey?: string;"]:[]," category?: string;"," placeable?: boolean;"," warmupCount?: number;"," singleton?: boolean;"," materialMode?: string;"," defaults?: Record<string, unknown>;"," contentHash?: string;"," byteSize?: number;"," external?: { platformAssetId?: string; assetPath?: string; assetUrl?: string };"," metadata?: Record<string, unknown>;"," createdAt?: string;"," updatedAt?: string;","}","","export const GENERATED_ASSET_CATALOG: Record<string, GeneratedAssetCatalogEntry> = {",i,"};","","export const GENERATED_ASSET_URL_MAP = Object.fromEntries("," Object.entries(GENERATED_ASSET_CATALOG).map(([assetId, entry]) => [assetId, entry.url]),",") as Record<string, string>;","","export const GENERATED_MODEL_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "model").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","export const GENERATED_TEXTURE_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "texture").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","export const GENERATED_IMAGE_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "image").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","export const GENERATED_SOUND_ASSET_URL_MAP = Object.fromEntries(",' Object.entries(GENERATED_ASSET_CATALOG).filter(([, entry]) => entry.kind === "sound").map(([assetId, entry]) => [assetId, entry.url]),',") as Record<string, string>;","","/** @deprecated Resolve assets by canonical assetId through GENERATED_ASSET_CATALOG. */","export const ASSET_IDS = {",c,"} as const satisfies Record<string, string>;"].join(`
11
11
  `)+`
12
- `}import $m from"node:fs/promises";import lt from"node:path";var Lm=5;async function ci(e){let t={...e.existingMetadata??{},...e.payloadMetadata??{}},r=await VE(e);if(r?(t.assetAnalysis=r,t.assetAnalysisStatus="complete"):(delete t.assetAnalysis,t.assetAnalysisStatus="unavailable"),e.kind==="texture"||e.kind==="image"){let o=EG(e.sourcePath,t);return o&&(t.textureUsage=o.usage,t.capabilities={...be(t.capabilities)?t.capabilities:{},materialTexture:o.materialTexture,environmentTexture:o.environmentTexture}),Object.keys(t).length>0?t:null}if(e.kind!=="model")return Object.keys(t).length>0?t:null;t.assetMetadataVersion=Lm;let n=await UE(e.sourcePath,{assetGuid:e.guid,assetId:e.assetId,cwd:e.cwd,assetsDir:e.assetsDir,existingMaterialSlots:t.materialSlots});return n.length===0?delete t.materialSlots:t.materialSlots=n,Object.keys(t).length>0?t:null}async function VE(e){return e.kind==="model"?Zv(e.sourcePath):e.kind==="texture"||e.kind==="image"?Qv(e.sourcePath):null}async function UE(e,t={}){try{let r=await KE(e);return lG(r,{...t,sourcePath:e})}catch{return[]}}async function KE(e){let t=lt.extname(e).toLowerCase();if(t===".gltf")return JSON.parse(await $m.readFile(e,"utf8"));if(t!==".glb")return null;let r=await $m.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let a=12;for(;a+8<=r.length;){let i=r.readUInt32LE(a),s=r.readUInt32LE(a+4);if(a+=8,a+i>r.length)return null;if(s===1313821514){let c=r.toString("utf8",a,a+i).replace(/\0+$/g,"");return JSON.parse(c)}a+=i}return null}async function Zv(e){try{let t=await KE(e);if(!t||typeof t!="object")return null;let r=Array.isArray(t.scenes)?t.scenes:[],n=Array.isArray(t.nodes)?t.nodes:[],o=Array.isArray(t.meshes)?t.meshes:[],a=Array.isArray(t.materials)?t.materials:[],i=Array.isArray(t.textures)?t.textures:[],s=Array.isArray(t.images)?t.images:[],c=Array.isArray(t.animations)?t.animations:[],d=Array.isArray(t.skins)?t.skins:[],u=Array.isArray(t.accessors)?t.accessors:[],l=XE(t),m=YE(n),f=new Set(l),S=o.reduce((I,P)=>I+(Array.isArray(P?.primitives)?P.primitives.length:0),0),g=o.reduce((I,P)=>I+(Array.isArray(P?.primitives)?P.primitives.reduce((A,$)=>A+(Array.isArray($?.targets)?$.targets.length:0),0):0),0),b=oG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length}),y=aG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,complexity:b});return{kind:"gltf",format:lt.extname(e).toLowerCase()===".gltf"?"gltf":"glb",summary:`${n.length} nodes, ${o.length} meshes, ${S} primitives, ${a.length} materials`,complexity:b,sceneCount:r.length,nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,nodes:eG(n,o,a,u,m,f),meshes:tG(o,a,u),materials:rG(t),diagnostics:y}}catch{return null}}async function Qv(e){try{let t=await $m.readFile(e),r=lt.extname(e).toLowerCase(),n=r===".png"?iG(t):r===".jpg"||r===".jpeg"?sG(t):r===".webp"?cG(t):null;if(!n)return null;let o=dG(n);return{kind:"image",format:n.format,summary:`${n.width}x${n.height} ${n.mime}`,complexity:n.estimatedPixels>=4096*4096?"high":n.estimatedPixels>=2048*2048?"medium":"low",width:n.width,height:n.height,mime:n.mime,bitDepth:n.bitDepth,hasAlpha:n.hasAlpha,estimatedPixels:n.estimatedPixels,diagnostics:o}}catch{return null}}function eG(e,t,r,n,o,a){return e.slice(0,100).map((i,s)=>{let c=Number.isInteger(i?.mesh)?i.mesh:-1,d=c>=0&&c<t.length?t[c]:null,u=Array.isArray(i?.children)?i.children.filter(f=>Number.isInteger(f)):[],l=ZE(e,o,a,s),m={nodeIndex:s,nodeIndexPath:eI(o,s),...typeof i?.name=="string"&&i.name.trim()?{name:i.name.trim()}:{},...l?{ownerNodePath:l}:{},...u.length>0?{children:u}:{}};if(d){let f=HE(d,r,n);Object.assign(m,{meshIndex:c,...typeof d?.name=="string"&&d.name.trim()?{meshName:d.name.trim()}:{},primitiveCount:f.length,...f.length>0?{primitives:f}:{}})}return m})}function tG(e,t,r){return e.slice(0,50).map((n,o)=>{let a=Array.isArray(n?.primitives)?n.primitives:[],i=[...new Set(a.map(c=>Number.isInteger(c?.material)?c.material:-1).filter(c=>c>=0))],s=HE(n,t,r);return{meshIndex:o,...typeof n?.name=="string"&&n.name.trim()?{name:n.name.trim()}:{},primitiveCount:a.length,...s.length>0?{primitives:s}:{},...i.length>0?{materialIndices:i}:{},...i.length>0?{materialNames:i.map(c=>{let d=t[c];return typeof d?.name=="string"?d.name.trim():""}).filter(Boolean)}:{}}})}function HE(e,t,r){let n=be(e)?e:{};return(Array.isArray(n.primitives)?n.primitives:[]).map((a,i)=>{let s=Number.isInteger(a?.material)?a.material:-1,c=s>=0?t[s]:null,d=typeof c?.name=="string"&&c.name.trim()?c.name.trim():"",u=tI(a,r),l=rI(a,r);return{primitiveIndex:i,...Number.isInteger(a?.mode)?{mode:a.mode}:{},...s>=0?{sourceMaterialIndex:s}:{},...d?{materialName:d}:{},...Number.isFinite(u)?{triangleCount:u}:{},...l?{boundingBox:l}:{}}})}function rG(e){return(Array.isArray(e?.materials)?e.materials:[]).slice(0,50).map((r,n)=>{let o=r?.pbrMetallicRoughness&&typeof r.pbrMetallicRoughness=="object"?r.pbrMetallicRoughness:{},a=nG(r,o);return{sourceMaterialIndex:n,...typeof r?.name=="string"&&r.name.trim()?{materialName:r.name.trim()}:{},...Array.isArray(o.baseColorFactor)?{baseColorFactor:o.baseColorFactor.slice(0,4)}:{},metallicFactor:Number.isFinite(o.metallicFactor)?o.metallicFactor:1,roughnessFactor:Number.isFinite(o.roughnessFactor)?o.roughnessFactor:1,alphaMode:qE(r?.alphaMode)??"opaque",...Number.isFinite(r?.alphaCutoff)?{alphaCutoff:r.alphaCutoff}:{},...a.length>0?{textureSlots:a}:{}}})}function nG(e,t){let r=[];return ii(r,"baseColor",t?.baseColorTexture),ii(r,"metallicRoughness",t?.metallicRoughnessTexture),ii(r,"normal",e?.normalTexture),ii(r,"occlusion",e?.occlusionTexture),ii(r,"emissive",e?.emissiveTexture),r}function ii(e,t,r){!be(r)||!Number.isInteger(r.index)||e.push({slot:t,textureIndex:r.index,...Number.isFinite(r.texCoord)?{texCoord:r.texCoord}:{}})}function oG(e){return e.nodeCount>=300||e.meshCount>=250||e.primitiveCount>=300||e.materialCount>=200||e.textureCount>=80||e.imageCount>=80?"high":e.nodeCount>=100||e.meshCount>=80||e.primitiveCount>=100||e.materialCount>=50||e.textureCount>=24||e.imageCount>=24?"medium":"low"}function aG(e){let t=[];return e.complexity==="high"&&t.push({severity:"warning",source:"asset",code:"asset.analysis.highComplexity",message:"GLTF asset is structurally complex; agent should place and inspect it before duplicating or using dense shadows.",details:{nodeCount:e.nodeCount,meshCount:e.meshCount,primitiveCount:e.primitiveCount,materialCount:e.materialCount,textureCount:e.textureCount,imageCount:e.imageCount}}),(e.animationCount>0||e.skinCount>0||e.morphTargetCount>0)&&t.push({severity:"info",source:"asset",code:"asset.analysis.riggedOrAnimated",message:"GLTF asset contains animation, skin, or morph target data.",details:{animationCount:e.animationCount,skinCount:e.skinCount,morphTargetCount:e.morphTargetCount}}),t}function iG(e){if(e.length<33||e[0]!==137||e.toString("ascii",1,4)!=="PNG"||e[4]!==13||e[5]!==10||e[6]!==26||e[7]!==10||e.toString("ascii",12,16)!=="IHDR")return null;let r=e.readUInt32BE(16),n=e.readUInt32BE(20),o=e[24],a=e[25],i=!1,s=33;for(;s+12<=e.length;){let c=e.readUInt32BE(s),d=s+12+c;if(d>e.length)break;let u=e.toString("ascii",s+4,s+8);if(u==="tRNS"){i=!0;break}if(u==="IDAT"||u==="IEND")break;s=d}return{format:"png",mime:"image/png",width:r,height:n,bitDepth:o,hasAlpha:a===4||a===6||i,estimatedPixels:r*n}}function sG(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<e.length;){if(e[t]!==255){t+=1;continue}let r=e[t+1],n=e.readUInt16BE(t+2);if(n<2)return null;if(r>=192&&r<=207&&![196,200,204].includes(r)&&t+8<e.length){let a=e[t+4],i=e.readUInt16BE(t+5),s=e.readUInt16BE(t+7);return{format:"jpeg",mime:"image/jpeg",width:s,height:i,bitDepth:a,hasAlpha:!1,estimatedPixels:s*i}}t+=2+n}return null}function cG(e){if(e.length<30||e.toString("ascii",0,4)!=="RIFF"||e.toString("ascii",8,12)!=="WEBP")return null;let t=e.toString("ascii",12,16);if(t==="VP8X"&&e.length>=30){let r=e[20],n=LE(e,24)+1,o=LE(e,27)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:(r&16)!==0,estimatedPixels:n*o}}if(t==="VP8 "&&e.length>=30){let r=e.readUInt16LE(26)&16383,n=e.readUInt16LE(28)&16383;return{format:"webp",mime:"image/webp",width:r,height:n,hasAlpha:!1,estimatedPixels:r*n}}if(t==="VP8L"&&e.length>=25&&e[20]===47){let r=e.readUInt32LE(21),n=(r&16383)+1,o=(r>>14&16383)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:!0,estimatedPixels:n*o}}return null}function LE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16}function dG(e){let t=[];return e.estimatedPixels>=4096*4096&&t.push({severity:"warning",source:"asset",code:"asset.analysis.largeImage",message:"Image asset is large; agent should inspect texture usage before assigning it broadly.",details:{width:e.width,height:e.height,estimatedPixels:e.estimatedPixels}}),t}function lG(e,t={}){if(!e||typeof e!="object")return[];let r=Array.isArray(e.nodes)?e.nodes:[],n=Array.isArray(e.meshes)?e.meshes:[],o=Array.isArray(e.materials)?e.materials:[],a=mG(e,t),i=XE(e),s=YE(r),c=new Set(i),d=Array.isArray(e.accessors)?e.accessors:[],u=SG(t.existingMaterialSlots),l=[],m=new Map;for(let f=0;f<r.length;f+=1){let S=r[f],g=Number.isInteger(S?.mesh)?S.mesh:-1;if(g<0||g>=n.length)continue;let b=ZE(r,s,c,f);if(!b)continue;let y=n[g],E=Array.isArray(y?.primitives)?y.primitives:[],I=PG(S,y,b),P=QE(y),A=eI(s,f);for(let $=0;$<E.length;$+=1){let z=E[$],p=TG(z,o),D=JE({ownerNodePath:b,nodeIndex:f,meshIndex:g,primitiveIndex:$}),h=tI(z,d),R=rI(z,d),K=E.length>1?`${I} / Primitive ${$}`:I,ne={ownerNodePath:b,nodeIndex:f,nodeIndexPath:A,meshIndex:g,primitiveIndex:$,...P?{sourceMeshName:P}:{},...p.index>=0?{sourceMaterialIndex:p.index}:{},...Number.isFinite(h)?{triangleCount:h}:{},...R?{boundingBox:R}:{}};if(p.index>=0){let F=m.get(p.index)??{label:K,materialName:p.name,sourceSurfaces:[]};F.sourceSurfaces.push(ne),m.set(p.index,F);continue}l.push({slotId:u.byExactSource.get(D)??yG({assetGuid:t.assetGuid,assetId:t.assetId,nodeIndex:f,meshIndex:g,primitiveIndex:E.length>1?$:void 0}),label:K,sourceSurfaces:[ne]})}}for(let[f,S]of m){let g=S.sourceSurfaces.sort(WE);l.push({slotId:u.bySourceMaterialIndex.get(f)??hG({assetGuid:t.assetGuid,assetId:t.assetId,sourceMaterialIndex:f}),label:S.label,sourceSurfaces:g,...S.materialName?{materialName:S.materialName,materialNames:[S.materialName]}:{},...fG(a,[f])})}return l.sort(uG)}function uG(e,t){let r=Array.isArray(e.sourceSurfaces)?e.sourceSurfaces[0]:void 0,n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces[0]:void 0;return WE(r,n)}function WE(e,t){let r=String(e?.ownerNodePath??"").localeCompare(String(t?.ownerNodePath??""));if(r!==0)return r;let n=Number.isInteger(e?.nodeIndex)?e.nodeIndex:-1,o=Number.isInteger(t?.nodeIndex)?t.nodeIndex:-1;if(n!==o)return n-o;let a=Number.isInteger(e?.meshIndex)?e.meshIndex:-1,i=Number.isInteger(t?.meshIndex)?t.meshIndex:-1;if(a!==i)return a-i;let s=Number.isInteger(e?.primitiveIndex)?e.primitiveIndex:-1,c=Number.isInteger(t?.primitiveIndex)?t.primitiveIndex:-1;return s-c}function mG(e,t={}){let r=Array.isArray(e?.materials)?e.materials:[],n=[];for(let o=0;o<r.length;o+=1){let a=pG(e,o,t);a&&n.push(a)}return n}function fG(e,t){if(!t.length||!e.length)return{};let r=new Map(e.map(o=>[o.sourceMaterialIndex,o])),n=t.map(o=>r.get(o)).filter(Boolean);return n.length>0?{sourceMaterialProfiles:n}:{}}function pG(e,t,r={}){let n=Array.isArray(e?.materials)?e.materials[t]:null;if(!n||typeof n!="object")return null;let o={},a=[],i=n.pbrMetallicRoughness&&typeof n.pbrMetallicRoughness=="object"?n.pbrMetallicRoughness:{},s={},c=Array.isArray(i.baseColorFactor)?i.baseColorFactor:null,d=zE(c);d&&(s.color=d);let u=si(e,i.baseColorTexture,r,"baseColor.texture",s,"texture",a);Object.keys(s).length>0&&(o.baseColor={...s,brightness:1,saturation:1,contrast:1,hue:0});let l={};si(e,n.normalTexture,r,"normal.texture",l,"texture",a),Number.isFinite(n.normalTexture?.scale)?l.strength=n.normalTexture.scale:l.texture&&(l.strength=1),Object.keys(l).length>0&&(o.normal=l),o.metallic=Number.isFinite(i.metallicFactor)?i.metallicFactor:1,o.roughness=Number.isFinite(i.roughnessFactor)?i.roughnessFactor:1;let m={};si(e,i.metallicRoughnessTexture,r,"metallicRoughness.texture",m,"texture",a),Object.keys(m).length>0&&(o.metallicRoughness=m);let f={};si(e,n.occlusionTexture,r,"occlusion.texture",f,"texture",a),Number.isFinite(n.occlusionTexture?.strength)?f.strength=n.occlusionTexture.strength:f.texture&&(f.strength=1),Object.keys(f).length>0&&(o.occlusion=f);let S={},g=zE(Array.isArray(n.emissiveFactor)?n.emissiveFactor:null),b=g&&(g.r!==0||g.g!==0||g.b!==0);b&&(S.color=g),si(e,n.emissiveTexture,r,"emission.texture",S,"texture",a),b&&(S.intensity=1),Object.keys(S).length>0&&(o.emission=S);let y={},E=qE(n.alphaMode);if(E&&(y.mode=E),(E==="mask"||E==="blend")&&(c&&Number.isFinite(c[3])&&c[3]!==1&&(y.opacity=c[3]),Number.isFinite(n.alphaCutoff)?y.cutoff=n.alphaCutoff:E==="mask"&&(y.cutoff=.5),u.texture&&(y.texture=structuredClone(u.texture)),u.hint&&a.push({...u.hint,profilePath:"alpha.texture"})),Object.keys(y).length>0&&(o.alpha=y),Object.keys(o).length===0&&a.length===0)return null;let I=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";return{sourceMaterialIndex:t,...I?{materialName:I}:{},...Object.keys(o).length>0?{profile:o}:{},...a.length>0?{textureHints:a}:{}}}function zE(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?{r:t,g:r,b:n}:null}function qE(e){return e==="MASK"?"mask":e==="BLEND"?"blend":e==="OPAQUE"?"opaque":null}function si(e,t,r,n,o,a,i){let s=gG(e,t,r,n);return s.texture&&(o[a]=s.texture),s.hint&&i.push(s.hint),s}function gG(e,t,r,n){let o=be(t)?t:{},a=Number.isInteger(o.index)?o.index:-1;if(a<0)return{};let i=Array.isArray(e?.textures)?e.textures:[],s=Array.isArray(e?.images)?e.images:[],c=i[a],d=bG(c),u=d.imageIndex,l=u>=0?s[u]:null,m=typeof l?.uri=="string"?l.uri.trim():"",f=/^data:/i.test(m),S={profilePath:n,textureIndex:a,...u>=0?{imageIndex:u}:{},...d.previewImageIndex>=0?{previewImageIndex:d.previewImageIndex}:{},...m&&!f?{uri:m}:{},...Number.isInteger(l?.bufferView)?{bufferView:l.bufferView}:{},...typeof l?.mimeType=="string"&&l.mimeType.trim()?{mimeType:l.mimeType.trim()}:{}};if(l?.bufferView!=null)return{hint:{...S,reason:"embedded-texture"}};if(!m)return{hint:{...S,reason:"missing-image-uri"}};if(f)return{hint:{...S,reason:"embedded-texture"}};if(/^https?:\/\//i.test(m)||m.startsWith("/"))return{texture:{url:m}};let g=m;try{g=decodeURIComponent(m)}catch{return{hint:{...S,reason:"unresolved-external-texture"}}}let b=lt.dirname(String(r.sourcePath??"")),y=lt.resolve(b,g),E=r.assetsDir?lt.resolve(r.assetsDir):"",I=r.cwd?lt.resolve(r.cwd):"",P=E?lt.relative(E,y):"../";return E&&I&&P&&!P.startsWith("..")&&!lt.isAbsolute(P)?{texture:{url:`/${lt.relative(I,y).split(lt.sep).join("/")}`},hint:{...S,reason:"external-texture"}}:{hint:{...S,reason:"external-texture"}}}function bG(e){let t=be(e)?e:{},r=be(t.extensions)?t.extensions:{},n=Number.isInteger(t.source)?t.source:-1,o=be(r.KHR_texture_basisu)?r.KHR_texture_basisu:{};if(Number.isInteger(o.source))return{imageIndex:o.source,previewImageIndex:n>=0&&n!==o.source?n:-1};let a=be(r.EXT_texture_webp)?r.EXT_texture_webp:{};return Number.isInteger(a.source)?{imageIndex:a.source,previewImageIndex:-1}:{imageIndex:n,previewImageIndex:-1}}function SG(e){let t=new Map,r=new Map;if(!Array.isArray(e))return{byExactSource:t,bySourceMaterialIndex:new Map};for(let o of e){if(!be(o))continue;let a=Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[],i=typeof o.slotId=="string"?o.slotId.trim():"";if(!i)continue;let s=new Set;for(let c of a){if(!be(c))continue;let d=typeof c.ownerNodePath=="string"?c.ownerNodePath.trim().replace(/^\/+|\/+$/g,""):"",u=Number.isInteger(c.nodeIndex)?c.nodeIndex:-1,l=Number.isInteger(c.meshIndex)?c.meshIndex:-1,m=Number.isInteger(c.primitiveIndex)?c.primitiveIndex:-1;a.length===1&&d&&u>=0&&l>=0&&m>=0&&t.set(JE({ownerNodePath:d,nodeIndex:u,meshIndex:l,primitiveIndex:m}),i),Number.isInteger(c.sourceMaterialIndex)&&c.sourceMaterialIndex>=0&&s.add(c.sourceMaterialIndex)}if(s.size===1){let[c]=s,d=r.get(c)??[];d.push(i),r.set(c,d)}}let n=new Map;for(let[o,a]of r)a.length===1&&n.set(o,a[0]);return{byExactSource:t,bySourceMaterialIndex:n}}function JE(e){return[e.ownerNodePath,e.nodeIndex,e.meshIndex,e.primitiveIndex].join("\0")}function yG(e){let t=Number.isInteger(e.primitiveIndex)?`:${e.primitiveIndex}`:"",r=`${e.assetGuid||e.assetId||"asset"}:${e.nodeIndex}:${e.meshIndex}${t}`;return`slot_${oI(r)}`}function hG(e){let t=`${e.assetGuid||e.assetId||"asset"}:material:${e.sourceMaterialIndex}`;return`slot_${oI(t)}`}function EG(e,t){if(t.textureUsage==="material"||t.usage==="material")return{usage:"material",materialTexture:!0,environmentTexture:!1};if(be(t.capabilities)&&t.capabilities.materialTexture===!0)return{usage:"material",materialTexture:!0,environmentTexture:!1};if(t.textureUsage==="environment"||t.usage==="environment")return{usage:"environment",materialTexture:!1,environmentTexture:!0};if(be(t.capabilities)&&t.capabilities.environmentTexture===!0)return{usage:"environment",materialTexture:!1,environmentTexture:!0};let r=lt.extname(e).toLowerCase();return[".env",".hdr",".dds",".ktx",".ktx2"].includes(r)?{usage:"environment",materialTexture:!1,environmentTexture:!0}:[".png",".jpg",".jpeg",".webp"].includes(r)?{usage:"material",materialTexture:!0,environmentTexture:!1}:null}function XE(e){let t=Array.isArray(e.scenes)?e.scenes:[],r=Number.isInteger(e.scene)?e.scene:0,n=t[r]??t[0];return Array.isArray(n?.nodes)?n.nodes.filter(Number.isInteger):[]}function YE(e){let t=new Map;for(let r=0;r<e.length;r+=1){let n=Array.isArray(e[r]?.children)?e[r].children:[];for(let o of n)Number.isInteger(o)&&!t.has(o)&&t.set(o,r)}return t}function ZE(e,t,r,n){let o=[],a=n,i=new Set;for(;Number.isInteger(a)&&a>=0&&a<e.length;){if(i.has(a))return"";i.add(a),o.push(IG(e[a],a));let s=t.get(a);if(typeof s!="number"||!Number.isInteger(s))break;a=s}return o.reverse(),o.length>1&&r.has(a)&&o.shift(),o.filter(Boolean).join("/")}function IG(e,t){return(be(e)&&typeof e.name=="string"?e.name.trim():"")||`node_${t}`}function PG(e,t,r){let n=be(e)&&typeof e.name=="string"?e.name.trim():"",o=QE(t);return n||o||r.split("/").filter(Boolean).pop()||r}function QE(e){return be(e)&&typeof e.name=="string"?e.name.trim():""}function eI(e,t){let r=[],n=t,o=new Set;for(;Number.isInteger(n)&&n>=0;){if(o.has(n))return[];o.add(n),r.push(n);let a=e.get(n);if(!Number.isInteger(a))break;n=a}return r.reverse(),r}function TG(e,t){let r=be(e)?e:{},n=Number.isInteger(r.material)?r.material:-1,o=n>=0?t[n]:null,a=typeof o?.name=="string"&&o.name.trim()?o.name.trim():"";return{index:n,name:a}}function tI(e,t){let r=be(e)?e:{},n=Number.isInteger(r.indices)?r.indices:-1,o=nI(r),a=n>=0?t[n]:null,i=o>=0?t[o]:null,s=Number.isFinite(a?.count)?Number(a.count):Number.isFinite(i?.count)?Number(i.count):null;if(s==null)return null;let c=Number.isInteger(r.mode)?r.mode:4;return c===4?Math.floor(s/3):c===5||c===6?Math.max(0,s-2):0}function rI(e,t){let r=be(e)?e:{},n=nI(r),o=n>=0?t[n]:null,a=BE(o?.min),i=BE(o?.max);return a&&i?{min:a,max:i}:null}function nI(e){let t=be(e.attributes)?e.attributes:{};return Number.isInteger(t.POSITION)?t.POSITION:-1}function BE(e){if(!Array.isArray(e)||e.length<3)return null;let t=Number(e[0]),r=Number(e[1]),n=Number(e[2]);return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?[t,r,n]:null}function be(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function oI(e){let t=String(e??""),r=2166136261;for(let n=0;n<t.length;n+=1)r^=t.charCodeAt(n),r=Math.imul(r,16777619);return(r>>>0).toString(16).padStart(8,"0")}import Qc from"node:crypto";import{constants as kG}from"node:fs";import W from"node:fs/promises";import v from"node:path";import di from"node:fs/promises";import Ot from"node:path";async function iI(e,t={}){try{let r=await xG(e);if(!r)return[];let n=Array.isArray(r.gltf.images)?r.gltf.images:[],o=t.imageIndexes?new Set(t.imageIndexes.filter(i=>Number.isInteger(i)&&i>=0)):null,a=[];for(let i=0;i<n.length;i+=1){if(o&&!o.has(i))continue;let s=ut(n[i]);if(!s)continue;let c=await AG(e,r,s);if(!c)continue;let d=li(s.name)??(c.originalFileName?Ot.parse(c.originalFileName).name:null)??void 0;a.push({imageIndex:i,bytes:c.bytes,extension:c.extension,mimeType:c.mimeType,...d?{displayName:d}:{},...c.originalFileName?{originalFileName:c.originalFileName}:{}})}return a}catch{return[]}}function sI(e){let t=new Set;for(let r of dI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n!=null&&t.add(n),o!=null&&t.add(o)}return[...t].sort((r,n)=>r-n)}function cI(e){let t=new Map;for(let r of dI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n==null||o==null||n===o||t.set(`${n}:${o}`,{imageIndex:n,previewImageIndex:o})}return[...t.values()].sort((r,n)=>r.imageIndex-n.imageIndex||r.previewImageIndex-n.previewImageIndex)}function dI(e){if(!e)return[];let t=[],r=Array.isArray(e.materialSlots)?e.materialSlots:[];for(let n of r){let o=ut(n),a=Array.isArray(o?.sourceMaterialProfiles)?o.sourceMaterialProfiles:[];for(let i of a){let s=ut(i),c=Array.isArray(s?.textureHints)?s.textureHints:[];for(let d of c){let u=ut(d);u&&t.push(u)}}}return t}function lI(e,t){if(!e||t.length===0)return e;let r=new Map(t.map(i=>[i.imageIndex,i.textureAssetId])),n=structuredClone(e),o=Array.isArray(n.materialSlots)?n.materialSlots:[],a=!1;for(let i of o){let s=ut(i),c=Array.isArray(s?.sourceMaterialProfiles)?s.sourceMaterialProfiles:[];for(let d of c){let u=ut(d);if(!u)continue;let l=Array.isArray(u.textureHints)?u.textureHints:[];if(l.length===0)continue;let m=[];for(let f of l){let S=ut(f),g=hr(S?.imageIndex),b=li(S?.profilePath),y=g==null?null:r.get(g)??null;if(!y||!b||!MG(b)){m.push(f);continue}let E=ut(u.profile)??{};wG(E,b,{textureAssetId:y}),u.profile=E,a=!0}m.length>0?u.textureHints=m:delete u.textureHints}}return a?n:e}async function xG(e){let t=Ot.extname(e).toLowerCase();if(t===".gltf"){let c=JSON.parse(await di.readFile(e,"utf8")),d=await Promise.all((Array.isArray(c.buffers)?c.buffers:[]).map(u=>aI(e,ut(u))));return{gltf:c,buffers:d}}if(t!==".glb")return null;let r=await di.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let n=null,o=[],a=12;for(;a+8<=r.length;){let c=r.readUInt32LE(a),d=r.readUInt32LE(a+4);if(a+=8,a+c>r.length)return null;let u=r.subarray(a,a+c);d===1313821514?n=JSON.parse(u.toString("utf8").replace(/\0+$/g,"")):d===5130562&&o.push(Buffer.from(u)),a+=c}if(!n)return null;let i=Array.isArray(n.buffers)?n.buffers:[],s=await Promise.all(i.map(async(c,d)=>{let u=ut(c);return li(u?.uri)?aI(e,u):o[d]??(d===0?o[0]??null:null)}));return s.length===0&&o.length>0&&s.push(o[0]),{gltf:n,buffers:s}}async function aI(e,t){let r=li(t?.uri);if(!r)return null;let n=fI(r);if(n)return n.bytes;if(Bm(r))return null;let o=mI(r);return o?uI(e,o):null}async function AG(e,t,r){let n=li(r.uri);if(n){let f=fI(n);if(f){let E=zm(f.bytes);return E?{bytes:f.bytes,...E}:null}if(Bm(n))return null;let S=mI(n);if(!S)return null;let g=await uI(e,S);if(!g)return null;let b=Ot.basename(S),y=zm(g);return y?{bytes:g,...y,originalFileName:b}:null}let o=hr(r.bufferView);if(o==null)return null;let a=Array.isArray(t.gltf.bufferViews)?t.gltf.bufferViews:[],i=ut(a[o]),s=hr(i?.buffer)??0,c=t.buffers[s],d=hr(i?.byteOffset)??0,u=hr(i?.byteLength);if(!c||u==null||d+u>c.length)return null;let l=Buffer.from(c.subarray(d,d+u)),m=zm(l);return m?{bytes:l,...m}:null}async function uI(e,t){if(Ot.isAbsolute(t)||Ot.win32.isAbsolute(t)||t.includes("\0"))return null;try{let r=await di.realpath(Ot.dirname(e)),n=Ot.resolve(r,t),o=await di.realpath(n);return DG(r,o)?await di.readFile(o):null}catch{return null}}function mI(e){if(Bm(e))return null;try{return decodeURIComponent(e)}catch{return null}}function DG(e,t){let r=Ot.relative(e,t);return r===""||!r.startsWith(`..${Ot.sep}`)&&r!==".."&&!Ot.isAbsolute(r)}function fI(e){let t=/^data:([^;,]+)?(?:;[^,]*)?,(.*)$/is.exec(e);if(!t)return null;let r=e.slice(0,e.indexOf(","));try{return{bytes:r.toLowerCase().includes(";base64")?Buffer.from(t[2]??"","base64"):Buffer.from(decodeURIComponent(t[2]??""),"utf8")}}catch{return null}}function zm(e){return e.length>=8&&e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))?{extension:".png",mimeType:"image/png"}:e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?{extension:".jpg",mimeType:"image/jpeg"}:e.length>=12&&e.toString("ascii",0,4)==="RIFF"&&e.toString("ascii",8,12)==="WEBP"?{extension:".webp",mimeType:"image/webp"}:e.length>=12&&e.subarray(0,12).equals(Buffer.from([171,75,84,88,32,50,48,187,13,10,26,10]))?{extension:".ktx2",mimeType:"image/ktx2"}:null}function MG(e){return["baseColor.texture","normal.texture","metallicRoughness.texture","occlusion.texture","emission.texture","emission.maskTexture","alpha.texture"].includes(e)}function wG(e,t,r){let n=t.split("."),o=e;for(let a=0;a<n.length-1;a+=1){let i=n[a],s=ut(o[i])??{};o[i]=s,o=s}o[n[n.length-1]]=r}function Bm(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("/")||Ot.win32.isAbsolute(e)}function ut(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function li(e){return typeof e=="string"&&e.trim()?e.trim():null}function hr(e){return Number.isInteger(e)&&e>=0?e:null}var U=class extends Error{constructor(t,r={}){super(t),this.name="PlayableEditorAssetRegistryError",this.details=r}};async function No(e,t,r={}){if(!t.payload&&!t.payloadData)throw new U("missing_payload_arg");let n=await LG(e,t),o=e.codeKeyPolicy??"legacy";if(o==="disabled"&&Object.prototype.hasOwnProperty.call(n,"codeKey"))throw new U("payload_code_key_disabled",{codeKeyPolicy:o,codeKey:n.codeKey});let a=v.resolve(e.cwd,String(n.sourcePath??n.assetPath??"")),i=vG(e,a);if(!i)throw new U(e.unsupportedSourceErrorCode??r.sourceMustBeSupportedAsset??"source_must_be_supported_asset",{sourcePath:a,supportedExtensions:EI(e)});try{await W.access(a,kG.R_OK)}catch(h){let R=jo(h)?h.code:void 0,K=R==="EACCES"||R==="EPERM"?"source_file_unreadable":r.sourceFileNotFound??"source_file_not_found";throw new U(K,{sourcePath:a,...R?{nodeCode:R}:{}})}let s=VG(n);await W.mkdir(e.generatedDir,{recursive:!0});let c=await Zt(e),d=await Ym(a),u=Hc(n.kind??n.assetKind??n.assetType,a);if(!u)throw new U("unsupported_asset_kind",{sourcePath:a,assetType:n.assetType});Wm(u,a,"source_path");let l=BG(c,n,s,a,d,u,e),m=ae(n.assetName)??l?.originalFileName??v.basename(a),f=ae(n.guid);if(l&&f&&l.guid!==f)throw new U("payload_guid_must_match_existing_asset",{guid:f,existingGuid:l.guid,existingAssetId:l.assetId});let S=l?.guid??f??Qc.randomUUID(),g=ae(n.projectAssetId),b=Uc(u,S);if(l?.assetId&&l.assetId!==b)throw new U("manifest_asset_id_must_match_guid",{guid:S,assetId:l.assetId,expectedAssetId:b});if(g&&g!==b)throw new U("project_asset_id_must_match_guid",{guid:S,projectAssetId:g,expectedAssetId:b});let y=i===".gltf"?v.posix.join(b,v.basename(a)):`${b}${i}`,E=GG(e,{existing:l,sourcePath:a,kind:u,targetFileName:y}),I=mi(e,E,u,"target_path"),P=new Date().toISOString(),A=Sm(ae(n.displayName)??l?.displayName,m),$=Zc({...Zc(l?.external)??{},...s??{}}),z=!1,p=[],D=null;try{await W.mkdir(v.dirname(I),{recursive:!0});let h=NG(a,I),R=h||await TI(I),K=!l||l.contentHash!==d.contentHash||!R;!h&&K&&(await W.copyFile(a,I),z=!l,i===".gltf"&&await OG(a,I));let F=await PI(e,{existing:l,payload:n,sourcePath:a,targetPath:I,kind:u,guid:S,assetId:b}),Ir=Ke(l?.metadata),er=Ke(F);if(u==="model"&&(Ir.assetAnalysisStatus==="complete"||Object.keys(Ke(Ir.assetAnalysis)).length>0)&&er.assetAnalysisStatus==="unavailable")throw new U("source_asset_analysis_failed",{sourcePath:a,assetId:b,guid:S});if(u==="model"){let tr=await RG({config:e,manifest:c,metadata:F,sourcePath:a,sourceAssetId:b,sourceAssetGuid:S,sourceDisplayName:A,now:P});p=tr.createdPaths,F=lI(F,tr.references)}let Hr=Jm({...l??{},guid:S,assetId:b,kind:u,displayName:A,relativePath:E,originalFileName:m,...o==="legacy"?{codeKey:ym(ae(n.codeKey)??ae(n.assetName)??l?.codeKey,m)}:{},...ae(n.category)?{category:ae(n.category)}:{},placeable:u==="texture"?!0:typeof n.placeable=="boolean"?n.placeable:l?.placeable??u==="model",...Tm(n.warmupCount)!=null?{warmupCount:Tm(n.warmupCount)}:{},...typeof n.singleton=="boolean"?{singleton:n.singleton}:{},...Pm(n.materialMode)?{materialMode:Pm(n.materialMode)}:{},...Im(n.scale)?{defaults:{transform:{scale:Im(n.scale)}}}:{},contentHash:d.contentHash,byteSize:d.byteSize,external:$,metadata:F,createdAt:l?.createdAt??P,updatedAt:K?P:l?.updatedAt??P});if(!Hr)throw new U("invalid_manifest_entry",{assetId:b,guid:S});D=Hr;let yi=c.findIndex(tr=>tr.guid===S||tr.assetId===b);yi>=0?c[yi]=Hr:c.push(Hr),c.sort(HG),await XG(e,c)}catch(h){z&&await W.rm(i===".gltf"?v.dirname(I):I,{recursive:i===".gltf",force:!0}).catch(()=>{});for(let R of p)await W.rm(R,{force:!0}).catch(()=>{});throw h}return{ok:!0,guid:S,assetId:b,kind:u,...D?.contentHash?{contentHash:D.contentHash}:{},...D?.external?{external:D.external}:{},displayName:D?.displayName,originalFileName:D?.originalFileName,assetUrl:$G(e,E,u),targetPath:I,manifestPath:e.manifestPath,registryPath:e.registryPath}}async function OG(e,t){let r;try{r=JSON.parse(await W.readFile(e,"utf8"))}catch{throw new U("gltf_source_invalid_json")}let n=v.dirname(await W.realpath(e)),o=v.dirname(t),a=[...Array.isArray(r.buffers)?r.buffers:[],...Array.isArray(r.images)?r.images:[]],i=new Set;for(let s of a){let c=ae(Ke(s)?.uri);if(!c||c.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(c)||c.startsWith("//"))continue;let d;try{d=decodeURIComponent(c.split(/[?#]/,1)[0])}catch{continue}let u=d.replace(/\\/g,"/"),l=v.posix.normalize(u);if(!l||l==="."||l===".."||l.startsWith("../")||v.posix.isAbsolute(l)||i.has(l))continue;i.add(l);let m;try{m=await W.realpath(v.resolve(n,...l.split("/")))}catch{continue}try{Vm(n,m,"gltf_dependency_path_escape")}catch{continue}let f=v.resolve(o,...l.split("/"));Vm(o,f,"gltf_dependency_target_escape"),await W.mkdir(v.dirname(f),{recursive:!0}),await W.copyFile(m,f)}}function Vm(e,t,r){let n=v.relative(e,t);if(!n||n===".."||n.startsWith(`..${v.sep}`)||v.isAbsolute(n))throw new U(r)}async function RG(e){let t=sI(e.metadata),r=cI(e.metadata),n=await iI(e.sourcePath,{imageIndexes:t}),o=[],a=new Map,i=[];try{for(let d of n){let u=ui(d.bytes),l=e.manifest.find(A=>A.kind==="texture"&&A.contentHash===u.contentHash&&Ke(Ke(A.metadata).capabilities).materialTexture!==!1&&Ke(A.metadata).textureUsage!=="environment");if(l){a.set(d.imageIndex,l),o.push({imageIndex:d.imageIndex,textureAssetId:l.assetId});continue}let m=qG(u.contentHash),f=Uc("texture",m),S=e.manifest.find(A=>A.guid===m||A.assetId===f);if(S)throw new U("derived_texture_identity_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,contentHash:u.contentHash,conflictingAssetId:S.assetId,conflictingContentHash:S.contentHash});let g=`${f}${d.extension}`,b=II(e.config,"texture",g),y=mi(e.config,b,"texture","derived_texture_target_path");if(await W.mkdir(v.dirname(y),{recursive:!0}),await TI(y)){let A=await Ym(y);if(A.contentHash!==u.contentHash)throw new U("derived_texture_target_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,targetPath:y,contentHash:u.contentHash,existingContentHash:A.contentHash})}else await WG(y,d.bytes),i.push(y);let E=d.displayName?`${e.sourceDisplayName} / ${d.displayName}`:`${e.sourceDisplayName} Texture ${d.imageIndex+1}`,I=await PI(e.config,{existing:null,payload:{metadata:{textureUsage:"material",capabilities:{materialTexture:!0,environmentTexture:!1},derivedFrom:{kind:"gltf-image",sourceAssetId:e.sourceAssetId,sourceAssetGuid:e.sourceAssetGuid,imageIndex:d.imageIndex,mimeType:d.mimeType}}},sourcePath:y,targetPath:y,kind:"texture",guid:m,assetId:f}),P=Jm({guid:m,assetId:f,kind:"texture",displayName:E,relativePath:b,originalFileName:d.originalFileName??`${JG(E)}${d.extension}`,category:"Texture",placeable:!0,contentHash:u.contentHash,byteSize:u.byteSize,metadata:I,createdAt:e.now,updatedAt:e.now});if(!P)throw new U("invalid_derived_texture_manifest_entry",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f});e.manifest.push(P),a.set(d.imageIndex,P),o.push({imageIndex:d.imageIndex,textureAssetId:f})}let s=new Map,c=new Map;for(let d of a.values())v.extname(d.relativePath).toLowerCase()===".ktx2"&&s.set(d.assetId,d);for(let d of r){let u=a.get(d.imageIndex),l=a.get(d.previewImageIndex);!u||!l||v.extname(u.relativePath).toLowerCase()!==".ktx2"||c.set(u.assetId,l.assetId)}for(let d of s.values()){let u=Ke(d.metadata),l=CG(u);delete l[e.sourceAssetId];let m=c.get(d.assetId);m&&(l[e.sourceAssetId]=m);let f=Object.fromEntries(Object.entries(l).sort(([b],[y])=>b.localeCompare(y))),S=Object.values(f)[0],g={...u};S?(g.previewTextureAssetId=S,g.previewTextureAssetIdsBySourceAssetId=f):(delete g.previewTextureAssetId,delete g.previewTextureAssetIdsBySourceAssetId),d.metadata=g}return{references:o,createdPaths:i}}catch(s){for(let c of i)await W.rm(c,{force:!0}).catch(()=>{});throw s}}function CG(e){let t={},r=Ke(e.previewTextureAssetIdsBySourceAssetId);for(let[a,i]of Object.entries(r)){let s=ae(a),c=ae(i);s&&c&&(t[s]=c)}if(Object.keys(t).length>0)return t;let n=ae(e.previewTextureAssetId),o=ae(Ke(e.derivedFrom).sourceAssetId);return n&&o&&(t[o]=n),t}async function Km(e,t={}){let r=await hI(e,t,!1),{availabilityIssues:n,...o}=r;return o}async function Hm(e,t={}){return hI(e,t,!0)}async function hI(e,t,r){let n=await Zt(e),o=[],a=[];for(let i of n){let s=mi(e,i.relativePath,i.kind,"refresh_source_path"),c;try{c=await Ym(s)}catch(m){let f=pI(i,m,t,"source-audit",s);if(!r||!f)throw gI(f,m,s);a.push(f);continue}let d=i.kind==="model"&&Ke(i.metadata).assetMetadataVersion!==Lm,u=i.kind==="texture"&&i.placeable===!1;if(i.contentHash===c.contentHash&&i.byteSize===c.byteSize&&!d&&!u)continue;let l;try{l=await No(e,{payloadData:{sourcePath:s,guid:i.guid,projectAssetId:i.assetId,kind:i.kind}},t)}catch(m){let f=pI(i,m,t,"source-analysis",s);if(!r||!f)throw gI(f,m,s);a.push(f);continue}if(!l.contentHash)throw new U("asset_refresh_missing_content_hash",{assetId:i.assetId,guid:i.guid,sourcePath:s});o.push({guid:i.guid,assetId:i.assetId,kind:i.kind,...i.contentHash?{previousContentHash:i.contentHash}:{},contentHash:l.contentHash})}return{ok:!0,scannedAssetCount:n.length,refreshedAssets:o,availabilityIssues:a}}function pI(e,t,r,n,o){let a=r.sourceFileNotFound??"source_file_not_found",i=t instanceof U?t.message:void 0,s=jo(t)?t.code:t instanceof U?ae(t.details.nodeCode):void 0,c=i===a||i==="source_file_not_found"||i==="source_file_unreadable"||i==="source_asset_analysis_failed"||i==="gltf_source_invalid_json",d=jo(t)&&typeof t.path=="string"?v.resolve(t.path):null;if(!c&&(!s||n!=="source-audit"&&d!==v.resolve(o)))return null;let u=i==="source_asset_analysis_failed"?"analysis-failed":i==="gltf_source_invalid_json"?"invalid":s==="ENOENT"||i===a||i==="source_file_not_found"?"missing":s==="EACCES"||s==="EPERM"||i==="source_file_unreadable"?"unreadable":s==="EISDIR"||s==="EINVAL"?"invalid":"audit-failed",l=i??(u==="missing"?a:u==="unreadable"?"source_file_unreadable":u==="invalid"?"source_file_invalid":"source_file_audit_failed");return{assetId:e.assetId,guid:e.guid,kind:e.kind,relativePath:e.relativePath,stage:n,reason:u,code:l,...s?{nodeCode:s}:{},retryable:!0}}function gI(e,t,r){return!e||t instanceof U?t:new U(e.code,{assetId:e.assetId,guid:e.guid,sourcePath:r,...e.nodeCode?{nodeCode:e.nodeCode}:{}})}async function Zt(e){let t=await qm(e.manifestPath,[]);if(!Array.isArray(t))throw new U("manifest_invalid_root",{manifestPath:e.manifestPath});let r=t.map((i,s)=>{let c=Jm(i,!0);if(!c)throw new U("manifest_invalid_entry",{index:s,manifestPath:e.manifestPath});return c}),n=new Set,o=new Set,a=e.codeKeyPolicy??"legacy";for(let i of r){if(a==="disabled"&&i.codeKey)throw new U("manifest_code_key_disabled",{manifestPath:e.manifestPath,codeKeyPolicy:a,assetId:i.assetId,codeKey:i.codeKey});if(n.has(i.assetId))throw new U("manifest_duplicate_asset_id",{assetId:i.assetId});if(o.has(i.guid))throw new U("manifest_duplicate_guid",{guid:i.guid});n.add(i.assetId),o.add(i.guid)}return r}async function Fo(e){return e.loadRules?e.loadRules():e.rulesPath?qm(e.rulesPath,{}):{}}function bI(e){return(Array.isArray(e)?e:[e]).filter(r=>typeof r=="string"&&!!r.trim()).map(r=>{let n=r.trim().toLowerCase();return n.startsWith(".")?n:`.${n}`})}function EI(e){let t=bI(e.supportedExtensions??e.supportedExtension);return t.length>0?t:bI(Ro)}function vG(e,t){let r=t.toLowerCase();return EI(e).find(n=>r.endsWith(n))??null}function GG(e,t){return t.existing?.relativePath?t.existing.relativePath:jG(e,t.sourcePath,t.kind)??II(e,t.kind,t.targetFileName)}function II(e,t,r){let n=e.relativeImportedPath;return n.length>=2?n(t,r):n({kind:t,fileName:r})}function jG(e,t,r){let n=e.assetRootDir??e.assetsDir;if(!n)return null;let o=v.resolve(t);return!SI(v.resolve(n),o)||SI(v.resolve(e.generatedDir),o)?null:(Wm(r,o,"source_path"),v.relative(e.generatedDir,o).split(v.sep).join("/"))}function SI(e,t){let r=v.relative(e,t);return r===""||!r.startsWith("..")&&!v.isAbsolute(r)}function NG(e,t){return v.relative(v.resolve(e),v.resolve(t))===""}function FG(e,t,r){let n=v.relative(e,t);if(n.startsWith("..")||v.isAbsolute(n))throw new U(`${r}_outside_allowed_directory`,{parent:e,child:t})}function _G(e,t,r){let n=v.relative(e,t);if(!n.startsWith("..")&&!v.isAbsolute(n))throw new U(`${r}_inside_forbidden_directory`,{parent:e,child:t})}function mi(e,t,r,n){let o=v.resolve(e.generatedDir,t),a=v.resolve(e.assetRootDir??e.assetsDir??e.importedDir??e.generatedDir);return FG(a,o,n),_G(v.resolve(e.generatedDir),o,n),Wm(r,o,n),o}function $G(e,t,r){let n=mi(e,t,r,"asset_url_path");return typeof e.publicUrlForCatalogRelativePath=="function"?e.publicUrlForCatalogRelativePath(t):typeof e.publicUrlForRelativePath=="function"?e.publicUrlForRelativePath(t):`/${v.relative(e.cwd,n).split(v.sep).join("/")}`}function Wm(e,t,r){let n=v.extname(t).toLowerCase(),o=hm(e);if(!o.includes(n))throw new U(`${r}_unsupported_extension`,{kind:e,filePath:t,extension:n,supportedExtensions:o})}async function qm(e,t){try{return JSON.parse(await W.readFile(e,"utf8"))}catch(r){if(jo(r)&&r.code==="ENOENT")return t;throw r}}async function LG(e,t){if(t.payloadData)return structuredClone(t.payloadData);if(!t.payload)return{};let r=v.resolve(e.cwd,t.payload),n=await qm(r,null);if(!n||typeof n!="object"||Array.isArray(n))throw new U("invalid_payload_json",{payloadPath:r});return n}function Jm(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=t?Xm:ae,o=n(r.guid),a=n(r.assetId),i=n(r.kind);if(t&&(!i||"assetKind"in r||"assetType"in r))return null;let s=t?pm.includes(i)?i:null:Hc(r.kind??r.assetKind??r.assetType,r.relativePath),c=n(r.displayName),d=n(r.relativePath);if(!o||!a||!s||!c||!d||t&&(!Gn(r,"originalFileName")||!Gn(r,"codeKey")||!Gn(r,"category")||!Gn(r,"materialMode")||!Gn(r,"contentHash")||!Gn(r,"createdAt")||!Gn(r,"updatedAt")||"placeable"in r&&typeof r.placeable!="boolean"||"warmupCount"in r&&(!Number.isInteger(r.warmupCount)||r.warmupCount<0)||"singleton"in r&&typeof r.singleton!="boolean"||"defaults"in r&&Vr(r.defaults)==null||"byteSize"in r&&(!Number.isFinite(r.byteSize)||r.byteSize<0)||"metadata"in r&&Vr(r.metadata)==null||"external"in r&&!zG(r.external)))return null;let u=Vr(r.metadata),l=n(r.originalFileName),m=n(r.codeKey),f=n(r.category),S=n(r.materialMode),g=Vr(r.defaults),b=n(r.contentHash),y=Zc(r.external),E=n(r.createdAt),I=n(r.updatedAt);return{guid:o,assetId:a,kind:s,displayName:c,relativePath:d,...l?{originalFileName:l}:{},...m?{codeKey:m}:{},...f?{category:f}:{},...typeof r.placeable=="boolean"?{placeable:r.placeable}:{},...typeof r.warmupCount=="number"?{warmupCount:r.warmupCount}:{},...typeof r.singleton=="boolean"?{singleton:r.singleton}:{},...S?{materialMode:S}:{},...g?{defaults:g}:{},...b?{contentHash:b}:{},...typeof r.byteSize=="number"?{byteSize:r.byteSize}:{},...y?{external:y}:{},...u?{metadata:u}:{},...E?{createdAt:E}:{},...I?{updatedAt:I}:{}}}function Xm(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function Gn(e,t){return!(t in e)||Xm(e[t])!=null}function zG(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e,r=["platformAssetId","assetPath","assetUrl"],n=Object.keys(t);return n.length>0&&n.every(o=>r.includes(o)&&Xm(t[o])!=null)}function Zc(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=ae(r.platformAssetId),o;try{if(o=qa(r.assetPath),t&&Object.prototype.hasOwnProperty.call(r,"assetPath")&&!o)throw new Error("external_asset_path_must_be_portable")}catch{if(t)throw new U("external_asset_path_must_be_portable",{assetPath:ae(r.assetPath)})}let a=ae(r.assetUrl);return!n&&!o&&!a?null:{...n?{platformAssetId:n}:{},...o?{assetPath:o}:{},...a?{assetUrl:a}:{}}}function Vr(e){return!e||typeof e!="object"||Array.isArray(e)?null:structuredClone(e)}async function PI(e,t){let r=Vr(t.payload?.metadata);if(typeof e.resolveAssetMetadata=="function"){let n=await e.resolveAssetMetadata({...t,existingMetadata:Vr(t.existing?.metadata),payloadMetadata:r}),o=Vr(n);return o||null}return ci({kind:t.kind,sourcePath:t.sourcePath,existingMetadata:Vr(t.existing?.metadata),payloadMetadata:r,guid:t.guid,assetId:t.assetId,cwd:e.cwd,assetsDir:e.assetsDir})}function BG(e,t,r,n,o,a,i){let s=ae(t.guid),c=ae(t.projectAssetId);if(s){let l=e.find(m=>m.guid===s);if(l)return l}if(c){let l=e.find(m=>m.assetId===c);if(l)return l}if(r?.platformAssetId){let l=e.find(m=>m.kind===a&&UG(m.external)===r.platformAssetId);if(l)return l}if(r?.assetPath){let l=e.find(m=>m.kind===a&&KG(m.external)===r.assetPath);if(l)return l}let d=v.resolve(n),u=e.find(l=>{if(l.kind!==a)return!1;try{return v.resolve(mi(i,l.relativePath,l.kind,"manifest_asset_path"))===d}catch{return!1}});if(u)return u;if(o.contentHash){let l=e.find(m=>m.kind===a&&m.contentHash===o.contentHash);if(l)return l}return null}function VG(e){return Zc({...e.external&&typeof e.external=="object"&&!Array.isArray(e.external)?e.external:{},platformAssetId:e.external?.platformAssetId??e.platformAssetId??e.assetId,assetUrl:e.external?.assetUrl??e.assetUrl},!0)}function UG(e){return ae(Ke(e).platformAssetId)}function KG(e){return ae(Ke(e).assetPath)}function HG(e,t){return e.kind.localeCompare(t.kind)||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)}async function Um(e,t){try{if(await W.readFile(e,"utf8")===t)return!1}catch(n){if(!jo(n)||n.code!=="ENOENT")throw n}let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{return await W.writeFile(r,t),await W.rename(r,e),!0}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function WG(e,t){let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{await W.writeFile(r,t),await W.rename(r,e)}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function Ym(e){let t=await W.readFile(e),r=await W.stat(e);if(v.extname(e).toLowerCase()!==".gltf")return{...ui(t),byteSize:r.size};let n;try{n=JSON.parse(t.toString("utf8"))}catch{return{...ui(t),byteSize:r.size}}let o=v.dirname(await W.realpath(e)),a=new Map;for(let d of[...Array.isArray(n.buffers)?n.buffers:[],...Array.isArray(n.images)?n.images:[]]){let u=ae(Ke(d)?.uri);if(!u||u.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(u)||u.startsWith("//"))continue;let l;try{l=decodeURIComponent(u.split(/[?#]/,1)[0])}catch{continue}let m=v.posix.normalize(l.replace(/\\/g,"/"));if(!m||m==="."||m===".."||m.startsWith("../")||v.posix.isAbsolute(m))continue;let f;try{f=await W.realpath(v.resolve(o,...m.split("/")))}catch{continue}try{Vm(o,f,"gltf_dependency_path_escape")}catch{continue}a.set(m,f)}let i=Qc.createHash("sha256").update("playable-editor-gltf-bundle-v1\0"),s=[{path:"",...ui(t)}],c=r.size;for(let[d,u]of[...a].sort(([l],[m])=>l.localeCompare(m))){let l=await W.readFile(u);s.push({path:d,...ui(l)}),c+=l.byteLength}return i.update(JSON.stringify(s)),{contentHash:`sha256:${i.digest("hex")}`,byteSize:c}}function ui(e){return{contentHash:`sha256:${Qc.createHash("sha256").update(e).digest("hex")}`,byteSize:e.byteLength}}function qG(e){let t=Qc.createHash("sha256").update(`material-texture\0${e}`).digest("hex");return`${t.slice(0,8)}-${t.slice(8,12)}-5${t.slice(13,16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}function JG(e){return e.trim().replace(/[^\p{L}\p{N}._-]+/gu,"_").replace(/^_+|_+$/g,"")||"Imported_Texture"}async function TI(e){try{return await W.access(e),!0}catch{return!1}}async function XG(e,t){let r=$E(t,{codeKeyPolicy:e.codeKeyPolicy??"legacy"});await W.mkdir(v.dirname(e.manifestPath),{recursive:!0}),await W.mkdir(v.dirname(e.registryPath),{recursive:!0});let n=await yI(e.manifestPath),o=await yI(e.registryPath);try{await Um(e.manifestPath,`${JSON.stringify(t,null,2)}
13
- `),await Um(e.registryPath,r)}catch(a){let i=[];for(let[s,c]of[[e.manifestPath,n],[e.registryPath,o]])try{await YG(s,c)}catch(d){i.push(d)}if(i.length>0){let s=new Error("generated_registry_transaction_rollback_failed");throw s.cause=a,s.rollbackErrors=i,s}throw a}}async function yI(e){try{return(await W.lstat(e)).isFile()?{kind:"file",content:await W.readFile(e,"utf8")}:{kind:"other"}}catch(t){if(jo(t)&&t.code==="ENOENT")return{kind:"missing"};throw t}}async function YG(e,t){if(t.kind!=="other"){if(t.kind==="missing"){await W.rm(e,{force:!0});return}await Um(e,t.content)}}function ae(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ke(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function jo(e){return e instanceof Error&&"code"in e}function xI(e){return{async loadManifest(){let t=await Zt(e.assetRegistryConfig),r=e.textureRegistryConfig?await Zt(e.textureRegistryConfig):[];return{ok:!0,manifest:t,textureManifest:r}},async loadEditorAssetLibrary(){let t=await e.loadAssetCatalogEntries(),r=[...e.createAssetLibrary?e.createAssetLibrary(t):Gs(t)];return{ok:!0,assets:r,summary:{assets:r.length}}},async importAsset({payload:t}){let r=e.selectRegistryConfig?e.selectRegistryConfig({payload:t,assetRegistryConfig:e.assetRegistryConfig,textureRegistryConfig:e.textureRegistryConfig}):ZG(t,e.assetRegistryConfig,e.textureRegistryConfig),n=await Fo(r),o=tj(n.errorCodes),a=await Zt(r),i=typeof t.projectAssetId=="string"&&t.projectAssetId.trim()?t.projectAssetId.trim():null,s=t.assetPath?await No(r,{payloadData:{...t,sourcePath:t.assetPath}},o):null,c=s?.assetId??i;if(!c)throw new Error("asset_import_result_missing_asset_id");s&&await ej(e,r,s);let d=await e.loadAssetCatalogEntries(),u=[...e.createAssetLibrary?e.createAssetLibrary(d):Gs(d)],l=u.find(m=>m.assetId===c||m.id===c);if(!l)throw new Error("asset_import_catalog_projection_missing");return{ok:!0,assetId:c,asset:l,assets:u,disposition:s&&a.some(m=>m.assetId===c)?"deduplicated":s?"created":"existing"}}}}function ZG(e,t,r){return r&&QG(e)?r:t}function QG(e){let t=typeof e.assetType=="string"?e.assetType.toLowerCase():"";if(/^(texture|image|png|jpg|jpeg|webp)$/.test(t))return!0;let r=typeof e.kind=="string"?e.kind.toLowerCase():"";if(/^(texture|image)$/.test(r)||(typeof e.mimeType=="string"?e.mimeType.toLowerCase():"").startsWith("image/"))return!0;let o=[e.sourcePath,e.assetPath,e.assetName].filter(a=>typeof a=="string").join(`
14
- `);return/\.(png|jpe?g|webp)(?:$|[?#])/i.test(o)}async function ej(e,t,r){if(!e.invalidateFiles)return;let n=typeof e.additionalInvalidationFiles=="function"?await e.additionalInvalidationFiles():e.additionalInvalidationFiles??[],o=new Set([...n,r.manifestPath||t.manifestPath,r.registryPath||t.registryPath]);await e.invalidateFiles([...o])}function tj(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}async function Zm(e,t={}){let r=[],n=0;for await(let o of e){let a=Buffer.from(o);if(n+=a.byteLength,t.maxBytes!==void 0&&n>t.maxBytes)throw Object.assign(new Error("asset_import_payload_too_large"),{code:"asset_import_payload_too_large",details:{maxBytes:t.maxBytes}});r.push(a)}return JSON.parse(Buffer.concat(r).toString("utf8")||"{}")}function Ur(e,t,r){if(e.statusCode=t.statusCode,fi(e,r),t.body==null){e.end();return}e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(JSON.stringify(t.body))}function fi(e,t={}){e.setHeader("Access-Control-Allow-Origin",t.origin??"*"),e.setHeader("Access-Control-Allow-Methods",t.methods??"GET,POST,OPTIONS"),e.setHeader("Access-Control-Allow-Headers",t.headers??"Content-Type, Authorization"),e.setHeader("Cross-Origin-Resource-Policy",t.resourcePolicy??"cross-origin"),e.setHeader("Cross-Origin-Embedder-Policy",t.embedderPolicy??"credentialless"),e.setHeader("Cache-Control",t.cacheControl??"no-store")}import{existsSync as RI,readFileSync as CI}from"node:fs";import{mkdir as DI,rename as ij,rm as MI,writeFile as sj}from"node:fs/promises";import{randomUUID as cj}from"node:crypto";import jn from"node:path";import rj from"node:path";var ed=new Map;async function td(e,t){let r=[...new Set(e.map(i=>rj.resolve(i)))].sort(),n=[...new Set(r.map(i=>ed.get(i)).filter(Boolean))],o=()=>{},a=new Promise(i=>{o=i});for(let i of r)ed.set(i,a);await Promise.all(n);try{return await t()}finally{o();for(let i of r)ed.get(i)===a&&ed.delete(i)}}import{performance as Qm}from"node:perf_hooks";var nj=1,oj=["prepare","compile","validate","stringify","write","checkpoint"];function AI(){let e=[],t=(r,n,o)=>{let a=process.memoryUsage();e.push({phase:r,durationMs:ef(Qm.now()-n),rssBeforeBytes:o.rss,rssAfterBytes:a.rss,maxObservedRssBytes:Math.max(o.rss,a.rss),heapUsedBeforeBytes:o.heapUsed,heapUsedAfterBytes:a.heapUsed,maxObservedHeapUsedBytes:Math.max(o.heapUsed,a.heapUsed)})};return{measure(r,n){let o=process.memoryUsage(),a=Qm.now();try{return n()}finally{t(r,a,o)}},async measureAsync(r,n){let o=process.memoryUsage(),a=Qm.now();try{return await n()}finally{t(r,a,o)}},snapshot(){return aj(e)}}}function aj(e){let t=new Map;for(let n of e){let o=t.get(n.phase);if(!o){t.set(n.phase,{...n});continue}o.durationMs=ef(o.durationMs+n.durationMs),o.rssAfterBytes=n.rssAfterBytes,o.maxObservedRssBytes=Math.max(o.maxObservedRssBytes,n.maxObservedRssBytes),o.heapUsedAfterBytes=n.heapUsedAfterBytes,o.maxObservedHeapUsedBytes=Math.max(o.maxObservedHeapUsedBytes,n.maxObservedHeapUsedBytes)}let r=oj.flatMap(n=>{let o=t.get(n);return o?[o]:[]});return{schemaVersion:nj,measuredDurationMs:ef(r.reduce((n,o)=>n+o.durationMs,0)),maxObservedRssBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedRssBytes),0),maxObservedHeapUsedBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedHeapUsedBytes),0),phases:r}}function ef(e){return Math.round(Math.max(0,e)*1e3)/1e3}async function vI(e){let t=e.paths,r=pi(t.editorScenePath),n=r?ua(r).document:null,o=pi(t.scenePath),a=await e.loadServices(e.server,e.projectRoot),i=await e.listEditorAssetLibrary(e.server,"report");n&&km(n),n&&wa(n,i);let s=n?a.ensureEditorSceneEnvironmentDefaults(a.enrichEditorSceneDocumentAssets(a.ensureAuthoringSource(n),i)):null;s&&Wc(s);let c=t.renderingConfigPath?pi(t.renderingConfigPath):void 0;c&&gt(c);let d={...Br(s),...t.renderingConfigPath?{rendering:c}:{}},u=FI(t.shadowsConfigPath),l=se(o),m=typeof l?.version=="number"?l.version:void 0,f=typeof l?.updatedAt=="string"?l.updatedAt:void 0;return{ok:!0,editorScenePath:t.editorScenePath,scenePath:t.scenePath,editorScene:s,assets:i,...m===void 0?{}:{version:m},...f===void 0?{}:{updatedAt:f},...Object.keys(d).length>0?{companionConfigs:d}:{},...u?{shadowMapExperimentConfig:u}:{},drift:s?a.detectRuntimeInputDrift(s,o):null,summary:NI(s)}}async function GI(e){Nn(e),kI(e.body,"$",!0),kI(e.rawEditorScene,"$.editorScene");let t=Am(e.body),r=Br(e.body),n=Object.prototype.hasOwnProperty.call(r,"rendering");t&&gt(t);let o=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig");if(o&&_I(e.body),o&&!e.paths.shadowsConfigPath)throw new Error("shadows_config_path_missing");let a=[e.paths.editorScenePath,...e.saveMode==="local-commit-save"?[e.paths.scenePath]:[],...n&&e.paths.renderingConfigPath?[e.paths.renderingConfigPath]:[],...o&&e.paths.shadowsConfigPath?[e.paths.shadowsConfigPath]:[]];return td(a,()=>(Nn(e),dj(e)))}async function dj(e){let t=AI(),r=t.measure("prepare",()=>lj(e)),n=ua(r).document,o=await t.measureAsync("prepare",()=>e.saveServices(e.server,e.projectRoot));Nn(e);let a=e.paths,i=Br(e.body),s=Am(e.body),c=Object.prototype.hasOwnProperty.call(i,"rendering"),d=Object.prototype.hasOwnProperty.call(i,vn),u=i[vn],l=Ar(u),m=t.measure("prepare",()=>pi(a.scenePath)??{}),f=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig"),g=_I(e.body)??FI(a.shadowsConfigPath);t.measure("validate",()=>{tf(u,l,{present:d,path:"$.companionConfigs.staticShadows"})});let b=Br(n),y=b[vn];t.measure("validate",()=>{tf(y,Ar(y),{present:Object.prototype.hasOwnProperty.call(b,vn),path:"$.editorScene.companionConfigs.staticShadows"})});let E=se(m)?.staticShadows;t.measure("validate",()=>{tf(E,Ar(E),{present:Object.prototype.hasOwnProperty.call(m,"staticShadows"),path:"$.scene.staticShadows"}),km(n)});let I=s&&e.normalizeRenderingProfile?e.normalizeRenderingProfile(s):s,P=await t.measureAsync("prepare",()=>e.listEditorAssetLibrary(e.server,"strict"));Nn(e),t.measure("validate",()=>{wa(n,P)});let A=t.measure("prepare",()=>{let xe=o.ensureEditorSceneEnvironmentDefaults(o.enrichEditorSceneDocumentAssets(o.ensureAuthoringSource(n),P));return xc(xe,4)});t.measure("validate",()=>{o.assertEditorSceneDocument(A),o.assertEditorSceneMaterialAssetIntegrity(A)});let $=t.measure("prepare",()=>o.bumpEditorSceneAuthoringSourceRevision(A)),z=d?l:l??sE(n)??Ar(se(m)?.staticShadows),p=t.measure("prepare",()=>xc(uj($,{staticShadows:z}),4)),D=t.measure("prepare",()=>Zl(p,P)),h=t.measure("compile",()=>o.compileEditorSceneDocumentToSceneConfig($,m,{...s==null?{}:{renderingProfile:s},shadowMapExperimentConfig:g??null})),R=z?{...h.sceneConfig,staticShadows:z}:{...h.sceneConfig};z||delete R.staticShadows;let K=typeof m.version=="number"?m.version:void 0,ne=typeof K=="number"?K+1:1,F=new Date().toISOString(),Ir=t.measure("compile",()=>xc(e.saveMode==="local-commit-save"?{...R,version:ne,updatedAt:F}:R,4));t.measure("validate",()=>{Ni(Ir)});let er=se(Ir)?.version,Hr=e.saveMode==="local-commit-save"&&typeof er=="number"?er:ne,yi=`/${jn.relative(e.projectRoot,a.scenePath).split(jn.sep).join("/")}?v=${encodeURIComponent(String(Hr))}`,tr="",zn=[];try{{let xe=t.measure("stringify",()=>`${JSON.stringify(D,null,2)}
15
- `);await t.measureAsync("write",()=>rd(e,zn,a.editorScenePath,xe))}if(s){if(!a.renderingConfigPath)throw new Error("rendering_config_path_missing");Nn(e),await DI(jn.dirname(a.renderingConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(s,null,2)}
16
- `);await t.measureAsync("write",()=>rd(e,zn,a.renderingConfigPath,xe))}else if(c&&!a.renderingConfigPath)throw new Error("rendering_config_path_missing");if(f){if(!a.shadowsConfigPath||!g)throw new Error("shadows_config_path_missing");await DI(jn.dirname(a.shadowsConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(g,null,2)}
12
+ `}import zm from"node:fs/promises";import lt from"node:path";var Bm=5;async function si(e){let t={...e.existingMetadata??{},...e.payloadMetadata??{}},r=await KE(e);if(r?(t.assetAnalysis=r,t.assetAnalysisStatus="complete"):(delete t.assetAnalysis,t.assetAnalysisStatus="unavailable"),e.kind==="texture"||e.kind==="image"){let o=PG(e.sourcePath,t);return o&&(t.textureUsage=o.usage,t.capabilities={...ge(t.capabilities)?t.capabilities:{},materialTexture:o.materialTexture,environmentTexture:o.environmentTexture}),Object.keys(t).length>0?t:null}if(e.kind!=="model")return Object.keys(t).length>0?t:null;t.assetMetadataVersion=Bm;let n=await HE(e.sourcePath,{assetGuid:e.guid,assetId:e.assetId,cwd:e.cwd,assetsDir:e.assetsDir,existingMaterialSlots:t.materialSlots});return n.length===0?delete t.materialSlots:t.materialSlots=n,Object.keys(t).length>0?t:null}async function KE(e){return e.kind==="model"?eG(e.sourcePath):e.kind==="texture"||e.kind==="image"?tG(e.sourcePath):null}async function HE(e,t={}){try{let r=await WE(e);return mG(r,{...t,sourcePath:e})}catch{return[]}}async function WE(e){let t=lt.extname(e).toLowerCase();if(t===".gltf")return JSON.parse(await zm.readFile(e,"utf8"));if(t!==".glb")return null;let r=await zm.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let a=12;for(;a+8<=r.length;){let i=r.readUInt32LE(a),s=r.readUInt32LE(a+4);if(a+=8,a+i>r.length)return null;if(s===1313821514){let c=r.toString("utf8",a,a+i).replace(/\0+$/g,"");return JSON.parse(c)}a+=i}return null}async function eG(e){try{let t=await WE(e);if(!t||typeof t!="object")return null;let r=Array.isArray(t.scenes)?t.scenes:[],n=Array.isArray(t.nodes)?t.nodes:[],o=Array.isArray(t.meshes)?t.meshes:[],a=Array.isArray(t.materials)?t.materials:[],i=Array.isArray(t.textures)?t.textures:[],s=Array.isArray(t.images)?t.images:[],c=Array.isArray(t.animations)?t.animations:[],d=Array.isArray(t.skins)?t.skins:[],u=Array.isArray(t.accessors)?t.accessors:[],l=ZE(t),m=QE(n),f=new Set(l),S=o.reduce((I,P)=>I+(Array.isArray(P?.primitives)?P.primitives.length:0),0),g=o.reduce((I,P)=>I+(Array.isArray(P?.primitives)?P.primitives.reduce((A,$)=>A+(Array.isArray($?.targets)?$.targets.length:0),0):0),0),b=iG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length}),y=sG({nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,complexity:b});return{kind:"gltf",format:lt.extname(e).toLowerCase()===".gltf"?"gltf":"glb",summary:`${n.length} nodes, ${o.length} meshes, ${S} primitives, ${a.length} materials`,complexity:b,sceneCount:r.length,nodeCount:n.length,meshCount:o.length,primitiveCount:S,materialCount:a.length,textureCount:i.length,imageCount:s.length,animationCount:c.length,skinCount:d.length,morphTargetCount:g,nodes:rG(n,o,a,u,m,f),meshes:nG(o,a,u),materials:oG(t),diagnostics:y}}catch{return null}}async function tG(e){try{let t=await zm.readFile(e),r=lt.extname(e).toLowerCase(),n=r===".png"?cG(t):r===".jpg"||r===".jpeg"?dG(t):r===".webp"?lG(t):null;if(!n)return null;let o=uG(n);return{kind:"image",format:n.format,summary:`${n.width}x${n.height} ${n.mime}`,complexity:n.estimatedPixels>=4096*4096?"high":n.estimatedPixels>=2048*2048?"medium":"low",width:n.width,height:n.height,mime:n.mime,bitDepth:n.bitDepth,hasAlpha:n.hasAlpha,estimatedPixels:n.estimatedPixels,diagnostics:o}}catch{return null}}function rG(e,t,r,n,o,a){return e.slice(0,100).map((i,s)=>{let c=Number.isInteger(i?.mesh)?i.mesh:-1,d=c>=0&&c<t.length?t[c]:null,u=Array.isArray(i?.children)?i.children.filter(f=>Number.isInteger(f)):[],l=eI(e,o,a,s),m={nodeIndex:s,nodeIndexPath:rI(o,s),...typeof i?.name=="string"&&i.name.trim()?{name:i.name.trim()}:{},...l?{ownerNodePath:l}:{},...u.length>0?{children:u}:{}};if(d){let f=qE(d,r,n);Object.assign(m,{meshIndex:c,...typeof d?.name=="string"&&d.name.trim()?{meshName:d.name.trim()}:{},primitiveCount:f.length,...f.length>0?{primitives:f}:{}})}return m})}function nG(e,t,r){return e.slice(0,50).map((n,o)=>{let a=Array.isArray(n?.primitives)?n.primitives:[],i=[...new Set(a.map(c=>Number.isInteger(c?.material)?c.material:-1).filter(c=>c>=0))],s=qE(n,t,r);return{meshIndex:o,...typeof n?.name=="string"&&n.name.trim()?{name:n.name.trim()}:{},primitiveCount:a.length,...s.length>0?{primitives:s}:{},...i.length>0?{materialIndices:i}:{},...i.length>0?{materialNames:i.map(c=>{let d=t[c];return typeof d?.name=="string"?d.name.trim():""}).filter(Boolean)}:{}}})}function qE(e,t,r){let n=ge(e)?e:{};return(Array.isArray(n.primitives)?n.primitives:[]).map((a,i)=>{let s=Number.isInteger(a?.material)?a.material:-1,c=s>=0?t[s]:null,d=typeof c?.name=="string"&&c.name.trim()?c.name.trim():"",u=nI(a,r),l=oI(a,r);return{primitiveIndex:i,...Number.isInteger(a?.mode)?{mode:a.mode}:{},...s>=0?{sourceMaterialIndex:s}:{},...d?{materialName:d}:{},...Number.isFinite(u)?{triangleCount:u}:{},...l?{boundingBox:l}:{}}})}function oG(e){return(Array.isArray(e?.materials)?e.materials:[]).slice(0,50).map((r,n)=>{let o=r?.pbrMetallicRoughness&&typeof r.pbrMetallicRoughness=="object"?r.pbrMetallicRoughness:{},a=aG(r,o);return{sourceMaterialIndex:n,...typeof r?.name=="string"&&r.name.trim()?{materialName:r.name.trim()}:{},...Array.isArray(o.baseColorFactor)?{baseColorFactor:o.baseColorFactor.slice(0,4)}:{},metallicFactor:Number.isFinite(o.metallicFactor)?o.metallicFactor:1,roughnessFactor:Number.isFinite(o.roughnessFactor)?o.roughnessFactor:1,alphaMode:XE(r?.alphaMode)??"opaque",...Number.isFinite(r?.alphaCutoff)?{alphaCutoff:r.alphaCutoff}:{},...a.length>0?{textureSlots:a}:{}}})}function aG(e,t){let r=[];return ai(r,"baseColor",t?.baseColorTexture),ai(r,"metallicRoughness",t?.metallicRoughnessTexture),ai(r,"normal",e?.normalTexture),ai(r,"occlusion",e?.occlusionTexture),ai(r,"emissive",e?.emissiveTexture),r}function ai(e,t,r){!ge(r)||!Number.isInteger(r.index)||e.push({slot:t,textureIndex:r.index,...Number.isFinite(r.texCoord)?{texCoord:r.texCoord}:{}})}function iG(e){return e.nodeCount>=300||e.meshCount>=250||e.primitiveCount>=300||e.materialCount>=200||e.textureCount>=80||e.imageCount>=80?"high":e.nodeCount>=100||e.meshCount>=80||e.primitiveCount>=100||e.materialCount>=50||e.textureCount>=24||e.imageCount>=24?"medium":"low"}function sG(e){let t=[];return e.complexity==="high"&&t.push({severity:"warning",source:"asset",code:"asset.analysis.highComplexity",message:"GLTF asset is structurally complex; agent should place and inspect it before duplicating or using dense shadows.",details:{nodeCount:e.nodeCount,meshCount:e.meshCount,primitiveCount:e.primitiveCount,materialCount:e.materialCount,textureCount:e.textureCount,imageCount:e.imageCount}}),(e.animationCount>0||e.skinCount>0||e.morphTargetCount>0)&&t.push({severity:"info",source:"asset",code:"asset.analysis.riggedOrAnimated",message:"GLTF asset contains animation, skin, or morph target data.",details:{animationCount:e.animationCount,skinCount:e.skinCount,morphTargetCount:e.morphTargetCount}}),t}function cG(e){if(e.length<33||e[0]!==137||e.toString("ascii",1,4)!=="PNG"||e[4]!==13||e[5]!==10||e[6]!==26||e[7]!==10||e.toString("ascii",12,16)!=="IHDR")return null;let r=e.readUInt32BE(16),n=e.readUInt32BE(20),o=e[24],a=e[25],i=!1,s=33;for(;s+12<=e.length;){let c=e.readUInt32BE(s),d=s+12+c;if(d>e.length)break;let u=e.toString("ascii",s+4,s+8);if(u==="tRNS"){i=!0;break}if(u==="IDAT"||u==="IEND")break;s=d}return{format:"png",mime:"image/png",width:r,height:n,bitDepth:o,hasAlpha:a===4||a===6||i,estimatedPixels:r*n}}function dG(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<e.length;){if(e[t]!==255){t+=1;continue}let r=e[t+1],n=e.readUInt16BE(t+2);if(n<2)return null;if(r>=192&&r<=207&&![196,200,204].includes(r)&&t+8<e.length){let a=e[t+4],i=e.readUInt16BE(t+5),s=e.readUInt16BE(t+7);return{format:"jpeg",mime:"image/jpeg",width:s,height:i,bitDepth:a,hasAlpha:!1,estimatedPixels:s*i}}t+=2+n}return null}function lG(e){if(e.length<30||e.toString("ascii",0,4)!=="RIFF"||e.toString("ascii",8,12)!=="WEBP")return null;let t=e.toString("ascii",12,16);if(t==="VP8X"&&e.length>=30){let r=e[20],n=BE(e,24)+1,o=BE(e,27)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:(r&16)!==0,estimatedPixels:n*o}}if(t==="VP8 "&&e.length>=30){let r=e.readUInt16LE(26)&16383,n=e.readUInt16LE(28)&16383;return{format:"webp",mime:"image/webp",width:r,height:n,hasAlpha:!1,estimatedPixels:r*n}}if(t==="VP8L"&&e.length>=25&&e[20]===47){let r=e.readUInt32LE(21),n=(r&16383)+1,o=(r>>14&16383)+1;return{format:"webp",mime:"image/webp",width:n,height:o,hasAlpha:!0,estimatedPixels:n*o}}return null}function BE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16}function uG(e){let t=[];return e.estimatedPixels>=4096*4096&&t.push({severity:"warning",source:"asset",code:"asset.analysis.largeImage",message:"Image asset is large; agent should inspect texture usage before assigning it broadly.",details:{width:e.width,height:e.height,estimatedPixels:e.estimatedPixels}}),t}function mG(e,t={}){if(!e||typeof e!="object")return[];let r=Array.isArray(e.nodes)?e.nodes:[],n=Array.isArray(e.meshes)?e.meshes:[],o=Array.isArray(e.materials)?e.materials:[],a=pG(e,t),i=ZE(e),s=QE(r),c=new Set(i),d=Array.isArray(e.accessors)?e.accessors:[],u=hG(t.existingMaterialSlots),l=[],m=new Map;for(let f=0;f<r.length;f+=1){let S=r[f],g=Number.isInteger(S?.mesh)?S.mesh:-1;if(g<0||g>=n.length)continue;let b=eI(r,s,c,f);if(!b)continue;let y=n[g],E=Array.isArray(y?.primitives)?y.primitives:[],I=xG(S,y,b),P=tI(y),A=rI(s,f);for(let $=0;$<E.length;$+=1){let z=E[$],p=AG(z,o),D=YE({ownerNodePath:b,nodeIndex:f,meshIndex:g,primitiveIndex:$}),h=nI(z,d),R=oI(z,d),K=E.length>1?`${I} / Primitive ${$}`:I,ne={ownerNodePath:b,nodeIndex:f,nodeIndexPath:A,meshIndex:g,primitiveIndex:$,...P?{sourceMeshName:P}:{},...p.index>=0?{sourceMaterialIndex:p.index}:{},...Number.isFinite(h)?{triangleCount:h}:{},...R?{boundingBox:R}:{}};if(p.index>=0){let F=m.get(p.index)??{label:K,materialName:p.name,sourceSurfaces:[]};F.sourceSurfaces.push(ne),m.set(p.index,F);continue}l.push({slotId:u.byExactSource.get(D)??EG({assetGuid:t.assetGuid,assetId:t.assetId,nodeIndex:f,meshIndex:g,primitiveIndex:E.length>1?$:void 0}),label:K,sourceSurfaces:[ne]})}}for(let[f,S]of m){let g=S.sourceSurfaces.sort(JE);l.push({slotId:u.bySourceMaterialIndex.get(f)??IG({assetGuid:t.assetGuid,assetId:t.assetId,sourceMaterialIndex:f}),label:S.label,sourceSurfaces:g,...S.materialName?{materialName:S.materialName,materialNames:[S.materialName]}:{},...gG(a,[f])})}return l.sort(fG)}function fG(e,t){let r=Array.isArray(e.sourceSurfaces)?e.sourceSurfaces[0]:void 0,n=Array.isArray(t.sourceSurfaces)?t.sourceSurfaces[0]:void 0;return JE(r,n)}function JE(e,t){let r=String(e?.ownerNodePath??"").localeCompare(String(t?.ownerNodePath??""));if(r!==0)return r;let n=Number.isInteger(e?.nodeIndex)?e.nodeIndex:-1,o=Number.isInteger(t?.nodeIndex)?t.nodeIndex:-1;if(n!==o)return n-o;let a=Number.isInteger(e?.meshIndex)?e.meshIndex:-1,i=Number.isInteger(t?.meshIndex)?t.meshIndex:-1;if(a!==i)return a-i;let s=Number.isInteger(e?.primitiveIndex)?e.primitiveIndex:-1,c=Number.isInteger(t?.primitiveIndex)?t.primitiveIndex:-1;return s-c}function pG(e,t={}){let r=Array.isArray(e?.materials)?e.materials:[],n=[];for(let o=0;o<r.length;o+=1){let a=bG(e,o,t);a&&n.push(a)}return n}function gG(e,t){if(!t.length||!e.length)return{};let r=new Map(e.map(o=>[o.sourceMaterialIndex,o])),n=t.map(o=>r.get(o)).filter(Boolean);return n.length>0?{sourceMaterialProfiles:n}:{}}function bG(e,t,r={}){let n=Array.isArray(e?.materials)?e.materials[t]:null;if(!n||typeof n!="object")return null;let o={},a=[],i=n.pbrMetallicRoughness&&typeof n.pbrMetallicRoughness=="object"?n.pbrMetallicRoughness:{},s={},c=Array.isArray(i.baseColorFactor)?i.baseColorFactor:null,d=VE(c);d&&(s.color=d);let u=ii(e,i.baseColorTexture,r,"baseColor.texture",s,"texture",a);Object.keys(s).length>0&&(o.baseColor={...s,brightness:1,saturation:1,contrast:1,hue:0});let l={};ii(e,n.normalTexture,r,"normal.texture",l,"texture",a),Number.isFinite(n.normalTexture?.scale)?l.strength=n.normalTexture.scale:l.texture&&(l.strength=1),Object.keys(l).length>0&&(o.normal=l),o.metallic=Number.isFinite(i.metallicFactor)?i.metallicFactor:1,o.roughness=Number.isFinite(i.roughnessFactor)?i.roughnessFactor:1;let m={};ii(e,i.metallicRoughnessTexture,r,"metallicRoughness.texture",m,"texture",a),Object.keys(m).length>0&&(o.metallicRoughness=m);let f={};ii(e,n.occlusionTexture,r,"occlusion.texture",f,"texture",a),Number.isFinite(n.occlusionTexture?.strength)?f.strength=n.occlusionTexture.strength:f.texture&&(f.strength=1),Object.keys(f).length>0&&(o.occlusion=f);let S={},g=VE(Array.isArray(n.emissiveFactor)?n.emissiveFactor:null),b=g&&(g.r!==0||g.g!==0||g.b!==0);b&&(S.color=g),ii(e,n.emissiveTexture,r,"emission.texture",S,"texture",a),b&&(S.intensity=1),Object.keys(S).length>0&&(o.emission=S);let y={},E=XE(n.alphaMode);if(E&&(y.mode=E),(E==="mask"||E==="blend")&&(c&&Number.isFinite(c[3])&&c[3]!==1&&(y.opacity=c[3]),Number.isFinite(n.alphaCutoff)?y.cutoff=n.alphaCutoff:E==="mask"&&(y.cutoff=.5),u.texture&&(y.texture=structuredClone(u.texture)),u.hint&&a.push({...u.hint,profilePath:"alpha.texture"})),Object.keys(y).length>0&&(o.alpha=y),Object.keys(o).length===0&&a.length===0)return null;let I=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";return{sourceMaterialIndex:t,...I?{materialName:I}:{},...Object.keys(o).length>0?{profile:o}:{},...a.length>0?{textureHints:a}:{}}}function VE(e){if(!Array.isArray(e)||e.length<3)return null;let[t,r,n]=e;return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?{r:t,g:r,b:n}:null}function XE(e){return e==="MASK"?"mask":e==="BLEND"?"blend":e==="OPAQUE"?"opaque":null}function ii(e,t,r,n,o,a,i){let s=SG(e,t,r,n);return s.texture&&(o[a]=s.texture),s.hint&&i.push(s.hint),s}function SG(e,t,r,n){let o=ge(t)?t:{},a=Number.isInteger(o.index)?o.index:-1;if(a<0)return{};let i=Array.isArray(e?.textures)?e.textures:[],s=Array.isArray(e?.images)?e.images:[],c=i[a],d=yG(c),u=d.imageIndex,l=u>=0?s[u]:null,m=typeof l?.uri=="string"?l.uri.trim():"",f=/^data:/i.test(m),S={profilePath:n,textureIndex:a,...u>=0?{imageIndex:u}:{},...d.previewImageIndex>=0?{previewImageIndex:d.previewImageIndex}:{},...m&&!f?{uri:m}:{},...Number.isInteger(l?.bufferView)?{bufferView:l.bufferView}:{},...typeof l?.mimeType=="string"&&l.mimeType.trim()?{mimeType:l.mimeType.trim()}:{}};if(l?.bufferView!=null)return{hint:{...S,reason:"embedded-texture"}};if(!m)return{hint:{...S,reason:"missing-image-uri"}};if(f)return{hint:{...S,reason:"embedded-texture"}};if(/^https?:\/\//i.test(m)||m.startsWith("/"))return{texture:{url:m}};let g=m;try{g=decodeURIComponent(m)}catch{return{hint:{...S,reason:"unresolved-external-texture"}}}let b=lt.dirname(String(r.sourcePath??"")),y=lt.resolve(b,g),E=r.assetsDir?lt.resolve(r.assetsDir):"",I=r.cwd?lt.resolve(r.cwd):"",P=E?lt.relative(E,y):"../";return E&&I&&P&&!P.startsWith("..")&&!lt.isAbsolute(P)?{texture:{url:`/${lt.relative(I,y).split(lt.sep).join("/")}`},hint:{...S,reason:"external-texture"}}:{hint:{...S,reason:"external-texture"}}}function yG(e){let t=ge(e)?e:{},r=ge(t.extensions)?t.extensions:{},n=Number.isInteger(t.source)?t.source:-1,o=ge(r.KHR_texture_basisu)?r.KHR_texture_basisu:{};if(Number.isInteger(o.source))return{imageIndex:o.source,previewImageIndex:n>=0&&n!==o.source?n:-1};let a=ge(r.EXT_texture_webp)?r.EXT_texture_webp:{};return Number.isInteger(a.source)?{imageIndex:a.source,previewImageIndex:-1}:{imageIndex:n,previewImageIndex:-1}}function hG(e){let t=new Map,r=new Map;if(!Array.isArray(e))return{byExactSource:t,bySourceMaterialIndex:new Map};for(let o of e){if(!ge(o))continue;let a=Array.isArray(o.sourceSurfaces)?o.sourceSurfaces:[],i=typeof o.slotId=="string"?o.slotId.trim():"";if(!i)continue;let s=new Set;for(let c of a){if(!ge(c))continue;let d=typeof c.ownerNodePath=="string"?c.ownerNodePath.trim().replace(/^\/+|\/+$/g,""):"",u=Number.isInteger(c.nodeIndex)?c.nodeIndex:-1,l=Number.isInteger(c.meshIndex)?c.meshIndex:-1,m=Number.isInteger(c.primitiveIndex)?c.primitiveIndex:-1;a.length===1&&d&&u>=0&&l>=0&&m>=0&&t.set(YE({ownerNodePath:d,nodeIndex:u,meshIndex:l,primitiveIndex:m}),i),Number.isInteger(c.sourceMaterialIndex)&&c.sourceMaterialIndex>=0&&s.add(c.sourceMaterialIndex)}if(s.size===1){let[c]=s,d=r.get(c)??[];d.push(i),r.set(c,d)}}let n=new Map;for(let[o,a]of r)a.length===1&&n.set(o,a[0]);return{byExactSource:t,bySourceMaterialIndex:n}}function YE(e){return[e.ownerNodePath,e.nodeIndex,e.meshIndex,e.primitiveIndex].join("\0")}function EG(e){let t=Number.isInteger(e.primitiveIndex)?`:${e.primitiveIndex}`:"",r=`${e.assetGuid||e.assetId||"asset"}:${e.nodeIndex}:${e.meshIndex}${t}`;return`slot_${iI(r)}`}function IG(e){let t=`${e.assetGuid||e.assetId||"asset"}:material:${e.sourceMaterialIndex}`;return`slot_${iI(t)}`}function PG(e,t){if(t.textureUsage==="material"||t.usage==="material")return{usage:"material",materialTexture:!0,environmentTexture:!1};if(ge(t.capabilities)&&t.capabilities.materialTexture===!0)return{usage:"material",materialTexture:!0,environmentTexture:!1};if(t.textureUsage==="environment"||t.usage==="environment")return{usage:"environment",materialTexture:!1,environmentTexture:!0};if(ge(t.capabilities)&&t.capabilities.environmentTexture===!0)return{usage:"environment",materialTexture:!1,environmentTexture:!0};let r=lt.extname(e).toLowerCase();return[".env",".hdr",".dds",".ktx",".ktx2"].includes(r)?{usage:"environment",materialTexture:!1,environmentTexture:!0}:[".png",".jpg",".jpeg",".webp"].includes(r)?{usage:"material",materialTexture:!0,environmentTexture:!1}:null}function ZE(e){let t=Array.isArray(e.scenes)?e.scenes:[],r=Number.isInteger(e.scene)?e.scene:0,n=t[r]??t[0];return Array.isArray(n?.nodes)?n.nodes.filter(Number.isInteger):[]}function QE(e){let t=new Map;for(let r=0;r<e.length;r+=1){let n=Array.isArray(e[r]?.children)?e[r].children:[];for(let o of n)Number.isInteger(o)&&!t.has(o)&&t.set(o,r)}return t}function eI(e,t,r,n){let o=[],a=n,i=new Set;for(;Number.isInteger(a)&&a>=0&&a<e.length;){if(i.has(a))return"";i.add(a),o.push(TG(e[a],a));let s=t.get(a);if(typeof s!="number"||!Number.isInteger(s))break;a=s}return o.reverse(),o.length>1&&r.has(a)&&o.shift(),o.filter(Boolean).join("/")}function TG(e,t){return(ge(e)&&typeof e.name=="string"?e.name.trim():"")||`node_${t}`}function xG(e,t,r){let n=ge(e)&&typeof e.name=="string"?e.name.trim():"",o=tI(t);return n||o||r.split("/").filter(Boolean).pop()||r}function tI(e){return ge(e)&&typeof e.name=="string"?e.name.trim():""}function rI(e,t){let r=[],n=t,o=new Set;for(;Number.isInteger(n)&&n>=0;){if(o.has(n))return[];o.add(n),r.push(n);let a=e.get(n);if(!Number.isInteger(a))break;n=a}return r.reverse(),r}function AG(e,t){let r=ge(e)?e:{},n=Number.isInteger(r.material)?r.material:-1,o=n>=0?t[n]:null,a=typeof o?.name=="string"&&o.name.trim()?o.name.trim():"";return{index:n,name:a}}function nI(e,t){let r=ge(e)?e:{},n=Number.isInteger(r.indices)?r.indices:-1,o=aI(r),a=n>=0?t[n]:null,i=o>=0?t[o]:null,s=Number.isFinite(a?.count)?Number(a.count):Number.isFinite(i?.count)?Number(i.count):null;if(s==null)return null;let c=Number.isInteger(r.mode)?r.mode:4;return c===4?Math.floor(s/3):c===5||c===6?Math.max(0,s-2):0}function oI(e,t){let r=ge(e)?e:{},n=aI(r),o=n>=0?t[n]:null,a=UE(o?.min),i=UE(o?.max);return a&&i?{min:a,max:i}:null}function aI(e){let t=ge(e.attributes)?e.attributes:{};return Number.isInteger(t.POSITION)?t.POSITION:-1}function UE(e){if(!Array.isArray(e)||e.length<3)return null;let t=Number(e[0]),r=Number(e[1]),n=Number(e[2]);return Number.isFinite(t)&&Number.isFinite(r)&&Number.isFinite(n)?[t,r,n]:null}function ge(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function iI(e){let t=String(e??""),r=2166136261;for(let n=0;n<t.length;n+=1)r^=t.charCodeAt(n),r=Math.imul(r,16777619);return(r>>>0).toString(16).padStart(8,"0")}import Qc from"node:crypto";import{constants as RG}from"node:fs";import W from"node:fs/promises";import v from"node:path";import ci from"node:fs/promises";import Ot from"node:path";async function cI(e,t={}){try{let r=await DG(e);if(!r)return[];let n=Array.isArray(r.gltf.images)?r.gltf.images:[],o=t.imageIndexes?new Set(t.imageIndexes.filter(i=>Number.isInteger(i)&&i>=0)):null,a=[];for(let i=0;i<n.length;i+=1){if(o&&!o.has(i))continue;let s=ut(n[i]);if(!s)continue;let c=await MG(e,r,s);if(!c)continue;let d=di(s.name)??(c.originalFileName?Ot.parse(c.originalFileName).name:null)??void 0;a.push({imageIndex:i,bytes:c.bytes,extension:c.extension,mimeType:c.mimeType,...d?{displayName:d}:{},...c.originalFileName?{originalFileName:c.originalFileName}:{}})}return a}catch{return[]}}function dI(e){let t=new Set;for(let r of uI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n!=null&&t.add(n),o!=null&&t.add(o)}return[...t].sort((r,n)=>r-n)}function lI(e){let t=new Map;for(let r of uI(e)){let n=hr(r.imageIndex),o=hr(r.previewImageIndex);n==null||o==null||n===o||t.set(`${n}:${o}`,{imageIndex:n,previewImageIndex:o})}return[...t.values()].sort((r,n)=>r.imageIndex-n.imageIndex||r.previewImageIndex-n.previewImageIndex)}function uI(e){if(!e)return[];let t=[],r=Array.isArray(e.materialSlots)?e.materialSlots:[];for(let n of r){let o=ut(n),a=Array.isArray(o?.sourceMaterialProfiles)?o.sourceMaterialProfiles:[];for(let i of a){let s=ut(i),c=Array.isArray(s?.textureHints)?s.textureHints:[];for(let d of c){let u=ut(d);u&&t.push(u)}}}return t}function mI(e,t){if(!e||t.length===0)return e;let r=new Map(t.map(i=>[i.imageIndex,i.textureAssetId])),n=structuredClone(e),o=Array.isArray(n.materialSlots)?n.materialSlots:[],a=!1;for(let i of o){let s=ut(i),c=Array.isArray(s?.sourceMaterialProfiles)?s.sourceMaterialProfiles:[];for(let d of c){let u=ut(d);if(!u)continue;let l=Array.isArray(u.textureHints)?u.textureHints:[];if(l.length===0)continue;let m=[];for(let f of l){let S=ut(f),g=hr(S?.imageIndex),b=di(S?.profilePath),y=g==null?null:r.get(g)??null;if(!y||!b||!kG(b)){m.push(f);continue}let E=ut(u.profile)??{};OG(E,b,{textureAssetId:y}),u.profile=E,a=!0}m.length>0?u.textureHints=m:delete u.textureHints}}return a?n:e}async function DG(e){let t=Ot.extname(e).toLowerCase();if(t===".gltf"){let c=JSON.parse(await ci.readFile(e,"utf8")),d=await Promise.all((Array.isArray(c.buffers)?c.buffers:[]).map(u=>sI(e,ut(u))));return{gltf:c,buffers:d}}if(t!==".glb")return null;let r=await ci.readFile(e);if(r.length<20||r.toString("utf8",0,4)!=="glTF"||r.readUInt32LE(4)!==2||r.readUInt32LE(8)>r.length)return null;let n=null,o=[],a=12;for(;a+8<=r.length;){let c=r.readUInt32LE(a),d=r.readUInt32LE(a+4);if(a+=8,a+c>r.length)return null;let u=r.subarray(a,a+c);d===1313821514?n=JSON.parse(u.toString("utf8").replace(/\0+$/g,"")):d===5130562&&o.push(Buffer.from(u)),a+=c}if(!n)return null;let i=Array.isArray(n.buffers)?n.buffers:[],s=await Promise.all(i.map(async(c,d)=>{let u=ut(c);return di(u?.uri)?sI(e,u):o[d]??(d===0?o[0]??null:null)}));return s.length===0&&o.length>0&&s.push(o[0]),{gltf:n,buffers:s}}async function sI(e,t){let r=di(t?.uri);if(!r)return null;let n=gI(r);if(n)return n.bytes;if(Um(r))return null;let o=pI(r);return o?fI(e,o):null}async function MG(e,t,r){let n=di(r.uri);if(n){let f=gI(n);if(f){let E=Vm(f.bytes);return E?{bytes:f.bytes,...E}:null}if(Um(n))return null;let S=pI(n);if(!S)return null;let g=await fI(e,S);if(!g)return null;let b=Ot.basename(S),y=Vm(g);return y?{bytes:g,...y,originalFileName:b}:null}let o=hr(r.bufferView);if(o==null)return null;let a=Array.isArray(t.gltf.bufferViews)?t.gltf.bufferViews:[],i=ut(a[o]),s=hr(i?.buffer)??0,c=t.buffers[s],d=hr(i?.byteOffset)??0,u=hr(i?.byteLength);if(!c||u==null||d+u>c.length)return null;let l=Buffer.from(c.subarray(d,d+u)),m=Vm(l);return m?{bytes:l,...m}:null}async function fI(e,t){if(Ot.isAbsolute(t)||Ot.win32.isAbsolute(t)||t.includes("\0"))return null;try{let r=await ci.realpath(Ot.dirname(e)),n=Ot.resolve(r,t),o=await ci.realpath(n);return wG(r,o)?await ci.readFile(o):null}catch{return null}}function pI(e){if(Um(e))return null;try{return decodeURIComponent(e)}catch{return null}}function wG(e,t){let r=Ot.relative(e,t);return r===""||!r.startsWith(`..${Ot.sep}`)&&r!==".."&&!Ot.isAbsolute(r)}function gI(e){let t=/^data:([^;,]+)?(?:;[^,]*)?,(.*)$/is.exec(e);if(!t)return null;let r=e.slice(0,e.indexOf(","));try{return{bytes:r.toLowerCase().includes(";base64")?Buffer.from(t[2]??"","base64"):Buffer.from(decodeURIComponent(t[2]??""),"utf8")}}catch{return null}}function Vm(e){return e.length>=8&&e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))?{extension:".png",mimeType:"image/png"}:e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?{extension:".jpg",mimeType:"image/jpeg"}:e.length>=12&&e.toString("ascii",0,4)==="RIFF"&&e.toString("ascii",8,12)==="WEBP"?{extension:".webp",mimeType:"image/webp"}:e.length>=12&&e.subarray(0,12).equals(Buffer.from([171,75,84,88,32,50,48,187,13,10,26,10]))?{extension:".ktx2",mimeType:"image/ktx2"}:null}function kG(e){return["baseColor.texture","normal.texture","metallicRoughness.texture","occlusion.texture","emission.texture","emission.maskTexture","alpha.texture"].includes(e)}function OG(e,t,r){let n=t.split("."),o=e;for(let a=0;a<n.length-1;a+=1){let i=n[a],s=ut(o[i])??{};o[i]=s,o=s}o[n[n.length-1]]=r}function Um(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("/")||Ot.win32.isAbsolute(e)}function ut(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function di(e){return typeof e=="string"&&e.trim()?e.trim():null}function hr(e){return Number.isInteger(e)&&e>=0?e:null}var U=class extends Error{constructor(t,r={}){super(t),this.name="PlayableEditorAssetRegistryError",this.details=r}};async function Go(e,t,r={}){if(!t.payload&&!t.payloadData)throw new U("missing_payload_arg");let n=await BG(e,t),o=e.codeKeyPolicy??"legacy";if(o==="disabled"&&Object.prototype.hasOwnProperty.call(n,"codeKey"))throw new U("payload_code_key_disabled",{codeKeyPolicy:o,codeKey:n.codeKey});let a=v.resolve(e.cwd,String(n.sourcePath??n.assetPath??"")),i=jG(e,a);if(!i)throw new U(e.unsupportedSourceErrorCode??r.sourceMustBeSupportedAsset??"source_must_be_supported_asset",{sourcePath:a,supportedExtensions:PI(e)});try{await W.access(a,RG.R_OK)}catch(h){let R=vo(h)?h.code:void 0,K=R==="EACCES"||R==="EPERM"?"source_file_unreadable":r.sourceFileNotFound??"source_file_not_found";throw new U(K,{sourcePath:a,...R?{nodeCode:R}:{}})}let s=KG(n);await W.mkdir(e.generatedDir,{recursive:!0});let c=await Zt(e),d=await Qm(a),u=Hc(n.kind??n.assetKind??n.assetType,a);if(!u)throw new U("unsupported_asset_kind",{sourcePath:a,assetType:n.assetType});Jm(u,a,"source_path");let l=UG(c,n,s,a,d,u,e),m=ae(n.assetName)??l?.originalFileName??v.basename(a),f=ae(n.guid);if(l&&f&&l.guid!==f)throw new U("payload_guid_must_match_existing_asset",{guid:f,existingGuid:l.guid,existingAssetId:l.assetId});let S=l?.guid??f??Qc.randomUUID(),g=ae(n.projectAssetId),b=Uc(u,S);if(l?.assetId&&l.assetId!==b)throw new U("manifest_asset_id_must_match_guid",{guid:S,assetId:l.assetId,expectedAssetId:b});if(g&&g!==b)throw new U("project_asset_id_must_match_guid",{guid:S,projectAssetId:g,expectedAssetId:b});let y=i===".gltf"?v.posix.join(b,v.basename(a)):`${b}${i}`,E=NG(e,{existing:l,sourcePath:a,kind:u,targetFileName:y}),I=ui(e,E,u,"target_path"),P=new Date().toISOString(),A=hm(ae(n.displayName)??l?.displayName,m),$=Zc({...Zc(l?.external)??{},...s??{}}),z=!1,p=[],D=null;try{await W.mkdir(v.dirname(I),{recursive:!0});let h=_G(a,I),R=h||await AI(I),K=!l||l.contentHash!==d.contentHash||!R;!h&&K&&(await W.copyFile(a,I),z=!l,i===".gltf"&&await CG(a,I));let F=await xI(e,{existing:l,payload:n,sourcePath:a,targetPath:I,kind:u,guid:S,assetId:b}),Ir=Ke(l?.metadata),er=Ke(F);if(u==="model"&&(Ir.assetAnalysisStatus==="complete"||Object.keys(Ke(Ir.assetAnalysis)).length>0)&&er.assetAnalysisStatus==="unavailable")throw new U("source_asset_analysis_failed",{sourcePath:a,assetId:b,guid:S});if(u==="model"){let tr=await vG({config:e,manifest:c,metadata:F,sourcePath:a,sourceAssetId:b,sourceAssetGuid:S,sourceDisplayName:A,now:P});p=tr.createdPaths,F=mI(F,tr.references)}let Hr=Ym({...l??{},guid:S,assetId:b,kind:u,displayName:A,relativePath:E,originalFileName:m,...o==="legacy"?{codeKey:Em(ae(n.codeKey)??ae(n.assetName)??l?.codeKey,m)}:{},...ae(n.category)?{category:ae(n.category)}:{},placeable:u==="texture"?!0:typeof n.placeable=="boolean"?n.placeable:l?.placeable??u==="model",...Am(n.warmupCount)!=null?{warmupCount:Am(n.warmupCount)}:{},...typeof n.singleton=="boolean"?{singleton:n.singleton}:{},...xm(n.materialMode)?{materialMode:xm(n.materialMode)}:{},...Tm(n.scale)?{defaults:{transform:{scale:Tm(n.scale)}}}:{},contentHash:d.contentHash,byteSize:d.byteSize,external:$,metadata:F,createdAt:l?.createdAt??P,updatedAt:K?P:l?.updatedAt??P});if(!Hr)throw new U("invalid_manifest_entry",{assetId:b,guid:S});D=Hr;let Si=c.findIndex(tr=>tr.guid===S||tr.assetId===b);Si>=0?c[Si]=Hr:c.push(Hr),c.sort(qG),await ZG(e,c)}catch(h){z&&await W.rm(i===".gltf"?v.dirname(I):I,{recursive:i===".gltf",force:!0}).catch(()=>{});for(let R of p)await W.rm(R,{force:!0}).catch(()=>{});throw h}return{ok:!0,guid:S,assetId:b,kind:u,...D?.contentHash?{contentHash:D.contentHash}:{},...D?.external?{external:D.external}:{},displayName:D?.displayName,originalFileName:D?.originalFileName,assetUrl:zG(e,E,u),targetPath:I,manifestPath:e.manifestPath,registryPath:e.registryPath}}async function CG(e,t){let r;try{r=JSON.parse(await W.readFile(e,"utf8"))}catch{throw new U("gltf_source_invalid_json")}let n=v.dirname(await W.realpath(e)),o=v.dirname(t),a=[...Array.isArray(r.buffers)?r.buffers:[],...Array.isArray(r.images)?r.images:[]],i=new Set;for(let s of a){let c=ae(Ke(s)?.uri);if(!c||c.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(c)||c.startsWith("//"))continue;let d;try{d=decodeURIComponent(c.split(/[?#]/,1)[0])}catch{continue}let u=d.replace(/\\/g,"/"),l=v.posix.normalize(u);if(!l||l==="."||l===".."||l.startsWith("../")||v.posix.isAbsolute(l)||i.has(l))continue;i.add(l);let m;try{m=await W.realpath(v.resolve(n,...l.split("/")))}catch{continue}try{Km(n,m,"gltf_dependency_path_escape")}catch{continue}let f=v.resolve(o,...l.split("/"));Km(o,f,"gltf_dependency_target_escape"),await W.mkdir(v.dirname(f),{recursive:!0}),await W.copyFile(m,f)}}function Km(e,t,r){let n=v.relative(e,t);if(!n||n===".."||n.startsWith(`..${v.sep}`)||v.isAbsolute(n))throw new U(r)}async function vG(e){let t=dI(e.metadata),r=lI(e.metadata),n=await cI(e.sourcePath,{imageIndexes:t}),o=[],a=new Map,i=[];try{for(let d of n){let u=li(d.bytes),l=e.manifest.find(A=>A.kind==="texture"&&A.contentHash===u.contentHash&&Ke(Ke(A.metadata).capabilities).materialTexture!==!1&&Ke(A.metadata).textureUsage!=="environment");if(l){a.set(d.imageIndex,l),o.push({imageIndex:d.imageIndex,textureAssetId:l.assetId});continue}let m=XG(u.contentHash),f=Uc("texture",m),S=e.manifest.find(A=>A.guid===m||A.assetId===f);if(S)throw new U("derived_texture_identity_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,contentHash:u.contentHash,conflictingAssetId:S.assetId,conflictingContentHash:S.contentHash});let g=`${f}${d.extension}`,b=TI(e.config,"texture",g),y=ui(e.config,b,"texture","derived_texture_target_path");if(await W.mkdir(v.dirname(y),{recursive:!0}),await AI(y)){let A=await Qm(y);if(A.contentHash!==u.contentHash)throw new U("derived_texture_target_conflict",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f,targetPath:y,contentHash:u.contentHash,existingContentHash:A.contentHash})}else await JG(y,d.bytes),i.push(y);let E=d.displayName?`${e.sourceDisplayName} / ${d.displayName}`:`${e.sourceDisplayName} Texture ${d.imageIndex+1}`,I=await xI(e.config,{existing:null,payload:{metadata:{textureUsage:"material",capabilities:{materialTexture:!0,environmentTexture:!1},derivedFrom:{kind:"gltf-image",sourceAssetId:e.sourceAssetId,sourceAssetGuid:e.sourceAssetGuid,imageIndex:d.imageIndex,mimeType:d.mimeType}}},sourcePath:y,targetPath:y,kind:"texture",guid:m,assetId:f}),P=Ym({guid:m,assetId:f,kind:"texture",displayName:E,relativePath:b,originalFileName:d.originalFileName??`${YG(E)}${d.extension}`,category:"Texture",placeable:!0,contentHash:u.contentHash,byteSize:u.byteSize,metadata:I,createdAt:e.now,updatedAt:e.now});if(!P)throw new U("invalid_derived_texture_manifest_entry",{sourceAssetId:e.sourceAssetId,imageIndex:d.imageIndex,assetId:f});e.manifest.push(P),a.set(d.imageIndex,P),o.push({imageIndex:d.imageIndex,textureAssetId:f})}let s=new Map,c=new Map;for(let d of a.values())v.extname(d.relativePath).toLowerCase()===".ktx2"&&s.set(d.assetId,d);for(let d of r){let u=a.get(d.imageIndex),l=a.get(d.previewImageIndex);!u||!l||v.extname(u.relativePath).toLowerCase()!==".ktx2"||c.set(u.assetId,l.assetId)}for(let d of s.values()){let u=Ke(d.metadata),l=GG(u);delete l[e.sourceAssetId];let m=c.get(d.assetId);m&&(l[e.sourceAssetId]=m);let f=Object.fromEntries(Object.entries(l).sort(([b],[y])=>b.localeCompare(y))),S=Object.values(f)[0],g={...u};S?(g.previewTextureAssetId=S,g.previewTextureAssetIdsBySourceAssetId=f):(delete g.previewTextureAssetId,delete g.previewTextureAssetIdsBySourceAssetId),d.metadata=g}return{references:o,createdPaths:i}}catch(s){for(let c of i)await W.rm(c,{force:!0}).catch(()=>{});throw s}}function GG(e){let t={},r=Ke(e.previewTextureAssetIdsBySourceAssetId);for(let[a,i]of Object.entries(r)){let s=ae(a),c=ae(i);s&&c&&(t[s]=c)}if(Object.keys(t).length>0)return t;let n=ae(e.previewTextureAssetId),o=ae(Ke(e.derivedFrom).sourceAssetId);return n&&o&&(t[o]=n),t}async function Wm(e,t={}){let r=await II(e,t,!1),{availabilityIssues:n,...o}=r;return o}async function qm(e,t={}){return II(e,t,!0)}async function II(e,t,r){let n=await Zt(e),o=[],a=[];for(let i of n){let s=ui(e,i.relativePath,i.kind,"refresh_source_path"),c;try{c=await Qm(s)}catch(m){let f=bI(i,m,t,"source-audit",s);if(!r||!f)throw SI(f,m,s);a.push(f);continue}let d=i.kind==="model"&&Ke(i.metadata).assetMetadataVersion!==Bm,u=i.kind==="texture"&&i.placeable===!1;if(i.contentHash===c.contentHash&&i.byteSize===c.byteSize&&!d&&!u)continue;let l;try{l=await Go(e,{payloadData:{sourcePath:s,guid:i.guid,projectAssetId:i.assetId,kind:i.kind}},t)}catch(m){let f=bI(i,m,t,"source-analysis",s);if(!r||!f)throw SI(f,m,s);a.push(f);continue}if(!l.contentHash)throw new U("asset_refresh_missing_content_hash",{assetId:i.assetId,guid:i.guid,sourcePath:s});o.push({guid:i.guid,assetId:i.assetId,kind:i.kind,...i.contentHash?{previousContentHash:i.contentHash}:{},contentHash:l.contentHash})}return{ok:!0,scannedAssetCount:n.length,refreshedAssets:o,availabilityIssues:a}}function bI(e,t,r,n,o){let a=r.sourceFileNotFound??"source_file_not_found",i=t instanceof U?t.message:void 0,s=vo(t)?t.code:t instanceof U?ae(t.details.nodeCode):void 0,c=i===a||i==="source_file_not_found"||i==="source_file_unreadable"||i==="source_asset_analysis_failed"||i==="gltf_source_invalid_json",d=vo(t)&&typeof t.path=="string"?v.resolve(t.path):null;if(!c&&(!s||n!=="source-audit"&&d!==v.resolve(o)))return null;let u=i==="source_asset_analysis_failed"?"analysis-failed":i==="gltf_source_invalid_json"?"invalid":s==="ENOENT"||i===a||i==="source_file_not_found"?"missing":s==="EACCES"||s==="EPERM"||i==="source_file_unreadable"?"unreadable":s==="EISDIR"||s==="EINVAL"?"invalid":"audit-failed",l=i??(u==="missing"?a:u==="unreadable"?"source_file_unreadable":u==="invalid"?"source_file_invalid":"source_file_audit_failed");return{assetId:e.assetId,guid:e.guid,kind:e.kind,relativePath:e.relativePath,stage:n,reason:u,code:l,...s?{nodeCode:s}:{},retryable:!0}}function SI(e,t,r){return!e||t instanceof U?t:new U(e.code,{assetId:e.assetId,guid:e.guid,sourcePath:r,...e.nodeCode?{nodeCode:e.nodeCode}:{}})}async function Zt(e){let t=await Xm(e.manifestPath,[]);if(!Array.isArray(t))throw new U("manifest_invalid_root",{manifestPath:e.manifestPath});let r=t.map((i,s)=>{let c=Ym(i,!0);if(!c)throw new U("manifest_invalid_entry",{index:s,manifestPath:e.manifestPath});return c}),n=new Set,o=new Set,a=e.codeKeyPolicy??"legacy";for(let i of r){if(a==="disabled"&&i.codeKey)throw new U("manifest_code_key_disabled",{manifestPath:e.manifestPath,codeKeyPolicy:a,assetId:i.assetId,codeKey:i.codeKey});if(n.has(i.assetId))throw new U("manifest_duplicate_asset_id",{assetId:i.assetId});if(o.has(i.guid))throw new U("manifest_duplicate_guid",{guid:i.guid});n.add(i.assetId),o.add(i.guid)}return r}async function jo(e){return e.loadRules?e.loadRules():e.rulesPath?Xm(e.rulesPath,{}):{}}function yI(e){return(Array.isArray(e)?e:[e]).filter(r=>typeof r=="string"&&!!r.trim()).map(r=>{let n=r.trim().toLowerCase();return n.startsWith(".")?n:`.${n}`})}function PI(e){let t=yI(e.supportedExtensions??e.supportedExtension);return t.length>0?t:yI(ko)}function jG(e,t){let r=t.toLowerCase();return PI(e).find(n=>r.endsWith(n))??null}function NG(e,t){return t.existing?.relativePath?t.existing.relativePath:FG(e,t.sourcePath,t.kind)??TI(e,t.kind,t.targetFileName)}function TI(e,t,r){let n=e.relativeImportedPath;return n.length>=2?n(t,r):n({kind:t,fileName:r})}function FG(e,t,r){let n=e.assetRootDir??e.assetsDir;if(!n)return null;let o=v.resolve(t);return!hI(v.resolve(n),o)||hI(v.resolve(e.generatedDir),o)?null:(Jm(r,o,"source_path"),v.relative(e.generatedDir,o).split(v.sep).join("/"))}function hI(e,t){let r=v.relative(e,t);return r===""||!r.startsWith("..")&&!v.isAbsolute(r)}function _G(e,t){return v.relative(v.resolve(e),v.resolve(t))===""}function $G(e,t,r){let n=v.relative(e,t);if(n.startsWith("..")||v.isAbsolute(n))throw new U(`${r}_outside_allowed_directory`,{parent:e,child:t})}function LG(e,t,r){let n=v.relative(e,t);if(!n.startsWith("..")&&!v.isAbsolute(n))throw new U(`${r}_inside_forbidden_directory`,{parent:e,child:t})}function ui(e,t,r,n){let o=v.resolve(e.generatedDir,t),a=v.resolve(e.assetRootDir??e.assetsDir??e.importedDir??e.generatedDir);return $G(a,o,n),LG(v.resolve(e.generatedDir),o,n),Jm(r,o,n),o}function zG(e,t,r){let n=ui(e,t,r,"asset_url_path");return typeof e.publicUrlForCatalogRelativePath=="function"?e.publicUrlForCatalogRelativePath(t):typeof e.publicUrlForRelativePath=="function"?e.publicUrlForRelativePath(t):`/${v.relative(e.cwd,n).split(v.sep).join("/")}`}function Jm(e,t,r){let n=v.extname(t).toLowerCase(),o=Im(e);if(!o.includes(n))throw new U(`${r}_unsupported_extension`,{kind:e,filePath:t,extension:n,supportedExtensions:o})}async function Xm(e,t){try{return JSON.parse(await W.readFile(e,"utf8"))}catch(r){if(vo(r)&&r.code==="ENOENT")return t;throw r}}async function BG(e,t){if(t.payloadData)return structuredClone(t.payloadData);if(!t.payload)return{};let r=v.resolve(e.cwd,t.payload),n=await Xm(r,null);if(!n||typeof n!="object"||Array.isArray(n))throw new U("invalid_payload_json",{payloadPath:r});return n}function Ym(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=t?Zm:ae,o=n(r.guid),a=n(r.assetId),i=n(r.kind);if(t&&(!i||"assetKind"in r||"assetType"in r))return null;let s=t?bm.includes(i)?i:null:Hc(r.kind??r.assetKind??r.assetType,r.relativePath),c=n(r.displayName),d=n(r.relativePath);if(!o||!a||!s||!c||!d||t&&(!Gn(r,"originalFileName")||!Gn(r,"codeKey")||!Gn(r,"category")||!Gn(r,"materialMode")||!Gn(r,"contentHash")||!Gn(r,"createdAt")||!Gn(r,"updatedAt")||"placeable"in r&&typeof r.placeable!="boolean"||"warmupCount"in r&&(!Number.isInteger(r.warmupCount)||r.warmupCount<0)||"singleton"in r&&typeof r.singleton!="boolean"||"defaults"in r&&Vr(r.defaults)==null||"byteSize"in r&&(!Number.isFinite(r.byteSize)||r.byteSize<0)||"metadata"in r&&Vr(r.metadata)==null||"external"in r&&!VG(r.external)))return null;let u=Vr(r.metadata),l=n(r.originalFileName),m=n(r.codeKey),f=n(r.category),S=n(r.materialMode),g=Vr(r.defaults),b=n(r.contentHash),y=Zc(r.external),E=n(r.createdAt),I=n(r.updatedAt);return{guid:o,assetId:a,kind:s,displayName:c,relativePath:d,...l?{originalFileName:l}:{},...m?{codeKey:m}:{},...f?{category:f}:{},...typeof r.placeable=="boolean"?{placeable:r.placeable}:{},...typeof r.warmupCount=="number"?{warmupCount:r.warmupCount}:{},...typeof r.singleton=="boolean"?{singleton:r.singleton}:{},...S?{materialMode:S}:{},...g?{defaults:g}:{},...b?{contentHash:b}:{},...typeof r.byteSize=="number"?{byteSize:r.byteSize}:{},...y?{external:y}:{},...u?{metadata:u}:{},...E?{createdAt:E}:{},...I?{updatedAt:I}:{}}}function Zm(e){return typeof e=="string"&&e.length>0&&e===e.trim()?e:null}function Gn(e,t){return!(t in e)||Zm(e[t])!=null}function VG(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e,r=["platformAssetId","assetPath","assetUrl"],n=Object.keys(t);return n.length>0&&n.every(o=>r.includes(o)&&Zm(t[o])!=null)}function Zc(e,t=!1){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e,n=ae(r.platformAssetId),o;try{if(o=Wa(r.assetPath),t&&Object.prototype.hasOwnProperty.call(r,"assetPath")&&!o)throw new Error("external_asset_path_must_be_portable")}catch{if(t)throw new U("external_asset_path_must_be_portable",{assetPath:ae(r.assetPath)})}let a=ae(r.assetUrl);return!n&&!o&&!a?null:{...n?{platformAssetId:n}:{},...o?{assetPath:o}:{},...a?{assetUrl:a}:{}}}function Vr(e){return!e||typeof e!="object"||Array.isArray(e)?null:structuredClone(e)}async function xI(e,t){let r=Vr(t.payload?.metadata);if(typeof e.resolveAssetMetadata=="function"){let n=await e.resolveAssetMetadata({...t,existingMetadata:Vr(t.existing?.metadata),payloadMetadata:r}),o=Vr(n);return o||null}return si({kind:t.kind,sourcePath:t.sourcePath,existingMetadata:Vr(t.existing?.metadata),payloadMetadata:r,guid:t.guid,assetId:t.assetId,cwd:e.cwd,assetsDir:e.assetsDir})}function UG(e,t,r,n,o,a,i){let s=ae(t.guid),c=ae(t.projectAssetId);if(s){let l=e.find(m=>m.guid===s);if(l)return l}if(c){let l=e.find(m=>m.assetId===c);if(l)return l}if(r?.platformAssetId){let l=e.find(m=>m.kind===a&&HG(m.external)===r.platformAssetId);if(l)return l}if(r?.assetPath){let l=e.find(m=>m.kind===a&&WG(m.external)===r.assetPath);if(l)return l}let d=v.resolve(n),u=e.find(l=>{if(l.kind!==a)return!1;try{return v.resolve(ui(i,l.relativePath,l.kind,"manifest_asset_path"))===d}catch{return!1}});if(u)return u;if(o.contentHash){let l=e.find(m=>m.kind===a&&m.contentHash===o.contentHash);if(l)return l}return null}function KG(e){return Zc({...e.external&&typeof e.external=="object"&&!Array.isArray(e.external)?e.external:{},platformAssetId:e.external?.platformAssetId??e.platformAssetId??e.assetId,assetUrl:e.external?.assetUrl??e.assetUrl},!0)}function HG(e){return ae(Ke(e).platformAssetId)}function WG(e){return ae(Ke(e).assetPath)}function qG(e,t){return e.kind.localeCompare(t.kind)||e.displayName.localeCompare(t.displayName)||e.assetId.localeCompare(t.assetId)}async function Hm(e,t){try{if(await W.readFile(e,"utf8")===t)return!1}catch(n){if(!vo(n)||n.code!=="ENOENT")throw n}let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{return await W.writeFile(r,t),await W.rename(r,e),!0}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function JG(e,t){let r=`${e}.tmp-${process.pid}-${Date.now()}`;try{await W.writeFile(r,t),await W.rename(r,e)}catch(n){throw await W.rm(r,{force:!0}).catch(()=>{}),n}}async function Qm(e){let t=await W.readFile(e),r=await W.stat(e);if(v.extname(e).toLowerCase()!==".gltf")return{...li(t),byteSize:r.size};let n;try{n=JSON.parse(t.toString("utf8"))}catch{return{...li(t),byteSize:r.size}}let o=v.dirname(await W.realpath(e)),a=new Map;for(let d of[...Array.isArray(n.buffers)?n.buffers:[],...Array.isArray(n.images)?n.images:[]]){let u=ae(Ke(d)?.uri);if(!u||u.startsWith("data:")||/^[a-z][a-z0-9+.-]*:/i.test(u)||u.startsWith("//"))continue;let l;try{l=decodeURIComponent(u.split(/[?#]/,1)[0])}catch{continue}let m=v.posix.normalize(l.replace(/\\/g,"/"));if(!m||m==="."||m===".."||m.startsWith("../")||v.posix.isAbsolute(m))continue;let f;try{f=await W.realpath(v.resolve(o,...m.split("/")))}catch{continue}try{Km(o,f,"gltf_dependency_path_escape")}catch{continue}a.set(m,f)}let i=Qc.createHash("sha256").update("playable-editor-gltf-bundle-v1\0"),s=[{path:"",...li(t)}],c=r.size;for(let[d,u]of[...a].sort(([l],[m])=>l.localeCompare(m))){let l=await W.readFile(u);s.push({path:d,...li(l)}),c+=l.byteLength}return i.update(JSON.stringify(s)),{contentHash:`sha256:${i.digest("hex")}`,byteSize:c}}function li(e){return{contentHash:`sha256:${Qc.createHash("sha256").update(e).digest("hex")}`,byteSize:e.byteLength}}function XG(e){let t=Qc.createHash("sha256").update(`material-texture\0${e}`).digest("hex");return`${t.slice(0,8)}-${t.slice(8,12)}-5${t.slice(13,16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}function YG(e){return e.trim().replace(/[^\p{L}\p{N}._-]+/gu,"_").replace(/^_+|_+$/g,"")||"Imported_Texture"}async function AI(e){try{return await W.access(e),!0}catch{return!1}}async function ZG(e,t){let r=zE(t,{codeKeyPolicy:e.codeKeyPolicy??"legacy"});await W.mkdir(v.dirname(e.manifestPath),{recursive:!0}),await W.mkdir(v.dirname(e.registryPath),{recursive:!0});let n=await EI(e.manifestPath),o=await EI(e.registryPath);try{await Hm(e.manifestPath,`${JSON.stringify(t,null,2)}
13
+ `),await Hm(e.registryPath,r)}catch(a){let i=[];for(let[s,c]of[[e.manifestPath,n],[e.registryPath,o]])try{await QG(s,c)}catch(d){i.push(d)}if(i.length>0){let s=new Error("generated_registry_transaction_rollback_failed");throw s.cause=a,s.rollbackErrors=i,s}throw a}}async function EI(e){try{return(await W.lstat(e)).isFile()?{kind:"file",content:await W.readFile(e,"utf8")}:{kind:"other"}}catch(t){if(vo(t)&&t.code==="ENOENT")return{kind:"missing"};throw t}}async function QG(e,t){if(t.kind!=="other"){if(t.kind==="missing"){await W.rm(e,{force:!0});return}await Hm(e,t.content)}}function ae(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ke(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function vo(e){return e instanceof Error&&"code"in e}function DI(e){return{async loadManifest(){let t=await Zt(e.assetRegistryConfig),r=e.textureRegistryConfig?await Zt(e.textureRegistryConfig):[];return{ok:!0,manifest:t,textureManifest:r}},async loadEditorAssetLibrary(){let t=await e.loadAssetCatalogEntries(),r=[...e.createAssetLibrary?e.createAssetLibrary(t):Gs(t)];return{ok:!0,assets:r,summary:{assets:r.length}}},async importAsset({payload:t}){let r=e.selectRegistryConfig?e.selectRegistryConfig({payload:t,assetRegistryConfig:e.assetRegistryConfig,textureRegistryConfig:e.textureRegistryConfig}):ej(t,e.assetRegistryConfig,e.textureRegistryConfig),n=await jo(r),o=nj(n.errorCodes),a=await Zt(r),i=typeof t.projectAssetId=="string"&&t.projectAssetId.trim()?t.projectAssetId.trim():null,s=t.assetPath?await Go(r,{payloadData:{...t,sourcePath:t.assetPath}},o):null,c=s?.assetId??i;if(!c)throw new Error("asset_import_result_missing_asset_id");s&&await rj(e,r,s);let d=await e.loadAssetCatalogEntries(),u=[...e.createAssetLibrary?e.createAssetLibrary(d):Gs(d)],l=u.find(m=>m.assetId===c||m.id===c);if(!l)throw new Error("asset_import_catalog_projection_missing");return{ok:!0,assetId:c,asset:l,assets:u,disposition:s&&a.some(m=>m.assetId===c)?"deduplicated":s?"created":"existing"}}}}function ej(e,t,r){return r&&tj(e)?r:t}function tj(e){let t=typeof e.assetType=="string"?e.assetType.toLowerCase():"";if(/^(texture|image|png|jpg|jpeg|webp)$/.test(t))return!0;let r=typeof e.kind=="string"?e.kind.toLowerCase():"";if(/^(texture|image)$/.test(r)||(typeof e.mimeType=="string"?e.mimeType.toLowerCase():"").startsWith("image/"))return!0;let o=[e.sourcePath,e.assetPath,e.assetName].filter(a=>typeof a=="string").join(`
14
+ `);return/\.(png|jpe?g|webp)(?:$|[?#])/i.test(o)}async function rj(e,t,r){if(!e.invalidateFiles)return;let n=typeof e.additionalInvalidationFiles=="function"?await e.additionalInvalidationFiles():e.additionalInvalidationFiles??[],o=new Set([...n,r.manifestPath||t.manifestPath,r.registryPath||t.registryPath]);await e.invalidateFiles([...o])}function nj(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}async function ef(e,t={}){let r=[],n=0;for await(let o of e){let a=Buffer.from(o);if(n+=a.byteLength,t.maxBytes!==void 0&&n>t.maxBytes)throw Object.assign(new Error("asset_import_payload_too_large"),{code:"asset_import_payload_too_large",details:{maxBytes:t.maxBytes}});r.push(a)}return JSON.parse(Buffer.concat(r).toString("utf8")||"{}")}function Ur(e,t,r){if(e.statusCode=t.statusCode,mi(e,r),t.body==null){e.end();return}e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(JSON.stringify(t.body))}function mi(e,t={}){e.setHeader("Access-Control-Allow-Origin",t.origin??"*"),e.setHeader("Access-Control-Allow-Methods",t.methods??"GET,POST,OPTIONS"),e.setHeader("Access-Control-Allow-Headers",t.headers??"Content-Type, Authorization"),e.setHeader("Cross-Origin-Resource-Policy",t.resourcePolicy??"cross-origin"),e.setHeader("Cross-Origin-Embedder-Policy",t.embedderPolicy??"credentialless"),e.setHeader("Cache-Control",t.cacheControl??"no-store")}import{existsSync as vI,readFileSync as GI}from"node:fs";import{mkdir as wI,rename as cj,rm as kI,writeFile as dj}from"node:fs/promises";import{randomUUID as lj}from"node:crypto";import jn from"node:path";import oj from"node:path";var ed=new Map;async function td(e,t){let r=[...new Set(e.map(i=>oj.resolve(i)))].sort(),n=[...new Set(r.map(i=>ed.get(i)).filter(Boolean))],o=()=>{},a=new Promise(i=>{o=i});for(let i of r)ed.set(i,a);await Promise.all(n);try{return await t()}finally{o();for(let i of r)ed.get(i)===a&&ed.delete(i)}}import{performance as tf}from"node:perf_hooks";var aj=1,ij=["prepare","compile","validate","stringify","write","checkpoint"];function MI(){let e=[],t=(r,n,o)=>{let a=process.memoryUsage();e.push({phase:r,durationMs:rf(tf.now()-n),rssBeforeBytes:o.rss,rssAfterBytes:a.rss,maxObservedRssBytes:Math.max(o.rss,a.rss),heapUsedBeforeBytes:o.heapUsed,heapUsedAfterBytes:a.heapUsed,maxObservedHeapUsedBytes:Math.max(o.heapUsed,a.heapUsed)})};return{measure(r,n){let o=process.memoryUsage(),a=tf.now();try{return n()}finally{t(r,a,o)}},async measureAsync(r,n){let o=process.memoryUsage(),a=tf.now();try{return await n()}finally{t(r,a,o)}},snapshot(){return sj(e)}}}function sj(e){let t=new Map;for(let n of e){let o=t.get(n.phase);if(!o){t.set(n.phase,{...n});continue}o.durationMs=rf(o.durationMs+n.durationMs),o.rssAfterBytes=n.rssAfterBytes,o.maxObservedRssBytes=Math.max(o.maxObservedRssBytes,n.maxObservedRssBytes),o.heapUsedAfterBytes=n.heapUsedAfterBytes,o.maxObservedHeapUsedBytes=Math.max(o.maxObservedHeapUsedBytes,n.maxObservedHeapUsedBytes)}let r=ij.flatMap(n=>{let o=t.get(n);return o?[o]:[]});return{schemaVersion:aj,measuredDurationMs:rf(r.reduce((n,o)=>n+o.durationMs,0)),maxObservedRssBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedRssBytes),0),maxObservedHeapUsedBytes:r.reduce((n,o)=>Math.max(n,o.maxObservedHeapUsedBytes),0),phases:r}}function rf(e){return Math.round(Math.max(0,e)*1e3)/1e3}async function jI(e){let t=e.paths,r=fi(t.editorScenePath),n=r?da(r).document:null,o=fi(t.scenePath),a=await e.loadServices(e.server,e.projectRoot),i=await e.listEditorAssetLibrary(e.server,"report");n&&Rm(n),n&&Ma(n,i);let s=n?a.ensureEditorSceneEnvironmentDefaults(a.enrichEditorSceneDocumentAssets(a.ensureAuthoringSource(n),i)):null;s&&Wc(s);let c=t.renderingConfigPath?fi(t.renderingConfigPath):void 0;c&&gt(c);let d={...Br(s),...t.renderingConfigPath?{rendering:c}:{}},u=$I(t.shadowsConfigPath),l=se(o),m=typeof l?.version=="number"?l.version:void 0,f=typeof l?.updatedAt=="string"?l.updatedAt:void 0;return{ok:!0,editorScenePath:t.editorScenePath,scenePath:t.scenePath,editorScene:s,assets:i,...m===void 0?{}:{version:m},...f===void 0?{}:{updatedAt:f},...Object.keys(d).length>0?{companionConfigs:d}:{},...u?{shadowMapExperimentConfig:u}:{},drift:s?a.detectRuntimeInputDrift(s,o):null,summary:_I(s)}}async function NI(e){Nn(e),RI(e.body,"$",!0),RI(e.rawEditorScene,"$.editorScene");let t=Mm(e.body),r=Br(e.body),n=Object.prototype.hasOwnProperty.call(r,"rendering");t&&gt(t);let o=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig");if(o&&LI(e.body),o&&!e.paths.shadowsConfigPath)throw new Error("shadows_config_path_missing");let a=[e.paths.editorScenePath,...e.saveMode==="local-commit-save"?[e.paths.scenePath]:[],...n&&e.paths.renderingConfigPath?[e.paths.renderingConfigPath]:[],...o&&e.paths.shadowsConfigPath?[e.paths.shadowsConfigPath]:[]];return td(a,()=>(Nn(e),uj(e)))}async function uj(e){let t=MI(),r=t.measure("prepare",()=>mj(e)),n=da(r).document,o=await t.measureAsync("prepare",()=>e.saveServices(e.server,e.projectRoot));Nn(e);let a=e.paths,i=Br(e.body),s=Mm(e.body),c=Object.prototype.hasOwnProperty.call(i,"rendering"),d=Object.prototype.hasOwnProperty.call(i,vn),u=i[vn],l=Ar(u),m=t.measure("prepare",()=>fi(a.scenePath)??{}),f=Object.prototype.hasOwnProperty.call(e.body,"shadowMapExperimentConfig"),g=LI(e.body)??$I(a.shadowsConfigPath);t.measure("validate",()=>{nf(u,l,{present:d,path:"$.companionConfigs.staticShadows"})});let b=Br(n),y=b[vn];t.measure("validate",()=>{nf(y,Ar(y),{present:Object.prototype.hasOwnProperty.call(b,vn),path:"$.editorScene.companionConfigs.staticShadows"})});let E=se(m)?.staticShadows;t.measure("validate",()=>{nf(E,Ar(E),{present:Object.prototype.hasOwnProperty.call(m,"staticShadows"),path:"$.scene.staticShadows"}),Rm(n)});let I=s&&e.normalizeRenderingProfile?e.normalizeRenderingProfile(s):s,P=await t.measureAsync("prepare",()=>e.listEditorAssetLibrary(e.server,"strict"));Nn(e),t.measure("validate",()=>{Ma(n,P)});let A=t.measure("prepare",()=>{let xe=o.ensureEditorSceneEnvironmentDefaults(o.enrichEditorSceneDocumentAssets(o.ensureAuthoringSource(n),P));return xc(xe,4)});t.measure("validate",()=>{o.assertEditorSceneDocument(A),o.assertEditorSceneMaterialAssetIntegrity(A)});let $=t.measure("prepare",()=>o.bumpEditorSceneAuthoringSourceRevision(A)),z=d?l:l??dE(n)??Ar(se(m)?.staticShadows),p=t.measure("prepare",()=>xc(fj($,{staticShadows:z}),4)),D=t.measure("prepare",()=>Zl(p,P)),h=t.measure("compile",()=>o.compileEditorSceneDocumentToSceneConfig($,m,{...s==null?{}:{renderingProfile:s},shadowMapExperimentConfig:g??null})),R=z?{...h.sceneConfig,staticShadows:z}:{...h.sceneConfig};z||delete R.staticShadows;let K=typeof m.version=="number"?m.version:void 0,ne=typeof K=="number"?K+1:1,F=new Date().toISOString(),Ir=t.measure("compile",()=>xc(e.saveMode==="local-commit-save"?{...R,version:ne,updatedAt:F}:R,4));t.measure("validate",()=>{ji(Ir)});let er=se(Ir)?.version,Hr=e.saveMode==="local-commit-save"&&typeof er=="number"?er:ne,Si=`/${jn.relative(e.projectRoot,a.scenePath).split(jn.sep).join("/")}?v=${encodeURIComponent(String(Hr))}`,tr="",zn=[];try{{let xe=t.measure("stringify",()=>`${JSON.stringify(D,null,2)}
15
+ `);await t.measureAsync("write",()=>rd(e,zn,a.editorScenePath,xe))}if(s){if(!a.renderingConfigPath)throw new Error("rendering_config_path_missing");Nn(e),await wI(jn.dirname(a.renderingConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(s,null,2)}
16
+ `);await t.measureAsync("write",()=>rd(e,zn,a.renderingConfigPath,xe))}else if(c&&!a.renderingConfigPath)throw new Error("rendering_config_path_missing");if(f){if(!a.shadowsConfigPath||!g)throw new Error("shadows_config_path_missing");await wI(jn.dirname(a.shadowsConfigPath),{recursive:!0});let xe=t.measure("stringify",()=>`${JSON.stringify(g,null,2)}
17
17
  `);await t.measureAsync("write",()=>rd(e,zn,a.shadowsConfigPath,xe))}tr=t.measure("stringify",()=>`${JSON.stringify(Ir,null,2)}
18
- `),e.saveMode==="local-commit-save"&&await t.measureAsync("write",()=>rd(e,zn,a.scenePath,tr)),Nn(e),await t.measureAsync("write",async()=>{for(let xe of zn)await ij(xe.temporaryPath,xe.targetPath),xe.committed=!0;c&&!s&&await MI(a.renderingConfigPath,{force:!0})})}finally{await Promise.all(zn.filter(xe=>!xe.committed).map(xe=>MI(xe.temporaryPath,{force:!0}).catch(()=>{})))}let bf=[...c&&a.renderingConfigPath?e.createRenderingInvalidationFiles?.(e.projectRoot,a.renderingConfigPath)??[a.renderingConfigPath]:[],...f&&a.shadowsConfigPath?[a.shadowsConfigPath]:[]];return bf.length>0&&e.invalidateFiles?.(e.server,bf),{ok:!0,mode:e.saveMode,editorScenePath:a.editorScenePath,scenePath:a.scenePath,expectedVersion:K,...e.saveMode==="local-commit-save"?{version:Hr,updatedAt:F,sceneUrl:yi}:{},editorScene:p,...g?{shadowMapExperimentConfig:g}:{},...c||d?{companionConfigs:{...c?{rendering:s}:{},...d?{staticShadows:z}:{}},...s?{renderingSummary:e.summarizeRenderingProfile?.(I??null)??null}:{}}:{},sceneJsonText:tr,performanceProfile:t.snapshot(),summary:{editorScene:NI($),compiled:h.summary}}}async function rd(e,t,r,n){Nn(e);let o=jn.join(jn.dirname(r),`.${jn.basename(r)}.${process.pid}.${cj()}.tmp`),a={targetPath:r,temporaryPath:o,committed:!1};t.push(a),await sj(o,n,{encoding:"utf8",signal:e.signal})}function Nn(e){if(!e.signal?.aborted&&(e.deadlineAt===void 0||Date.now()<e.deadlineAt))return;let t=new Error("Document export lifecycle deadline elapsed before filesystem persistence completed.");throw Object.assign(t,{code:"document_export_timeout"}),t}function lj(e){let t=pi(e.paths.editorScenePath);if(!t)return e.rawEditorScene;let r=wI(t);if(!r)return e.rawEditorScene;let n=wI(e.rawEditorScene),o=typeof e.body.expectedAuthoringSourceRevision=="number"&&Number.isFinite(e.body.expectedAuthoringSourceRevision)?e.body.expectedAuthoringSourceRevision:n?.revision??null;if(!(n?.sourceId===r.sourceId&&n.sourceType===r.sourceType)){let m={stage:e.saveMode==="prepare-platform-save"?"document.export":"document.save",expectedSourceId:r.sourceId,expectedSourceType:r.sourceType,actualSourceId:n?.sourceId??null,actualSourceType:n?.sourceType??null},f=new Error("authoring_source_identity_mismatch");throw Object.assign(f,{code:"authoring_source_identity_mismatch",details:m,...m}),f}if(n.revision===r.revision&&o===r.revision)return e.rawEditorScene;let i=se(e.body.authoringSourceConflictResolution);if(i?.strategy==="overwrite"&&typeof i.expectedPersistedRevision=="number"&&Number.isFinite(i.expectedPersistedRevision)&&i.expectedPersistedRevision===r.revision){let l=structuredClone(e.rawEditorScene),m=se(se(l.meta)?.authoringSource);return m&&(m.revision=r.revision),l}let c=e.saveMode==="prepare-platform-save"?"document.export":"document.save",d={stage:c,sourceId:r.sourceId,sourceType:r.sourceType,expectedRevision:o,submittedRevision:n.revision,persistedRevision:r.revision},u=new Error("authoring_source_revision_mismatch");throw Object.assign(u,{code:"authoring_source_revision_mismatch",stage:c,sourceId:r.sourceId,expectedRevision:o,actualRevision:r.revision,details:d}),u}function wI(e){let t=se(se(e.meta)?.authoringSource);return typeof t?.sourceId!="string"||!t.sourceId.trim()||typeof t.sourceType!="string"||!t.sourceType.trim()||typeof t.revision!="number"||!Number.isFinite(t.revision)?null:{sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision}}function tf(e,t,r){if(!r.present||e==null||t)return;let n=new Error(`schema.unsupportedVersion: ${r.path}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:r.path}),n}function jI(e){Wc(e)}function NI(e){let t=se(e),r=se(t?.meta),n=se(r?.authoringSource),o=se(t?.scene);return{schemaVersion:t?.schemaVersion??null,sourceId:n?.sourceId??null,sourceType:n?.sourceType??null,revision:n?.revision??null,assets:Array.isArray(t?.assets)?t.assets.length:0,gameObjects:Array.isArray(o?.gameObjects)?o.gameObjects.length:0,materialAssets:Array.isArray(o?.materialAssets)?o.materialAssets.length:0}}function uj(e,t){let r={...Br(e)};delete r.rendering;for(let[o,a]of Object.entries(t))a==null?delete r[o]:r[o]=a;let n={...e};return Object.keys(r).length>0?n.companionConfigs=r:delete n.companionConfigs,n}function pi(e){return RI(e)?JSON.parse(CI(e,"utf8")||"{}"):null}function FI(e){if(!e)return null;if(!RI(e))throw new Error(`shadows_config_missing:${e}`);let t=JSON.parse(CI(e,"utf8")||"{}");return Mi(t,"$"),structuredClone(t)}function _I(e){return Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentConfig")?(Mi(e.shadowMapExperimentConfig,"$.shadowMapExperimentConfig"),structuredClone(e.shadowMapExperimentConfig)):null}function kI(e,t,r=!1){let n=se(e);if(!n)return;for(let a of["shadowMapExperimentConfig","shadowsConfig"])if(!(r&&a==="shadowMapExperimentConfig")&&Object.prototype.hasOwnProperty.call(n,a))throw OI(`${t}.${a}`);let o=se(n.companionConfigs);if(o&&Object.prototype.hasOwnProperty.call(o,"shadows"))throw OI(`${t}.companionConfigs.shadows`)}function OI(e){let t=new Error(`shadow_map_experiment_config_readonly:${e}`);return Object.assign(t,{code:"shadowMapExperiment.configReadonly",path:e}),t}import Si from"node:path";import{pipeline as Ij}from"node:stream/promises";import{realpathSync as mj}from"node:fs";import nf from"node:path";function _o(e,t){let r=e.moduleGraph,n=new Set;for(let o of t)for(let a of fj(o)){let i=r.getModulesByFile(a);if(i)for(let s of i)r.invalidateModule(s,n)}}function fj(e){let t=nf.resolve(e),r=gi(t);return[...new Set([e,t,r,rf(e),rf(t),rf(r)])]}function gi(e){let t=nf.resolve(e);try{return mj(t)}catch{return t}}function rf(e){return e.split(nf.sep).join("/")}import{constants as $I}from"node:fs";import bi from"node:fs/promises";import Fn from"node:path";var pj=128*1024*1024,gj=512*1024*1024;async function $o(e){let t=[];for(let n=0;n<2;n+=1)try{await e.close();return}catch(o){t.push(o)}let r=new Error("project_file_close_failed");throw r.errors=t,r}function bj(e){let t=e.trim();if(!t||t!==e||t.includes("\0")||t.includes("\\")||Fn.posix.isAbsolute(t)||/^[A-Za-z]:\//.test(t))throw new Error("project_file_path_invalid");let r=t.split("/");if(r.some(n=>!n||n==="."||n===".."))throw new Error("project_file_path_invalid");return r.join("/")}function of(e){if(e===void 0)return pj;if(!Number.isSafeInteger(e)||e<=0)throw new Error("project_file_media_limit_invalid");return Math.min(e,gj)}async function nd(e,t){let r=bj(t),n=await bi.realpath(Fn.resolve(e)),o=Fn.resolve(n,...r.split("/"));LI(n,o),await Sj(n,r);let a;try{a=await bi.open(o,$I.O_RDONLY|($I.O_NOFOLLOW??0))}catch(i){throw i?.code==="ELOOP"?new Error("project_file_symlink_unsupported"):i}try{let i=await a.stat();if(!i.isFile())throw new Error("project_file_not_found");let s=await bi.realpath(o);if(LI(n,s),s!==o)throw new Error("project_file_symlink_unsupported");let c=await bi.stat(s);if(c.dev!==i.dev||c.ino!==i.ino)throw new Error("project_file_changed_during_read");return{absolutePath:o,handle:a,relativePath:r,stat:i}}catch(i){try{await $o(a)}catch(s){let c=new Error("project_file_close_failed");throw c.errors=[i,s],c}throw i}}function LI(e,t){let r=Fn.relative(e,t);if(!r||r===".."||r.startsWith(`..${Fn.sep}`)||Fn.isAbsolute(r))throw new Error("project_file_path_invalid")}async function Sj(e,t){let r=e;for(let n of t.split("/"))if(r=Fn.join(r,n),(await bi.lstat(r)).isSymbolicLink())throw new Error("project_file_symlink_unsupported")}import Er from"node:fs/promises";import mt from"node:path";var zI=512*1024,yj=new Set([".DS_Store",".cache",".git",".next",".nuxt",".parcel-cache",".turbo",".vite","build","coverage","dist","dist-tests","node_modules","output","playwright-report","test-results"]);async function BI(e,t={}){let r=await Er.realpath(mt.resolve(e)),n=Math.max(1,t.maxEntries??2e4),o=new Set([...yj,...t.ignoredNames??[]]),a=[],i=!1,s=async c=>{if(i)return;let d=mt.resolve(r,c),u=await hj(r,d);if(u){u.sort((l,m)=>Number(m.isDirectory())-Number(l.isDirectory())||l.name.localeCompare(m.name,void 0,{numeric:!0,sensitivity:"base"}));for(let l of u){if(l.name.startsWith(".")||o.has(l.name)||l.isSymbolicLink())continue;if(a.length>=n){i=!0;return}let m=mt.posix.join(c.split(mt.sep).join("/"),l.name),f=mt.resolve(r,...m.split("/")),S=await Ej(r,f);if(!S)continue;let g=S==="file"?mt.extname(l.name).slice(1).toLowerCase():"";a.push({path:m,name:l.name,parentPath:c?c.split(mt.sep).join("/"):null,kind:S,...g?{extension:g}:{}}),S==="directory"&&await s(m)}}};return await s(""),{rootName:mt.basename(r)||"Project",entries:a,truncated:i}}async function hj(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink()||!r.isDirectory())return null;let n=await Er.realpath(t);if(n!==t||!af(e,n))return null;let o=await Er.readdir(t,{withFileTypes:!0}),a=await Er.lstat(t),i=await Er.realpath(t);return a.isSymbolicLink()||!a.isDirectory()||r.dev!==a.dev||r.ino!==a.ino||n!==i||i!==t||!af(e,i)?null:o}catch{return null}}async function VI(e,t,r={}){let n=await nd(e,t),{handle:o,relativePath:a,stat:i}=n;if(!yE(a))throw await $o(o),new Error("project_file_preview_unsupported");let s=zI,c,d=0;try{s=Math.max(1,Math.min(r.maxBytes??zI,4*1024*1024));let l=Math.min(i.size,s);c=Buffer.alloc(l),l>0&&({bytesRead:d}=await o.read(c,0,l,0))}finally{await $o(o)}let u=mt.basename(a);return{path:a,name:u,extension:qc(u),language:Om(u)??"text",text:c.subarray(0,d).toString("utf8"),size:i.size,truncated:i.size>d}}async function Ej(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink())return null;let n=await Er.realpath(t);if(n===e||!af(e,n)||n!==t)return null;let o=await Er.stat(n);return o.dev!==r.dev||o.ino!==r.ino?null:o.isDirectory()?"directory":o.isFile()?"file":null}catch{return null}}function af(e,t){let r=mt.relative(e,t);return r===""||r!==".."&&!r.startsWith(`..${mt.sep}`)&&!mt.isAbsolute(r)}var sf="/__fps_editor_authoring";function UI(e){let t=Promise.resolve([]);return{name:e.name??"fps-editor-project-authoring-api",enforce:"post",apply:"serve",async configureServer(r){let n=e.createAssetAuthoringHandlers(r);e.getAuthoringWrittenFiles&&(t=e.getAuthoringWrittenFiles(r).then(o=>o.map(a=>Si.resolve(e.projectRoot,a))).then(async o=>(Pj(r,o),Tj(r.watcher,o),await r.watcher?.unwatch?.(o),e.logger?.log?.("[ProjectAuthoring][Vite] watcher and HMR suppressed for authoring-written files",o),o)).catch(o=>(e.logger?.warn?.("[ProjectAuthoring][Vite] failed to resolve authoring files for HMR suppression",o),[])),await t),r.middlewares.use(async(o,a,i)=>{let s=new URL(o.url??"","http://localhost"),c=s.pathname,d=c===sf||c.startsWith(`${sf}/`),u=d&&c.slice(sf.length)||"/";if(d&&u==="/project-media"){if(fi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}if(o.method!=="GET"){Ur(a,{statusCode:405,body:{ok:!1,error:"method_not_allowed"}});return}let m=s.searchParams.get("path")?.trim()??"";if(!m){Ur(a,{statusCode:400,body:{ok:!1,error:"missing_file_path"}});return}try{let f=await nd(e.projectRoot,m),S=null,g=null;try{let b=Rm(f.relativePath);if(!b)throw new Error("project_file_media_unsupported");if(f.stat.size>of(e.projectMediaMaxBytes))throw new Error("project_file_media_too_large");let y=Si.basename(f.relativePath);if(a.statusCode=200,a.setHeader("Content-Type",b.mimeType),a.setHeader("Content-Length",String(f.stat.size)),a.setHeader("Content-Disposition",`inline; filename*=UTF-8''${encodeURIComponent(y)}`),a.setHeader("X-Content-Type-Options","nosniff"),f.stat.size>0&&(g=Buffer.allocUnsafe(1),(await f.handle.read(g,0,1,f.stat.size-1)).bytesRead!==1))throw new Error("project_file_changed_during_read");f.stat.size>1&&await Ij(f.handle.createReadStream({autoClose:!1,start:0,end:f.stat.size-2}),a,{end:!1})}catch(b){S=b}try{await $o(f.handle)}catch(b){if(S){let y=new Error("project_file_close_failed");y.errors=[S,b],S=y}else S=b}if(S)throw S;g?a.end(g):a.end()}catch(f){if(a.headersSent)a.destroy(f instanceof Error?f:void 0);else{let S=f instanceof Error?f.message:String(f);Ur(a,{statusCode:S==="project_file_media_too_large"?413:404,body:{ok:!1,error:S}})}}return}if(d&&(u==="/rendering-profile"||u.startsWith("/rendering-profile/"))){if(!e.handleRenderingProfileRoute){i();return}if(fi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}try{let m=await e.handleRenderingProfileRoute({server:r,req:o,readJsonBody:Zm});Ur(a,m)}catch(m){Ur(a,{statusCode:500,body:{ok:!1,error:m instanceof Error?m.message:String(m),details:m?.details}})}return}let l=await PE({url:o.url??"",method:o.method??"GET"},{readBody:(m,f)=>Zm(o,{...f.routeName==="asset-import"?{maxBytes:Xu}:{}}),async loadManifest(m){let f=await n;if(!f.loadManifest)throw new Error("asset_manifest_handler_unavailable");return f.loadManifest(m)},async loadEditorAssetLibrary(m){let f=await n;if(!f.loadEditorAssetLibrary)throw new Error("asset_library_handler_unavailable");return f.loadEditorAssetLibrary(m)},async loadProjectFiles(){return BI(e.projectRoot,e.projectFileScan)},async loadProjectFile({path:m}){return VI(e.projectRoot,m)},async loadEditorScene(){return e.loadEditorScene(r)},async importAsset(m){let f=await n;if(!f.importAsset)throw new Error("asset_import_handler_unavailable");return f.importAsset(m)},async saveEditorScene({mode:m,rawEditorScene:f,body:S}){return e.saveEditorScene({server:r,saveMode:m,rawEditorScene:f,body:S})}});if(!l){if(d){fi(a),Ur(a,{statusCode:404,body:{ok:!1,error:"not_found"}});return}i();return}Ur(a,l)})},async handleHotUpdate(r){if(typeof r.file!="string")return;let n=await t;if(od(r.file,n))return[]}}}function od(e,t){let r=gi(e);return t.some(n=>{let o=gi(n);if(r===o)return!0;let a=Si.relative(o,r);return a.length>0&&a!==".."&&!a.startsWith(`..${Si.sep}`)&&!Si.isAbsolute(a)})}function Pj(e,t){if(!e.watcher?.prependListener||!e.ws?.send)return;let r=null,n=null,o=()=>{r=null,n&&clearTimeout(n),n=null},a=s=>{o(),r=typeof s=="string"&&od(s,t)?gi(s):null,r&&(n=setTimeout(o,1e3))};for(let s of["add","change","unlink"])e.watcher.prependListener(s,a);let i=e.ws.send.bind(e.ws);e.ws.send=(s,...c)=>{let d=typeof s?.triggeredBy=="string"?s.triggeredBy:void 0,u=d?od(d,t):!1;if(!(s?.type==="full-reload"&&(u||r&&!d)))return i(s,...c)}}function Tj(e,t){if(!e?.add)return;let r=e.add.bind(e);e.add=n=>{let a=(typeof n=="string"?[n]:[...n]).filter(i=>!od(i,t));return a.length===0?e:r(typeof n=="string"?a[0]:a)}}import _n,{resolve as Lo}from"node:path";import{pathToFileURL as xj}from"node:url";function KI(e){let t=Promise.resolve();function r(m){let f=t.then(m);return t=f.then(()=>{},()=>{}),f}async function n(m,f="strict"){let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=[S,g].filter(P=>!!P),y=[],E=[],I=0;for(let P of b){let A=await Fo(P),$=typeof A.errorCodes=="object"&&A.errorCodes?A.errorCodes:{},z=f==="report"?await Hm(P,$):await Km(P,$);I+=z.scannedAssetCount,y.push(...z.refreshedAssets);let p="availabilityIssues"in z&&Array.isArray(z.availabilityIssues)?z.availabilityIssues:[];E.push(...p)}return y.length>0&&_o(m,[...b.flatMap(P=>[P.manifestPath,P.registryPath]),...cf(e)]),{scannedAssetCount:I,refreshedAssets:y,availabilityIssues:Aj(E)}}function o(m){return r(async()=>{let f=await n(m,"strict");return{scannedAssetCount:f.scannedAssetCount,refreshedAssets:f.refreshedAssets}})}function a(m){return r(async()=>{let f=await n(m,"report"),S=u(Ma(await c(!1)),f.availabilityIssues??[]);return{scannedAssetCount:f.scannedAssetCount,refreshedAssetIds:f.refreshedAssets.map(g=>g.assetId),availabilityIssues:f.availabilityIssues??[],assets:S}})}function i(m,f){return r(async()=>{let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=f.kind??([".png",".jpg",".jpeg",".env"].includes(_n.extname(f.sourcePath).toLowerCase())?"texture":"model"),y=b==="texture"?g??S:S,E=await Fo(y),I=typeof E.errorCodes=="object"&&E.errorCodes?E.errorCodes:{},P=await Zt(y),A=await No(y,{payloadData:{sourcePath:f.sourcePath,...f.displayName?{displayName:f.displayName}:{},kind:b,...f.category?{category:f.category}:{},...f.placeable===void 0?{}:{placeable:f.placeable}}},I);_o(m,[y.manifestPath,y.registryPath,...cf(e)]);let z=Ma(await c(!1)).find(p=>p.assetId===A.assetId);if(!z)throw new Error("asset_import_catalog_projection_missing");return{asset:z,disposition:P.some(p=>p.assetId===A.assetId)?"deduplicated":"created"}})}async function s(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=xI({assetRegistryConfig:f,textureRegistryConfig:S,loadAssetCatalogEntries:()=>c(!0),additionalInvalidationFiles:cf(e),invalidateFiles(b){_o(m,b)}});return{loadManifest:b=>r(async()=>(await n(m,"report"),g.loadManifest(b))),loadEditorAssetLibrary:b=>r(async()=>{let y=await n(m,"report"),E=await g.loadEditorAssetLibrary(b);return!E||typeof E!="object"||!Array.isArray(E.assets)?E:{...E,assets:u(E.assets,y.availabilityIssues??[])}}),importAsset:b=>r(async()=>g.importAsset(b))}}async function c(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=[f,S].filter(I=>!!I),b=[...new Map(g.map(I=>[I.manifestPath,I])).values()],y=(await Promise.all(b.map(I=>Zt(I)))).flat(),E=new Set;return y.filter(I=>{if(I.kind!=="model"&&I.kind!=="texture"||m&&I.kind==="model"&&I.placeable!==!0)return!1;if(E.has(I.assetId))throw new Error(`asset_catalog_duplicate_asset_id:${I.assetId}`);return E.add(I.assetId),!0})}async function d(m,f="strict"){return r(async()=>{let S=await n(m,f);return u(Ma(await c(!1)),S.availabilityIssues??[])})}function u(m,f){if(f.length===0)return m;let S=new Map;for(let g of f){let b=S.get(g.assetId)??[];b.push(g),S.set(g.assetId,b)}return m.map(g=>{let b=typeof g.assetId=="string"?g.assetId:typeof g.id=="string"?g.id:"",y=b?S.get(b):void 0;return!y||y.length===0?g:{...g,availability:{status:"unavailable",issues:y.map(E=>({code:E.code,reason:E.reason,stage:E.stage,severity:"error",relativePath:E.relativePath,...E.nodeCode?{nodeCode:E.nodeCode}:{},retryable:E.retryable}))}}})}async function l(){if(e.assetRegistryConfig)return{projectAssetRegistryConfig:e.assetRegistryConfig,projectTextureRegistryConfig:e.textureRegistryConfig??e.assetRegistryConfig};if(!e.assetCatalogConfigModulePath)throw new Error("Project asset authoring requires assetRegistryConfig or assetCatalogConfigModulePath.");return import(`${xj(Lo(e.projectRoot,e.assetCatalogConfigModulePath)).href}?project-asset-catalog-config=${Date.now()}`)}return{createProjectAssetAuthoringHandlers:s,listEditorAssetLibrary:d,loadProjectAssetCatalogConfigModule:l,importProjectAsset:i,refreshProjectAssetCatalog:o,refreshAndListProjectAssetCatalog:a}}function Aj(e){let t=new Set;return e.filter(r=>{let n=JSON.stringify([r.assetId,r.guid,r.kind,r.relativePath,r.stage,r.reason,r.code,r.nodeCode??null,r.retryable]);return t.has(n)?!1:(t.add(n),!0)})}function HI(e,t){let r=Lo(e,t.importedDir),n=Lo(e,t.generatedDir),o=_n.dirname(r);return{cwd:e,codeKeyPolicy:"disabled",assetsDir:o,importedDir:r,generatedDir:n,manifestPath:_n.join(n,"asset-catalog.manifest.json"),registryPath:_n.join(n,"asset-catalog.generated.ts"),scenePath:Lo(e,t.runtimeArtifact),...t.editorScene?{editorScenePath:Lo(e,t.editorScene)}:{},supportedExtensions:Ro,commands:{register:"asset:register",unregister:"asset:unregister"},relativeImportedPath(a,i){let s=a==="sound"?"sounds":a==="model"?"":"textures",c=_n.join(r,s,i);return _n.relative(n,c).split(_n.sep).join("/")},resolveAssetMetadata(a){return ci({kind:a.kind,sourcePath:a.sourcePath,existingMetadata:a.existingMetadata,payloadMetadata:a.payloadMetadata,guid:a.guid,assetId:a.assetId,cwd:e,assetsDir:o})}}}function cf(e){return(e.additionalInvalidationFiles??[]).map(t=>Lo(e.projectRoot,t))}import ad from"node:path";function WI(e,t){return{editorScenePath:ad.resolve(t,e.source.editorScene),scenePath:ad.resolve(t,e.source.runtimeScene),...e.source.rendering?{renderingConfigPath:ad.resolve(t,e.source.rendering)}:{},...e.source.shadows?{shadowsConfigPath:ad.resolve(t,e.source.shadows)}:{}}}import{existsSync as Dj,readFileSync as Mj}from"node:fs";import{mkdir as wj,writeFile as kj}from"node:fs/promises";import df from"node:path";function qI(e,t){let r=e.source.rendering,n=r?df.resolve(t.projectRoot,r):null,o=()=>[...n?[n]:[],...(t.additionalInvalidationFiles??[]).map(a=>df.resolve(t.projectRoot,a))];return{createInvalidationFiles:o,summarize:Rj,async handleRoute(a){return n?_E({method:Oj(a.req)},{readBody:()=>a.readJsonBody(a.req),loadConfig(){return{renderingConfig:Dj(n)?JSON.parse(Mj(n,"utf8")||"{}"):{},response:{renderingConfigPath:n}}},async saveConfig({renderingConfig:i}){return td([n],async()=>(await wj(df.dirname(n),{recursive:!0}),await kj(n,`${JSON.stringify(i,null,2)}
19
- `,"utf8"),_o(a.server,o()),{renderingConfigPath:n}))}}):{statusCode:404,body:{error:"rendering_config_not_configured"}}}}}function Oj(e){if(!e||typeof e!="object")return"GET";let t=e.method;return typeof t=="string"?t:"GET"}function Rj(e){return{postProcessEnabled:e?.postProcess?.enabled??e?.globalVolume?.enabled??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??e?.globalVolume?.postProcessing?.bloom?.enabled??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}import{randomUUID as Cj}from"node:crypto";import{realpath as vj}from"node:fs/promises";import{createServer as Gj}from"node:http";async function XI(e){let t=await vj(e.projectRoot),r=Cj(),n=[...e.middlewares??[]],o=Gj((c,d)=>{jj(d);let u=new URL(c.url??"/","http://fps-editor-project-io.local");if(c.method==="GET"&&u.pathname==="/__fps_editor_worker/health"){lf(d,200,{ok:!0,kind:"project-io",serviceInstanceId:r,canonicalProjectRoot:t});return}let l=0,m=()=>{let f=n[l++];if(!f){lf(d,404,{ok:!1,error:"not_found"});return}Promise.resolve(f(c,d,m)).catch(S=>{if(d.headersSent){d.destroy(S instanceof Error?S:void 0);return}lf(d,500,{ok:!1,error:S instanceof Error?S.message:String(S)})})};m()});await new Promise((c,d)=>{o.once("error",d),o.listen(0,"127.0.0.1",()=>{o.off("error",d),c()})});let a=o.address();if(!a||typeof a=="string")throw await JI(o).catch(()=>{}),new Error("Editor Project I/O worker address is unavailable.");let i=`http://127.0.0.1:${a.port}`;e.logger?.info?.(`[fps-editor] Project I/O worker ready at ${i}`);let s=null;return Object.freeze({serviceInstanceId:r,internalUrl:i,dispose(){return s||(s=JI(o).catch(c=>{throw s=null,c}),s)}})}function jj(e){e.setHeader("Cache-Control","no-store"),e.setHeader("Cross-Origin-Resource-Policy","cross-origin"),e.setHeader("X-Content-Type-Options","nosniff")}function lf(e,t,r){Nj(e)||(e.statusCode=t,e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(`${JSON.stringify(r)}
20
- `))}function Nj(e){return e.destroyed||e.writableEnded}async function JI(e){e.listening&&await new Promise((t,r)=>{e.close(n=>n?r(n):t())})}var Rt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),$n={kind:"texture"},YI={kind:"color"},Fj={kind:"enum",values:["lit","unlit"]},_j={kind:"enum",values:["opaque","mask","blend"]},eP={lightingModel:Fj,baseColor:{kind:"object",properties:{color:YI,texture:$n,brightness:Rt(0),saturation:Rt(0),contrast:Rt(0),hue:Rt(-180,180)}},normal:{kind:"object",properties:{texture:$n,strength:Rt(0)}},emission:{kind:"object",properties:{color:YI,intensity:Rt(0),texture:$n,maskTexture:$n}},alpha:{kind:"object",properties:{mode:_j,opacity:Rt(0,1),cutoff:Rt(0,1),texture:$n}}},$j={kind:"object",properties:{...eP,metallic:Rt(0,1),roughness:Rt(0,1),metallicRoughness:{kind:"object",properties:{texture:$n}},occlusion:{kind:"object",properties:{texture:$n,strength:Rt(0)}}}},Lj={kind:"object",properties:eP},zj={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}},Bj={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}},ZI=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],Ln={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},tP=[Bo("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Bo("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),Vo("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),Ct("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[zo("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[zo("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[zo("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[zo("properties.baseColor.texture.textureAssetId","baseTexture")]}),Vo("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[Ln]),Ct("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Ln,zo("properties.normal.texture.textureAssetId","normalTexture")]}),Bo("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),Ct("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),Vo("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Bo("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"}),Ct("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),Ct("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),Vo("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],Vj=[...tP,Ct("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[Ln]}),Ct("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[Ln]}),Vo("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[Ln]),Vo("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[Ln]),Ct("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Ln,zo("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],mf=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:$j,defaultProperties:zj,inspector:{sections:ZI,fields:Vj}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Lj,defaultProperties:Bj,inspector:{sections:ZI,fields:tP}}],mK=ff(mf);function ff(e){let t=new Map;for(let n of e){Uj(n,t);let o=Kj(n);t.set(n.shaderId,aP(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Bo(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function Ct(e,t,r,n,o,a,i={}){return Bo(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function Vo(e,t,r,n,o,a,i,s){return Bo(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",conditions:s})}function zo(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Uj(e,t){if(!Hn(e.shaderId)&&!ta(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(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!Wj(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);rP(e.shaderId,e.propertiesSchema,"properties");let r=[];if(oP(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);Hj(e,a),o.add(a.path)}}function Kj(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=nP(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function Hj(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=nP(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function rP(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))rP(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function Wj(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function qj(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function nP(e,t){let r=qj(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function oP(e,t,r,n){if(e.kind==="object"){if(!uf(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&oP(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];QI(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){QI(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!uf(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function QI(e,t,r,n,o){if(!uf(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function aP(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))aP(t)}return e}function uf(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Jj=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xj=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 id(e){return Yj(new TextEncoder().encode(e))}function iP(e){return`sha256:${id(JSON.stringify(e))}`}function Yj(e){let t=Math.ceil((e.length+9)/64)*64,r=new Uint8Array(t);r.set(e),r[e.length]=128;let n=new DataView(r.buffer);n.setUint32(t-8,Math.floor(e.length/536870912),!1),n.setUint32(t-4,e.length*8>>>0,!1);let o=[...Jj],a=new Uint32Array(64);for(let i=0;i<r.length;i+=64){for(let g=0;g<16;g+=1)a[g]=n.getUint32(i+g*4,!1);for(let g=16;g<64;g+=1){let b=a[g-15],y=a[g-2],E=Qt(b,7)^Qt(b,18)^b>>>3,I=Qt(y,17)^Qt(y,19)^y>>>10;a[g]=a[g-16]+E+a[g-7]+I>>>0}let[s,c,d,u,l,m,f,S]=o;for(let g=0;g<64;g+=1){let b=Qt(l,6)^Qt(l,11)^Qt(l,25),y=l&m^~l&f,E=S+b+y+Xj[g]+a[g]>>>0,I=Qt(s,2)^Qt(s,13)^Qt(s,22),P=s&c^s&d^c&d,A=I+P>>>0;S=f,f=m,m=l,l=u+E>>>0,u=d,d=c,c=s,s=E+A>>>0}o[0]=o[0]+s>>>0,o[1]=o[1]+c>>>0,o[2]=o[2]+d>>>0,o[3]=o[3]+u>>>0,o[4]=o[4]+l>>>0,o[5]=o[5]+m>>>0,o[6]=o[6]+f>>>0,o[7]=o[7]+S>>>0}return o.map(i=>i.toString(16).padStart(8,"0")).join("")}function Qt(e,t){return e>>>t|e<<32-t}var Zj="fps.plugin.materials";function cP(e){let t=e?.[Zj];if(t==null)return null;if(!Uo(t)||t.schemaVersion!==1||typeof t.snapshotId!="string"||!Array.isArray(t.shaders))throw new Error("Materials Plugin snapshot is invalid. Run fps-editor-prepare again.");let r=structuredClone(t);return Qj(r),dP(r)}function pf(e){return ff([...mf,...e?.shaders.map(t=>t.definition)??[]])}function Qj(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(let r of e.shaders)if(!Uo(r)||!Uo(r.definition)||!Uo(r.program))throw new Error("Materials Plugin Shader snapshot is invalid. Run fps-editor-prepare again.");pf(e);for(let r of e.shaders){let{definition:n,program:o}=r;if(o.shaderId!==n.shaderId||o.definitionVersion!==n.version)throw new Error(`Material snapshot Definition identity does not match its program: ${n.shaderId}`);if(o.language!=="glsl"||!sP(o.vertexSourcePath)||!sP(o.fragmentSourcePath)||!/^[a-f0-9]{64}$/.test(o.vertexSourceHash)||!/^[a-f0-9]{64}$/.test(o.fragmentSourceHash)||typeof o.vertexSource!="string"||!o.vertexSource.trim()||typeof o.fragmentSource!="string"||!o.fragmentSource.trim())throw new Error(`Material snapshot program is invalid: ${n.shaderId}`);if(id(o.vertexSource)!==o.vertexSourceHash||id(o.fragmentSource)!==o.fragmentSourceHash)throw new Error(`Material snapshot source hash does not match its GLSL content: ${n.shaderId}`);if(!Array.isArray(o.attributes)||o.attributes.length===0||o.attributes.some(a=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a))||new Set(o.attributes).size!==o.attributes.length)throw new Error(`Material snapshot attributes are invalid: ${n.shaderId}`);if(!["opaque","combine","add"].includes(o.alphaMode)||!Uo(o.enumUniformValues)||!Uo(o.frame)||!["on-demand","continuous"].includes(o.frame.mode))throw new Error(`Material snapshot rendering policy is invalid: ${n.shaderId}`)}let t={schemaVersion:e.schemaVersion,shaders:e.shaders};if(iP(t)!==e.snapshotId)throw new Error("Materials Plugin snapshot payload does not match its identity. Run fps-editor-prepare again.")}function sP(e){return typeof e=="string"&&!!e&&!e.startsWith("/")&&!e.includes("\\")&&!e.includes(":")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function dP(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))dP(t);return Object.freeze(e)}function Uo(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}async function uP(e){let t=EE(e.definition),r=cP(e.pluginSnapshots),n=pf(r),o=t.project,a=eN(e.projectRoot),i=HI(e.projectRoot,{importedDir:o.assets.importedDir,generatedDir:o.assets.generatedDir,runtimeArtifact:o.source.runtimeScene,editorScene:o.source.editorScene}),s=KI({projectRoot:e.projectRoot,assetRegistryConfig:i}),c=qI(o,{projectRoot:e.projectRoot}),d=WI(o,e.projectRoot),u=Qh({materialShaderDefinitions:n,markerTypes:t.metadata.markerTypes??[],relationTypes:t.metadata.relationTypes??[],features:o.features,getRenderingProfile:()=>({shadows:{defaultMode:"none"}}),createPatch:{gameObjectField:(g,b,y)=>({kind:"game-object.field",targetId:g,path:b,value:y}),gameObjectFieldBatch:g=>({kind:"game-object.property-field-batch",fields:g}),materialAssetField:(g,b,y)=>({kind:"scene.material-asset.field",materialAssetId:g,path:b,value:y}),materialAssetReplace:(g,b)=>({kind:"scene.material-asset.replace",materialAssetId:g,materialAsset:b}),prefabAssetReplace:(g,b)=>({kind:"scene.prefab-asset.replace",assetId:g,prefabAsset:b}),markerGraph:g=>({kind:"scene.marker-graph",command:g})}}),l={ensureAuthoringSource:Og,detectRuntimeInputDrift:Cg,enrichEditorSceneDocumentAssets:Yl,ensureEditorSceneEnvironmentDefaults:u.ensureEnvironmentDefaults.bind(u)},m={...l,assertEditorSceneDocument:jI,assertEditorSceneMaterialAssetIntegrity:u.assertMaterialAssetIntegrity.bind(u),bumpEditorSceneAuthoringSourceRevision:Rg,compileEditorSceneDocumentToSceneConfig:(g,b,y)=>xE(g,b,{...y,materialShaderDefinitions:n,readCustomTransformRuntimeData:E=>E?.transformType==="groundDecal"&&rN(E.groundDecal)?{groundDecal:FE(E.groundDecal)}:null})},f=(g,b="report")=>s.listEditorAssetLibrary(a,b),S=UI({projectRoot:e.projectRoot,createAssetAuthoringHandlers:()=>s.createProjectAssetAuthoringHandlers(a),handleRenderingProfileRoute:c.handleRoute,loadEditorScene:()=>vI({projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,loadServices:async()=>l}),saveEditorScene:g=>GI({...g,projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,saveServices:async()=>m,normalizeRenderingProfile:b=>Ne(b),summarizeRenderingProfile:b=>Bn(b),createRenderingInvalidationFiles:c.createInvalidationFiles}),logger:console});return await tN(S.configureServer,a),XI({projectRoot:e.projectRoot,middlewares:a.middlewares.stack,logger:console})}function eN(e){let t={stack:[],use(o){this.stack.push(o)}},r=new lP,n=new lP;return n.unwatch=async()=>{},n.add=()=>n,{middlewares:t,httpServer:r,watcher:n,ws:{send(){}},moduleGraph:{getModulesByFile(){},invalidateModule(){}},config:{root:e,logger:console}}}async function tN(e,t){if(typeof e=="function"){await e(t);return}e&&typeof e=="object"&&"handler"in e&&typeof e.handler=="function"&&await e.handler(t)}function rN(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Kr=await uP({projectRoot:process.cwd(),definition:fP("FPS_EDITOR_WORKER_PROJECT_DEFINITION"),pluginSnapshots:fP("FPS_EDITOR_WORKER_PLUGIN_SNAPSHOTS")});if(!Kr||typeof Kr.serviceInstanceId!="string"||typeof Kr.internalUrl!="string"||typeof Kr.dispose!="function")throw new Error("Static Project I/O worker returned an invalid worker handle.");process.send?.({type:"ready",serviceInstanceId:Kr.serviceInstanceId,internalUrl:Kr.internalUrl});var gf=!0,pP=setInterval(()=>{gf&&process.send?.({type:"heartbeat",serviceInstanceId:Kr.serviceInstanceId})},1e3);pP.unref?.();process.on("message",e=>{e?.type==="test.stop-heartbeat"&&(gf=!1),e?.type==="test.start-heartbeat"&&(gf=!0)});var mP=!1;for(let e of["SIGINT","SIGTERM"])process.once(e,()=>{mP||(mP=!0,clearInterval(pP),Kr.dispose().finally(()=>{process.exitCode=e==="SIGINT"?130:143}))});function nN(e){let t=process.env[e]?.trim();if(!t)throw new Error(`${e} is required.`);return t}function fP(e){let t=JSON.parse(nN(e));if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must contain a JSON object.`);return t}
18
+ `),e.saveMode==="local-commit-save"&&await t.measureAsync("write",()=>rd(e,zn,a.scenePath,tr)),Nn(e),await t.measureAsync("write",async()=>{for(let xe of zn)await cj(xe.temporaryPath,xe.targetPath),xe.committed=!0;c&&!s&&await kI(a.renderingConfigPath,{force:!0})})}finally{await Promise.all(zn.filter(xe=>!xe.committed).map(xe=>kI(xe.temporaryPath,{force:!0}).catch(()=>{})))}let yf=[...c&&a.renderingConfigPath?e.createRenderingInvalidationFiles?.(e.projectRoot,a.renderingConfigPath)??[a.renderingConfigPath]:[],...f&&a.shadowsConfigPath?[a.shadowsConfigPath]:[]];return yf.length>0&&e.invalidateFiles?.(e.server,yf),{ok:!0,mode:e.saveMode,editorScenePath:a.editorScenePath,scenePath:a.scenePath,expectedVersion:K,...e.saveMode==="local-commit-save"?{version:Hr,updatedAt:F,sceneUrl:Si}:{},editorScene:p,...g?{shadowMapExperimentConfig:g}:{},...c||d?{companionConfigs:{...c?{rendering:s}:{},...d?{staticShadows:z}:{}},...s?{renderingSummary:e.summarizeRenderingProfile?.(I??null)??null}:{}}:{},sceneJsonText:tr,performanceProfile:t.snapshot(),summary:{editorScene:_I($),compiled:h.summary}}}async function rd(e,t,r,n){Nn(e);let o=jn.join(jn.dirname(r),`.${jn.basename(r)}.${process.pid}.${lj()}.tmp`),a={targetPath:r,temporaryPath:o,committed:!1};t.push(a),await dj(o,n,{encoding:"utf8",signal:e.signal})}function Nn(e){if(!e.signal?.aborted&&(e.deadlineAt===void 0||Date.now()<e.deadlineAt))return;let t=new Error("Document export lifecycle deadline elapsed before filesystem persistence completed.");throw Object.assign(t,{code:"document_export_timeout"}),t}function mj(e){let t=fi(e.paths.editorScenePath);if(!t)return e.rawEditorScene;let r=OI(t);if(!r)return e.rawEditorScene;let n=OI(e.rawEditorScene),o=typeof e.body.expectedAuthoringSourceRevision=="number"&&Number.isFinite(e.body.expectedAuthoringSourceRevision)?e.body.expectedAuthoringSourceRevision:n?.revision??null;if(!(n?.sourceId===r.sourceId&&n.sourceType===r.sourceType)){let m={stage:e.saveMode==="prepare-platform-save"?"document.export":"document.save",expectedSourceId:r.sourceId,expectedSourceType:r.sourceType,actualSourceId:n?.sourceId??null,actualSourceType:n?.sourceType??null},f=new Error("authoring_source_identity_mismatch");throw Object.assign(f,{code:"authoring_source_identity_mismatch",details:m,...m}),f}if(n.revision===r.revision&&o===r.revision)return e.rawEditorScene;let i=se(e.body.authoringSourceConflictResolution);if(i?.strategy==="overwrite"&&typeof i.expectedPersistedRevision=="number"&&Number.isFinite(i.expectedPersistedRevision)&&i.expectedPersistedRevision===r.revision){let l=structuredClone(e.rawEditorScene),m=se(se(l.meta)?.authoringSource);return m&&(m.revision=r.revision),l}let c=e.saveMode==="prepare-platform-save"?"document.export":"document.save",d={stage:c,sourceId:r.sourceId,sourceType:r.sourceType,expectedRevision:o,submittedRevision:n.revision,persistedRevision:r.revision},u=new Error("authoring_source_revision_mismatch");throw Object.assign(u,{code:"authoring_source_revision_mismatch",stage:c,sourceId:r.sourceId,expectedRevision:o,actualRevision:r.revision,details:d}),u}function OI(e){let t=se(se(e.meta)?.authoringSource);return typeof t?.sourceId!="string"||!t.sourceId.trim()||typeof t.sourceType!="string"||!t.sourceType.trim()||typeof t.revision!="number"||!Number.isFinite(t.revision)?null:{sourceId:t.sourceId,sourceType:t.sourceType,revision:t.revision}}function nf(e,t,r){if(!r.present||e==null||t)return;let n=new Error(`schema.unsupportedVersion: ${r.path}`);throw Object.assign(n,{code:"schema.unsupportedVersion",path:r.path}),n}function FI(e){Wc(e)}function _I(e){let t=se(e),r=se(t?.meta),n=se(r?.authoringSource),o=se(t?.scene);return{schemaVersion:t?.schemaVersion??null,sourceId:n?.sourceId??null,sourceType:n?.sourceType??null,revision:n?.revision??null,assets:Array.isArray(t?.assets)?t.assets.length:0,gameObjects:Array.isArray(o?.gameObjects)?o.gameObjects.length:0,materialAssets:Array.isArray(o?.materialAssets)?o.materialAssets.length:0}}function fj(e,t){let r={...Br(e)};delete r.rendering;for(let[o,a]of Object.entries(t))a==null?delete r[o]:r[o]=a;let n={...e};return Object.keys(r).length>0?n.companionConfigs=r:delete n.companionConfigs,n}function fi(e){return vI(e)?JSON.parse(GI(e,"utf8")||"{}"):null}function $I(e){if(!e)return null;if(!vI(e))throw new Error(`shadows_config_missing:${e}`);let t=JSON.parse(GI(e,"utf8")||"{}");return Di(t,"$"),structuredClone(t)}function LI(e){return Object.prototype.hasOwnProperty.call(e,"shadowMapExperimentConfig")?(Di(e.shadowMapExperimentConfig,"$.shadowMapExperimentConfig"),structuredClone(e.shadowMapExperimentConfig)):null}function RI(e,t,r=!1){let n=se(e);if(!n)return;for(let a of["shadowMapExperimentConfig","shadowsConfig"])if(!(r&&a==="shadowMapExperimentConfig")&&Object.prototype.hasOwnProperty.call(n,a))throw CI(`${t}.${a}`);let o=se(n.companionConfigs);if(o&&Object.prototype.hasOwnProperty.call(o,"shadows"))throw CI(`${t}.companionConfigs.shadows`)}function CI(e){let t=new Error(`shadow_map_experiment_config_readonly:${e}`);return Object.assign(t,{code:"shadowMapExperiment.configReadonly",path:e}),t}import bi from"node:path";import{pipeline as Tj}from"node:stream/promises";import{realpathSync as pj}from"node:fs";import af from"node:path";function No(e,t){let r=e.moduleGraph,n=new Set;for(let o of t)for(let a of gj(o)){let i=r.getModulesByFile(a);if(i)for(let s of i)r.invalidateModule(s,n)}}function gj(e){let t=af.resolve(e),r=pi(t);return[...new Set([e,t,r,of(e),of(t),of(r)])]}function pi(e){let t=af.resolve(e);try{return pj(t)}catch{return t}}function of(e){return e.split(af.sep).join("/")}import{constants as zI}from"node:fs";import gi from"node:fs/promises";import Fn from"node:path";var bj=128*1024*1024,Sj=512*1024*1024;async function Fo(e){let t=[];for(let n=0;n<2;n+=1)try{await e.close();return}catch(o){t.push(o)}let r=new Error("project_file_close_failed");throw r.errors=t,r}function yj(e){let t=e.trim();if(!t||t!==e||t.includes("\0")||t.includes("\\")||Fn.posix.isAbsolute(t)||/^[A-Za-z]:\//.test(t))throw new Error("project_file_path_invalid");let r=t.split("/");if(r.some(n=>!n||n==="."||n===".."))throw new Error("project_file_path_invalid");return r.join("/")}function sf(e){if(e===void 0)return bj;if(!Number.isSafeInteger(e)||e<=0)throw new Error("project_file_media_limit_invalid");return Math.min(e,Sj)}async function nd(e,t){let r=yj(t),n=await gi.realpath(Fn.resolve(e)),o=Fn.resolve(n,...r.split("/"));BI(n,o),await hj(n,r);let a;try{a=await gi.open(o,zI.O_RDONLY|(zI.O_NOFOLLOW??0))}catch(i){throw i?.code==="ELOOP"?new Error("project_file_symlink_unsupported"):i}try{let i=await a.stat();if(!i.isFile())throw new Error("project_file_not_found");let s=await gi.realpath(o);if(BI(n,s),s!==o)throw new Error("project_file_symlink_unsupported");let c=await gi.stat(s);if(c.dev!==i.dev||c.ino!==i.ino)throw new Error("project_file_changed_during_read");return{absolutePath:o,handle:a,relativePath:r,stat:i}}catch(i){try{await Fo(a)}catch(s){let c=new Error("project_file_close_failed");throw c.errors=[i,s],c}throw i}}function BI(e,t){let r=Fn.relative(e,t);if(!r||r===".."||r.startsWith(`..${Fn.sep}`)||Fn.isAbsolute(r))throw new Error("project_file_path_invalid")}async function hj(e,t){let r=e;for(let n of t.split("/"))if(r=Fn.join(r,n),(await gi.lstat(r)).isSymbolicLink())throw new Error("project_file_symlink_unsupported")}import Er from"node:fs/promises";import mt from"node:path";var VI=512*1024,Ej=new Set([".DS_Store",".cache",".git",".next",".nuxt",".parcel-cache",".turbo",".vite","build","coverage","dist","dist-tests","node_modules","output","playwright-report","test-results"]);async function UI(e,t={}){let r=await Er.realpath(mt.resolve(e)),n=Math.max(1,t.maxEntries??2e4),o=new Set([...Ej,...t.ignoredNames??[]]),a=[],i=!1,s=async c=>{if(i)return;let d=mt.resolve(r,c),u=await Ij(r,d);if(u){u.sort((l,m)=>Number(m.isDirectory())-Number(l.isDirectory())||l.name.localeCompare(m.name,void 0,{numeric:!0,sensitivity:"base"}));for(let l of u){if(l.name.startsWith(".")||o.has(l.name)||l.isSymbolicLink())continue;if(a.length>=n){i=!0;return}let m=mt.posix.join(c.split(mt.sep).join("/"),l.name),f=mt.resolve(r,...m.split("/")),S=await Pj(r,f);if(!S)continue;let g=S==="file"?mt.extname(l.name).slice(1).toLowerCase():"";a.push({path:m,name:l.name,parentPath:c?c.split(mt.sep).join("/"):null,kind:S,...g?{extension:g}:{}}),S==="directory"&&await s(m)}}};return await s(""),{rootName:mt.basename(r)||"Project",entries:a,truncated:i}}async function Ij(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink()||!r.isDirectory())return null;let n=await Er.realpath(t);if(n!==t||!cf(e,n))return null;let o=await Er.readdir(t,{withFileTypes:!0}),a=await Er.lstat(t),i=await Er.realpath(t);return a.isSymbolicLink()||!a.isDirectory()||r.dev!==a.dev||r.ino!==a.ino||n!==i||i!==t||!cf(e,i)?null:o}catch{return null}}async function KI(e,t,r={}){let n=await nd(e,t),{handle:o,relativePath:a,stat:i}=n;if(!EE(a))throw await Fo(o),new Error("project_file_preview_unsupported");let s=VI,c,d=0;try{s=Math.max(1,Math.min(r.maxBytes??VI,4*1024*1024));let l=Math.min(i.size,s);c=Buffer.alloc(l),l>0&&({bytesRead:d}=await o.read(c,0,l,0))}finally{await Fo(o)}let u=mt.basename(a);return{path:a,name:u,extension:qc(u),language:Cm(u)??"text",text:c.subarray(0,d).toString("utf8"),size:i.size,truncated:i.size>d}}async function Pj(e,t){try{let r=await Er.lstat(t);if(r.isSymbolicLink())return null;let n=await Er.realpath(t);if(n===e||!cf(e,n)||n!==t)return null;let o=await Er.stat(n);return o.dev!==r.dev||o.ino!==r.ino?null:o.isDirectory()?"directory":o.isFile()?"file":null}catch{return null}}function cf(e,t){let r=mt.relative(e,t);return r===""||r!==".."&&!r.startsWith(`..${mt.sep}`)&&!mt.isAbsolute(r)}var df="/__fps_editor_authoring";function HI(e){let t=Promise.resolve([]);return{name:e.name??"fps-editor-project-authoring-api",enforce:"post",apply:"serve",async configureServer(r){let n=e.createAssetAuthoringHandlers(r);e.getAuthoringWrittenFiles&&(t=e.getAuthoringWrittenFiles(r).then(o=>o.map(a=>bi.resolve(e.projectRoot,a))).then(async o=>(xj(r,o),Aj(r.watcher,o),await r.watcher?.unwatch?.(o),e.logger?.log?.("[ProjectAuthoring][Vite] watcher and HMR suppressed for authoring-written files",o),o)).catch(o=>(e.logger?.warn?.("[ProjectAuthoring][Vite] failed to resolve authoring files for HMR suppression",o),[])),await t),r.middlewares.use(async(o,a,i)=>{let s=new URL(o.url??"","http://localhost"),c=s.pathname,d=c===df||c.startsWith(`${df}/`),u=d&&c.slice(df.length)||"/";if(d&&u==="/project-media"){if(mi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}if(o.method!=="GET"){Ur(a,{statusCode:405,body:{ok:!1,error:"method_not_allowed"}});return}let m=s.searchParams.get("path")?.trim()??"";if(!m){Ur(a,{statusCode:400,body:{ok:!1,error:"missing_file_path"}});return}try{let f=await nd(e.projectRoot,m),S=null,g=null;try{let b=vm(f.relativePath);if(!b)throw new Error("project_file_media_unsupported");if(f.stat.size>sf(e.projectMediaMaxBytes))throw new Error("project_file_media_too_large");let y=bi.basename(f.relativePath);if(a.statusCode=200,a.setHeader("Content-Type",b.mimeType),a.setHeader("Content-Length",String(f.stat.size)),a.setHeader("Content-Disposition",`inline; filename*=UTF-8''${encodeURIComponent(y)}`),a.setHeader("X-Content-Type-Options","nosniff"),f.stat.size>0&&(g=Buffer.allocUnsafe(1),(await f.handle.read(g,0,1,f.stat.size-1)).bytesRead!==1))throw new Error("project_file_changed_during_read");f.stat.size>1&&await Tj(f.handle.createReadStream({autoClose:!1,start:0,end:f.stat.size-2}),a,{end:!1})}catch(b){S=b}try{await Fo(f.handle)}catch(b){if(S){let y=new Error("project_file_close_failed");y.errors=[S,b],S=y}else S=b}if(S)throw S;g?a.end(g):a.end()}catch(f){if(a.headersSent)a.destroy(f instanceof Error?f:void 0);else{let S=f instanceof Error?f.message:String(f);Ur(a,{statusCode:S==="project_file_media_too_large"?413:404,body:{ok:!1,error:S}})}}return}if(d&&(u==="/rendering-profile"||u.startsWith("/rendering-profile/"))){if(!e.handleRenderingProfileRoute){i();return}if(mi(a),o.method==="OPTIONS"){a.statusCode=204,a.end();return}try{let m=await e.handleRenderingProfileRoute({server:r,req:o,readJsonBody:ef});Ur(a,m)}catch(m){Ur(a,{statusCode:500,body:{ok:!1,error:m instanceof Error?m.message:String(m),details:m?.details}})}return}let l=await xE({url:o.url??"",method:o.method??"GET"},{readBody:(m,f)=>ef(o,{...f.routeName==="asset-import"?{maxBytes:Zu}:{}}),async loadManifest(m){let f=await n;if(!f.loadManifest)throw new Error("asset_manifest_handler_unavailable");return f.loadManifest(m)},async loadEditorAssetLibrary(m){let f=await n;if(!f.loadEditorAssetLibrary)throw new Error("asset_library_handler_unavailable");return f.loadEditorAssetLibrary(m)},async loadProjectFiles(){return UI(e.projectRoot,e.projectFileScan)},async loadProjectFile({path:m}){return KI(e.projectRoot,m)},async loadEditorScene(){return e.loadEditorScene(r)},async importAsset(m){let f=await n;if(!f.importAsset)throw new Error("asset_import_handler_unavailable");return f.importAsset(m)},async saveEditorScene({mode:m,rawEditorScene:f,body:S}){return e.saveEditorScene({server:r,saveMode:m,rawEditorScene:f,body:S})}});if(!l){if(d){mi(a),Ur(a,{statusCode:404,body:{ok:!1,error:"not_found"}});return}i();return}Ur(a,l)})},async handleHotUpdate(r){if(typeof r.file!="string")return;let n=await t;if(od(r.file,n))return[]}}}function od(e,t){let r=pi(e);return t.some(n=>{let o=pi(n);if(r===o)return!0;let a=bi.relative(o,r);return a.length>0&&a!==".."&&!a.startsWith(`..${bi.sep}`)&&!bi.isAbsolute(a)})}function xj(e,t){if(!e.watcher?.prependListener||!e.ws?.send)return;let r=null,n=null,o=()=>{r=null,n&&clearTimeout(n),n=null},a=s=>{o(),r=typeof s=="string"&&od(s,t)?pi(s):null,r&&(n=setTimeout(o,1e3))};for(let s of["add","change","unlink"])e.watcher.prependListener(s,a);let i=e.ws.send.bind(e.ws);e.ws.send=(s,...c)=>{let d=typeof s?.triggeredBy=="string"?s.triggeredBy:void 0,u=d?od(d,t):!1;if(!(s?.type==="full-reload"&&(u||r&&!d)))return i(s,...c)}}function Aj(e,t){if(!e?.add)return;let r=e.add.bind(e);e.add=n=>{let a=(typeof n=="string"?[n]:[...n]).filter(i=>!od(i,t));return a.length===0?e:r(typeof n=="string"?a[0]:a)}}import _n,{resolve as _o}from"node:path";import{pathToFileURL as Dj}from"node:url";function WI(e){let t=Promise.resolve();function r(m){let f=t.then(m);return t=f.then(()=>{},()=>{}),f}async function n(m,f="strict"){let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=[S,g].filter(P=>!!P),y=[],E=[],I=0;for(let P of b){let A=await jo(P),$=typeof A.errorCodes=="object"&&A.errorCodes?A.errorCodes:{},z=f==="report"?await qm(P,$):await Wm(P,$);I+=z.scannedAssetCount,y.push(...z.refreshedAssets);let p="availabilityIssues"in z&&Array.isArray(z.availabilityIssues)?z.availabilityIssues:[];E.push(...p)}return y.length>0&&No(m,[...b.flatMap(P=>[P.manifestPath,P.registryPath]),...lf(e)]),{scannedAssetCount:I,refreshedAssets:y,availabilityIssues:Mj(E)}}function o(m){return r(async()=>{let f=await n(m,"strict");return{scannedAssetCount:f.scannedAssetCount,refreshedAssets:f.refreshedAssets}})}function a(m){return r(async()=>{let f=await n(m,"report"),S=u(Da(await c(!1)),f.availabilityIssues??[]);return{scannedAssetCount:f.scannedAssetCount,refreshedAssetIds:f.refreshedAssets.map(g=>g.assetId),availabilityIssues:f.availabilityIssues??[],assets:S}})}function i(m,f){return r(async()=>{let{projectAssetRegistryConfig:S,projectTextureRegistryConfig:g}=await l(),b=f.kind??([".png",".jpg",".jpeg",".env"].includes(_n.extname(f.sourcePath).toLowerCase())?"texture":"model"),y=b==="texture"?g??S:S,E=await jo(y),I=typeof E.errorCodes=="object"&&E.errorCodes?E.errorCodes:{},P=await Zt(y),A=await Go(y,{payloadData:{sourcePath:f.sourcePath,...f.displayName?{displayName:f.displayName}:{},kind:b,...f.category?{category:f.category}:{},...f.placeable===void 0?{}:{placeable:f.placeable}}},I);No(m,[y.manifestPath,y.registryPath,...lf(e)]);let z=Da(await c(!1)).find(p=>p.assetId===A.assetId);if(!z)throw new Error("asset_import_catalog_projection_missing");return{asset:z,disposition:P.some(p=>p.assetId===A.assetId)?"deduplicated":"created"}})}async function s(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=DI({assetRegistryConfig:f,textureRegistryConfig:S,loadAssetCatalogEntries:()=>c(!0),additionalInvalidationFiles:lf(e),invalidateFiles(b){No(m,b)}});return{loadManifest:b=>r(async()=>(await n(m,"report"),g.loadManifest(b))),loadEditorAssetLibrary:b=>r(async()=>{let y=await n(m,"report"),E=await g.loadEditorAssetLibrary(b);return!E||typeof E!="object"||!Array.isArray(E.assets)?E:{...E,assets:u(E.assets,y.availabilityIssues??[])}}),importAsset:b=>r(async()=>g.importAsset(b))}}async function c(m){let{projectAssetRegistryConfig:f,projectTextureRegistryConfig:S}=await l(),g=[f,S].filter(I=>!!I),b=[...new Map(g.map(I=>[I.manifestPath,I])).values()],y=(await Promise.all(b.map(I=>Zt(I)))).flat(),E=new Set;return y.filter(I=>{if(I.kind!=="model"&&I.kind!=="texture"||m&&I.kind==="model"&&I.placeable!==!0)return!1;if(E.has(I.assetId))throw new Error(`asset_catalog_duplicate_asset_id:${I.assetId}`);return E.add(I.assetId),!0})}async function d(m,f="strict"){return r(async()=>{let S=await n(m,f);return u(Da(await c(!1)),S.availabilityIssues??[])})}function u(m,f){if(f.length===0)return m;let S=new Map;for(let g of f){let b=S.get(g.assetId)??[];b.push(g),S.set(g.assetId,b)}return m.map(g=>{let b=typeof g.assetId=="string"?g.assetId:typeof g.id=="string"?g.id:"",y=b?S.get(b):void 0;return!y||y.length===0?g:{...g,availability:{status:"unavailable",issues:y.map(E=>({code:E.code,reason:E.reason,stage:E.stage,severity:"error",relativePath:E.relativePath,...E.nodeCode?{nodeCode:E.nodeCode}:{},retryable:E.retryable}))}}})}async function l(){if(e.assetRegistryConfig)return{projectAssetRegistryConfig:e.assetRegistryConfig,projectTextureRegistryConfig:e.textureRegistryConfig??e.assetRegistryConfig};if(!e.assetCatalogConfigModulePath)throw new Error("Project asset authoring requires assetRegistryConfig or assetCatalogConfigModulePath.");return import(`${Dj(_o(e.projectRoot,e.assetCatalogConfigModulePath)).href}?project-asset-catalog-config=${Date.now()}`)}return{createProjectAssetAuthoringHandlers:s,listEditorAssetLibrary:d,loadProjectAssetCatalogConfigModule:l,importProjectAsset:i,refreshProjectAssetCatalog:o,refreshAndListProjectAssetCatalog:a}}function Mj(e){let t=new Set;return e.filter(r=>{let n=JSON.stringify([r.assetId,r.guid,r.kind,r.relativePath,r.stage,r.reason,r.code,r.nodeCode??null,r.retryable]);return t.has(n)?!1:(t.add(n),!0)})}function qI(e,t){let r=_o(e,t.importedDir),n=_o(e,t.generatedDir),o=_n.dirname(r);return{cwd:e,codeKeyPolicy:"disabled",assetsDir:o,importedDir:r,generatedDir:n,manifestPath:_n.join(n,"asset-catalog.manifest.json"),registryPath:_n.join(n,"asset-catalog.generated.ts"),scenePath:_o(e,t.runtimeArtifact),...t.editorScene?{editorScenePath:_o(e,t.editorScene)}:{},supportedExtensions:ko,commands:{register:"asset:register",unregister:"asset:unregister"},relativeImportedPath(a,i){let s=a==="sound"?"sounds":a==="model"?"":"textures",c=_n.join(r,s,i);return _n.relative(n,c).split(_n.sep).join("/")},resolveAssetMetadata(a){return si({kind:a.kind,sourcePath:a.sourcePath,existingMetadata:a.existingMetadata,payloadMetadata:a.payloadMetadata,guid:a.guid,assetId:a.assetId,cwd:e,assetsDir:o})}}}function lf(e){return(e.additionalInvalidationFiles??[]).map(t=>_o(e.projectRoot,t))}import ad from"node:path";function JI(e,t){return{editorScenePath:ad.resolve(t,e.source.editorScene),scenePath:ad.resolve(t,e.source.runtimeScene),...e.source.rendering?{renderingConfigPath:ad.resolve(t,e.source.rendering)}:{},...e.source.shadows?{shadowsConfigPath:ad.resolve(t,e.source.shadows)}:{}}}import{existsSync as wj,readFileSync as kj}from"node:fs";import{mkdir as Oj,writeFile as Rj}from"node:fs/promises";import uf from"node:path";function XI(e,t){let r=e.source.rendering,n=r?uf.resolve(t.projectRoot,r):null,o=()=>[...n?[n]:[],...(t.additionalInvalidationFiles??[]).map(a=>uf.resolve(t.projectRoot,a))];return{createInvalidationFiles:o,summarize:vj,async handleRoute(a){return n?LE({method:Cj(a.req)},{readBody:()=>a.readJsonBody(a.req),loadConfig(){return{renderingConfig:wj(n)?JSON.parse(kj(n,"utf8")||"{}"):{},response:{renderingConfigPath:n}}},async saveConfig({renderingConfig:i}){return td([n],async()=>(await Oj(uf.dirname(n),{recursive:!0}),await Rj(n,`${JSON.stringify(i,null,2)}
19
+ `,"utf8"),No(a.server,o()),{renderingConfigPath:n}))}}):{statusCode:404,body:{error:"rendering_config_not_configured"}}}}}function Cj(e){if(!e||typeof e!="object")return"GET";let t=e.method;return typeof t=="string"?t:"GET"}function vj(e){return{postProcessEnabled:e?.postProcess?.enabled??e?.globalVolume?.enabled??null,postProcessBloomEnabled:e?.postProcess?.bloom?.enabled??e?.globalVolume?.postProcessing?.bloom?.enabled??null,planarEnabled:e?.shadows?.planar?.enabled??null,planarOpacity:e?.shadows?.planar?.appearance?.color?.a??null,planeHeight:e?.shadows?.planar?.plane?.height??null,planeBias:e?.shadows?.planar?.plane?.bias??null,stencilEnabled:e?.shadows?.planar?.stencil?.enabled??null}}import{randomUUID as Gj}from"node:crypto";import{realpath as jj}from"node:fs/promises";import{createServer as Nj}from"node:http";async function ZI(e){let t=await jj(e.projectRoot),r=Gj(),n=[...e.middlewares??[]],o=Nj((c,d)=>{Fj(d);let u=new URL(c.url??"/","http://fps-editor-project-io.local");if(c.method==="GET"&&u.pathname==="/__fps_editor_worker/health"){mf(d,200,{ok:!0,kind:"project-io",serviceInstanceId:r,canonicalProjectRoot:t});return}let l=0,m=()=>{let f=n[l++];if(!f){mf(d,404,{ok:!1,error:"not_found"});return}Promise.resolve(f(c,d,m)).catch(S=>{if(d.headersSent){d.destroy(S instanceof Error?S:void 0);return}mf(d,500,{ok:!1,error:S instanceof Error?S.message:String(S)})})};m()});await new Promise((c,d)=>{o.once("error",d),o.listen(0,"127.0.0.1",()=>{o.off("error",d),c()})});let a=o.address();if(!a||typeof a=="string")throw await YI(o).catch(()=>{}),new Error("Editor Project I/O worker address is unavailable.");let i=`http://127.0.0.1:${a.port}`;e.logger?.info?.(`[fps-editor] Project I/O worker ready at ${i}`);let s=null;return Object.freeze({serviceInstanceId:r,internalUrl:i,dispose(){return s||(s=YI(o).catch(c=>{throw s=null,c}),s)}})}function Fj(e){e.setHeader("Cache-Control","no-store"),e.setHeader("Cross-Origin-Resource-Policy","cross-origin"),e.setHeader("X-Content-Type-Options","nosniff")}function mf(e,t,r){_j(e)||(e.statusCode=t,e.setHeader("Content-Type","application/json; charset=utf-8"),e.end(`${JSON.stringify(r)}
20
+ `))}function _j(e){return e.destroyed||e.writableEnded}async function YI(e){e.listening&&await new Promise((t,r)=>{e.close(n=>n?r(n):t())})}var Rt=(e,t)=>({kind:"number",...e!=null?{min:e}:{},...t!=null?{max:t}:{}}),$n={kind:"texture"},QI={kind:"color"},$j={kind:"enum",values:["lit","unlit"]},Lj={kind:"enum",values:["opaque","mask","blend"]},rP={lightingModel:$j,baseColor:{kind:"object",properties:{color:QI,texture:$n,brightness:Rt(0),saturation:Rt(0),contrast:Rt(0),hue:Rt(-180,180)}},normal:{kind:"object",properties:{texture:$n,strength:Rt(0)}},emission:{kind:"object",properties:{color:QI,intensity:Rt(0),texture:$n,maskTexture:$n}},alpha:{kind:"object",properties:{mode:Lj,opacity:Rt(0,1),cutoff:Rt(0,1),texture:$n}}},zj={kind:"object",properties:{...rP,metallic:Rt(0,1),roughness:Rt(0,1),metallicRoughness:{kind:"object",properties:{texture:$n}},occlusion:{kind:"object",properties:{texture:$n,strength:Rt(0)}}}},Bj={kind:"object",properties:rP},Vj={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}},Uj={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}},eP=[{id:"surface",title:"Surface",order:40},{id:"geometry",title:"Geometry",order:50},{id:"emission",title:"Emission",order:60},{id:"alpha",title:"Alpha",order:70}],Ln={path:"properties.lightingModel",operator:"equals",value:"lit",inactiveReasonKey:"litMaterial"},nP=[Lo("properties.lightingModel","surface",1,"enum","assetLightingModel","lightingModel","lit",{options:[{value:"lit",labelKey:"assetLightingModelLit"},{value:"unlit",labelKey:"assetLightingModelUnlit"}],binding:"lightingModel",updateClass:"define"}),Lo("properties.baseColor.color","surface",2,"color","assetBaseColor","baseColor",{r:1,g:1,b:1},{binding:"baseColor.color"}),zo("properties.baseColor.texture.textureAssetId","properties.baseColor.texture","surface",3,"assetBaseTexture","baseTexture","baseColor.texture"),Ct("properties.baseColor.brightness","surface",4,"assetBrightness","brightness",1,{softMin:0,softMax:4,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.saturation","surface",5,"assetSaturation","saturation",1,{softMin:0,softMax:2,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.contrast","surface",6,"assetContrast","contrast",1,{softMin:0,softMax:2,step:.05,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),Ct("properties.baseColor.hue","surface",7,"assetHue","hue",0,{step:1,conditions:[$o("properties.baseColor.texture.textureAssetId","baseTexture")]}),zo("properties.normal.texture.textureAssetId","properties.normal.texture","geometry",10,"assetNormalTexture","normalTexture","normal.texture",[Ln]),Ct("properties.normal.strength","geometry",11,"assetNormalStrength","normalStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Ln,$o("properties.normal.texture.textureAssetId","normalTexture")]}),Lo("properties.emission.color","emission",50,"color","assetEmissionColor","emissionColor",{r:0,g:0,b:0},{binding:"emission.color"}),Ct("properties.emission.intensity","emission",51,"assetEmissionIntensity","emissionIntensity",0,{softMin:0,softMax:8,step:.05}),zo("properties.emission.texture.textureAssetId","properties.emission.texture","emission",52,"assetEmissionTexture","emissionTexture","emission.texture"),Lo("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"}),Ct("properties.alpha.opacity","alpha",61,"assetAlphaOpacity","alphaOpacity",1,{step:.05,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"blend",inactiveReasonKey:"alphaBlend"}]}),Ct("properties.alpha.cutoff","alpha",62,"assetAlphaCutoff","alphaCutoff",.5,{step:.01,conditions:[{path:"properties.alpha.mode",operator:"equals",value:"mask",inactiveReasonKey:"alphaMask"}]}),zo("properties.alpha.texture.textureAssetId","properties.alpha.texture","alpha",63,"assetAlphaTexture","alphaTexture","alpha.texture",[{path:"properties.alpha.mode",operator:"not-equals",value:"opaque",inactiveReasonKey:"alphaTransparency"}])],Kj=[...nP,Ct("properties.metallic","geometry",20,"assetMetallic","metallic",0,{step:.05,conditions:[Ln]}),Ct("properties.roughness","geometry",21,"assetRoughness","roughness",1,{step:.05,conditions:[Ln]}),zo("properties.metallicRoughness.texture.textureAssetId","properties.metallicRoughness.texture","geometry",22,"assetMetallicRoughnessTexture","metallicRoughnessTexture","metallicRoughness.texture",[Ln]),zo("properties.occlusion.texture.textureAssetId","properties.occlusion.texture","geometry",23,"assetOcclusionTexture","occlusionTexture","occlusion.texture",[Ln]),Ct("properties.occlusion.strength","geometry",24,"assetOcclusionStrength","occlusionStrength",1,{softMin:0,softMax:4,step:.05,conditions:[Ln,$o("properties.occlusion.texture.textureAssetId","occlusionTexture")]})],pf=[{shaderId:"fps.builtin.pbr",version:1,runtimeKind:"pbr",displayName:"PBR",propertiesSchema:zj,defaultProperties:Vj,inspector:{sections:eP,fields:Kj}},{shaderId:"fps.builtin.standard",version:1,runtimeKind:"standard",displayName:"Standard",propertiesSchema:Bj,defaultProperties:Uj,inspector:{sections:eP,fields:nP}}],pK=gf(pf);function gf(e){let t=new Map;for(let n of e){Hj(n,t);let o=Wj(n);t.set(n.shaderId,sP(o))}let r=Object.freeze([...t.values()]);return Object.freeze({get(n){return typeof n=="string"?t.get(n)??null:null},list(){return r}})}function Lo(e,t,r,n,o,a,i,s){return{path:e,sectionId:t,order:r,control:n,labelKey:o,tooltipKey:a,defaultValue:i,updateClass:"uniform",...s}}function Ct(e,t,r,n,o,a,i={}){return Lo(e,t,r,"number",n,o,a,{binding:e.replace(/^properties\./,""),step:i.step??.05,displayPrecision:2,precision:2,...i})}function zo(e,t,r,n,o,a,i,s){return Lo(e,r,n,"texture",o,a,"",{schemaPath:t,binding:i,updateClass:"texture",...s?{conditions:s}:{}})}function $o(e,t){return{path:e,operator:"truthy",inactiveReasonKey:t}}function Hj(e,t){if(!Hn(e.shaderId)&&!Qo(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(t.has(e.shaderId))throw new Error(`Duplicate Material Shader Definition: ${e.shaderId}`);if(e.sourceFile!=null&&!Jj(e.sourceFile))throw new Error(`Material Shader Definition ${e.shaderId} sourceFile must be a safe project-relative path.`);oP(e.shaderId,e.propertiesSchema,"properties");let r=[];if(iP(e.propertiesSchema,e.defaultProperties,"properties",r),r.length>0){let a=r[0];throw new Error(`Material Shader Definition ${e.shaderId} default ${a.path} ${a.message}.`)}let n=new Set;for(let a of e.inspector.sections){if(!a.id.trim()||n.has(a.id))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate section: ${a.id}`);n.add(a.id)}let o=new Set;for(let a of e.inspector.fields){if(!a.path.startsWith("properties.")||o.has(a.path))throw new Error(`Material Shader Definition ${e.shaderId} contains an invalid or duplicate field: ${a.path}`);if(!n.has(a.sectionId))throw new Error(`Material Shader Definition ${e.shaderId} field ${a.path} references an unknown section.`);qj(e,a),o.add(a.path)}}function Wj(e){let t=structuredClone(e);return{...t,inspector:{...t.inspector,fields:t.inspector.fields.map(r=>{if(r.control!=="number")return r;let n=aP(t.propertiesSchema,r.schemaPath??r.path);return n?.kind!=="number"?r:{...r,...n.min!=null?{min:n.min}:{},...n.max!=null?{max:n.max}:{}}})}}}function qj(e,t){let r=[["min",t.min],["max",t.max],["softMin",t.softMin],["softMax",t.softMax]];for(let[o,a]of r)if(a!=null&&!Number.isFinite(a))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must be finite.`);if(t.control!=="number"){if(r.some(([,o])=>o!=null))throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} uses numeric ranges with a non-number control.`);return}let n=aP(e.propertiesSchema,t.schemaPath??t.path);if(n?.kind!=="number")throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} must reference a number schema.`);for(let[o,a,i]of[["min",t.min,n.min],["max",t.max,n.max]])if(a!=null&&a!==i)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} ${o} must match propertiesSchema.`);if(t.softMin!=null&&t.softMax!=null&&t.softMin>t.softMax)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not exceed softMax.`);if(n.min!=null&&t.softMin!=null&&t.softMin<n.min)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMin must not be below the schema minimum.`);if(n.max!=null&&t.softMax!=null&&t.softMax>n.max)throw new Error(`Material Shader Definition ${e.shaderId} field ${t.path} softMax must not exceed the schema maximum.`)}function oP(e,t,r){if(t.kind==="object"){for(let[n,o]of Object.entries(t.properties))oP(e,o,`${r}.${n}`);return}if(t.kind==="number"){if(t.min!=null&&!Number.isFinite(t.min))throw new Error(`Material Shader Definition ${e} number field ${r} min must be finite.`);if(t.max!=null&&!Number.isFinite(t.max))throw new Error(`Material Shader Definition ${e} number field ${r} max must be finite.`);if(t.min!=null&&t.max!=null&&t.min>t.max)throw new Error(`Material Shader Definition ${e} number field ${r} min must not exceed max.`);return}if(t.kind==="color"&&t.channels!=null&&t.channels!==3&&t.channels!==4)throw new Error(`Material Shader Definition ${e} color field ${r} channels must be 3 or 4.`)}function Jj(e){let t=e.trim();return!t||t.startsWith("/")||t.includes("\\")||t.includes(":")?!1:!t.split("/").includes("..")}function Xj(e){let t=e.trim();return t.startsWith("properties.")?t:`properties.${t}`}function aP(e,t){let r=Xj(t).replace(/^properties\./,"").split(".").filter(Boolean);if(r.length===0)return null;let n=e;for(let o of r){if(n.kind!=="object")return null;let a=n.properties[o];if(!a)return null;n=a}return n}function iP(e,t,r,n){if(e.kind==="object"){if(!ff(t)){n.push({path:r,message:"must be an object"});return}for(let a of Object.keys(t))Object.prototype.hasOwnProperty.call(e.properties,a)||n.push({path:`${r}.${a}`,message:"is not supported by the selected shader"});for(let[a,i]of Object.entries(e.properties))t[a]!==void 0&&iP(i,t[a],`${r}.${a}`,n);return}if(e.kind==="number"){if(typeof t!="number"||!Number.isFinite(t)){n.push({path:r,message:"must be a finite number"});return}e.min!=null&&t<e.min&&n.push({path:r,message:`must be greater than or equal to ${e.min}`}),e.max!=null&&t>e.max&&n.push({path:r,message:`must be less than or equal to ${e.max}`});return}if(e.kind==="boolean"){typeof t!="boolean"&&n.push({path:r,message:"must be a boolean"});return}if(e.kind==="string"){t!==null&&typeof t!="string"?n.push({path:r,message:"must be a string"}):t===null&&!e.nullable&&n.push({path:r,message:"must not be null"});return}if(e.kind==="enum"){(typeof t!="string"||!e.values.includes(t))&&n.push({path:r,message:`must be one of: ${e.values.join(", ")}`});return}if(e.kind==="color"){let a=e.channels===4?["r","g","b","a"]:["r","g","b"];tP(t,r,a,n,e.channels===4?"an RGBA object":"an RGB object");return}if(e.kind==="vec2"||e.kind==="vec3"){tP(t,r,e.kind==="vec2"?["x","y"]:["x","y","z"],n,`a ${e.kind} object`);return}if(t===null)return;if(!ff(t)){n.push({path:r,message:"must be a texture reference object or null"});return}Object.keys(t).some(a=>a!=="url"&&a!=="textureAssetId")&&n.push({path:r,message:"must contain only url or textureAssetId"});for(let a of["url","textureAssetId"]){let i=t[a];i!==void 0&&(typeof i!="string"||!i.trim())&&n.push({path:`${r}.${a}`,message:"must be a non-empty string"})}}function tP(e,t,r,n,o){if(!ff(e)){n.push({path:t,message:`must be ${o}`});return}Object.keys(e).some(a=>!r.includes(a))&&n.push({path:t,message:`must contain only ${r.join(", ")}`});for(let a of r)(typeof e[a]!="number"||!Number.isFinite(e[a]))&&n.push({path:`${t}.${a}`,message:"must be a finite number"})}function sP(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){Object.freeze(e);for(let t of Object.values(e))sP(t)}return e}function ff(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Yj=Object.freeze([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Zj=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 id(e){return Qj(new TextEncoder().encode(e))}function cP(e){return`sha256:${id(JSON.stringify(e))}`}function Qj(e){let t=Math.ceil((e.length+9)/64)*64,r=new Uint8Array(t);r.set(e),r[e.length]=128;let n=new DataView(r.buffer);n.setUint32(t-8,Math.floor(e.length/536870912),!1),n.setUint32(t-4,e.length*8>>>0,!1);let o=[...Yj],a=new Uint32Array(64);for(let i=0;i<r.length;i+=64){for(let g=0;g<16;g+=1)a[g]=n.getUint32(i+g*4,!1);for(let g=16;g<64;g+=1){let b=a[g-15],y=a[g-2],E=Qt(b,7)^Qt(b,18)^b>>>3,I=Qt(y,17)^Qt(y,19)^y>>>10;a[g]=a[g-16]+E+a[g-7]+I>>>0}let[s,c,d,u,l,m,f,S]=o;for(let g=0;g<64;g+=1){let b=Qt(l,6)^Qt(l,11)^Qt(l,25),y=l&m^~l&f,E=S+b+y+Zj[g]+a[g]>>>0,I=Qt(s,2)^Qt(s,13)^Qt(s,22),P=s&c^s&d^c&d,A=I+P>>>0;S=f,f=m,m=l,l=u+E>>>0,u=d,d=c,c=s,s=E+A>>>0}o[0]=o[0]+s>>>0,o[1]=o[1]+c>>>0,o[2]=o[2]+d>>>0,o[3]=o[3]+u>>>0,o[4]=o[4]+l>>>0,o[5]=o[5]+m>>>0,o[6]=o[6]+f>>>0,o[7]=o[7]+S>>>0}return o.map(i=>i.toString(16).padStart(8,"0")).join("")}function Qt(e,t){return e>>>t|e<<32-t}var eN="fps.plugin.materials";function lP(e){let t=e?.[eN];if(t==null)return null;if(!Bo(t)||t.schemaVersion!==1||typeof t.snapshotId!="string"||!Array.isArray(t.shaders))throw new Error("Materials Plugin snapshot is invalid. Run fps-editor-prepare again.");let r=structuredClone(t);return tN(r),uP(r)}function bf(e){return gf([...pf,...e?.shaders.map(t=>t.definition)??[]])}function tN(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(let r of e.shaders)if(!Bo(r)||!Bo(r.definition)||!Bo(r.program))throw new Error("Materials Plugin Shader snapshot is invalid. Run fps-editor-prepare again.");bf(e);for(let r of e.shaders){let{definition:n,program:o}=r;if(o.shaderId!==n.shaderId||o.definitionVersion!==n.version)throw new Error(`Material snapshot Definition identity does not match its program: ${n.shaderId}`);if(o.language!=="glsl"||!dP(o.vertexSourcePath)||!dP(o.fragmentSourcePath)||!/^[a-f0-9]{64}$/.test(o.vertexSourceHash)||!/^[a-f0-9]{64}$/.test(o.fragmentSourceHash)||typeof o.vertexSource!="string"||!o.vertexSource.trim()||typeof o.fragmentSource!="string"||!o.fragmentSource.trim())throw new Error(`Material snapshot program is invalid: ${n.shaderId}`);if(id(o.vertexSource)!==o.vertexSourceHash||id(o.fragmentSource)!==o.fragmentSourceHash)throw new Error(`Material snapshot source hash does not match its GLSL content: ${n.shaderId}`);if(!Array.isArray(o.attributes)||o.attributes.length===0||o.attributes.some(a=>!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a))||new Set(o.attributes).size!==o.attributes.length)throw new Error(`Material snapshot attributes are invalid: ${n.shaderId}`);if(!["opaque","combine","add"].includes(o.alphaMode)||!Bo(o.enumUniformValues)||!Bo(o.frame)||!["on-demand","continuous"].includes(o.frame.mode))throw new Error(`Material snapshot rendering policy is invalid: ${n.shaderId}`)}let t={schemaVersion:e.schemaVersion,shaders:e.shaders};if(cP(t)!==e.snapshotId)throw new Error("Materials Plugin snapshot payload does not match its identity. Run fps-editor-prepare again.")}function dP(e){return typeof e=="string"&&!!e&&!e.startsWith("/")&&!e.includes("\\")&&!e.includes(":")&&e.split("/").every(t=>!!t&&t!=="."&&t!=="..")}function uP(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))uP(t);return Object.freeze(e)}function Bo(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}async function fP(e){let t=PE(e.definition),r=lP(e.pluginSnapshots),n=bf(r),o=t.project,a=rN(e.projectRoot),i=qI(e.projectRoot,{importedDir:o.assets.importedDir,generatedDir:o.assets.generatedDir,runtimeArtifact:o.source.runtimeScene,editorScene:o.source.editorScene}),s=WI({projectRoot:e.projectRoot,assetRegistryConfig:i}),c=XI(o,{projectRoot:e.projectRoot}),d=JI(o,e.projectRoot),u=tE({materialShaderDefinitions:n,markerTypes:t.metadata.markerTypes??[],relationTypes:t.metadata.relationTypes??[],features:o.features,getRenderingProfile:()=>({shadows:{defaultMode:"none"}}),createPatch:{gameObjectField:(g,b,y)=>({kind:"game-object.field",targetId:g,path:b,value:y}),gameObjectFieldBatch:g=>({kind:"game-object.property-field-batch",fields:g}),materialAssetField:(g,b,y)=>({kind:"scene.material-asset.field",materialAssetId:g,path:b,value:y}),materialAssetReplace:(g,b)=>({kind:"scene.material-asset.replace",materialAssetId:g,materialAsset:b}),prefabAssetReplace:(g,b)=>({kind:"scene.prefab-asset.replace",assetId:g,prefabAsset:b}),markerGraph:g=>({kind:"scene.marker-graph",command:g})}}),l={ensureAuthoringSource:Cg,detectRuntimeInputDrift:Gg,enrichEditorSceneDocumentAssets:Yl,ensureEditorSceneEnvironmentDefaults:u.ensureEnvironmentDefaults.bind(u)},m={...l,assertEditorSceneDocument:FI,assertEditorSceneMaterialAssetIntegrity:u.assertMaterialAssetIntegrity.bind(u),bumpEditorSceneAuthoringSourceRevision:vg,compileEditorSceneDocumentToSceneConfig:(g,b,y)=>DE(g,b,{...y,materialShaderDefinitions:n,readCustomTransformRuntimeData:E=>E?.transformType==="groundDecal"&&oN(E.groundDecal)?{groundDecal:$E(E.groundDecal)}:null})},f=(g,b="report")=>s.listEditorAssetLibrary(a,b),S=HI({projectRoot:e.projectRoot,createAssetAuthoringHandlers:()=>s.createProjectAssetAuthoringHandlers(a),handleRenderingProfileRoute:c.handleRoute,loadEditorScene:()=>jI({projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,loadServices:async()=>l}),saveEditorScene:g=>NI({...g,projectRoot:e.projectRoot,server:a,paths:d,listEditorAssetLibrary:f,saveServices:async()=>m,normalizeRenderingProfile:b=>Ne(b),summarizeRenderingProfile:b=>Bn(b),createRenderingInvalidationFiles:c.createInvalidationFiles}),logger:console});return await nN(S.configureServer,a),ZI({projectRoot:e.projectRoot,middlewares:a.middlewares.stack,logger:console})}function rN(e){let t={stack:[],use(o){this.stack.push(o)}},r=new mP,n=new mP;return n.unwatch=async()=>{},n.add=()=>n,{middlewares:t,httpServer:r,watcher:n,ws:{send(){}},moduleGraph:{getModulesByFile(){},invalidateModule(){}},config:{root:e,logger:console}}}async function nN(e,t){if(typeof e=="function"){await e(t);return}e&&typeof e=="object"&&"handler"in e&&typeof e.handler=="function"&&await e.handler(t)}function oN(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Kr=await fP({projectRoot:process.cwd(),definition:gP("FPS_EDITOR_WORKER_PROJECT_DEFINITION"),pluginSnapshots:gP("FPS_EDITOR_WORKER_PLUGIN_SNAPSHOTS")});if(!Kr||typeof Kr.serviceInstanceId!="string"||typeof Kr.internalUrl!="string"||typeof Kr.dispose!="function")throw new Error("Static Project I/O worker returned an invalid worker handle.");process.send?.({type:"ready",serviceInstanceId:Kr.serviceInstanceId,internalUrl:Kr.internalUrl});var Sf=!0,bP=setInterval(()=>{Sf&&process.send?.({type:"heartbeat",serviceInstanceId:Kr.serviceInstanceId})},1e3);bP.unref?.();process.on("message",e=>{e?.type==="test.stop-heartbeat"&&(Sf=!1),e?.type==="test.start-heartbeat"&&(Sf=!0)});var pP=!1;for(let e of["SIGINT","SIGTERM"])process.once(e,()=>{pP||(pP=!0,clearInterval(bP),Kr.dispose().finally(()=>{process.exitCode=e==="SIGINT"?130:143}))});function aN(e){let t=process.env[e]?.trim();if(!t)throw new Error(`${e} is required.`);return t}function gP(e){let t=JSON.parse(aN(e));if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must contain a JSON object.`);return t}