handler-playable-sdk 0.3.50 → 0.3.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ZKYTDO2L.js → chunk-YDMSBKAK.js} +2 -2
- package/dist/cli/brand-dna.mjs +1 -1
- package/dist/cli/canva-import.mjs +1 -1
- package/dist/cli/cleanup-assets.mjs +1 -1
- package/dist/cli/fix-scales.mjs +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/screen-helper.mjs +1 -1
- package/dist/cli/setup-library.mjs +1 -1
- package/dist/cli/student-helper.mjs +1 -1
- package/dist/cli/sync-screens.mjs +1 -1
- package/dist/cli/validate-assets.mjs +1 -1
- package/dist/cli/validate.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/pixi/index.cjs +1 -1
- package/dist/pixi/index.js +1 -1
- package/dist/three/index.cjs +1 -1
- package/dist/three/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Mi,d as le,e as _i}from"./chunk-I5OOVR5U.js";import{i as It}from"./chunk-LV4HGC5G.js";import{c as ot,d as Rt,e as Ri,g as Qn,h as Ii,j as Oi,k as ea,l as ta,m as ji,n as Di,o as ia}from"./chunk-ZLL42OOV.js";import{a as Yr}from"./chunk-JXBG6UFL.js";import{Application as Hs}from"pixi.js";var Ce={};function Ot(a,e,t=!1){Ce[a]||(Ce[a]=[]),Ce[a].push({fn:e,once:t})}function zi(a,e){if(Ce[a]){if(!e){delete Ce[a];return}Ce[a]=Ce[a].filter(t=>t.fn!==e)}}function jt(a,...e){let t=Ce[a];if(t)for(let i of[...t])i.fn(...e),i.once&&zi(a,i.fn)}function ee(a,e){Ot(a,e,!0)}var G=null,ne=[],Ne=null;function ra(a){G=a,ne=[],Ne!==null&&(clearTimeout(Ne),Ne=null)}function sa(){var a,e,t;return{endpoint:(G==null?void 0:G.endpoint)||"",transport:(G==null?void 0:G.transport)||"beacon",batchSize:(a=G==null?void 0:G.batchSize)!=null?a:10,flushIntervalMs:(e=G==null?void 0:G.flushIntervalMs)!=null?e:300,maxQueue:(t=G==null?void 0:G.maxQueue)!=null?t:200,debug:!!(G!=null&&G.debug)}}async function na(a,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(a,new Blob([n],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function Hi(a,e){let t=sa();if(e&&t.endpoint){if(ne.push(a),ne.length>t.maxQueue&&(ne=ne.slice(ne.length-t.maxQueue)),ne.length>=t.batchSize){aa();return}Ne===null&&(Ne=window.setTimeout(()=>{Ne=null,aa()},t.flushIntervalMs))}}async function aa(){let a=sa();if(!a.endpoint||ne.length===0)return;let e=ne.splice(0,a.batchSize);await na(a.endpoint,{events:e},a.transport,a.debug),ne.length>0&&await na(a.endpoint,{events:ne.splice(0,a.batchSize)},a.transport,a.debug)}function oa(a){return Math.max(0,Math.min(1,a))}function Wr(a){let e=String(a!=null?a:"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 lt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Kr(a,e){let t=a==null?void 0:a[e];return typeof t=="number"?t:0}function la(a,e,t){try{a[e]=t}catch{}}function Xr(a){let e=a==null?void 0:a.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 ca(a,e){let t=a==null?void 0:a.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 da(a,e){let t=Xr(a);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 pa(){let a=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),a.size>0&&i()})},n=p=>{var u;a.add(p);let d=(u=e.get(p.target))!=null?u:new Set;d.add(p),e.set(p.target,d),i()},r=p=>{a.delete(p);let d=e.get(p.target);d&&(d.delete(p),d.size===0&&e.delete(p.target))},s=p=>{p.killed||(p.killed=!0,r(p))},o=()=>{var d,u;let p=lt();for(let g of Array.from(a)){if(g.killed||g.paused)continue;let f=p-g.startMs-g.delayMs;if(f<0)continue;let h=g.durationMs>0?f/g.durationMs:1,m=oa(h),b=g.repeat>=0?g.repeat+1:1,y=g.repeat>0?Math.min(Math.floor(h),b-1):0;if(g.repeat>0&&h>=1){let w=h-y;m=oa(w)}let v=g.ease(m);g.yoyo&&y%2===1&&(v=1-v);for(let w of g.props)la(g.target,w.key,w.from+(w.to-w.from)*v);g.scaleFrom&&g.scaleTo&&ca(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{(d=g.onUpdate)==null||d.call(g)}catch{}if(h>=b){s(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(p,d,u)=>{var w;let g=Math.max(0,(typeof d.duration=="number"?d.duration:.5)*1e3),f=Math.max(0,(typeof d.delay=="number"?d.delay:0)*1e3+((w=u==null?void 0:u.delayMsOverride)!=null?w:0)),h=Wr(d.ease),m=typeof d.repeat=="number"?Math.max(0,d.repeat|0):0,b=d.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let C of Object.keys(d)){if(y.has(C))continue;let k=d[C];typeof k=="number"&&v.push({key:C,from:Kr(p,C),to:k})}let x=da(p,d);return{target:p,startMs:lt(),delayMs:f,durationMs:g,ease:h,props:v,scaleFrom:x.from,scaleTo:x.to,repeat:m,yoyo:b,onUpdate:typeof d.onUpdate=="function"?d.onUpdate:void 0,onComplete:typeof d.onComplete=="function"?d.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(p,d){let u=l(p,d);return n(u),{kill:()=>s(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=lt())},resume:()=>{var h;if(!u.paused)return;let g=(h=u.pauseAtMs)!=null?h:lt(),f=lt()-g;u.startMs+=f,u.paused=!1,u.pauseAtMs=null},isActive:()=>!u.killed&&!u.paused}},fromTo(p,d,u){return c.set(p,d),c.to(p,u)},set(p,d){if(!p||!d)return;for(let g of Object.keys(d)){let f=d[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof f=="number"&&la(p,g,f)}let u=da(p,d);u.to&&ca(p,u.to)},killTweensOf(p){let d=e.get(p);if(d)for(let u of Array.from(d))s(u)},timeline(p={}){let d=[],u=0,g=!1,f=[],h=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=>{d.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:h(x)}),b},fromTo(y,v,x,w){return m({kind:"fromTo",target:y,vars:x,from:v,atMs:h(w)}),b},play(){var y,v;if(g)return b;g=!0,f=[];for(let x of d)x.kind==="fromTo"&&c.set(x.target,(y=x.from)!=null?y:{}),f.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 f)y.pause();return b},kill(){for(let y of f)y.kill();f=[],g=!1}};return p.paused||b.play(),b}};return c}function ua(){if(typeof window=="undefined")return;let a=window;if(!a.gsap)try{a.gsap=pa()}catch{}}var ga={name:"handler-playable-sdk",version:"0.3.50",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 && 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/ && chmod +x dist/cli/*.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 && 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; 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 te=0,Zr=te++,ha=te++,fa=te++,ma=te++,ba=te++,ya=te++,va=te++,xa=te++,wa=te++,Ea=te++,Aa=te++,Sa=te++,F=Zr;function Ca(){return F===ha}function La(){return F===fa}function Ta(){return F===ma}function ka(){return F===ba}function Fe(){return F===ya}function Ue(){return F===va}function Pa(){return F===xa}function Ma(){return F===wa}function _a(){return F===Ea}function $i(){return F===Aa}function Bi(){return F===Sa}function Ra(){let a=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(a==="mraid")try{mraid.getState(),F=ha;return}catch{}else if(a==="dapi")try{dapi.isReady(),F=fa;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(F=ma)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(F=ba)}catch{}else if(e==="mintegral")window.gameReady&&(F=ya);else if(e==="tapjoy")window.TJ_API&&(F=va);else if(e==="tiktok")window.openAppStore&&(F=xa);else if(e==="smadex")try{window.smxTracking&&(F=wa)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(F=Ea)}catch{}else e==="vungle"?F=Aa:(a==="nucleo"||e==="nucleo")&&(F=Sa)}import Ni from"lottie-web";var Ia=Ni;typeof window!="undefined"&&(window.lottie=Ni,window.__baseLottie=Ni);function q(a,e){let t=(n,r)=>r===0?n:t(r,n%r),i=t(a,e);return`${a/i}:${e/i}`}var Oo=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:q(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:q(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:q(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:q(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:q(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:q(360,780)}],jo=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:q(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:q(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:q(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:q(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:q(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:q(412,915)}],Do=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:q(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:q(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:q(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:q(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:q(800,1280)}],Fi=[{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:q(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:q(768,1024),mraidScale:.7}];var Oa=[...Fi],ja=[{category:"playable",label:"Playable Ad",devices:Fi}],Ui=Fi[0];function Ge(a){return Oa.find(e=>e.id===a)||Ui}function zo(a){return Oa.filter(e=>e.category===a)}var Dt=class{constructor(){this.root=null;this.listContainer=null;this.searchInput=null;this.selectedId=null;this.options=null;this.retryTimer=null;this.screenFilter="all"}getScreenFilterStorageKey(){return`handler_preview_screen_filter::${typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default"}`}render(){return`
|
|
1
|
+
import{c as Mi,d as le,e as _i}from"./chunk-I5OOVR5U.js";import{i as It}from"./chunk-LV4HGC5G.js";import{c as ot,d as Rt,e as Ri,g as Qn,h as Ii,j as Oi,k as ea,l as ta,m as ji,n as Di,o as ia}from"./chunk-ZLL42OOV.js";import{a as Yr}from"./chunk-JXBG6UFL.js";import{Application as Hs}from"pixi.js";var Ce={};function Ot(a,e,t=!1){Ce[a]||(Ce[a]=[]),Ce[a].push({fn:e,once:t})}function zi(a,e){if(Ce[a]){if(!e){delete Ce[a];return}Ce[a]=Ce[a].filter(t=>t.fn!==e)}}function jt(a,...e){let t=Ce[a];if(t)for(let i of[...t])i.fn(...e),i.once&&zi(a,i.fn)}function ee(a,e){Ot(a,e,!0)}var G=null,ne=[],Ne=null;function ra(a){G=a,ne=[],Ne!==null&&(clearTimeout(Ne),Ne=null)}function sa(){var a,e,t;return{endpoint:(G==null?void 0:G.endpoint)||"",transport:(G==null?void 0:G.transport)||"beacon",batchSize:(a=G==null?void 0:G.batchSize)!=null?a:10,flushIntervalMs:(e=G==null?void 0:G.flushIntervalMs)!=null?e:300,maxQueue:(t=G==null?void 0:G.maxQueue)!=null?t:200,debug:!!(G!=null&&G.debug)}}async function na(a,e,t,i){let n=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(a,new Blob([n],{type:"application/json"}));i&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){i&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function Hi(a,e){let t=sa();if(e&&t.endpoint){if(ne.push(a),ne.length>t.maxQueue&&(ne=ne.slice(ne.length-t.maxQueue)),ne.length>=t.batchSize){aa();return}Ne===null&&(Ne=window.setTimeout(()=>{Ne=null,aa()},t.flushIntervalMs))}}async function aa(){let a=sa();if(!a.endpoint||ne.length===0)return;let e=ne.splice(0,a.batchSize);await na(a.endpoint,{events:e},a.transport,a.debug),ne.length>0&&await na(a.endpoint,{events:ne.splice(0,a.batchSize)},a.transport,a.debug)}function oa(a){return Math.max(0,Math.min(1,a))}function Wr(a){let e=String(a!=null?a:"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 lt(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Kr(a,e){let t=a==null?void 0:a[e];return typeof t=="number"?t:0}function la(a,e,t){try{a[e]=t}catch{}}function Xr(a){let e=a==null?void 0:a.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 ca(a,e){let t=a==null?void 0:a.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 da(a,e){let t=Xr(a);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 pa(){let a=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),a.size>0&&i()})},n=p=>{var u;a.add(p);let d=(u=e.get(p.target))!=null?u:new Set;d.add(p),e.set(p.target,d),i()},r=p=>{a.delete(p);let d=e.get(p.target);d&&(d.delete(p),d.size===0&&e.delete(p.target))},s=p=>{p.killed||(p.killed=!0,r(p))},o=()=>{var d,u;let p=lt();for(let g of Array.from(a)){if(g.killed||g.paused)continue;let f=p-g.startMs-g.delayMs;if(f<0)continue;let h=g.durationMs>0?f/g.durationMs:1,m=oa(h),b=g.repeat>=0?g.repeat+1:1,y=g.repeat>0?Math.min(Math.floor(h),b-1):0;if(g.repeat>0&&h>=1){let w=h-y;m=oa(w)}let v=g.ease(m);g.yoyo&&y%2===1&&(v=1-v);for(let w of g.props)la(g.target,w.key,w.from+(w.to-w.from)*v);g.scaleFrom&&g.scaleTo&&ca(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{(d=g.onUpdate)==null||d.call(g)}catch{}if(h>=b){s(g);try{(u=g.onComplete)==null||u.call(g)}catch{}}}},l=(p,d,u)=>{var w;let g=Math.max(0,(typeof d.duration=="number"?d.duration:.5)*1e3),f=Math.max(0,(typeof d.delay=="number"?d.delay:0)*1e3+((w=u==null?void 0:u.delayMsOverride)!=null?w:0)),h=Wr(d.ease),m=typeof d.repeat=="number"?Math.max(0,d.repeat|0):0,b=d.yoyo===!0,y=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let C of Object.keys(d)){if(y.has(C))continue;let k=d[C];typeof k=="number"&&v.push({key:C,from:Kr(p,C),to:k})}let x=da(p,d);return{target:p,startMs:lt(),delayMs:f,durationMs:g,ease:h,props:v,scaleFrom:x.from,scaleTo:x.to,repeat:m,yoyo:b,onUpdate:typeof d.onUpdate=="function"?d.onUpdate:void 0,onComplete:typeof d.onComplete=="function"?d.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(p,d){let u=l(p,d);return n(u),{kill:()=>s(u),pause:()=>{u.paused||(u.paused=!0,u.pauseAtMs=lt())},resume:()=>{var h;if(!u.paused)return;let g=(h=u.pauseAtMs)!=null?h:lt(),f=lt()-g;u.startMs+=f,u.paused=!1,u.pauseAtMs=null},isActive:()=>!u.killed&&!u.paused}},fromTo(p,d,u){return c.set(p,d),c.to(p,u)},set(p,d){if(!p||!d)return;for(let g of Object.keys(d)){let f=d[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof f=="number"&&la(p,g,f)}let u=da(p,d);u.to&&ca(p,u.to)},killTweensOf(p){let d=e.get(p);if(d)for(let u of Array.from(d))s(u)},timeline(p={}){let d=[],u=0,g=!1,f=[],h=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=>{d.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:h(x)}),b},fromTo(y,v,x,w){return m({kind:"fromTo",target:y,vars:x,from:v,atMs:h(w)}),b},play(){var y,v;if(g)return b;g=!0,f=[];for(let x of d)x.kind==="fromTo"&&c.set(x.target,(y=x.from)!=null?y:{}),f.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 f)y.pause();return b},kill(){for(let y of f)y.kill();f=[],g=!1}};return p.paused||b.play(),b}};return c}function ua(){if(typeof window=="undefined")return;let a=window;if(!a.gsap)try{a.gsap=pa()}catch{}}var ga={name:"handler-playable-sdk",version:"0.3.51",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 && 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/ && chmod +x dist/cli/*.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 && 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; 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 te=0,Zr=te++,ha=te++,fa=te++,ma=te++,ba=te++,ya=te++,va=te++,xa=te++,wa=te++,Ea=te++,Aa=te++,Sa=te++,F=Zr;function Ca(){return F===ha}function La(){return F===fa}function Ta(){return F===ma}function ka(){return F===ba}function Fe(){return F===ya}function Ue(){return F===va}function Pa(){return F===xa}function Ma(){return F===wa}function _a(){return F===Ea}function $i(){return F===Aa}function Bi(){return F===Sa}function Ra(){let a=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(a==="mraid")try{mraid.getState(),F=ha;return}catch{}else if(a==="dapi")try{dapi.isReady(),F=fa;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(F=ma)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(F=ba)}catch{}else if(e==="mintegral")window.gameReady&&(F=ya);else if(e==="tapjoy")window.TJ_API&&(F=va);else if(e==="tiktok")window.openAppStore&&(F=xa);else if(e==="smadex")try{window.smxTracking&&(F=wa)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(F=Ea)}catch{}else e==="vungle"?F=Aa:(a==="nucleo"||e==="nucleo")&&(F=Sa)}import Ni from"lottie-web";var Ia=Ni;typeof window!="undefined"&&(window.lottie=Ni,window.__baseLottie=Ni);function q(a,e){let t=(n,r)=>r===0?n:t(r,n%r),i=t(a,e);return`${a/i}:${e/i}`}var Oo=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:q(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:q(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:q(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:q(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:q(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:q(360,780)}],jo=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:q(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:q(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:q(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:q(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:q(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:q(412,915)}],Do=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:q(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:q(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:q(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:q(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:q(800,1280)}],Fi=[{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:q(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:q(768,1024),mraidScale:.7}];var Oa=[...Fi],ja=[{category:"playable",label:"Playable Ad",devices:Fi}],Ui=Fi[0];function Ge(a){return Oa.find(e=>e.id===a)||Ui}function zo(a){return Oa.filter(e=>e.category===a)}var Dt=class{constructor(){this.root=null;this.listContainer=null;this.searchInput=null;this.selectedId=null;this.options=null;this.retryTimer=null;this.screenFilter="all"}getScreenFilterStorageKey(){return`handler_preview_screen_filter::${typeof window!="undefined"&&window.__HANDLER_PROJECT_ID||"default"}`}render(){return`
|
|
2
2
|
<div class="scene-panel scene-objects panel-accent-teal" data-panel="scene-objects" style="left:16px; top:72px;">
|
|
3
3
|
<div class="scene-panel-header" data-panel-handle>
|
|
4
4
|
<div class="panel-title">
|
|
@@ -1444,7 +1444,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=n,this.currentPrompt=n}}c
|
|
|
1444
1444
|
<div class="console-messages" id="console-messages"></div>
|
|
1445
1445
|
</div>
|
|
1446
1446
|
</div>
|
|
1447
|
-
`,this.setupEventListeners(e),e}setupEventListeners(e){var n,r,s,o,l,c,p,d,u,g;let t=e.querySelector("#device-select");t==null||t.addEventListener("change",f=>{if(this.viewMode==="compare")return;let h=f.target.value;this.setDevice(h)}),Array.from(e.querySelectorAll("[data-view-toggle]")).forEach(f=>{f.addEventListener("click",()=>{let h=f.dataset.viewToggle;h&&this.setViewMode(h)})}),(n=e.querySelector("#rotate-btn"))==null||n.addEventListener("click",()=>this.toggleRotation()),(r=e.querySelector("#zoom-in-btn"))==null||r.addEventListener("click",()=>this.adjustUserZoom(.1)),(s=e.querySelector("#zoom-out-btn"))==null||s.addEventListener("click",()=>this.adjustUserZoom(-.1)),(o=e.querySelector("#refresh-btn"))==null||o.addEventListener("click",()=>this.refresh()),(l=e.querySelector("#console-toggle"))==null||l.addEventListener("click",()=>this.toggleConsole()),(c=e.querySelector("#console-close"))==null||c.addEventListener("click",()=>this.toggleConsole(!1)),(p=e.querySelector("#console-clear"))==null||p.addEventListener("click",()=>this.clearConsole()),(d=e.querySelector("#corner-zoom-in-btn"))==null||d.addEventListener("click",()=>this.adjustUserZoom(.1)),(u=e.querySelector("#corner-zoom-out-btn"))==null||u.addEventListener("click",()=>this.adjustUserZoom(-.1)),(g=e.querySelector("#corner-grab-btn"))==null||g.addEventListener("click",()=>{this.frameDragger.style.cursor="grab",setTimeout(()=>{this.isSpaceKeyPressed||(this.frameDragger.style.cursor="")},1e3)})}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:"0 20px 50px rgba(0,0,0,0.5)",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.gameReady||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),r=Math.max(0,i.height);if(n<=0||r<=0)return;this.applyPresetDimensions(),this.viewMode==="compare"&&this.applyCompareDimensions();let s=n/t.width,o=r/t.height;if(this.autoScale=Math.max(.01,Math.min(s,o)),!this.hasInitialFit){this.hasInitialFit=!0;let l=.6;this.userScaleMultiplier=l/this.autoScale}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(){var r;if(!this.gameReady||this.viewMode==="compare")return;let e=this.frameWrapper.getBoundingClientRect(),t=(r=this.container.querySelector(".preview-main"))==null?void 0:r.getBoundingClientRect();if(!t)return;let i=this.container.querySelector("#scene-tools-container");if(i&&i.children.length>0){let o=e.left-t.left+e.width/2,l=e.top-t.top-16;i.style.position="absolute",i.style.left=`${o}px`,i.style.top=`${Math.max(16,l)}px`,i.style.transform="translate(-50%, -100%)",i.style.zIndex="100"}let n=this.container.querySelector("#nudge-panel-container");if(n&&n.children.length>0){let o=e.left-t.left-16,l=e.top-t.top+e.height/2;n.style.position="absolute",n.style.left=`${Math.max(16,o)}px`,n.style.top=`${l}px`,n.style.transform="translate(-100%, -50%)",n.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}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.autoScale*this.userScaleMultiplier;this.isLandscape=!this.isLandscape,this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale: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,r)=>{if(typeof r=="object"&&r!==null){if(t.has(r))return"[Circular]";t.add(r)}return r},2)}catch{try{if(e&&((i=e.constructor)!=null&&i.name))return`[object ${e.constructor.name}]`}catch{}return String(e)}}setupConsoleInterceptor(){let e=console.log.bind(console),t=console.warn.bind(console),i=console.error.bind(console),n=console.info.bind(console),r=(s,...o)=>{let l=o.map(p=>typeof p=="object"?this.safeStringify(p):String(p)).join(" ");this.consoleMessages.push({type:s,message:l,timestamp:new Date}),this.appendConsoleMessage(this.consoleMessages[this.consoleMessages.length-1]);let c=this.container.querySelector("#console-badge");if(c){let p=this.consoleMessages.filter(d=>d.type==="error").length;c.textContent=p>0?`${p}!`:"0",c.classList.toggle("has-errors",p>0)}};console.log=(...s)=>{e(...s),r("log",...s)},console.warn=(...s)=>{t(...s),r("warn",...s)},console.error=(...s)=>{i(...s),r("error",...s)},console.info=(...s)=>{n(...s),r("info",...s)}}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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}toggleConsole(e){var t;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(d=>d.id===i);if(!n)return;let r=t.querySelector("[data-compare-slot]"),s=t.querySelector("[data-compare-ghost]"),o=t.querySelector("[data-compare-wrapper]"),l=t.querySelector("[data-compare-frame]"),c=t.querySelector("[data-compare-snapshot]"),p=t.querySelector("[data-compare-focus]");!r||!s||!o||!l||(t.addEventListener("click",d=>{let u=d.target;if(u!=null&&u.closest("[data-compare-focus]")){d.preventDefault(),this.activateCompareViewport(i);return}t.classList.contains("is-active")||this.activateCompareViewport(i)}),this.compareViewports.set(i,{preset:n,root:t,slot:r,ghost:s,wrapper:o,frame:l,canvas:c,focus:p}))})}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");if(i&&(i.disabled=e==="compare"),this.updateViewToggleUI(),e==="compare"){this.lastSinglePresetId=this.currentPreset.id,this.activateCompareViewport(this.activeCompareId),this.refreshCompareSnapshots(),this.startCompareSnapshots();return}this.stopCompareSnapshots(),this.singleStage.appendChild(this.frameDragger),this.setDevice(this.lastSinglePresetId,{suppressCallback:!0}),this.fitToScreen()}updateViewToggleUI(){Array.from(this.container.querySelectorAll("[data-view-toggle]")).forEach(t=>{t.classList.toggle("active",t.dataset.viewToggle===this.viewMode)})}activateCompareViewport(e){var r,s;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}),(s=(r=this.options).onDeviceChange)==null||s.call(r,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 r=i/e.preset.width,s=n/e.preset.height,o=Math.max(.01,Math.min(r,s));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 r=t.canvas.width,s=t.canvas.height,o=Math.min(r/i.width,s/i.height),l=i.width*o,c=i.height*o,p=(r-l)/2,d=(s-c)/2;n.clearRect(0,0,r,s),n.drawImage(i,p,d,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")return{width:this.previewContainer.clientWidth-40,height:this.previewContainer.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 wr(a={}){let e=new yn(a);return typeof window!="undefined"&&(window.__previewShell=e),e.mount(),e}import{Sprite as ys,Container as Er}from"pixi.js";var vs=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",vn=vs;if(typeof window!="undefined")try{let a=new XMLHttpRequest;if(a.open("GET","./build-settings.json",!1),a.send(),a.status===200&&a.responseText){let e=JSON.parse(a.responseText);e!=null&&e.buildMode&&(vn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${vn}`))}}catch{}function xs(a){var t,i,n,r,s;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(a);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(a))return{x:(t=a[0])!=null?t:.5,y:(i=a[1])!=null?i:.5};if(a&&typeof a=="object"&&"x"in a&&"y"in a)return{x:(n=a.x)!=null?n:.5,y:(r=a.y)!=null?r:.5};if(typeof a=="string"){let o=a.trim().toLowerCase();return(s=e[o])!=null?s:{x:.5,y:.5}}return null}var ke=class{static async create(e,t,i){var l,c,p,d,u,g,f;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${vn}`);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 h=new Er;return this.applyTransform(h,t==null?void 0:t.transform,t),h}let r=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${n.type}, path: ${n.path}`);let s=await Mi.load(e,n,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(p=s==null?void 0:s.constructor)==null?void 0:p.name}`);let o;if(n.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",e),o=new ys(s),console.log("[ObjectFactory] Created object:",o,"type:",(d=o==null?void 0:o.constructor)==null?void 0:d.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=s==null?void 0:s.constructor)==null?void 0:u.name,s),s&&(((g=s.constructor)==null?void 0:g.name)==="Container"||s instanceof Er)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[n.path,`/assets/${n.path}`,`assets/${n.path}`,`../assets/${n.path}`],m=!1;for(let b of h)try{let y=await fetch(b);if(y.ok){o=await y.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(f=o==null?void 0:o.constructor)==null?void 0:f.name),m=!0;break}}catch{continue}m||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=s)}else o=s;else o=s,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,r,s,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(n=t.position.x)!=null?n:0,e.y=(r=t.position.y)!=null?r:0):"position"in e&&e.position&&e.position.set((s=t.position.x)!=null?s: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=xs(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};function xn(a){try{if(a&&typeof a.keys=="function")return Array.from(a.keys())}catch{}return[]}function Ar(a){var e;return a?((e=a.getDisplayObject)==null?void 0:e.call(a))||a.pixiObject||a:null}function ws(a,e){if(!a||!(e!=null&&e.interaction))return;let t=e.interaction,i=t.enabled!==!1&&(t.draggable===!0||t.clickable===!0);a.eventMode=i?"static":"none",a.interactive=i,i&&(a.cursor=t.draggable?"move":"pointer")}function Sr(a,e){var l,c,p,d,u;if(!a||!e)return;let t=e.transform||{};ws(a,e);let i=t.position||{},n=t.offset||{},r=(typeof i.x=="number"?i.x:0)+(typeof n.x=="number"?n.x:0),s=(typeof i.y=="number"?i.y:0)+(typeof n.y=="number"?n.y:0);(l=a.position)!=null&&l.set?a.position.set(r,s):(typeof a.x=="number"&&(a.x=r),typeof a.y=="number"&&(a.y=s)),typeof t.scale=="number"&&((c=a.scale)!=null&&c.set?a.scale.set(t.scale):a.scale&&(a.scale.x=t.scale,a.scale.y=t.scale));let o=(d=t.anchor)!=null?d:(p=e.render)==null?void 0:p.anchor;o&&((u=a.anchor)!=null&&u.set)&&typeof o.x=="number"&&typeof o.y=="number"&&a.anchor.set(o.x,o.y)}function Cr(a){if(typeof window=="undefined")return;let e=a==null?void 0:a.objects,t=xn(e),i=r=>{try{let s=window.__HANDLER_ACTIVE_SCREEN;if(!s||s==="all")return r;let o=window.__HANDLER_SCREEN_INDEX,l=o==null?void 0:o.instanceToScreen;return l?r.filter(c=>l[c]===s):r}catch{return r}};window.__editableObjectConfigs=e;let n=new Map;t.forEach(r=>n.set(r,[r])),window.__editableObjectInstances=n,window.refreshEditableConfigIndex=()=>Cr(window.__editableConfig),window.getEditableObjectList=()=>{var r;return i(xn((r=window.__editableConfig)==null?void 0:r.objects))},window.getEditableObjectListAll=()=>{var r;return xn((r=window.__editableConfig)==null?void 0:r.objects)},window.getEditableObjectConfig=r=>{var p,d,u,g,f;let s=(g=(u=(d=(p=window.__editableConfig)==null?void 0:p.objects)==null?void 0:d.get)==null?void 0:u.call(d,r))!=null?g:null,o=window.__HANDLER_ACTIVE_SCREEN;if(!o||o==="all")return s;let l=window.__HANDLER_SCREEN_INDEX,c=(f=l==null?void 0:l.instanceToScreen)==null?void 0:f[r];return c&&c===o?s:null},window.getEditableEngineConfig=()=>{let r=window.__editableConfig;if(console.log("[BRIDGE] getEditableEngineConfig called, cfg present:",!!r),!r)return null;if(r.engine&&r.objects instanceof Map){console.log("[BRIDGE] Detected ObjectCentricConfig, flattening...");let s={...r.engine,objects:r.objects,scene:r.scene};return console.log("[BRIDGE] Returned assets:",Object.keys(s.assets||{})),s}return r}}function Es(){if(typeof window=="undefined")return;let a=t=>{let i=String(t||"").trim();return i?/^(data:|blob:|https?:)/.test(i)||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`:""},e=async(t,i)=>{var r,s,o;let n=a(i);if(n)try{let[{Assets:l},{AssetTextures:c}]=await Promise.all([import("pixi.js"),import("./AssetTextures-67BIZDFD.js")]),p=Date.now(),d=/^(data:|blob:)/.test(n)?n:n+(n.includes("?")?`&t=${p}`:`?t=${p}`),u=await l.load(d);if(!u)return;c[t]=u;let g=window.CustomAssets;(r=g==null?void 0:g[t])!=null&&r.texture&&(g[t].texture=u);let f=window.gameObjectManager,h=(s=f==null?void 0:f.get)==null?void 0:s.call(f,t);if(h){let m=((o=h.getDisplayObject)==null?void 0:o.call(h))||h.pixiObject||h.pixi||h;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=Ii();Array.isArray(i)&&i.length&&(window.__editableConfig=t,Rt(i,{silent:!0,persist:!1}))}catch{}},window.applyEngineOverrides=t=>{try{let i=Ii();Array.isArray(i)&&i.length&&(window.__editableConfig=t,Rt(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[r,s]of Object.entries(t.runtime))n.push({path:`runtime.${r}`,value:s});if(t.assets)for(let[r,s]of Object.entries(t.assets))n.push({path:`assets.${r}`,value:s}),typeof s=="string"&&e(r,s);if(t.splash)for(let[r,s]of Object.entries(t.splash))n.push({path:`splash.${r}`,value:s});if(t.loading)for(let[r,s]of Object.entries(t.loading))n.push({path:`loading.${r}`,value:s});if(t.start)for(let[r,s]of Object.entries(t.start))n.push({path:`start.${r}`,value:s});n.length&&Rt(n,{silent:!0,persist:!0,emitEvent:!0})}}function wn(a){let{getConfig:e,gameObjectManager:t,onObjectConfigApplied:i}=a;t&&(t.onObjectRebuildRequired=async(r,s)=>{console.log(`[LIVE-EDIT] \u{1F3D7}\uFE0F Rebuilding object ${r} due to type change...`);let o=t.get(r),l=o==null?void 0:o.pixiObject,c=l==null?void 0:l.parent,p=c==null?void 0:c.children.indexOf(l);o?t.remove(r):l&&l.destroy();let d=window.gameApp,u=await ke.create(r,s,d);c&&(p!==void 0&&p!==-1?c.addChildAt(u,p):c.addChild(u));let g=t.create(r,u);return console.log(`[LIVE-EDIT] \u2705 Rebuild complete for ${r}`),g}),typeof window!="undefined"&&(Es(),window.applyEditableObjectConfig=(r,s)=>{var o,l,c;console.log("[LIVE-EDIT] \u{1F504} applyEditableObjectConfig called for:",r);try{let p=window.__editableConfig;(o=p==null?void 0:p.objects)!=null&&o.set&&(p.objects.set(r,s),console.log("[LIVE-EDIT] \u2705 Updated config in __editableConfig"));let d=(l=t==null?void 0:t.get)==null?void 0:l.call(t,r);if(console.log("[LIVE-EDIT] gameObject found?",!!d),d&&(console.log("[LIVE-EDIT] gameObject type:",(c=d.constructor)==null?void 0:c.name),console.log("[LIVE-EDIT] has updateConfig?",typeof d.updateConfig=="function"),console.log("[LIVE-EDIT] has onConfigUpdate?",typeof d.onConfigUpdate=="function")),d&&typeof d.updateConfig=="function")console.log("[LIVE-EDIT] \u2705 Calling updateConfig()"),d.updateConfig(s);else if(d&&typeof d.onConfigUpdate=="function")console.log("[LIVE-EDIT] \u2705 Calling onConfigUpdate()"),d.onConfigUpdate();else{console.log("[LIVE-EDIT] \u26A0\uFE0F No updateConfig or onConfigUpdate, applying transform directly");let u=Ar(d);Sr(u,s)}}catch(p){console.error("[LIVE-EDIT] \u274C Error in applyEditableObjectConfig:",p)}});let n={async applyObjectConfig(r,s){var p,d;console.log("[BRIDGE] \u{1F504} applyObjectConfig called for:",r);let o=e();(p=o==null?void 0:o.objects)!=null&&p.set&&(o.objects.set(r,s),console.log("[BRIDGE] \u2705 Updated config"));let l=(d=t==null?void 0:t.get)==null?void 0:d.call(t,r);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(s);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=Ar(l);Sr(u,s)}let c=[r];i==null||i(r,s,c)},rebuildIndexes(){let r=e();typeof window!="undefined"&&(window.__editableConfig=r,Cr(r))}};return n.rebuildIndexes(),n}import As from"lottie-web";Cn(Ia);typeof window!="undefined"&&!window.lottie&&(window.lottie=As);var Ke=null,Ss=async()=>{if(!Ke){let a=typeof window!="undefined"?window.INLINE_ASSETS:null,e=(a==null?void 0:a["handler.config"])||(a==null?void 0:a["handler.config.json"]);if(e)try{if(e.startsWith("data:")){let i=atob(e.split(",")[1]);Ke=JSON.parse(i)}else Ke=JSON.parse(e);return Ke}catch(i){console.warn("[CONFIG] Failed to parse inline handler.config.json:",i)}Ke=await(await fetch("./handler.config.json")).json()}return Ke},Ln,gt,kr,Xe,An,Sn;function ld(a){Ln=a.initGame,gt=a.CustomAssets,kr=a.updateScreenState,Xe=a.globalResponsiveMultipliers,An=a.layout,Sn=a.clearResponsiveElements}var ui="web_embed",ut="https://example.com",Lr={profile_id:ui},Pe=null,ce=null,En={width:0,height:0},Cs=!0,cd=async()=>{var c,p,d,u;document.title="Handler Pixi Game";let a=await Ss();Lr={...a.ids||{},profile_id:ui},ut=a.destination_url||((p=(c=a.export_profiles)==null?void 0:c[ui])==null?void 0:p.destination_url)||ut,me.init({ids:Lr,profile:ui,destinationUrl:ut});let e=me.getRoot();if(typeof __PREVIEW_SHELL__!="undefined"&&__PREVIEW_SHELL__){console.log("[BOOTSTRAP] Initializing Preview Shell..."),ce=wr({onDeviceChange:f=>{console.log(`[PREVIEW] Device switched to ${f.width}x${f.height}, restarting game...`),Tr()},onRefresh:Tr});let g=ce.getGameContainer();g&&(e=g),window.addEventListener("handler-preview:screen",f=>{var v,x,w,C,k,P,O,j,T,E,S;let h=window.gameApp,m=window.gameObjectManager,{width:b,height:y}=f.detail;if(En.width=b,En.height=y,kr(b,y),!(!h||!h.renderer)){m&&o(h,m);try{h.renderer.resize(b,y);let A=h.view;A&&(A.style.width="100%",A.style.height="100%",A.style.display="block")}catch(A){console.warn("[SCREEN] Error resizing renderer:",A);return}if(t&&m&&An)try{let A=(v=window.__mainContainer)!=null?v:h.stage,M=(O=(P=(C=window.__tutorialLabel)!=null?C:(w=(x=m.get("label_1"))==null?void 0:x.getDisplayObject)==null?void 0:w.call(x))!=null?P:(k=m.get("label_1"))==null?void 0:k.pixiObject)!=null?O:m.get("label_1"),I=m.get("background_1"),D=(S=(E=(T=window.__background)!=null?T:(j=I==null?void 0:I.getDisplayObject)==null?void 0:j.call(I))!=null?E:I==null?void 0:I.pixiObject)!=null?S:I;if(A){let L=A===h.stage;An({mainContainer:A,label:M,background:D,backgroundTexture:(D==null?void 0:D.texture)||null,app:h},t,0,En,m,{skipMainContainerTransform:L})}}catch(A){console.warn("[SCREEN] Error in layout:",A)}}})}let t=await It("scene.main");window.__editableConfig=t,s(),window.__editableConfigBaseline||(window.__editableConfigBaseline=Oi(t),console.log("[BOOTSTRAP] Frozen config baseline for persistence")),(u=(d=t.engine.runtime)==null?void 0:d.layout)!=null&&u.design_width_portrait||(console.warn("[BOOTSTRAP] Config layout missing, retrying..."),await new Promise(g=>setTimeout(g,100)),t=await It("scene.main"));let i=await Ln(e,t,ut,ce);Pe=i.app;let n=i.gameObjectManager;window.gameApp=Pe,window.gameObjectManager=n;try{window.__liveEditBridge=wn({getConfig:()=>window.__editableConfig,gameObjectManager:n,assets:gt})}catch(g){console.warn("[BOOTSTRAP] Failed to initialize live-edit bridge",g)}ce&&ce.notifyGameLoaded();let r=window.__debugScale;r&&typeof r=="number"&&(Xe.scale=r,console.log(`[DEBUG] Applied persisted debug scale: ${r}`)),o(Pe,n);async function s(){try{let g=async y=>{let v=y.startsWith("/")?y:`/${y}`,x=await fetch(v,{cache:"no-cache"});if(!x.ok)return null;let w=await x.text();try{return JSON.parse(w)}catch{return null}},f=await g("configs/flow/app.flow.json");if(!f||typeof f!="object")return;let h=f.screens;if(!h||typeof h!="object")return;let m={},b={};for(let[y,v]of Object.entries(h)){let x=v==null?void 0:v.source;if(typeof x!="string")continue;let w=await g(x),C=w==null?void 0:w.elements;if(!Array.isArray(C))continue;let k=C.map(P=>P==null?void 0:P.instance_id).filter(P=>typeof P=="string");m[y]=k;for(let P of k)b[P]||(b[P]=y)}window.__HANDLER_APP_FLOW=f,window.__HANDLER_SCREEN_INDEX={screenToInstances:m,instanceToScreen:b},window.dispatchEvent(new CustomEvent("handler:screen-index-loaded"))}catch{}}function o(g,f){if(Cs){console.log("[RESPONSIVE] Skipping global scaling; using config-driven layout");return}if(console.log("[RESPONSIVE] ===== APPLYING GLOBAL RESPONSIVE SCALING ====="),console.log(`[RESPONSIVE] Scale multiplier: ${Xe.scale.toFixed(3)}`),g.stage){let m=function(b,y=0){if(!b||!b.children)return;let v=" ".repeat(y);b.children.forEach((x,w)=>{if(x&&x.zIndex===9999){console.log(`${v}[RESPONSIVE] Skipping debug border (zIndex 9999)`);return}if(x&&x.scale){let C=x.scale.x||1,k=x.scale.y||1;x.__originalScale||(x.__originalScale={x:C,y:k},console.log(`${v}[RESPONSIVE] Stored original scale for child[${w}]: ${C.toFixed(3)}, ${k.toFixed(3)}`));let P=x.__originalScale.x*Xe.scale,O=x.__originalScale.y*Xe.scale;typeof x.scale.set=="function"?x.scale.set(P,O):(x.scale.x=P,x.scale.y=O),console.log(`${v}[RESPONSIVE] Child[${w}] scale: ${C.toFixed(3)}\u2192${x.scale.x.toFixed(3)} (type: ${x.constructor.name})`),m(x,y+1)}else x&&console.log(`${v}[RESPONSIVE] Child[${w}] has no scale (type: ${x.constructor.name})`)})};var h=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){Xe.scale=g,console.log(`[RESPONSIVE] Updated global scale multiplier to: ${g.toFixed(3)}`);let f=window.gameApp,h=window.gameObjectManager;f&&h?(o(f,h),f.renderer&&(f.renderer.render(f.stage),console.log("[RESPONSIVE] Forced PIXI renderer update"))):console.warn(`[RESPONSIVE] No gameApp (${!!f}) or gameObjectManager (${!!h}) found in window for live update`)}}window.updateGlobalResponsiveMultipliers=l,me.start()},Tr=async()=>{var e,t,i,n;console.log("[PREVIEW] Restarting game in 1 seconds...");let a=(e=window.gameObjectManager)==null?void 0:e.get("character_1");if(a){let r=((t=a.getDisplayObject)==null?void 0:t.call(a))||a;r&&r.scale&&console.log(`[CHARACTER] Before restart - Current scale - x: ${((i=r.scale.x)!=null?i:1).toFixed(3)}, y: ${((n=r.scale.y)!=null?n:1).toFixed(3)}`)}if(ce){ce.notifyGameDestroyed();try{Sn&&Sn()}catch(r){console.warn("Failed to clear responsive elements",r)}setTimeout(()=>{console.log("[PREVIEW] Executing restart...");let r=ce.getGameContainer(),s=window.gameObjectManager;if(s&&typeof s.clear=="function"&&(console.log("[PREVIEW] Clearing old GameObjectManager tickers..."),s.clear()),Pe){try{Pe.destroy(!0,{children:!0,texture:!1})}catch(o){console.warn("[PREVIEW] Destroy warning:",o)}Pe=null}window.gameApp=null,window.gameObjectManager=null,r&&(r.innerHTML="");try{typeof gt.resetScene=="function"&>.resetScene()}catch(o){console.warn("Asset reset failed",o)}setTimeout(()=>{It("scene.main").then(o=>{window.__editableConfig=o,window.__editableConfigBaseline||(window.__editableConfigBaseline=Oi(o)),Ln(r,o,ut).then(l=>{Pe=l.app,window.gameApp=Pe,window.gameObjectManager=l.gameObjectManager;try{window.__liveEditBridge=wn({getConfig:()=>window.__editableConfig,gameObjectManager:window.gameObjectManager,assets:gt})}catch(c){console.warn("[BOOTSTRAP] Failed to re-initialize live-edit bridge",c)}ce&&ce.notifyGameLoaded(),console.log("[PREVIEW] Game restarted successfully");try{me.start()}catch{}})})},100)},1e3)}};var be={background:"#F6F3EF",ink:"#1E1E1E",secondaryText:"#8E8A84",primaryAccent:"#E38A5A",secondaryAccent:"#C9A28C",statusGreen:"#5F8F6B"},Ls=1.25,Ts={fontFamily:"Inter, system-ui, sans-serif"};var Tn=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=`
|
|
1447
|
+
`,this.setupEventListeners(e),e}setupEventListeners(e){var n,r,s,o,l,c,p,d,u,g;let t=e.querySelector("#device-select");t==null||t.addEventListener("change",f=>{if(this.viewMode==="compare")return;let h=f.target.value;this.setDevice(h)}),Array.from(e.querySelectorAll("[data-view-toggle]")).forEach(f=>{f.addEventListener("click",()=>{let h=f.dataset.viewToggle;h&&this.setViewMode(h)})}),(n=e.querySelector("#rotate-btn"))==null||n.addEventListener("click",()=>this.toggleRotation()),(r=e.querySelector("#zoom-in-btn"))==null||r.addEventListener("click",()=>this.adjustUserZoom(.1)),(s=e.querySelector("#zoom-out-btn"))==null||s.addEventListener("click",()=>this.adjustUserZoom(-.1)),(o=e.querySelector("#refresh-btn"))==null||o.addEventListener("click",()=>this.refresh()),(l=e.querySelector("#console-toggle"))==null||l.addEventListener("click",()=>this.toggleConsole()),(c=e.querySelector("#console-close"))==null||c.addEventListener("click",()=>this.toggleConsole(!1)),(p=e.querySelector("#console-clear"))==null||p.addEventListener("click",()=>this.clearConsole()),(d=e.querySelector("#corner-zoom-in-btn"))==null||d.addEventListener("click",()=>this.adjustUserZoom(.1)),(u=e.querySelector("#corner-zoom-out-btn"))==null||u.addEventListener("click",()=>this.adjustUserZoom(-.1)),(g=e.querySelector("#corner-grab-btn"))==null||g.addEventListener("click",()=>{this.frameDragger.style.cursor="grab",setTimeout(()=>{this.isSpaceKeyPressed||(this.frameDragger.style.cursor="")},1e3)})}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:"0 20px 50px rgba(0,0,0,0.5)",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.gameReady||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),r=Math.max(0,i.height);if(n<=0||r<=0)return;this.applyPresetDimensions(),this.viewMode==="compare"&&this.applyCompareDimensions();let s=n/t.width,o=r/t.height;if(this.autoScale=Math.max(.01,Math.min(s,o)),!this.hasInitialFit){this.hasInitialFit=!0;let l=.6;this.userScaleMultiplier=l/this.autoScale}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(){var r;if(!this.gameReady||this.viewMode==="compare")return;let e=this.frameWrapper.getBoundingClientRect(),t=(r=this.container.querySelector(".preview-main"))==null?void 0:r.getBoundingClientRect();if(!t)return;let i=this.container.querySelector("#scene-tools-container");if(i&&i.children.length>0){let o=e.left-t.left+e.width/2,l=e.top-t.top-32;i.style.position="absolute",i.style.left=`${o}px`,i.style.top=`${Math.max(32,l)}px`,i.style.transform="translate(-50%, -100%)",i.style.zIndex="100"}let n=this.container.querySelector("#nudge-panel-container");if(n&&n.children.length>0){let o=e.left-t.left-32,l=e.top-t.top+e.height/2;n.style.position="absolute",n.style.left=`${Math.max(32,o)}px`,n.style.top=`${l}px`,n.style.transform="translate(-100%, -50%)",n.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}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.autoScale*this.userScaleMultiplier;this.isLandscape=!this.isLandscape,this.applyPresetDimensions(),this.fitToScreen({keepVisibleScale: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,r)=>{if(typeof r=="object"&&r!==null){if(t.has(r))return"[Circular]";t.add(r)}return r},2)}catch{try{if(e&&((i=e.constructor)!=null&&i.name))return`[object ${e.constructor.name}]`}catch{}return String(e)}}setupConsoleInterceptor(){let e=console.log.bind(console),t=console.warn.bind(console),i=console.error.bind(console),n=console.info.bind(console),r=(s,...o)=>{let l=o.map(p=>typeof p=="object"?this.safeStringify(p):String(p)).join(" ");this.consoleMessages.push({type:s,message:l,timestamp:new Date}),this.appendConsoleMessage(this.consoleMessages[this.consoleMessages.length-1]);let c=this.container.querySelector("#console-badge");if(c){let p=this.consoleMessages.filter(d=>d.type==="error").length;c.textContent=p>0?`${p}!`:"0",c.classList.toggle("has-errors",p>0)}};console.log=(...s)=>{e(...s),r("log",...s)},console.warn=(...s)=>{t(...s),r("warn",...s)},console.error=(...s)=>{i(...s),r("error",...s)},console.info=(...s)=>{n(...s),r("info",...s)}}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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}toggleConsole(e){var t;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(d=>d.id===i);if(!n)return;let r=t.querySelector("[data-compare-slot]"),s=t.querySelector("[data-compare-ghost]"),o=t.querySelector("[data-compare-wrapper]"),l=t.querySelector("[data-compare-frame]"),c=t.querySelector("[data-compare-snapshot]"),p=t.querySelector("[data-compare-focus]");!r||!s||!o||!l||(t.addEventListener("click",d=>{let u=d.target;if(u!=null&&u.closest("[data-compare-focus]")){d.preventDefault(),this.activateCompareViewport(i);return}t.classList.contains("is-active")||this.activateCompareViewport(i)}),this.compareViewports.set(i,{preset:n,root:t,slot:r,ghost:s,wrapper:o,frame:l,canvas:c,focus:p}))})}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");if(i&&(i.disabled=e==="compare"),this.updateViewToggleUI(),e==="compare"){this.lastSinglePresetId=this.currentPreset.id,this.activateCompareViewport(this.activeCompareId),this.refreshCompareSnapshots(),this.startCompareSnapshots();return}this.stopCompareSnapshots(),this.singleStage.appendChild(this.frameDragger),this.setDevice(this.lastSinglePresetId,{suppressCallback:!0}),this.fitToScreen()}updateViewToggleUI(){Array.from(this.container.querySelectorAll("[data-view-toggle]")).forEach(t=>{t.classList.toggle("active",t.dataset.viewToggle===this.viewMode)})}activateCompareViewport(e){var r,s;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}),(s=(r=this.options).onDeviceChange)==null||s.call(r,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 r=i/e.preset.width,s=n/e.preset.height,o=Math.max(.01,Math.min(r,s));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 r=t.canvas.width,s=t.canvas.height,o=Math.min(r/i.width,s/i.height),l=i.width*o,c=i.height*o,p=(r-l)/2,d=(s-c)/2;n.clearRect(0,0,r,s),n.drawImage(i,p,d,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")return{width:this.previewContainer.clientWidth-40,height:this.previewContainer.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 wr(a={}){let e=new yn(a);return typeof window!="undefined"&&(window.__previewShell=e),e.mount(),e}import{Sprite as ys,Container as Er}from"pixi.js";var vs=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",vn=vs;if(typeof window!="undefined")try{let a=new XMLHttpRequest;if(a.open("GET","./build-settings.json",!1),a.send(),a.status===200&&a.responseText){let e=JSON.parse(a.responseText);e!=null&&e.buildMode&&(vn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${vn}`))}}catch{}function xs(a){var t,i,n,r,s;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(a);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(a))return{x:(t=a[0])!=null?t:.5,y:(i=a[1])!=null?i:.5};if(a&&typeof a=="object"&&"x"in a&&"y"in a)return{x:(n=a.x)!=null?n:.5,y:(r=a.y)!=null?r:.5};if(typeof a=="string"){let o=a.trim().toLowerCase();return(s=e[o])!=null?s:{x:.5,y:.5}}return null}var ke=class{static async create(e,t,i){var l,c,p,d,u,g,f;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${vn}`);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 h=new Er;return this.applyTransform(h,t==null?void 0:t.transform,t),h}let r=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${n.type}, path: ${n.path}`);let s=await Mi.load(e,n,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(p=s==null?void 0:s.constructor)==null?void 0:p.name}`);let o;if(n.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",e),o=new ys(s),console.log("[ObjectFactory] Created object:",o,"type:",(d=o==null?void 0:o.constructor)==null?void 0:d.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=s==null?void 0:s.constructor)==null?void 0:u.name,s),s&&(((g=s.constructor)==null?void 0:g.name)==="Container"||s instanceof Er)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let h=[n.path,`/assets/${n.path}`,`assets/${n.path}`,`../assets/${n.path}`],m=!1;for(let b of h)try{let y=await fetch(b);if(y.ok){o=await y.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(f=o==null?void 0:o.constructor)==null?void 0:f.name),m=!0;break}}catch{continue}m||(console.error("[ObjectFactory] Failed to reload JSON from any path"),o=s)}else o=s;else o=s,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,r,s,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(n=t.position.x)!=null?n:0,e.y=(r=t.position.y)!=null?r:0):"position"in e&&e.position&&e.position.set((s=t.position.x)!=null?s: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=xs(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};function xn(a){try{if(a&&typeof a.keys=="function")return Array.from(a.keys())}catch{}return[]}function Ar(a){var e;return a?((e=a.getDisplayObject)==null?void 0:e.call(a))||a.pixiObject||a:null}function ws(a,e){if(!a||!(e!=null&&e.interaction))return;let t=e.interaction,i=t.enabled!==!1&&(t.draggable===!0||t.clickable===!0);a.eventMode=i?"static":"none",a.interactive=i,i&&(a.cursor=t.draggable?"move":"pointer")}function Sr(a,e){var l,c,p,d,u;if(!a||!e)return;let t=e.transform||{};ws(a,e);let i=t.position||{},n=t.offset||{},r=(typeof i.x=="number"?i.x:0)+(typeof n.x=="number"?n.x:0),s=(typeof i.y=="number"?i.y:0)+(typeof n.y=="number"?n.y:0);(l=a.position)!=null&&l.set?a.position.set(r,s):(typeof a.x=="number"&&(a.x=r),typeof a.y=="number"&&(a.y=s)),typeof t.scale=="number"&&((c=a.scale)!=null&&c.set?a.scale.set(t.scale):a.scale&&(a.scale.x=t.scale,a.scale.y=t.scale));let o=(d=t.anchor)!=null?d:(p=e.render)==null?void 0:p.anchor;o&&((u=a.anchor)!=null&&u.set)&&typeof o.x=="number"&&typeof o.y=="number"&&a.anchor.set(o.x,o.y)}function Cr(a){if(typeof window=="undefined")return;let e=a==null?void 0:a.objects,t=xn(e),i=r=>{try{let s=window.__HANDLER_ACTIVE_SCREEN;if(!s||s==="all")return r;let o=window.__HANDLER_SCREEN_INDEX,l=o==null?void 0:o.instanceToScreen;return l?r.filter(c=>l[c]===s):r}catch{return r}};window.__editableObjectConfigs=e;let n=new Map;t.forEach(r=>n.set(r,[r])),window.__editableObjectInstances=n,window.refreshEditableConfigIndex=()=>Cr(window.__editableConfig),window.getEditableObjectList=()=>{var r;return i(xn((r=window.__editableConfig)==null?void 0:r.objects))},window.getEditableObjectListAll=()=>{var r;return xn((r=window.__editableConfig)==null?void 0:r.objects)},window.getEditableObjectConfig=r=>{var p,d,u,g,f;let s=(g=(u=(d=(p=window.__editableConfig)==null?void 0:p.objects)==null?void 0:d.get)==null?void 0:u.call(d,r))!=null?g:null,o=window.__HANDLER_ACTIVE_SCREEN;if(!o||o==="all")return s;let l=window.__HANDLER_SCREEN_INDEX,c=(f=l==null?void 0:l.instanceToScreen)==null?void 0:f[r];return c&&c===o?s:null},window.getEditableEngineConfig=()=>{let r=window.__editableConfig;if(console.log("[BRIDGE] getEditableEngineConfig called, cfg present:",!!r),!r)return null;if(r.engine&&r.objects instanceof Map){console.log("[BRIDGE] Detected ObjectCentricConfig, flattening...");let s={...r.engine,objects:r.objects,scene:r.scene};return console.log("[BRIDGE] Returned assets:",Object.keys(s.assets||{})),s}return r}}function Es(){if(typeof window=="undefined")return;let a=t=>{let i=String(t||"").trim();return i?/^(data:|blob:|https?:)/.test(i)||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`:""},e=async(t,i)=>{var r,s,o;let n=a(i);if(n)try{let[{Assets:l},{AssetTextures:c}]=await Promise.all([import("pixi.js"),import("./AssetTextures-67BIZDFD.js")]),p=Date.now(),d=/^(data:|blob:)/.test(n)?n:n+(n.includes("?")?`&t=${p}`:`?t=${p}`),u=await l.load(d);if(!u)return;c[t]=u;let g=window.CustomAssets;(r=g==null?void 0:g[t])!=null&&r.texture&&(g[t].texture=u);let f=window.gameObjectManager,h=(s=f==null?void 0:f.get)==null?void 0:s.call(f,t);if(h){let m=((o=h.getDisplayObject)==null?void 0:o.call(h))||h.pixiObject||h.pixi||h;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=Ii();Array.isArray(i)&&i.length&&(window.__editableConfig=t,Rt(i,{silent:!0,persist:!1}))}catch{}},window.applyEngineOverrides=t=>{try{let i=Ii();Array.isArray(i)&&i.length&&(window.__editableConfig=t,Rt(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[r,s]of Object.entries(t.runtime))n.push({path:`runtime.${r}`,value:s});if(t.assets)for(let[r,s]of Object.entries(t.assets))n.push({path:`assets.${r}`,value:s}),typeof s=="string"&&e(r,s);if(t.splash)for(let[r,s]of Object.entries(t.splash))n.push({path:`splash.${r}`,value:s});if(t.loading)for(let[r,s]of Object.entries(t.loading))n.push({path:`loading.${r}`,value:s});if(t.start)for(let[r,s]of Object.entries(t.start))n.push({path:`start.${r}`,value:s});n.length&&Rt(n,{silent:!0,persist:!0,emitEvent:!0})}}function wn(a){let{getConfig:e,gameObjectManager:t,onObjectConfigApplied:i}=a;t&&(t.onObjectRebuildRequired=async(r,s)=>{console.log(`[LIVE-EDIT] \u{1F3D7}\uFE0F Rebuilding object ${r} due to type change...`);let o=t.get(r),l=o==null?void 0:o.pixiObject,c=l==null?void 0:l.parent,p=c==null?void 0:c.children.indexOf(l);o?t.remove(r):l&&l.destroy();let d=window.gameApp,u=await ke.create(r,s,d);c&&(p!==void 0&&p!==-1?c.addChildAt(u,p):c.addChild(u));let g=t.create(r,u);return console.log(`[LIVE-EDIT] \u2705 Rebuild complete for ${r}`),g}),typeof window!="undefined"&&(Es(),window.applyEditableObjectConfig=(r,s)=>{var o,l,c;console.log("[LIVE-EDIT] \u{1F504} applyEditableObjectConfig called for:",r);try{let p=window.__editableConfig;(o=p==null?void 0:p.objects)!=null&&o.set&&(p.objects.set(r,s),console.log("[LIVE-EDIT] \u2705 Updated config in __editableConfig"));let d=(l=t==null?void 0:t.get)==null?void 0:l.call(t,r);if(console.log("[LIVE-EDIT] gameObject found?",!!d),d&&(console.log("[LIVE-EDIT] gameObject type:",(c=d.constructor)==null?void 0:c.name),console.log("[LIVE-EDIT] has updateConfig?",typeof d.updateConfig=="function"),console.log("[LIVE-EDIT] has onConfigUpdate?",typeof d.onConfigUpdate=="function")),d&&typeof d.updateConfig=="function")console.log("[LIVE-EDIT] \u2705 Calling updateConfig()"),d.updateConfig(s);else if(d&&typeof d.onConfigUpdate=="function")console.log("[LIVE-EDIT] \u2705 Calling onConfigUpdate()"),d.onConfigUpdate();else{console.log("[LIVE-EDIT] \u26A0\uFE0F No updateConfig or onConfigUpdate, applying transform directly");let u=Ar(d);Sr(u,s)}}catch(p){console.error("[LIVE-EDIT] \u274C Error in applyEditableObjectConfig:",p)}});let n={async applyObjectConfig(r,s){var p,d;console.log("[BRIDGE] \u{1F504} applyObjectConfig called for:",r);let o=e();(p=o==null?void 0:o.objects)!=null&&p.set&&(o.objects.set(r,s),console.log("[BRIDGE] \u2705 Updated config"));let l=(d=t==null?void 0:t.get)==null?void 0:d.call(t,r);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(s);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=Ar(l);Sr(u,s)}let c=[r];i==null||i(r,s,c)},rebuildIndexes(){let r=e();typeof window!="undefined"&&(window.__editableConfig=r,Cr(r))}};return n.rebuildIndexes(),n}import As from"lottie-web";Cn(Ia);typeof window!="undefined"&&!window.lottie&&(window.lottie=As);var Ke=null,Ss=async()=>{if(!Ke){let a=typeof window!="undefined"?window.INLINE_ASSETS:null,e=(a==null?void 0:a["handler.config"])||(a==null?void 0:a["handler.config.json"]);if(e)try{if(e.startsWith("data:")){let i=atob(e.split(",")[1]);Ke=JSON.parse(i)}else Ke=JSON.parse(e);return Ke}catch(i){console.warn("[CONFIG] Failed to parse inline handler.config.json:",i)}Ke=await(await fetch("./handler.config.json")).json()}return Ke},Ln,gt,kr,Xe,An,Sn;function ld(a){Ln=a.initGame,gt=a.CustomAssets,kr=a.updateScreenState,Xe=a.globalResponsiveMultipliers,An=a.layout,Sn=a.clearResponsiveElements}var ui="web_embed",ut="https://example.com",Lr={profile_id:ui},Pe=null,ce=null,En={width:0,height:0},Cs=!0,cd=async()=>{var c,p,d,u;document.title="Handler Pixi Game";let a=await Ss();Lr={...a.ids||{},profile_id:ui},ut=a.destination_url||((p=(c=a.export_profiles)==null?void 0:c[ui])==null?void 0:p.destination_url)||ut,me.init({ids:Lr,profile:ui,destinationUrl:ut});let e=me.getRoot();if(typeof __PREVIEW_SHELL__!="undefined"&&__PREVIEW_SHELL__){console.log("[BOOTSTRAP] Initializing Preview Shell..."),ce=wr({onDeviceChange:f=>{console.log(`[PREVIEW] Device switched to ${f.width}x${f.height}, restarting game...`),Tr()},onRefresh:Tr});let g=ce.getGameContainer();g&&(e=g),window.addEventListener("handler-preview:screen",f=>{var v,x,w,C,k,P,O,j,T,E,S;let h=window.gameApp,m=window.gameObjectManager,{width:b,height:y}=f.detail;if(En.width=b,En.height=y,kr(b,y),!(!h||!h.renderer)){m&&o(h,m);try{h.renderer.resize(b,y);let A=h.view;A&&(A.style.width="100%",A.style.height="100%",A.style.display="block")}catch(A){console.warn("[SCREEN] Error resizing renderer:",A);return}if(t&&m&&An)try{let A=(v=window.__mainContainer)!=null?v:h.stage,M=(O=(P=(C=window.__tutorialLabel)!=null?C:(w=(x=m.get("label_1"))==null?void 0:x.getDisplayObject)==null?void 0:w.call(x))!=null?P:(k=m.get("label_1"))==null?void 0:k.pixiObject)!=null?O:m.get("label_1"),I=m.get("background_1"),D=(S=(E=(T=window.__background)!=null?T:(j=I==null?void 0:I.getDisplayObject)==null?void 0:j.call(I))!=null?E:I==null?void 0:I.pixiObject)!=null?S:I;if(A){let L=A===h.stage;An({mainContainer:A,label:M,background:D,backgroundTexture:(D==null?void 0:D.texture)||null,app:h},t,0,En,m,{skipMainContainerTransform:L})}}catch(A){console.warn("[SCREEN] Error in layout:",A)}}})}let t=await It("scene.main");window.__editableConfig=t,s(),window.__editableConfigBaseline||(window.__editableConfigBaseline=Oi(t),console.log("[BOOTSTRAP] Frozen config baseline for persistence")),(u=(d=t.engine.runtime)==null?void 0:d.layout)!=null&&u.design_width_portrait||(console.warn("[BOOTSTRAP] Config layout missing, retrying..."),await new Promise(g=>setTimeout(g,100)),t=await It("scene.main"));let i=await Ln(e,t,ut,ce);Pe=i.app;let n=i.gameObjectManager;window.gameApp=Pe,window.gameObjectManager=n;try{window.__liveEditBridge=wn({getConfig:()=>window.__editableConfig,gameObjectManager:n,assets:gt})}catch(g){console.warn("[BOOTSTRAP] Failed to initialize live-edit bridge",g)}ce&&ce.notifyGameLoaded();let r=window.__debugScale;r&&typeof r=="number"&&(Xe.scale=r,console.log(`[DEBUG] Applied persisted debug scale: ${r}`)),o(Pe,n);async function s(){try{let g=async y=>{let v=y.startsWith("/")?y:`/${y}`,x=await fetch(v,{cache:"no-cache"});if(!x.ok)return null;let w=await x.text();try{return JSON.parse(w)}catch{return null}},f=await g("configs/flow/app.flow.json");if(!f||typeof f!="object")return;let h=f.screens;if(!h||typeof h!="object")return;let m={},b={};for(let[y,v]of Object.entries(h)){let x=v==null?void 0:v.source;if(typeof x!="string")continue;let w=await g(x),C=w==null?void 0:w.elements;if(!Array.isArray(C))continue;let k=C.map(P=>P==null?void 0:P.instance_id).filter(P=>typeof P=="string");m[y]=k;for(let P of k)b[P]||(b[P]=y)}window.__HANDLER_APP_FLOW=f,window.__HANDLER_SCREEN_INDEX={screenToInstances:m,instanceToScreen:b},window.dispatchEvent(new CustomEvent("handler:screen-index-loaded"))}catch{}}function o(g,f){if(Cs){console.log("[RESPONSIVE] Skipping global scaling; using config-driven layout");return}if(console.log("[RESPONSIVE] ===== APPLYING GLOBAL RESPONSIVE SCALING ====="),console.log(`[RESPONSIVE] Scale multiplier: ${Xe.scale.toFixed(3)}`),g.stage){let m=function(b,y=0){if(!b||!b.children)return;let v=" ".repeat(y);b.children.forEach((x,w)=>{if(x&&x.zIndex===9999){console.log(`${v}[RESPONSIVE] Skipping debug border (zIndex 9999)`);return}if(x&&x.scale){let C=x.scale.x||1,k=x.scale.y||1;x.__originalScale||(x.__originalScale={x:C,y:k},console.log(`${v}[RESPONSIVE] Stored original scale for child[${w}]: ${C.toFixed(3)}, ${k.toFixed(3)}`));let P=x.__originalScale.x*Xe.scale,O=x.__originalScale.y*Xe.scale;typeof x.scale.set=="function"?x.scale.set(P,O):(x.scale.x=P,x.scale.y=O),console.log(`${v}[RESPONSIVE] Child[${w}] scale: ${C.toFixed(3)}\u2192${x.scale.x.toFixed(3)} (type: ${x.constructor.name})`),m(x,y+1)}else x&&console.log(`${v}[RESPONSIVE] Child[${w}] has no scale (type: ${x.constructor.name})`)})};var h=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){Xe.scale=g,console.log(`[RESPONSIVE] Updated global scale multiplier to: ${g.toFixed(3)}`);let f=window.gameApp,h=window.gameObjectManager;f&&h?(o(f,h),f.renderer&&(f.renderer.render(f.stage),console.log("[RESPONSIVE] Forced PIXI renderer update"))):console.warn(`[RESPONSIVE] No gameApp (${!!f}) or gameObjectManager (${!!h}) found in window for live update`)}}window.updateGlobalResponsiveMultipliers=l,me.start()},Tr=async()=>{var e,t,i,n;console.log("[PREVIEW] Restarting game in 1 seconds...");let a=(e=window.gameObjectManager)==null?void 0:e.get("character_1");if(a){let r=((t=a.getDisplayObject)==null?void 0:t.call(a))||a;r&&r.scale&&console.log(`[CHARACTER] Before restart - Current scale - x: ${((i=r.scale.x)!=null?i:1).toFixed(3)}, y: ${((n=r.scale.y)!=null?n:1).toFixed(3)}`)}if(ce){ce.notifyGameDestroyed();try{Sn&&Sn()}catch(r){console.warn("Failed to clear responsive elements",r)}setTimeout(()=>{console.log("[PREVIEW] Executing restart...");let r=ce.getGameContainer(),s=window.gameObjectManager;if(s&&typeof s.clear=="function"&&(console.log("[PREVIEW] Clearing old GameObjectManager tickers..."),s.clear()),Pe){try{Pe.destroy(!0,{children:!0,texture:!1})}catch(o){console.warn("[PREVIEW] Destroy warning:",o)}Pe=null}window.gameApp=null,window.gameObjectManager=null,r&&(r.innerHTML="");try{typeof gt.resetScene=="function"&>.resetScene()}catch(o){console.warn("Asset reset failed",o)}setTimeout(()=>{It("scene.main").then(o=>{window.__editableConfig=o,window.__editableConfigBaseline||(window.__editableConfigBaseline=Oi(o)),Ln(r,o,ut).then(l=>{Pe=l.app,window.gameApp=Pe,window.gameObjectManager=l.gameObjectManager;try{window.__liveEditBridge=wn({getConfig:()=>window.__editableConfig,gameObjectManager:window.gameObjectManager,assets:gt})}catch(c){console.warn("[BOOTSTRAP] Failed to re-initialize live-edit bridge",c)}ce&&ce.notifyGameLoaded(),console.log("[PREVIEW] Game restarted successfully");try{me.start()}catch{}})})},100)},1e3)}};var be={background:"#F6F3EF",ink:"#1E1E1E",secondaryText:"#8E8A84",primaryAccent:"#E38A5A",secondaryAccent:"#C9A28C",statusGreen:"#5F8F6B"},Ls=1.25,Ts={fontFamily:"Inter, system-ui, sans-serif"};var Tn=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=`
|
|
1448
1448
|
position: fixed;
|
|
1449
1449
|
inset: 0;
|
|
1450
1450
|
display: flex;
|