handler-playable-sdk 0.5.43 → 0.5.45

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/index.css CHANGED
@@ -1076,6 +1076,18 @@
1076
1076
  transition: all var(--ui-duration-fast) var(--ui-ease);
1077
1077
  }
1078
1078
 
1079
+ .scene-object-checkbox {
1080
+ width: 14px;
1081
+ height: 14px;
1082
+ min-width: 14px;
1083
+ min-height: 14px;
1084
+ margin: 0;
1085
+ margin-right: 6px;
1086
+ cursor: pointer;
1087
+ accent-color: var(--ui-terracotta);
1088
+ flex-shrink: 0;
1089
+ }
1090
+
1079
1091
  .scene-object-label {
1080
1092
  white-space: nowrap;
1081
1093
  overflow: hidden;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{E as J,F as K,G as L,H as M,I as N,J as O,K as P,L as Q,M as R,N as S,O as T,P as U,Q as V,R as W,S as X,T as Y,U as Z,a}from"./chunk-UATUWWUY.js";import"./chunk-I5OOVR5U.js";import{a as u,b as v,c as w,d as x,e as y,f as z,g as A,h as B,i as C,j as D,k as E,l as F,m as G,n as H,o as I}from"./chunk-PW2FGMCO.js";import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t}from"./chunk-HVKF2KYL.js";import"./chunk-E6WJCS24.js";import"./chunk-JXBG6UFL.js";export{U as COLORS,F as ConfigWatcher,O as DebugPanel,E as DefaultReloadStrategy,Y as Handler,X as PlayableLoadingScreen,P as PreviewShell,V as STROKE_WIDTH,W as THEME,d as applyConfigOverride,e as applyConfigOverrides,r as applyConfigsToDisk,B as applyDefaults,a as baseLottie,T as bootstrap,f as clearConfigOverrides,g as clearConfigOverridesForObject,j as configOverrideManager,Q as createPreviewShell,o as deepClone,Z as default,L as defaultPreset,K as deviceGroups,J as devicePresets,G as diffConfigs,p as exportConfigsAsJSON,i as getConfigOverrides,q as getConfigStateSummary,b as getOverrideMode,M as getPresetById,N as getPresetsByCategory,w as loadAllObjectConfigs,u as loadComponentSchemas,x as loadEngineConfig,y as loadGamePromptConfig,C as loadObjectCentricConfig,v as loadObjectConfig,z as loadSceneConfig,l as redoLastConfigChange,H as rehydrateObject,h as removeConfigOverride,s as resetToApplied,t as resetToOriginal,S as setBootstrapDependencies,c as setOverrideMode,I as setupHotReload,R as setupLiveEditBridge,D as toLegacyFormat,m as trackObjectCreation,n as trackObjectDeletion,k as undoLastConfigChange,A as validateObjectConfig};
