handler-playable-sdk 1.0.20 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{chunk-5XDKSUEE.js → chunk-KHEZYZMO.js} +3 -3
  2. package/dist/cli/brand-dna.mjs +1 -1
  3. package/dist/cli/canva-import.mjs +1 -1
  4. package/dist/cli/cleanup-assets.mjs +1 -1
  5. package/dist/cli/fix-scales.mjs +1 -1
  6. package/dist/cli/index.js +1 -1
  7. package/dist/cli/screen-helper.mjs +1 -1
  8. package/dist/cli/setup-library.mjs +1 -1
  9. package/dist/cli/student-helper/add-logic.mjs +1 -1
  10. package/dist/cli/student-helper/add-object.mjs +1 -1
  11. package/dist/cli/student-helper/arg-parsing.mjs +1 -1
  12. package/dist/cli/student-helper/asset-registry.mjs +1 -1
  13. package/dist/cli/student-helper/bullet-system.mjs +1 -1
  14. package/dist/cli/student-helper/collectable-system.mjs +1 -1
  15. package/dist/cli/student-helper/constants.mjs +1 -1
  16. package/dist/cli/student-helper/drag-snap-couples.mjs +1 -1
  17. package/dist/cli/student-helper/endgame-screen.mjs +1 -1
  18. package/dist/cli/student-helper/fs-io.mjs +1 -1
  19. package/dist/cli/student-helper/logic-defaults.mjs +1 -1
  20. package/dist/cli/student-helper/print-help.mjs +1 -1
  21. package/dist/cli/student-helper/prompts.mjs +1 -1
  22. package/dist/cli/student-helper/scratch-card.mjs +1 -1
  23. package/dist/cli/student-helper/screen-utils.mjs +1 -1
  24. package/dist/cli/student-helper/snippets.mjs +1 -1
  25. package/dist/cli/student-helper/start-screen.mjs +1 -1
  26. package/dist/cli/student-helper/swerve-collect.mjs +1 -1
  27. package/dist/cli/student-helper/tap-destroy.mjs +1 -1
  28. package/dist/cli/student-helper/template-packs.mjs +1 -1
  29. package/dist/cli/student-helper.mjs +1 -1
  30. package/dist/cli/sync-screens.mjs +1 -1
  31. package/dist/cli/validate-assets.mjs +1 -1
  32. package/dist/cli/validate.mjs +1 -1
  33. package/dist/index.cjs +3 -3
  34. package/dist/index.js +1 -1
  35. package/dist/pixi/index.cjs +1 -1
  36. package/dist/pixi/index.js +1 -1
  37. package/dist/three/index.cjs +13 -13
  38. package/dist/three/index.js +1 -1
  39. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -43,7 +43,7 @@
43
43
  <button class="debug-btn primary" data-modal-apply>Apply</button>
44
44
  </div>
45
45
  </div>