1
+ import{E as J,F as K,G as L,H as M,I as N,J as O,K as P,L as Q,M as R,N as S,O as T,P as U,Q as V,R as W,S as X,T as Y,U as Z,a}from"./chunk-7PB4AWTL.js";import"./chunk-I5OOVR5U.js";import{a as u,b as v,c as w,d as x,e as y,f as z,g as A,h as B,i as C,j as D,k as E,l as F,m as G,n as H,o as I}from"./chunk-PW2FGMCO.js";import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t}from"./chunk-HVKF2KYL.js";import"./chunk-E6WJCS24.js";import"./chunk-JXBG6UFL.js";export{U as COLORS,F as ConfigWatcher,O as DebugPanel,E as DefaultReloadStrategy,Y as Handler,X as PlayableLoadingScreen,P as PreviewShell,V as STROKE_WIDTH,W as THEME,d as applyConfigOverride,e as applyConfigOverrides,r as applyConfigsToDisk,B as applyDefaults,a as baseLottie,T as bootstrap,f as clearConfigOverrides,g as clearConfigOverridesForObject,j as configOverrideManager,Q as createPreviewShell,o as deepClone,Z as default,L as defaultPreset,K as deviceGroups,J as devicePresets,G as diffConfigs,p as exportConfigsAsJSON,i as getConfigOverrides,q as getConfigStateSummary,b as getOverrideMode,M as getPresetById,N as getPresetsByCategory,w as loadAllObjectConfigs,u as loadComponentSchemas,x as loadEngineConfig,y as loadGamePromptConfig,C as loadObjectCentricConfig,v as loadObjectConfig,z as loadSceneConfig,l as redoLastConfigChange,H as rehydrateObject,h as removeConfigOverride,s as resetToApplied,t as resetToOriginal,S as setBootstrapDependencies,c as setOverrideMode,I as setupHotReload,R as setupLiveEditBridge,D as toLegacyFormat,m as trackObjectCreation,n as trackObjectDeletion,k as undoLastConfigChange,A as validateObjectConfig};
@@ -1,4 +1,4 @@
1
- "use strict";var ya=Object.create;var Mt=Object.defineProperty;var va=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var xa=Object.getPrototypeOf,Ea=Object.prototype.hasOwnProperty;var le=(n,e)=>()=>(n&&(e=n(n=0)),e);var Wn=(n,e)=>{for(var t in e)Mt(n,t,{get:e[t],enumerable:!0})},Yn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of wa(e))!Ea.call(n,a)&&a!==t&&Mt(n,a,{get:()=>e[a],enumerable:!(i=va(e,a))||i.enumerable});return n};var Pt=(n,e,t)=>(t=n!=null?ya(xa(n)):{},Yn(e||!n||!n.__esModule?Mt(t,"default",{value:n,enumerable:!0}):t,n)),Sa=n=>Yn(Mt({},"__esModule",{value:!0}),n);var Ia,ce=le(()=>{"use strict";Ia="handler_preview_override_mode";if(typeof window!="undefined"){let n=window.localStorage.getItem(Ia);window.__enableConfigOverrides=n===null?!0:n==="true"}});var Ti,_e,Qr,pn=le(()=>{"use strict";ce();Ti=null,_e="dev";if(typeof window!="undefined"){let n=window.__BUILD_SETTINGS__;if(n!=null&&n.buildMode)Ti=n,_e=n.buildMode,console.log("[CONFIG] Loaded inline build settings:",n,"buildMode:",_e);else try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);Ti=t,_e=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",_e)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",_e)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",_e);Qr=_e==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var un=le(()=>{"use strict"});var ki=le(()=>{"use strict";un();pn()});var gn=le(()=>{"use strict";pn();un();ki()});var ae,mn=le(()=>{"use strict";ae=class{static get(e){var t;return(t=this.store.get(e))==null?void 0:t.data}static set(e,t){this.store.set(e,{data:t})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};ae.store=new Map});function Ba(){var n,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(n=document.querySelector("script"))==null?void 0:n.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),i=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!i)}catch{return!1}}async function Ua(){try{if(typeof window!="undefined"){let n=await fetch("./build-settings.json");if(n.ok){let e=await n.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Ga(){try{if(typeof window!="undefined"){let n=new XMLHttpRequest;if(n.open("GET","./build-settings.json",!1),n.send(),n.status===200&&n.responseText){let e=JSON.parse(n.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}async function qa(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${M}`),Object.keys(de).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(de)),de;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),de={...window.INLINE_ASSETS},de;if(!(M==="publish"&&re!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),de;if(!bn){let e=typeof window!="undefined"?new URL("inline-assets.js",window.location.href).href:"./inline-assets.js";console.log("[AssetLoader] Loading inline assets from:",e),bn=(async()=>{try{try{let r=await import(e+"?t="+Date.now());if(r.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(r.INLINE_ASSETS)),r.INLINE_ASSETS}catch(r){console.warn("[AssetLoader] ES module import failed, trying text parse:",r)}let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let i=await t.text();console.log("[AssetLoader] Received JS code, length:",i.length);let a=i.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)try{let r=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let s=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(s)),s}catch(r){return console.warn("[AssetLoader] Failed to parse inline assets:",r),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",i.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return de=await bn,console.log("[AssetLoader] Final inline assets cache:",Object.keys(de)),de}function yn(n){return n===null||typeof n!="object"||(Object.freeze(n),Object.values(n).forEach(e=>yn(e))),n}function Va(n=64,e=64,t=16711680){let i=document.createElement("canvas");i.width=n,i.height=e;let a=i.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,n,e),a.strokeStyle="#000",a.strokeRect(0,0,n,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",n/2,e/2),pe.Texture.from(i)}function $t(n,e){zi.set(n,e)}var pe,ji,Ri,Oe,M,re,Ae,de,bn,zi,Ce,Dt=le(()=>{"use strict";pe=require("pixi.js");mn();ji=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Ri=Ba(),Oe=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,M=Ri?"publish":ji,re=Oe==null?void 0:Oe.assetsInlined;Oe!=null&&Oe.buildMode&&(M=Oe.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${M}`));Ae=Ga();Ae!=null&&Ae.buildMode&&(M=Ae.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${M}`));(Ae==null?void 0:Ae.assetsInlined)!==void 0&&(re=Ae.assetsInlined);Ua().then(n=>{n!=null&&n.buildMode&&n.buildMode!==M&&(M=n.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${M}`)),(n==null?void 0:n.assetsInlined)!==void 0&&(re=n.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${ji}, Runtime: ${Ri?"publish":"dev"}, Effective: ${M}`);de={},bn=null;zi=new Map;Ce=class{static async load(e,t,i,a){let r=`${e}:${t.path}`,s=ae.get(r);if(s!==void 0)return s;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${M}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let o=await qa(),l=o[e];if(!l&&a&&(l=o[a],l&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${a}`)),!l&&t.path){let c=t.path.split("/");if(c.length>=2){let p=c[c.length-1].split(".")[0];o[p]&&(l=o[p],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${p}`))}}if(console.log("[AssetLoader] Inline data for",e,":",l?"FOUND":"NOT FOUND"),M==="publish"&&re!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!l))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${t.path}`);let u=zi.get(t.type);if(u)try{let c=await u(t.path,l,e,i);return ae.set(r,c),c}catch(c){return this.handleFailure(e,t.type,c)}try{let c;switch(t.type){case"image":c=await this.loadImage(t.path,l);break;case"json":c=await this.loadJSON(t.path,l),c=yn(c);break;default:throw new Error(`Unknown asset type: ${t.type}`)}return ae.set(r,c),c}catch(c){return this.handleFailure(e,t.type,c)}}static async loadImage(e,t){let i=M==="publish",a=i&&re!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${M}, isPublishMode: ${i}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof t!="string"||!t.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof t}`);try{return await pe.Assets.load(t)}catch(r){throw console.error("[AssetLoader] Failed to load texture from data URI:",r),r}}if(t&&typeof t=="string"&&t.startsWith("data:"))try{return await pe.Assets.load(t)}catch(r){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",r),await pe.Assets.load(e)}return await pe.Assets.load(e)}static async loadJSON(e,t){let i=M==="publish",a=i&&re!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${M}, isPublishMode: ${i}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let s=atob(t.split(",")[1]);return JSON.parse(s)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let s=atob(t.split(",")[1]);return JSON.parse(s)}return JSON.parse(t)}let r=await fetch(e);if(!r.ok)throw new Error(`JSON fetch failed: ${e}`);return r.json()}static handleFailure(e,t,i){if(M==="dev"){let r=t==="image"?Va():yn({__placeholder:!0,type:t});return ae.set(e+":"+((i==null?void 0:i.path)||"missing"),r),r}throw i}};$t("image",async(n,e)=>{let t=M==="publish",i=t&&re!==!1,a=M==="brand",r=t&&re===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${M}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${n}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return pe.Assets.load(e)}let s=n;return(a||r)&&n&&!n.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(s=n,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${n}" as-is`)):(s=`assets/${n}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${n}" -> "${s}"`))),pe.Assets.load(e||s)});$t("json",async(n,e)=>{let t=M==="publish",i=t&&re!==!1,a=M==="brand",r=t&&re===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${M}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${n}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let s=n;if((a||r)&&n&&!n.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(s=n,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${n}" as-is`)):(s=`assets/${n}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${n}" -> "${s}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let o=await fetch(s);if(!o.ok)throw new Error(`JSON fetch failed: ${n}`);return o.json()})});function Ht(n,e){$i.init(n,e),typeof window!="undefined"&&(window.__AssetTextures=Te)}var vn,$i,Te,gt=le(()=>{"use strict";Dt();vn=class{constructor(){this.textures=new Map;this.readyPromise=null;this.priorityReadyPromise=null;this.priorityReadyResolve=null;this.config=null;this.app=null;this.attempted=new Set;this.waiters=new Set}init(e,t){if(this.config===e&&this.app===t&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.attempted.clear(),this.waiters.clear(),this.priorityReadyPromise=new Promise(i=>{this.priorityReadyResolve=i}),this.config=e,this.app=t,console.log("[AssetTextures] Initialized with config, cleared previous textures")}async ready(){if(this.readyPromise){await this.readyPromise;return}if(!this.config)throw new Error("[AssetTextures] Must call init() before ready() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before ready() - app is null");let e=this.config,t=this.app;return this.readyPromise=(async()=>{var s;console.log("[AssetTextures] Loading all assets...");let i=new Set(["background_loading_1"]),a=[],r=[];for(let[o,l]of e.objects.entries()){let d=(s=l.render)==null?void 0:s.asset;if(!d)continue;let u=async()=>{var c;try{let p=(c=l.identity)==null?void 0:c.id;console.log(`[AssetTextures] Loading ${d.type}: ${o} (${p})`);let g=await Ce.load(o,d,t,p);this.textures.set(o,g),console.log(`[AssetTextures] \u2713 Loaded: ${o}`)}catch(p){console.error(`[AssetTextures] \u2717 Failed to load: ${o}`,p)}finally{this.attempted.add(o);try{for(let p of Array.from(this.waiters))p()}catch{}}};i.has(o)?a.push(u()):r.push(u())}a.length>0&&(console.log("[AssetTextures] Phase 1: Loading priority assets (loading screen)..."),await Promise.all(a),console.log("[AssetTextures] Phase 1: Priority assets ready")),this.priorityReadyResolve&&this.priorityReadyResolve(),console.log("[AssetTextures] Phase 2: Loading remaining assets..."),await Promise.all(r),console.log("[AssetTextures] All textures loaded:",Array.from(this.textures.keys()))})(),this.readyPromise}async priorityReady(){return this.priorityReadyPromise?this.priorityReadyPromise:Promise.resolve()}async waitFor(e,t={}){if(!this.config)throw new Error("[AssetTextures] Must call init() before waitFor() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before waitFor() - app is null");let a=Array.from(new Set((e||[]).filter(o=>typeof o=="string"&&o))).filter(o=>{var l,d,u,c;try{let p=(u=(d=(l=this.config)==null?void 0:l.objects)==null?void 0:d.get)==null?void 0:u.call(d,o);return!!((c=p==null?void 0:p.render)!=null&&c.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let r=()=>a.every(o=>this.textures.has(o)||this.attempted.has(o));if(r())return;let s=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(o=>{let l=!1,d=()=>{l||r()&&(l=!0,this.waiters.delete(d),o())};this.waiters.add(d),d(),s>0&&setTimeout(()=>{l||(l=!0,this.waiters.delete(d),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),o())},s)})}get(e){return this.textures.get(e)}set(e,t){this.textures.set(e,t),console.log(`[AssetTextures] Updated texture: ${e}`)}clear(){this.textures.clear(),this.readyPromise=null,console.log("[AssetTextures] Cleared all textures")}getAllIds(){return Array.from(this.textures.keys())}},$i=new vn,Te=new Proxy($i,{get(n,e){return e in n&&typeof n[e]=="function"?n[e].bind(n):n.get(e)},set(n,e,t){return n.set(e,t),!0}})});var Ni={};Wn(Ni,{AssetEditorModal:()=>An});var An,Cn=le(()=>{"use strict";An=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,i,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=i,this.onApplyCallback=a,this.createModal(e,i),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let i=document.createElement("div");i.className="asset-editor-modal",i.innerHTML=`
1
+ "use strict";var ya=Object.create;var Mt=Object.defineProperty;var va=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var xa=Object.getPrototypeOf,Ea=Object.prototype.hasOwnProperty;var le=(n,e)=>()=>(n&&(e=n(n=0)),e);var Wn=(n,e)=>{for(var t in e)Mt(n,t,{get:e[t],enumerable:!0})},Yn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of wa(e))!Ea.call(n,a)&&a!==t&&Mt(n,a,{get:()=>e[a],enumerable:!(i=va(e,a))||i.enumerable});return n};var Pt=(n,e,t)=>(t=n!=null?ya(xa(n)):{},Yn(e||!n||!n.__esModule?Mt(t,"default",{value:n,enumerable:!0}):t,n)),Sa=n=>Yn(Mt({},"__esModule",{value:!0}),n);var Ia,ce=le(()=>{"use strict";Ia="handler_preview_override_mode";if(typeof window!="undefined"){let n=window.localStorage.getItem(Ia);window.__enableConfigOverrides=n===null?!0:n==="true"}});var Ti,_e,Qr,pn=le(()=>{"use strict";ce();Ti=null,_e="dev";if(typeof window!="undefined"){let n=window.__BUILD_SETTINGS__;if(n!=null&&n.buildMode)Ti=n,_e=n.buildMode,console.log("[CONFIG] Loaded inline build settings:",n,"buildMode:",_e);else try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);Ti=t,_e=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",_e)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",_e)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",_e);Qr=_e==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var un=le(()=>{"use strict"});var ki=le(()=>{"use strict";un();pn()});var gn=le(()=>{"use strict";pn();un();ki()});var ae,mn=le(()=>{"use strict";ae=class{static get(e){var t;return(t=this.store.get(e))==null?void 0:t.data}static set(e,t){this.store.set(e,{data:t})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};ae.store=new Map});function Ba(){var n,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(n=document.querySelector("script"))==null?void 0:n.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),i=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!i)}catch{return!1}}async function Ua(){try{if(typeof window!="undefined"){let n=await fetch("./build-settings.json");if(n.ok){let e=await n.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Ga(){try{if(typeof window!="undefined"){let n=new XMLHttpRequest;if(n.open("GET","./build-settings.json",!1),n.send(),n.status===200&&n.responseText){let e=JSON.parse(n.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}async function qa(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${M}`),Object.keys(de).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(de)),de;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),de={...window.INLINE_ASSETS},de;if(!(M==="publish"&&re!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),de;if(!bn){let e=typeof window!="undefined"?new URL("inline-assets.js",window.location.href).href:"./inline-assets.js";console.log("[AssetLoader] Loading inline assets from:",e),bn=(async()=>{try{try{let r=await import(e+"?t="+Date.now());if(r.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(r.INLINE_ASSETS)),r.INLINE_ASSETS}catch(r){console.warn("[AssetLoader] ES module import failed, trying text parse:",r)}let t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);let i=await t.text();console.log("[AssetLoader] Received JS code, length:",i.length);let a=i.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(a)try{let r=a[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let s=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(s)),s}catch(r){return console.warn("[AssetLoader] Failed to parse inline assets:",r),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",i.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return de=await bn,console.log("[AssetLoader] Final inline assets cache:",Object.keys(de)),de}function yn(n){return n===null||typeof n!="object"||(Object.freeze(n),Object.values(n).forEach(e=>yn(e))),n}function Va(n=64,e=64,t=16711680){let i=document.createElement("canvas");i.width=n,i.height=e;let a=i.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,n,e),a.strokeStyle="#000",a.strokeRect(0,0,n,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",n/2,e/2),pe.Texture.from(i)}function $t(n,e){zi.set(n,e)}var pe,Oi,Ri,je,M,re,Ae,de,bn,zi,Ce,Dt=le(()=>{"use strict";pe=require("pixi.js");mn();Oi=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Ri=Ba(),je=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,M=Ri?"publish":Oi,re=je==null?void 0:je.assetsInlined;je!=null&&je.buildMode&&(M=je.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${M}`));Ae=Ga();Ae!=null&&Ae.buildMode&&(M=Ae.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${M}`));(Ae==null?void 0:Ae.assetsInlined)!==void 0&&(re=Ae.assetsInlined);Ua().then(n=>{n!=null&&n.buildMode&&n.buildMode!==M&&(M=n.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${M}`)),(n==null?void 0:n.assetsInlined)!==void 0&&(re=n.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${Oi}, Runtime: ${Ri?"publish":"dev"}, Effective: ${M}`);de={},bn=null;zi=new Map;Ce=class{static async load(e,t,i,a){let r=`${e}:${t.path}`,s=ae.get(r);if(s!==void 0)return s;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${M}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let o=await qa(),l=o[e];if(!l&&a&&(l=o[a],l&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${a}`)),!l&&t.path){let c=t.path.split("/");if(c.length>=2){let p=c[c.length-1].split(".")[0];o[p]&&(l=o[p],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${p}`))}}if(console.log("[AssetLoader] Inline data for",e,":",l?"FOUND":"NOT FOUND"),M==="publish"&&re!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!l))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${t.path}`);let u=zi.get(t.type);if(u)try{let c=await u(t.path,l,e,i);return ae.set(r,c),c}catch(c){return this.handleFailure(e,t.type,c)}try{let c;switch(t.type){case"image":c=await this.loadImage(t.path,l);break;case"json":c=await this.loadJSON(t.path,l),c=yn(c);break;default:throw new Error(`Unknown asset type: ${t.type}`)}return ae.set(r,c),c}catch(c){return this.handleFailure(e,t.type,c)}}static async loadImage(e,t){let i=M==="publish",a=i&&re!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${M}, isPublishMode: ${i}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof t!="string"||!t.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof t}`);try{return await pe.Assets.load(t)}catch(r){throw console.error("[AssetLoader] Failed to load texture from data URI:",r),r}}if(t&&typeof t=="string"&&t.startsWith("data:"))try{return await pe.Assets.load(t)}catch(r){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",r),await pe.Assets.load(e)}return await pe.Assets.load(e)}static async loadJSON(e,t){let i=M==="publish",a=i&&re!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${M}, isPublishMode: ${i}, inlineData: ${t?"EXISTS":"MISSING"}`),a){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!t)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let s=atob(t.split(",")[1]);return JSON.parse(s)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let s=atob(t.split(",")[1]);return JSON.parse(s)}return JSON.parse(t)}let r=await fetch(e);if(!r.ok)throw new Error(`JSON fetch failed: ${e}`);return r.json()}static handleFailure(e,t,i){if(M==="dev"){let r=t==="image"?Va():yn({__placeholder:!0,type:t});return ae.set(e+":"+((i==null?void 0:i.path)||"missing"),r),r}throw i}};$t("image",async(n,e)=>{let t=M==="publish",i=t&&re!==!1,a=M==="brand",r=t&&re===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${M}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${n}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return pe.Assets.load(e)}let s=n;return(a||r)&&n&&!n.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(s=n,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${n}" as-is`)):(s=`assets/${n}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${n}" -> "${s}"`))),pe.Assets.load(e||s)});$t("json",async(n,e)=>{let t=M==="publish",i=t&&re!==!1,a=M==="brand",r=t&&re===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${M}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),i){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${n}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let s=n;if((a||r)&&n&&!n.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(s=n,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${n}" as-is`)):(s=`assets/${n}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${n}" -> "${s}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let o=await fetch(s);if(!o.ok)throw new Error(`JSON fetch failed: ${n}`);return o.json()})});function Ht(n,e){$i.init(n,e),typeof window!="undefined"&&(window.__AssetTextures=Te)}var vn,$i,Te,gt=le(()=>{"use strict";Dt();vn=class{constructor(){this.textures=new Map;this.readyPromise=null;this.priorityReadyPromise=null;this.priorityReadyResolve=null;this.config=null;this.app=null;this.attempted=new Set;this.waiters=new Set}init(e,t){if(this.config===e&&this.app===t&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.attempted.clear(),this.waiters.clear(),this.priorityReadyPromise=new Promise(i=>{this.priorityReadyResolve=i}),this.config=e,this.app=t,console.log("[AssetTextures] Initialized with config, cleared previous textures")}async ready(){if(this.readyPromise){await this.readyPromise;return}if(!this.config)throw new Error("[AssetTextures] Must call init() before ready() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before ready() - app is null");let e=this.config,t=this.app;return this.readyPromise=(async()=>{var s;console.log("[AssetTextures] Loading all assets...");let i=new Set(["background_loading_1"]),a=[],r=[];for(let[o,l]of e.objects.entries()){let d=(s=l.render)==null?void 0:s.asset;if(!d)continue;let u=async()=>{var c;try{let p=(c=l.identity)==null?void 0:c.id;console.log(`[AssetTextures] Loading ${d.type}: ${o} (${p})`);let g=await Ce.load(o,d,t,p);this.textures.set(o,g),console.log(`[AssetTextures] \u2713 Loaded: ${o}`)}catch(p){console.error(`[AssetTextures] \u2717 Failed to load: ${o}`,p)}finally{this.attempted.add(o);try{for(let p of Array.from(this.waiters))p()}catch{}}};i.has(o)?a.push(u()):r.push(u())}a.length>0&&(console.log("[AssetTextures] Phase 1: Loading priority assets (loading screen)..."),await Promise.all(a),console.log("[AssetTextures] Phase 1: Priority assets ready")),this.priorityReadyResolve&&this.priorityReadyResolve(),console.log("[AssetTextures] Phase 2: Loading remaining assets..."),await Promise.all(r),console.log("[AssetTextures] All textures loaded:",Array.from(this.textures.keys()))})(),this.readyPromise}async priorityReady(){return this.priorityReadyPromise?this.priorityReadyPromise:Promise.resolve()}async waitFor(e,t={}){if(!this.config)throw new Error("[AssetTextures] Must call init() before waitFor() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before waitFor() - app is null");let a=Array.from(new Set((e||[]).filter(o=>typeof o=="string"&&o))).filter(o=>{var l,d,u,c;try{let p=(u=(d=(l=this.config)==null?void 0:l.objects)==null?void 0:d.get)==null?void 0:u.call(d,o);return!!((c=p==null?void 0:p.render)!=null&&c.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let r=()=>a.every(o=>this.textures.has(o)||this.attempted.has(o));if(r())return;let s=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(o=>{let l=!1,d=()=>{l||r()&&(l=!0,this.waiters.delete(d),o())};this.waiters.add(d),d(),s>0&&setTimeout(()=>{l||(l=!0,this.waiters.delete(d),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),o())},s)})}get(e){return this.textures.get(e)}set(e,t){this.textures.set(e,t),console.log(`[AssetTextures] Updated texture: ${e}`)}clear(){this.textures.clear(),this.readyPromise=null,console.log("[AssetTextures] Cleared all textures")}getAllIds(){return Array.from(this.textures.keys())}},$i=new vn,Te=new Proxy($i,{get(n,e){return e in n&&typeof n[e]=="function"?n[e].bind(n):n.get(e)},set(n,e,t){return n.set(e,t),!0}})});var Ni={};Wn(Ni,{AssetEditorModal:()=>An});var An,Cn=le(()=>{"use strict";An=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,i,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=i,this.onApplyCallback=a,this.createModal(e,i),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let i=document.createElement("div");i.className="asset-editor-modal",i.innerHTML=`
2
2
  <div class="asset-editor-card">
3
3
  <div class="asset-editor-header">
4
4
  <div>
@@ -43,7 +43,7 @@
43
43
  <button class="debug-btn primary" data-modal-apply>Apply</button>
44
44
  </div>
45
45
  </div>
46
- `,this.modal=i}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let d=o.target.dataset.tab;d&&this.switchTab(d)})});let i=this.modal.querySelector("[data-ai-generate]");i==null||i.addEventListener("click",()=>{this.openAiEditor("generate")});let a=this.modal.querySelector("[data-ai-edit]");a==null||a.addEventListener("click",()=>{this.openAiEditor("edit")});let r=this.modal.querySelector("[data-modal-apply]");r==null||r.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",s=>{s.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let t=window.__openAiEditor;if(typeof t!="function"){alert("AI Editor not available. Please check your setup.");return}let i="";e==="edit"&&this.currentAsset?i=`Edit this image: ${this.currentObjectId}`:i=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",i,this.currentAsset,{path:this.currentPath,onApply:a=>{this.onApplyCallback&&this.onApplyCallback(a),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var Nr={};Wn(Nr,{AssetCache:()=>ae,AssetLoader:()=>Ce,AssetSystem:()=>Kt,AssetTextures:()=>Te,Assets:()=>ua,BaseSystem:()=>Ze,GameEngine:()=>Yt,GameObject:()=>At,GameObjectManager:()=>Xe,ObjectFactory:()=>Le,Renderer:()=>St,RuntimeObjectRegistry:()=>Qe,Transform:()=>Et,applyScreenAnchor:()=>Zt,basePixi:()=>la,clearResponsiveElements:()=>ha,createPixiBase:()=>Vt,getRegisteredFontIds:()=>aa,globalResponsiveMultipliers:()=>Tt,initAssetTextures:()=>Ht,initAssets:()=>ga,layout:()=>ma,playLottieOverlay:()=>sa,registerFont:()=>ia,registerType:()=>$t,resolveAnchorVec2:()=>$e,resolveFont:()=>ta,resolveFontWeight:()=>na,resolveScreenAnchorPoint:()=>et,resolveScreenRatioPoint:()=>tt,runInitSequence:()=>ba,setLottieInstance:()=>Nt,spawnSceneFromConfig:()=>da,updateScreenState:()=>Jt});module.exports=Sa(Nr);var ea=require("pixi.js");var Se={};function _t(n,e,t=!1){Se[n]||(Se[n]=[]),Se[n].push({fn:e,once:t})}function on(n,e){if(Se[n]){if(!e){delete Se[n];return}Se[n]=Se[n].filter(t=>t.fn!==e)}}function Ot(n,...e){let t=Se[n];if(t)for(let i of[...t])i.fn(...e),i.once&&on(n,i.fn)}function J(n,e){_t(n,e,!0)}var $=null,ee=[],He=null;function Jn(n){$=n,ee=[],He!==null&&(clearTimeout(He),He=null)}function Zn(){var n,e,t;return{endpoint:($==null?void 0:$.endpoint)||"",transport:($==null?void 0:$.transport)||"beacon",batchSize:(n=$==null?void 0:$.batchSize)!=null?n:10,flushIntervalMs:(e=$==null?void 0:$.flushIntervalMs)!=null?e:300,maxQueue:(t=$==null?void 0:$.maxQueue)!=null?t:200,debug:!!($!=null&&$.debug)}}async function Kn(n,e,t,i){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(n,new Blob([a],{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(n,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function ln(n,e){let t=Zn();if(e&&t.endpoint){if(ee.push(n),ee.length>t.maxQueue&&(ee=ee.slice(ee.length-t.maxQueue)),ee.length>=t.batchSize){Xn();return}He===null&&(He=window.setTimeout(()=>{He=null,Xn()},t.flushIntervalMs))}}async function Xn(){let n=Zn();if(!n.endpoint||ee.length===0)return;let e=ee.splice(0,n.batchSize);await Kn(n.endpoint,{events:e},n.transport,n.debug),ee.length>0&&await Kn(n.endpoint,{events:ee.splice(0,n.batchSize)},n.transport,n.debug)}function Qn(n){return Math.max(0,Math.min(1,n))}function Aa(n){let e=String(n!=null?n:"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 a=>1+(i+1)*Math.pow(a-1,3)+i*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function ut(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Ca(n,e){let t=n==null?void 0:n[e];return typeof t=="number"?t:0}function ei(n,e,t){try{n[e]=t}catch{}}function Ta(n){let e=n==null?void 0:n.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 ti(n,e){let t=n==null?void 0:n.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 ni(n,e){let t=Ta(n);if(!t)return{from:null,to:null};let i=null,a=null;return typeof e.scale=="number"?(i=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),i===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:i!=null?i:t.x,y:a!=null?a:t.y}}}function ii(){let n=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),n.size>0&&i()})},a=u=>{var p;n.add(u);let c=(p=e.get(u.target))!=null?p:new Set;c.add(u),e.set(u.target,c),i()},r=u=>{n.delete(u);let c=e.get(u.target);c&&(c.delete(u),c.size===0&&e.delete(u.target))},s=u=>{u.killed||(u.killed=!0,r(u))},o=()=>{var c,p;let u=ut();for(let g of Array.from(n)){if(g.killed||g.paused)continue;let m=u-g.startMs-g.delayMs;if(m<0)continue;let f=g.durationMs>0?m/g.durationMs:1,A=Qn(f),b=g.repeat>=0?g.repeat+1:1,h=g.repeat>0?Math.min(Math.floor(f),b-1):0;if(g.repeat>0&&f>=1){let y=f-h;A=Qn(y)}let v=g.ease(A);g.yoyo&&h%2===1&&(v=1-v);for(let y of g.props)ei(g.target,y.key,y.from+(y.to-y.from)*v);g.scaleFrom&&g.scaleTo&&ti(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{(c=g.onUpdate)==null||c.call(g)}catch{}if(f>=b){s(g);try{(p=g.onComplete)==null||p.call(g)}catch{}}}},l=(u,c,p)=>{var y;let g=Math.max(0,(typeof c.duration=="number"?c.duration:.5)*1e3),m=Math.max(0,(typeof c.delay=="number"?c.delay:0)*1e3+((y=p==null?void 0:p.delayMsOverride)!=null?y:0)),f=Aa(c.ease),A=typeof c.repeat=="number"?Math.max(0,c.repeat|0):0,b=c.yoyo===!0,h=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let I of Object.keys(c)){if(h.has(I))continue;let P=c[I];typeof P=="number"&&v.push({key:I,from:Ca(u,I),to:P})}let w=ni(u,c);return{target:u,startMs:ut(),delayMs:m,durationMs:g,ease:f,props:v,scaleFrom:w.from,scaleTo:w.to,repeat:A,yoyo:b,onUpdate:typeof c.onUpdate=="function"?c.onUpdate:void 0,onComplete:typeof c.onComplete=="function"?c.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},d={to(u,c){let p=l(u,c);return a(p),{kill:()=>s(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=ut())},resume:()=>{var f;if(!p.paused)return;let g=(f=p.pauseAtMs)!=null?f:ut(),m=ut()-g;p.startMs+=m,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(u,c,p){return d.set(u,c),d.to(u,p)},set(u,c){if(!u||!c)return;for(let g of Object.keys(c)){let m=c[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof m=="number"&&ei(u,g,m)}let p=ni(u,c);p.to&&ti(u,p.to)},killTweensOf(u){let c=e.get(u);if(c)for(let p of Array.from(c))s(p)},timeline(u={}){let c=[],p=0,g=!1,m=[],f=h=>{if(typeof h=="number")return Math.max(0,h*1e3);let v=typeof h=="string"?h.trim():"";return v.startsWith("+=")?p+Math.max(0,Number(v.slice(2))*1e3||0):v?Math.max(0,Number(v)*1e3||0):p},A=h=>{c.push(h);let v=Math.max(0,(typeof h.vars.duration=="number"?h.vars.duration:.5)*1e3);p=Math.max(p,h.atMs+v)},b={to(h,v,w){return A({kind:"to",target:h,vars:v,atMs:f(w)}),b},fromTo(h,v,w,y){return A({kind:"fromTo",target:h,vars:w,from:v,atMs:f(y)}),b},play(){var h,v;if(g)return b;g=!0,m=[];for(let w of c)w.kind==="fromTo"&&d.set(w.target,(h=w.from)!=null?h:{}),m.push(d.to(w.target,{...w.vars,delay:w.atMs/1e3+((v=w.vars.delay)!=null?v:0)}));return b},pause(){for(let h of m)h.pause();return b},kill(){for(let h of m)h.kill();m=[],g=!1}};return u.paused||b.play(),b}};return d}function ai(){if(typeof window=="undefined")return;let n=window;if(!n.gsap)try{n.gsap=ii()}catch{}}var ri={name:"handler-playable-sdk",version:"0.5.43",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 Z=0,ka=Z++,si=Z++,oi=Z++,li=Z++,ci=Z++,di=Z++,pi=Z++,ui=Z++,gi=Z++,hi=Z++,fi=Z++,mi=Z++,O=ka;function bi(){return O===si}function yi(){return O===oi}function vi(){return O===li}function wi(){return O===ci}function Ne(){return O===di}function Fe(){return O===pi}function xi(){return O===ui}function Ei(){return O===gi}function Si(){return O===hi}function cn(){return O===fi}function dn(){return O===mi}function Ai(){let n=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(n==="mraid")try{mraid.getState(),O=si;return}catch{}else if(n==="dapi")try{dapi.isReady(),O=oi;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(O=li)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(O=ci)}catch{}else if(e==="mintegral")window.gameReady&&(O=di);else if(e==="tapjoy")window.TJ_API&&(O=pi);else if(e==="tiktok")window.openAppStore&&(O=ui);else if(e==="smadex")try{window.smxTracking&&(O=gi)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(O=hi)}catch{}else e==="vungle"?O=fi:(n==="nucleo"||e==="nucleo")&&(O=mi)}var jt=Pt(require("lottie-web"),1),Ci=jt.default;typeof window!="undefined"&&(window.lottie=jt.default,window.__baseLottie=jt.default);gn();function D(n,e){let t=(a,r)=>r===0?a:t(r,a%r),i=t(n,e);return`${n/i}:${e/i}`}var vs=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:D(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:D(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:D(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:D(360,780)}],ws=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:D(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:D(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:D(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:D(412,915)}],xs=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:D(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:D(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:D(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:D(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:D(800,1280)}],Ii=[{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:D(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:D(768,1024),mraidScale:.7}];var Es=[...Ii];var za=Ii[0];ce();var Fa=Pt(require("jszip"),1);function Da(n){return new Promise((e,t)=>{let i=new FileReader;i.onerror=()=>t(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(n)})}function Ha(n){var a;let[e,t]=n.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}async function Na(n){return await new Promise(e=>{let t=new Image;t.onload=()=>e({width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}),t.onerror=()=>e(null),t.src=n})}async function hn(n){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",n);let i=await fetch(n);if(!i.ok)return console.warn("[ImageUtils] Fetch failed with status:",i.status,n),null;let a=await i.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let r=await Da(a),s=await Na(r),o=Ha(r);return console.log("[ImageUtils] Success resolution:",s==null?void 0:s.width,"x",s==null?void 0:s.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:r,width:(e=s==null?void 0:s.width)!=null?e:0,height:(t=s==null?void 0:s.height)!=null?t:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function Rt(n,e=30){try{console.log("[ImageUtils] Removing background color...");let t=await new Promise((c,p)=>{let g=new Image;g.onload=()=>c(g),g.onerror=()=>p(new Error("Failed to load image")),g.src=n}),i=document.createElement("canvas");i.width=t.width,i.height=t.height;let a=i.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),n;a.drawImage(t,0,0);let r=a.getImageData(0,0,i.width,i.height),s=r.data,l=[{name:"top-left",offset:0},{name:"top-right",offset:(i.width-1)*4},{name:"bottom-left",offset:(i.height-1)*i.width*4},{name:"bottom-right",offset:((i.height-1)*i.width+(i.width-1))*4}].map(c=>({r:s[c.offset],g:s[c.offset+1],b:s[c.offset+2]})),d=0;for(let c=0;c<s.length;c+=4){let p=s[c],g=s[c+1],m=s[c+2],f=!1;for(let A of l)if(Math.sqrt(Math.pow(p-A.r,2)+Math.pow(g-A.g,2)+Math.pow(m-A.b,2))<e){f=!0;break}f&&(s[c+3]=0,d++)}return console.log(`[ImageUtils] Removed background from ${d} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),i.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),n}}var Pi=require("@google/genai");async function fn(n,e,t=[],i={}){var a,r,s,o,l,d,u;try{if(!(n!=null&&n.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let b=0;b<t.length;b++){let h=t[b];if(!h.base64||!h.mimeType)throw new Error(`Image ${b+1} is missing required data`);if(h.base64.length<1e3&&console.warn(`Image ${b+1} data appears very small, may be corrupted`),!h.mimeType.startsWith("image/"))throw new Error(`Image ${b+1} has invalid MIME type: ${h.mimeType}`)}let c=new Pi.GoogleGenAI({apiKey:n}),p="gemini-2.5-flash",g=[e];t.length>0&&t.forEach((b,h)=>{g.push({inlineData:{data:b.base64,mimeType:b.mimeType}}),console.log(`[Gemini] Added image ${h+1}: ${b.mimeType}, size: ${Math.round(b.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${t.length} images and prompt length: ${e.length}`);let m=await c.models.generateContent({model:p,contents:g}),f="",A=(s=(r=(a=m.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:s.parts;if(A)for(let b of A)b.text&&(f+=b.text);if(!f.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${f.length}`),f}catch(c){throw console.error("[Gemini] API error:",c),(o=c.message)!=null&&o.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(l=c.message)!=null&&l.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(d=c.message)!=null&&d.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(u=c.message)!=null&&u.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):c}}var _i=require("@google/genai");async function zt(n,e,t=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new _i.GoogleGenAI({apiKey:n}),r=[{text:e}];t.length>0&&t.forEach((o,l)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${l}`),r.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let s=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!s.candidates||!s.candidates[0]||!s.candidates[0].content||!s.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of s.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let l=o.inlineData.data,d=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${d};base64,${l}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(a){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(a,Object.getOwnPropertyNames(a),2)),a}}var Wa=require("pixi.js");gt();ce();var Di=require("pixi.js");var Ya=require("pixi.js");ce();function nr(n){return new Promise((e,t)=>{let i=new FileReader;i.onerror=()=>t(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(n)})}function ir(n){var a;let[e,t]=n.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}function ar(n){return`
46
+ `,this.modal=i}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(s=>{s.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(s=>{s.addEventListener("click",o=>{let d=o.target.dataset.tab;d&&this.switchTab(d)})});let i=this.modal.querySelector("[data-ai-generate]");i==null||i.addEventListener("click",()=>{this.openAiEditor("generate")});let a=this.modal.querySelector("[data-ai-edit]");a==null||a.addEventListener("click",()=>{this.openAiEditor("edit")});let r=this.modal.querySelector("[data-modal-apply]");r==null||r.addEventListener("click",()=>{this.apply()}),this.modal.addEventListener("click",s=>{s.target===this.modal&&this.close()})}switchTab(e){if(!this.modal)return;this.modal.querySelectorAll("[data-tab]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===e)}),this.modal.querySelectorAll("[data-tab-panel]").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab-panel")===e)})}openAiEditor(e){let t=window.__openAiEditor;if(typeof t!="function"){alert("AI Editor not available. Please check your setup.");return}let i="";e==="edit"&&this.currentAsset?i=`Edit this image: ${this.currentObjectId}`:i=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",i,this.currentAsset,{path:this.currentPath,onApply:a=>{this.onApplyCallback&&this.onApplyCallback(a),this.close()}})}apply(){this.onApplyCallback&&this.onApplyCallback("library/placeholder.png"),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.currentObjectId=null,this.currentPath=null,this.onApplyCallback=null}}});var Nr={};Wn(Nr,{AssetCache:()=>ae,AssetLoader:()=>Ce,AssetSystem:()=>Kt,AssetTextures:()=>Te,Assets:()=>ua,BaseSystem:()=>Ze,GameEngine:()=>Yt,GameObject:()=>At,GameObjectManager:()=>Xe,ObjectFactory:()=>Le,Renderer:()=>St,RuntimeObjectRegistry:()=>Qe,Transform:()=>Et,applyScreenAnchor:()=>Zt,basePixi:()=>la,clearResponsiveElements:()=>ha,createPixiBase:()=>Vt,getRegisteredFontIds:()=>aa,globalResponsiveMultipliers:()=>Tt,initAssetTextures:()=>Ht,initAssets:()=>ga,layout:()=>ma,playLottieOverlay:()=>sa,registerFont:()=>ia,registerType:()=>$t,resolveAnchorVec2:()=>$e,resolveFont:()=>ta,resolveFontWeight:()=>na,resolveScreenAnchorPoint:()=>et,resolveScreenRatioPoint:()=>tt,runInitSequence:()=>ba,setLottieInstance:()=>Nt,spawnSceneFromConfig:()=>da,updateScreenState:()=>Jt});module.exports=Sa(Nr);var ea=require("pixi.js");var Se={};function _t(n,e,t=!1){Se[n]||(Se[n]=[]),Se[n].push({fn:e,once:t})}function on(n,e){if(Se[n]){if(!e){delete Se[n];return}Se[n]=Se[n].filter(t=>t.fn!==e)}}function jt(n,...e){let t=Se[n];if(t)for(let i of[...t])i.fn(...e),i.once&&on(n,i.fn)}function J(n,e){_t(n,e,!0)}var $=null,ee=[],He=null;function Jn(n){$=n,ee=[],He!==null&&(clearTimeout(He),He=null)}function Zn(){var n,e,t;return{endpoint:($==null?void 0:$.endpoint)||"",transport:($==null?void 0:$.transport)||"beacon",batchSize:(n=$==null?void 0:$.batchSize)!=null?n:10,flushIntervalMs:(e=$==null?void 0:$.flushIntervalMs)!=null?e:300,maxQueue:(t=$==null?void 0:$.maxQueue)!=null?t:200,debug:!!($!=null&&$.debug)}}async function Kn(n,e,t,i){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(n,new Blob([a],{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(n,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),i&&console.log("[handler.telemetry] fetch",e)}catch(r){i&&console.warn("[handler.telemetry] fetch failed",r)}}function ln(n,e){let t=Zn();if(e&&t.endpoint){if(ee.push(n),ee.length>t.maxQueue&&(ee=ee.slice(ee.length-t.maxQueue)),ee.length>=t.batchSize){Xn();return}He===null&&(He=window.setTimeout(()=>{He=null,Xn()},t.flushIntervalMs))}}async function Xn(){let n=Zn();if(!n.endpoint||ee.length===0)return;let e=ee.splice(0,n.batchSize);await Kn(n.endpoint,{events:e},n.transport,n.debug),ee.length>0&&await Kn(n.endpoint,{events:ee.splice(0,n.batchSize)},n.transport,n.debug)}function Qn(n){return Math.max(0,Math.min(1,n))}function Aa(n){let e=String(n!=null?n:"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 a=>1+(i+1)*Math.pow(a-1,3)+i*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function ut(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Ca(n,e){let t=n==null?void 0:n[e];return typeof t=="number"?t:0}function ei(n,e,t){try{n[e]=t}catch{}}function Ta(n){let e=n==null?void 0:n.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 ti(n,e){let t=n==null?void 0:n.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 ni(n,e){let t=Ta(n);if(!t)return{from:null,to:null};let i=null,a=null;return typeof e.scale=="number"?(i=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(i=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(i=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),i===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:i!=null?i:t.x,y:a!=null?a:t.y}}}function ii(){let n=new Set,e=new WeakMap,t=null,i=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,o(),n.size>0&&i()})},a=u=>{var p;n.add(u);let c=(p=e.get(u.target))!=null?p:new Set;c.add(u),e.set(u.target,c),i()},r=u=>{n.delete(u);let c=e.get(u.target);c&&(c.delete(u),c.size===0&&e.delete(u.target))},s=u=>{u.killed||(u.killed=!0,r(u))},o=()=>{var c,p;let u=ut();for(let g of Array.from(n)){if(g.killed||g.paused)continue;let m=u-g.startMs-g.delayMs;if(m<0)continue;let f=g.durationMs>0?m/g.durationMs:1,A=Qn(f),b=g.repeat>=0?g.repeat+1:1,h=g.repeat>0?Math.min(Math.floor(f),b-1):0;if(g.repeat>0&&f>=1){let y=f-h;A=Qn(y)}let v=g.ease(A);g.yoyo&&h%2===1&&(v=1-v);for(let y of g.props)ei(g.target,y.key,y.from+(y.to-y.from)*v);g.scaleFrom&&g.scaleTo&&ti(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{(c=g.onUpdate)==null||c.call(g)}catch{}if(f>=b){s(g);try{(p=g.onComplete)==null||p.call(g)}catch{}}}},l=(u,c,p)=>{var y;let g=Math.max(0,(typeof c.duration=="number"?c.duration:.5)*1e3),m=Math.max(0,(typeof c.delay=="number"?c.delay:0)*1e3+((y=p==null?void 0:p.delayMsOverride)!=null?y:0)),f=Aa(c.ease),A=typeof c.repeat=="number"?Math.max(0,c.repeat|0):0,b=c.yoyo===!0,h=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),v=[];for(let I of Object.keys(c)){if(h.has(I))continue;let P=c[I];typeof P=="number"&&v.push({key:I,from:Ca(u,I),to:P})}let w=ni(u,c);return{target:u,startMs:ut(),delayMs:m,durationMs:g,ease:f,props:v,scaleFrom:w.from,scaleTo:w.to,repeat:A,yoyo:b,onUpdate:typeof c.onUpdate=="function"?c.onUpdate:void 0,onComplete:typeof c.onComplete=="function"?c.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},d={to(u,c){let p=l(u,c);return a(p),{kill:()=>s(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=ut())},resume:()=>{var f;if(!p.paused)return;let g=(f=p.pauseAtMs)!=null?f:ut(),m=ut()-g;p.startMs+=m,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(u,c,p){return d.set(u,c),d.to(u,p)},set(u,c){if(!u||!c)return;for(let g of Object.keys(c)){let m=c[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof m=="number"&&ei(u,g,m)}let p=ni(u,c);p.to&&ti(u,p.to)},killTweensOf(u){let c=e.get(u);if(c)for(let p of Array.from(c))s(p)},timeline(u={}){let c=[],p=0,g=!1,m=[],f=h=>{if(typeof h=="number")return Math.max(0,h*1e3);let v=typeof h=="string"?h.trim():"";return v.startsWith("+=")?p+Math.max(0,Number(v.slice(2))*1e3||0):v?Math.max(0,Number(v)*1e3||0):p},A=h=>{c.push(h);let v=Math.max(0,(typeof h.vars.duration=="number"?h.vars.duration:.5)*1e3);p=Math.max(p,h.atMs+v)},b={to(h,v,w){return A({kind:"to",target:h,vars:v,atMs:f(w)}),b},fromTo(h,v,w,y){return A({kind:"fromTo",target:h,vars:w,from:v,atMs:f(y)}),b},play(){var h,v;if(g)return b;g=!0,m=[];for(let w of c)w.kind==="fromTo"&&d.set(w.target,(h=w.from)!=null?h:{}),m.push(d.to(w.target,{...w.vars,delay:w.atMs/1e3+((v=w.vars.delay)!=null?v:0)}));return b},pause(){for(let h of m)h.pause();return b},kill(){for(let h of m)h.kill();m=[],g=!1}};return u.paused||b.play(),b}};return d}function ai(){if(typeof window=="undefined")return;let n=window;if(!n.gsap)try{n.gsap=ii()}catch{}}var ri={name:"handler-playable-sdk",version:"0.5.45",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 Z=0,ka=Z++,si=Z++,oi=Z++,li=Z++,ci=Z++,di=Z++,pi=Z++,ui=Z++,gi=Z++,hi=Z++,fi=Z++,mi=Z++,j=ka;function bi(){return j===si}function yi(){return j===oi}function vi(){return j===li}function wi(){return j===ci}function Ne(){return j===di}function Fe(){return j===pi}function xi(){return j===ui}function Ei(){return j===gi}function Si(){return j===hi}function cn(){return j===fi}function dn(){return j===mi}function Ai(){let n=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(n==="mraid")try{mraid.getState(),j=si;return}catch{}else if(n==="dapi")try{dapi.isReady(),j=oi;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(j=li)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(j=ci)}catch{}else if(e==="mintegral")window.gameReady&&(j=di);else if(e==="tapjoy")window.TJ_API&&(j=pi);else if(e==="tiktok")window.openAppStore&&(j=ui);else if(e==="smadex")try{window.smxTracking&&(j=gi)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(j=hi)}catch{}else e==="vungle"?j=fi:(n==="nucleo"||e==="nucleo")&&(j=mi)}var Ot=Pt(require("lottie-web"),1),Ci=Ot.default;typeof window!="undefined"&&(window.lottie=Ot.default,window.__baseLottie=Ot.default);gn();function D(n,e){let t=(a,r)=>r===0?a:t(r,a%r),i=t(n,e);return`${n/i}:${e/i}`}var vs=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:D(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:D(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:D(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:D(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:D(360,780)}],ws=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:D(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:D(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:D(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:D(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:D(412,915)}],xs=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:D(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:D(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:D(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:D(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:D(800,1280)}],Ii=[{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:D(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:D(768,1024),mraidScale:.7}];var Es=[...Ii];var za=Ii[0];ce();var Fa=Pt(require("jszip"),1);function Da(n){return new Promise((e,t)=>{let i=new FileReader;i.onerror=()=>t(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(n)})}function Ha(n){var a;let[e,t]=n.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}async function Na(n){return await new Promise(e=>{let t=new Image;t.onload=()=>e({width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}),t.onerror=()=>e(null),t.src=n})}async function hn(n){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",n);let i=await fetch(n);if(!i.ok)return console.warn("[ImageUtils] Fetch failed with status:",i.status,n),null;let a=await i.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let r=await Da(a),s=await Na(r),o=Ha(r);return console.log("[ImageUtils] Success resolution:",s==null?void 0:s.width,"x",s==null?void 0:s.height,"mime:",o.mimeType),{base64:o.base64,mimeType:o.mimeType,dataUrl:r,width:(e=s==null?void 0:s.width)!=null?e:0,height:(t=s==null?void 0:s.height)!=null?t:0}}catch(i){return console.error("[ImageUtils] Error fetching image data:",i),null}}async function Rt(n,e=30){try{console.log("[ImageUtils] Removing background color...");let t=await new Promise((c,p)=>{let g=new Image;g.onload=()=>c(g),g.onerror=()=>p(new Error("Failed to load image")),g.src=n}),i=document.createElement("canvas");i.width=t.width,i.height=t.height;let a=i.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),n;a.drawImage(t,0,0);let r=a.getImageData(0,0,i.width,i.height),s=r.data,l=[{name:"top-left",offset:0},{name:"top-right",offset:(i.width-1)*4},{name:"bottom-left",offset:(i.height-1)*i.width*4},{name:"bottom-right",offset:((i.height-1)*i.width+(i.width-1))*4}].map(c=>({r:s[c.offset],g:s[c.offset+1],b:s[c.offset+2]})),d=0;for(let c=0;c<s.length;c+=4){let p=s[c],g=s[c+1],m=s[c+2],f=!1;for(let A of l)if(Math.sqrt(Math.pow(p-A.r,2)+Math.pow(g-A.g,2)+Math.pow(m-A.b,2))<e){f=!0;break}f&&(s[c+3]=0,d++)}return console.log(`[ImageUtils] Removed background from ${d} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),i.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),n}}var Pi=require("@google/genai");async function fn(n,e,t=[],i={}){var a,r,s,o,l,d,u;try{if(!(n!=null&&n.trim()))throw new Error("Gemini API key is required");if(!(e!=null&&e.trim()))throw new Error("Prompt is required");for(let b=0;b<t.length;b++){let h=t[b];if(!h.base64||!h.mimeType)throw new Error(`Image ${b+1} is missing required data`);if(h.base64.length<1e3&&console.warn(`Image ${b+1} data appears very small, may be corrupted`),!h.mimeType.startsWith("image/"))throw new Error(`Image ${b+1} has invalid MIME type: ${h.mimeType}`)}let c=new Pi.GoogleGenAI({apiKey:n}),p="gemini-2.5-flash",g=[e];t.length>0&&t.forEach((b,h)=>{g.push({inlineData:{data:b.base64,mimeType:b.mimeType}}),console.log(`[Gemini] Added image ${h+1}: ${b.mimeType}, size: ${Math.round(b.base64.length/1024)}KB`)}),console.log(`[Gemini] Making request with ${t.length} images and prompt length: ${e.length}`);let m=await c.models.generateContent({model:p,contents:g}),f="",A=(s=(r=(a=m.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:s.parts;if(A)for(let b of A)b.text&&(f+=b.text);if(!f.trim())throw new Error("Empty response from Gemini API");return console.log(`[Gemini] Response received, length: ${f.length}`),f}catch(c){throw console.error("[Gemini] API error:",c),(o=c.message)!=null&&o.includes("Unable to process input image")?new Error("Unable to process the uploaded image. Please ensure it's a valid PNG, JPG, or JPEG file under 10MB and not corrupted."):(l=c.message)!=null&&l.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(d=c.message)!=null&&d.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(u=c.message)!=null&&u.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):c}}var _i=require("@google/genai");async function zt(n,e,t=[],i={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new _i.GoogleGenAI({apiKey:n}),r=[{text:e}];t.length>0&&t.forEach((o,l)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${l}`),r.push({inlineData:{mimeType:o.mimeType,data:o.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let s=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!s.candidates||!s.candidates[0]||!s.candidates[0].content||!s.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let o of s.candidates[0].content.parts)if(o.text)console.log(o.text);else if(o.inlineData){let l=o.inlineData.data,d=o.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${d};base64,${l}`}throw new Error("Gemini 2.5 Flash Image returned no image data.")}catch(a){throw console.error("[GEMINI-REAL-SDK] Error in generateImageWithGemini25Flash:",JSON.stringify(a,Object.getOwnPropertyNames(a),2)),a}}var Wa=require("pixi.js");gt();ce();var Di=require("pixi.js");var Ya=require("pixi.js");ce();function nr(n){return new Promise((e,t)=>{let i=new FileReader;i.onerror=()=>t(new Error("FileReader failed")),i.onload=()=>e(String(i.result||"")),i.readAsDataURL(n)})}function ir(n){var a;let[e,t]=n.split(","),i=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=i==null?void 0:i[1])!=null?a:"image/png"}}function ar(n){return`
47
47
  Analyze these screenshots of a brand or game and extract its "Brand DNA".
48
48
 
49
49
  Provide a concise summary (2-3 sentences) covering:
@@ -62,7 +62,7 @@ ADDITIONAL RULES/NOTES:
62
62
  ${n}`:""}
63
63
  `.trim()}function Hi(){let n=[],e="",t=null;return{async addSources(i){let a=[];for(let r of i){let s=await nr(r),o=ir(s),l={id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,name:r.name,base64:o.base64,mimeType:o.mimeType,dataUrl:s};n.push(l),a.push(l)}return a},getSources(){return n.slice()},async analyze(i,a,r){if(n.length===0)throw new Error("No screenshots to analyze.");let s=ar(a),o=n.map(p=>({base64:p.base64,mimeType:p.mimeType})),l=await fn(i,s,o,{model:r}),d=e,u=[],c=l.split(`
64
64
  `);for(let p of c)if(p.toLowerCase().startsWith("summary:"))d=p.slice(8).trim();else if(p.toLowerCase().includes("palette:")){let g=p.match(/#[0-9A-Fa-f]{6}/g);g&&g.forEach(m=>{u.includes(m.toUpperCase())||u.push(m.toUpperCase())})}return(!d||d===e)&&(d=l.split(`
65
- Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:d,palette:u.slice(0,10)},t},setSummary(i){e=i,t&&(t={...t,summary:i})},getResult(){return t}}}var je="handler_api_key_";var Be=class{static setKey(e,t,i){try{let a={key:this.encryptKey(t),created:Date.now(),lastUsed:Date.now(),label:i||e},r=`${je}${e}`;localStorage.setItem(r,JSON.stringify(a))}catch(a){console.error("[ApiKeyStorage] Failed to store API key:",a)}}static getKey(e){try{let t=`${je}${e}`,i=localStorage.getItem(t);if(!i)return null;let a=JSON.parse(i);return a.lastUsed=Date.now(),localStorage.setItem(t,JSON.stringify(a)),this.decryptKey(a.key)}catch(t){return console.error("[ApiKeyStorage] Failed to retrieve API key:",t),null}}static hasKey(e){let t=`${je}${e}`;return localStorage.getItem(t)!==null}static removeKey(e){try{let t=`${je}${e}`;localStorage.removeItem(t)}catch(t){console.error("[ApiKeyStorage] Failed to remove API key:",t)}}static getStoredServices(){let e=[];try{for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);if(i&&i.startsWith(je)){let a=i.substring(je.length),r=localStorage.getItem(i);if(r){let s=JSON.parse(r);e.push({service:a,label:s.label,created:s.created,lastUsed:s.lastUsed})}}}}catch(t){console.error("[ApiKeyStorage] Failed to get stored services:",t)}return e.sort((t,i)=>i.lastUsed-t.lastUsed)}static clearAll(){try{let e=[];for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);i&&i.startsWith(je)&&e.push(i)}e.forEach(t=>localStorage.removeItem(t))}catch(e){console.error("[ApiKeyStorage] Failed to clear API keys:",e)}}static encryptKey(e){try{let i="handler_preview_salt_2024"+e;return btoa(i)}catch(t){return console.warn("[ApiKeyStorage] Encryption failed, storing as-is:",t),e}}static decryptKey(e){try{let t=atob(e),i="handler_preview_salt_2024";return t.startsWith(i)?t.substring(i.length):t}catch(t){return console.warn("[ApiKeyStorage] Decryption failed, returning as-is:",t),e}}},wn=()=>Be.getKey("gemini"),xn=(n,e)=>Be.setKey("gemini",n,e),rr=()=>Be.hasKey("gemini");window.ApiKeyStorage=Be;window.getGeminiApiKey=wn;window.setGeminiApiKey=xn;window.hasGeminiApiKey=rr;var Sn=class{constructor(){this.modal=null;this.options=null;this.analyzer=Hi();this.currentPrompt="";this.isGenerating=!1;this.generatedImages=[];this.selectedImageIndex=-1;this.promptInput=null;this.generateBtn=null;this.loadingEl=null;this.galleryEl=null;this.previewEl=null}open(e){this.options=e,this.currentPrompt=e.initialPrompt||"",this.generatedImages=[],this.selectedImageIndex=-1,this.isGenerating=!1,this.createModal(),document.body.appendChild(this.modal),setTimeout(()=>{var t,i;(t=this.promptInput)==null||t.focus(),(i=this.promptInput)==null||i.select()},100)}createModal(){var t;let e=document.createElement("div");e.className="ai-modal",e.innerHTML=`
65
+ Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:d,palette:u.slice(0,10)},t},setSummary(i){e=i,t&&(t={...t,summary:i})},getResult(){return t}}}var Oe="handler_api_key_";var Be=class{static setKey(e,t,i){try{let a={key:this.encryptKey(t),created:Date.now(),lastUsed:Date.now(),label:i||e},r=`${Oe}${e}`;localStorage.setItem(r,JSON.stringify(a))}catch(a){console.error("[ApiKeyStorage] Failed to store API key:",a)}}static getKey(e){try{let t=`${Oe}${e}`,i=localStorage.getItem(t);if(!i)return null;let a=JSON.parse(i);return a.lastUsed=Date.now(),localStorage.setItem(t,JSON.stringify(a)),this.decryptKey(a.key)}catch(t){return console.error("[ApiKeyStorage] Failed to retrieve API key:",t),null}}static hasKey(e){let t=`${Oe}${e}`;return localStorage.getItem(t)!==null}static removeKey(e){try{let t=`${Oe}${e}`;localStorage.removeItem(t)}catch(t){console.error("[ApiKeyStorage] Failed to remove API key:",t)}}static getStoredServices(){let e=[];try{for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);if(i&&i.startsWith(Oe)){let a=i.substring(Oe.length),r=localStorage.getItem(i);if(r){let s=JSON.parse(r);e.push({service:a,label:s.label,created:s.created,lastUsed:s.lastUsed})}}}}catch(t){console.error("[ApiKeyStorage] Failed to get stored services:",t)}return e.sort((t,i)=>i.lastUsed-t.lastUsed)}static clearAll(){try{let e=[];for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);i&&i.startsWith(Oe)&&e.push(i)}e.forEach(t=>localStorage.removeItem(t))}catch(e){console.error("[ApiKeyStorage] Failed to clear API keys:",e)}}static encryptKey(e){try{let i="handler_preview_salt_2024"+e;return btoa(i)}catch(t){return console.warn("[ApiKeyStorage] Encryption failed, storing as-is:",t),e}}static decryptKey(e){try{let t=atob(e),i="handler_preview_salt_2024";return t.startsWith(i)?t.substring(i.length):t}catch(t){return console.warn("[ApiKeyStorage] Decryption failed, returning as-is:",t),e}}},wn=()=>Be.getKey("gemini"),xn=(n,e)=>Be.setKey("gemini",n,e),rr=()=>Be.hasKey("gemini");window.ApiKeyStorage=Be;window.getGeminiApiKey=wn;window.setGeminiApiKey=xn;window.hasGeminiApiKey=rr;var Sn=class{constructor(){this.modal=null;this.options=null;this.analyzer=Hi();this.currentPrompt="";this.isGenerating=!1;this.generatedImages=[];this.selectedImageIndex=-1;this.promptInput=null;this.generateBtn=null;this.loadingEl=null;this.galleryEl=null;this.previewEl=null}open(e){this.options=e,this.currentPrompt=e.initialPrompt||"",this.generatedImages=[],this.selectedImageIndex=-1,this.isGenerating=!1,this.createModal(),document.body.appendChild(this.modal),setTimeout(()=>{var t,i;(t=this.promptInput)==null||t.focus(),(i=this.promptInput)==null||i.select()},100)}createModal(){var t;let e=document.createElement("div");e.className="ai-modal",e.innerHTML=`
66
66
  <div class="ai-modal-card">
67
67
  <div class="ai-modal-header">
68
68
  <div class="ai-modal-actions">
@@ -226,7 +226,7 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
226
226
  <button class="asset-crop-apply primary" data-action="apply">Apply Crop</button>
227
227
  </div>
228
228
  </div>
229
- `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,i=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,i-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,i=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,i,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,i,a),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+i-r,t],[e,t+a-r],[e+i-r,t+a-r]].forEach(([o,l])=>{var d;(d=this.ctx)==null||d.fillRect(o,l,r,r)})}updatePreview(){if(!this.modal||!this.image)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let i=150;e.width=i,e.height=i;let a=i/this.cropWidth,r=i/this.cropHeight,s=Math.min(a,r),o=this.cropWidth*s,l=this.cropHeight*s,d=(i-o)/2,u=(i-l)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,d,u,o,l)}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",i=>{let a=parseFloat(i.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",i=>{let a=i.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let i=e.toDataURL("image/png");this.options.onCrop(i),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(n){new Ln().open(n)};ce();ce();var ht=require("pixi.js");Dt();var sr=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",kn=sr;if(typeof window!="undefined")try{let n=new XMLHttpRequest;if(n.open("GET","./build-settings.json",!1),n.send(),n.status===200&&n.responseText){let e=JSON.parse(n.responseText);e!=null&&e.buildMode&&(kn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${kn}`))}}catch{}function or(n){var t,i,a,r,s;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(n);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(n))return{x:(t=n[0])!=null?t:.5,y:(i=n[1])!=null?i:.5};if(n&&typeof n=="object"&&"x"in n&&"y"in n)return{x:(a=n.x)!=null?a:.5,y:(r=n.y)!=null?r:.5};if(typeof n=="string"){let o=n.trim().toLowerCase();return(s=e[o])!=null?s:{x:.5,y:.5}}return null}var Le=class{static async create(e,t,i){var l,d,u,c,p,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${kn}`);let a=(l=t==null?void 0:t.render)==null?void 0:l.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let f=new ht.Container;return this.applyTransform(f,t==null?void 0:t.transform,t),f}let r=(d=t==null?void 0:t.identity)==null?void 0:d.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${a.type}, path: ${a.path}`);let s=await Ce.load(e,a,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=s==null?void 0:s.constructor)==null?void 0:u.name}`);let o;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",e),o=new ht.Sprite(s),console.log("[ObjectFactory] Created object:",o,"type:",(c=o==null?void 0:o.constructor)==null?void 0:c.name),this.applyTransform(o,t==null?void 0:t.transform,t);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name,s),s&&(((g=s.constructor)==null?void 0:g.name)==="Container"||s instanceof ht.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let f=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],A=!1;for(let b of f)try{let h=await fetch(b);if(h.ok){o=await h.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=o==null?void 0:o.constructor)==null?void 0:m.name),A=!0;break}}catch{continue}A||(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 a,r,s,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(a=t.position.x)!=null?a: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=or(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};ce();var Fi=Pt(require("lottie-web"),1);Nt(Ci);typeof window!="undefined"&&!window.lottie&&(window.lottie=Fi.default);gn();ce();var In=ri.version,cr=new Set(["init","boot","view","ready","start","pause","resume","complete","error","engagement","first_interaction","retry","cta_show","cta_click","cta_dismiss","clickout","conversion","session_time","level_time","load_time","level_start","level_complete","level_fail","checkpoint","reward","tutorial_start","tutorial_complete","tutorial_skip","ab_assign","fps","memory","asset_load_start","asset_load_complete"]);ai();var Yi={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ki=Math.random().toString(36).slice(2),qe=null,Ue={...Yi},Xi="web_embed",On={},bt,Mn=!1,mt=!1,vt=!1,Ji=!1,$n=1,Bt=0,qt=!1,ue=!1,Ge="",Ve=Math.floor(window.innerWidth),We=Math.floor(window.innerHeight),jn=Ve>We,ge=!1,yt=!1,Bi=!1,Ui=!1,Pn=!1,Ut=null,Re=null,Rn=!1,zn=!1,Ft=new Map;function Zi(){if(!Re)return null;let n=Date.now()-Re;return!Number.isFinite(n)||n<0?null:n}function _n(n){if(Rn)return;let e=Zi();e!==null&&(Rn=!0,x("session_time",{duration_ms:e,reason:n}))}function Gi(){if(qe)return qe;let n=document.createElement("div");return n.id="handler-root",n.setAttribute("data-handler-root","true"),document.body.appendChild(n),qe=n,n}function Gt(n){switch(n){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return n}}function Qi(n,e){return{event_name:n,ts:Date.now(),session_id:Ki,deployment_id:Ue.deployment_id,variant_id:Ue.variant_id,export_profile_id:Ue.profile_id,instance_id:Ue.instance_id||"default",env:Xi==="mraid"?"mraid":"web",attribution:bt,payload:e}}function x(n,e){let t=Gt(n),i=Qi(t,e);ln(i,!!On.analytics),Ot(t,i),t!==n&&Ot(n,i)}function wt(){Ut&&(Ut(Ve,We),Ut=null)}function Ye(n){$n=n,x("volume",n)}function Ke(n){n&&(Ji=!0),!vt&&(vt=!0,x("pause"),Ye(0))}function xt(n){!n&&Ji||vt&&(vt=!1,x("resume"),Ye($n))}function ke(n,e){Ve=Math.floor(n||window.innerWidth),We=Math.floor(e||window.innerHeight),jn=Ve>We,x("resize",{width:Ve,height:We})}function dr(){if(bi())try{let n=mraid.getMaxSize();ke(n.width,n.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?xt():Ke()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let t=mraid.getMaxSize();ke(t.width,t.height)}),mraid.getAudioVolume){let t=mraid.getAudioVolume();Ye(t?1:0)}if(mraid.addEventListener("audioVolumeChange",t=>{t!==null&&Ye(t>0?1:0)}),mraid.addEventListener("error",(t,i)=>{console.warn("mraid error:",t,"action:",i)}),qt=!0,mraid.isViewable()&&mraid.getState()!=="hidden")ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt();else{let t=()=>{ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt()};mraid.addEventListener("ready",t)}}catch(n){console.warn("MRAID hook skipped",n)}}function pr(){if(yi())try{let n=dapi.getScreenSize();ke(n.width,n.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?xt():Ke()}),dapi.addEventListener("adResized",t=>{let i=dapi.getScreenSize();ke(t.width||i.width,t.height||i.height)});let e=dapi.getAudioVolume();if(Ye(e?1:0),dapi.addEventListener("audioVolumeChange",t=>Ye(t?1:0)),qt=!0,dapi.isViewable())ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt();else{let t=()=>{ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt()};dapi.addEventListener("ready",t)}}catch(n){console.warn("DAPI hook skipped",n)}}function qi(){let n=()=>{ge||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt(),yt&&(yt=!1,se.start()))};window.addEventListener("resize",()=>ke()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(xt(),n()):Ke()}),document.readyState==="complete"||document.readyState==="interactive"?n():window.addEventListener("load",n),qt=!0}function ur(){let n=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(Bi=!0),!(Bi&&e instanceof MouseEvent)&&(Bt+=1,zn||(zn=!0,x("first_interaction",{count:Bt})),x("interaction",Bt))};document.addEventListener("mousedown",n),document.addEventListener("touchstart",n)}function Vi(n){var i,a,r,s,o,l,d,u,c,p,g,m;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(n||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(Fe())(r=(a=window.TJ_API)==null?void 0:a.click)==null||r.call(a);else if(vi())(o=(s=window.FbPlayableAd)==null?void 0:s.onCTAClick)==null||o.call(s);else if(Si())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Ei())try{(c=(u=window.smxTracking)==null?void 0:u.redirect)==null||c.call(u)}catch(f){console.warn("Smadex redirect failed",f)}else if(wi()){let f=window.ExitApi;f&&typeof f.exit=="function"?f.exit(n||Ge||""):n&&window.open(n)}else Ne()?(p=window.install)==null||p.call(window):xi()?(g=window.openAppStore)==null||g.call(window):cn()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):n&&window.open(n)}function gr(){let n=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let i=new Image;i.src=t};if(n==="bigabid"){let t=window.BIGABID_BIDTIMEMACROS;if(!t)return;J("view",()=>e(t.mraid_viewable)),J("start",()=>e(t.game_viewable)),J("engagement",()=>e(t.engagement));let i=()=>e(t.complete);J("complete",i),_t("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.count)>3&&i()}),J("cta_click",()=>e(t.click))}else if(n==="inmobi"){let t=window.INMOBI_DSPMACROS;if(!t)return;J("view",()=>e(t.Ad_Load_Start)),J("start",()=>e(t.Ad_Viewable)),J("engagement",()=>e(t.First_Engagement)),J("complete",()=>e(t.Gameplay_Complete)),J("cta_click",()=>e(t.DSP_Click)),J("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>e(t[`Spent_${i}_Seconds`]),i*1e3))})}}function hr(){if(!Fe())return;let n=window.TJ_API;n&&n.setPlayableAPI&&n.setPlayableAPI({skipAd:()=>{try{se.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function Wi(){var e,t,i;let n=window.TJ_API;(e=n==null?void 0:n.objectiveComplete)==null||e.call(n),(t=n==null?void 0:n.playableFinished)==null||t.call(n),(i=n==null?void 0:n.gameplayFinished)==null||i.call(n)}function fr(){Ne()&&(window.mintGameStart=()=>{xt(!0),ke()},window.mintGameClose=()=>{Ke(!0)})}function mr(){if(!dn())return;let n=window.NUC;!n||!n.trigger||(se.on("cta_click",()=>{var e,t;return(t=(e=n.trigger).convert)==null?void 0:t.call(e,Ge)}),se.on("complete",()=>{var e,t;return(t=(e=n.trigger).tryAgain)==null?void 0:t.call(e)}))}var se={init(n={},e){var t;if(Xi=n.profile||"web_embed",On=n.consent||{},Ue={...Yi,...n.ids||{}},qe=n.rootEl||qe,bt=void 0,Jn((t=n.telemetry)!=null&&t.endpoint?n.telemetry:null),Re=null,Rn=!1,zn=!1,Ft.clear(),Ge=n.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Ut=e),x("init"),document.body.oncontextmenu=()=>!1,Gi(),yr(qe),Ai(),dr(),pr(),!qt){if(document.readyState==="complete")qi();else if(!Ui){Ui=!0;let i=()=>{qi(),window.removeEventListener("load",i),document.removeEventListener("DOMContentLoaded",i)};window.addEventListener("load",i),document.addEventListener("DOMContentLoaded",i)}}ur(),gr(),hr(),fr(),mr(),console.log(`%c @handler/playable-sdk %c v${In} `,"background: var(--ui-console-info); color: var(--ui-white); font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: var(--ui-console-bg); color: var(--ui-console-text); font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),ge&&!ue&&(x("boot"),x("view"),x("ready"),yt&&(yt=!1,se.start()),ue=!0),ue=ge},getRoot(){return Gi()},get version(){return In},get maxWidth(){return Ve},get maxHeight(){return We},get isLandscape(){return jn},get isReady(){return ue},get isStarted(){return Mn},get isPaused(){return vt},get isFinished(){return mt},get volume(){return $n},get interactions(){return Bt},on(n,e){_t(Gt(n),e)},off(n,e){on(Gt(n),e)},start(){var n,e;if(!Mn){if(!ge){yt=!0;return}if(Mn=!0,Re||(Re=Date.now()),x("start"),ke(),Ne())Ke(),(n=window.gameReady)==null||n.call(window);else if(Fe()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:jn?"landscape":"portrait",buildID:In})}}},finish(){var n,e;mt||(mt=!0,x("complete"),_n("complete"),Ne()?(n=window.gameEnd)==null||n.call(window):cn()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Fe()&&Wi())},install(n){if(!mt){mt=!0,Fe()?(Wi(),setTimeout(()=>se.install(n),300)):(x("complete"),setTimeout(()=>se.install(n),0));return}Pn||(Pn=!0,setTimeout(()=>Pn=!1,500),x("cta_click"),x("conversion"),_n("cta"),Vi(n||Ge))},emit(n,e){let t=Gt(n);if(!cr.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${n} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Qi(t,e);ln(i,!!On.analytics),Ot(t,i)},gameStart(){se.start()},gameEnd(){se.finish()},ctaClick(n,e){x("cta_click",{url:n||Ge,manual:!0}),(e==null?void 0:e.open)!==!1&&Vi(n||Ge)},ctaShow(n){x("cta_show",n)},ctaDismiss(n){x("cta_dismiss",n)},getGameTimeMs(){return Zi()},endSession(n="manual"){_n(n)},setAttribution(n){bt=n},abTest(n,e){if(!n)throw new Error("abTest requires experimentId");if(!Array.isArray(e)||e.length<2)throw new Error("abTest requires at least 2 variants");let t=Math.abs(br(`${Ki}:${n}`))%e.length,i=e[t];return bt={...bt||{},experiment_id:n},Ue.variant_id=i,x("ab_assign",{experiment_id:n,variant_id:i}),i},levelStart(n,e){Re||(Re=Date.now()),x("level_start",{level_id:n,...e})},levelComplete(n,e){x("level_complete",{level_id:n,...e})},levelFail(n,e){x("level_fail",{level_id:n,...e})},checkpoint(n,e){x("checkpoint",{checkpoint_id:n,...e})},reward(n,e){x("reward",{reward_id:n,...e})},tutorialStart(n,e){x("tutorial_start",{step_id:n,...e})},tutorialComplete(n,e){x("tutorial_complete",{step_id:n,...e})},tutorialSkip(n,e){x("tutorial_skip",{step_id:n,...e})},timerStart(n){n&&Ft.set(n,Date.now())},timerEnd(n,e="custom",t){if(!n)return;let i=Ft.get(n);if(!i)return;Ft.delete(n);let a=Date.now()-i;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){x("engagement",{action:"timer",key:n,duration_ms:a,...t});return}x(e,{key:n,duration_ms:a,...t})}},fps(n,e){x("fps",{value:n,...e})},memory(n,e){x("memory",{bytes:n,...e})},assetLoadStart(n,e){x("asset_load_start",{asset_id:n,...e})},assetLoadComplete(n,e){x("asset_load_complete",{asset_id:n,...e})},reportError(n,e,t){x("error",{code:n,message:e,...t})},retry(){var n,e,t;if(Ne())(n=window.gameRetry)==null||n.call(window);else if(dn()){let i=window.NUC;(t=(e=i==null?void 0:i.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}x("engagement",{action:"retry"})},pause(){Ke(!0)},resume(){xt(!0)},resize(n,e){ke(n,e)}},ft=se;function br(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function yr(n){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
229
+ `,this.modal=e,this.attachEventListeners(),this.initializeCanvas()}initializeCanvas(){this.modal&&(this.canvas=this.modal.querySelector(".asset-crop-canvas"),this.canvas&&(this.ctx=this.canvas.getContext("2d"),this.canvas.width=400,this.canvas.height=300))}loadImage(){this.options&&(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=()=>{this.initializeCrop(),this.render()},this.image.src=this.options.imageSrc)}initializeCrop(){var i;if(!this.image||!this.canvas)return;let e=this.image.width/this.image.height,t=this.canvas.width/this.canvas.height;e>t?(this.cropHeight=this.image.height,this.cropWidth=this.cropHeight*t,this.cropX=(this.image.width-this.cropWidth)/2,this.cropY=0):(this.cropWidth=this.image.width,this.cropHeight=this.cropWidth/t,this.cropX=0,this.cropY=(this.image.height-this.cropHeight)/2),(i=this.options)!=null&&i.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,i=this.cropX+this.cropWidth/2,a=this.cropY+this.cropHeight/2;e>t?(this.cropWidth=Math.min(this.image.width,this.cropHeight*e),this.cropHeight=this.cropWidth/e):(this.cropHeight=Math.min(this.image.height,this.cropWidth/e),this.cropWidth=this.cropHeight*e),this.cropX=Math.max(0,Math.min(this.image.width-this.cropWidth,i-this.cropWidth/2)),this.cropY=Math.max(0,Math.min(this.image.height-this.cropHeight,a-this.cropHeight/2))}fitToCanvas(){if(!this.image||!this.canvas)return;let e=this.canvas.width/this.cropWidth,t=this.canvas.height/this.cropHeight;this.scale=Math.min(e,t)*.9,this.panX=(this.canvas.width-this.cropWidth*this.scale)/2,this.panY=(this.canvas.height-this.cropHeight*this.scale)/2}render(){!this.ctx||!this.image||!this.canvas||(this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.ctx.translate(this.panX,this.panY),this.ctx.scale(this.scale,this.scale),this.ctx.drawImage(this.image,-this.cropX,-this.cropY,this.image.width,this.image.height),this.ctx.restore(),this.drawCropOverlay(),this.updatePreview())}drawCropOverlay(){if(!this.ctx||!this.canvas)return;let e=this.panX,t=this.panY,i=this.cropWidth*this.scale,a=this.cropHeight*this.scale;this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.clearRect(e,t,i,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,i,a),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+i-r,t],[e,t+a-r],[e+i-r,t+a-r]].forEach(([o,l])=>{var d;(d=this.ctx)==null||d.fillRect(o,l,r,r)})}updatePreview(){if(!this.modal||!this.image)return;let e=this.modal.querySelector(".asset-crop-preview-canvas");if(!e)return;let t=e.getContext("2d");if(!t)return;let i=150;e.width=i,e.height=i;let a=i/this.cropWidth,r=i/this.cropHeight,s=Math.min(a,r),o=this.cropWidth*s,l=this.cropHeight*s,d=(i-o)/2,u=(i-l)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,d,u,o,l)}attachEventListeners(){if(!this.modal||!this.canvas)return;this.canvas.addEventListener("mousedown",this.handleMouseDown.bind(this)),this.canvas.addEventListener("mousemove",this.handleMouseMove.bind(this)),this.canvas.addEventListener("mouseup",this.handleMouseUp.bind(this)),this.canvas.addEventListener("wheel",this.handleWheel.bind(this)),this.canvas.addEventListener("touchstart",this.handleTouchStart.bind(this)),this.canvas.addEventListener("touchmove",this.handleTouchMove.bind(this)),this.canvas.addEventListener("touchend",this.handleTouchEnd.bind(this));let e=this.modal.querySelector(".asset-crop-zoom-slider");e==null||e.addEventListener("input",i=>{let a=parseFloat(i.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",i=>{let a=i.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",i=>{switch(i.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",i=>{i.target===this.modal&&this.close()})}handleMouseDown(e){this.isDragging=!0,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.lastPanX=this.panX,this.lastPanY=this.panY,this.canvas.style.cursor="grabbing"}handleMouseMove(e){if(!this.isDragging)return;let t=e.clientX-this.dragStartX,i=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleMouseUp(){this.isDragging=!1,this.canvas.style.cursor="grab"}handleWheel(e){e.preventDefault();let t=e.deltaY>0?.9:1.1;this.setZoom(this.scale*t)}handleTouchStart(e){e.touches.length===1&&(this.isDragging=!0,this.dragStartX=e.touches[0].clientX,this.dragStartY=e.touches[0].clientY,this.lastPanX=this.panX,this.lastPanY=this.panY)}handleTouchMove(e){if(!this.isDragging||e.touches.length!==1)return;e.preventDefault();let t=e.touches[0].clientX-this.dragStartX,i=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+i,this.constrainPan(),this.render()}handleTouchEnd(){this.isDragging=!1}setZoom(e){this.scale=Math.max(.1,Math.min(3,e)),this.updateZoomUI(),this.constrainPan(),this.render()}setAspectRatio(e){let t;switch(e){case"1:1":t=1;break;case"4:3":t=4/3;break;case"16:9":t=16/9;break;case"3:2":t=3/2;break;default:t=void 0}t&&this.applyAspectRatio(t),this.fitToCanvas(),this.render()}updateZoomUI(){if(!this.modal)return;let e=this.modal.querySelector(".asset-crop-zoom-value"),t=this.modal.querySelector(".asset-crop-zoom-slider");e&&(e.textContent=`${this.scale.toFixed(1)}x`),t&&(t.value=this.scale.toString())}constrainPan(){if(!this.canvas)return;let e=this.cropWidth*this.scale,t=this.cropHeight*this.scale;this.panX=Math.max(this.canvas.width-e,Math.min(0,this.panX)),this.panY=Math.max(this.canvas.height-t,Math.min(0,this.panY))}reset(){this.initializeCrop(),this.render()}applyCrop(){var a;if(!this.image||!((a=this.options)!=null&&a.onCrop))return;let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return;e.width=this.cropWidth,e.height=this.cropHeight,t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight);let i=e.toDataURL("image/png");this.options.onCrop(i),this.close()}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal);let e=this.options;this.modal=null,this.canvas=null,this.ctx=null,this.image=null,this.options=null,e!=null&&e.onCancel&&e.onCancel()}};window.openAssetCrop=function(n){new Ln().open(n)};ce();ce();var ht=require("pixi.js");Dt();var sr=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",kn=sr;if(typeof window!="undefined")try{let n=new XMLHttpRequest;if(n.open("GET","./build-settings.json",!1),n.send(),n.status===200&&n.responseText){let e=JSON.parse(n.responseText);e!=null&&e.buildMode&&(kn=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${kn}`))}}catch{}function or(n){var t,i,a,r,s;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(n);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(n))return{x:(t=n[0])!=null?t:.5,y:(i=n[1])!=null?i:.5};if(n&&typeof n=="object"&&"x"in n&&"y"in n)return{x:(a=n.x)!=null?a:.5,y:(r=n.y)!=null?r:.5};if(typeof n=="string"){let o=n.trim().toLowerCase();return(s=e[o])!=null?s:{x:.5,y:.5}}return null}var Le=class{static async create(e,t,i){var l,d,u,c,p,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${kn}`);let a=(l=t==null?void 0:t.render)==null?void 0:l.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let f=new ht.Container;return this.applyTransform(f,t==null?void 0:t.transform,t),f}let r=(d=t==null?void 0:t.identity)==null?void 0:d.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${a.type}, path: ${a.path}`);let s=await Ce.load(e,a,i,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=s==null?void 0:s.constructor)==null?void 0:u.name}`);let o;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",s,"for object:",e),o=new ht.Sprite(s),console.log("[ObjectFactory] Created object:",o,"type:",(c=o==null?void 0:o.constructor)==null?void 0:c.name),this.applyTransform(o,t==null?void 0:t.transform,t);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(p=s==null?void 0:s.constructor)==null?void 0:p.name,s),s&&(((g=s.constructor)==null?void 0:g.name)==="Container"||s instanceof ht.Container)){console.warn("[ObjectFactory] JSON asset is Container (from cache), reloading JSON directly");let f=[a.path,`/assets/${a.path}`,`assets/${a.path}`,`../assets/${a.path}`],A=!1;for(let b of f)try{let h=await fetch(b);if(h.ok){o=await h.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=o==null?void 0:o.constructor)==null?void 0:m.name),A=!0;break}}catch{continue}A||(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 a,r,s,o;if(!(!t||!e)&&(t.position&&("x"in e&&"y"in e?(e.x=(a=t.position.x)!=null?a: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=or(t.anchor);l&&("set"in e.anchor?e.anchor.set(l.x,l.y):(e.anchor.x=l.x,e.anchor.y=l.y))}}};ce();var Fi=Pt(require("lottie-web"),1);Nt(Ci);typeof window!="undefined"&&!window.lottie&&(window.lottie=Fi.default);gn();ce();var In=ri.version,cr=new Set(["init","boot","view","ready","start","pause","resume","complete","error","engagement","first_interaction","retry","cta_show","cta_click","cta_dismiss","clickout","conversion","session_time","level_time","load_time","level_start","level_complete","level_fail","checkpoint","reward","tutorial_start","tutorial_complete","tutorial_skip","ab_assign","fps","memory","asset_load_start","asset_load_complete"]);ai();var Yi={mechanic_id:"TODO_mechanic_id",variant_id:"TODO_variant_id",deployment_id:"TODO_deployment_id",export_id:"TODO_export_id",profile_id:"TODO_profile_id",instance_id:"default"},Ki=Math.random().toString(36).slice(2),qe=null,Ue={...Yi},Xi="web_embed",jn={},bt,Mn=!1,mt=!1,vt=!1,Ji=!1,$n=1,Bt=0,qt=!1,ue=!1,Ge="",Ve=Math.floor(window.innerWidth),We=Math.floor(window.innerHeight),On=Ve>We,ge=!1,yt=!1,Bi=!1,Ui=!1,Pn=!1,Ut=null,Re=null,Rn=!1,zn=!1,Ft=new Map;function Zi(){if(!Re)return null;let n=Date.now()-Re;return!Number.isFinite(n)||n<0?null:n}function _n(n){if(Rn)return;let e=Zi();e!==null&&(Rn=!0,x("session_time",{duration_ms:e,reason:n}))}function Gi(){if(qe)return qe;let n=document.createElement("div");return n.id="handler-root",n.setAttribute("data-handler-root","true"),document.body.appendChild(n),qe=n,n}function Gt(n){switch(n){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return n}}function Qi(n,e){return{event_name:n,ts:Date.now(),session_id:Ki,deployment_id:Ue.deployment_id,variant_id:Ue.variant_id,export_profile_id:Ue.profile_id,instance_id:Ue.instance_id||"default",env:Xi==="mraid"?"mraid":"web",attribution:bt,payload:e}}function x(n,e){let t=Gt(n),i=Qi(t,e);ln(i,!!jn.analytics),jt(t,i),t!==n&&jt(n,i)}function wt(){Ut&&(Ut(Ve,We),Ut=null)}function Ye(n){$n=n,x("volume",n)}function Ke(n){n&&(Ji=!0),!vt&&(vt=!0,x("pause"),Ye(0))}function xt(n){!n&&Ji||vt&&(vt=!1,x("resume"),Ye($n))}function ke(n,e){Ve=Math.floor(n||window.innerWidth),We=Math.floor(e||window.innerHeight),On=Ve>We,x("resize",{width:Ve,height:We})}function dr(){if(bi())try{let n=mraid.getMaxSize();ke(n.width,n.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?xt():Ke()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let t=mraid.getMaxSize();ke(t.width,t.height)}),mraid.getAudioVolume){let t=mraid.getAudioVolume();Ye(t?1:0)}if(mraid.addEventListener("audioVolumeChange",t=>{t!==null&&Ye(t>0?1:0)}),mraid.addEventListener("error",(t,i)=>{console.warn("mraid error:",t,"action:",i)}),qt=!0,mraid.isViewable()&&mraid.getState()!=="hidden")ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt();else{let t=()=>{ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt()};mraid.addEventListener("ready",t)}}catch(n){console.warn("MRAID hook skipped",n)}}function pr(){if(yi())try{let n=dapi.getScreenSize();ke(n.width,n.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?xt():Ke()}),dapi.addEventListener("adResized",t=>{let i=dapi.getScreenSize();ke(t.width||i.width,t.height||i.height)});let e=dapi.getAudioVolume();if(Ye(e?1:0),dapi.addEventListener("audioVolumeChange",t=>Ye(t?1:0)),qt=!0,dapi.isViewable())ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt();else{let t=()=>{ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt()};dapi.addEventListener("ready",t)}}catch(n){console.warn("DAPI hook skipped",n)}}function qi(){let n=()=>{ge||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(ge=!0,x("boot"),x("view"),x("ready"),ue=!0,wt(),yt&&(yt=!1,se.start()))};window.addEventListener("resize",()=>ke()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(xt(),n()):Ke()}),document.readyState==="complete"||document.readyState==="interactive"?n():window.addEventListener("load",n),qt=!0}function ur(){let n=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(Bi=!0),!(Bi&&e instanceof MouseEvent)&&(Bt+=1,zn||(zn=!0,x("first_interaction",{count:Bt})),x("interaction",Bt))};document.addEventListener("mousedown",n),document.addEventListener("touchstart",n)}function Vi(n){var i,a,r,s,o,l,d,u,c,p,g,m;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(n||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(Fe())(r=(a=window.TJ_API)==null?void 0:a.click)==null||r.call(a);else if(vi())(o=(s=window.FbPlayableAd)==null?void 0:s.onCTAClick)==null||o.call(s);else if(Si())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Ei())try{(c=(u=window.smxTracking)==null?void 0:u.redirect)==null||c.call(u)}catch(f){console.warn("Smadex redirect failed",f)}else if(wi()){let f=window.ExitApi;f&&typeof f.exit=="function"?f.exit(n||Ge||""):n&&window.open(n)}else Ne()?(p=window.install)==null||p.call(window):xi()?(g=window.openAppStore)==null||g.call(window):cn()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):n&&window.open(n)}function gr(){let n=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let i=new Image;i.src=t};if(n==="bigabid"){let t=window.BIGABID_BIDTIMEMACROS;if(!t)return;J("view",()=>e(t.mraid_viewable)),J("start",()=>e(t.game_viewable)),J("engagement",()=>e(t.engagement));let i=()=>e(t.complete);J("complete",i),_t("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.count)>3&&i()}),J("cta_click",()=>e(t.click))}else if(n==="inmobi"){let t=window.INMOBI_DSPMACROS;if(!t)return;J("view",()=>e(t.Ad_Load_Start)),J("start",()=>e(t.Ad_Viewable)),J("engagement",()=>e(t.First_Engagement)),J("complete",()=>e(t.Gameplay_Complete)),J("cta_click",()=>e(t.DSP_Click)),J("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>e(t[`Spent_${i}_Seconds`]),i*1e3))})}}function hr(){if(!Fe())return;let n=window.TJ_API;n&&n.setPlayableAPI&&n.setPlayableAPI({skipAd:()=>{try{se.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function Wi(){var e,t,i;let n=window.TJ_API;(e=n==null?void 0:n.objectiveComplete)==null||e.call(n),(t=n==null?void 0:n.playableFinished)==null||t.call(n),(i=n==null?void 0:n.gameplayFinished)==null||i.call(n)}function fr(){Ne()&&(window.mintGameStart=()=>{xt(!0),ke()},window.mintGameClose=()=>{Ke(!0)})}function mr(){if(!dn())return;let n=window.NUC;!n||!n.trigger||(se.on("cta_click",()=>{var e,t;return(t=(e=n.trigger).convert)==null?void 0:t.call(e,Ge)}),se.on("complete",()=>{var e,t;return(t=(e=n.trigger).tryAgain)==null?void 0:t.call(e)}))}var se={init(n={},e){var t;if(Xi=n.profile||"web_embed",jn=n.consent||{},Ue={...Yi,...n.ids||{}},qe=n.rootEl||qe,bt=void 0,Jn((t=n.telemetry)!=null&&t.endpoint?n.telemetry:null),Re=null,Rn=!1,zn=!1,Ft.clear(),Ge=n.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Ut=e),x("init"),document.body.oncontextmenu=()=>!1,Gi(),yr(qe),Ai(),dr(),pr(),!qt){if(document.readyState==="complete")qi();else if(!Ui){Ui=!0;let i=()=>{qi(),window.removeEventListener("load",i),document.removeEventListener("DOMContentLoaded",i)};window.addEventListener("load",i),document.addEventListener("DOMContentLoaded",i)}}ur(),gr(),hr(),fr(),mr(),console.log(`%c @handler/playable-sdk %c v${In} `,"background: var(--ui-console-info); color: var(--ui-white); font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: var(--ui-console-bg); color: var(--ui-console-text); font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),ge&&!ue&&(x("boot"),x("view"),x("ready"),yt&&(yt=!1,se.start()),ue=!0),ue=ge},getRoot(){return Gi()},get version(){return In},get maxWidth(){return Ve},get maxHeight(){return We},get isLandscape(){return On},get isReady(){return ue},get isStarted(){return Mn},get isPaused(){return vt},get isFinished(){return mt},get volume(){return $n},get interactions(){return Bt},on(n,e){_t(Gt(n),e)},off(n,e){on(Gt(n),e)},start(){var n,e;if(!Mn){if(!ge){yt=!0;return}if(Mn=!0,Re||(Re=Date.now()),x("start"),ke(),Ne())Ke(),(n=window.gameReady)==null||n.call(window);else if(Fe()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:On?"landscape":"portrait",buildID:In})}}},finish(){var n,e;mt||(mt=!0,x("complete"),_n("complete"),Ne()?(n=window.gameEnd)==null||n.call(window):cn()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Fe()&&Wi())},install(n){if(!mt){mt=!0,Fe()?(Wi(),setTimeout(()=>se.install(n),300)):(x("complete"),setTimeout(()=>se.install(n),0));return}Pn||(Pn=!0,setTimeout(()=>Pn=!1,500),x("cta_click"),x("conversion"),_n("cta"),Vi(n||Ge))},emit(n,e){let t=Gt(n);if(!cr.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${n} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Qi(t,e);ln(i,!!jn.analytics),jt(t,i)},gameStart(){se.start()},gameEnd(){se.finish()},ctaClick(n,e){x("cta_click",{url:n||Ge,manual:!0}),(e==null?void 0:e.open)!==!1&&Vi(n||Ge)},ctaShow(n){x("cta_show",n)},ctaDismiss(n){x("cta_dismiss",n)},getGameTimeMs(){return Zi()},endSession(n="manual"){_n(n)},setAttribution(n){bt=n},abTest(n,e){if(!n)throw new Error("abTest requires experimentId");if(!Array.isArray(e)||e.length<2)throw new Error("abTest requires at least 2 variants");let t=Math.abs(br(`${Ki}:${n}`))%e.length,i=e[t];return bt={...bt||{},experiment_id:n},Ue.variant_id=i,x("ab_assign",{experiment_id:n,variant_id:i}),i},levelStart(n,e){Re||(Re=Date.now()),x("level_start",{level_id:n,...e})},levelComplete(n,e){x("level_complete",{level_id:n,...e})},levelFail(n,e){x("level_fail",{level_id:n,...e})},checkpoint(n,e){x("checkpoint",{checkpoint_id:n,...e})},reward(n,e){x("reward",{reward_id:n,...e})},tutorialStart(n,e){x("tutorial_start",{step_id:n,...e})},tutorialComplete(n,e){x("tutorial_complete",{step_id:n,...e})},tutorialSkip(n,e){x("tutorial_skip",{step_id:n,...e})},timerStart(n){n&&Ft.set(n,Date.now())},timerEnd(n,e="custom",t){if(!n)return;let i=Ft.get(n);if(!i)return;Ft.delete(n);let a=Date.now()-i;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){x("engagement",{action:"timer",key:n,duration_ms:a,...t});return}x(e,{key:n,duration_ms:a,...t})}},fps(n,e){x("fps",{value:n,...e})},memory(n,e){x("memory",{bytes:n,...e})},assetLoadStart(n,e){x("asset_load_start",{asset_id:n,...e})},assetLoadComplete(n,e){x("asset_load_complete",{asset_id:n,...e})},reportError(n,e,t){x("error",{code:n,message:e,...t})},retry(){var n,e,t;if(Ne())(n=window.gameRetry)==null||n.call(window);else if(dn()){let i=window.NUC;(t=(e=i==null?void 0:i.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}x("engagement",{action:"retry"})},pause(){Ke(!0)},resume(){xt(!0)},resize(n,e){ke(n,e)}},ft=se;function br(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function yr(n){let e=document.createElement("script");e.type="text/javascript",e.textContent=`
230
230
  (function(){
231
231
  var events = ['touchstart','touchend','mousedown','keydown'];
232
232
  function unlock(){
@@ -252,4 +252,4 @@ Style guidelines: ${i.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
252
252
  pointer-events: none;
253
253
  z-index: ${b};
254
254
  opacity: ${h};
255
- `,e.appendChild(v);let w;try{w=u.loadAnimation({container:v,renderer:r.renderer||"svg",loop:(we=r.loop)!=null?we:!1,autoplay:(xe=r.autoplay)!=null?xe:!0,animationData:d})}catch(q){return v.parentNode&&v.parentNode.removeChild(v),console.warn(`[LottieOverlay] Failed to start animation: ${n}`,q),null}r.speed!==void 0&&w.setSpeed(r.speed);let y=()=>{w.destroy(),v.parentNode&&v.parentNode.removeChild(v)};return r.loop||w.addEventListener("complete",y),{animation:w,cleanup:y}}Dt();mn();var Yt=class{constructor(e,t,i){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=i}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:i}=await Vt(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=i,this.gameObjectManager=new Xe(this.config),this.stage.eventMode="passive",this.stage.interactive=!1,this.stage.interactiveChildren=!0,this.stage.sortableChildren=!0,this.context={app:this.app,stage:this.stage,config:this.config,gameObjectManager:this.gameObjectManager,destinationUrl:this.destinationUrl,root:this.root,engine:this};for(let a of this.systems)a.setContext(this.context);return{app:this.app,gameObjectManager:this.gameObjectManager}}async initSystems(){if(!this.context)throw new Error("[GameEngine] createApp() must be called before initSystems()");for(let e of this.systems)e.init&&await e.init()}async init(e){return await this.createApp(e),await this.initSystems(),{app:this.app,gameObjectManager:this.gameObjectManager}}registerSystems(e){this.systems.push(...e)}async start(){for(let e of this.systems)e.onStart&&await e.onStart();this.app.ticker.add(this.update.bind(this)),window.addEventListener("handler-preview:screen",e=>{let{width:t,height:i}=e.detail;this.resize(t,i)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let i of this.systems)i.update&&i.update(t,this.totalTime)}resize(e,t){for(let i of this.systems)i.onResize&&i.onResize(e,t)}updateConfig(e){this.config=e;for(let t of this.systems)t.context.config=e,t.onConfigUpdate&&t.onConfigUpdate(e)}destroy(){for(let e of this.systems)e.onDestroy&&e.onDestroy();this.app.ticker.remove(this.update.bind(this)),this.app.destroy(!0,{children:!0,texture:!1})}getApp(){return this.app}getGameObjectManager(){return this.gameObjectManager}getTotalTime(){return this.totalTime}getSystem(e){let t=this.systems.find(i=>i instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var Ze=class{setContext(e){this.context=e}};var Qe=class{constructor(){this.config=null}init(e){this.config=e}get(e){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(e)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(e){return this.config?this.config.objects.has(e):!1}};var oa=Pt(require("pixi.js"),1),la=oa;typeof window!="undefined"&&(window.__basePixi=oa);gt();var he=require("pixi.js");gt();var ca=n=>n*Math.PI/180;function Er(n,e){var s,o,l,d,u;let t=e.ui;if(!(t!=null&&t.text))return null;let i="#ffffff";(s=e.render)!=null&&s.tint&&(i=e.render.tint);let a=new he.TextStyle({fontFamily:(o=t.font)!=null?o:"Arial",fontSize:(l=t.fontSize)!=null?l:16,fill:i,align:(d=t.align)!=null?d:"center",letterSpacing:(u=t.letterSpacing)!=null?u:0}),r=new he.Text({text:t.text,style:a});return r.label=n,r}function da(n){var u,c,p,g,m,f,A,b,h,v;let{stage:e,mainContainer:t,activeConfig:i,gameObjectManager:a,allowList:r,denyList:s}=n,o={},l={},d={};t.sortableChildren=!0;for(let[w,y]of i.objects.entries()){if(s!=null&&s.has(w)||r&&!r.has(w)||(y==null?void 0:y.enabled)===!1)continue;let I=(c=(u=y==null?void 0:y.render)==null?void 0:u.asset)==null?void 0:c.path,P=(g=(p=y==null?void 0:y.render)==null?void 0:p.asset)==null?void 0:g.type,B=!!(I&&P==="image"),R=!!((m=y==null?void 0:y.ui)!=null&&m.text),H=R?(f=y==null?void 0:y.ui)==null?void 0:f.renderMode:void 0,z;if(H==="png"&&B?z="png":H==="text"&&R?z="text":B?z="png":R?z="text":z="skip",z!=="skip"){if(z==="text"){let T=Er(w,y);if(!T)continue;let E=y.render;T.alpha=typeof(E==null?void 0:E.alpha)=="number"?E.alpha:1,T.visible=(E==null?void 0:E.visible)!==!1,T.zIndex=typeof(E==null?void 0:E.z_index)=="number"?E.z_index:0,E!=null&&E.anchor&&typeof E.anchor.x=="number"&&typeof E.anchor.y=="number"?T.anchor.set(E.anchor.x,E.anchor.y):T.anchor.set(.5,.5);let S=y.transform,C=(S==null?void 0:S.position)||(S==null?void 0:S.offset);C&&T.position.set((A=C.x)!=null?A:0,(b=C.y)!=null?b:0);let L=typeof(S==null?void 0:S.scale)=="number"?S.scale:1;T.scale.set(L,L);let G=typeof(S==null?void 0:S.rotation)=="number"?S.rotation:0;T.rotation=ca(G),T.parent||t.addChild(T);try{a.create(w,T)}catch{}o[w]=T,d[w]=T}else if(z==="png"){let T=Te[w]||(typeof he.Texture!="undefined"?he.Texture.EMPTY:void 0),E=new he.Sprite(T);E.label=w;let S=y.render;E.alpha=typeof(S==null?void 0:S.alpha)=="number"?S.alpha:1,E.visible=(S==null?void 0:S.visible)!==!1,E.zIndex=typeof(S==null?void 0:S.z_index)=="number"?S.z_index:0,S!=null&&S.anchor&&typeof S.anchor.x=="number"&&typeof S.anchor.y=="number"&&E.anchor.set(S.anchor.x,S.anchor.y);let C=y.transform,L=(C==null?void 0:C.position)||(C==null?void 0:C.offset);L&&E.position.set((h=L.x)!=null?h:0,(v=L.y)!=null?v:0);let G=typeof(C==null?void 0:C.scale)=="number"?C.scale:1;E.scale.set(G,G);let ne=typeof(C==null?void 0:C.rotation)=="number"?C.rotation:0;E.rotation=ca(ne),E.parent||t.addChild(E);try{a.create(w,E)}catch{}o[w]=E,l[w]=E}}}return t.parent||e.addChild(t),{objects:o,sprites:l,texts:d}}var Dn=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Qe}init(e,t){this.registry.init(e),this.app=t}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let t=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(t.length===0)return;let i=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async r=>{var o;let s=this.registry.get(r);if(!s){console.warn("[Assets] No config found for object:",r);return}try{let l=await Le.create(r,s,this.app);this.instanceCache.set(r,l),console.log("[Assets] Loaded object:",r,(o=l==null?void 0:l.constructor)==null?void 0:o.name)}catch(l){console.error("[Assets] Failed to load object:",r,l)}})))};return this.readyPromise=(async()=>{await i(t);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let t=this.registry.get(e);if(t){let i=await Le.create(e,t,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},pa=new Dn,ua=new Proxy(pa,{get(n,e){if(e in n&&typeof n[e]=="function")return n[e].bind(n);if(n.get(e))return n.get(e)}});function ga(n,e){pa.init(n,e)}gt();var Kt=class extends Ze{async init(){Ht(this.context.config,this.context.app),await Te.ready(),console.log("[AssetSystem] All assets preloaded and ready")}async onStart(){}onConfigUpdate(){console.log("[AssetSystem] Config updated - systems will refresh textures")}};var Qt=require("pixi.js"),fe={width:400,height:600,designWidth:400,scaleFactor:1},Tt={scale:1,position:1},en=[];function Sr(n,e,t,i,a,r,s){en.push({element:n,originalScale:r,positionHelper:e,heightPercent:a}),e(n,t,i,a,r,s,!1)}function Ar(){en.forEach(({element:n,originalScale:e,positionHelper:t,heightPercent:i})=>{let a=e*fe.scaleFactor;t(n,fe.width,fe.height,i,a,!0,!1)})}function ha(){en.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Jt(n,e){console.log(`[SCREEN] updateScreenState called: ${n}x${e}`),fe.width=n,fe.height=e,fe.scaleFactor=Math.min(n/fe.designWidth,1.15),Tt.scale=fe.scaleFactor,Tt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Tt.scale.toFixed(3)}`),Ar()}var j={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Cr(n,e,t){let i=j[n];i&&i[e]!==void 0&&(i[e]=t,console.log(`Updated ${n}.${e} = ${t}`))}function Tr(){return j}var Lr={center:{x:.5,y:.5},"center-center":{x:.5,y:.5},middle:{x:.5,y:.5},"middle-center":{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},"left-center":{x:0,y:.5},"right-center":{x:1,y:.5},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};function Xt(n,e){return typeof n=="number"&&Number.isFinite(n)?n:e}function $e(n,e={x:.5,y:.5}){var t;if(Array.isArray(n))return{x:Xt(n[0],e.x),y:Xt(n[1],e.y)};if(n&&typeof n=="object"){let i=n;return{x:Xt(i.x,e.x),y:Xt(i.y,e.y)}}if(typeof n=="string"){let i=n.trim().toLowerCase();return(t=Lr[i])!=null?t:e}return e}function et(n,e,t,i={}){var g,m,f,A,b,h;let a=$e(t),r=(g=i.inset)!=null?g:{},s=(m=i.padding)!=null?m:{x:0,y:0},o=((f=r.left)!=null?f:0)+s.x,l=((A=r.right)!=null?A:0)+s.x,d=((b=r.top)!=null?b:0)+s.y,u=((h=r.bottom)!=null?h:0)+s.y,c=Math.max(0,n-o-l),p=Math.max(0,e-d-u);return{x:o+c*a.x,y:d+p*a.y}}function tt(n,e,t,i={}){var f,A,b,h,v,w;let a=(f=i.inset)!=null?f:{},r=(A=i.padding)!=null?A:{x:0,y:0},s=((b=a.left)!=null?b:0)+r.x,o=((h=a.right)!=null?h:0)+r.x,l=((v=a.top)!=null?v:0)+r.y,d=((w=a.bottom)!=null?w:0)+r.y,u=Math.max(0,n-s-o),c=Math.max(0,e-l-d),p=$e(t,{x:.5,y:.5}),g=Math.min(Math.max(p.x,0),1),m=Math.min(Math.max(p.y,0),1);return{x:s+u*g,y:l+c*m}}function Zt(n,e,t,i={}){var u,c,p;if(!n)return;let a=i.positionRatio?tt(e,t,i.positionRatio,{inset:i.inset,padding:i.screenPadding}):et(e,t,i.anchor,{inset:i.inset,padding:i.screenPadding}),r=(u=i.offset)!=null?u:{x:0,y:0},s=a.x+r.x,o=a.y+r.y;n.anchor&&i.renderAnchor&&n.anchor.set(i.renderAnchor.x,i.renderAnchor.y),te(n,s,o);let l=(c=i.scale)!=null?c:1,d=(p=i.scaleMultiplier)!=null?p:1;(i.scale!==void 0||i.scaleMultiplier!==void 0)&&oe(n,l*d)}if(typeof window!="undefined"){let n=window.innerWidth,e=window.innerHeight,t=()=>{let i=window.innerWidth,a=window.innerHeight;(i!==n||a!==e)&&(n=i,e=a,Jt(i,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Jt(window.innerWidth,window.innerHeight),window.updateDebugConfig=Cr,window.getDebugConfig=Tr,window.copyConfig=Dr,window.applyConfig=Ct,window.applyConfigForRatio=Hr,window.positionAtBottom=fa,window.positionAtTop=Mr,window.positionAtCenter=Pr,window.positionAtLeft=_r,window.positionAtRight=Or,window.positionAtBottomLeft=jr,window.positionAtBottomRight=Rr,window.positionAtTopLeft=zr,window.positionAtTopRight=$r,window.applyPositionContract=Ir,console.log("\u{1F3AE} Debug Config Functions Available:"),console.log("\u2022 updateDebugConfig(category, key, value)"),console.log("\u2022 getDebugConfig()"),console.log("\u2022 copyConfig(presetName)"),console.log("\u2022 applyConfig(config)"),console.log("\u2022 applyConfigForRatio(width, height)"),console.log("\u{1F4CD} Positioning Helpers Available (with scale):"),console.log("\u2022 positionAtBottom(element, w, h, percent, scale)"),console.log("\u2022 positionAtTop(element, w, h, percent, scale)"),console.log("\u2022 positionAtCenter(element, w, h, offsetX, offsetY, scale)"),console.log("\u2022 positionAtLeft/Right(element, w, h, percent, scale)"),console.log("\u2022 Corner positions: BottomLeft/Right, TopLeft/Right (all with scale)"),console.log("\u2022 applyPositionContract(element, w, h, contract)"),console.log("Example: positionAtCenter(mySprite, 400, 600, 0, -50, 1.2)")}function tn(n,e,t=0){return n*e+t}function nn(n,e,t=0){return n*(1-e)+t}function an(n,e,t=0){return n*e+t}function rn(n,e,t=0){return n*(1-e)+t}function Q(n,e=0){return n/2+e}function kr(n,e){return n*e}function Ir(n,e,t,i){var s,o,l,d,u,c,p,g,m,f,A,b,h,v,w,y,I,P,B,R;let a=0,r=0;switch(i.type){case"top":a=Q(e,(o=(s=i.offset)==null?void 0:s.x)!=null?o:0),r=tn(t,i.percent,(d=(l=i.offset)==null?void 0:l.y)!=null?d:0);break;case"bottom":a=Q(e,(c=(u=i.offset)==null?void 0:u.x)!=null?c:0),r=nn(t,i.percent,(g=(p=i.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=an(e,i.percent,(f=(m=i.offset)==null?void 0:m.x)!=null?f:0),r=Q(t,(b=(A=i.offset)==null?void 0:A.y)!=null?b:0);break;case"right":a=rn(e,i.percent,(v=(h=i.offset)==null?void 0:h.x)!=null?v:0),r=Q(t,(y=(w=i.offset)==null?void 0:w.y)!=null?y:0);break;case"center":a=Q(e,(P=(I=i.offset)==null?void 0:I.x)!=null?P:0),r=Q(t,(R=(B=i.offset)==null?void 0:B.y)!=null?R:0);break}n.position?n.position.set(a,r):(n.x=a,n.y=r),i.scale!==void 0&&i.scale!==1&&n.scale&&(typeof n.scale.set=="function"?n.scale.set(i.scale,i.scale):(n.scale.x=i.scale,n.scale.y=i.scale))}function fa(n,e,t,i=.2,a=1,r=!0,s=!1){let o=kr(t,i),l=nn(t,i/2);te(n,Q(e),l);let d=r?a*fe.scaleFactor:a;oe(n,d),s&&!en.find(u=>u.element===n)&&Sr(n,fa,e,t,i,a,r)}function Mr(n,e,t,i=.1,a=1){te(n,Q(e),tn(t,i)),oe(n,a)}function Pr(n,e,t,i=0,a=0,r=1){te(n,Q(e,i),Q(t,a)),oe(n,r)}function _r(n,e,t,i=.1,a=1){te(n,an(e,i),Q(t)),oe(n,a)}function Or(n,e,t,i=.1,a=1){te(n,rn(e,i),Q(t)),oe(n,a)}function jr(n,e,t,i=.05,a=.05,r=1){te(n,an(e,a),nn(t,i)),oe(n,r)}function Rr(n,e,t,i=.05,a=.05,r=1){te(n,rn(e,a),nn(t,i)),oe(n,r)}function zr(n,e,t,i=.05,a=.05,r=1){te(n,an(e,a),tn(t,i)),oe(n,r)}function $r(n,e,t,i=.05,a=.05,r=1){te(n,rn(e,a),tn(t,i)),oe(n,r)}function te(n,e,t){n&&n.position?typeof n.position.set=="function"?n.position.set(e,t):(n.position.x=e,n.position.y=t):n&&(n.x=e,n.y=t)}function oe(n,e){e!==1&&n&&n.scale&&(typeof n.scale.set=="function"?n.scale.set(e,e):n.scale.x!==void 0&&n.scale.y!==void 0&&(n.scale.x=e,n.scale.y=e))}var ze={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function Dr(n){return n&&ze[n]?JSON.parse(JSON.stringify(ze[n])):JSON.parse(JSON.stringify(j))}function Ct(n){Object.keys(n).forEach(e=>{let t=e;j[t]&&n[t]&&Object.assign(j[t],n[t])}),console.log("Config applied:",n)}function Hr(n,e){let t=n/e;t>1.6?(Ct(ze.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(Ct(ze.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(Ct(ze.square),console.log("Applied SQUARE config for ratio:",t)):(Ct(ze.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let n=window;n.configPresets=ze,n.resolveAnchorVec2=n.resolveAnchorVec2||$e,n.resolveScreenAnchorPoint=n.resolveScreenAnchorPoint||et,n.resolveScreenRatioPoint=n.resolveScreenRatioPoint||tt}var Y=null;function ma(n,e,t,i,a,r={}){var G,ne,me,be,ye,ve,we,xe,q,Ie,nt,it,at,rt,st,ot,lt,ct,dt,pt,N,K,U,X,De,Me,Hn,Nn,Fn,Bn,Un,Gn,qn,Vn;let s=(G=r.enableDebugLogs)!=null?G:!1;s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:i.width,height:i.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",r));let{mainContainer:o,label:l,background:d,backgroundTexture:u,app:c}=n;if(!c||!c.renderer){s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:c.renderer.width,height:c.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:c.screen.width,height:c.screen.height}));let p=i.width,g=i.height;s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:p,baseHeight:g});let m=p*j.layout.screen_scale_x,f=g*j.layout.screen_scale_y,A=p/2,b=e.engine.runtime||{},h=b.layout||{};s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:j.layout.screen_scale_x,screen_scale_y:j.layout.screen_scale_y}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Calculated dimensions:",{width:m,height:f,midX:A}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",b),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",h));let v=h.design_width_portrait||400,w=m/v;w=Math.min(w,1.15);let y=w*((ne=j.engine.scale)!=null?ne:1),I=(me=r.skipMainContainerTransform)!=null?me:!1;!I&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(y):(o.scale.x=y,o.scale.y=y));let P=(be=h.main_container_anchor)!=null?be:"center",B=(ye=h.main_container_position_ratio)!=null?ye:{x:.5,y:.5},R=(ve=h.main_container_offset)!=null?ve:{x:0,y:0},H=h.main_container_position_ratio?tt(p,g,B):et(p,g,P),z=H.x+R.x+j.layout.position_offset.x,T=H.y+R.y+j.layout.position_offset.y;if(!I&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(z,T):(o.position.x=z,o.position.y=T)),a&&(o!=null&&o.toLocal))for(let[V,F]of e.objects.entries()){let _=F==null?void 0:F.transform;if(!_||((we=_.position_mode)!=null?we:"static")!=="static")continue;let k=(xe=a.get)==null?void 0:xe.call(a,V),ie=((q=k==null?void 0:k.getDisplayObject)==null?void 0:q.call(k))||(k==null?void 0:k.pixiObject)||k;if(!ie||ie.parent!==o)continue;let Lt=_.position_ratio!=null?tt(p,g,_.position_ratio):et(p,g,(Ie=_.anchor)!=null?Ie:"center"),kt=o.toLocal(new Qt.Point(Lt.x,Lt.y)),It=(nt=_.position)!=null?nt:{x:0,y:0},Pe=kt.x+It.x,sn=kt.y+It.y;typeof(k==null?void 0:k.setPosition)=="function"?k.setPosition(Pe,sn):(te(ie,Pe,sn),(it=k==null?void 0:k.transform)!=null&&it.position&&(k.transform.position.x=Pe,k.transform.position.y=sn))}let E=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,C=((E==null?void 0:E.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(j.layout.debug_rect_visible&&C){(!Y||Y.parent!==c.stage)&&(Y==null||Y.destroy(),Y=new Qt.Graphics,Y.zIndex=9999,c.stage.addChild(Y)),Y.clear();let V=j.layout.debug_rect_scale_x,F=j.layout.debug_rect_scale_y,_=(p-4)*V,Ee=(g-4)*F,k=(p-_)/2,ie=(g-Ee)/2;s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:_,rectH:Ee,offsetX:k,offsetY:ie}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+k,y:2+ie,width:_,height:Ee})),Y.rect(2+k,2+ie,_,Ee).stroke({width:j.layout.debug_rect_thickness,color:j.layout.debug_rect_color})}else Y&&(Y.destroy(),Y=null);let L=((at=n.label)==null?void 0:at.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(l&&l.position&&L){let V=(st=(rt=L==null?void 0:L.transform)==null?void 0:rt.anchor)!=null?st:"center",F=(ot=L==null?void 0:L.transform)==null?void 0:ot.position_ratio,_=((lt=L==null?void 0:L.transform)==null?void 0:lt.offset)||{x:0,y:0};Zt(l,p,g,{anchor:V,positionRatio:F,offset:{x:_.x*y,y:_.y*y},renderAnchor:$e(V)})}if(l&&l.alpha>0){let V=1+Math.sin(t*j.engine.label_pulse_speed)*j.engine.label_pulse_intensity,F=(dt=(ct=L==null?void 0:L.transform)==null?void 0:ct.scale)!=null?dt:1,_=V*y*F;l.scale&&(typeof l.scale.set=="function"?l.scale.set(_):(l.scale.x=_,l.scale.y=_))}if(s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),d){s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!d),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(pt=d.constructor)==null?void 0:pt.name)),d.alpha=((K=(N=b.background)==null?void 0:N.alpha)!=null?K:.98)*j.engine.background_alpha,s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",d.alpha);let V=e.objects.get("background_1");s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",V);let F=(V==null?void 0:V.transform)||{};s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",F);let _=F.offset||{x:0,y:0},Ee=((X=(U=b.background)==null?void 0:U.offset_y)!=null?X:0)+j.engine.background_offset_y,k=(De=F.anchor)!=null?De:"center",ie=F.position_ratio;if(s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:_,bgRuntimeOffsetY:Ee,bgScreenAnchor:k,bgPositionRatio:ie,baseWidth:p,baseHeight:g,finalScale:y}),Zt(d,p,g,{anchor:k,positionRatio:ie,offset:{x:_.x*y,y:_.y*y+Ee},renderAnchor:$e(k)}),s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:d.x,y:d.y,scaleX:(Me=d.scale)==null?void 0:Me.x,scaleY:(Hn=d.scale)==null?void 0:Hn.y,anchorX:(Nn=d.anchor)==null?void 0:Nn.x,anchorY:(Fn=d.anchor)==null?void 0:Fn.y,pivotX:(Bn=d.pivot)==null?void 0:Bn.x,pivotY:(Un=d.pivot)==null?void 0:Un.y,width:d.width,height:d.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background texture dimensions:",{textureWidth:u==null?void 0:u.width,textureHeight:u==null?void 0:u.height})),u){let Lt=Math.max(m/u.width,f/u.height),kt=(qn=(Gn=b.background)==null?void 0:Gn.scale_multiplier)!=null?qn:1.05,It=(Vn=F.scale)!=null?Vn:1,Pe=Lt*kt*j.engine.background_scale*It;d.scale&&(typeof d.scale.set=="function"?d.scale.set(Pe):(d.scale.x=Pe,d.scale.y=Pe))}else d&&typeof d.clear=="function"&&(d.clear(),d.rect(-m/2,-f/2,m,f).fill({color:1444375}))}}function ba(n){var o,l,d;let{setState:e,updateLabelAlpha:t,updateHandAlpha:i,config:a,states:r}=n,s=((l=(o=a.engine)==null?void 0:o.runtime)==null?void 0:l.timeline)||{};e(r.showHook),setTimeout(()=>{t(1),i(1),e(r.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(d=s.tutorial_delay_ms)!=null?d:1500)}0&&(module.exports={AssetCache,AssetLoader,AssetSystem,AssetTextures,Assets,BaseSystem,GameEngine,GameObject,GameObjectManager,ObjectFactory,Renderer,RuntimeObjectRegistry,Transform,applyScreenAnchor,basePixi,clearResponsiveElements,createPixiBase,getRegisteredFontIds,globalResponsiveMultipliers,initAssetTextures,initAssets,layout,playLottieOverlay,registerFont,registerType,resolveAnchorVec2,resolveFont,resolveFontWeight,resolveScreenAnchorPoint,resolveScreenRatioPoint,runInitSequence,setLottieInstance,spawnSceneFromConfig,updateScreenState});
255
+ `,e.appendChild(v);let w;try{w=u.loadAnimation({container:v,renderer:r.renderer||"svg",loop:(we=r.loop)!=null?we:!1,autoplay:(xe=r.autoplay)!=null?xe:!0,animationData:d})}catch(q){return v.parentNode&&v.parentNode.removeChild(v),console.warn(`[LottieOverlay] Failed to start animation: ${n}`,q),null}r.speed!==void 0&&w.setSpeed(r.speed);let y=()=>{w.destroy(),v.parentNode&&v.parentNode.removeChild(v)};return r.loop||w.addEventListener("complete",y),{animation:w,cleanup:y}}Dt();mn();var Yt=class{constructor(e,t,i){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=i}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:i}=await Vt(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=i,this.gameObjectManager=new Xe(this.config),this.stage.eventMode="passive",this.stage.interactive=!1,this.stage.interactiveChildren=!0,this.stage.sortableChildren=!0,this.context={app:this.app,stage:this.stage,config:this.config,gameObjectManager:this.gameObjectManager,destinationUrl:this.destinationUrl,root:this.root,engine:this};for(let a of this.systems)a.setContext(this.context);return{app:this.app,gameObjectManager:this.gameObjectManager}}async initSystems(){if(!this.context)throw new Error("[GameEngine] createApp() must be called before initSystems()");for(let e of this.systems)e.init&&await e.init()}async init(e){return await this.createApp(e),await this.initSystems(),{app:this.app,gameObjectManager:this.gameObjectManager}}registerSystems(e){this.systems.push(...e)}async start(){for(let e of this.systems)e.onStart&&await e.onStart();this.app.ticker.add(this.update.bind(this)),window.addEventListener("handler-preview:screen",e=>{let{width:t,height:i}=e.detail;this.resize(t,i)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let i of this.systems)i.update&&i.update(t,this.totalTime)}resize(e,t){for(let i of this.systems)i.onResize&&i.onResize(e,t)}updateConfig(e){this.config=e;for(let t of this.systems)t.context.config=e,t.onConfigUpdate&&t.onConfigUpdate(e)}destroy(){for(let e of this.systems)e.onDestroy&&e.onDestroy();this.app.ticker.remove(this.update.bind(this)),this.app.destroy(!0,{children:!0,texture:!1})}getApp(){return this.app}getGameObjectManager(){return this.gameObjectManager}getTotalTime(){return this.totalTime}getSystem(e){let t=this.systems.find(i=>i instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var Ze=class{setContext(e){this.context=e}};var Qe=class{constructor(){this.config=null}init(e){this.config=e}get(e){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return this.config.objects.get(e)}getAllIds(){if(!this.config)throw new Error("RuntimeObjectRegistry not initialized. Call init() first.");return Array.from(this.config.objects.keys())}has(e){return this.config?this.config.objects.has(e):!1}};var oa=Pt(require("pixi.js"),1),la=oa;typeof window!="undefined"&&(window.__basePixi=oa);gt();var he=require("pixi.js");gt();var ca=n=>n*Math.PI/180;function Er(n,e){var s,o,l,d,u;let t=e.ui;if(!(t!=null&&t.text))return null;let i="#ffffff";(s=e.render)!=null&&s.tint&&(i=e.render.tint);let a=new he.TextStyle({fontFamily:(o=t.font)!=null?o:"Arial",fontSize:(l=t.fontSize)!=null?l:16,fill:i,align:(d=t.align)!=null?d:"center",letterSpacing:(u=t.letterSpacing)!=null?u:0}),r=new he.Text({text:t.text,style:a});return r.label=n,r}function da(n){var u,c,p,g,m,f,A,b,h,v;let{stage:e,mainContainer:t,activeConfig:i,gameObjectManager:a,allowList:r,denyList:s}=n,o={},l={},d={};t.sortableChildren=!0;for(let[w,y]of i.objects.entries()){if(s!=null&&s.has(w)||r&&!r.has(w)||(y==null?void 0:y.enabled)===!1)continue;let I=(c=(u=y==null?void 0:y.render)==null?void 0:u.asset)==null?void 0:c.path,P=(g=(p=y==null?void 0:y.render)==null?void 0:p.asset)==null?void 0:g.type,B=!!(I&&P==="image"),R=!!((m=y==null?void 0:y.ui)!=null&&m.text),H=R?(f=y==null?void 0:y.ui)==null?void 0:f.renderMode:void 0,z;if(H==="png"&&B?z="png":H==="text"&&R?z="text":B?z="png":R?z="text":z="skip",z!=="skip"){if(z==="text"){let T=Er(w,y);if(!T)continue;let E=y.render;T.alpha=typeof(E==null?void 0:E.alpha)=="number"?E.alpha:1,T.visible=(E==null?void 0:E.visible)!==!1,T.zIndex=typeof(E==null?void 0:E.z_index)=="number"?E.z_index:0,E!=null&&E.anchor&&typeof E.anchor.x=="number"&&typeof E.anchor.y=="number"?T.anchor.set(E.anchor.x,E.anchor.y):T.anchor.set(.5,.5);let S=y.transform,C=(S==null?void 0:S.position)||(S==null?void 0:S.offset);C&&T.position.set((A=C.x)!=null?A:0,(b=C.y)!=null?b:0);let L=typeof(S==null?void 0:S.scale)=="number"?S.scale:1;T.scale.set(L,L);let G=typeof(S==null?void 0:S.rotation)=="number"?S.rotation:0;T.rotation=ca(G),T.parent||t.addChild(T);try{a.create(w,T)}catch{}o[w]=T,d[w]=T}else if(z==="png"){let T=Te[w]||(typeof he.Texture!="undefined"?he.Texture.EMPTY:void 0),E=new he.Sprite(T);E.label=w;let S=y.render;E.alpha=typeof(S==null?void 0:S.alpha)=="number"?S.alpha:1,E.visible=(S==null?void 0:S.visible)!==!1,E.zIndex=typeof(S==null?void 0:S.z_index)=="number"?S.z_index:0,S!=null&&S.anchor&&typeof S.anchor.x=="number"&&typeof S.anchor.y=="number"&&E.anchor.set(S.anchor.x,S.anchor.y);let C=y.transform,L=(C==null?void 0:C.position)||(C==null?void 0:C.offset);L&&E.position.set((h=L.x)!=null?h:0,(v=L.y)!=null?v:0);let G=typeof(C==null?void 0:C.scale)=="number"?C.scale:1;E.scale.set(G,G);let ne=typeof(C==null?void 0:C.rotation)=="number"?C.rotation:0;E.rotation=ca(ne),E.parent||t.addChild(E);try{a.create(w,E)}catch{}o[w]=E,l[w]=E}}}return t.parent||e.addChild(t),{objects:o,sprites:l,texts:d}}var Dn=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Qe}init(e,t){this.registry.init(e),this.app=t}updateConfig(e){this.registry.init(e),this.instanceCache.clear(),this.readyPromise=null}async ready(){this.readyPromise&&await this.readyPromise;let t=this.registry.getAllIds().filter(a=>!this.instanceCache.has(a));if(t.length===0)return;let i=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async r=>{var o;let s=this.registry.get(r);if(!s){console.warn("[Assets] No config found for object:",r);return}try{let l=await Le.create(r,s,this.app);this.instanceCache.set(r,l),console.log("[Assets] Loaded object:",r,(o=l==null?void 0:l.constructor)==null?void 0:o.name)}catch(l){console.error("[Assets] Failed to load object:",r,l)}})))};return this.readyPromise=(async()=>{await i(t);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await i(a)),console.log("[Assets] Ready. Cached objects:",Array.from(this.instanceCache.keys()))})(),this.readyPromise}resetScene(){this.instanceCache.clear(),this.readyPromise=null}async reloadObject(e){let t=this.registry.get(e);if(t){let i=await Le.create(e,t,this.app);this.instanceCache.set(e,i)}}get(e){return this.instanceCache.get(e)}},pa=new Dn,ua=new Proxy(pa,{get(n,e){if(e in n&&typeof n[e]=="function")return n[e].bind(n);if(n.get(e))return n.get(e)}});function ga(n,e){pa.init(n,e)}gt();var Kt=class extends Ze{async init(){Ht(this.context.config,this.context.app),await Te.ready(),console.log("[AssetSystem] All assets preloaded and ready")}async onStart(){}onConfigUpdate(){console.log("[AssetSystem] Config updated - systems will refresh textures")}};var Qt=require("pixi.js"),fe={width:400,height:600,designWidth:400,scaleFactor:1},Tt={scale:1,position:1},en=[];function Sr(n,e,t,i,a,r,s){en.push({element:n,originalScale:r,positionHelper:e,heightPercent:a}),e(n,t,i,a,r,s,!1)}function Ar(){en.forEach(({element:n,originalScale:e,positionHelper:t,heightPercent:i})=>{let a=e*fe.scaleFactor;t(n,fe.width,fe.height,i,a,!0,!1)})}function ha(){en.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Jt(n,e){console.log(`[SCREEN] updateScreenState called: ${n}x${e}`),fe.width=n,fe.height=e,fe.scaleFactor=Math.min(n/fe.designWidth,1.15),Tt.scale=fe.scaleFactor,Tt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Tt.scale.toFixed(3)}`),Ar()}var O={layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}};function Cr(n,e,t){let i=O[n];i&&i[e]!==void 0&&(i[e]=t,console.log(`Updated ${n}.${e} = ${t}`))}function Tr(){return O}var Lr={center:{x:.5,y:.5},"center-center":{x:.5,y:.5},middle:{x:.5,y:.5},"middle-center":{x:.5,y:.5},"top-left":{x:0,y:0},"top-center":{x:.5,y:0},"top-right":{x:1,y:0},"bottom-left":{x:0,y:1},"bottom-center":{x:.5,y:1},"bottom-right":{x:1,y:1},"left-center":{x:0,y:.5},"right-center":{x:1,y:.5},"center-left":{x:0,y:.5},"center-right":{x:1,y:.5},left:{x:0,y:.5},right:{x:1,y:.5},top:{x:.5,y:0},bottom:{x:.5,y:1}};function Xt(n,e){return typeof n=="number"&&Number.isFinite(n)?n:e}function $e(n,e={x:.5,y:.5}){var t;if(Array.isArray(n))return{x:Xt(n[0],e.x),y:Xt(n[1],e.y)};if(n&&typeof n=="object"){let i=n;return{x:Xt(i.x,e.x),y:Xt(i.y,e.y)}}if(typeof n=="string"){let i=n.trim().toLowerCase();return(t=Lr[i])!=null?t:e}return e}function et(n,e,t,i={}){var g,m,f,A,b,h;let a=$e(t),r=(g=i.inset)!=null?g:{},s=(m=i.padding)!=null?m:{x:0,y:0},o=((f=r.left)!=null?f:0)+s.x,l=((A=r.right)!=null?A:0)+s.x,d=((b=r.top)!=null?b:0)+s.y,u=((h=r.bottom)!=null?h:0)+s.y,c=Math.max(0,n-o-l),p=Math.max(0,e-d-u);return{x:o+c*a.x,y:d+p*a.y}}function tt(n,e,t,i={}){var f,A,b,h,v,w;let a=(f=i.inset)!=null?f:{},r=(A=i.padding)!=null?A:{x:0,y:0},s=((b=a.left)!=null?b:0)+r.x,o=((h=a.right)!=null?h:0)+r.x,l=((v=a.top)!=null?v:0)+r.y,d=((w=a.bottom)!=null?w:0)+r.y,u=Math.max(0,n-s-o),c=Math.max(0,e-l-d),p=$e(t,{x:.5,y:.5}),g=Math.min(Math.max(p.x,0),1),m=Math.min(Math.max(p.y,0),1);return{x:s+u*g,y:l+c*m}}function Zt(n,e,t,i={}){var u,c,p;if(!n)return;let a=i.positionRatio?tt(e,t,i.positionRatio,{inset:i.inset,padding:i.screenPadding}):et(e,t,i.anchor,{inset:i.inset,padding:i.screenPadding}),r=(u=i.offset)!=null?u:{x:0,y:0},s=a.x+r.x,o=a.y+r.y;n.anchor&&i.renderAnchor&&n.anchor.set(i.renderAnchor.x,i.renderAnchor.y),te(n,s,o);let l=(c=i.scale)!=null?c:1,d=(p=i.scaleMultiplier)!=null?p:1;(i.scale!==void 0||i.scaleMultiplier!==void 0)&&oe(n,l*d)}if(typeof window!="undefined"){let n=window.innerWidth,e=window.innerHeight,t=()=>{let i=window.innerWidth,a=window.innerHeight;(i!==n||a!==e)&&(n=i,e=a,Jt(i,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Jt(window.innerWidth,window.innerHeight),window.updateDebugConfig=Cr,window.getDebugConfig=Tr,window.copyConfig=Dr,window.applyConfig=Ct,window.applyConfigForRatio=Hr,window.positionAtBottom=fa,window.positionAtTop=Mr,window.positionAtCenter=Pr,window.positionAtLeft=_r,window.positionAtRight=jr,window.positionAtBottomLeft=Or,window.positionAtBottomRight=Rr,window.positionAtTopLeft=zr,window.positionAtTopRight=$r,window.applyPositionContract=Ir,console.log("\u{1F3AE} Debug Config Functions Available:"),console.log("\u2022 updateDebugConfig(category, key, value)"),console.log("\u2022 getDebugConfig()"),console.log("\u2022 copyConfig(presetName)"),console.log("\u2022 applyConfig(config)"),console.log("\u2022 applyConfigForRatio(width, height)"),console.log("\u{1F4CD} Positioning Helpers Available (with scale):"),console.log("\u2022 positionAtBottom(element, w, h, percent, scale)"),console.log("\u2022 positionAtTop(element, w, h, percent, scale)"),console.log("\u2022 positionAtCenter(element, w, h, offsetX, offsetY, scale)"),console.log("\u2022 positionAtLeft/Right(element, w, h, percent, scale)"),console.log("\u2022 Corner positions: BottomLeft/Right, TopLeft/Right (all with scale)"),console.log("\u2022 applyPositionContract(element, w, h, contract)"),console.log("Example: positionAtCenter(mySprite, 400, 600, 0, -50, 1.2)")}function tn(n,e,t=0){return n*e+t}function nn(n,e,t=0){return n*(1-e)+t}function an(n,e,t=0){return n*e+t}function rn(n,e,t=0){return n*(1-e)+t}function Q(n,e=0){return n/2+e}function kr(n,e){return n*e}function Ir(n,e,t,i){var s,o,l,d,u,c,p,g,m,f,A,b,h,v,w,y,I,P,B,R;let a=0,r=0;switch(i.type){case"top":a=Q(e,(o=(s=i.offset)==null?void 0:s.x)!=null?o:0),r=tn(t,i.percent,(d=(l=i.offset)==null?void 0:l.y)!=null?d:0);break;case"bottom":a=Q(e,(c=(u=i.offset)==null?void 0:u.x)!=null?c:0),r=nn(t,i.percent,(g=(p=i.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=an(e,i.percent,(f=(m=i.offset)==null?void 0:m.x)!=null?f:0),r=Q(t,(b=(A=i.offset)==null?void 0:A.y)!=null?b:0);break;case"right":a=rn(e,i.percent,(v=(h=i.offset)==null?void 0:h.x)!=null?v:0),r=Q(t,(y=(w=i.offset)==null?void 0:w.y)!=null?y:0);break;case"center":a=Q(e,(P=(I=i.offset)==null?void 0:I.x)!=null?P:0),r=Q(t,(R=(B=i.offset)==null?void 0:B.y)!=null?R:0);break}n.position?n.position.set(a,r):(n.x=a,n.y=r),i.scale!==void 0&&i.scale!==1&&n.scale&&(typeof n.scale.set=="function"?n.scale.set(i.scale,i.scale):(n.scale.x=i.scale,n.scale.y=i.scale))}function fa(n,e,t,i=.2,a=1,r=!0,s=!1){let o=kr(t,i),l=nn(t,i/2);te(n,Q(e),l);let d=r?a*fe.scaleFactor:a;oe(n,d),s&&!en.find(u=>u.element===n)&&Sr(n,fa,e,t,i,a,r)}function Mr(n,e,t,i=.1,a=1){te(n,Q(e),tn(t,i)),oe(n,a)}function Pr(n,e,t,i=0,a=0,r=1){te(n,Q(e,i),Q(t,a)),oe(n,r)}function _r(n,e,t,i=.1,a=1){te(n,an(e,i),Q(t)),oe(n,a)}function jr(n,e,t,i=.1,a=1){te(n,rn(e,i),Q(t)),oe(n,a)}function Or(n,e,t,i=.05,a=.05,r=1){te(n,an(e,a),nn(t,i)),oe(n,r)}function Rr(n,e,t,i=.05,a=.05,r=1){te(n,rn(e,a),nn(t,i)),oe(n,r)}function zr(n,e,t,i=.05,a=.05,r=1){te(n,an(e,a),tn(t,i)),oe(n,r)}function $r(n,e,t,i=.05,a=.05,r=1){te(n,rn(e,a),tn(t,i)),oe(n,r)}function te(n,e,t){n&&n.position?typeof n.position.set=="function"?n.position.set(e,t):(n.position.x=e,n.position.y=t):n&&(n.x=e,n.y=t)}function oe(n,e){e!==1&&n&&n.scale&&(typeof n.scale.set=="function"?n.scale.set(e,e):n.scale.x!==void 0&&n.scale.y!==void 0&&(n.scale.x=e,n.scale.y=e))}var ze={default:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1,screen_scale_y:1},engine:{scale:1,background_scale:1.05,background_offset_y:0,background_alpha:.98,label_pulse_speed:3,label_pulse_intensity:.03}},wide:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.9,screen_scale_y:1.1},engine:{scale:1,background_scale:1.1,background_offset_y:0,background_alpha:.95,label_pulse_speed:3,label_pulse_intensity:.03}},square:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:.85,screen_scale_y:.85},engine:{scale:1,background_scale:1,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}},tall:{layout:{scale_multiplier:1,position_offset:{x:0,y:0},debug_rect_visible:!0,debug_rect_color:16711680,debug_rect_thickness:4,debug_rect_scale_x:1,debug_rect_scale_y:1,screen_scale_x:1.1,screen_scale_y:.9},engine:{scale:1,background_scale:.95,background_offset_y:0,background_alpha:1,label_pulse_speed:3,label_pulse_intensity:.03}}};function Dr(n){return n&&ze[n]?JSON.parse(JSON.stringify(ze[n])):JSON.parse(JSON.stringify(O))}function Ct(n){Object.keys(n).forEach(e=>{let t=e;O[t]&&n[t]&&Object.assign(O[t],n[t])}),console.log("Config applied:",n)}function Hr(n,e){let t=n/e;t>1.6?(Ct(ze.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(Ct(ze.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(Ct(ze.square),console.log("Applied SQUARE config for ratio:",t)):(Ct(ze.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let n=window;n.configPresets=ze,n.resolveAnchorVec2=n.resolveAnchorVec2||$e,n.resolveScreenAnchorPoint=n.resolveScreenAnchorPoint||et,n.resolveScreenRatioPoint=n.resolveScreenRatioPoint||tt}var Y=null;function ma(n,e,t,i,a,r={}){var G,ne,me,be,ye,ve,we,xe,q,Ie,nt,it,at,rt,st,ot,lt,ct,dt,pt,N,K,U,X,De,Me,Hn,Nn,Fn,Bn,Un,Gn,qn,Vn;let s=(G=r.enableDebugLogs)!=null?G:!1;s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:i.width,height:i.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",r));let{mainContainer:o,label:l,background:d,backgroundTexture:u,app:c}=n;if(!c||!c.renderer){s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:c.renderer.width,height:c.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:c.screen.width,height:c.screen.height}));let p=i.width,g=i.height;s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Base dimensions:",{baseWidth:p,baseHeight:g});let m=p*O.layout.screen_scale_x,f=g*O.layout.screen_scale_y,A=p/2,b=e.engine.runtime||{},h=b.layout||{};s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug config:",{screen_scale_x:O.layout.screen_scale_x,screen_scale_y:O.layout.screen_scale_y}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Calculated dimensions:",{width:m,height:f,midX:A}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",b),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",h));let v=h.design_width_portrait||400,w=m/v;w=Math.min(w,1.15);let y=w*((ne=O.engine.scale)!=null?ne:1),I=(me=r.skipMainContainerTransform)!=null?me:!1;!I&&o&&o.scale&&(typeof o.scale.set=="function"?o.scale.set(y):(o.scale.x=y,o.scale.y=y));let P=(be=h.main_container_anchor)!=null?be:"center",B=(ye=h.main_container_position_ratio)!=null?ye:{x:.5,y:.5},R=(ve=h.main_container_offset)!=null?ve:{x:0,y:0},H=h.main_container_position_ratio?tt(p,g,B):et(p,g,P),z=H.x+R.x+O.layout.position_offset.x,T=H.y+R.y+O.layout.position_offset.y;if(!I&&o&&o.position&&(typeof o.position.set=="function"?o.position.set(z,T):(o.position.x=z,o.position.y=T)),a&&(o!=null&&o.toLocal))for(let[V,F]of e.objects.entries()){let _=F==null?void 0:F.transform;if(!_||((we=_.position_mode)!=null?we:"static")!=="static")continue;let k=(xe=a.get)==null?void 0:xe.call(a,V),ie=((q=k==null?void 0:k.getDisplayObject)==null?void 0:q.call(k))||(k==null?void 0:k.pixiObject)||k;if(!ie||ie.parent!==o)continue;let Lt=_.position_ratio!=null?tt(p,g,_.position_ratio):et(p,g,(Ie=_.anchor)!=null?Ie:"center"),kt=o.toLocal(new Qt.Point(Lt.x,Lt.y)),It=(nt=_.position)!=null?nt:{x:0,y:0},Pe=kt.x+It.x,sn=kt.y+It.y;typeof(k==null?void 0:k.setPosition)=="function"?k.setPosition(Pe,sn):(te(ie,Pe,sn),(it=k==null?void 0:k.transform)!=null&&it.position&&(k.transform.position.x=Pe,k.transform.position.y=sn))}let E=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,C=((E==null?void 0:E.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(O.layout.debug_rect_visible&&C){(!Y||Y.parent!==c.stage)&&(Y==null||Y.destroy(),Y=new Qt.Graphics,Y.zIndex=9999,c.stage.addChild(Y)),Y.clear();let V=O.layout.debug_rect_scale_x,F=O.layout.debug_rect_scale_y,_=(p-4)*V,Ee=(g-4)*F,k=(p-_)/2,ie=(g-Ee)/2;s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:_,rectH:Ee,offsetX:k,offsetY:ie}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+k,y:2+ie,width:_,height:Ee})),Y.rect(2+k,2+ie,_,Ee).stroke({width:O.layout.debug_rect_thickness,color:O.layout.debug_rect_color})}else Y&&(Y.destroy(),Y=null);let L=((at=n.label)==null?void 0:at.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(l&&l.position&&L){let V=(st=(rt=L==null?void 0:L.transform)==null?void 0:rt.anchor)!=null?st:"center",F=(ot=L==null?void 0:L.transform)==null?void 0:ot.position_ratio,_=((lt=L==null?void 0:L.transform)==null?void 0:lt.offset)||{x:0,y:0};Zt(l,p,g,{anchor:V,positionRatio:F,offset:{x:_.x*y,y:_.y*y},renderAnchor:$e(V)})}if(l&&l.alpha>0){let V=1+Math.sin(t*O.engine.label_pulse_speed)*O.engine.label_pulse_intensity,F=(dt=(ct=L==null?void 0:L.transform)==null?void 0:ct.scale)!=null?dt:1,_=V*y*F;l.scale&&(typeof l.scale.set=="function"?l.scale.set(_):(l.scale.x=_,l.scale.y=_))}if(s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),d){s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!d),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(pt=d.constructor)==null?void 0:pt.name)),d.alpha=((K=(N=b.background)==null?void 0:N.alpha)!=null?K:.98)*O.engine.background_alpha,s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",d.alpha);let V=e.objects.get("background_1");s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",V);let F=(V==null?void 0:V.transform)||{};s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",F);let _=F.offset||{x:0,y:0},Ee=((X=(U=b.background)==null?void 0:U.offset_y)!=null?X:0)+O.engine.background_offset_y,k=(De=F.anchor)!=null?De:"center",ie=F.position_ratio;if(s&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:_,bgRuntimeOffsetY:Ee,bgScreenAnchor:k,bgPositionRatio:ie,baseWidth:p,baseHeight:g,finalScale:y}),Zt(d,p,g,{anchor:k,positionRatio:ie,offset:{x:_.x*y,y:_.y*y+Ee},renderAnchor:$e(k)}),s&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:d.x,y:d.y,scaleX:(Me=d.scale)==null?void 0:Me.x,scaleY:(Hn=d.scale)==null?void 0:Hn.y,anchorX:(Nn=d.anchor)==null?void 0:Nn.x,anchorY:(Fn=d.anchor)==null?void 0:Fn.y,pivotX:(Bn=d.pivot)==null?void 0:Bn.x,pivotY:(Un=d.pivot)==null?void 0:Un.y,width:d.width,height:d.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background texture dimensions:",{textureWidth:u==null?void 0:u.width,textureHeight:u==null?void 0:u.height})),u){let Lt=Math.max(m/u.width,f/u.height),kt=(qn=(Gn=b.background)==null?void 0:Gn.scale_multiplier)!=null?qn:1.05,It=(Vn=F.scale)!=null?Vn:1,Pe=Lt*kt*O.engine.background_scale*It;d.scale&&(typeof d.scale.set=="function"?d.scale.set(Pe):(d.scale.x=Pe,d.scale.y=Pe))}else d&&typeof d.clear=="function"&&(d.clear(),d.rect(-m/2,-f/2,m,f).fill({color:1444375}))}}function ba(n){var o,l,d;let{setState:e,updateLabelAlpha:t,updateHandAlpha:i,config:a,states:r}=n,s=((l=(o=a.engine)==null?void 0:o.runtime)==null?void 0:l.timeline)||{};e(r.showHook),setTimeout(()=>{t(1),i(1),e(r.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(d=s.tutorial_delay_ms)!=null?d:1500)}0&&(module.exports={AssetCache,AssetLoader,AssetSystem,AssetTextures,Assets,BaseSystem,GameEngine,GameObject,GameObjectManager,ObjectFactory,Renderer,RuntimeObjectRegistry,Transform,applyScreenAnchor,basePixi,clearResponsiveElements,createPixiBase,getRegisteredFontIds,globalResponsiveMultipliers,initAssetTextures,initAssets,layout,playLottieOverlay,registerFont,registerType,resolveAnchorVec2,resolveFont,resolveFontWeight,resolveScreenAnchorPoint,resolveScreenRatioPoint,runInitSequence,setLottieInstance,spawnSceneFromConfig,updateScreenState});
@@ -1076,6 +1076,18 @@
1076
1076
  transition: all var(--ui-duration-fast) var(--ui-ease);
1077
1077
  }
1078
1078
 
1079
+ .scene-object-checkbox {
1080
+ width: 14px;
1081
+ height: 14px;
1082
+ min-width: 14px;
1083
+ min-height: 14px;
1084
+ margin: 0;
1085
+ margin-right: 6px;
1086
+ cursor: pointer;
1087
+ accent-color: var(--ui-terracotta);
1088
+ flex-shrink: 0;
1089
+ }
1090
+
1079
1091
  .scene-object-label {
1080
1092
  white-space: nowrap;
1081
1093
  overflow: hidden;