46
- `,this.modal=i}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(r=>{r.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.addEventListener("click",o=>{let c=o.target.dataset.tab;c&&this.switchTab(c)})});let i=this.modal.querySelector("[data-ai-generate]");i==null||i.addEventListener("click",()=>{this.openAiEditor("generate")});let n=this.modal.querySelector("[data-ai-edit]");n==null||n.addEventListener("click",()=>{this.openAiEditor("edit")});let a=this.modal.querySelector("[data-modal-apply]");a==null||a.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",r=>{r.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(n=>{n.classList.toggle("active",n.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(n=>{n.classList.toggle("active",n.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let t=window.__openAiEditor;if(typeof t!="function"){alert("AI Editor not available. Please check your setup.");return}let i="";e==="edit"&&this.currentAsset?i=`Edit this image: ${this.currentObjectId}`:i=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",i,this.currentAsset,{path:this.currentPath,onApply:n=>{this.onApplyCallback&&this.onApplyCallback(n),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var zl={};St(zl,{COLORS:()=>me,ConfigWatcher:()=>Ue,DebugPanel:()=>Ft,DefaultReloadStrategy:()=>Ot,Handler:()=>de,PlayableLoadingScreen:()=>dn,PreviewShell:()=>on,STROKE_WIDTH:()=>Nr,THEME:()=>Hr,applyConfigOverride:()=>ee,applyConfigOverrides:()=>ke,applyConfigsToDisk:()=>fi,applyDefaults:()=>Ge,baseLottie:()=>An,bootstrap:()=>Al,clearConfigOverrides:()=>se,clearConfigOverridesForObject:()=>zs,configOverrideManager:()=>$s,createPreviewShell:()=>Oa,deepClone:()=>Y,default:()=>De,defaultPreset:()=>Si,deviceGroups:()=>ea,devicePresets:()=>Qn,diffConfigs:()=>Wn,exportConfigsAsJSON:()=>Be,getConfigOverrides:()=>Z,getConfigStateSummary:()=>Pe,getOverrideMode:()=>It,getPresetById:()=>qe,getPresetsByCategory:()=>Qo,loadAllObjectConfigs:()=>yi,loadComponentSchemas:()=>bi,loadEngineConfig:()=>vi,loadGamePromptConfig:()=>Un,loadObjectCentricConfig:()=>Se,loadObjectConfig:()=>Me,loadSceneConfig:()=>wi,redoLastConfigChange:()=>hi,rehydrateObject:()=>Yn,removeConfigOverride:()=>Mt,resetToApplied:()=>jt,resetToOriginal:()=>mi,setBootstrapDependencies:()=>El,setOverrideMode:()=>Fn,setupHotReload:()=>Jn,setupLiveEditBridge:()=>ln,toLegacyFormat:()=>qn,trackObjectCreation:()=>Ds,trackObjectDeletion:()=>Ns,undoLastConfigChange:()=>gi,validateObjectConfig:()=>st});module.exports=oo(zl);var Le={};function Qt(s,e,t=!1){Le[s]||(Le[s]=[]),Le[s].push({fn:e,once:t})}function xn(s,e){if(Le[s]){if(!e){delete Le[s];return}Le[s]=Le[s].filter(t=>t.fn!==e)}}function ei(s,...e){let t=Le[s];if(t)for(let i of[...t])i.fn(...e),i.once&&xn(s,i.fn)}function te(s,e){Qt(s,e,!0)}var V=null,oe=[],Qe=null;function Ja(s){V=s,oe=[],Qe!==null&&(clearTimeout(Qe),Qe=null)}function Za(){var s,e,t;return{endpoint:(V==null?void 0:V.endpoint)||"",transport:(V==null?void 0:V.transport)||"beacon",batchSize:(s=V==null?void 0:V.batchSize)!=null?s:10,flushIntervalMs:(e=V==null?void 0:V.flushIntervalMs)!=null?e:300,maxQueue:(t=V==null?void 0:V.maxQueue)!=null?t:200,debug:!!(V!=null&&V.debug)}}async function Ka(s,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(s,new Blob([n],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",a,e);return}catch(a){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(a){i&&console.warn("[handler.telemetry] fetch failed",a)}}function Sn(s,e){let t=Za();if(e&&t.endpoint){if(oe.push(s),oe.length>t.maxQueue&&(oe=oe.slice(oe.length-t.maxQueue)),oe.length>=t.batchSize){Xa();return}Qe===null&&(Qe=window.setTimeout(()=>{Qe=null,Xa()},t.flushIntervalMs))}}async function Xa(){let s=Za();if(!s.endpoint||oe.length===0)return;let e=oe.splice(0,s.batchSize);await Ka(s.endpoint,{events:e},s.transport,s.debug),oe.length>0&&await Ka(s.endpoint,{events:oe.splice(0,s.batchSize)},s.transport,s.debug)}function Qa(s){return Math.max(0,Math.min(1,s))}function lo(s){let e=String(s!=null?s:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),i=t?Number(t[1]):1.8;return n=>1+(i+1)*Math.pow(n-1,3)+i*Math.pow(n-1,2)}return t=>1-(1-t)*(1-t)}function Et(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function co(s,e){let t=s==null?void 0:s[e];return typeof t=="number"?t:0}function es(s,e,t){try{s[e]=t}catch{}}function po(s){let e=s==null?void 0:s.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:t,y:i}}function ts(s,e){let t=s==null?void 0:s.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function is(s,e){let t=po(s);if(!t)return{from:null,to:null};let i=null,n=null;return typeof e.scale=="number"?(i=e.scale,n=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(n=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(n=e.scaleY),i===null&&n===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:i!=null?i:t.x,y:n!=null?n:t.y}}}function ns(){let s=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),s.size>0&&i()})},n=d=>{var u;s.add(d);let p=(u=e.get(d.target))!=null?u:new Set;p.add(d),e.set(d.target,p),i()},a=d=>{s.delete(d);let p=e.get(d.target);p&&(p.delete(d),p.size===0&&e.delete(d.target))},r=d=>{d.killed||(d.killed=!0,a(d))},o=()=>{var p,u;let d=Et();for(let g of Array.from(s)){if(g.killed||g.paused)continue;let h=d-g.startMs-g.delayMs;if(h<0)continue;let f=g.durationMs>0?h/g.durationMs:1,m=Qa(f),b=g.repeat>=0?g.repeat+1:1,y=g.repeat>0?Math.min(Math.floor(f),b-1):0;if(g.repeat>0&&f>=1){let L=f-y;m=Qa(L)}let v=g.ease(m);g.yoyo&&y%2===1&&(v=1-v);for(let L of g.props)es(g.target,L.key,L.from+(L.to-L.from)*v);g.scaleFrom&&g.scaleTo&&ts(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*v,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*v});try{(p=g.onUpdate)==null||p.call(g)}catch{}if(f>=b){r(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(d,p,u)=>{var L;let g=Math.max(0,(typeof p.duration=="number"?p.duration:.5)*1e3),h=Math.max(0,(typeof p.delay=="number"?p.delay:0)*1e3+((L=u==null?void 0:u.delayMsOverride)!=null?L:0)),f=lo(p.ease),m=typeof p.repeat=="number"?Math.max(0,p.repeat|0):0,b=p.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let P of Object.keys(p)){if(y.has(P))continue;let O=p[P];typeof O=="number"&&v.push({key:P,from:co(d,P),to:O})}let x=is(d,p);return{target:d,startMs:Et(),delayMs:h,durationMs:g,ease:f,props:v,scaleFrom:x.from,scaleTo:x.to,repeat:m,yoyo:b,onUpdate:typeof p.onUpdate=="function"?p.onUpdate:void 0,onComplete:typeof p.onComplete=="function"?p.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(d,p){let u=l(d,p);return n(u),{kill:()=>r(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=Et())},resume:()=>{var f;if(!u.paused)return;let g=(f=u.pauseAtMs)!=null?f:Et(),h=Et()-g;u.startMs+=h,u.paused=!1,u.pauseAtMs=null},isActive:()=>!u.killed&&!u.paused}},fromTo(d,p,u){return c.set(d,p),c.to(d,u)},set(d,p){if(!d||!p)return;for(let g of Object.keys(p)){let h=p[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof h=="number"&&es(d,g,h)}let u=is(d,p);u.to&&ts(d,u.to)},killTweensOf(d){let p=e.get(d);if(p)for(let u of Array.from(p))r(u)},timeline(d={}){let p=[],u=0,g=!1,h=[],f=y=>{if(typeof y=="number")return Math.max(0,y*1e3);let v=typeof y=="string"?y.trim():"";return v.startsWith("+=")?u+Math.max(0,Number(v.slice(2))*1e3||0):v?Math.max(0,Number(v)*1e3||0):u},m=y=>{p.push(y);let v=Math.max(0,(typeof y.vars.duration=="number"?y.vars.duration:.5)*1e3);u=Math.max(u,y.atMs+v)},b={to(y,v,x){return m({kind:"to",target:y,vars:v,atMs:f(x)}),b},fromTo(y,v,x,L){return m({kind:"fromTo",target:y,vars:x,from:v,atMs:f(L)}),b},play(){var y,v;if(g)return b;g=!0,h=[];for(let x of p)x.kind==="fromTo"&&c.set(x.target,(y=x.from)!=null?y:{}),h.push(c.to(x.target,{...x.vars,delay:x.atMs/1e3+((v=x.vars.delay)!=null?v:0)}));return b},pause(){for(let y of h)y.pause();return b},kill(){for(let y of h)y.kill();h=[],g=!1}};return d.paused||b.play(),b}};return c}function as(){if(typeof window=="undefined")return;let s=window;if(!s.gsap)try{s.gsap=ns()}catch{}}var ss={name:"handler-playable-sdk",version:"1.0.20",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs dist/cli/student-helper/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var ie=0,go=ie++,rs=ie++,os=ie++,ls=ie++,cs=ie++,ds=ie++,ps=ie++,us=ie++,gs=ie++,hs=ie++,fs=ie++,ms=ie++,U=go;function bs(){return U===rs}function ys(){return U===os}function vs(){return U===ls}function ws(){return U===cs}function et(){return U===ds}function tt(){return U===ps}function xs(){return U===us}function Ss(){return U===gs}function Es(){return U===hs}function En(){return U===fs}function Cn(){return U===ms}function Cs(){let s=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(s==="mraid")try{mraid.getState(),U=rs;return}catch{}else if(s==="dapi")try{dapi.isReady(),U=os;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(U=ls)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(U=cs)}catch{}else if(e==="mintegral")window.gameReady&&(U=ds);else if(e==="tapjoy")window.TJ_API&&(U=ps);else if(e==="tiktok")window.openAppStore&&(U=us);else if(e==="smadex")try{window.smxTracking&&(U=gs)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(U=hs)}catch{}else e==="vungle"?U=fs:(s==="nucleo"||e==="nucleo")&&(U=ms)}var ti=Ze(require("lottie-web"),1),An=ti.default;typeof window!="undefined"&&(window.lottie=ti.default,window.__baseLottie=ti.default);var ho=require("pixi.js");var Ln=require("pixi.js");var fo=null;function Tn(s){fo=s}ni();ii();var Ct=require("pixi.js");ni();var xo=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Mn=xo;if(typeof window!="undefined")try{let s=new XMLHttpRequest;if(s.open("GET","./build-settings.json",!1),s.send(),s.status===200&&s.responseText){let e=JSON.parse(s.responseText);e!=null&&e.buildMode&&(Mn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${Mn}`))}}catch{}function So(s){var t,i,n,a,r;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(s);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(s))return{x:(t=s[0])!=null?t:.5,y:(i=s[1])!=null?i:.5};if(s&&typeof s=="object"&&"x"in s&&"y"in s)return{x:(n=s.x)!=null?n:.5,y:(a=s.y)!=null?a:.5};if(typeof s=="string"){let o=s.trim().toLowerCase();return(r=e[o])!=null?r:{x:.5,y:.5}}return null}var ue=class{static async create(e,t,i){var l,c,d,p,u,g,h;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${Mn}`);let n=(l=t==null?void 0:t.render)==null?void 0:l.asset;if(!n){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let f=new Ct.Container;return this.applyTransform(f,t==null?void 0:t.transform,t),f}let a=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${a}, type: ${n.type}, path: ${n.path}`);let r=await He.load(e,n,i,a);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(d=r==null?void 0:r.constructor)==null?void 0:d.name}`);let o;if(n.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",r,"for object:",e),o=new Ct.Sprite(r),console.log("[ObjectFactory] Created object:",o,"type:",(p=o==null?void 0:o.constructor)==null?void 0:p.name),this.applyTransform(o,t==null?void 0:t.transform,t);else if(n.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(u=r==null?void 0:r.constructor)==null?void 0:u.name,r),r&&(((g=r.constructor)==null?void 0:g.name)==="Container"||r instanceof Ct.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let f=[n.path,`/assets/${n.path}`,`assets/${n.path}`,`../assets/${n.path}`],m=!1;for(let b of f)try{let y=await fetch(b);if(y.ok){o=await y.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(h=o==null?void 0:o.constructor)==null?void 0:h.name),m=!0;break}}catch{continue}m||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=r)}else o=r;else o=r,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,t==null?void 0:t.transform,t);return o}static applyTransform(e,t,i){var n,a,r,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(n=t.position.x)!=null?n:0,e.y=(a=t.position.y)!=null?a:0):"position"in e&&e.position&&e.position.set((r=t.position.x)!=null?r:0,(o=t.position.y)!=null?o:0)),t.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(t.scale):e.scale=t.scale),t.rotation!==void 0&&"rotation"in e&&(e.rotation=t.rotation),t.anchor&&"anchor"in e&&e.anchor)){let l=So(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};var At=class{constructor(){this.config=null}init(e){this.config=e}get(e){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(e)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(e){return this.config?this.config.objects.has(e):!1}};var Ao=Ze(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=Ao);it();var ai=require("pixi.js");it();var On=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new At}init(e,t){this.registry.init(e),this.app=t}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let t=this.registry.getAllIds().filter(n=>!this.instanceCache.has(n));if(t.length===0)return;let i=async n=>{n.length&&(console.log("[Assets] Loading objects:",n),await Promise.all(n.map(async a=>{var o;let r=this.registry.get(a);if(!r){console.warn("[Assets] No config found for object:",a);return}try{let l=await ue.create(a,r,this.app);this.instanceCache.set(a,l),console.log("[Assets] Loaded object:",a,(o=l==null?void 0:l.constructor)==null?void 0:o.name)}catch(l){console.error("[Assets] Failed to load object:",a,l)}})))};return this.readyPromise=(async()=>{await i(t);let n=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));n.length>0&&(console.warn("[Assets] Retrying missing assets:",n),await i(n)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let t=this.registry.get(e);if(t){let i=await ue.create(e,t,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},Lo=new On,To=new Proxy(Lo,{get(s,e){if(e in s&&typeof s[e]=="function")return s[e].bind(s);if(s.get(e))return s.get(e)}});it();var Is=require("pixi.js"),le={width:400,height:600,designWidth:400,scaleFactor:1},nt={scale:1,position:1},zn=[];function Po(s,e,t,i,n,a,r){zn.push({element:s,originalScale:a,positionHelper:e,heightPercent:n}),e(s,t,i,n,a,r,!1)}function Io(){zn.forEach(({element:s,originalScale:e,positionHelper:t,heightPercent:i})=>{let n=e*le.scaleFactor;t(s,le.width,le.height,i,n,!0,!1)})}function Rn(s,e){console.log(`[SCREEN] updateScreenState called: ${s}x${e}`),le.width=s,le.height=e,le.scaleFactor=Math.min(s/le.designWidth,1.15),nt.scale=le.scaleFactor,nt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${nt.scale.toFixed(3)}`),Io()}var he={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Mo(s,e,t){let i=he[s];i&&i[e]!==void 0&&(i[e]=t,console.log(`Updated ${s}.${e} = ${t}`))}function jo(){return he}var _o={center:{x:.5,y:.5},"center-center":{x:.5,y:.5},middle:{x:.5,y:.5},"middle-center":{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},"left-center":{x:0,y:.5},"right-center":{x:1,y:.5},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};function si(s,e){return typeof s=="number"&&Number.isFinite(s)?s:e}function at(s,e={x:.5,y:.5}){var t;if(Array.isArray(s))return{x:si(s[0],e.x),y:si(s[1],e.y)};if(s&&typeof s=="object"){let i=s;return{x:si(i.x,e.x),y:si(i.y,e.y)}}if(typeof s=="string"){let i=s.trim().toLowerCase();return(t=_o[i])!=null?t:e}return e}function Tt(s,e,t,i={}){var g,h,f,m,b,y;let n=at(t),a=(g=i.inset)!=null?g:{},r=(h=i.padding)!=null?h:{x:0,y:0},o=((f=a.left)!=null?f:0)+r.x,l=((m=a.right)!=null?m:0)+r.x,c=((b=a.top)!=null?b:0)+r.y,d=((y=a.bottom)!=null?y:0)+r.y,p=Math.max(0,s-o-l),u=Math.max(0,e-c-d);return{x:o+p*n.x,y:c+u*n.y}}function kt(s,e,t,i={}){var f,m,b,y,v,x;let n=(f=i.inset)!=null?f:{},a=(m=i.padding)!=null?m:{x:0,y:0},r=((b=n.left)!=null?b:0)+a.x,o=((y=n.right)!=null?y:0)+a.x,l=((v=n.top)!=null?v:0)+a.y,c=((x=n.bottom)!=null?x:0)+a.y,d=Math.max(0,s-r-o),p=Math.max(0,e-l-c),u=at(t,{x:.5,y:.5}),g=Math.min(Math.max(u.x,0),1),h=Math.min(Math.max(u.y,0),1);return{x:r+d*g,y:l+p*h}}if(typeof window!="undefined"){let s=window.innerWidth,e=window.innerHeight,t=()=>{let i=window.innerWidth,n=window.innerHeight;(i!==s||n!==e)&&(s=i,e=n,Rn(i,n))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Rn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Mo,window.getDebugConfig=jo,window.copyConfig=Uo,window.applyConfig=Lt,window.applyConfigForRatio=qo,window.positionAtBottom=Ms,window.positionAtTop=zo,window.positionAtCenter=$o,window.positionAtLeft=Do,window.positionAtRight=No,window.positionAtBottomLeft=Ho,window.positionAtBottomRight=Fo,window.positionAtTopLeft=Bo,window.positionAtTopRight=Go,window.applyPositionContract=Ro,console.log("\u{1F3AE} Debug Config Functions Available:"),console.log("\u2022 updateDebugConfig(category, key, value)"),console.log("\u2022 getDebugConfig()"),console.log("\u2022 copyConfig(presetName)"),console.log("\u2022 applyConfig(config)"),console.log("\u2022 applyConfigForRatio(width, height)"),console.log("\u{1F4CD} Positioning Helpers Available (with scale):"),console.log("\u2022 positionAtBottom(element, w, h, percent, scale)"),console.log("\u2022 positionAtTop(element, w, h, percent, scale)"),console.log("\u2022 positionAtCenter(element, w, h, offsetX, offsetY, scale)"),console.log("\u2022 positionAtLeft/Right(element, w, h, percent, scale)"),console.log("\u2022 Corner positions: BottomLeft/Right, TopLeft/Right (all with scale)"),console.log("\u2022 applyPositionContract(element, w, h, contract)"),console.log("Example: positionAtCenter(mySprite, 400, 600, 0, -50, 1.2)")}function ri(s,e,t=0){return s*e+t}function oi(s,e,t=0){return s*(1-e)+t}function li(s,e,t=0){return s*e+t}function ci(s,e,t=0){return s*(1-e)+t}function ae(s,e=0){return s/2+e}function Oo(s,e){return s*e}function Ro(s,e,t,i){var r,o,l,c,d,p,u,g,h,f,m,b,y,v,x,L,P,O,w,k;let n=0,a=0;switch(i.type){case"top":n=ae(e,(o=(r=i.offset)==null?void 0:r.x)!=null?o:0),a=ri(t,i.percent,(c=(l=i.offset)==null?void 0:l.y)!=null?c:0);break;case"bottom":n=ae(e,(p=(d=i.offset)==null?void 0:d.x)!=null?p:0),a=oi(t,i.percent,(g=(u=i.offset)==null?void 0:u.y)!=null?g:0);break;case"left":n=li(e,i.percent,(f=(h=i.offset)==null?void 0:h.x)!=null?f:0),a=ae(t,(b=(m=i.offset)==null?void 0:m.y)!=null?b:0);break;case"right":n=ci(e,i.percent,(v=(y=i.offset)==null?void 0:y.x)!=null?v:0),a=ae(t,(L=(x=i.offset)==null?void 0:x.y)!=null?L:0);break;case"center":n=ae(e,(O=(P=i.offset)==null?void 0:P.x)!=null?O:0),a=ae(t,(k=(w=i.offset)==null?void 0:w.y)!=null?k:0);break}s.position?s.position.set(n,a):(s.x=n,s.y=a),i.scale!==void 0&&i.scale!==1&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(i.scale,i.scale):(s.scale.x=i.scale,s.scale.y=i.scale))}function Ms(s,e,t,i=.2,n=1,a=!0,r=!1){let o=Oo(t,i),l=oi(t,i/2);we(s,ae(e),l);let c=a?n*le.scaleFactor:n;xe(s,c),r&&!zn.find(d=>d.element===s)&&Po(s,Ms,e,t,i,n,a)}function zo(s,e,t,i=.1,n=1){we(s,ae(e),ri(t,i)),xe(s,n)}function $o(s,e,t,i=0,n=0,a=1){we(s,ae(e,i),ae(t,n)),xe(s,a)}function Do(s,e,t,i=.1,n=1){we(s,li(e,i),ae(t)),xe(s,n)}function No(s,e,t,i=.1,n=1){we(s,ci(e,i),ae(t)),xe(s,n)}function Ho(s,e,t,i=.05,n=.05,a=1){we(s,li(e,n),oi(t,i)),xe(s,a)}function Fo(s,e,t,i=.05,n=.05,a=1){we(s,ci(e,n),oi(t,i)),xe(s,a)}function Bo(s,e,t,i=.05,n=.05,a=1){we(s,li(e,n),ri(t,i)),xe(s,a)}function Go(s,e,t,i=.05,n=.05,a=1){we(s,ci(e,n),ri(t,i)),xe(s,a)}function we(s,e,t){s&&s.position?typeof s.position.set=="function"?s.position.set(e,t):(s.position.x=e,s.position.y=t):s&&(s.x=e,s.y=t)}function xe(s,e){e!==1&&s&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(e,e):s.scale.x!==void 0&&s.scale.y!==void 0&&(s.scale.x=e,s.scale.y=e))}var Fe={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function Uo(s){return s&&Fe[s]?JSON.parse(JSON.stringify(Fe[s])):JSON.parse(JSON.stringify(he))}function Lt(s){Object.keys(s).forEach(e=>{let t=e;he[t]&&s[t]&&Object.assign(he[t],s[t])}),console.log("Config applied:",s)}function qo(s,e){let t=s/e;t>1.6?(Lt(Fe.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(Lt(Fe.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(Lt(Fe.square),console.log("Applied SQUARE config for ratio:",t)):(Lt(Fe.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let s=window;s.configPresets=Fe,s.resolveAnchorVec2=s.resolveAnchorVec2||at,s.resolveScreenAnchorPoint=s.resolveScreenAnchorPoint||Tt,s.resolveScreenRatioPoint=s.resolveScreenRatioPoint||kt}xi();function W(s,e){let t=(n,a)=>a===0?n:t(a,n%a),i=t(s,e);return`${s/i}:${e/i}`}var dd=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:W(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:W(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:W(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:W(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:W(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:W(360,780)}],pd=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:W(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:W(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:W(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:W(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:W(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:W(412,915)}],ud=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:W(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:W(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:W(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:W(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:W(800,1280)}],Zn=[{id:"playable-portrait",label:"Playable Portrait",width:320,height:480,category:"playable",ratio:"2:3",mraidScale:1},{id:"mraid-320x480",label:"MRAID 320\xD7480",width:320,height:480,category:"playable",ratio:"2:3",mraidScale:1},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"playable",ratio:W(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:W(768,1024),mraidScale:.7}];var Qn=[...Zn],ea=[{category:"playable",label:"Playable Ad",devices:Zn}],Si=Zn[0];function qe(s){return Qn.find(e=>e.id===s)||Si}function Qo(s){return Qn.filter(e=>e.category===s)}K();var je=class{async updateProperty(e,t,i,n={}){var l,c,d;console.log("[PropertyUpdateManager] Updating:",e,t,i);let a=window.getEditableObjectConfig;if(typeof a!="function"){console.error("[PropertyUpdateManager] getEditableObjectConfig not available");return}let r=a(e);if(!r){console.error("[PropertyUpdateManager] Config not found for:",e);return}ee({objectId:e,path:t,value:i},{persist:!0});let o=window.applyEditableObjectConfig;if(typeof o=="function"){let p=window.__editableConfig,u=(d=(c=(l=p==null?void 0:p.objects)==null?void 0:l.get)==null?void 0:c.call(l,e))!=null?d:r;await o(e,u),console.log("[PropertyUpdateManager] Applied config successfully")}else console.warn("[PropertyUpdateManager] applyEditableObjectConfig not available");this.triggerRefresh(e),n.refreshInspector&&window.dispatchEvent(new CustomEvent("inspector:refresh"))}getNestedProperty(e,t){let i=t.split("."),n=e;for(let a of i)if(n&&typeof n=="object"&&a in n)n=n[a];else return;return n}triggerRefresh(e){let t=window.__refreshHierarchy;typeof t=="function"&&t(),window.dispatchEvent(new CustomEvent("inspector:property-updated",{detail:{objectId:e}}))}};function ta(s){let e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async t=>{var a;let i=(a=t.target.files)==null?void 0:a[0];if(!i)return;let n=new FileReader;n.onload=async()=>{let r=n.result,o=s.category||"misc",c=`${(s.objectId||"new_asset").replace(/^json\./,"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"")||"new_asset"}_uploaded`;try{let p=await(await fetch("/api/library/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:o,filename:`${c}.png`,data:r,overwrite:!0})})).json();if(!(p!=null&&p.success)){alert(`Upload failed: ${(p==null?void 0:p.error)||"Unknown error"}`);return}let u=window.addAssetToRegistry;typeof u=="function"&&u(o,`${c}.png`);try{await fetch("/api/setup-library",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}let g=window.refreshAssetLibrary;typeof g=="function"&&await g(),await s.onApply(p.path)}catch(d){console.error("[QuickActionsBar] Upload error:",d),alert("Upload failed. Check console.")}},n.readAsDataURL(i)},e.click()}var Ei=class{constructor(){this.updateManager=new je}async handleAction(e,t,i){console.log("[QuickActionsBar] Action:",e,t,i);let n=window.getEditableObjectConfig;if(typeof n!="function")return;let a=n(t);if(!a)return;let r=this.updateManager.getNestedProperty(a,i);if(e==="ai-convert"||e==="upload"||e==="library"){let o=i==="ui.text"||i==="render.asset.path",l=i==="render.asset.path";o&&(await this.prepareForImageConversion(t,a),e==="ai-convert"&&i!=="render.asset.path"&&(i="render.asset.path"))}switch(e){case"library":this.openLibrary(t,i,r);break;case"ai-edit":this.openAIEditor(t,i,r);break;case"upload":this.openUpload(t,i);break;case"reset":await this.resetToDefault(t,i);break;case"ai-convert":this.handleAiConvert(t,i,r);break;default:console.warn("[QuickActionsBar] Unknown action:",e)}}async prepareForImageConversion(e,t){var i,n;if(console.log("[QuickActionsBar] Preparing for image conversion:",e),t.render||(t.render={alpha:1,visible:!0}),(t.render.alpha===0||t.render.alpha===void 0)&&(t.render.alpha=1,await this.updateManager.updateProperty(e,"render.alpha",1)),(t.render.visible===!1||t.render.visible===void 0)&&(t.render.visible=!0,await this.updateManager.updateProperty(e,"render.visible",!0)),t.render.asset||(t.render.asset={type:"image",path:""}),t.render.asset.type!=="image"&&(t.render.asset.type="image",await this.updateManager.updateProperty(e,"render.asset",{type:"image",path:t.render.asset.path||""})),t.ui&&t.ui.renderMode!=="png"){await this.updateManager.updateProperty(e,"ui.renderMode","png",{refreshInspector:!0}),await this.updateManager.updateProperty(e,"render.tint","#ffffff");let r=((n=(i=t.transform)==null?void 0:i.scale)!=null?n:1)*.3;await this.updateManager.updateProperty(e,"transform.scale",r),console.log("[QuickActionsBar] Text to PNG conversion: set tint white, scale",r)}this.ensureSlotInRegistry(e,t)}ensureSlotInRegistry(e,t){var o,l,c;let i=window.getEditableAssets;if(typeof i!="function")return;let n=i();if(!n||!n.slots)return;let a=e.startsWith("json.")?e.replace("json.",""):e;if(!n.slots.some(d=>d.objectId===a||d.slotId===a)){let d=((o=t.identity)==null?void 0:o.category)||"ui";console.log("[QuickActionsBar] Adding new slot to registry for converted object:",a),n.slots.push({slotId:a,displayName:a.replace(/_/g," "),objectId:a,category:d,currentAsset:((c=(l=t.render)==null?void 0:l.asset)==null?void 0:c.path)||"",defaultAsset:"",libraryFolder:d,assetType:"image"}),n.categories&&!n.categories.includes(d)&&n.categories.push(d),n.libraryAssets&&!n.libraryAssets[d]&&(n.libraryAssets[d]=[]);let p=window.reRenderAssetLibrary;typeof p=="function"&&p()}}openLibrary(e,t,i){var a;let n=window.__debugContext;if(n){if(n.activeTab!=="library"){n.activeTab="library";let r=window.__updateWorkbenchTabs;typeof r=="function"&&r()}if(n.libraryPanel){let r=window.getEditableObjectConfig,o=r==null?void 0:r(e),l=(a=o==null?void 0:o.identity)==null?void 0:a.category;l||(l=t.split(".")[0]==="render"?"environment":"ui"),console.log("[QuickActionsBar] Highlighting library slot:",e,"category:",l),n.libraryPanel.highlightSlot(e,l)}}}openAIEditor(e,t,i){let n=window.__openAiEditor;if(typeof n=="function"){let a=t.split(".").pop()||t;n(a,`Edit ${a} for ${e}`,i,{objectId:e,path:t})}else console.warn("[QuickActionsBar] AI Editor not available")}openUpload(e,t){var r;let i=window.getEditableObjectConfig,n=i==null?void 0:i(e),a=((r=n==null?void 0:n.identity)==null?void 0:r.category)||(t.split(".")[0]==="render"?"environment":"ui");ta({objectId:e,category:a,onApply:async o=>{var g,h;let l=window.applyAssetToSlot,c=this.getFilenameFromPath(o),d=/render\.asset\.path/i.test(t)||/\.(png|jpg|jpeg|gif|webp)$/i.test(o);typeof l=="function"&&c&&d&&await l(e,c,a),await this.updateManager.updateProperty(e,t,o);let p=window.__debugContext;(h=(g=p==null?void 0:p.options)==null?void 0:g.onPropertyChange)==null||h.call(g,e,t,o);let u=window.__highlightLibrarySlot;typeof u=="function"&&setTimeout(()=>{u(e,a)},500),window.dispatchEvent(new CustomEvent("inspector:refresh"))}})}getFilenameFromPath(e){if(!e)return"";let t=e.split("?")[0].replace(/\\/g,"/");return t.split("/").pop()||t}async resetToDefault(e,t){console.log("[QuickActionsBar] Reset to default:",e,t);try{let i=await this.getDefaultValue(e,t);i!==void 0?(await this.updateManager.updateProperty(e,t,i),console.log("[QuickActionsBar] Reset to default value:",i)):alert("No default value found for this property.")}catch(i){console.error("[QuickActionsBar] Failed to reset to default:",i),alert("Failed to reset property. Check console for details.")}}async getDefaultValue(e,t){let i=t.split(".");if(i.length<2)return;let n=i[0],a=i.slice(1),r=window.__editableConfig;if(!(r!=null&&r.schemas))return;let o=null;if(r.schemas instanceof Map?o=r.schemas.get(n):typeof r.schemas=="object"&&(o=r.schemas[n]),!(o!=null&&o.defaults))return;let l=o.defaults;for(let c of a)if(l&&typeof l=="object")l=l[c];else return;return l}handleAiConvert(e,t,i){let n=window.__openAiEditor;if(typeof n=="function"){let r=`A single, high-quality, high-detail game UI icon/asset representing "${String(i||e.replace(/_/g," ").replace("json.",""))}". Modern stylized 3D rendered style, vibrant colors, soft lighting, isolated on solid magenta background, highly polished professional game art.`,o="render.asset.path";console.log("[QuickActionsBar] AI Convert for:",e,"from:",t,"to:",o),n(e,r,"",{objectId:e,path:o});let l=window.__debugContext;if(l){l.activeTab="ai";let c=window.__updateWorkbenchTabs;typeof c=="function"&&c()}}else console.warn("[QuickActionsBar] AI Editor not available")}};var el=[{value:"loading",label:"Loading"},{value:"start",label:"Start"},{value:"gameplay",label:"Gameplay"},{value:"tutorial",label:"Tutorial"},{value:"endgame",label:"Endgame"}],tl=["environment","ui","character","system","backgrounds"],il=["bg","world","ui"],qs={SwerveMove:{speed:5,sensitivity:1,directionMode:"dominantAxis",axis:"both",bounds:{left:-400,right:400,top:-300,bottom:300}},DragToWin:{targetId:"",successDistance:80},DragSnap:{snapTargetId:"",snapDistance:40},JoystickMove:{speed:6,bounds:{left:-400,right:400,top:-300,bottom:300}}},Ci=class{constructor(){this.modal=null;this.state=null}open(e){this.state=this.createInitialState(e),this.createModal(),document.body.appendChild(this.modal),this.attachEventListeners(),this.updateStepUI()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),window.__wizardAssetPicker=null,this.modal=null,this.state=null}createInitialState(e){return{step:1,objectType:"sprite",instanceId:"",displayName:"",category:"environment",screenId:e.screenId,layer:"world",positionMode:"static",anchorPreset:"center",anchorX:.5,anchorY:.5,positionX:0,positionY:0,offsetX:0,offsetY:0,scale:.2,rotation:0,zIndex:0,assetPath:"",tint:"",alpha:1,text:"",font:"brand.primary",fontSize:18,letterSpacing:0,align:"center",graphicsWidth:200,graphicsHeight:200,graphicsFill:"#FFFFFF",graphicsAlpha:1,interactionEnabled:!1,dragEnabled:!1,hoverEnabled:!1,clickEnabled:!1,logicId:"",logicPropsRaw:""}}createModal(){let e=document.createElement("div");e.className="wizard-modal",e.innerHTML=`
46
+ `,this.modal=i}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(r=>{r.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(r=>{r.addEventListener("click",o=>{let c=o.target.dataset.tab;c&&this.switchTab(c)})});let i=this.modal.querySelector("[data-ai-generate]");i==null||i.addEventListener("click",()=>{this.openAiEditor("generate")});let n=this.modal.querySelector("[data-ai-edit]");n==null||n.addEventListener("click",()=>{this.openAiEditor("edit")});let a=this.modal.querySelector("[data-modal-apply]");a==null||a.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",r=>{r.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(n=>{n.classList.toggle("active",n.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(n=>{n.classList.toggle("active",n.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let t=window.__openAiEditor;if(typeof t!="function"){alert("AI Editor not available. Please check your setup.");return}let i="";e==="edit"&&this.currentAsset?i=`Edit this image: ${this.currentObjectId}`:i=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",i,this.currentAsset,{path:this.currentPath,onApply:n=>{this.onApplyCallback&&this.onApplyCallback(n),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var zl={};St(zl,{COLORS:()=>me,ConfigWatcher:()=>Ue,DebugPanel:()=>Ft,DefaultReloadStrategy:()=>Ot,Handler:()=>de,PlayableLoadingScreen:()=>dn,PreviewShell:()=>on,STROKE_WIDTH:()=>Nr,THEME:()=>Hr,applyConfigOverride:()=>ee,applyConfigOverrides:()=>ke,applyConfigsToDisk:()=>fi,applyDefaults:()=>Ge,baseLottie:()=>An,bootstrap:()=>Al,clearConfigOverrides:()=>se,clearConfigOverridesForObject:()=>zs,configOverrideManager:()=>$s,createPreviewShell:()=>Oa,deepClone:()=>Y,default:()=>De,defaultPreset:()=>Si,deviceGroups:()=>ea,devicePresets:()=>Qn,diffConfigs:()=>Wn,exportConfigsAsJSON:()=>Be,getConfigOverrides:()=>Z,getConfigStateSummary:()=>Pe,getOverrideMode:()=>It,getPresetById:()=>qe,getPresetsByCategory:()=>Qo,loadAllObjectConfigs:()=>yi,loadComponentSchemas:()=>bi,loadEngineConfig:()=>vi,loadGamePromptConfig:()=>Un,loadObjectCentricConfig:()=>Se,loadObjectConfig:()=>Me,loadSceneConfig:()=>wi,redoLastConfigChange:()=>hi,rehydrateObject:()=>Yn,removeConfigOverride:()=>Mt,resetToApplied:()=>jt,resetToOriginal:()=>mi,setBootstrapDependencies:()=>El,setOverrideMode:()=>Fn,setupHotReload:()=>Jn,setupLiveEditBridge:()=>ln,toLegacyFormat:()=>qn,trackObjectCreation:()=>Ds,trackObjectDeletion:()=>Ns,undoLastConfigChange:()=>gi,validateObjectConfig:()=>st});module.exports=oo(zl);var Le={};function Qt(s,e,t=!1){Le[s]||(Le[s]=[]),Le[s].push({fn:e,once:t})}function xn(s,e){if(Le[s]){if(!e){delete Le[s];return}Le[s]=Le[s].filter(t=>t.fn!==e)}}function ei(s,...e){let t=Le[s];if(t)for(let i of[...t])i.fn(...e),i.once&&xn(s,i.fn)}function te(s,e){Qt(s,e,!0)}var V=null,oe=[],Qe=null;function Ja(s){V=s,oe=[],Qe!==null&&(clearTimeout(Qe),Qe=null)}function Za(){var s,e,t;return{endpoint:(V==null?void 0:V.endpoint)||"",transport:(V==null?void 0:V.transport)||"beacon",batchSize:(s=V==null?void 0:V.batchSize)!=null?s:10,flushIntervalMs:(e=V==null?void 0:V.flushIntervalMs)!=null?e:300,maxQueue:(t=V==null?void 0:V.maxQueue)!=null?t:200,debug:!!(V!=null&&V.debug)}}async function Ka(s,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let a=navigator.sendBeacon(s,new Blob([n],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",a,e);return}catch(a){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",a)}try{await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(a){i&&console.warn("[handler.telemetry] fetch failed",a)}}function Sn(s,e){let t=Za();if(e&&t.endpoint){if(oe.push(s),oe.length>t.maxQueue&&(oe=oe.slice(oe.length-t.maxQueue)),oe.length>=t.batchSize){Xa();return}Qe===null&&(Qe=window.setTimeout(()=>{Qe=null,Xa()},t.flushIntervalMs))}}async function Xa(){let s=Za();if(!s.endpoint||oe.length===0)return;let e=oe.splice(0,s.batchSize);await Ka(s.endpoint,{events:e},s.transport,s.debug),oe.length>0&&await Ka(s.endpoint,{events:oe.splice(0,s.batchSize)},s.transport,s.debug)}function Qa(s){return Math.max(0,Math.min(1,s))}function lo(s){let e=String(s!=null?s:"power2.out");if(e==="linear")return t=>t;if(e==="sine.inOut")return t=>.5-Math.cos(Math.PI*t)/2;if(e==="power2.out"||e==="easeOutQuad")return t=>1-(1-t)*(1-t);if(e.startsWith("back.out")){let t=e.match(/back\.out\(([\d.]+)\)/),i=t?Number(t[1]):1.8;return n=>1+(i+1)*Math.pow(n-1,3)+i*Math.pow(n-1,2)}return t=>1-(1-t)*(1-t)}function Et(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function co(s,e){let t=s==null?void 0:s[e];return typeof t=="number"?t:0}function es(s,e,t){try{s[e]=t}catch{}}function po(s){let e=s==null?void 0:s.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,i=typeof e.y=="number"?e.y:1;return{x:t,y:i}}function ts(s,e){let t=s==null?void 0:s.scale;if(t)try{typeof t.set=="function"?t.set(e.x,e.y):(typeof t.x=="number"&&(t.x=e.x),typeof t.y=="number"&&(t.y=e.y))}catch{}}function is(s,e){let t=po(s);if(!t)return{from:null,to:null};let i=null,n=null;return typeof e.scale=="number"?(i=e.scale,n=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(n=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(n=e.scaleY),i===null&&n===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:i!=null?i:t.x,y:n!=null?n:t.y}}}function ns(){let s=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),s.size>0&&i()})},n=d=>{var u;s.add(d);let p=(u=e.get(d.target))!=null?u:new Set;p.add(d),e.set(d.target,p),i()},a=d=>{s.delete(d);let p=e.get(d.target);p&&(p.delete(d),p.size===0&&e.delete(d.target))},r=d=>{d.killed||(d.killed=!0,a(d))},o=()=>{var p,u;let d=Et();for(let g of Array.from(s)){if(g.killed||g.paused)continue;let h=d-g.startMs-g.delayMs;if(h<0)continue;let f=g.durationMs>0?h/g.durationMs:1,m=Qa(f),b=g.repeat>=0?g.repeat+1:1,y=g.repeat>0?Math.min(Math.floor(f),b-1):0;if(g.repeat>0&&f>=1){let L=f-y;m=Qa(L)}let v=g.ease(m);g.yoyo&&y%2===1&&(v=1-v);for(let L of g.props)es(g.target,L.key,L.from+(L.to-L.from)*v);g.scaleFrom&&g.scaleTo&&ts(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*v,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*v});try{(p=g.onUpdate)==null||p.call(g)}catch{}if(f>=b){r(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(d,p,u)=>{var L;let g=Math.max(0,(typeof p.duration=="number"?p.duration:.5)*1e3),h=Math.max(0,(typeof p.delay=="number"?p.delay:0)*1e3+((L=u==null?void 0:u.delayMsOverride)!=null?L:0)),f=lo(p.ease),m=typeof p.repeat=="number"?Math.max(0,p.repeat|0):0,b=p.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let P of Object.keys(p)){if(y.has(P))continue;let O=p[P];typeof O=="number"&&v.push({key:P,from:co(d,P),to:O})}let x=is(d,p);return{target:d,startMs:Et(),delayMs:h,durationMs:g,ease:f,props:v,scaleFrom:x.from,scaleTo:x.to,repeat:m,yoyo:b,onUpdate:typeof p.onUpdate=="function"?p.onUpdate:void 0,onComplete:typeof p.onComplete=="function"?p.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(d,p){let u=l(d,p);return n(u),{kill:()=>r(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=Et())},resume:()=>{var f;if(!u.paused)return;let g=(f=u.pauseAtMs)!=null?f:Et(),h=Et()-g;u.startMs+=h,u.paused=!1,u.pauseAtMs=null},isActive:()=>!u.killed&&!u.paused}},fromTo(d,p,u){return c.set(d,p),c.to(d,u)},set(d,p){if(!d||!p)return;for(let g of Object.keys(p)){let h=p[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof h=="number"&&es(d,g,h)}let u=is(d,p);u.to&&ts(d,u.to)},killTweensOf(d){let p=e.get(d);if(p)for(let u of Array.from(p))r(u)},timeline(d={}){let p=[],u=0,g=!1,h=[],f=y=>{if(typeof y=="number")return Math.max(0,y*1e3);let v=typeof y=="string"?y.trim():"";return v.startsWith("+=")?u+Math.max(0,Number(v.slice(2))*1e3||0):v?Math.max(0,Number(v)*1e3||0):u},m=y=>{p.push(y);let v=Math.max(0,(typeof y.vars.duration=="number"?y.vars.duration:.5)*1e3);u=Math.max(u,y.atMs+v)},b={to(y,v,x){return m({kind:"to",target:y,vars:v,atMs:f(x)}),b},fromTo(y,v,x,L){return m({kind:"fromTo",target:y,vars:x,from:v,atMs:f(L)}),b},play(){var y,v;if(g)return b;g=!0,h=[];for(let x of p)x.kind==="fromTo"&&c.set(x.target,(y=x.from)!=null?y:{}),h.push(c.to(x.target,{...x.vars,delay:x.atMs/1e3+((v=x.vars.delay)!=null?v:0)}));return b},pause(){for(let y of h)y.pause();return b},kill(){for(let y of h)y.kill();h=[],g=!1}};return d.paused||b.play(),b}};return c}function as(){if(typeof window=="undefined")return;let s=window;if(!s.gsap)try{s.gsap=ns()}catch{}}var ss={name:"handler-playable-sdk",version:"1.0.21",type:"module",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.cjs",module:"dist/index.js",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.js",require:"./dist/pixi/index.cjs"},"./pixi/index.css":{import:"./dist/pixi/index.css",require:"./dist/pixi/index.css"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.js",require:"./dist/three/index.cjs"},"./cli":{types:"./dist/cli/index.d.ts",import:"./dist/cli/index.js",require:"./dist/cli/index.cjs"}},bin:{"handler-student-helper":"./bin/student-helper.mjs","handler-validate":"./bin/validate.mjs","handler-sync-screens":"./bin/sync-screens.mjs","handler-brand-dna":"./bin/brand-dna.mjs","handler-setup-library":"./bin/setup-library.mjs","handler-screen-helper":"./bin/screen-helper.mjs"},scripts:{prebuild:"python3 src/preview/build-css.py",build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --minify --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli && npm run obfuscate && npm run postbuild",postbuild:"python3 src/preview/copy-css-to-dist.py","postbuild-cli":"cp src/cli/*.mjs dist/cli/ && mkdir -p dist/cli/student-helper && cp src/cli/student-helper/*.mjs dist/cli/student-helper/ && chmod +x dist/cli/*.mjs dist/cli/student-helper/*.mjs && chmod +x bin/*.mjs","create-mjs-symlinks":"cd dist && ln -sf index.js index.mjs && cd pixi && ln -sf index.js index.mjs && cd ../three && ln -sf index.js index.mjs","build:dev":"tsup src/index.ts src/pixi/index.ts src/three/index.ts src/cli/index.ts --format cjs,esm --dts --clean --external lottie-web --external jszip && npm run create-mjs-symlinks && npm run postbuild-cli",obfuscate:"javascript-obfuscator dist/pixi/index.js --output dist/pixi/index.js --config obfuscator.config.json && javascript-obfuscator dist/three/index.js --output dist/three/index.js --config obfuscator.config.json && javascript-obfuscator dist/cli/index.js --output dist/cli/index.js --config obfuscator.config.json && npm run obfuscate-cli","obfuscate-cli":'for file in dist/cli/*.mjs dist/cli/student-helper/*.mjs; do javascript-obfuscator "$file" --output "$file" --config obfuscator.config.json; done',lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build","publish:update":"node scripts/publish-and-update.cjs patch","publish:update:minor":"node scripts/publish-and-update.cjs minor","publish:update:major":"node scripts/publish-and-update.cjs major"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","bin","LICENSE","README.md"],peerDependencies:{"lottie-web":"^5.0.0","pixi.js":"^8.0.0",three:"^0.182.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0},"lottie-web":{optional:!0}},devDependencies:{"@types/three":"^0.182.0",eslint:"^9.39.2","javascript-obfuscator":"^5.1.0","pixi.js":"8.8.1",three:"^0.182.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2","typescript-eslint":"^8.53.0"},dependencies:{"@google/genai":"^1.35.0","@google/generative-ai":"^0.24.1",jszip:"^3.10.1",sharp:"^0.34.5"}};var ie=0,go=ie++,rs=ie++,os=ie++,ls=ie++,cs=ie++,ds=ie++,ps=ie++,us=ie++,gs=ie++,hs=ie++,fs=ie++,ms=ie++,U=go;function bs(){return U===rs}function ys(){return U===os}function vs(){return U===ls}function ws(){return U===cs}function et(){return U===ds}function tt(){return U===ps}function xs(){return U===us}function Ss(){return U===gs}function Es(){return U===hs}function En(){return U===fs}function Cn(){return U===ms}function Cs(){let s=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(s==="mraid")try{mraid.getState(),U=rs;return}catch{}else if(s==="dapi")try{dapi.isReady(),U=os;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(U=ls)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(U=cs)}catch{}else if(e==="mintegral")window.gameReady&&(U=ds);else if(e==="tapjoy")window.TJ_API&&(U=ps);else if(e==="tiktok")window.openAppStore&&(U=us);else if(e==="smadex")try{window.smxTracking&&(U=gs)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(U=hs)}catch{}else e==="vungle"?U=fs:(s==="nucleo"||e==="nucleo")&&(U=ms)}var ti=Ze(require("lottie-web"),1),An=ti.default;typeof window!="undefined"&&(window.lottie=ti.default,window.__baseLottie=ti.default);var ho=require("pixi.js");var Ln=require("pixi.js");var fo=null;function Tn(s){fo=s}ni();ii();var Ct=require("pixi.js");ni();var xo=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Mn=xo;if(typeof window!="undefined")try{let s=new XMLHttpRequest;if(s.open("GET","./build-settings.json",!1),s.send(),s.status===200&&s.responseText){let e=JSON.parse(s.responseText);e!=null&&e.buildMode&&(Mn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${Mn}`))}}catch{}function So(s){var t,i,n,a,r;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(s);let e={center:{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};if(Array.isArray(s))return{x:(t=s[0])!=null?t:.5,y:(i=s[1])!=null?i:.5};if(s&&typeof s=="object"&&"x"in s&&"y"in s)return{x:(n=s.x)!=null?n:.5,y:(a=s.y)!=null?a:.5};if(typeof s=="string"){let o=s.trim().toLowerCase();return(r=e[o])!=null?r:{x:.5,y:.5}}return null}var ue=class{static async create(e,t,i){var l,c,d,p,u,g,h;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${Mn}`);let n=(l=t==null?void 0:t.render)==null?void 0:l.asset;if(!n){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let f=new Ct.Container;return this.applyTransform(f,t==null?void 0:t.transform,t),f}let a=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${a}, type: ${n.type}, path: ${n.path}`);let r=await He.load(e,n,i,a);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(d=r==null?void 0:r.constructor)==null?void 0:d.name}`);let o;if(n.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",r,"for object:",e),o=new Ct.Sprite(r),console.log("[ObjectFactory] Created object:",o,"type:",(p=o==null?void 0:o.constructor)==null?void 0:p.name),this.applyTransform(o,t==null?void 0:t.transform,t);else if(n.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(u=r==null?void 0:r.constructor)==null?void 0:u.name,r),r&&(((g=r.constructor)==null?void 0:g.name)==="Container"||r instanceof Ct.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let f=[n.path,`/assets/${n.path}`,`assets/${n.path}`,`../assets/${n.path}`],m=!1;for(let b of f)try{let y=await fetch(b);if(y.ok){o=await y.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(h=o==null?void 0:o.constructor)==null?void 0:h.name),m=!0;break}}catch{continue}m||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=r)}else o=r;else o=r,o&&typeof o=="object"&&("x"in o||"position"in o)&&this.applyTransform(o,t==null?void 0:t.transform,t);return o}static applyTransform(e,t,i){var n,a,r,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(n=t.position.x)!=null?n:0,e.y=(a=t.position.y)!=null?a:0):"position"in e&&e.position&&e.position.set((r=t.position.x)!=null?r:0,(o=t.position.y)!=null?o:0)),t.scale!==void 0&&"scale"in e&&e.scale&&(typeof e.scale=="object"&&"set"in e.scale?e.scale.set(t.scale):e.scale=t.scale),t.rotation!==void 0&&"rotation"in e&&(e.rotation=t.rotation),t.anchor&&"anchor"in e&&e.anchor)){let l=So(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};var At=class{constructor(){this.config=null}init(e){this.config=e}get(e){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(e)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(e){return this.config?this.config.objects.has(e):!1}};var Ao=Ze(require("pixi.js"),1);typeof window!="undefined"&&(window.__basePixi=Ao);it();var ai=require("pixi.js");it();var On=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new At}init(e,t){this.registry.init(e),this.app=t}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let t=this.registry.getAllIds().filter(n=>!this.instanceCache.has(n));if(t.length===0)return;let i=async n=>{n.length&&(console.log("[Assets] Loading objects:",n),await Promise.all(n.map(async a=>{var o;let r=this.registry.get(a);if(!r){console.warn("[Assets] No config found for object:",a);return}try{let l=await ue.create(a,r,this.app);this.instanceCache.set(a,l),console.log("[Assets] Loaded object:",a,(o=l==null?void 0:l.constructor)==null?void 0:o.name)}catch(l){console.error("[Assets] Failed to load object:",a,l)}})))};return this.readyPromise=(async()=>{await i(t);let n=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));n.length>0&&(console.warn("[Assets] Retrying missing assets:",n),await i(n)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let t=this.registry.get(e);if(t){let i=await ue.create(e,t,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},Lo=new On,To=new Proxy(Lo,{get(s,e){if(e in s&&typeof s[e]=="function")return s[e].bind(s);if(s.get(e))return s.get(e)}});it();var Is=require("pixi.js"),le={width:400,height:600,designWidth:400,scaleFactor:1},nt={scale:1,position:1},zn=[];function Po(s,e,t,i,n,a,r){zn.push({element:s,originalScale:a,positionHelper:e,heightPercent:n}),e(s,t,i,n,a,r,!1)}function Io(){zn.forEach(({element:s,originalScale:e,positionHelper:t,heightPercent:i})=>{let n=e*le.scaleFactor;t(s,le.width,le.height,i,n,!0,!1)})}function Rn(s,e){console.log(`[SCREEN] updateScreenState called: ${s}x${e}`),le.width=s,le.height=e,le.scaleFactor=Math.min(s/le.designWidth,1.15),nt.scale=le.scaleFactor,nt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${nt.scale.toFixed(3)}`),Io()}var he={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Mo(s,e,t){let i=he[s];i&&i[e]!==void 0&&(i[e]=t,console.log(`Updated ${s}.${e} = ${t}`))}function jo(){return he}var _o={center:{x:.5,y:.5},"center-center":{x:.5,y:.5},middle:{x:.5,y:.5},"middle-center":{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},"left-center":{x:0,y:.5},"right-center":{x:1,y:.5},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};function si(s,e){return typeof s=="number"&&Number.isFinite(s)?s:e}function at(s,e={x:.5,y:.5}){var t;if(Array.isArray(s))return{x:si(s[0],e.x),y:si(s[1],e.y)};if(s&&typeof s=="object"){let i=s;return{x:si(i.x,e.x),y:si(i.y,e.y)}}if(typeof s=="string"){let i=s.trim().toLowerCase();return(t=_o[i])!=null?t:e}return e}function Tt(s,e,t,i={}){var g,h,f,m,b,y;let n=at(t),a=(g=i.inset)!=null?g:{},r=(h=i.padding)!=null?h:{x:0,y:0},o=((f=a.left)!=null?f:0)+r.x,l=((m=a.right)!=null?m:0)+r.x,c=((b=a.top)!=null?b:0)+r.y,d=((y=a.bottom)!=null?y:0)+r.y,p=Math.max(0,s-o-l),u=Math.max(0,e-c-d);return{x:o+p*n.x,y:c+u*n.y}}function kt(s,e,t,i={}){var f,m,b,y,v,x;let n=(f=i.inset)!=null?f:{},a=(m=i.padding)!=null?m:{x:0,y:0},r=((b=n.left)!=null?b:0)+a.x,o=((y=n.right)!=null?y:0)+a.x,l=((v=n.top)!=null?v:0)+a.y,c=((x=n.bottom)!=null?x:0)+a.y,d=Math.max(0,s-r-o),p=Math.max(0,e-l-c),u=at(t,{x:.5,y:.5}),g=Math.min(Math.max(u.x,0),1),h=Math.min(Math.max(u.y,0),1);return{x:r+d*g,y:l+p*h}}if(typeof window!="undefined"){let s=window.innerWidth,e=window.innerHeight,t=()=>{let i=window.innerWidth,n=window.innerHeight;(i!==s||n!==e)&&(s=i,e=n,Rn(i,n))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Rn(window.innerWidth,window.innerHeight),window.updateDebugConfig=Mo,window.getDebugConfig=jo,window.copyConfig=Uo,window.applyConfig=Lt,window.applyConfigForRatio=qo,window.positionAtBottom=Ms,window.positionAtTop=zo,window.positionAtCenter=$o,window.positionAtLeft=Do,window.positionAtRight=No,window.positionAtBottomLeft=Ho,window.positionAtBottomRight=Fo,window.positionAtTopLeft=Bo,window.positionAtTopRight=Go,window.applyPositionContract=Ro,console.log("\u{1F3AE} Debug Config Functions Available:"),console.log("\u2022 updateDebugConfig(category, key, value)"),console.log("\u2022 getDebugConfig()"),console.log("\u2022 copyConfig(presetName)"),console.log("\u2022 applyConfig(config)"),console.log("\u2022 applyConfigForRatio(width, height)"),console.log("\u{1F4CD} Positioning Helpers Available (with scale):"),console.log("\u2022 positionAtBottom(element, w, h, percent, scale)"),console.log("\u2022 positionAtTop(element, w, h, percent, scale)"),console.log("\u2022 positionAtCenter(element, w, h, offsetX, offsetY, scale)"),console.log("\u2022 positionAtLeft/Right(element, w, h, percent, scale)"),console.log("\u2022 Corner positions: BottomLeft/Right, TopLeft/Right (all with scale)"),console.log("\u2022 applyPositionContract(element, w, h, contract)"),console.log("Example: positionAtCenter(mySprite, 400, 600, 0, -50, 1.2)")}function ri(s,e,t=0){return s*e+t}function oi(s,e,t=0){return s*(1-e)+t}function li(s,e,t=0){return s*e+t}function ci(s,e,t=0){return s*(1-e)+t}function ae(s,e=0){return s/2+e}function Oo(s,e){return s*e}function Ro(s,e,t,i){var r,o,l,c,d,p,u,g,h,f,m,b,y,v,x,L,P,O,w,k;let n=0,a=0;switch(i.type){case"top":n=ae(e,(o=(r=i.offset)==null?void 0:r.x)!=null?o:0),a=ri(t,i.percent,(c=(l=i.offset)==null?void 0:l.y)!=null?c:0);break;case"bottom":n=ae(e,(p=(d=i.offset)==null?void 0:d.x)!=null?p:0),a=oi(t,i.percent,(g=(u=i.offset)==null?void 0:u.y)!=null?g:0);break;case"left":n=li(e,i.percent,(f=(h=i.offset)==null?void 0:h.x)!=null?f:0),a=ae(t,(b=(m=i.offset)==null?void 0:m.y)!=null?b:0);break;case"right":n=ci(e,i.percent,(v=(y=i.offset)==null?void 0:y.x)!=null?v:0),a=ae(t,(L=(x=i.offset)==null?void 0:x.y)!=null?L:0);break;case"center":n=ae(e,(O=(P=i.offset)==null?void 0:P.x)!=null?O:0),a=ae(t,(k=(w=i.offset)==null?void 0:w.y)!=null?k:0);break}s.position?s.position.set(n,a):(s.x=n,s.y=a),i.scale!==void 0&&i.scale!==1&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(i.scale,i.scale):(s.scale.x=i.scale,s.scale.y=i.scale))}function Ms(s,e,t,i=.2,n=1,a=!0,r=!1){let o=Oo(t,i),l=oi(t,i/2);we(s,ae(e),l);let c=a?n*le.scaleFactor:n;xe(s,c),r&&!zn.find(d=>d.element===s)&&Po(s,Ms,e,t,i,n,a)}function zo(s,e,t,i=.1,n=1){we(s,ae(e),ri(t,i)),xe(s,n)}function $o(s,e,t,i=0,n=0,a=1){we(s,ae(e,i),ae(t,n)),xe(s,a)}function Do(s,e,t,i=.1,n=1){we(s,li(e,i),ae(t)),xe(s,n)}function No(s,e,t,i=.1,n=1){we(s,ci(e,i),ae(t)),xe(s,n)}function Ho(s,e,t,i=.05,n=.05,a=1){we(s,li(e,n),oi(t,i)),xe(s,a)}function Fo(s,e,t,i=.05,n=.05,a=1){we(s,ci(e,n),oi(t,i)),xe(s,a)}function Bo(s,e,t,i=.05,n=.05,a=1){we(s,li(e,n),ri(t,i)),xe(s,a)}function Go(s,e,t,i=.05,n=.05,a=1){we(s,ci(e,n),ri(t,i)),xe(s,a)}function we(s,e,t){s&&s.position?typeof s.position.set=="function"?s.position.set(e,t):(s.position.x=e,s.position.y=t):s&&(s.x=e,s.y=t)}function xe(s,e){e!==1&&s&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(e,e):s.scale.x!==void 0&&s.scale.y!==void 0&&(s.scale.x=e,s.scale.y=e))}var Fe={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function Uo(s){return s&&Fe[s]?JSON.parse(JSON.stringify(Fe[s])):JSON.parse(JSON.stringify(he))}function Lt(s){Object.keys(s).forEach(e=>{let t=e;he[t]&&s[t]&&Object.assign(he[t],s[t])}),console.log("Config applied:",s)}function qo(s,e){let t=s/e;t>1.6?(Lt(Fe.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(Lt(Fe.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(Lt(Fe.square),console.log("Applied SQUARE config for ratio:",t)):(Lt(Fe.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let s=window;s.configPresets=Fe,s.resolveAnchorVec2=s.resolveAnchorVec2||at,s.resolveScreenAnchorPoint=s.resolveScreenAnchorPoint||Tt,s.resolveScreenRatioPoint=s.resolveScreenRatioPoint||kt}xi();function W(s,e){let t=(n,a)=>a===0?n:t(a,n%a),i=t(s,e);return`${s/i}:${e/i}`}var dd=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:W(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:W(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:W(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:W(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:W(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:W(360,780)}],pd=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:W(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:W(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:W(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:W(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:W(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:W(412,915)}],ud=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:W(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:W(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:W(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:W(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:W(800,1280)}],Zn=[{id:"playable-portrait",label:"Playable Portrait",width:320,height:480,category:"playable",ratio:"2:3",mraidScale:1},{id:"mraid-320x480",label:"MRAID 320\xD7480",width:320,height:480,category:"playable",ratio:"2:3",mraidScale:1},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"playable",ratio:W(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:W(768,1024),mraidScale:.7}];var Qn=[...Zn],ea=[{category:"playable",label:"Playable Ad",devices:Zn}],Si=Zn[0];function qe(s){return Qn.find(e=>e.id===s)||Si}function Qo(s){return Qn.filter(e=>e.category===s)}K();var je=class{async updateProperty(e,t,i,n={}){var l,c,d;console.log("[PropertyUpdateManager] Updating:",e,t,i);let a=window.getEditableObjectConfig;if(typeof a!="function"){console.error("[PropertyUpdateManager] getEditableObjectConfig not available");return}let r=a(e);if(!r){console.error("[PropertyUpdateManager] Config not found for:",e);return}ee({objectId:e,path:t,value:i},{persist:!0});let o=window.applyEditableObjectConfig;if(typeof o=="function"){let p=window.__editableConfig,u=(d=(c=(l=p==null?void 0:p.objects)==null?void 0:l.get)==null?void 0:c.call(l,e))!=null?d:r;await o(e,u),console.log("[PropertyUpdateManager] Applied config successfully")}else console.warn("[PropertyUpdateManager] applyEditableObjectConfig not available");this.triggerRefresh(e),n.refreshInspector&&window.dispatchEvent(new CustomEvent("inspector:refresh"))}getNestedProperty(e,t){let i=t.split("."),n=e;for(let a of i)if(n&&typeof n=="object"&&a in n)n=n[a];else return;return n}triggerRefresh(e){let t=window.__refreshHierarchy;typeof t=="function"&&t(),window.dispatchEvent(new CustomEvent("inspector:property-updated",{detail:{objectId:e}}))}};function ta(s){let e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=async t=>{var a;let i=(a=t.target.files)==null?void 0:a[0];if(!i)return;let n=new FileReader;n.onload=async()=>{let r=n.result,o=s.category||"misc",c=`${(s.objectId||"new_asset").replace(/^json\./,"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"")||"new_asset"}_uploaded`;try{let p=await(await fetch("/api/library/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({category:o,filename:`${c}.png`,data:r,overwrite:!0})})).json();if(!(p!=null&&p.success)){alert(`Upload failed: ${(p==null?void 0:p.error)||"Unknown error"}`);return}let u=window.addAssetToRegistry;typeof u=="function"&&u(o,`${c}.png`);try{await fetch("/api/setup-library",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}let g=window.refreshAssetLibrary;typeof g=="function"&&await g(),await s.onApply(p.path)}catch(d){console.error("[QuickActionsBar] Upload error:",d),alert("Upload failed. Check console.")}},n.readAsDataURL(i)},e.click()}var Ei=class{constructor(){this.updateManager=new je}async handleAction(e,t,i){console.log("[QuickActionsBar] Action:",e,t,i);let n=window.getEditableObjectConfig;if(typeof n!="function")return;let a=n(t);if(!a)return;let r=this.updateManager.getNestedProperty(a,i);if(e==="ai-convert"||e==="upload"||e==="library"){let o=i==="ui.text"||i==="render.asset.path",l=i==="render.asset.path";o&&(await this.prepareForImageConversion(t,a),e==="ai-convert"&&i!=="render.asset.path"&&(i="render.asset.path"))}switch(e){case"library":this.openLibrary(t,i,r);break;case"ai-edit":this.openAIEditor(t,i,r);break;case"upload":this.openUpload(t,i);break;case"reset":await this.resetToDefault(t,i);break;case"ai-convert":this.handleAiConvert(t,i,r);break;default:console.warn("[QuickActionsBar] Unknown action:",e)}}async prepareForImageConversion(e,t){var i,n;if(console.log("[QuickActionsBar] Preparing for image conversion:",e),t.render||(t.render={alpha:1,visible:!0}),(t.render.alpha===0||t.render.alpha===void 0)&&(t.render.alpha=1,await this.updateManager.updateProperty(e,"render.alpha",1)),(t.render.visible===!1||t.render.visible===void 0)&&(t.render.visible=!0,await this.updateManager.updateProperty(e,"render.visible",!0)),t.render.asset||(t.render.asset={type:"image",path:""}),t.render.asset.type!=="image"&&(t.render.asset.type="image",await this.updateManager.updateProperty(e,"render.asset",{type:"image",path:t.render.asset.path||""})),t.ui&&t.ui.renderMode!=="png"){await this.updateManager.updateProperty(e,"ui.renderMode","png",{refreshInspector:!0}),await this.updateManager.updateProperty(e,"render.tint","#ffffff");let r=((n=(i=t.transform)==null?void 0:i.scale)!=null?n:1)*.3;await this.updateManager.updateProperty(e,"transform.scale",r),console.log("[QuickActionsBar] Text to PNG conversion: set tint white, scale",r)}this.ensureSlotInRegistry(e,t)}ensureSlotInRegistry(e,t){var o,l,c;let i=window.getEditableAssets;if(typeof i!="function")return;let n=i();if(!n||!n.slots)return;let a=e.startsWith("json.")?e.replace("json.",""):e;if(!n.slots.some(d=>d.objectId===a||d.slotId===a)){let d=((o=t.identity)==null?void 0:o.category)||"ui";console.log("[QuickActionsBar] Adding new slot to registry for converted object:",a),n.slots.push({slotId:a,displayName:a.replace(/_/g," "),objectId:a,category:d,currentAsset:((c=(l=t.render)==null?void 0:l.asset)==null?void 0:c.path)||"",defaultAsset:"",libraryFolder:d,assetType:"image"}),n.categories&&!n.categories.includes(d)&&n.categories.push(d),n.libraryAssets&&!n.libraryAssets[d]&&(n.libraryAssets[d]=[]);let p=window.reRenderAssetLibrary;typeof p=="function"&&p()}}openLibrary(e,t,i){var a;let n=window.__debugContext;if(n){if(n.activeTab!=="library"){n.activeTab="library";let r=window.__updateWorkbenchTabs;typeof r=="function"&&r()}if(n.libraryPanel){let r=window.getEditableObjectConfig,o=r==null?void 0:r(e),l=(a=o==null?void 0:o.identity)==null?void 0:a.category;l||(l=t.split(".")[0]==="render"?"environment":"ui"),console.log("[QuickActionsBar] Highlighting library slot:",e,"category:",l),n.libraryPanel.highlightSlot(e,l)}}}openAIEditor(e,t,i){let n=window.__openAiEditor;if(typeof n=="function"){let a=t.split(".").pop()||t;n(a,`Edit ${a} for ${e}`,i,{objectId:e,path:t})}else console.warn("[QuickActionsBar] AI Editor not available")}openUpload(e,t){var r;let i=window.getEditableObjectConfig,n=i==null?void 0:i(e),a=((r=n==null?void 0:n.identity)==null?void 0:r.category)||(t.split(".")[0]==="render"?"environment":"ui");ta({objectId:e,category:a,onApply:async o=>{var g,h;let l=window.applyAssetToSlot,c=this.getFilenameFromPath(o),d=/render\.asset\.path/i.test(t)||/\.(png|jpg|jpeg|gif|webp)$/i.test(o);typeof l=="function"&&c&&d&&await l(e,c,a),await this.updateManager.updateProperty(e,t,o);let p=window.__debugContext;(h=(g=p==null?void 0:p.options)==null?void 0:g.onPropertyChange)==null||h.call(g,e,t,o);let u=window.__highlightLibrarySlot;typeof u=="function"&&setTimeout(()=>{u(e,a)},500),window.dispatchEvent(new CustomEvent("inspector:refresh"))}})}getFilenameFromPath(e){if(!e)return"";let t=e.split("?")[0].replace(/\\/g,"/");return t.split("/").pop()||t}async resetToDefault(e,t){console.log("[QuickActionsBar] Reset to default:",e,t);try{let i=await this.getDefaultValue(e,t);i!==void 0?(await this.updateManager.updateProperty(e,t,i),console.log("[QuickActionsBar] Reset to default value:",i)):alert("No default value found for this property.")}catch(i){console.error("[QuickActionsBar] Failed to reset to default:",i),alert("Failed to reset property. Check console for details.")}}async getDefaultValue(e,t){let i=t.split(".");if(i.length<2)return;let n=i[0],a=i.slice(1),r=window.__editableConfig;if(!(r!=null&&r.schemas))return;let o=null;if(r.schemas instanceof Map?o=r.schemas.get(n):typeof r.schemas=="object"&&(o=r.schemas[n]),!(o!=null&&o.defaults))return;let l=o.defaults;for(let c of a)if(l&&typeof l=="object")l=l[c];else return;return l}handleAiConvert(e,t,i){let n=window.__openAiEditor;if(typeof n=="function"){let r=`A single, high-quality, high-detail game UI icon/asset representing "${String(i||e.replace(/_/g," ").replace("json.",""))}". Modern stylized 3D rendered style, vibrant colors, soft lighting, isolated on solid magenta background, highly polished professional game art.`,o="render.asset.path";console.log("[QuickActionsBar] AI Convert for:",e,"from:",t,"to:",o),n(e,r,"",{objectId:e,path:o});let l=window.__debugContext;if(l){l.activeTab="ai";let c=window.__updateWorkbenchTabs;typeof c=="function"&&c()}}else console.warn("[QuickActionsBar] AI Editor not available")}};var el=[{value:"loading",label:"Loading"},{value:"start",label:"Start"},{value:"gameplay",label:"Gameplay"},{value:"tutorial",label:"Tutorial"},{value:"endgame",label:"Endgame"}],tl=["environment","ui","character","system","backgrounds"],il=["bg","world","ui"],qs={SwerveMove:{speed:5,sensitivity:1,directionMode:"dominantAxis",axis:"both",bounds:{left:-400,right:400,top:-300,bottom:300}},DragToWin:{targetId:"",successDistance:80},DragSnap:{snapTargetId:"",snapDistance:40},JoystickMove:{speed:6,bounds:{left:-400,right:400,top:-300,bottom:300}}},Ci=class{constructor(){this.modal=null;this.state=null}open(e){this.state=this.createInitialState(e),this.createModal(),document.body.appendChild(this.modal),this.attachEventListeners(),this.updateStepUI()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),window.__wizardAssetPicker=null,this.modal=null,this.state=null}createInitialState(e){return{step:1,objectType:"sprite",instanceId:"",displayName:"",category:"environment",screenId:e.screenId,layer:"world",positionMode:"static",anchorPreset:"center",anchorX:.5,anchorY:.5,positionX:0,positionY:0,offsetX:0,offsetY:0,scale:.2,rotation:0,zIndex:0,assetPath:"",tint:"",alpha:1,text:"",font:"brand.primary",fontSize:18,letterSpacing:0,align:"center",graphicsWidth:200,graphicsHeight:200,graphicsFill:"#FFFFFF",graphicsAlpha:1,interactionEnabled:!1,dragEnabled:!1,hoverEnabled:!1,clickEnabled:!1,logicId:"",logicPropsRaw:""}}createModal(){let e=document.createElement("div");e.className="wizard-modal",e.innerHTML=`
47
47
  <div class="wizard-card">
48
48
  <div class="wizard-header">
49
49
  <div class="wizard-title">
@@ -578,7 +578,7 @@ OK = Share, Cancel = Snapshot`);try{let c=await fetch("/api/objects/duplicate",{
578
578
  </div>
579
579
  <div class="panel-resize-handle-v" data-panel-resize-v></div>
580
580
  </div>
581
- `}initialize(e,t){var a,r,o,l,c,d,p,u;this.options=t,this.root=e.querySelector('[data-panel="scene-objects"]'),this.listContainer=(a=this.root)==null?void 0:a.querySelector("[data-object-list]"),this.searchInput=(r=this.root)==null?void 0:r.querySelector("#scene-object-search"),(o=this.searchInput)==null||o.addEventListener("input",()=>this.refreshObjects()),this.loadCollapsedGroups(),(l=this.listContainer)==null||l.addEventListener("click",g=>{var x;let h=g.target,f=h==null?void 0:h.closest("[data-collapse-key]");if(f){let L=f.dataset.collapseKey||"";if(!L)return;let P=(x=this.listContainer)==null?void 0:x.querySelector(`[data-collapse-content="${L}"]`),O=this.isCollapsed(L);P&&(P.style.display=O?"":"none"),f.textContent=O?"\u25BE":"\u25B8",this.setCollapsed(L,!O),g.preventDefault(),g.stopPropagation();return}let m=h==null?void 0:h.closest("[data-object-visibility-toggle][data-object-id]");if(m){let L=m.dataset.objectId;if(!L)return;g.preventDefault(),g.stopPropagation(),this.toggleObjectVisibility(L);return}let b=h==null?void 0:h.closest("[data-system-bundle-action][data-system-bundle-id]");if(!b)return;g.preventDefault(),g.stopPropagation();let y=b.dataset.systemBundleAction,v=b.dataset.systemBundleId;if(!(!y||!v)){if(y==="toggle-visibility"){this.toggleSystemBundleVisibility(v);return}y==="delete"&&this.deleteSystemBundle(v)}});let i=(c=this.root)==null?void 0:c.querySelector("[data-add-object]");i==null||i.addEventListener("click",g=>{g.stopPropagation();let h=i.getBoundingClientRect();this.openAddObjectMenu({x:h.left,y:h.bottom+4})});let n=(d=this.root)==null?void 0:d.querySelector("#scene-screen-filter");if(n){try{let g=window.localStorage.getItem(this.getScreenFilterStorageKey());g&&(this.screenFilter=g)}catch{}n.value=this.screenFilter;try{window.__HANDLER_ACTIVE_SCREEN=this.screenFilter,window.dispatchEvent(new CustomEvent("handler:active-screen-changed",{detail:{screen:this.screenFilter}}))}catch{}n.addEventListener("change",()=>{let g=n.value||"all";this.screenFilter=g;try{window.localStorage.setItem(this.getScreenFilterStorageKey(),this.screenFilter)}catch{}try{window.__HANDLER_ACTIVE_SCREEN=this.screenFilter,window.dispatchEvent(new CustomEvent("handler:active-screen-changed",{detail:{screen:this.screenFilter}}))}catch{}this.refreshObjects()})}(p=this.root)==null||p.addEventListener("click",g=>{let h=g.target;if(!h||h.closest("[data-context-menu]"))return;if(h.tagName==="INPUT"&&h.classList.contains("scene-object-checkbox")){let x=h.dataset.objectId;if(!x)return;g.stopPropagation(),this.toggleBatchSelect(x);return}let f=h.closest(".scene-object-item[data-object-id]");if(!f)return;let m=f.dataset.objectId;if(!m)return;let b=g.ctrlKey||g.metaKey;g.shiftKey&&this.lastSelectedIndex>=0?this.selectRange(this.lastSelectedIndex,m):b?this.toggleBatchSelect(m):this.select(m)}),(u=this.listContainer)==null||u.addEventListener("contextmenu",g=>{var x;let h=g.target,f=h==null?void 0:h.closest("[data-object-id]");if(!f)return;let m=f.dataset.objectId;if(!m)return;g.preventDefault();let b=window.getEditableObjectConfig,y=typeof b=="function"?b(m):null;if(!y){let L=window.__editableObjectConfigs;L&&typeof L.get=="function"&&(y=(x=L.get(m))!=null?x:null)}let v=this.inferScreen(m,y);this.showContextMenu(m,v,g.clientX,g.clientY)}),window.addEventListener("handler:screen-index-loaded",()=>this.refreshObjects()),window.addEventListener("handler:scene-objects-refresh",()=>this.refreshObjects())}setSelected(e){e?(this.selectedIds.clear(),this.selectedIds.add(e),this.selectedId=e):(this.selectedIds.clear(),this.selectedId=null),this.updateSelectionUI()}getSelectedIds(){return Array.from(this.selectedIds)}updateSelectionUI(){var a,r,o,l,c;if(!this.listContainer)return;Array.from(this.listContainer.querySelectorAll("[data-object-id]")).forEach(d=>{let p=d.dataset.objectId,u=p?this.selectedIds.has(p):!1,g=p===this.selectedId;d.classList.toggle("selected",u),d.classList.toggle("active",g);let h=d.closest(".scene-object-item-wrapper"),f=h==null?void 0:h.querySelector(".scene-object-checkbox");f&&(f.checked=u)});let t=(a=this.root)==null?void 0:a.querySelector("[data-breadcrumbs]"),i=(r=this.root)==null?void 0:r.querySelector("[data-breadcrumb-screen]"),n=(o=this.root)==null?void 0:o.querySelector("[data-breadcrumb-object]");if(t&&i&&n){let d=this.selectedIds.size===1?this.selectedId:null;if(d){let p=window.getEditableObjectConfig,u=typeof p=="function"?p(d):null;if(!u){let b=window.__editableObjectConfigs;b&&typeof b.get=="function"&&(u=(l=b.get(d))!=null?l:null)}let g=this.inferScreen(d,u),h={loading:"Loading",start:"Start",gameplay:"Gameplay",tutorial:"Tutorial",endgame:"Endgame"},f=(((c=u==null?void 0:u.identity)==null?void 0:c.id)||d).toString(),m=this.formatDisplayName(f);i.textContent=h[g]||g,n.textContent=m,t.style.display="flex"}else t.style.display="none"}}refreshObjects(){var u;if(!this.listContainer)return;let e=window.getEditableObjectList,t=window.getEditableObjectListAll,i=window.refreshEditableConfigIndex;if(typeof i=="function"&&i(),typeof e!="function"&&typeof t!="function"){this.scheduleRetry();return}let n=typeof t=="function"?t():e();if(!Array.isArray(n)||n.length===0){let g=window.__editableObjectConfigs;g&&typeof g.keys=="function"&&(n=Array.from(g.keys()))}if(!Array.isArray(n)||n.length===0){this.scheduleRetry();return}let a=(((u=this.searchInput)==null?void 0:u.value)||"").trim().toLowerCase(),r=["loading","start","gameplay","tutorial","endgame"],o={loading:{templates:[],systems:[],objects:[],bundles:new Map},start:{templates:[],systems:[],objects:[],bundles:new Map},gameplay:{templates:[],systems:[],objects:[],bundles:new Map},tutorial:{templates:[],systems:[],objects:[],bundles:new Map},endgame:{templates:[],systems:[],objects:[],bundles:new Map}};this.systemBundles=new Map;let l=g=>{var m,b,y,v,x;let h=(v=(y=(b=(m=window.__editableConfig)==null?void 0:m.objects)==null?void 0:b.get)==null?void 0:y.call(b,g))!=null?v:null;if(h)return h;let f=window.__editableObjectConfigs;return f&&typeof f.get=="function"&&(x=f.get(g))!=null?x:null};n.forEach(g=>{var T,E,S,_,I,R,z;let h=l(g),f=(((T=h==null?void 0:h.identity)==null?void 0:T.category)||"scene").toString(),m=(((E=h==null?void 0:h.identity)==null?void 0:E.id)||g).toString(),b=f.toLowerCase(),y=m.toLowerCase(),v=b.includes("ui")||y.startsWith("ui")||y.includes("label"),x=b==="system",L=((S=h==null?void 0:h.identity)==null?void 0:S.is_template)===!0||y.includes(".template")||g.toLowerCase().includes(".template"),P=typeof((_=h==null?void 0:h.identity)==null?void 0:_.system_group)=="string"?h.identity.system_group:null,O=typeof((I=h==null?void 0:h.identity)==null?void 0:I.system_label)=="string"?h.identity.system_label:P?this.formatDisplayName(P):null,w=this.formatDisplayName(m||g),k=((R=h==null?void 0:h.render)==null?void 0:R.visible)===!1||(h==null?void 0:h.enabled)===!1,j=this.getObjectType(h),C={id:g,label:w,category:f,isUi:v,isTemplate:L,isUnused:k,objectType:j,systemGroupId:P,systemLabel:O},A=this.inferScreen(C.id,h);if(!(this.screenFilter!=="all"&&A!==this.screenFilter||!(!a||C.id.toLowerCase().includes(a)||C.label.toLowerCase().includes(a)))){if(P){let N=this.getSystemBundleKey(A,P),X=O!=null?O:P,F=o[A],q=F.bundles.get(N);q?(q.entries.push(C),q.objectIds.push(g)):F.bundles.set(N,{key:N,label:X,objectIds:[g],entries:[C]});let Q=(z=this.systemBundles.get(N))!=null?z:{label:X,objectIds:[]};Q.label=X,Q.objectIds.push(g),this.systemBundles.set(N,Q);return}if(L){o[A].templates.push(C);return}x?o[A].systems.push(C):o[A].objects.push(C)}});let c={loading:"Loading Screen",start:"Start Screen",gameplay:"Gameplay",tutorial:"Tutorial",endgame:"Endgame"},d=this.screenFilter==="all"?r:[this.screenFilter],p=d.map(g=>this.renderScreenGroup(g,c[g],o[g])).join("");this.listContainer.innerHTML=p,this.objectEntries=[];for(let g of d){let h=o[g];this.objectEntries.push(...h.templates),h.bundles.forEach(f=>this.objectEntries.push(...f.entries)),this.objectEntries.push(...h.systems),this.objectEntries.push(...h.objects)}for(let g of d){let h=o[g];if(!h.systems.length)continue;let f=this.listContainer.querySelector(`[data-delete-system-group="${g}"]`);f==null||f.addEventListener("click",m=>{m.stopPropagation(),this.deleteSystemGroup(h.systems)})}this.updateSelectionUI()}renderSystemBundle(e,t,i,n){let a=this.isBundleAllHidden(i),r=a?"Show all objects in this system":"Hide all objects in this system",o=a?"is-hidden":"",l=n.map(g=>this.renderEntryItem(g)).join(""),c=this.escapeHtml(e),d=this.getCollapseKey(`system:${e}`),p=this.isCollapsed(d);return`
581
+ `}initialize(e,t){var a,r,o,l,c,d,p,u;this.options=t,this.root=e.querySelector('[data-panel="scene-objects"]'),this.listContainer=(a=this.root)==null?void 0:a.querySelector("[data-object-list]"),this.searchInput=(r=this.root)==null?void 0:r.querySelector("#scene-object-search"),(o=this.searchInput)==null||o.addEventListener("input",()=>this.refreshObjects()),this.loadCollapsedGroups(),(l=this.listContainer)==null||l.addEventListener("click",g=>{var x;let h=g.target,f=h==null?void 0:h.closest("[data-collapse-key]");if(f){let L=f.dataset.collapseKey||"";if(!L)return;let P=(x=this.listContainer)==null?void 0:x.querySelector(`[data-collapse-content="${L}"]`),O=this.isCollapsed(L);P&&(P.style.display=O?"":"none"),f.textContent=O?"\u25BE":"\u25B8",this.setCollapsed(L,!O),g.preventDefault(),g.stopPropagation();return}let m=h==null?void 0:h.closest("[data-object-visibility-toggle][data-object-id]");if(m){let L=m.dataset.objectId;if(!L)return;g.preventDefault(),g.stopPropagation(),this.toggleObjectVisibility(L);return}let b=h==null?void 0:h.closest("[data-system-bundle-action][data-system-bundle-id]");if(!b)return;g.preventDefault(),g.stopPropagation();let y=b.dataset.systemBundleAction,v=b.dataset.systemBundleId;if(!(!y||!v)){if(y==="toggle-visibility"){this.toggleSystemBundleVisibility(v);return}y==="delete"&&this.deleteSystemBundle(v)}});let i=(c=this.root)==null?void 0:c.querySelector("[data-add-object]");i==null||i.addEventListener("click",g=>{g.stopPropagation();let h=i.getBoundingClientRect();this.openAddObjectMenu({x:h.left,y:h.bottom+4})});let n=(d=this.root)==null?void 0:d.querySelector("#scene-screen-filter");if(n){try{let g=window.localStorage.getItem(this.getScreenFilterStorageKey());g&&(this.screenFilter=g)}catch{}n.value=this.screenFilter;try{window.__HANDLER_ACTIVE_SCREEN=this.screenFilter,window.dispatchEvent(new CustomEvent("handler:active-screen-changed",{detail:{screen:this.screenFilter}}))}catch{}try{let g=window.__HANDLER_REFRESH_SCREEN_INDEX;typeof g=="function"&&g().catch(()=>{})}catch{}n.addEventListener("change",()=>{let g=n.value||"all";this.screenFilter=g;try{window.localStorage.setItem(this.getScreenFilterStorageKey(),this.screenFilter)}catch{}try{window.__HANDLER_ACTIVE_SCREEN=this.screenFilter,window.dispatchEvent(new CustomEvent("handler:active-screen-changed",{detail:{screen:this.screenFilter}}))}catch{}try{let h=window.__HANDLER_REFRESH_SCREEN_INDEX;typeof h=="function"&&h().catch(()=>{})}catch{}this.refreshObjects()})}(p=this.root)==null||p.addEventListener("click",g=>{let h=g.target;if(!h||h.closest("[data-context-menu]"))return;if(h.tagName==="INPUT"&&h.classList.contains("scene-object-checkbox")){let x=h.dataset.objectId;if(!x)return;g.stopPropagation(),this.toggleBatchSelect(x);return}let f=h.closest(".scene-object-item[data-object-id]");if(!f)return;let m=f.dataset.objectId;if(!m)return;let b=g.ctrlKey||g.metaKey;g.shiftKey&&this.lastSelectedIndex>=0?this.selectRange(this.lastSelectedIndex,m):b?this.toggleBatchSelect(m):this.select(m)}),(u=this.listContainer)==null||u.addEventListener("contextmenu",g=>{var x;let h=g.target,f=h==null?void 0:h.closest("[data-object-id]");if(!f)return;let m=f.dataset.objectId;if(!m)return;g.preventDefault();let b=window.getEditableObjectConfig,y=typeof b=="function"?b(m):null;if(!y){let L=window.__editableObjectConfigs;L&&typeof L.get=="function"&&(y=(x=L.get(m))!=null?x:null)}let v=this.inferScreen(m,y);this.showContextMenu(m,v,g.clientX,g.clientY)}),window.addEventListener("handler:screen-index-loaded",()=>this.refreshObjects()),window.addEventListener("handler:scene-objects-refresh",()=>this.refreshObjects())}setSelected(e){e?(this.selectedIds.clear(),this.selectedIds.add(e),this.selectedId=e):(this.selectedIds.clear(),this.selectedId=null),this.updateSelectionUI()}getSelectedIds(){return Array.from(this.selectedIds)}updateSelectionUI(){var a,r,o,l,c;if(!this.listContainer)return;Array.from(this.listContainer.querySelectorAll("[data-object-id]")).forEach(d=>{let p=d.dataset.objectId,u=p?this.selectedIds.has(p):!1,g=p===this.selectedId;d.classList.toggle("selected",u),d.classList.toggle("active",g);let h=d.closest(".scene-object-item-wrapper"),f=h==null?void 0:h.querySelector(".scene-object-checkbox");f&&(f.checked=u)});let t=(a=this.root)==null?void 0:a.querySelector("[data-breadcrumbs]"),i=(r=this.root)==null?void 0:r.querySelector("[data-breadcrumb-screen]"),n=(o=this.root)==null?void 0:o.querySelector("[data-breadcrumb-object]");if(t&&i&&n){let d=this.selectedIds.size===1?this.selectedId:null;if(d){let p=window.getEditableObjectConfig,u=typeof p=="function"?p(d):null;if(!u){let b=window.__editableObjectConfigs;b&&typeof b.get=="function"&&(u=(l=b.get(d))!=null?l:null)}let g=this.inferScreen(d,u),h={loading:"Loading",start:"Start",gameplay:"Gameplay",tutorial:"Tutorial",endgame:"Endgame"},f=(((c=u==null?void 0:u.identity)==null?void 0:c.id)||d).toString(),m=this.formatDisplayName(f);i.textContent=h[g]||g,n.textContent=m,t.style.display="flex"}else t.style.display="none"}}refreshObjects(){var u;if(!this.listContainer)return;let e=window.getEditableObjectList,t=window.getEditableObjectListAll,i=window.refreshEditableConfigIndex;if(typeof i=="function"&&i(),typeof e!="function"&&typeof t!="function"){this.scheduleRetry();return}let n=typeof t=="function"?t():e();if(!Array.isArray(n)||n.length===0){let g=window.__editableObjectConfigs;g&&typeof g.keys=="function"&&(n=Array.from(g.keys()))}if(!Array.isArray(n)||n.length===0){this.scheduleRetry();return}let a=(((u=this.searchInput)==null?void 0:u.value)||"").trim().toLowerCase(),r=["loading","start","gameplay","tutorial","endgame"],o={loading:{templates:[],systems:[],objects:[],bundles:new Map},start:{templates:[],systems:[],objects:[],bundles:new Map},gameplay:{templates:[],systems:[],objects:[],bundles:new Map},tutorial:{templates:[],systems:[],objects:[],bundles:new Map},endgame:{templates:[],systems:[],objects:[],bundles:new Map}};this.systemBundles=new Map;let l=g=>{var m,b,y,v,x;let h=(v=(y=(b=(m=window.__editableConfig)==null?void 0:m.objects)==null?void 0:b.get)==null?void 0:y.call(b,g))!=null?v:null;if(h)return h;let f=window.__editableObjectConfigs;return f&&typeof f.get=="function"&&(x=f.get(g))!=null?x:null};n.forEach(g=>{var T,E,S,_,I,R,z;let h=l(g),f=(((T=h==null?void 0:h.identity)==null?void 0:T.category)||"scene").toString(),m=(((E=h==null?void 0:h.identity)==null?void 0:E.id)||g).toString(),b=f.toLowerCase(),y=m.toLowerCase(),v=b.includes("ui")||y.startsWith("ui")||y.includes("label"),x=b==="system",L=((S=h==null?void 0:h.identity)==null?void 0:S.is_template)===!0||y.includes(".template")||g.toLowerCase().includes(".template"),P=typeof((_=h==null?void 0:h.identity)==null?void 0:_.system_group)=="string"?h.identity.system_group:null,O=typeof((I=h==null?void 0:h.identity)==null?void 0:I.system_label)=="string"?h.identity.system_label:P?this.formatDisplayName(P):null,w=this.formatDisplayName(m||g),k=((R=h==null?void 0:h.render)==null?void 0:R.visible)===!1||(h==null?void 0:h.enabled)===!1,j=this.getObjectType(h),C={id:g,label:w,category:f,isUi:v,isTemplate:L,isUnused:k,objectType:j,systemGroupId:P,systemLabel:O},A=this.inferScreen(C.id,h);if(!(this.screenFilter!=="all"&&A!==this.screenFilter||!(!a||C.id.toLowerCase().includes(a)||C.label.toLowerCase().includes(a)))){if(P){let N=this.getSystemBundleKey(A,P),X=O!=null?O:P,F=o[A],q=F.bundles.get(N);q?(q.entries.push(C),q.objectIds.push(g)):F.bundles.set(N,{key:N,label:X,objectIds:[g],entries:[C]});let Q=(z=this.systemBundles.get(N))!=null?z:{label:X,objectIds:[]};Q.label=X,Q.objectIds.push(g),this.systemBundles.set(N,Q);return}if(L){o[A].templates.push(C);return}x?o[A].systems.push(C):o[A].objects.push(C)}});let c={loading:"Loading Screen",start:"Start Screen",gameplay:"Gameplay",tutorial:"Tutorial",endgame:"Endgame"},d=this.screenFilter==="all"?r:[this.screenFilter],p=d.map(g=>this.renderScreenGroup(g,c[g],o[g])).join("");this.listContainer.innerHTML=p,this.objectEntries=[];for(let g of d){let h=o[g];this.objectEntries.push(...h.templates),h.bundles.forEach(f=>this.objectEntries.push(...f.entries)),this.objectEntries.push(...h.systems),this.objectEntries.push(...h.objects)}for(let g of d){let h=o[g];if(!h.systems.length)continue;let f=this.listContainer.querySelector(`[data-delete-system-group="${g}"]`);f==null||f.addEventListener("click",m=>{m.stopPropagation(),this.deleteSystemGroup(h.systems)})}this.updateSelectionUI()}renderSystemBundle(e,t,i,n){let a=this.isBundleAllHidden(i),r=a?"Show all objects in this system":"Hide all objects in this system",o=a?"is-hidden":"",l=n.map(g=>this.renderEntryItem(g)).join(""),c=this.escapeHtml(e),d=this.getCollapseKey(`system:${e}`),p=this.isCollapsed(d);return`
582
582
  <div class="scene-object-group scene-object-group-bundle" data-system-bundle="${c}">
583
583
  <div class="scene-object-group-title">
584
584
  <button class="scene-object-group-toggle" type="button" data-collapse-key="${d}">${p?"\u25B8":"\u25BE"}</button>
@@ -2484,7 +2484,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=n,this.currentPrompt=n}}c
2484
2484
  </div>
2485
2485
 
2486
2486
  </div>
2487
- `,this.setupEventListeners(e),e}setupEventListeners(e){var P,O,w,k,j,C,A,M;let t=e.querySelector("#device-select");t==null||t.addEventListener("change",T=>{if(this.viewMode==="compare")return;let E=T.target.value;this.setDevice(E)});let i=e.querySelector("#theme-select");i==null||i.addEventListener("change",T=>{let E=T.target.value;this.setTheme(E)}),Array.from(e.querySelectorAll("[data-view-toggle]")).forEach(T=>{T.addEventListener("click",()=>{let E=T.dataset.viewToggle;E&&this.setViewMode(E)})}),Array.from(e.querySelectorAll("[data-layout-toggle]")).forEach(T=>{T.addEventListener("click",()=>{let E=T.dataset.layoutToggle;E&&this.setLayoutMode(E)})});let r=e.querySelector("#scene-toggle");r==null||r.addEventListener("click",()=>{this.viewMode!=="compare"&&(this.setSceneVisible(!this.sceneVisiblePreference),this.updateSceneVisibility())});let o=e.querySelector("#scene-hide-btn");o==null||o.addEventListener("click",()=>{this.viewMode!=="compare"&&(this.setSceneVisible(!1),this.updateSceneVisibility())});let l=T=>{let E=typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default";return`handler_preview_scene_${T}::${E}`},c=e.querySelector("#scene-grid-btn"),d=e.querySelector("#scene-play-btn"),p=(T,E,S)=>{T&&(T.textContent=E?`${S} On`:`${S} Off`,T.setAttribute("aria-pressed",E?"true":"false"))},u=()=>{let T=window.localStorage.getItem(l("grid_gap")),E=Number(T!=null?T:50);return Number.isFinite(E)?E:50},g=T=>{try{window.localStorage.setItem(l("grid_enabled"),T?"true":"false")}catch{}p(c,T,"Grid");let E=u();window.dispatchEvent(new CustomEvent("scene-editor:grid",{detail:{enabled:T,gap:E}}))},h=T=>{try{window.localStorage.setItem(l("play_mode"),T?"true":"false")}catch{}p(d,T,"Play"),window.dispatchEvent(new CustomEvent("scene-editor:play-mode",{detail:{enabled:T}}))};try{let T=window.localStorage.getItem(l("grid_enabled"))==="true",E=window.localStorage.getItem(l("play_mode"))==="true";if(p(c,T,"Grid"),p(d,E,"Play"),c){let S=u();window.dispatchEvent(new CustomEvent("scene-editor:grid",{detail:{enabled:T,gap:S}}))}d&&window.dispatchEvent(new CustomEvent("scene-editor:play-mode",{detail:{enabled:E}}))}catch{}c==null||c.addEventListener("click",()=>{let T=c.getAttribute("aria-pressed")==="true";g(!T)}),d==null||d.addEventListener("click",()=>{let T=d.getAttribute("aria-pressed")==="true";h(!T)}),(P=e.querySelector("#rotate-btn"))==null||P.addEventListener("click",()=>this.toggleRotation()),(O=e.querySelector("#zoom-in-btn"))==null||O.addEventListener("click",()=>this.adjustUserZoom(.1)),(w=e.querySelector("#zoom-out-btn"))==null||w.addEventListener("click",()=>this.adjustUserZoom(-.1)),(k=e.querySelector("#refresh-btn"))==null||k.addEventListener("click",()=>this.refresh());let f=e.querySelector("#bottom-dock"),m=e.querySelector("#bottom-dock-resize");f&&m&&this.makeBottomDockResizable(f,m);let b=Array.from(e.querySelectorAll(".bottom-dock-tab"));b.forEach(T=>{T.addEventListener("click",()=>{let E=T.dataset.dockTab;if(!E)return;b.forEach(_=>_.classList.remove("active")),T.classList.add("active"),Array.from(e.querySelectorAll(".bottom-dock-panel")).forEach(_=>{let I=_.dataset.dockPanel;_.classList.toggle("active",I===E)})})}),(j=e.querySelector("#console-clear"))==null||j.addEventListener("click",()=>this.clearConsole()),(C=e.querySelector("#corner-zoom-in-btn"))==null||C.addEventListener("click",()=>this.adjustUserZoom(.1)),(A=e.querySelector("#corner-zoom-out-btn"))==null||A.addEventListener("click",()=>this.adjustUserZoom(-.1)),(M=e.querySelector("#corner-grab-btn"))==null||M.addEventListener("click",()=>{this.frameDragger.style.cursor="grab",setTimeout(()=>{this.isSpaceKeyPressed||(this.frameDragger.style.cursor="")},1e3)});let y=e.querySelector(".scene-panel.scene-objects"),v=y==null?void 0:y.querySelector("[data-panel-resize-v]");y&&v&&this.makeSidebarResizable(y,v,"left");let x=e.querySelector(".debug-workbench"),L=x==null?void 0:x.querySelector("#workbench-resize-v");x&&L&&this.makeSidebarResizable(x,L,"right")}applyDeviceFrameStyles(){Object.assign(this.frameDragger.style,{display:"flex",justifyContent:"center",alignItems:"center",transform:"translate(0px, 0px)",touchAction:"none"}),Object.assign(this.frameWrapper.style,{display:"flex",justifyContent:"center",alignItems:"center",transformOrigin:"center center",transition:"transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)",boxShadow:"var(--ui-shadow-strong)",borderRadius:"0px",willChange:"transform"}),Object.assign(this.deviceFrame.style,{overflow:"hidden",position:"relative",borderRadius:"0px"}),Object.assign(this.gameContainer.style,{position:"relative",overflow:"hidden",minWidth:"0px",minHeight:"0px"})}setupObserversAndListeners(){this.resizeObserver=new ResizeObserver(()=>{this.resizeListenersDisabled||this.scheduleFit()}),this.resizeObserver.observe(this.previewContainer),window.addEventListener("resize",this.onWindowResize,{passive:!0})}scheduleFit(){this.rafFitHandle&&cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=requestAnimationFrame(()=>{this.rafFitHandle=null,this.fitToScreen()})}applyPresetDimensions(){let e=this.getEffectivePreset(),t=`${e.width}px`,i=`${e.height}px`;this.deviceFrame.style.width=t,this.deviceFrame.style.height=i,this.gameContainer.style.width=t,this.gameContainer.style.height=i,this.gameContainer.style.maxWidth=t,this.gameContainer.style.maxHeight=i,this.gameContainer.style.minWidth=t,this.gameContainer.style.minHeight=i,this.gameContainer.dataset.screenWidth=String(e.width),this.gameContainer.dataset.screenHeight=String(e.height),this.container.style.setProperty("--preview-screen-width",String(e.width)),this.container.style.setProperty("--preview-screen-height",String(e.height))}fitToScreen(e){if(!this.previewContainer)return;let t=this.getEffectivePreset(),i=this.getFitBounds(),n=Math.max(0,i.width),a=Math.max(0,i.height);if(n<=0||a<=0)return;this.applyPresetDimensions(),this.viewMode==="compare"&&this.applyCompareDimensions();let r=n/t.width,o=a/t.height;if(this.autoScale=Math.max(.01,Math.min(r,o)),!this.hasInitialFit){this.hasInitialFit=!0;let l=.6;this.userScaleMultiplier=l/this.autoScale}(e==null?void 0:e.keepUserScaleMultiplier)!==void 0&&e.keepUserScaleMultiplier>0?this.userScaleMultiplier=e.keepUserScaleMultiplier:e!=null&&e.keepVisibleScale&&e.keepVisibleScale>0&&(this.userScaleMultiplier=e.keepVisibleScale/this.autoScale),this.applyTransform(),this.viewMode==="compare"&&this.fitCompareGhosts(),requestAnimationFrame(()=>this.updatePanelPositions()),this.emitScreenChange()}applyTransform(){let e=this.autoScale*this.userScaleMultiplier;this.frameWrapper.style.transform=`scale(${e})`;let t=this.container.querySelector("#zoom-label");t&&(t.textContent=`${Math.round(e*100)}%`),requestAnimationFrame(()=>this.updatePanelPositions())}applyFrameDrag(){this.frameDragger.style.transform=`translate(${this.frameDragOffsetX}px, ${this.frameDragOffsetY}px)`,requestAnimationFrame(()=>this.updatePanelPositions())}updatePanelPositions(){if(!this.gameReady||this.viewMode==="compare")return;let e=this.container.querySelector('[data-panel="scene-tools-corner"]'),t=this.container.querySelector('[data-panel="nudge-panel"]');if(this.layoutMode==="fixed"){let i=this.gameViewPane||this.container.querySelector(".preview-container");i&&(e&&e.parentElement!==i&&i.appendChild(e),t&&t.parentElement!==i&&i.appendChild(t))}else{let i=this.container.querySelector(".preview-main");i&&(e&&e.parentElement!==i&&i.appendChild(e),t&&t.parentElement!==i&&i.appendChild(t))}e&&(e.style.zIndex="100"),t&&(t.style.position="absolute",t.style.left="50%",t.style.top="16px",t.style.transform="translateX(calc(-50% + 200px))",t.style.zIndex="100")}setupFrameDragging(){this.frameDragger.addEventListener("pointerdown",e=>{let t=!this.gameContainer.contains(e.target);!this.isSpaceKeyPressed&&!t||e.button===0&&(e.preventDefault(),this.frameDragActive=!0,this.frameDragStartX=e.clientX,this.frameDragStartY=e.clientY,this.frameDragOriginX=this.frameDragOffsetX,this.frameDragOriginY=this.frameDragOffsetY,window.addEventListener("pointermove",this.onFrameDragMove),window.addEventListener("pointerup",this.onFrameDragEnd))})}setupSpaceKeyListener(){window.addEventListener("keydown",e=>{e.code==="Space"&&!this.isInputFocused()&&(this.isSpaceKeyPressed||(this.isSpaceKeyPressed=!0,this.updateDragCursor(),e.preventDefault()))}),window.addEventListener("keyup",e=>{e.code==="Space"&&(this.isSpaceKeyPressed=!1,this.updateDragCursor(),this.frameDragActive&&this.onFrameDragEnd())}),window.addEventListener("blur",()=>{this.isSpaceKeyPressed=!1,this.updateDragCursor(),this.frameDragActive&&this.onFrameDragEnd()})}isInputFocused(){let e=document.activeElement;if(!e)return!1;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"||e.isContentEditable}setupShortcutListeners(){window.addEventListener("keydown",e=>{if(this.isInputFocused())return;let t=navigator.platform.toUpperCase().indexOf("MAC")>=0,i=e.ctrlKey||e.metaKey,n=e.shiftKey;if(i&&e.key==="s"&&!n){e.preventDefault();let a=document.querySelector("#apply-current-btn");a&&a.getAttribute("disabled")===null&&a.click();return}if(i&&e.key==="z"&&!n){e.preventDefault(),gi();return}if(i&&(e.key==="z"&&n||e.key==="y"&&!n)){e.preventDefault(),hi();return}})}setupUnsavedChangesIndicator(){let e=this.container.querySelector("#preview-save-shortcut-text");e&&(e.textContent=`(${this.getShortcutKey()} + S)`),window.addEventListener("config:changed",()=>{this.updateUnsavedChangesIndicator()}),this.updateUnsavedChangesIndicator();let t=this.container.querySelector("#preview-save-btn");t==null||t.addEventListener("click",()=>{let i=document.querySelector("#apply-current-btn");i&&i.getAttribute("disabled")===null&&i.click()})}updateUnsavedChangesIndicator(){let t=Pe().hasChanges;if(t!==this.hasUnsavedChanges){this.hasUnsavedChanges=t;let i=this.container.querySelector("#preview-unsaved-star"),n=this.container.querySelector("#preview-save-btn");i&&(i.style.display=t?"inline-block":"none"),n&&(n.style.display=t?"inline-flex":"none")}}updateDragCursor(){this.isSpaceKeyPressed?(this.frameDragger.style.cursor="grab",this.frameDragActive&&(this.frameDragger.style.cursor="grabbing")):this.frameDragger.style.cursor=""}adjustUserZoom(e){this.userScaleMultiplier=Math.max(.1,Math.min(6,this.userScaleMultiplier+e)),this.applyTransform(),this.emitScreenChange()}toggleRotation(){var t,i;if(this.viewMode==="compare")return;let e=this.userScaleMultiplier;this.isLandscape=!this.isLandscape,this.applyPresetDimensions(),this.fitToScreen({keepUserScaleMultiplier:e}),(i=(t=this.options).onDeviceChange)==null||i.call(t,this.getEffectivePreset()),this.emitScreenChange()}emitScreenChange(){if(!this.gameReady)return;let e=this.getEffectivePreset(),t={width:e.width,height:e.height,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:e.id,isLandscape:this.isLandscape};if(window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:t})),this.viewMode==="compare"&&this.refreshCompareSnapshots(),this.isInitialized&&this.isMounted&&this.gameReady){let i=window.gameApp;if(!(i!=null&&i.renderer))return;this.ignoreNextWindowResize=!0,window.dispatchEvent(new Event("resize"))}}safeStringify(e){var i;let t=new WeakSet;try{return JSON.stringify(e,(n,a)=>{if(typeof a=="object"&&a!==null){if(t.has(a))return"[Circular]";t.add(a)}return a},2)}catch{try{if(e&&((i=e.constructor)!=null&&i.name))return`[object ${e.constructor.name}]`}catch{}return String(e)}}setupConsoleInterceptor(){let e=(t,...i)=>{let n=i.map(r=>typeof r=="object"?this.safeStringify(r):String(r)).join(" ");this.consoleMessages.push({type:t,message:n,timestamp:new Date}),this.appendConsoleMessage(this.consoleMessages[this.consoleMessages.length-1]);let a=this.container.querySelector("#console-badge");if(a){let r=this.consoleMessages.filter(o=>o.type==="error").length;a.textContent=r>0?`${r}!`:"0",a.classList.toggle("has-errors",r>0)}};console.log=(...t)=>{this.originalConsole.log(...t),e("log",...t)},console.warn=(...t)=>{this.originalConsole.warn(...t),e("warn",...t)},console.error=(...t)=>{this.originalConsole.error(...t),e("error",...t)},console.info=(...t)=>{this.originalConsole.info(...t),e("info",...t)}}appendConsoleMessage(e){let t=this.container.querySelector("#console-messages");if(!t)return;let i=document.createElement("div");i.className=`console-msg type-${e.type}`;let n=e.timestamp.toLocaleTimeString();i.innerHTML=`<span class="time">${this.escapeHtml(n)}</span> <pre>${this.escapeHtml(e.message)}</pre>`,t.appendChild(i),t.scrollTop=t.scrollHeight}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}toggleConsole(e){var t;if(this.layoutMode==="fixed"){let i=this.container.querySelector('[data-dock-tab="console"]');if(i){i.click();let n=this.container.querySelector("#bottom-dock");n==null||n.classList.remove("hidden")}return}this.isConsoleOpen=e!=null?e:!this.isConsoleOpen,(t=this.consolePanel)==null||t.classList.toggle("closed",!this.isConsoleOpen)}clearConsole(){this.consoleMessages=[];let e=this.container.querySelector("#console-messages");e&&(e.innerHTML="");let t=this.container.querySelector("#console-badge");t&&(t.textContent="0")}setupCompareViewports(){Array.from(this.container.querySelectorAll("[data-viewport]")).forEach(t=>{let i=t.dataset.viewport;if(!i)return;let n=this.comparePresets.find(p=>p.id===i);if(!n)return;let a=t.querySelector("[data-compare-slot]"),r=t.querySelector("[data-compare-ghost]"),o=t.querySelector("[data-compare-wrapper]"),l=t.querySelector("[data-compare-frame]"),c=t.querySelector("[data-compare-snapshot]"),d=t.querySelector("[data-compare-focus]");!a||!r||!o||!l||(t.addEventListener("click",p=>{let u=p.target;if(u!=null&&u.closest("[data-compare-focus]")){p.preventDefault(),this.activateCompareViewport(i);return}t.classList.contains("is-active")||this.activateCompareViewport(i)}),this.compareViewports.set(i,{preset:n,root:t,slot:a,ghost:r,wrapper:o,frame:l,canvas:c,focus:d}))})}setViewMode(e){if(this.viewMode===e)return;this.viewMode=e,this.container.classList.toggle("compare-mode",e==="compare"),this.singleStage.classList.toggle("hidden",e!=="single"),this.compareStage.classList.toggle("hidden",e!=="compare");let t=this.container.querySelector("#device-select");t&&(t.disabled=e==="compare");let i=this.container.querySelector("#rotate-btn");i&&(i.disabled=e==="compare");let n=this.container.querySelector("#scene-toggle");if(n&&(n.disabled=e==="compare"),this.updateViewToggleUI(),e==="compare"){this.lastSinglePresetId=this.currentPreset.id,this.activateCompareViewport(this.activeCompareId),this.refreshCompareSnapshots(),this.startCompareSnapshots(),this.updateSceneVisibility();return}this.stopCompareSnapshots(),this.singleStage.appendChild(this.frameDragger),this.setDevice(this.lastSinglePresetId,{suppressCallback:!0}),this.fitToScreen(),this.updateSceneVisibility()}updateViewToggleUI(){Array.from(this.container.querySelectorAll("[data-view-toggle]")).forEach(t=>{t.classList.toggle("active",t.dataset.viewToggle===this.viewMode)})}activateCompareViewport(e){var a,r;let t=this.compareViewports.get(e);if(!t)return;let i=this.autoScale*this.userScaleMultiplier,n=this.activeCompareId;n&&n!==e&&this.captureCompareSnapshot(n),this.activeCompareId=e,this.currentPreset=t.preset,this.isLandscape=!1,t.slot.appendChild(this.frameDragger),this.frameDragOffsetX=0,this.frameDragOffsetY=0,this.applyFrameDrag(),this.compareViewports.forEach((o,l)=>{o.root.classList.toggle("is-active",l===e),o.ghost.classList.toggle("hidden",l===e),o.focus&&(o.focus.textContent=l===e?"Live":"Focus")}),this.applyPresetDimensions(),this.applyCompareDimensions(),this.fitToScreen({keepVisibleScale:i}),(r=(a=this.options).onDeviceChange)==null||r.call(a,this.getEffectivePreset())}applyCompareDimensions(){this.compareViewports.forEach(e=>{let t=e.preset,i=`${t.width}px`,n=`${t.height}px`;e.frame.style.width=i,e.frame.style.height=n,e.canvas&&(e.canvas.width=t.width,e.canvas.height=t.height)})}fitCompareGhosts(){this.compareViewports.forEach(e=>{let t=e.root.querySelector(".compare-body");if(!t)return;let i=Math.max(0,t.clientWidth-24),n=Math.max(0,t.clientHeight-24);if(i<=0||n<=0)return;let a=i/e.preset.width,r=n/e.preset.height,o=Math.max(.01,Math.min(a,r));e.wrapper.style.transform=`scale(${o})`})}captureCompareSnapshot(e){let t=this.compareViewports.get(e);if(!(t!=null&&t.canvas))return;let i=this.gameContainer.querySelector("canvas");if(!i)return;let n=t.canvas.getContext("2d");if(!n)return;let a=t.canvas.width,r=t.canvas.height,o=Math.min(a/i.width,r/i.height),l=i.width*o,c=i.height*o,d=(a-l)/2,p=(r-c)/2;n.clearRect(0,0,a,r),n.drawImage(i,d,p,l,c)}refreshCompareSnapshots(){this.compareViewports.forEach((e,t)=>{t!==this.activeCompareId&&this.captureCompareSnapshot(t)})}startCompareSnapshots(){this.compareSnapshotTimer||(this.compareSnapshotTimer=window.setInterval(()=>{this.viewMode==="compare"&&this.refreshCompareSnapshots()},500))}stopCompareSnapshots(){this.compareSnapshotTimer&&(window.clearInterval(this.compareSnapshotTimer),this.compareSnapshotTimer=null)}getFitBounds(){if(this.viewMode!=="compare"){let i=this.gameViewPane||this.previewContainer;return{width:i.clientWidth-40,height:i.clientHeight-40}}let e=this.compareViewports.get(this.activeCompareId),t=e==null?void 0:e.root.querySelector(".compare-body");return t?{width:t.clientWidth-24,height:t.clientHeight-24}:{width:this.previewContainer.clientWidth-40,height:this.previewContainer.clientHeight-40}}mustQuery(e){let t=this.container.querySelector(e);if(!t)throw new Error(`PreviewShell missing element: ${e}`);return t}};function Oa(s={}){let e=new on(s);return typeof window!="undefined"&&(window.__previewShell=e),e.mount(),e}K();function Ra(s){try{if(s&&typeof s.keys=="function")return Array.from(s.keys())}catch{}return[]}function jr(s){var e;return s?((e=s.getDisplayObject)==null?void 0:e.call(s))||s.pixiObject||s:null}function wl(s,e){if(!s||!(e!=null&&e.interaction))return;let t=e.interaction,i=t.enabled!==!1&&(t.draggable===!0||t.clickable===!0);s.eventMode=i?"static":"none",s.interactive=i,i&&(s.cursor=t.draggable?"move":"pointer")}function _r(s,e){var l,c,d;if(!s||!e)return;let t=e.transform||{};wl(s,e);let i=t.position||{},n=t.offset||{},a=(typeof i.x=="number"?i.x:0)+(typeof n.x=="number"?n.x:0),r=(typeof i.y=="number"?i.y:0)+(typeof n.y=="number"?n.y:0);(l=s.position)!=null&&l.set?s.position.set(a,r):(typeof s.x=="number"&&(s.x=a),typeof s.y=="number"&&(s.y=r)),typeof t.scale=="number"&&((c=s.scale)!=null&&c.set?s.scale.set(t.scale):s.scale&&(s.scale.x=t.scale,s.scale.y=t.scale));let o=t.anchor;if(o&&((d=s.anchor)!=null&&d.set)){let p=null;typeof window!="undefined"&&window.resolveAnchorVec2?p=window.resolveAnchorVec2(o):typeof o=="object"&&o.x!==void 0&&o.y!==void 0?p=o:Array.isArray(o)&&o.length===2&&(p={x:o[0],y:o[1]}),p&&typeof p.x=="number"&&typeof p.y=="number"&&s.anchor.set(p.x,p.y)}}function Or(s){if(typeof window=="undefined")return;let e=s==null?void 0:s.objects,t=Ra(e),i=a=>{try{let r=window.__HANDLER_ACTIVE_SCREEN;if(!r||r==="all")return a;let o=window.__HANDLER_SCREEN_INDEX,l=o==null?void 0:o.instanceToScreen;return l?a.filter(c=>l[c]===r):a}catch{return a}};window.__editableObjectConfigs=e;let n=new Map;t.forEach(a=>n.set(a,[a])),window.__editableObjectInstances=n,window.refreshEditableConfigIndex=()=>Or(window.__editableConfig),window.getEditableObjectList=()=>{var a;return i(Ra((a=window.__editableConfig)==null?void 0:a.objects))},window.getEditableObjectListAll=()=>{var a;return Ra((a=window.__editableConfig)==null?void 0:a.objects)},window.getEditableObjectConfig=a=>{var d,p,u,g,h;let r=(g=(u=(p=(d=window.__editableConfig)==null?void 0:d.objects)==null?void 0:p.get)==null?void 0:u.call(p,a))!=null?g:null,o=window.__HANDLER_ACTIVE_SCREEN;if(!o||o==="all")return r;let l=window.__HANDLER_SCREEN_INDEX,c=(h=l==null?void 0:l.instanceToScreen)==null?void 0:h[a];return c&&c===o?r:null},window.getEditableEngineConfig=()=>{let a=window.__editableConfig;if(console.log("[BRIDGE] getEditableEngineConfig called, cfg present:",!!a),!a)return null;if(a.engine&&a.objects instanceof Map){console.log("[BRIDGE] Detected ObjectCentricConfig, flattening...");let r={...a.engine,objects:a.objects,scene:a.scene};return console.log("[BRIDGE] Returned assets:",Object.keys(r.assets||{})),r}return a}}function xl(){if(typeof window=="undefined")return;let s=t=>{let i=String(t||"").trim();return i?/^(data:|blob:|https?:)/.test(i)||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`:""},e=async(t,i)=>{var a,r,o;let n=s(i);if(n)try{let[{Assets:l},{AssetTextures:c}]=await Promise.all([import("pixi.js"),Promise.resolve().then(()=>(it(),Ps))]),d=Date.now(),p=/^(data:|blob:)/.test(n)?n:n+(n.includes("?")?`&t=${d}`:`?t=${d}`),u=await l.load(p);if(!u)return;c[t]=u;let g=window.CustomAssets;(a=g==null?void 0:g[t])!=null&&a.texture&&(g[t].texture=u);let h=window.gameObjectManager,f=(r=h==null?void 0:h.get)==null?void 0:r.call(h,t);if(f){let m=((o=f.getDisplayObject)==null?void 0:o.call(f))||f.pixiObject||f.pixi||f;if(m!=null&&m.texture)m.texture=u;else if(m!=null&&m.children){let b=m.children.find(y=>y==null?void 0:y.texture);b!=null&&b.texture&&(b.texture=u)}}}catch(l){console.warn("[LIVE-EDIT] Failed to reload Pixi texture for",t,l)}};window.applyLiveEditOverrides=t=>{try{let i=Z();Array.isArray(i)&&i.length&&(window.__editableConfig=t,ke(i,{silent:!0,persist:!1}))}catch{}},window.applyEngineOverrides=t=>{try{let i=Z();Array.isArray(i)&&i.length&&(window.__editableConfig=t,ke(i,{silent:!0,persist:!1}))}catch{}},window.applyEditableEngineConfig=t=>{let i=window.__editableConfig;if(!(i!=null&&i.engine))return;let n=[];if(t.runtime)for(let[a,r]of Object.entries(t.runtime))n.push({path:`runtime.${a}`,value:r});if(t.assets)for(let[a,r]of Object.entries(t.assets))n.push({path:`assets.${a}`,value:r}),typeof r=="string"&&e(a,r);if(t.splash)for(let[a,r]of Object.entries(t.splash))n.push({path:`splash.${a}`,value:r});if(t.loading)for(let[a,r]of Object.entries(t.loading))n.push({path:`loading.${a}`,value:r});if(t.start)for(let[a,r]of Object.entries(t.start))n.push({path:`start.${a}`,value:r});n.length&&ke(n,{silent:!0,persist:!0,emitEvent:!0})}}function ln(s){let{getConfig:e,gameObjectManager:t,onObjectConfigApplied:i}=s;t&&(t.onObjectRebuildRequired=async(a,r)=>{console.log(`[LIVE-EDIT] \u{1F3D7}\uFE0F Rebuilding object ${a} due to type change...`);let o=t.get(a),l=o==null?void 0:o.pixiObject,c=l==null?void 0:l.parent,d=c==null?void 0:c.children.indexOf(l);o?t.remove(a):l&&l.destroy();let p=window.gameApp,u=await ue.create(a,r,p);c&&(d!==void 0&&d!==-1?c.addChildAt(u,d):c.addChild(u));let g=t.create(a,u);return console.log(`[LIVE-EDIT] \u2705 Rebuild complete for ${a}`),g}),typeof window!="undefined"&&(xl(),window.applyEditableObjectConfig=(a,r)=>{var o,l,c;console.log("[LIVE-EDIT] \u{1F504} applyEditableObjectConfig called for:",a);try{let d=window.__editableConfig;(o=d==null?void 0:d.objects)!=null&&o.set&&(d.objects.set(a,r),console.log("[LIVE-EDIT] \u2705 Updated config in __editableConfig"));let p=(l=t==null?void 0:t.get)==null?void 0:l.call(t,a);if(console.log("[LIVE-EDIT] gameObject found?",!!p),p&&(console.log("[LIVE-EDIT] gameObject type:",(c=p.constructor)==null?void 0:c.name),console.log("[LIVE-EDIT] has updateConfig?",typeof p.updateConfig=="function"),console.log("[LIVE-EDIT] has onConfigUpdate?",typeof p.onConfigUpdate=="function")),p&&typeof p.updateConfig=="function")console.log("[LIVE-EDIT] \u2705 Calling updateConfig()"),p.updateConfig(r);else if(p&&typeof p.onConfigUpdate=="function")console.log("[LIVE-EDIT] \u2705 Calling onConfigUpdate()"),p.onConfigUpdate();else{console.log("[LIVE-EDIT] \u26A0\uFE0F No updateConfig or onConfigUpdate, applying transform directly");let u=jr(p);_r(u,r)}}catch(d){console.error("[LIVE-EDIT] \u274C Error in applyEditableObjectConfig:",d)}});let n={async applyObjectConfig(a,r){var d,p;console.log("[BRIDGE] \u{1F504} applyObjectConfig called for:",a);let o=e();(d=o==null?void 0:o.objects)!=null&&d.set&&(o.objects.set(a,r),console.log("[BRIDGE] \u2705 Updated config"));let l=(p=t==null?void 0:t.get)==null?void 0:p.call(t,a);if(console.log("[BRIDGE] gameObject found?",!!l),l&&(console.log("[BRIDGE] has updateConfig?",typeof l.updateConfig=="function"),console.log("[BRIDGE] has onConfigUpdate?",typeof l.onConfigUpdate=="function")),l&&typeof l.updateConfig=="function")console.log("[BRIDGE] \u2705 Calling updateConfig()"),l.updateConfig(r);else if(l&&typeof l.onConfigUpdate=="function")console.log("[BRIDGE] \u2705 Calling onConfigUpdate()"),l.onConfigUpdate();else{console.log("[BRIDGE] \u26A0\uFE0F Applying transform directly");let u=jr(l);_r(u,r)}let c=[a];i==null||i(a,r,c)},rebuildIndexes(){let a=e();typeof window!="undefined"&&(window.__editableConfig=a,Or(a))}};return n.rebuildIndexes(),n}K();var $r=Ze(require("lottie-web"),1);Tn(An);typeof window!="undefined"&&!window.lottie&&(window.lottie=$r.default);var pt=null,Sl=async()=>{if(!pt){let s=typeof window!="undefined"?window.INLINE_ASSETS:null,e=(s==null?void 0:s["handler.config"])||(s==null?void 0:s["handler.config.json"]);if(e)try{if(e.startsWith("data:")){let i=atob(e.split(",")[1]);pt=JSON.parse(i)}else pt=JSON.parse(e);return pt}catch(i){console.warn("[CONFIG] Failed to parse inline handler.config.json:",i)}pt=await(await fetch("./handler.config.json")).json()}return pt},Da,Ut,Dr,ut,za,$a;function El(s){Da=s.initGame,Ut=s.CustomAssets,Dr=s.updateScreenState,ut=s.globalResponsiveMultipliers,za=s.layout,$a=s.clearResponsiveElements}var cn="web_embed",Gt="https://example.com",Rr={profile_id:cn},Re=null,fe=null,Bt={width:0,height:0},Cl=!0,Al=async()=>{var c,d,p,u;document.title="Handler Pixi Game";let s=await Sl();Rr={...s.ids||{},profile_id:cn},Gt=s.destination_url||((d=(c=s.export_profiles)==null?void 0:c[cn])==null?void 0:d.destination_url)||Gt,De.init({ids:Rr,profile:cn,destinationUrl:Gt});let e=De.getRoot();if(typeof __PREVIEW_SHELL__!="undefined"&&__PREVIEW_SHELL__){console.log("[BOOTSTRAP] Initializing Preview Shell..."),fe=Oa({onDeviceChange:h=>{console.log(`[PREVIEW] Device switched to ${h.width}x${h.height}, restarting game...`),zr()},onRefresh:zr});let g=fe.getGameContainer();g&&(e=g),window.addEventListener("handler-preview:screen",h=>{var v,x,L,P,O,w,k,j,C,A,M,T,E;let f=window.gameApp,m=window.gameObjectManager,{width:b,height:y}=h.detail;if(Bt.width=b,Bt.height=y,Dr(b,y),!(!f||!f.renderer)){m&&o(f,m);try{f.renderer.resize(b,y);let S=f.view;S&&(S.style.width="100%",S.style.height="100%",S.style.display="block")}catch(S){console.warn("[SCREEN] Error resizing renderer:",S);return}if(t&&m&&za)try{let S=(v=window.__mainContainer)!=null?v:f.stage,_=(k=(w=(P=window.__tutorialLabel)!=null?P:(L=(x=m.get("label_1"))==null?void 0:x.getDisplayObject)==null?void 0:L.call(x))!=null?w:(O=m.get("label_1"))==null?void 0:O.pixiObject)!=null?k:m.get("label_1"),I=m.get("background_1"),R=(M=(A=(C=window.__background)!=null?C:(j=I==null?void 0:I.getDisplayObject)==null?void 0:j.call(I))!=null?A:I==null?void 0:I.pixiObject)!=null?M:I;if(S){let z=S===f.stage;za({mainContainer:S,label:_,background:R,backgroundTexture:(R==null?void 0:R.texture)||null,app:f},t,0,Bt,m,{skipMainContainerTransform:z}),window.dispatchEvent(new CustomEvent("handler:layout-applied",{detail:{width:Bt.width,height:Bt.height,presetId:(E=(T=h.detail)==null?void 0:T.presetId)!=null?E:null}}))}}catch(S){console.warn("[SCREEN] Error in layout:",S)}}})}let t=await Se("scene.main");window.__editableConfig=t,r(),window.__editableConfigBaseline||(window.__editableConfigBaseline=Y(t),console.log("[BOOTSTRAP] Frozen config baseline for persistence")),(u=(p=t.engine.runtime)==null?void 0:p.layout)!=null&&u.design_width_portrait||(console.warn("[BOOTSTRAP] Config layout missing, retrying..."),await new Promise(g=>setTimeout(g,100)),t=await Se("scene.main"));let i=await Da(e,t,Gt,fe);Re=i.app;let n=i.gameObjectManager;window.gameApp=Re,window.gameObjectManager=n;try{window.__liveEditBridge=ln({getConfig:()=>window.__editableConfig,gameObjectManager:n,assets:Ut})}catch(g){console.warn("[BOOTSTRAP] Failed to initialize live-edit bridge",g)}fe&&fe.notifyGameLoaded();let a=window.__debugScale;a&&typeof a=="number"&&(ut.scale=a,console.log(`[DEBUG] Applied persisted debug scale: ${a}`)),o(Re,n);async function r(){try{let g=async y=>{let v=y.startsWith("/")?y:`/${y}`,x=await fetch(v,{cache:"no-cache"});if(!x.ok)return null;let L=await x.text();try{return JSON.parse(L)}catch{return null}},h=await g("configs/flow/app.flow.json");if(!h||typeof h!="object")return;let f=h.screens;if(!f||typeof f!="object")return;let m={},b={};for(let[y,v]of Object.entries(f)){let x=v==null?void 0:v.source;if(typeof x!="string")continue;let L=await g(x),P=L==null?void 0:L.elements;if(!Array.isArray(P))continue;let O=P.map(w=>w==null?void 0:w.instance_id).filter(w=>typeof w=="string");m[y]=O;for(let w of O)b[w]||(b[w]=y)}window.__HANDLER_APP_FLOW=h,window.__HANDLER_SCREEN_INDEX={screenToInstances:m,instanceToScreen:b},window.dispatchEvent(new CustomEvent("handler:screen-index-loaded"))}catch{}}function o(g,h){if(Cl){console.log("[RESPONSIVE] Skipping global scaling; using config-driven layout");return}if(console.log("[RESPONSIVE] ===== APPLYING GLOBAL RESPONSIVE SCALING ====="),console.log(`[RESPONSIVE] Scale multiplier: ${ut.scale.toFixed(3)}`),g.stage){let m=function(b,y=0){if(!b||!b.children)return;let v=" ".repeat(y);b.children.forEach((x,L)=>{if(x&&x.zIndex===9999){console.log(`${v}[RESPONSIVE] Skipping debug border (zIndex 9999)`);return}if(x&&x.scale){let P=x.scale.x||1,O=x.scale.y||1;x.__originalScale||(x.__originalScale={x:P,y:O},console.log(`${v}[RESPONSIVE] Stored original scale for child[${L}]: ${P.toFixed(3)}, ${O.toFixed(3)}`));let w=x.__originalScale.x*ut.scale,k=x.__originalScale.y*ut.scale;typeof x.scale.set=="function"?x.scale.set(w,k):(x.scale.x=w,x.scale.y=k),console.log(`${v}[RESPONSIVE] Child[${L}] scale: ${P.toFixed(3)}\u2192${x.scale.x.toFixed(3)} (type: ${x.constructor.name})`),m(x,y+1)}else x&&console.log(`${v}[RESPONSIVE] Child[${L}] has no scale (type: ${x.constructor.name})`)})};var f=m;console.log("[RESPONSIVE] Applying scale to PIXI stage children"),m(g.stage)}else console.warn("[RESPONSIVE] No app.stage found!");console.log("[REDDEBUG] Debug border left unscaled (fixed boundaries)"),console.log("[RESPONSIVE] ===== GLOBAL RESPONSIVE SCALING COMPLETE =====")}function l(g){if(g!==void 0){ut.scale=g,console.log(`[RESPONSIVE] Updated global scale multiplier to: ${g.toFixed(3)}`);let h=window.gameApp,f=window.gameObjectManager;h&&f?(o(h,f),h.renderer&&(h.renderer.render(h.stage),console.log("[RESPONSIVE] Forced PIXI renderer update"))):console.warn(`[RESPONSIVE] No gameApp (${!!h}) or gameObjectManager (${!!f}) found in window for live update`)}}window.updateGlobalResponsiveMultipliers=l,De.start()},zr=async()=>{var e,t,i,n;console.log("[PREVIEW] Restarting game in 1 seconds...");let s=(e=window.gameObjectManager)==null?void 0:e.get("character_1");if(s){let a=((t=s.getDisplayObject)==null?void 0:t.call(s))||s;a&&a.scale&&console.log(`[CHARACTER] Before restart - Current scale - x: ${((i=a.scale.x)!=null?i:1).toFixed(3)}, y: ${((n=a.scale.y)!=null?n:1).toFixed(3)}`)}if(fe){fe.notifyGameDestroyed();try{$a&&$a()}catch(a){console.warn("Failed to clear responsive elements",a)}setTimeout(()=>{console.log("[PREVIEW] Executing restart...");let a=fe.getGameContainer(),r=window.gameObjectManager;if(r&&typeof r.clear=="function"&&(console.log("[PREVIEW] Clearing old GameObjectManager tickers..."),r.clear()),Re){try{Re.destroy(!0,{children:!0,texture:!1})}catch(o){console.warn("[PREVIEW] Destroy warning:",o)}Re=null}window.gameApp=null,window.gameObjectManager=null,a&&(a.innerHTML="");try{typeof Ut.resetScene=="function"&&Ut.resetScene()}catch(o){console.warn("Asset reset failed",o)}setTimeout(()=>{Se("scene.main").then(o=>{window.__editableConfig=o,window.__editableConfigBaseline||(window.__editableConfigBaseline=Y(o)),Da(a,o,Gt).then(l=>{Re=l.app,window.gameApp=Re,window.gameObjectManager=l.gameObjectManager;try{window.__liveEditBridge=ln({getConfig:()=>window.__editableConfig,gameObjectManager:window.gameObjectManager,assets:Ut})}catch(c){console.warn("[BOOTSTRAP] Failed to re-initialize live-edit bridge",c)}fe&&fe.notifyGameLoaded(),console.log("[PREVIEW] Game restarted successfully");try{De.start()}catch{}})})},100)},1e3)}};xi();K();var me={background:"#F6F3EF",ink:"#1E1E1E",secondaryText:"#8E8A84",primaryAccent:"#E38A5A",secondaryAccent:"#C9A28C",statusGreen:"#5F8F6B"},Nr=1.25,Hr={fontFamily:"Inter, system-ui, sans-serif"};var dn=class{constructor(e={}){this.currentProgress=0;var t;this.currentProgress=(t=e.progress)!=null?t:0,this.container=this.createContainer()}createContainer(){let e=document.createElement("div");e.className="handler-loading-screen",e.style.cssText=`
2487
+ `,this.setupEventListeners(e),e}setupEventListeners(e){var P,O,w,k,j,C,A,M;let t=e.querySelector("#device-select");t==null||t.addEventListener("change",T=>{if(this.viewMode==="compare")return;let E=T.target.value;this.setDevice(E)});let i=e.querySelector("#theme-select");i==null||i.addEventListener("change",T=>{let E=T.target.value;this.setTheme(E)}),Array.from(e.querySelectorAll("[data-view-toggle]")).forEach(T=>{T.addEventListener("click",()=>{let E=T.dataset.viewToggle;E&&this.setViewMode(E)})}),Array.from(e.querySelectorAll("[data-layout-toggle]")).forEach(T=>{T.addEventListener("click",()=>{let E=T.dataset.layoutToggle;E&&this.setLayoutMode(E)})});let r=e.querySelector("#scene-toggle");r==null||r.addEventListener("click",()=>{this.viewMode!=="compare"&&(this.setSceneVisible(!this.sceneVisiblePreference),this.updateSceneVisibility())});let o=e.querySelector("#scene-hide-btn");o==null||o.addEventListener("click",()=>{this.viewMode!=="compare"&&(this.setSceneVisible(!1),this.updateSceneVisibility())});let l=T=>{let E=typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default";return`handler_preview_scene_${T}::${E}`},c=e.querySelector("#scene-grid-btn"),d=e.querySelector("#scene-play-btn"),p=(T,E,S)=>{T&&(T.textContent=E?`${S} On`:`${S} Off`,T.setAttribute("aria-pressed",E?"true":"false"))},u=()=>{let T=window.localStorage.getItem(l("grid_gap")),E=Number(T!=null?T:50);return Number.isFinite(E)?E:50},g=T=>{try{window.localStorage.setItem(l("grid_enabled"),T?"true":"false")}catch{}p(c,T,"Grid");let E=u();window.dispatchEvent(new CustomEvent("scene-editor:grid",{detail:{enabled:T,gap:E}}))},h=T=>{try{window.localStorage.setItem(l("play_mode"),T?"true":"false")}catch{}p(d,T,"Play"),window.dispatchEvent(new CustomEvent("scene-editor:play-mode",{detail:{enabled:T}}))};try{let T=window.localStorage.getItem(l("grid_enabled"))==="true",E=window.localStorage.getItem(l("play_mode"))==="true";if(p(c,T,"Grid"),p(d,E,"Play"),c){let S=u();window.dispatchEvent(new CustomEvent("scene-editor:grid",{detail:{enabled:T,gap:S}}))}d&&window.dispatchEvent(new CustomEvent("scene-editor:play-mode",{detail:{enabled:E}}))}catch{}c==null||c.addEventListener("click",()=>{let T=c.getAttribute("aria-pressed")==="true";g(!T)}),d==null||d.addEventListener("click",()=>{let T=d.getAttribute("aria-pressed")==="true";h(!T)}),(P=e.querySelector("#rotate-btn"))==null||P.addEventListener("click",()=>this.toggleRotation()),(O=e.querySelector("#zoom-in-btn"))==null||O.addEventListener("click",()=>this.adjustUserZoom(.1)),(w=e.querySelector("#zoom-out-btn"))==null||w.addEventListener("click",()=>this.adjustUserZoom(-.1)),(k=e.querySelector("#refresh-btn"))==null||k.addEventListener("click",()=>this.refresh());let f=e.querySelector("#bottom-dock"),m=e.querySelector("#bottom-dock-resize");f&&m&&this.makeBottomDockResizable(f,m);let b=Array.from(e.querySelectorAll(".bottom-dock-tab"));b.forEach(T=>{T.addEventListener("click",()=>{let E=T.dataset.dockTab;if(!E)return;b.forEach(_=>_.classList.remove("active")),T.classList.add("active"),Array.from(e.querySelectorAll(".bottom-dock-panel")).forEach(_=>{let I=_.dataset.dockPanel;_.classList.toggle("active",I===E)})})}),(j=e.querySelector("#console-clear"))==null||j.addEventListener("click",()=>this.clearConsole()),(C=e.querySelector("#corner-zoom-in-btn"))==null||C.addEventListener("click",()=>this.adjustUserZoom(.1)),(A=e.querySelector("#corner-zoom-out-btn"))==null||A.addEventListener("click",()=>this.adjustUserZoom(-.1)),(M=e.querySelector("#corner-grab-btn"))==null||M.addEventListener("click",()=>{this.frameDragger.style.cursor="grab",setTimeout(()=>{this.isSpaceKeyPressed||(this.frameDragger.style.cursor="")},1e3)});let y=e.querySelector(".scene-panel.scene-objects"),v=y==null?void 0:y.querySelector("[data-panel-resize-v]");y&&v&&this.makeSidebarResizable(y,v,"left");let x=e.querySelector(".debug-workbench"),L=x==null?void 0:x.querySelector("#workbench-resize-v");x&&L&&this.makeSidebarResizable(x,L,"right")}applyDeviceFrameStyles(){Object.assign(this.frameDragger.style,{display:"flex",justifyContent:"center",alignItems:"center",transform:"translate(0px, 0px)",touchAction:"none"}),Object.assign(this.frameWrapper.style,{display:"flex",justifyContent:"center",alignItems:"center",transformOrigin:"center center",transition:"transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)",boxShadow:"var(--ui-shadow-strong)",borderRadius:"0px",willChange:"transform"}),Object.assign(this.deviceFrame.style,{overflow:"hidden",position:"relative",borderRadius:"0px"}),Object.assign(this.gameContainer.style,{position:"relative",overflow:"hidden",minWidth:"0px",minHeight:"0px"})}setupObserversAndListeners(){this.resizeObserver=new ResizeObserver(()=>{this.resizeListenersDisabled||this.scheduleFit()}),this.resizeObserver.observe(this.previewContainer),window.addEventListener("resize",this.onWindowResize,{passive:!0})}scheduleFit(){this.rafFitHandle&&cancelAnimationFrame(this.rafFitHandle),this.rafFitHandle=requestAnimationFrame(()=>{this.rafFitHandle=null,this.fitToScreen()})}applyPresetDimensions(){let e=this.getEffectivePreset(),t=`${e.width}px`,i=`${e.height}px`;this.deviceFrame.style.width=t,this.deviceFrame.style.height=i,this.gameContainer.style.width=t,this.gameContainer.style.height=i,this.gameContainer.style.maxWidth=t,this.gameContainer.style.maxHeight=i,this.gameContainer.style.minWidth=t,this.gameContainer.style.minHeight=i,this.gameContainer.dataset.screenWidth=String(e.width),this.gameContainer.dataset.screenHeight=String(e.height),this.container.style.setProperty("--preview-screen-width",String(e.width)),this.container.style.setProperty("--preview-screen-height",String(e.height))}fitToScreen(e){if(!this.previewContainer)return;let t=this.getEffectivePreset(),i=this.getFitBounds(),n=Math.max(0,i.width),a=Math.max(0,i.height);if(n<=0||a<=0)return;this.applyPresetDimensions(),this.viewMode==="compare"&&this.applyCompareDimensions();let r=n/t.width,o=a/t.height;if(this.autoScale=Math.max(.01,Math.min(r,o)),!this.hasInitialFit){this.hasInitialFit=!0;let l=.6;this.userScaleMultiplier=l/this.autoScale}(e==null?void 0:e.keepUserScaleMultiplier)!==void 0&&e.keepUserScaleMultiplier>0?this.userScaleMultiplier=e.keepUserScaleMultiplier:e!=null&&e.keepVisibleScale&&e.keepVisibleScale>0&&(this.userScaleMultiplier=e.keepVisibleScale/this.autoScale),this.applyTransform(),this.viewMode==="compare"&&this.fitCompareGhosts(),requestAnimationFrame(()=>this.updatePanelPositions()),this.emitScreenChange()}applyTransform(){let e=this.autoScale*this.userScaleMultiplier;this.frameWrapper.style.transform=`scale(${e})`;let t=this.container.querySelector("#zoom-label");t&&(t.textContent=`${Math.round(e*100)}%`),requestAnimationFrame(()=>this.updatePanelPositions())}applyFrameDrag(){this.frameDragger.style.transform=`translate(${this.frameDragOffsetX}px, ${this.frameDragOffsetY}px)`,requestAnimationFrame(()=>this.updatePanelPositions())}updatePanelPositions(){if(!this.gameReady||this.viewMode==="compare")return;let e=this.container.querySelector('[data-panel="scene-tools-corner"]'),t=this.container.querySelector('[data-panel="nudge-panel"]');if(this.layoutMode==="fixed"){let i=this.gameViewPane||this.container.querySelector(".preview-container");i&&(e&&e.parentElement!==i&&i.appendChild(e),t&&t.parentElement!==i&&i.appendChild(t))}else{let i=this.container.querySelector(".preview-main");i&&(e&&e.parentElement!==i&&i.appendChild(e),t&&t.parentElement!==i&&i.appendChild(t))}e&&(e.style.zIndex="100"),t&&(t.style.position="absolute",t.style.left="50%",t.style.top="16px",t.style.transform="translateX(calc(-50% + 200px))",t.style.zIndex="100")}setupFrameDragging(){this.frameDragger.addEventListener("pointerdown",e=>{let t=!this.gameContainer.contains(e.target);!this.isSpaceKeyPressed&&!t||e.button===0&&(e.preventDefault(),this.frameDragActive=!0,this.frameDragStartX=e.clientX,this.frameDragStartY=e.clientY,this.frameDragOriginX=this.frameDragOffsetX,this.frameDragOriginY=this.frameDragOffsetY,window.addEventListener("pointermove",this.onFrameDragMove),window.addEventListener("pointerup",this.onFrameDragEnd))})}setupSpaceKeyListener(){window.addEventListener("keydown",e=>{e.code==="Space"&&!this.isInputFocused()&&(this.isSpaceKeyPressed||(this.isSpaceKeyPressed=!0,this.updateDragCursor(),e.preventDefault()))}),window.addEventListener("keyup",e=>{e.code==="Space"&&(this.isSpaceKeyPressed=!1,this.updateDragCursor(),this.frameDragActive&&this.onFrameDragEnd())}),window.addEventListener("blur",()=>{this.isSpaceKeyPressed=!1,this.updateDragCursor(),this.frameDragActive&&this.onFrameDragEnd()})}isInputFocused(){let e=document.activeElement;if(!e)return!1;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"||e.isContentEditable}setupShortcutListeners(){window.addEventListener("keydown",e=>{if(this.isInputFocused())return;let t=navigator.platform.toUpperCase().indexOf("MAC")>=0,i=e.ctrlKey||e.metaKey,n=e.shiftKey;if(i&&e.key==="s"&&!n){e.preventDefault();let a=document.querySelector("#apply-current-btn");a&&a.getAttribute("disabled")===null&&a.click();return}if(i&&e.key==="z"&&!n){e.preventDefault(),gi();return}if(i&&(e.key==="z"&&n||e.key==="y"&&!n)){e.preventDefault(),hi();return}})}setupUnsavedChangesIndicator(){let e=this.container.querySelector("#preview-save-shortcut-text");e&&(e.textContent=`(${this.getShortcutKey()} + S)`),window.addEventListener("config:changed",()=>{this.updateUnsavedChangesIndicator()}),this.updateUnsavedChangesIndicator();let t=this.container.querySelector("#preview-save-btn");t==null||t.addEventListener("click",()=>{let i=document.querySelector("#apply-current-btn");i&&i.getAttribute("disabled")===null&&i.click()})}updateUnsavedChangesIndicator(){let t=Pe().hasChanges;if(t!==this.hasUnsavedChanges){this.hasUnsavedChanges=t;let i=this.container.querySelector("#preview-unsaved-star"),n=this.container.querySelector("#preview-save-btn");i&&(i.style.display=t?"inline-block":"none"),n&&(n.style.display=t?"inline-flex":"none")}}updateDragCursor(){this.isSpaceKeyPressed?(this.frameDragger.style.cursor="grab",this.frameDragActive&&(this.frameDragger.style.cursor="grabbing")):this.frameDragger.style.cursor=""}adjustUserZoom(e){this.userScaleMultiplier=Math.max(.1,Math.min(6,this.userScaleMultiplier+e)),this.applyTransform(),this.emitScreenChange()}toggleRotation(){var t,i;if(this.viewMode==="compare")return;let e=this.userScaleMultiplier;this.isLandscape=!this.isLandscape,this.applyPresetDimensions(),this.fitToScreen({keepUserScaleMultiplier:e}),(i=(t=this.options).onDeviceChange)==null||i.call(t,this.getEffectivePreset()),this.emitScreenChange()}emitScreenChange(){if(!this.gameReady)return;let e=this.getEffectivePreset(),t={width:e.width,height:e.height,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:e.id,isLandscape:this.isLandscape};if(window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:t})),this.viewMode==="compare"&&this.refreshCompareSnapshots(),this.isInitialized&&this.isMounted&&this.gameReady){let i=window.gameApp;if(!(i!=null&&i.renderer))return;this.ignoreNextWindowResize=!0,window.dispatchEvent(new Event("resize"))}}safeStringify(e){var i;let t=new WeakSet;try{return JSON.stringify(e,(n,a)=>{if(typeof a=="object"&&a!==null){if(t.has(a))return"[Circular]";t.add(a)}return a},2)}catch{try{if(e&&((i=e.constructor)!=null&&i.name))return`[object ${e.constructor.name}]`}catch{}return String(e)}}setupConsoleInterceptor(){let e=(t,...i)=>{let n=i.map(r=>typeof r=="object"?this.safeStringify(r):String(r)).join(" ");this.consoleMessages.push({type:t,message:n,timestamp:new Date}),this.appendConsoleMessage(this.consoleMessages[this.consoleMessages.length-1]);let a=this.container.querySelector("#console-badge");if(a){let r=this.consoleMessages.filter(o=>o.type==="error").length;a.textContent=r>0?`${r}!`:"0",a.classList.toggle("has-errors",r>0)}};console.log=(...t)=>{this.originalConsole.log(...t),e("log",...t)},console.warn=(...t)=>{this.originalConsole.warn(...t),e("warn",...t)},console.error=(...t)=>{this.originalConsole.error(...t),e("error",...t)},console.info=(...t)=>{this.originalConsole.info(...t),e("info",...t)}}appendConsoleMessage(e){let t=this.container.querySelector("#console-messages");if(!t)return;let i=document.createElement("div");i.className=`console-msg type-${e.type}`;let n=e.timestamp.toLocaleTimeString();i.innerHTML=`<span class="time">${this.escapeHtml(n)}</span> <pre>${this.escapeHtml(e.message)}</pre>`,t.appendChild(i),t.scrollTop=t.scrollHeight}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}toggleConsole(e){var t;if(this.layoutMode==="fixed"){let i=this.container.querySelector('[data-dock-tab="console"]');if(i){i.click();let n=this.container.querySelector("#bottom-dock");n==null||n.classList.remove("hidden")}return}this.isConsoleOpen=e!=null?e:!this.isConsoleOpen,(t=this.consolePanel)==null||t.classList.toggle("closed",!this.isConsoleOpen)}clearConsole(){this.consoleMessages=[];let e=this.container.querySelector("#console-messages");e&&(e.innerHTML="");let t=this.container.querySelector("#console-badge");t&&(t.textContent="0")}setupCompareViewports(){Array.from(this.container.querySelectorAll("[data-viewport]")).forEach(t=>{let i=t.dataset.viewport;if(!i)return;let n=this.comparePresets.find(p=>p.id===i);if(!n)return;let a=t.querySelector("[data-compare-slot]"),r=t.querySelector("[data-compare-ghost]"),o=t.querySelector("[data-compare-wrapper]"),l=t.querySelector("[data-compare-frame]"),c=t.querySelector("[data-compare-snapshot]"),d=t.querySelector("[data-compare-focus]");!a||!r||!o||!l||(t.addEventListener("click",p=>{let u=p.target;if(u!=null&&u.closest("[data-compare-focus]")){p.preventDefault(),this.activateCompareViewport(i);return}t.classList.contains("is-active")||this.activateCompareViewport(i)}),this.compareViewports.set(i,{preset:n,root:t,slot:a,ghost:r,wrapper:o,frame:l,canvas:c,focus:d}))})}setViewMode(e){if(this.viewMode===e)return;this.viewMode=e,this.container.classList.toggle("compare-mode",e==="compare"),this.singleStage.classList.toggle("hidden",e!=="single"),this.compareStage.classList.toggle("hidden",e!=="compare");let t=this.container.querySelector("#device-select");t&&(t.disabled=e==="compare");let i=this.container.querySelector("#rotate-btn");i&&(i.disabled=e==="compare");let n=this.container.querySelector("#scene-toggle");if(n&&(n.disabled=e==="compare"),this.updateViewToggleUI(),e==="compare"){this.lastSinglePresetId=this.currentPreset.id,this.activateCompareViewport(this.activeCompareId),this.refreshCompareSnapshots(),this.startCompareSnapshots(),this.updateSceneVisibility();return}this.stopCompareSnapshots(),this.singleStage.appendChild(this.frameDragger),this.setDevice(this.lastSinglePresetId,{suppressCallback:!0}),this.fitToScreen(),this.updateSceneVisibility()}updateViewToggleUI(){Array.from(this.container.querySelectorAll("[data-view-toggle]")).forEach(t=>{t.classList.toggle("active",t.dataset.viewToggle===this.viewMode)})}activateCompareViewport(e){var a,r;let t=this.compareViewports.get(e);if(!t)return;let i=this.autoScale*this.userScaleMultiplier,n=this.activeCompareId;n&&n!==e&&this.captureCompareSnapshot(n),this.activeCompareId=e,this.currentPreset=t.preset,this.isLandscape=!1,t.slot.appendChild(this.frameDragger),this.frameDragOffsetX=0,this.frameDragOffsetY=0,this.applyFrameDrag(),this.compareViewports.forEach((o,l)=>{o.root.classList.toggle("is-active",l===e),o.ghost.classList.toggle("hidden",l===e),o.focus&&(o.focus.textContent=l===e?"Live":"Focus")}),this.applyPresetDimensions(),this.applyCompareDimensions(),this.fitToScreen({keepVisibleScale:i}),(r=(a=this.options).onDeviceChange)==null||r.call(a,this.getEffectivePreset())}applyCompareDimensions(){this.compareViewports.forEach(e=>{let t=e.preset,i=`${t.width}px`,n=`${t.height}px`;e.frame.style.width=i,e.frame.style.height=n,e.canvas&&(e.canvas.width=t.width,e.canvas.height=t.height)})}fitCompareGhosts(){this.compareViewports.forEach(e=>{let t=e.root.querySelector(".compare-body");if(!t)return;let i=Math.max(0,t.clientWidth-24),n=Math.max(0,t.clientHeight-24);if(i<=0||n<=0)return;let a=i/e.preset.width,r=n/e.preset.height,o=Math.max(.01,Math.min(a,r));e.wrapper.style.transform=`scale(${o})`})}captureCompareSnapshot(e){let t=this.compareViewports.get(e);if(!(t!=null&&t.canvas))return;let i=this.gameContainer.querySelector("canvas");if(!i)return;let n=t.canvas.getContext("2d");if(!n)return;let a=t.canvas.width,r=t.canvas.height,o=Math.min(a/i.width,r/i.height),l=i.width*o,c=i.height*o,d=(a-l)/2,p=(r-c)/2;n.clearRect(0,0,a,r),n.drawImage(i,d,p,l,c)}refreshCompareSnapshots(){this.compareViewports.forEach((e,t)=>{t!==this.activeCompareId&&this.captureCompareSnapshot(t)})}startCompareSnapshots(){this.compareSnapshotTimer||(this.compareSnapshotTimer=window.setInterval(()=>{this.viewMode==="compare"&&this.refreshCompareSnapshots()},500))}stopCompareSnapshots(){this.compareSnapshotTimer&&(window.clearInterval(this.compareSnapshotTimer),this.compareSnapshotTimer=null)}getFitBounds(){if(this.viewMode!=="compare"){let i=this.gameViewPane||this.previewContainer;return{width:i.clientWidth-40,height:i.clientHeight-40}}let e=this.compareViewports.get(this.activeCompareId),t=e==null?void 0:e.root.querySelector(".compare-body");return t?{width:t.clientWidth-24,height:t.clientHeight-24}:{width:this.previewContainer.clientWidth-40,height:this.previewContainer.clientHeight-40}}mustQuery(e){let t=this.container.querySelector(e);if(!t)throw new Error(`PreviewShell missing element: ${e}`);return t}};function Oa(s={}){let e=new on(s);return typeof window!="undefined"&&(window.__previewShell=e),e.mount(),e}K();function Ra(s){try{if(s&&typeof s.keys=="function")return Array.from(s.keys())}catch{}return[]}function jr(s){var e;return s?((e=s.getDisplayObject)==null?void 0:e.call(s))||s.pixiObject||s:null}function wl(s,e){if(!s||!(e!=null&&e.interaction))return;let t=e.interaction,i=t.enabled!==!1&&(t.draggable===!0||t.clickable===!0);s.eventMode=i?"static":"none",s.interactive=i,i&&(s.cursor=t.draggable?"move":"pointer")}function _r(s,e){var l,c,d;if(!s||!e)return;let t=e.transform||{};wl(s,e);let i=t.position||{},n=t.offset||{},a=(typeof i.x=="number"?i.x:0)+(typeof n.x=="number"?n.x:0),r=(typeof i.y=="number"?i.y:0)+(typeof n.y=="number"?n.y:0);(l=s.position)!=null&&l.set?s.position.set(a,r):(typeof s.x=="number"&&(s.x=a),typeof s.y=="number"&&(s.y=r)),typeof t.scale=="number"&&((c=s.scale)!=null&&c.set?s.scale.set(t.scale):s.scale&&(s.scale.x=t.scale,s.scale.y=t.scale));let o=t.anchor;if(o&&((d=s.anchor)!=null&&d.set)){let p=null;typeof window!="undefined"&&window.resolveAnchorVec2?p=window.resolveAnchorVec2(o):typeof o=="object"&&o.x!==void 0&&o.y!==void 0?p=o:Array.isArray(o)&&o.length===2&&(p={x:o[0],y:o[1]}),p&&typeof p.x=="number"&&typeof p.y=="number"&&s.anchor.set(p.x,p.y)}}function Or(s){if(typeof window=="undefined")return;let e=s==null?void 0:s.objects,t=Ra(e),i=a=>{var r;try{let o=window.__HANDLER_ACTIVE_SCREEN;if(!o||o==="all")return a;let l=window.__HANDLER_SCREEN_INDEX,c=(r=l==null?void 0:l.screenToInstances)==null?void 0:r[o];if(Array.isArray(c)&&c.length>0){let p=new Set(c);return a.filter(u=>p.has(u))}let d=l==null?void 0:l.instanceToScreen;return d?a.filter(p=>d[p]===o):a}catch{return a}};window.__editableObjectConfigs=e;let n=new Map;t.forEach(a=>n.set(a,[a])),window.__editableObjectInstances=n,window.refreshEditableConfigIndex=()=>Or(window.__editableConfig),window.getEditableObjectList=()=>{var a;return i(Ra((a=window.__editableConfig)==null?void 0:a.objects))},window.getEditableObjectListAll=()=>{var a;return Ra((a=window.__editableConfig)==null?void 0:a.objects)},window.getEditableObjectConfig=a=>{var p,u,g,h,f,m;let r=(h=(g=(u=(p=window.__editableConfig)==null?void 0:p.objects)==null?void 0:u.get)==null?void 0:g.call(u,a))!=null?h:null,o=window.__HANDLER_ACTIVE_SCREEN;if(!o||o==="all")return r;let l=window.__HANDLER_SCREEN_INDEX,c=(f=l==null?void 0:l.screenToInstances)==null?void 0:f[o];if(Array.isArray(c))return c.includes(a)?r:null;let d=(m=l==null?void 0:l.instanceToScreen)==null?void 0:m[a];return d&&d===o?r:null},window.getEditableEngineConfig=()=>{let a=window.__editableConfig;if(console.log("[BRIDGE] getEditableEngineConfig called, cfg present:",!!a),!a)return null;if(a.engine&&a.objects instanceof Map){console.log("[BRIDGE] Detected ObjectCentricConfig, flattening...");let r={...a.engine,objects:a.objects,scene:a.scene};return console.log("[BRIDGE] Returned assets:",Object.keys(r.assets||{})),r}return a}}function xl(){if(typeof window=="undefined")return;let s=t=>{let i=String(t||"").trim();return i?/^(data:|blob:|https?:)/.test(i)||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`:""},e=async(t,i)=>{var a,r,o;let n=s(i);if(n)try{let[{Assets:l},{AssetTextures:c}]=await Promise.all([import("pixi.js"),Promise.resolve().then(()=>(it(),Ps))]),d=Date.now(),p=/^(data:|blob:)/.test(n)?n:n+(n.includes("?")?`&t=${d}`:`?t=${d}`),u=await l.load(p);if(!u)return;c[t]=u;let g=window.CustomAssets;(a=g==null?void 0:g[t])!=null&&a.texture&&(g[t].texture=u);let h=window.gameObjectManager,f=(r=h==null?void 0:h.get)==null?void 0:r.call(h,t);if(f){let m=((o=f.getDisplayObject)==null?void 0:o.call(f))||f.pixiObject||f.pixi||f;if(m!=null&&m.texture)m.texture=u;else if(m!=null&&m.children){let b=m.children.find(y=>y==null?void 0:y.texture);b!=null&&b.texture&&(b.texture=u)}}}catch(l){console.warn("[LIVE-EDIT] Failed to reload Pixi texture for",t,l)}};window.applyLiveEditOverrides=t=>{try{let i=Z();Array.isArray(i)&&i.length&&(window.__editableConfig=t,ke(i,{silent:!0,persist:!1}))}catch{}},window.applyEngineOverrides=t=>{try{let i=Z();Array.isArray(i)&&i.length&&(window.__editableConfig=t,ke(i,{silent:!0,persist:!1}))}catch{}},window.applyEditableEngineConfig=t=>{let i=window.__editableConfig;if(!(i!=null&&i.engine))return;let n=[];if(t.runtime)for(let[a,r]of Object.entries(t.runtime))n.push({path:`runtime.${a}`,value:r});if(t.assets)for(let[a,r]of Object.entries(t.assets))n.push({path:`assets.${a}`,value:r}),typeof r=="string"&&e(a,r);if(t.splash)for(let[a,r]of Object.entries(t.splash))n.push({path:`splash.${a}`,value:r});if(t.loading)for(let[a,r]of Object.entries(t.loading))n.push({path:`loading.${a}`,value:r});if(t.start)for(let[a,r]of Object.entries(t.start))n.push({path:`start.${a}`,value:r});n.length&&ke(n,{silent:!0,persist:!0,emitEvent:!0})}}function ln(s){let{getConfig:e,gameObjectManager:t,onObjectConfigApplied:i}=s;t&&(t.onObjectRebuildRequired=async(a,r)=>{console.log(`[LIVE-EDIT] \u{1F3D7}\uFE0F Rebuilding object ${a} due to type change...`);let o=t.get(a),l=o==null?void 0:o.pixiObject,c=l==null?void 0:l.parent,d=c==null?void 0:c.children.indexOf(l);o?t.remove(a):l&&l.destroy();let p=window.gameApp,u=await ue.create(a,r,p);c&&(d!==void 0&&d!==-1?c.addChildAt(u,d):c.addChild(u));let g=t.create(a,u);return console.log(`[LIVE-EDIT] \u2705 Rebuild complete for ${a}`),g}),typeof window!="undefined"&&(xl(),window.applyEditableObjectConfig=(a,r)=>{var o,l,c;console.log("[LIVE-EDIT] \u{1F504} applyEditableObjectConfig called for:",a);try{let d=window.__editableConfig;(o=d==null?void 0:d.objects)!=null&&o.set&&(d.objects.set(a,r),console.log("[LIVE-EDIT] \u2705 Updated config in __editableConfig"));let p=(l=t==null?void 0:t.get)==null?void 0:l.call(t,a);if(console.log("[LIVE-EDIT] gameObject found?",!!p),p&&(console.log("[LIVE-EDIT] gameObject type:",(c=p.constructor)==null?void 0:c.name),console.log("[LIVE-EDIT] has updateConfig?",typeof p.updateConfig=="function"),console.log("[LIVE-EDIT] has onConfigUpdate?",typeof p.onConfigUpdate=="function")),p&&typeof p.updateConfig=="function")console.log("[LIVE-EDIT] \u2705 Calling updateConfig()"),p.updateConfig(r);else if(p&&typeof p.onConfigUpdate=="function")console.log("[LIVE-EDIT] \u2705 Calling onConfigUpdate()"),p.onConfigUpdate();else{console.log("[LIVE-EDIT] \u26A0\uFE0F No updateConfig or onConfigUpdate, applying transform directly");let u=jr(p);_r(u,r)}}catch(d){console.error("[LIVE-EDIT] \u274C Error in applyEditableObjectConfig:",d)}});let n={async applyObjectConfig(a,r){var d,p;console.log("[BRIDGE] \u{1F504} applyObjectConfig called for:",a);let o=e();(d=o==null?void 0:o.objects)!=null&&d.set&&(o.objects.set(a,r),console.log("[BRIDGE] \u2705 Updated config"));let l=(p=t==null?void 0:t.get)==null?void 0:p.call(t,a);if(console.log("[BRIDGE] gameObject found?",!!l),l&&(console.log("[BRIDGE] has updateConfig?",typeof l.updateConfig=="function"),console.log("[BRIDGE] has onConfigUpdate?",typeof l.onConfigUpdate=="function")),l&&typeof l.updateConfig=="function")console.log("[BRIDGE] \u2705 Calling updateConfig()"),l.updateConfig(r);else if(l&&typeof l.onConfigUpdate=="function")console.log("[BRIDGE] \u2705 Calling onConfigUpdate()"),l.onConfigUpdate();else{console.log("[BRIDGE] \u26A0\uFE0F Applying transform directly");let u=jr(l);_r(u,r)}let c=[a];i==null||i(a,r,c)},rebuildIndexes(){let a=e();typeof window!="undefined"&&(window.__editableConfig=a,Or(a))}};return n.rebuildIndexes(),n}K();var $r=Ze(require("lottie-web"),1);Tn(An);typeof window!="undefined"&&!window.lottie&&(window.lottie=$r.default);var pt=null,Sl=async()=>{if(!pt){let s=typeof window!="undefined"?window.INLINE_ASSETS:null,e=(s==null?void 0:s["handler.config"])||(s==null?void 0:s["handler.config.json"]);if(e)try{if(e.startsWith("data:")){let i=atob(e.split(",")[1]);pt=JSON.parse(i)}else pt=JSON.parse(e);return pt}catch(i){console.warn("[CONFIG] Failed to parse inline handler.config.json:",i)}pt=await(await fetch("./handler.config.json")).json()}return pt},Da,Ut,Dr,ut,za,$a;function El(s){Da=s.initGame,Ut=s.CustomAssets,Dr=s.updateScreenState,ut=s.globalResponsiveMultipliers,za=s.layout,$a=s.clearResponsiveElements}var cn="web_embed",Gt="https://example.com",Rr={profile_id:cn},Re=null,fe=null,Bt={width:0,height:0},Cl=!0,Al=async()=>{var c,d,p,u;document.title="Handler Pixi Game";let s=await Sl();Rr={...s.ids||{},profile_id:cn},Gt=s.destination_url||((d=(c=s.export_profiles)==null?void 0:c[cn])==null?void 0:d.destination_url)||Gt,De.init({ids:Rr,profile:cn,destinationUrl:Gt});let e=De.getRoot();if(typeof __PREVIEW_SHELL__!="undefined"&&__PREVIEW_SHELL__){console.log("[BOOTSTRAP] Initializing Preview Shell..."),fe=Oa({onDeviceChange:h=>{console.log(`[PREVIEW] Device switched to ${h.width}x${h.height}, restarting game...`),zr()},onRefresh:zr});let g=fe.getGameContainer();g&&(e=g),window.addEventListener("handler-preview:screen",h=>{var v,x,L,P,O,w,k,j,C,A,M,T,E;let f=window.gameApp,m=window.gameObjectManager,{width:b,height:y}=h.detail;if(Bt.width=b,Bt.height=y,Dr(b,y),!(!f||!f.renderer)){m&&o(f,m);try{f.renderer.resize(b,y);let S=f.view;S&&(S.style.width="100%",S.style.height="100%",S.style.display="block")}catch(S){console.warn("[SCREEN] Error resizing renderer:",S);return}if(t&&m&&za)try{let S=(v=window.__mainContainer)!=null?v:f.stage,_=(k=(w=(P=window.__tutorialLabel)!=null?P:(L=(x=m.get("label_1"))==null?void 0:x.getDisplayObject)==null?void 0:L.call(x))!=null?w:(O=m.get("label_1"))==null?void 0:O.pixiObject)!=null?k:m.get("label_1"),I=m.get("background_1"),R=(M=(A=(C=window.__background)!=null?C:(j=I==null?void 0:I.getDisplayObject)==null?void 0:j.call(I))!=null?A:I==null?void 0:I.pixiObject)!=null?M:I;if(S){let z=S===f.stage;za({mainContainer:S,label:_,background:R,backgroundTexture:(R==null?void 0:R.texture)||null,app:f},t,0,Bt,m,{skipMainContainerTransform:z}),window.dispatchEvent(new CustomEvent("handler:layout-applied",{detail:{width:Bt.width,height:Bt.height,presetId:(E=(T=h.detail)==null?void 0:T.presetId)!=null?E:null}}))}}catch(S){console.warn("[SCREEN] Error in layout:",S)}}})}let t=await Se("scene.main");window.__editableConfig=t,r(),window.__editableConfigBaseline||(window.__editableConfigBaseline=Y(t),console.log("[BOOTSTRAP] Frozen config baseline for persistence")),(u=(p=t.engine.runtime)==null?void 0:p.layout)!=null&&u.design_width_portrait||(console.warn("[BOOTSTRAP] Config layout missing, retrying..."),await new Promise(g=>setTimeout(g,100)),t=await Se("scene.main"));let i=await Da(e,t,Gt,fe);Re=i.app;let n=i.gameObjectManager;window.gameApp=Re,window.gameObjectManager=n;try{window.__liveEditBridge=ln({getConfig:()=>window.__editableConfig,gameObjectManager:n,assets:Ut})}catch(g){console.warn("[BOOTSTRAP] Failed to initialize live-edit bridge",g)}fe&&fe.notifyGameLoaded();let a=window.__debugScale;a&&typeof a=="number"&&(ut.scale=a,console.log(`[DEBUG] Applied persisted debug scale: ${a}`)),o(Re,n);async function r(){try{let g=async y=>{let v=y.startsWith("/")?y:`/${y}`,x=await fetch(v,{cache:"no-cache"});if(!x.ok)return null;let L=await x.text();try{return JSON.parse(L)}catch{return null}},h=await g("configs/flow/app.flow.json");if(!h||typeof h!="object")return;let f=h.screens;if(!f||typeof f!="object")return;let m={},b={};for(let[y,v]of Object.entries(f)){let x=v==null?void 0:v.source;if(typeof x!="string")continue;let L=await g(x),P=L==null?void 0:L.elements;if(!Array.isArray(P))continue;let O=P.map(w=>w==null?void 0:w.instance_id).filter(w=>typeof w=="string");m[y]=O;for(let w of O)b[w]||(b[w]=y)}window.__HANDLER_APP_FLOW=h,window.__HANDLER_SCREEN_INDEX={screenToInstances:m,instanceToScreen:b},window.dispatchEvent(new CustomEvent("handler:screen-index-loaded"))}catch{}}function o(g,h){if(Cl){console.log("[RESPONSIVE] Skipping global scaling; using config-driven layout");return}if(console.log("[RESPONSIVE] ===== APPLYING GLOBAL RESPONSIVE SCALING ====="),console.log(`[RESPONSIVE] Scale multiplier: ${ut.scale.toFixed(3)}`),g.stage){let m=function(b,y=0){if(!b||!b.children)return;let v=" ".repeat(y);b.children.forEach((x,L)=>{if(x&&x.zIndex===9999){console.log(`${v}[RESPONSIVE] Skipping debug border (zIndex 9999)`);return}if(x&&x.scale){let P=x.scale.x||1,O=x.scale.y||1;x.__originalScale||(x.__originalScale={x:P,y:O},console.log(`${v}[RESPONSIVE] Stored original scale for child[${L}]: ${P.toFixed(3)}, ${O.toFixed(3)}`));let w=x.__originalScale.x*ut.scale,k=x.__originalScale.y*ut.scale;typeof x.scale.set=="function"?x.scale.set(w,k):(x.scale.x=w,x.scale.y=k),console.log(`${v}[RESPONSIVE] Child[${L}] scale: ${P.toFixed(3)}\u2192${x.scale.x.toFixed(3)} (type: ${x.constructor.name})`),m(x,y+1)}else x&&console.log(`${v}[RESPONSIVE] Child[${L}] has no scale (type: ${x.constructor.name})`)})};var f=m;console.log("[RESPONSIVE] Applying scale to PIXI stage children"),m(g.stage)}else console.warn("[RESPONSIVE] No app.stage found!");console.log("[REDDEBUG] Debug border left unscaled (fixed boundaries)"),console.log("[RESPONSIVE] ===== GLOBAL RESPONSIVE SCALING COMPLETE =====")}function l(g){if(g!==void 0){ut.scale=g,console.log(`[RESPONSIVE] Updated global scale multiplier to: ${g.toFixed(3)}`);let h=window.gameApp,f=window.gameObjectManager;h&&f?(o(h,f),h.renderer&&(h.renderer.render(h.stage),console.log("[RESPONSIVE] Forced PIXI renderer update"))):console.warn(`[RESPONSIVE] No gameApp (${!!h}) or gameObjectManager (${!!f}) found in window for live update`)}}window.updateGlobalResponsiveMultipliers=l,De.start()},zr=async()=>{var e,t,i,n;console.log("[PREVIEW] Restarting game in 1 seconds...");let s=(e=window.gameObjectManager)==null?void 0:e.get("character_1");if(s){let a=((t=s.getDisplayObject)==null?void 0:t.call(s))||s;a&&a.scale&&console.log(`[CHARACTER] Before restart - Current scale - x: ${((i=a.scale.x)!=null?i:1).toFixed(3)}, y: ${((n=a.scale.y)!=null?n:1).toFixed(3)}`)}if(fe){fe.notifyGameDestroyed();try{$a&&$a()}catch(a){console.warn("Failed to clear responsive elements",a)}setTimeout(()=>{console.log("[PREVIEW] Executing restart...");let a=fe.getGameContainer(),r=window.gameObjectManager;if(r&&typeof r.clear=="function"&&(console.log("[PREVIEW] Clearing old GameObjectManager tickers..."),r.clear()),Re){try{Re.destroy(!0,{children:!0,texture:!1})}catch(o){console.warn("[PREVIEW] Destroy warning:",o)}Re=null}window.gameApp=null,window.gameObjectManager=null,a&&(a.innerHTML="");try{typeof Ut.resetScene=="function"&&Ut.resetScene()}catch(o){console.warn("Asset reset failed",o)}setTimeout(()=>{Se("scene.main").then(o=>{window.__editableConfig=o,window.__editableConfigBaseline||(window.__editableConfigBaseline=Y(o)),Da(a,o,Gt).then(l=>{Re=l.app,window.gameApp=Re,window.gameObjectManager=l.gameObjectManager;try{window.__liveEditBridge=ln({getConfig:()=>window.__editableConfig,gameObjectManager:window.gameObjectManager,assets:Ut})}catch(c){console.warn("[BOOTSTRAP] Failed to re-initialize live-edit bridge",c)}fe&&fe.notifyGameLoaded(),console.log("[PREVIEW] Game restarted successfully");try{De.start()}catch{}})})},100)},1e3)}};xi();K();var me={background:"#F6F3EF",ink:"#1E1E1E",secondaryText:"#8E8A84",primaryAccent:"#E38A5A",secondaryAccent:"#C9A28C",statusGreen:"#5F8F6B"},Nr=1.25,Hr={fontFamily:"Inter, system-ui, sans-serif"};var dn=class{constructor(e={}){this.currentProgress=0;var t;this.currentProgress=(t=e.progress)!=null?t:0,this.container=this.createContainer()}createContainer(){let e=document.createElement("div");e.className="handler-loading-screen",e.style.cssText=`
2488
2488
  position: fixed;
2489
2489
  inset: 0;
2490
2490
  display: flex;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{E as J,F as K,G as L,H as M,I as N,J as O,K as P,L as Q,M as R,N as S,O as T,P as U,Q as V,R as W,S as X,T as Y,U as Z,a}from"./chunk-5XDKSUEE.js";import"./chunk-I5OOVR5U.js";import{a as u,b as v,c as w,d as x,e as y,f as z,g as A,h as B,i as C,j as D,k as E,l as F,m as G,n as H,o as I}from"./chunk-PW2FGMCO.js";import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t}from"./chunk-HVKF2KYL.js";import"./chunk-E6WJCS24.js";import"./chunk-JXBG6UFL.js";export{U as COLORS,F as ConfigWatcher,O as DebugPanel,E as DefaultReloadStrategy,Y as Handler,X as PlayableLoadingScreen,P as PreviewShell,V as STROKE_WIDTH,W as THEME,d as applyConfigOverride,e as applyConfigOverrides,r as applyConfigsToDisk,B as applyDefaults,a as baseLottie,T as bootstrap,f as clearConfigOverrides,g as clearConfigOverridesForObject,j as configOverrideManager,Q as createPreviewShell,o as deepClone,Z as default,L as defaultPreset,K as deviceGroups,J as devicePresets,G as diffConfigs,p as exportConfigsAsJSON,i as getConfigOverrides,q as getConfigStateSummary,b as getOverrideMode,M as getPresetById,N as getPresetsByCategory,w as loadAllObjectConfigs,u as loadComponentSchemas,x as loadEngineConfig,y as loadGamePromptConfig,C as loadObjectCentricConfig,v as loadObjectConfig,z as loadSceneConfig,l as redoLastConfigChange,H as rehydrateObject,h as removeConfigOverride,s as resetToApplied,t as resetToOriginal,S as setBootstrapDependencies,c as setOverrideMode,I as setupHotReload,R as setupLiveEditBridge,D as toLegacyFormat,m as trackObjectCreation,n as trackObjectDeletion,k as undoLastConfigChange,A as validateObjectConfig};
1
+ import{E as J,F as K,G as L,H as M,I as N,J as O,K as P,L as Q,M as R,N as S,O as T,P as U,Q as V,R as W,S as X,T as Y,U as Z,a}from"./chunk-KHEZYZMO.js";import"./chunk-I5OOVR5U.js";import{a as u,b as v,c as w,d as x,e as y,f as z,g as A,h as B,i as C,j as D,k as E,l as F,m as G,n as H,o as I}from"./chunk-PW2FGMCO.js";import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t}from"./chunk-HVKF2KYL.js";import"./chunk-E6WJCS24.js";import"./chunk-JXBG6UFL.js";export{U as COLORS,F as ConfigWatcher,O as DebugPanel,E as DefaultReloadStrategy,Y as Handler,X as PlayableLoadingScreen,P as PreviewShell,V as STROKE_WIDTH,W as THEME,d as applyConfigOverride,e as applyConfigOverrides,r as applyConfigsToDisk,B as applyDefaults,a as baseLottie,T as bootstrap,f as clearConfigOverrides,g as clearConfigOverridesForObject,j as configOverrideManager,Q as createPreviewShell,o as deepClone,Z as default,L as defaultPreset,K as deviceGroups,J as devicePresets,G as diffConfigs,p as exportConfigsAsJSON,i as getConfigOverrides,q as getConfigStateSummary,b as getOverrideMode,M as getPresetById,N as getPresetsByCategory,w as loadAllObjectConfigs,u as loadComponentSchemas,x as loadEngineConfig,y as loadGamePromptConfig,C as loadObjectCentricConfig,v as loadObjectConfig,z as loadSceneConfig,l as redoLastConfigChange,H as rehydrateObject,h as removeConfigOverride,s as resetToApplied,t as resetToOriginal,S as setBootstrapDependencies,c as setOverrideMode,I as setupHotReload,R as setupLiveEditBridge,D as toLegacyFormat,m as trackObjectCreation,n as trackObjectDeletion,k as undoLastConfigChange,A as validateObjectConfig};