handler-playable-sdk 0.5.26 → 0.5.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-CFNCYJKB.js → chunk-EZMANCHN.js} +211 -105
- package/dist/cli/brand-dna.mjs +1 -1
- package/dist/cli/canva-import.mjs +1 -1
- package/dist/cli/cleanup-assets.mjs +1 -1
- package/dist/cli/fix-scales.mjs +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/screen-helper.mjs +1 -1
- package/dist/cli/setup-library.mjs +1 -1
- package/dist/cli/student-helper.mjs +1 -1
- package/dist/cli/sync-screens.mjs +1 -1
- package/dist/cli/validate-assets.mjs +1 -1
- package/dist/cli/validate.mjs +1 -1
- package/dist/index.cjs +195 -89
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/pixi/index.cjs +13 -13
- package/dist/pixi/index.js +1 -1
- package/dist/three/index.cjs +17 -17
- package/dist/three/index.js +1 -1
- package/package.json +1 -1
package/dist/pixi/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ba=Object.create;var ht=Object.defineProperty;var ya=Object.getOwnPropertyDescriptor;var va=Object.getOwnPropertyNames;var wa=Object.getPrototypeOf,xa=Object.prototype.hasOwnProperty;var ne=(i,e)=>()=>(i&&(e=i(i=0)),e);var Vi=(i,e)=>{for(var t in e)ht(i,t,{get:e[t],enumerable:!0})},Wi=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of va(e))!xa.call(i,a)&&a!==t&&ht(i,a,{get:()=>e[a],enumerable:!(n=ya(e,a))||n.enumerable});return i};var ft=(i,e,t)=>(t=i!=null?ba(wa(i)):{},Wi(e||!i||!i.__esModule?ht(t,"default",{value:i,enumerable:!0}):t,i)),Ea=i=>Wi(ht({},"__esModule",{value:!0}),i);var ka,ue=ne(()=>{"use strict";ka="handler_preview_override_mode";if(typeof window!="undefined"){let i=window.localStorage.getItem(ka);window.__enableConfigOverrides=i===null?!0:i==="true"}});var Tn,we,Zr,Yt=ne(()=>{"use strict";ue();Tn=null,we="dev";if(typeof window!="undefined"){let i=window.__BUILD_SETTINGS__;if(i!=null&&i.buildMode)Tn=i,we=i.buildMode,console.log("[CONFIG] Loaded inline build settings:",i,"buildMode:",we);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);Tn=t,we=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",we)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",we)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",we);Zr=we==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var Kt=ne(()=>{"use strict"});var kn=ne(()=>{"use strict";Kt();Yt()});var Xt=ne(()=>{"use strict";Yt();Kt();kn()});var Q,Qt=ne(()=>{"use strict";Q=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()}};Q.store=new Map});function Ba(){var i,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(i=document.querySelector("script"))==null?void 0:i.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),n=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!n)}catch{return!1}}async function Ua(){try{if(typeof window!="undefined"){let i=await fetch("./build-settings.json");if(i.ok){let e=await i.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Ga(){try{if(typeof window!="undefined"){let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.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: ${P}`),Object.keys(ae).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(ae)),ae;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),ae={...window.INLINE_ASSETS},ae;if(!(P==="publish"&&ee!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),ae;if(!ei){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),ei=(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 n=await t.text();console.log("[AssetLoader] Received JS code, length:",n.length);let a=n.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 o=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(o)),o}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:",n.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return ae=await ei,console.log("[AssetLoader] Final inline assets cache:",Object.keys(ae)),ae}function ti(i){return i===null||typeof i!="object"||(Object.freeze(i),Object.values(i).forEach(e=>ti(e))),i}function Va(i=64,e=64,t=16711680){let n=document.createElement("canvas");n.width=i,n.height=e;let a=n.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,i,e),a.strokeStyle="#000",a.strokeRect(0,0,i,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",i/2,e/2),re.Texture.from(n)}function xt(i,e){Rn.set(i,e)}var re,In,jn,xe,P,ee,ge,ae,ei,Rn,he,Et=ne(()=>{"use strict";re=require("pixi.js");Qt();In=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",jn=Ba(),xe=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,P=jn?"publish":In,ee=xe==null?void 0:xe.assetsInlined;xe!=null&&xe.buildMode&&(P=xe.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${P}`));ge=Ga();ge!=null&&ge.buildMode&&(P=ge.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${P}`));(ge==null?void 0:ge.assetsInlined)!==void 0&&(ee=ge.assetsInlined);Ua().then(i=>{i!=null&&i.buildMode&&i.buildMode!==P&&(P=i.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${P}`)),(i==null?void 0:i.assetsInlined)!==void 0&&(ee=i.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${In}, Runtime: ${jn?"publish":"dev"}, Effective: ${P}`);ae={},ei=null;Rn=new Map;he=class{static async load(e,t,n,a){let r=`${e}:${t.path}`,o=Q.get(r);if(o!==void 0)return o;console.log(`[AssetLoader] Loading asset: ${e}, type: ${t.type}, Effective mode: ${P}`),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 s=await qa(),d=s[e];if(!d&&a&&(d=s[a],d&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${a}`)),!d&&t.path){let l=t.path.split("/");if(l.length>=2){let p=l[l.length-1].split(".")[0];s[p]&&(d=s[p],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${p}`))}}if(console.log("[AssetLoader] Inline data for",e,":",d?"FOUND":"NOT FOUND"),P==="publish"&&ee!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!d))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${t.path}`);let u=Rn.get(t.type);if(u)try{let l=await u(t.path,d,e,n);return Q.set(r,l),l}catch(l){return this.handleFailure(e,t.type,l)}try{let l;switch(t.type){case"image":l=await this.loadImage(t.path,d);break;case"json":l=await this.loadJSON(t.path,d),l=ti(l);break;default:throw new Error(`Unknown asset type: ${t.type}`)}return Q.set(r,l),l}catch(l){return this.handleFailure(e,t.type,l)}}static async loadImage(e,t){let n=P==="publish",a=n&&ee!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${P}, isPublishMode: ${n}, 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 re.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 re.Assets.load(t)}catch(r){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",r),await re.Assets.load(e)}return await re.Assets.load(e)}static async loadJSON(e,t){let n=P==="publish",a=n&&ee!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${P}, isPublishMode: ${n}, 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 o=atob(t.split(",")[1]);return JSON.parse(o)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let o=atob(t.split(",")[1]);return JSON.parse(o)}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,n){if(P==="dev"){let r=t==="image"?Va():ti({__placeholder:!0,type:t});return Q.set(e+":"+((n==null?void 0:n.path)||"missing"),r),r}throw n}};xt("image",async(i,e)=>{let t=P==="publish",n=t&&ee!==!1,a=P==="brand",r=t&&ee===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${P}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){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: ${i}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return re.Assets.load(e)}let o=i;return(a||r)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(o=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${o}"`))),re.Assets.load(e||o)});xt("json",async(i,e)=>{let t=P==="publish",n=t&&ee!==!1,a=P==="brand",r=t&&ee===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${P}, isPublishMode: ${t}, isBrandMode: ${a}, inlineData: ${e?"EXISTS":"MISSING"}`),n){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: ${i}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let o=i;if((a||r)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(o=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${o}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let s=await fetch(o);if(!s.ok)throw new Error(`JSON fetch failed: ${i}`);return s.json()})});function St(i,e){zn.init(i,e),typeof window!="undefined"&&(window.__AssetTextures=fe)}var ii,zn,fe,Xe=ne(()=>{"use strict";Et();ii=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(n=>{this.priorityReadyResolve=n}),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 o;console.log("[AssetTextures] Loading all assets...");let n=new Set(["background_loading_1"]),a=[],r=[];for(let[s,d]of e.objects.entries()){let c=(o=d.render)==null?void 0:o.asset;if(!c)continue;let u=async()=>{var l;try{let p=(l=d.identity)==null?void 0:l.id;console.log(`[AssetTextures] Loading ${c.type}: ${s} (${p})`);let g=await he.load(s,c,t,p);this.textures.set(s,g),console.log(`[AssetTextures] \u2713 Loaded: ${s}`)}catch(p){console.error(`[AssetTextures] \u2717 Failed to load: ${s}`,p)}finally{this.attempted.add(s);try{for(let p of Array.from(this.waiters))p()}catch{}}};n.has(s)?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(s=>typeof s=="string"&&s))).filter(s=>{var d,c,u,l;try{let p=(u=(c=(d=this.config)==null?void 0:d.objects)==null?void 0:c.get)==null?void 0:u.call(c,s);return!!((l=p==null?void 0:p.render)!=null&&l.asset)}catch{return!1}});if(a.length===0)return;this.ready().catch(()=>{});let r=()=>a.every(s=>this.textures.has(s)||this.attempted.has(s));if(r())return;let o=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(s=>{let d=!1,c=()=>{d||r()&&(d=!0,this.waiters.delete(c),s())};this.waiters.add(c),c(),o>0&&setTimeout(()=>{d||(d=!0,this.waiters.delete(c),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),s())},o)})}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())}},zn=new ii,fe=new Proxy(zn,{get(i,e){return e in i&&typeof i[e]=="function"?i[e].bind(i):i.get(e)},set(i,e,t){return i.set(e,t),!0}})});var Hn={};Vi(Hn,{AssetEditorModal:()=>si});var si,li=ne(()=>{"use strict";si=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,n,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=n,this.onApplyCallback=a,this.createModal(e,n),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let n=document.createElement("div");n.className="asset-editor-modal",n.innerHTML=`
|
|
1
|
+
"use strict";var ba=Object.create;var Mt=Object.defineProperty;var ya=Object.getOwnPropertyDescriptor;var va=Object.getOwnPropertyNames;var wa=Object.getPrototypeOf,xa=Object.prototype.hasOwnProperty;var le=(i,e)=>()=>(i&&(e=i(i=0)),e);var Vi=(i,e)=>{for(var t in e)Mt(i,t,{get:e[t],enumerable:!0})},Wi=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of va(e))!xa.call(i,a)&&a!==t&&Mt(i,a,{get:()=>e[a],enumerable:!(n=ya(e,a))||n.enumerable});return i};var _t=(i,e,t)=>(t=i!=null?ba(wa(i)):{},Wi(e||!i||!i.__esModule?Mt(t,"default",{value:i,enumerable:!0}):t,i)),Ea=i=>Wi(Mt({},"__esModule",{value:!0}),i);var ka,Se=le(()=>{"use strict";ka="handler_preview_override_mode";if(typeof window!="undefined"){let i=window.localStorage.getItem(ka);window.__enableConfigOverrides=i===null?!0:i==="true"}});var Tn,Oe,Zr,di=le(()=>{"use strict";Se();Tn=null,Oe="dev";if(typeof window!="undefined"){let i=window.__BUILD_SETTINGS__;if(i!=null&&i.buildMode)Tn=i,Oe=i.buildMode,console.log("[CONFIG] Loaded inline build settings:",i,"buildMode:",Oe);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);Tn=t,Oe=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",Oe)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",Oe)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",Oe);Zr=Oe==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload")});var pi=le(()=>{"use strict"});var kn=le(()=>{"use strict";pi();di()});var ui=le(()=>{"use strict";di();pi();kn()});var ae,fi=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 i,e;try{let t=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(i=document.querySelector("script"))==null?void 0:i.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),n=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(t&&!n)}catch{return!1}}async function Ua(){try{if(typeof window!="undefined"){let i=await fetch("./build-settings.json");if(i.ok){let e=await i.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function Ga(){try{if(typeof window!="undefined"){let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.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(ce).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(ce)),ce;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),ce={...window.INLINE_ASSETS},ce;if(!(M==="publish"&&re!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),ce;if(!mi){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),mi=(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 n=await t.text();console.log("[AssetLoader] Received JS code, length:",n.length);let a=n.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 o=new Function("return "+r)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(o)),o}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:",n.substring(0,500)),{}}catch(t){return console.warn("[AssetLoader] Failed to load inline assets:",t),{}}})()}return ce=await mi,console.log("[AssetLoader] Final inline assets cache:",Object.keys(ce)),ce}function bi(i){return i===null||typeof i!="object"||(Object.freeze(i),Object.values(i).forEach(e=>bi(e))),i}function Va(i=64,e=64,t=16711680){let n=document.createElement("canvas");n.width=i,n.height=e;let a=n.getContext("2d");return a.fillStyle=`#${t.toString(16).padStart(6,"0")}`,a.fillRect(0,0,i,e),a.strokeStyle="#000",a.strokeRect(0,0,i,e),a.fillStyle="#fff",a.font="10px sans-serif",a.textAlign="center",a.fillText("MISSING",i/2,e/2),de.Texture.from(n)}function Dt(i,e){Rn.set(i,e)}var de,In,jn,Ie,M,re,Ae,ce,mi,Rn,Ce,$t=le(()=>{"use strict";de=require("pixi.js");fi();In=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",jn=Ba(),Ie=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,M=jn?"publish":In,re=Ie==null?void 0:Ie.assetsInlined;Ie!=null&&Ie.buildMode&&(M=Ie.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(i=>{i!=null&&i.buildMode&&i.buildMode!==M&&(M=i.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${M}`)),(i==null?void 0:i.assetsInlined)!==void 0&&(re=i.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${In}, Runtime: ${jn?"publish":"dev"}, Effective: ${M}`);ce={},mi=null;Rn=new Map;Ce=class{static async load(e,t,n,a){let r=`${e}:${t.path}`,o=ae.get(r);if(o!==void 0)return o;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 s=await qa(),l=s[e];if(!l&&a&&(l=s[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];s[p]&&(l=s[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=Rn.get(t.type);if(u)try{let c=await u(t.path,l,e,n);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=bi(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 n=M==="publish",a=n&&re!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${M}, isPublishMode: ${n}, 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 de.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 de.Assets.load(t)}catch(r){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",r),await de.Assets.load(e)}return await de.Assets.load(e)}static async loadJSON(e,t){let n=M==="publish",a=n&&re!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${M}, isPublishMode: ${n}, 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 o=atob(t.split(",")[1]);return JSON.parse(o)}return JSON.parse(t)}if(t){if(typeof t=="object"&&t!==null)return t;if(typeof t=="string"&&t.startsWith("data:")){let o=atob(t.split(",")[1]);return JSON.parse(o)}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,n){if(M==="dev"){let r=t==="image"?Va():bi({__placeholder:!0,type:t});return ae.set(e+":"+((n==null?void 0:n.path)||"missing"),r),r}throw n}};Dt("image",async(i,e)=>{let t=M==="publish",n=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"}`),n){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: ${i}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return de.Assets.load(e)}let o=i;return(a||r)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(o=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${o}"`))),de.Assets.load(e||o)});Dt("json",async(i,e)=>{let t=M==="publish",n=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"}`),n){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: ${i}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let o=i;if((a||r)&&i&&!i.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(o=i,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${i}" as-is`)):(o=`assets/${i}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${i}" -> "${o}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let s=await fetch(o);if(!s.ok)throw new Error(`JSON fetch failed: ${i}`);return s.json()})});function Ht(i,e){zn.init(i,e),typeof window!="undefined"&&(window.__AssetTextures=Te)}var yi,zn,Te,gt=le(()=>{"use strict";$t();yi=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(n=>{this.priorityReadyResolve=n}),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 o;console.log("[AssetTextures] Loading all assets...");let n=new Set(["background_loading_1"]),a=[],r=[];for(let[s,l]of e.objects.entries()){let d=(o=l.render)==null?void 0:o.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}: ${s} (${p})`);let g=await Ce.load(s,d,t,p);this.textures.set(s,g),console.log(`[AssetTextures] \u2713 Loaded: ${s}`)}catch(p){console.error(`[AssetTextures] \u2717 Failed to load: ${s}`,p)}finally{this.attempted.add(s);try{for(let p of Array.from(this.waiters))p()}catch{}}};n.has(s)?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(s=>typeof s=="string"&&s))).filter(s=>{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,s);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(s=>this.textures.has(s)||this.attempted.has(s));if(r())return;let o=typeof t.timeoutMs=="number"?t.timeoutMs:15e3;await new Promise(s=>{let l=!1,d=()=>{l||r()&&(l=!0,this.waiters.delete(d),s())};this.waiters.add(d),d(),o>0&&setTimeout(()=>{l||(l=!0,this.waiters.delete(d),console.warn("[AssetTextures] waitFor timed out; continuing",{ids:a}),s())},o)})}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())}},zn=new yi,Te=new Proxy(zn,{get(i,e){return e in i&&typeof i[e]=="function"?i[e].bind(i):i.get(e)},set(i,e,t){return i.set(e,t),!0}})});var Hn={};Vi(Hn,{AssetEditorModal:()=>Si});var Si,Ai=le(()=>{"use strict";Si=class{constructor(){this.modal=null;this.currentObjectId=null;this.currentPath=null;this.currentAsset="";this.onApplyCallback=null}show(e,t,n,a){this.currentObjectId=e,this.currentPath=t,this.currentAsset=n,this.onApplyCallback=a,this.createModal(e,n),document.body.appendChild(this.modal),this.attachModalListeners()}createModal(e,t){let n=document.createElement("div");n.className="asset-editor-modal",n.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=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(o=>{o.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(o=>{o.addEventListener("click",s=>{let c=s.target.dataset.tab;c&&this.switchTab(c)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.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",o=>{o.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 n="";e==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",n,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 Hr={};Vi(Hr,{AssetCache:()=>Q,AssetLoader:()=>he,AssetSystem:()=>It,AssetTextures:()=>fe,Assets:()=>pa,BaseSystem:()=>He,GameEngine:()=>Ot,GameObject:()=>st,GameObjectManager:()=>De,ObjectFactory:()=>me,Renderer:()=>ot,RuntimeObjectRegistry:()=>Ne,Transform:()=>rt,applyScreenAnchor:()=>zt,basePixi:()=>sa,clearResponsiveElements:()=>ga,createPixiBase:()=>_t,getRegisteredFontIds:()=>na,globalResponsiveMultipliers:()=>ct,initAssetTextures:()=>St,initAssets:()=>ua,layout:()=>fa,playLottieOverlay:()=>ra,registerFont:()=>ia,registerType:()=>xt,resolveAnchorVec2:()=>Ce,resolveFont:()=>ea,resolveFontWeight:()=>ta,resolveScreenAnchorPoint:()=>Fe,resolveScreenRatioPoint:()=>Be,runInitSequence:()=>ma,setLottieInstance:()=>At,spawnSceneFromConfig:()=>ca,updateScreenState:()=>Rt});module.exports=Ea(Hr);var Qn=require("pixi.js");var pe={};function mt(i,e,t=!1){pe[i]||(pe[i]=[]),pe[i].push({fn:e,once:t})}function Gt(i,e){if(pe[i]){if(!e){delete pe[i];return}pe[i]=pe[i].filter(t=>t.fn!==e)}}function bt(i,...e){let t=pe[i];if(t)for(let n of[...t])n.fn(...e),n.once&&Gt(i,n.fn)}function q(i,e){mt(i,e,!0)}var z=null,Y=[],Te=null;function Xi(i){z=i,Y=[],Te!==null&&(clearTimeout(Te),Te=null)}function Ji(){var i,e,t;return{endpoint:(z==null?void 0:z.endpoint)||"",transport:(z==null?void 0:z.transport)||"beacon",batchSize:(i=z==null?void 0:z.batchSize)!=null?i:10,flushIntervalMs:(e=z==null?void 0:z.flushIntervalMs)!=null?e:300,maxQueue:(t=z==null?void 0:z.maxQueue)!=null?t:200,debug:!!(z!=null&&z.debug)}}async function Yi(i,e,t,n){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(i,new Blob([a],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",e)}catch(r){n&&console.warn("[handler.telemetry] fetch failed",r)}}function qt(i,e){let t=Ji();if(e&&t.endpoint){if(Y.push(i),Y.length>t.maxQueue&&(Y=Y.slice(Y.length-t.maxQueue)),Y.length>=t.batchSize){Ki();return}Te===null&&(Te=window.setTimeout(()=>{Te=null,Ki()},t.flushIntervalMs))}}async function Ki(){let i=Ji();if(!i.endpoint||Y.length===0)return;let e=Y.splice(0,i.batchSize);await Yi(i.endpoint,{events:e},i.transport,i.debug),Y.length>0&&await Yi(i.endpoint,{events:Y.splice(0,i.batchSize)},i.transport,i.debug)}function Zi(i){return Math.max(0,Math.min(1,i))}function Sa(i){let e=String(i!=null?i:"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.]+)\)/),n=t?Number(t[1]):1.8;return a=>1+(n+1)*Math.pow(a-1,3)+n*Math.pow(a-1,2)}return t=>1-(1-t)*(1-t)}function Ke(){return typeof performance!="undefined"&&performance.now?performance.now():Date.now()}function Aa(i,e){let t=i==null?void 0:i[e];return typeof t=="number"?t:0}function Qi(i,e,t){try{i[e]=t}catch{}}function Ca(i){let e=i==null?void 0:i.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,n=typeof e.y=="number"?e.y:1;return{x:t,y:n}}function en(i,e){let t=i==null?void 0:i.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 tn(i,e){let t=Ca(i);if(!t)return{from:null,to:null};let n=null,a=null;return typeof e.scale=="number"?(n=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(n=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(n=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),n===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:n!=null?n:t.x,y:a!=null?a:t.y}}}function nn(){let i=new Set,e=new WeakMap,t=null,n=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,s(),i.size>0&&n()})},a=u=>{var p;i.add(u);let l=(p=e.get(u.target))!=null?p:new Set;l.add(u),e.set(u.target,l),n()},r=u=>{i.delete(u);let l=e.get(u.target);l&&(l.delete(u),l.size===0&&e.delete(u.target))},o=u=>{u.killed||(u.killed=!0,r(u))},s=()=>{var l,p;let u=Ke();for(let g of Array.from(i)){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,S=Zi(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;S=Zi(y)}let w=g.ease(S);g.yoyo&&h%2===1&&(w=1-w);for(let y of g.props)Qi(g.target,y.key,y.from+(y.to-y.from)*w);g.scaleFrom&&g.scaleTo&&en(g.target,{x:g.scaleFrom.x+(g.scaleTo.x-g.scaleFrom.x)*w,y:g.scaleFrom.y+(g.scaleTo.y-g.scaleFrom.y)*w});try{(l=g.onUpdate)==null||l.call(g)}catch{}if(f>=b){o(g);try{(p=g.onComplete)==null||p.call(g)}catch{}}}},d=(u,l,p)=>{var y;let g=Math.max(0,(typeof l.duration=="number"?l.duration:.5)*1e3),m=Math.max(0,(typeof l.delay=="number"?l.delay:0)*1e3+((y=p==null?void 0:p.delayMsOverride)!=null?y:0)),f=Sa(l.ease),S=typeof l.repeat=="number"?Math.max(0,l.repeat|0):0,b=l.yoyo===!0,h=new Set(["duration","delay","ease","repeat","yoyo","onUpdate","onComplete","scale","scaleX","scaleY"]),w=[];for(let I of Object.keys(l)){if(h.has(I))continue;let R=l[I];typeof R=="number"&&w.push({key:I,from:Aa(u,I),to:R})}let x=tn(u,l);return{target:u,startMs:Ke(),delayMs:m,durationMs:g,ease:f,props:w,scaleFrom:x.from,scaleTo:x.to,repeat:S,yoyo:b,onUpdate:typeof l.onUpdate=="function"?l.onUpdate:void 0,onComplete:typeof l.onComplete=="function"?l.onComplete:void 0,killed:!1,paused:!1,pauseAtMs:null}},c={to(u,l){let p=d(u,l);return a(p),{kill:()=>o(p),pause:()=>{p.paused||(p.paused=!0,p.pauseAtMs=Ke())},resume:()=>{var f;if(!p.paused)return;let g=(f=p.pauseAtMs)!=null?f:Ke(),m=Ke()-g;p.startMs+=m,p.paused=!1,p.pauseAtMs=null},isActive:()=>!p.killed&&!p.paused}},fromTo(u,l,p){return c.set(u,l),c.to(u,p)},set(u,l){if(!u||!l)return;for(let g of Object.keys(l)){let m=l[g];g==="scale"||g==="scaleX"||g==="scaleY"||typeof m=="number"&&Qi(u,g,m)}let p=tn(u,l);p.to&&en(u,p.to)},killTweensOf(u){let l=e.get(u);if(l)for(let p of Array.from(l))o(p)},timeline(u={}){let l=[],p=0,g=!1,m=[],f=h=>{if(typeof h=="number")return Math.max(0,h*1e3);let w=typeof h=="string"?h.trim():"";return w.startsWith("+=")?p+Math.max(0,Number(w.slice(2))*1e3||0):w?Math.max(0,Number(w)*1e3||0):p},S=h=>{l.push(h);let w=Math.max(0,(typeof h.vars.duration=="number"?h.vars.duration:.5)*1e3);p=Math.max(p,h.atMs+w)},b={to(h,w,x){return S({kind:"to",target:h,vars:w,atMs:f(x)}),b},fromTo(h,w,x,y){return S({kind:"fromTo",target:h,vars:x,from:w,atMs:f(y)}),b},play(){var h,w;if(g)return b;g=!0,m=[];for(let x of l)x.kind==="fromTo"&&c.set(x.target,(h=x.from)!=null?h:{}),m.push(c.to(x.target,{...x.vars,delay:x.atMs/1e3+((w=x.vars.delay)!=null?w: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 c}function an(){if(typeof window=="undefined")return;let i=window;if(!i.gsap)try{i.gsap=nn()}catch{}}var rn={name:"handler-playable-sdk",version:"0.5.26",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 V=0,La=V++,on=V++,sn=V++,ln=V++,cn=V++,dn=V++,pn=V++,un=V++,gn=V++,hn=V++,fn=V++,mn=V++,M=La;function bn(){return M===on}function yn(){return M===sn}function vn(){return M===ln}function wn(){return M===cn}function Le(){return M===dn}function ke(){return M===pn}function xn(){return M===un}function En(){return M===gn}function Sn(){return M===hn}function Vt(){return M===fn}function Wt(){return M===mn}function An(){let i=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(i==="mraid")try{mraid.getState(),M=on;return}catch{}else if(i==="dapi")try{dapi.isReady(),M=sn;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(M=ln)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(M=cn)}catch{}else if(e==="mintegral")window.gameReady&&(M=dn);else if(e==="tapjoy")window.TJ_API&&(M=pn);else if(e==="tiktok")window.openAppStore&&(M=un);else if(e==="smadex")try{window.smxTracking&&(M=gn)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(M=hn)}catch{}else e==="vungle"?M=fn:(i==="nucleo"||e==="nucleo")&&(M=mn)}var yt=ft(require("lottie-web"),1),Cn=yt.default;typeof window!="undefined"&&(window.lottie=yt.default,window.__baseLottie=yt.default);Xt();function D(i,e){let t=(a,r)=>r===0?a:t(r,a%r),n=t(i,e);return`${i/n}:${e/n}`}var vo=[{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)}],wo=[{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)}],xo=[{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)}],Pn=[{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 Eo=[...Pn];var Ra=Pn[0];ue();var Fa=ft(require("jszip"),1);function $a(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Ha(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}async function Na(i){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=i})}async function Jt(i){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",i);let n=await fetch(i);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,i),null;let a=await n.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let r=await $a(a),o=await Na(r),s=Ha(r);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",s.mimeType),{base64:s.base64,mimeType:s.mimeType,dataUrl:r,width:(e=o==null?void 0:o.width)!=null?e:0,height:(t=o==null?void 0:o.height)!=null?t:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function vt(i,e=30){try{console.log("[ImageUtils] Removing background color...");let t=await new Promise((l,p)=>{let g=new Image;g.onload=()=>l(g),g.onerror=()=>p(new Error("Failed to load image")),g.src=i}),n=document.createElement("canvas");n.width=t.width,n.height=t.height;let a=n.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),i;a.drawImage(t,0,0);let r=a.getImageData(0,0,n.width,n.height),o=r.data,d=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(l=>({r:o[l.offset],g:o[l.offset+1],b:o[l.offset+2]})),c=0;for(let l=0;l<o.length;l+=4){let p=o[l],g=o[l+1],m=o[l+2],f=!1;for(let S of d)if(Math.sqrt(Math.pow(p-S.r,2)+Math.pow(g-S.g,2)+Math.pow(m-S.b,2))<e){f=!0;break}f&&(o[l+3]=0,c++)}return console.log(`[ImageUtils] Removed background from ${c} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),n.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),i}}var _n=require("@google/genai");async function Zt(i,e,t=[],n={}){var a,r,o,s,d,c,u;try{if(!(i!=null&&i.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 l=new _n.GoogleGenAI({apiKey:i}),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 l.models.generateContent({model:p,contents:g}),f="",S=(o=(r=(a=m.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:o.parts;if(S)for(let b of S)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(l){throw console.error("[Gemini] API error:",l),(s=l.message)!=null&&s.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."):(d=l.message)!=null&&d.includes("API_KEY_INVALID")?new Error("Invalid Gemini API key. Please check your API key configuration."):(c=l.message)!=null&&c.includes("QUOTA_EXCEEDED")?new Error("Gemini API quota exceeded. Please try again later or check your billing."):(u=l.message)!=null&&u.includes("SAFETY")?new Error("Content was flagged by Gemini safety filters. Please try with different images."):l}}var Mn=require("@google/genai");async function wt(i,e,t=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new Mn.GoogleGenAI({apiKey:i}),r=[{text:e}];t.length>0&&t.forEach((s,d)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${d}`),r.push({inlineData:{mimeType:s.mimeType,data:s.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let s of o.candidates[0].content.parts)if(s.text)console.log(s.text);else if(s.inlineData){let d=s.inlineData.data,c=s.inlineData.mimeType||"image/png";return console.info("[GEMINI-REAL-SDK] Found inline image data in response"),`data:${c};base64,${d}`}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");Xe();ue();var Dn=require("pixi.js");var Ya=require("pixi.js");ue();function tr(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function ir(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}function nr(i){return`
|
|
46
|
+
`,this.modal=n}attachModalListeners(){if(!this.modal)return;this.modal.querySelectorAll("[data-modal-close]").forEach(o=>{o.addEventListener("click",()=>this.close())}),this.modal.querySelectorAll("[data-tab]").forEach(o=>{o.addEventListener("click",s=>{let d=s.target.dataset.tab;d&&this.switchTab(d)})});let n=this.modal.querySelector("[data-ai-generate]");n==null||n.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",o=>{o.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 n="";e==="edit"&&this.currentAsset?n=`Edit this image: ${this.currentObjectId}`:n=`Create an image for: ${this.currentObjectId}`,t(this.currentObjectId||"unknown",n,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 Hr={};Vi(Hr,{AssetCache:()=>ae,AssetLoader:()=>Ce,AssetSystem:()=>Kt,AssetTextures:()=>Te,Assets:()=>pa,BaseSystem:()=>Ze,GameEngine:()=>Yt,GameObject:()=>At,GameObjectManager:()=>Xe,ObjectFactory:()=>Le,Renderer:()=>St,RuntimeObjectRegistry:()=>Qe,Transform:()=>Et,applyScreenAnchor:()=>Zt,basePixi:()=>sa,clearResponsiveElements:()=>ga,createPixiBase:()=>Vt,getRegisteredFontIds:()=>na,globalResponsiveMultipliers:()=>Tt,initAssetTextures:()=>Ht,initAssets:()=>ua,layout:()=>fa,playLottieOverlay:()=>ra,registerFont:()=>ia,registerType:()=>Dt,resolveAnchorVec2:()=>De,resolveFont:()=>ea,resolveFontWeight:()=>ta,resolveScreenAnchorPoint:()=>et,resolveScreenRatioPoint:()=>tt,runInitSequence:()=>ma,setLottieInstance:()=>Nt,spawnSceneFromConfig:()=>ca,updateScreenState:()=>Jt});module.exports=Ea(Hr);var Qn=require("pixi.js");var Ee={};function Ot(i,e,t=!1){Ee[i]||(Ee[i]=[]),Ee[i].push({fn:e,once:t})}function oi(i,e){if(Ee[i]){if(!e){delete Ee[i];return}Ee[i]=Ee[i].filter(t=>t.fn!==e)}}function It(i,...e){let t=Ee[i];if(t)for(let n of[...t])n.fn(...e),n.once&&oi(i,n.fn)}function J(i,e){Ot(i,e,!0)}var D=null,ee=[],He=null;function Xi(i){D=i,ee=[],He!==null&&(clearTimeout(He),He=null)}function Ji(){var i,e,t;return{endpoint:(D==null?void 0:D.endpoint)||"",transport:(D==null?void 0:D.transport)||"beacon",batchSize:(i=D==null?void 0:D.batchSize)!=null?i:10,flushIntervalMs:(e=D==null?void 0:D.flushIntervalMs)!=null?e:300,maxQueue:(t=D==null?void 0:D.maxQueue)!=null?t:200,debug:!!(D!=null&&D.debug)}}async function Yi(i,e,t,n){let a=JSON.stringify(e);if(t==="beacon"&&typeof navigator!="undefined"&&typeof navigator.sendBeacon=="function")try{let r=navigator.sendBeacon(i,new Blob([a],{type:"application/json"}));n&&console.log("[handler.telemetry] beacon",r,e);return}catch(r){n&&console.warn("[handler.telemetry] beacon failed, fallback to fetch",r)}try{await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:a,keepalive:!0}),n&&console.log("[handler.telemetry] fetch",e)}catch(r){n&&console.warn("[handler.telemetry] fetch failed",r)}}function si(i,e){let t=Ji();if(e&&t.endpoint){if(ee.push(i),ee.length>t.maxQueue&&(ee=ee.slice(ee.length-t.maxQueue)),ee.length>=t.batchSize){Ki();return}He===null&&(He=window.setTimeout(()=>{He=null,Ki()},t.flushIntervalMs))}}async function Ki(){let i=Ji();if(!i.endpoint||ee.length===0)return;let e=ee.splice(0,i.batchSize);await Yi(i.endpoint,{events:e},i.transport,i.debug),ee.length>0&&await Yi(i.endpoint,{events:ee.splice(0,i.batchSize)},i.transport,i.debug)}function Zi(i){return Math.max(0,Math.min(1,i))}function Sa(i){let e=String(i!=null?i:"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.]+)\)/),n=t?Number(t[1]):1.8;return a=>1+(n+1)*Math.pow(a-1,3)+n*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 Aa(i,e){let t=i==null?void 0:i[e];return typeof t=="number"?t:0}function Qi(i,e,t){try{i[e]=t}catch{}}function Ca(i){let e=i==null?void 0:i.scale;if(!e)return null;let t=typeof e.x=="number"?e.x:1,n=typeof e.y=="number"?e.y:1;return{x:t,y:n}}function en(i,e){let t=i==null?void 0:i.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 tn(i,e){let t=Ca(i);if(!t)return{from:null,to:null};let n=null,a=null;return typeof e.scale=="number"?(n=e.scale,a=e.scale):e.scale&&typeof e.scale=="object"&&(typeof e.scale.x=="number"&&(n=e.scale.x),typeof e.scale.y=="number"&&(a=e.scale.y)),typeof e.scaleX=="number"&&(n=e.scaleX),typeof e.scaleY=="number"&&(a=e.scaleY),n===null&&a===null?{from:null,to:null}:{from:{x:t.x,y:t.y},to:{x:n!=null?n:t.x,y:a!=null?a:t.y}}}function nn(){let i=new Set,e=new WeakMap,t=null,n=()=>{if(t!=null)return;t=requestAnimationFrame(()=>{t=null,s(),i.size>0&&n()})},a=u=>{var p;i.add(u);let c=(p=e.get(u.target))!=null?p:new Set;c.add(u),e.set(u.target,c),n()},r=u=>{i.delete(u);let c=e.get(u.target);c&&(c.delete(u),c.size===0&&e.delete(u.target))},o=u=>{u.killed||(u.killed=!0,r(u))},s=()=>{var c,p;let u=ut();for(let g of Array.from(i)){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=Zi(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=Zi(y)}let v=g.ease(A);g.yoyo&&h%2===1&&(v=1-v);for(let y of g.props)Qi(g.target,y.key,y.from+(y.to-y.from)*v);g.scaleFrom&&g.scaleTo&&en(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){o(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=Sa(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 P of Object.keys(c)){if(h.has(P))continue;let _=c[P];typeof _=="number"&&v.push({key:P,from:Aa(u,P),to:_})}let w=tn(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:()=>o(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"&&Qi(u,g,m)}let p=tn(u,c);p.to&&en(u,p.to)},killTweensOf(u){let c=e.get(u);if(c)for(let p of Array.from(c))o(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 an(){if(typeof window=="undefined")return;let i=window;if(!i.gsap)try{i.gsap=nn()}catch{}}var rn={name:"handler-playable-sdk",version:"0.5.28",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,La=Z++,on=Z++,sn=Z++,ln=Z++,cn=Z++,dn=Z++,pn=Z++,un=Z++,gn=Z++,hn=Z++,fn=Z++,mn=Z++,I=La;function bn(){return I===on}function yn(){return I===sn}function vn(){return I===ln}function wn(){return I===cn}function Ne(){return I===dn}function Fe(){return I===pn}function xn(){return I===un}function En(){return I===gn}function Sn(){return I===hn}function li(){return I===fn}function ci(){return I===mn}function An(){let i=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(i==="mraid")try{mraid.getState(),I=on;return}catch{}else if(i==="dapi")try{dapi.isReady(),I=sn;return}catch{}if(e==="facebook")try{typeof FbPlayableAd!="undefined"&&(I=ln)}catch{}else if(e==="google")try{typeof ExitApi!="undefined"&&(I=cn)}catch{}else if(e==="mintegral")window.gameReady&&(I=dn);else if(e==="tapjoy")window.TJ_API&&(I=pn);else if(e==="tiktok")window.openAppStore&&(I=un);else if(e==="smadex")try{window.smxTracking&&(I=gn)}catch{}else if(e==="snapchat")try{window.ScPlayableAd&&(I=hn)}catch{}else e==="vungle"?I=fn:(i==="nucleo"||e==="nucleo")&&(I=mn)}var jt=_t(require("lottie-web"),1),Cn=jt.default;typeof window!="undefined"&&(window.lottie=jt.default,window.__baseLottie=jt.default);ui();function $(i,e){let t=(a,r)=>r===0?a:t(r,a%r),n=t(i,e);return`${i/n}:${e/n}`}var vo=[{id:"iphone-15-pro-max",label:"iPhone 15 Pro Max",width:430,height:932,category:"iphone",ratio:$(430,932)},{id:"iphone-15-pro",label:"iPhone 15 Pro",width:393,height:852,category:"iphone",ratio:$(393,852)},{id:"iphone-15",label:"iPhone 15",width:393,height:852,category:"iphone",ratio:$(393,852)},{id:"iphone-14",label:"iPhone 14",width:390,height:844,category:"iphone",ratio:$(390,844)},{id:"iphone-se",label:"iPhone SE",width:375,height:667,category:"iphone",ratio:$(375,667)},{id:"iphone-12-mini",label:"iPhone 12 Mini",width:360,height:780,category:"iphone",ratio:$(360,780)}],wo=[{id:"pixel-8-pro",label:"Pixel 8 Pro",width:448,height:998,category:"android",ratio:$(448,998)},{id:"pixel-8",label:"Pixel 8",width:412,height:915,category:"android",ratio:$(412,915)},{id:"samsung-s24-ultra",label:"Samsung S24 Ultra",width:412,height:915,category:"android",ratio:$(412,915)},{id:"samsung-s24",label:"Samsung S24",width:360,height:780,category:"android",ratio:$(360,780)},{id:"samsung-a54",label:"Samsung A54",width:412,height:915,category:"android",ratio:$(412,915)},{id:"oneplus-12",label:"OnePlus 12",width:412,height:915,category:"android",ratio:$(412,915)}],xo=[{id:"ipad-pro-12",label:'iPad Pro 12.9"',width:1024,height:1366,category:"tablet",ratio:$(1024,1366)},{id:"ipad-pro-11",label:'iPad Pro 11"',width:834,height:1194,category:"tablet",ratio:$(834,1194)},{id:"ipad-air",label:"iPad Air",width:820,height:1180,category:"tablet",ratio:$(820,1180)},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"tablet",ratio:$(768,1024)},{id:"samsung-tab-s9",label:"Samsung Tab S9",width:800,height:1280,category:"tablet",ratio:$(800,1280)}],Pn=[{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:$(390,844),mraidScale:.7},{id:"ipad-mini",label:"iPad Mini",width:768,height:1024,category:"playable",ratio:$(768,1024),mraidScale:.7}];var Eo=[...Pn];var Ra=Pn[0];Se();var Fa=_t(require("jszip"),1);function $a(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function Ha(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}async function Na(i){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=i})}async function gi(i){var e,t;try{console.log("[ImageUtils] Fetching image data from URL:",i);let n=await fetch(i);if(!n.ok)return console.warn("[ImageUtils] Fetch failed with status:",n.status,i),null;let a=await n.blob();console.log("[ImageUtils] Blob received, size:",a.size,"type:",a.type);let r=await $a(a),o=await Na(r),s=Ha(r);return console.log("[ImageUtils] Success resolution:",o==null?void 0:o.width,"x",o==null?void 0:o.height,"mime:",s.mimeType),{base64:s.base64,mimeType:s.mimeType,dataUrl:r,width:(e=o==null?void 0:o.width)!=null?e:0,height:(t=o==null?void 0:o.height)!=null?t:0}}catch(n){return console.error("[ImageUtils] Error fetching image data:",n),null}}async function Rt(i,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=i}),n=document.createElement("canvas");n.width=t.width,n.height=t.height;let a=n.getContext("2d");if(!a)return console.error("[ImageUtils] Failed to get canvas context"),i;a.drawImage(t,0,0);let r=a.getImageData(0,0,n.width,n.height),o=r.data,l=[{name:"top-left",offset:0},{name:"top-right",offset:(n.width-1)*4},{name:"bottom-left",offset:(n.height-1)*n.width*4},{name:"bottom-right",offset:((n.height-1)*n.width+(n.width-1))*4}].map(c=>({r:o[c.offset],g:o[c.offset+1],b:o[c.offset+2]})),d=0;for(let c=0;c<o.length;c+=4){let p=o[c],g=o[c+1],m=o[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&&(o[c+3]=0,d++)}return console.log(`[ImageUtils] Removed background from ${d} pixels (4-corner sampling, tolerance: ${e})`),a.putImageData(r,0,0),n.toDataURL("image/png")}catch(t){return console.error("[ImageUtils] Error removing background:",t),i}}var Mn=require("@google/genai");async function hi(i,e,t=[],n={}){var a,r,o,s,l,d,u;try{if(!(i!=null&&i.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 Mn.GoogleGenAI({apiKey:i}),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=(o=(r=(a=m.candidates)==null?void 0:a[0])==null?void 0:r.content)==null?void 0:o.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),(s=c.message)!=null&&s.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 _n=require("@google/genai");async function zt(i,e,t=[],n={}){try{console.info("[GEMINI-REAL-SDK] Initializing GoogleGenAI...");let a=new _n.GoogleGenAI({apiKey:i}),r=[{text:e}];t.length>0&&t.forEach((s,l)=>{console.info(`[GEMINI-REAL-SDK] Adding image part ${l}`),r.push({inlineData:{mimeType:s.mimeType,data:s.base64}})}),console.info("[GEMINI-REAL-SDK] Calling generateContent with model: gemini-2.5-flash-image");let o=await a.models.generateContent({model:"gemini-2.5-flash-image",contents:r});if(console.info("[GEMINI-REAL-SDK] Received response from model"),!o.candidates||!o.candidates[0]||!o.candidates[0].content||!o.candidates[0].content.parts)throw new Error("Gemini 2.5 Flash Image returned invalid response structure.");for(let s of o.candidates[0].content.parts)if(s.text)console.log(s.text);else if(s.inlineData){let l=s.inlineData.data,d=s.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();Se();var Dn=require("pixi.js");var Ya=require("pixi.js");Se();function tr(i){return new Promise((e,t)=>{let n=new FileReader;n.onerror=()=>t(new Error("FileReader failed")),n.onload=()=>e(String(n.result||"")),n.readAsDataURL(i)})}function ir(i){var a;let[e,t]=i.split(","),n=e==null?void 0:e.match(/data:(.*?);base64/);return{base64:t!=null?t:"",mimeType:(a=n==null?void 0:n[1])!=null?a:"image/png"}}function nr(i){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:
|
|
@@ -60,9 +60,9 @@ Palette: [#RRGGBB, #RRGGBB, ...]
|
|
|
60
60
|
${i?`
|
|
61
61
|
ADDITIONAL RULES/NOTES:
|
|
62
62
|
${i}`:""}
|
|
63
|
-
`.trim()}function $n(){let i=[],e="",t=null;return{async addSources(n){let a=[];for(let r of n){let o=await tr(r),s=ir(o),
|
|
64
|
-
`);for(let p of
|
|
65
|
-
Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:
|
|
63
|
+
`.trim()}function $n(){let i=[],e="",t=null;return{async addSources(n){let a=[];for(let r of n){let o=await tr(r),s=ir(o),l={id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,name:r.name,base64:s.base64,mimeType:s.mimeType,dataUrl:o};i.push(l),a.push(l)}return a},getSources(){return i.slice()},async analyze(n,a,r){if(i.length===0)throw new Error("No screenshots to analyze.");let o=nr(a),s=i.map(p=>({base64:p.base64,mimeType:p.mimeType})),l=await hi(n,o,s,{model:r}),d=e,u=[],c=l.split(`
|
|
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(n){e=n,t&&(t={...t,summary:n})},getResult(){return t}}}var je="handler_api_key_";var Be=class{static setKey(e,t,n){try{let a={key:this.encryptKey(t),created:Date.now(),lastUsed:Date.now(),label:n||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}`,n=localStorage.getItem(t);if(!n)return null;let a=JSON.parse(n);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 n=localStorage.key(t);if(n&&n.startsWith(je)){let a=n.substring(je.length),r=localStorage.getItem(n);if(r){let o=JSON.parse(r);e.push({service:a,label:o.label,created:o.created,lastUsed:o.lastUsed})}}}}catch(t){console.error("[ApiKeyStorage] Failed to get stored services:",t)}return e.sort((t,n)=>n.lastUsed-t.lastUsed)}static clearAll(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&n.startsWith(je)&&e.push(n)}e.forEach(t=>localStorage.removeItem(t))}catch(e){console.error("[ApiKeyStorage] Failed to clear API keys:",e)}}static encryptKey(e){try{let n="handler_preview_salt_2024"+e;return btoa(n)}catch(t){return console.warn("[ApiKeyStorage] Encryption failed, storing as-is:",t),e}}static decryptKey(e){try{let t=atob(e),n="handler_preview_salt_2024";return t.startsWith(n)?t.substring(n.length):t}catch(t){return console.warn("[ApiKeyStorage] Decryption failed, returning as-is:",t),e}}},vi=()=>Be.getKey("gemini"),wi=(i,e)=>Be.setKey("gemini",i,e),ar=()=>Be.hasKey("gemini");window.ApiKeyStorage=Be;window.getGeminiApiKey=vi;window.setGeminiApiKey=wi;window.hasGeminiApiKey=ar;var Ei=class{constructor(){this.modal=null;this.options=null;this.analyzer=$n();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,n;(t=this.promptInput)==null||t.focus(),(n=this.promptInput)==null||n.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">
|
|
@@ -143,12 +143,12 @@ Palette:`)[0].replace(/^Summary:\s*/i,"").trim()),t={summary:c,palette:u.slice(0
|
|
|
143
143
|
</div>
|
|
144
144
|
`,this.modal=e,this.attachEventListeners(),this.updatePromptFromDna()}attachEventListeners(){var n;if(!this.modal)return;this.promptInput=this.modal.querySelector(".ai-textarea"),this.generateBtn=this.modal.querySelector('[data-action="generate"]'),this.loadingEl=this.modal.querySelector("[data-loading]"),this.galleryEl=this.modal.querySelector("[data-gallery]"),this.previewEl=this.modal.querySelector("[data-preview]"),(n=this.promptInput)==null||n.addEventListener("input",()=>{var a;this.currentPrompt=((a=this.promptInput)==null?void 0:a.value)||"",this.updateGenerateButton()});let e=this.modal.querySelector('[data-strength="creativity"]'),t=this.modal.querySelector(".ai-strength-value");e==null||e.addEventListener("input",()=>{t.textContent=e.value}),this.modal.addEventListener("click",a=>{var s;let r=a.target;switch(r.dataset.action||((s=r.closest("[data-action]"))==null?void 0:s.getAttribute("data-action"))){case"generate":this.generateImage();break;case"apply":this.applySelectedImage();break;case"gallery":this.toggleGallery();break;case"close":case"cancel":this.close();break}}),this.modal.addEventListener("click",a=>{let r=a.target;if(r.classList.contains("ai-gallery-item")||r.closest(".ai-gallery-item")){let o=r.closest(".ai-gallery-item"),s=parseInt(o.dataset.index||"-1");s>=0&&this.selectImage(s)}}),this.modal.addEventListener("click",a=>{a.target===this.modal&&this.close()}),this.updateGenerateButton()}updateGenerateButton(){if(!this.generateBtn)return;let e=this.currentPrompt.trim().length>0;this.generateBtn.disabled=!e||this.isGenerating}async updatePromptFromDna(){var t;let e=(t=this.modal)==null?void 0:t.querySelector("#ai-use-dna");if(e!=null&&e.checked)try{let n=this.analyzer.getResult();if(n!=null&&n.summary&&this.promptInput){let a=`${this.currentPrompt}
|
|
145
145
|
|
|
146
|
-
Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}catch(n){console.warn("[AiEditorModal] Failed to apply brand DNA:",n)}}async generateImage(){var e,t,n,a;if(!(!this.options||this.isGenerating)){this.isGenerating=!0,this.updateGenerateButton(),(e=this.loadingEl)==null||e.classList.remove("hidden"),(t=this.previewEl)==null||t.classList.add("hidden");try{let r=this.getApiKey();if(!r){alert("Please set your Gemini API key first. You can do this in the AI Creative Suite panel.");return}let o=[];if(this.options.currentValue&&this.options.currentValue.startsWith("data:"))try{let
|
|
146
|
+
Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}catch(n){console.warn("[AiEditorModal] Failed to apply brand DNA:",n)}}async generateImage(){var e,t,n,a;if(!(!this.options||this.isGenerating)){this.isGenerating=!0,this.updateGenerateButton(),(e=this.loadingEl)==null||e.classList.remove("hidden"),(t=this.previewEl)==null||t.classList.add("hidden");try{let r=this.getApiKey();if(!r){alert("Please set your Gemini API key first. You can do this in the AI Creative Suite panel.");return}let o=[];if(this.options.currentValue&&this.options.currentValue.startsWith("data:"))try{let d=await gi(this.options.currentValue);d&&(o=[{base64:d.base64,mimeType:d.mimeType}])}catch(d){console.warn("[AiEditorModal] Failed to load current image:",d)}let s=await zt(r,this.currentPrompt,o,{aspectRatio:"1:1"}),l=await Rt(s);this.generatedImages.push(l||s),this.selectedImageIndex=this.generatedImages.length-1,this.updateGallery(),this.updatePreview(),this.updateApplyButton()}catch(r){console.error("[AiEditorModal] Generation failed:",r),alert(`Generation failed: ${r instanceof Error?r.message:"Unknown error"}`)}finally{this.isGenerating=!1,(n=this.loadingEl)==null||n.classList.add("hidden"),(a=this.previewEl)==null||a.classList.remove("hidden"),this.updateGenerateButton()}}}updateGallery(){if(!this.galleryEl)return;let e=this.galleryEl.querySelector("[data-gallery-grid]");e&&(e.innerHTML=this.generatedImages.map((t,n)=>`
|
|
147
147
|
<div class="ai-gallery-item ${n===this.selectedImageIndex?"active":""}" data-index="${n}">
|
|
148
148
|
<img class="ai-gallery-thumb" src="${t}" alt="Generated ${n+1}" />
|
|
149
149
|
<div class="ai-gallery-label">#${n+1}</div>
|
|
150
150
|
</div>
|
|
151
|
-
`).join(""))}updatePreview(){if(!this.previewEl||this.selectedImageIndex<0)return;let e=this.generatedImages[this.selectedImageIndex];this.previewEl.innerHTML=`<img src="${e}" alt="Selected image" />`}selectImage(e){e<0||e>=this.generatedImages.length||(this.selectedImageIndex=e,this.updateGallery(),this.updatePreview(),this.updateApplyButton())}toggleGallery(){this.galleryEl&&this.galleryEl.classList.toggle("hidden")}updateApplyButton(){var t;let e=(t=this.modal)==null?void 0:t.querySelector('[data-action="apply"]');e&&(e.disabled=this.selectedImageIndex<0)}applySelectedImage(){var t;if(this.selectedImageIndex<0||!((t=this.options)!=null&&t.onApply))return;let e=this.generatedImages[this.selectedImageIndex];this.options.onApply(e),this.close()}getApiKey(){let e=
|
|
151
|
+
`).join(""))}updatePreview(){if(!this.previewEl||this.selectedImageIndex<0)return;let e=this.generatedImages[this.selectedImageIndex];this.previewEl.innerHTML=`<img src="${e}" alt="Selected image" />`}selectImage(e){e<0||e>=this.generatedImages.length||(this.selectedImageIndex=e,this.updateGallery(),this.updatePreview(),this.updateApplyButton())}toggleGallery(){this.galleryEl&&this.galleryEl.classList.toggle("hidden")}updateApplyButton(){var t;let e=(t=this.modal)==null?void 0:t.querySelector('[data-action="apply"]');e&&(e.disabled=this.selectedImageIndex<0)}applySelectedImage(){var t;if(this.selectedImageIndex<0||!((t=this.options)!=null&&t.onApply))return;let e=this.generatedImages[this.selectedImageIndex];this.options.onApply(e),this.close()}getApiKey(){let e=vi();if(e)return e;try{let t=this.analyzer.getResult();if(t&&t.apiKey)return wi(t.apiKey,"From Brand DNA"),t.apiKey}catch(t){console.warn("[AiEditorModal] Failed to get API key from brand DNA:",t)}return null}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.options=null}},xi=null;window.__openAiEditor=function(i,e,t,n){xi||(xi=new Ei),xi.open({objectId:i,initialPrompt:e,currentValue:t,path:n==null?void 0:n.path,onApply:a=>{if(n!=null&&n.path){let r=window.updateManager;if(r)r.updateProperty(i,n.path,a);else{let o=window.getEditableObjectConfig,s=o==null?void 0:o(i);if(s){let l=n.path.split("."),d=s;for(let u=0;u<l.length-1;u++)d[l[u]]||(d[l[u]]={}),d=d[l[u]];d[l[l.length-1]]=a}}}window.dispatchEvent(new CustomEvent("inspector:refresh"))}})};Ai();var Ci=class{constructor(){this.modal=null;this.options=null}open(e){this.options=e,this.createModal(),document.body.appendChild(this.modal)}createModal(){if(!this.options)return;let{assetPath:e,assetType:t,objectId:n}=this.options,a=n||"Asset Preview",r=document.createElement("div");r.className="asset-preview-modal",r.innerHTML=`
|
|
152
152
|
<div class="asset-preview-card">
|
|
153
153
|
<div class="asset-preview-header">
|
|
154
154
|
<div class="asset-preview-title">${a}</div>
|
|
@@ -175,7 +175,7 @@ Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
175
175
|
<source src="${a}" type="audio/wav">
|
|
176
176
|
Your browser does not support the audio element.
|
|
177
177
|
</audio>
|
|
178
|
-
`;case"text":return`<pre style="background: rgba(0,0,0,0.2); padding: 16px; border-radius: 8px; max-height: 300px; overflow-y: auto; white-space: pre-wrap;">${e}</pre>`;default:return`<div class="asset-preview-placeholder">Cannot preview ${t} assets</div>`}}resolveAssetUrl(e){return e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("/")?e:`/raw/${e}`}attachEventListeners(){if(!this.modal)return;this.modal.addEventListener("click",n=>{let a=n.target;(a.dataset.action==="close"||a===this.modal)&&this.close()});let e=this.modal.querySelector('[data-action="change"]');e&&e.addEventListener("click",()=>{this.openAssetEditor()});let t=this.modal.querySelector('[data-action="edit"]');t&&t.addEventListener("click",()=>{this.openAiEditor(),this.close()})}openAssetEditor(){this.options&&Promise.resolve().then(()=>(
|
|
178
|
+
`;case"text":return`<pre style="background: rgba(0,0,0,0.2); padding: 16px; border-radius: 8px; max-height: 300px; overflow-y: auto; white-space: pre-wrap;">${e}</pre>`;default:return`<div class="asset-preview-placeholder">Cannot preview ${t} assets</div>`}}resolveAssetUrl(e){return e.startsWith("data:")||e.startsWith("blob:")||e.startsWith("/")?e:`/raw/${e}`}attachEventListeners(){if(!this.modal)return;this.modal.addEventListener("click",n=>{let a=n.target;(a.dataset.action==="close"||a===this.modal)&&this.close()});let e=this.modal.querySelector('[data-action="change"]');e&&e.addEventListener("click",()=>{this.openAssetEditor()});let t=this.modal.querySelector('[data-action="edit"]');t&&t.addEventListener("click",()=>{this.openAiEditor(),this.close()})}openAssetEditor(){this.options&&Promise.resolve().then(()=>(Ai(),Hn)).then(({AssetEditorModal:e})=>{new e().show(this.options.objectId||"unknown",this.options.propertyPath||"",this.options.assetPath,n=>{var a;(a=this.options)!=null&&a.onChange&&this.options.onChange(n),this.close()})})}openAiEditor(){if(!this.options||this.options.assetType!=="image")return;let e=window.__openAiEditor;typeof e=="function"&&e(this.options.objectId||"asset","Edit this image asset",this.options.assetPath,{path:this.options.propertyPath,onApply:t=>{var n;(n=this.options)!=null&&n.onChange&&this.options.onChange(t)}})}close(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),this.modal=null,this.options=null}};window.openAssetPreview=function(i){new Ci().open(i)};var Ti=class{constructor(){this.modal=null;this.canvas=null;this.ctx=null;this.image=null;this.options=null;this.cropX=0;this.cropY=0;this.cropWidth=100;this.cropHeight=100;this.scale=1;this.panX=0;this.panY=0;this.isDragging=!1;this.dragStartX=0;this.dragStartY=0;this.lastPanX=0;this.lastPanY=0}open(e){this.options=e,this.createModal(),this.loadImage(),document.body.appendChild(this.modal)}createModal(){let e=document.createElement("div");e.className="asset-crop-modal",e.innerHTML=`
|
|
179
179
|
<div class="asset-crop-card">
|
|
180
180
|
<div class="asset-crop-header">
|
|
181
181
|
<div>
|
|
@@ -226,7 +226,7 @@ Style guidelines: ${n.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 n;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),(n=this.options)!=null&&n.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,n=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,n-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,n=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,n,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,n,a),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+n-r,t],[e,t+a-r],[e+n-r,t+a-r]].forEach(([s,d])=>{var c;(c=this.ctx)==null||c.fillRect(s,d,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 n=150;e.width=n,e.height=n;let a=n/this.cropWidth,r=n/this.cropHeight,o=Math.min(a,r),s=this.cropWidth*o,d=this.cropHeight*o,c=(n-s)/2,u=(n-d)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,c,u,s,d)}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",n=>{let a=parseFloat(n.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",n=>{let a=n.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",n=>{switch(n.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",n=>{n.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,n=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,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,n=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,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 n=e.toDataURL("image/png");this.options.onCrop(n),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(i){new di().open(i)};ue();var Je=require("pixi.js");Et();var rr=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",pi=rr;if(typeof window!="undefined")try{let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);e!=null&&e.buildMode&&(pi=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${pi}`))}}catch{}function or(i){var t,n,a,r,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(i);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(i))return{x:(t=i[0])!=null?t:.5,y:(n=i[1])!=null?n:.5};if(i&&typeof i=="object"&&"x"in i&&"y"in i)return{x:(a=i.x)!=null?a:.5,y:(r=i.y)!=null?r:.5};if(typeof i=="string"){let s=i.trim().toLowerCase();return(o=e[s])!=null?o:{x:.5,y:.5}}return null}var me=class{static async create(e,t,n){var d,c,u,l,p,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${pi}`);let a=(d=t==null?void 0:t.render)==null?void 0:d.asset;if(!a){console.log(`[ObjectFactory] No asset definition for: ${e}, returning empty container`);let f=new Je.Container;return this.applyTransform(f,t==null?void 0:t.transform,t),f}let r=(c=t==null?void 0:t.identity)==null?void 0:c.id;console.log(`[ObjectFactory] Calling AssetLoader.load() for: ${e}, configId: ${r}, type: ${a.type}, path: ${a.path}`);let o=await he.load(e,a,n,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=o==null?void 0:o.constructor)==null?void 0:u.name}`);let s;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),s=new Je.Sprite(o),console.log("[ObjectFactory] Created object:",s,"type:",(l=s==null?void 0:s.constructor)==null?void 0:l.name),this.applyTransform(s,t==null?void 0:t.transform,t);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(p=o==null?void 0:o.constructor)==null?void 0:p.name,o),o&&(((g=o.constructor)==null?void 0:g.name)==="Container"||o instanceof Je.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}`],S=!1;for(let b of f)try{let h=await fetch(b);if(h.ok){s=await h.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=s==null?void 0:s.constructor)==null?void 0:m.name),S=!0;break}}catch{continue}S||(console.error("[ObjectFactory] Failed to reload JSON from any path"),s=o)}else s=o;else s=o,s&&typeof s=="object"&&("x"in s||"position"in s)&&this.applyTransform(s,t==null?void 0:t.transform,t);return s}static applyTransform(e,t,n){var a,r,o,s;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((o=t.position.x)!=null?o:0,(s=t.position.y)!=null?s: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 d=or(t.anchor);d&&("set"in e.anchor?e.anchor.set(d.x,d.y):(e.anchor.x=d.x,e.anchor.y=d.y))}}};ue();var Nn=ft(require("lottie-web"),1);At(Cn);typeof window!="undefined"&&!window.lottie&&(window.lottie=Nn.default);Xt();ue();var ui=rn.version,lr=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"]);an();var Wn={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"},Yn=Math.random().toString(36).slice(2),Oe=null,_e={...Wn},Kn="web_embed",mi={},et,gi=!1,Qe=!1,it=!1,Xn=!1,wi=1,Tt=0,Pt=!1,oe=!1,Me="",Ie=Math.floor(window.innerWidth),je=Math.floor(window.innerHeight),bi=Ie>je,se=!1,tt=!1,Fn=!1,Bn=!1,hi=!1,Lt=null,Se=null,yi=!1,vi=!1,Ct=new Map;function Jn(){if(!Se)return null;let i=Date.now()-Se;return!Number.isFinite(i)||i<0?null:i}function fi(i){if(yi)return;let e=Jn();e!==null&&(yi=!0,v("session_time",{duration_ms:e,reason:i}))}function Un(){if(Oe)return Oe;let i=document.createElement("div");return i.id="handler-root",i.setAttribute("data-handler-root","true"),document.body.appendChild(i),Oe=i,i}function kt(i){switch(i){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return i}}function Zn(i,e){return{event_name:i,ts:Date.now(),session_id:Yn,deployment_id:_e.deployment_id,variant_id:_e.variant_id,export_profile_id:_e.profile_id,instance_id:_e.instance_id||"default",env:Kn==="mraid"?"mraid":"web",attribution:et,payload:e}}function v(i,e){let t=kt(i),n=Zn(t,e);qt(n,!!mi.analytics),bt(t,n),t!==i&&bt(i,n)}function nt(){Lt&&(Lt(Ie,je),Lt=null)}function Re(i){wi=i,v("volume",i)}function ze(i){i&&(Xn=!0),!it&&(it=!0,v("pause"),Re(0))}function at(i){!i&&Xn||it&&(it=!1,v("resume"),Re(wi))}function be(i,e){Ie=Math.floor(i||window.innerWidth),je=Math.floor(e||window.innerHeight),bi=Ie>je,v("resize",{width:Ie,height:je})}function cr(){if(bn())try{let i=mraid.getMaxSize();be(i.width,i.height);let e=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?at():ze()};if(mraid.addEventListener("viewableChange",e),mraid.addEventListener("stateChange",e),mraid.addEventListener("sizeChange",()=>{let t=mraid.getMaxSize();be(t.width,t.height)}),mraid.getAudioVolume){let t=mraid.getAudioVolume();Re(t?1:0)}if(mraid.addEventListener("audioVolumeChange",t=>{t!==null&&Re(t>0?1:0)}),mraid.addEventListener("error",(t,n)=>{console.warn("mraid error:",t,"action:",n)}),Pt=!0,mraid.isViewable()&&mraid.getState()!=="hidden")se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt();else{let t=()=>{se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt()};mraid.addEventListener("ready",t)}}catch(i){console.warn("MRAID hook skipped",i)}}function dr(){if(yn())try{let i=dapi.getScreenSize();be(i.width,i.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?at():ze()}),dapi.addEventListener("adResized",t=>{let n=dapi.getScreenSize();be(t.width||n.width,t.height||n.height)});let e=dapi.getAudioVolume();if(Re(e?1:0),dapi.addEventListener("audioVolumeChange",t=>Re(t?1:0)),Pt=!0,dapi.isViewable())se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt();else{let t=()=>{se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt()};dapi.addEventListener("ready",t)}}catch(i){console.warn("DAPI hook skipped",i)}}function Gn(){let i=()=>{se||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(se=!0,v("boot"),v("view"),v("ready"),oe=!0,nt(),tt&&(tt=!1,te.start()))};window.addEventListener("resize",()=>be()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(at(),i()):ze()}),document.readyState==="complete"||document.readyState==="interactive"?i():window.addEventListener("load",i),Pt=!0}function pr(){let i=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(Fn=!0),!(Fn&&e instanceof MouseEvent)&&(Tt+=1,vi||(vi=!0,v("first_interaction",{count:Tt})),v("interaction",Tt))};document.addEventListener("mousedown",i),document.addEventListener("touchstart",i)}function qn(i){var n,a,r,o,s,d,c,u,l,p,g,m;let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(n=window.ExitApi)==null||n.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(i||"");else if(e==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ke())(r=(a=window.TJ_API)==null?void 0:a.click)==null||r.call(a);else if(vn())(s=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||s.call(o);else if(Sn())(c=(d=window.ScPlayableAd)==null?void 0:d.onCTAClick)==null||c.call(d);else if(En())try{(l=(u=window.smxTracking)==null?void 0:u.redirect)==null||l.call(u)}catch(f){console.warn("Smadex redirect failed",f)}else if(wn()){let f=window.ExitApi;f&&typeof f.exit=="function"?f.exit(i||Me||""):i&&window.open(i)}else Le()?(p=window.install)==null||p.call(window):xn()?(g=window.openAppStore)==null||g.call(window):Vt()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):i&&window.open(i)}function ur(){let i=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let n=new Image;n.src=t};if(i==="bigabid"){let t=window.BIGABID_BIDTIMEMACROS;if(!t)return;q("view",()=>e(t.mraid_viewable)),q("start",()=>e(t.game_viewable)),q("engagement",()=>e(t.engagement));let n=()=>e(t.complete);q("complete",n),mt("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.count)>3&&n()}),q("cta_click",()=>e(t.click))}else if(i==="inmobi"){let t=window.INMOBI_DSPMACROS;if(!t)return;q("view",()=>e(t.Ad_Load_Start)),q("start",()=>e(t.Ad_Viewable)),q("engagement",()=>e(t.First_Engagement)),q("complete",()=>e(t.Gameplay_Complete)),q("cta_click",()=>e(t.DSP_Click)),q("start",()=>{[5,10,15,20,25,30].forEach(n=>setTimeout(()=>e(t[`Spent_${n}_Seconds`]),n*1e3))})}}function gr(){if(!ke())return;let i=window.TJ_API;i&&i.setPlayableAPI&&i.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function Vn(){var e,t,n;let i=window.TJ_API;(e=i==null?void 0:i.objectiveComplete)==null||e.call(i),(t=i==null?void 0:i.playableFinished)==null||t.call(i),(n=i==null?void 0:i.gameplayFinished)==null||n.call(i)}function hr(){Le()&&(window.mintGameStart=()=>{at(!0),be()},window.mintGameClose=()=>{ze(!0)})}function fr(){if(!Wt())return;let i=window.NUC;!i||!i.trigger||(te.on("cta_click",()=>{var e,t;return(t=(e=i.trigger).convert)==null?void 0:t.call(e,Me)}),te.on("complete",()=>{var e,t;return(t=(e=i.trigger).tryAgain)==null?void 0:t.call(e)}))}var te={init(i={},e){var t;if(Kn=i.profile||"web_embed",mi=i.consent||{},_e={...Wn,...i.ids||{}},Oe=i.rootEl||Oe,et=void 0,Xi((t=i.telemetry)!=null&&t.endpoint?i.telemetry:null),Se=null,yi=!1,vi=!1,Ct.clear(),Me=i.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),e&&(Lt=e),v("init"),document.body.oncontextmenu=()=>!1,Un(),br(Oe),An(),cr(),dr(),!Pt){if(document.readyState==="complete")Gn();else if(!Bn){Bn=!0;let n=()=>{Gn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}pr(),ur(),gr(),hr(),fr(),console.log(`%c @handler/playable-sdk %c v${ui} `,"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;"),se&&!oe&&(v("boot"),v("view"),v("ready"),tt&&(tt=!1,te.start()),oe=!0),oe=se},getRoot(){return Un()},get version(){return ui},get maxWidth(){return Ie},get maxHeight(){return je},get isLandscape(){return bi},get isReady(){return oe},get isStarted(){return gi},get isPaused(){return it},get isFinished(){return Qe},get volume(){return wi},get interactions(){return Tt},on(i,e){mt(kt(i),e)},off(i,e){Gt(kt(i),e)},start(){var i,e;if(!gi){if(!se){tt=!0;return}if(gi=!0,Se||(Se=Date.now()),v("start"),be(),Le())ze(),(i=window.gameReady)==null||i.call(window);else if(ke()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:bi?"landscape":"portrait",buildID:ui})}}},finish(){var i,e;Qe||(Qe=!0,v("complete"),fi("complete"),Le()?(i=window.gameEnd)==null||i.call(window):Vt()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):ke()&&Vn())},install(i){if(!Qe){Qe=!0,ke()?(Vn(),setTimeout(()=>te.install(i),300)):(v("complete"),setTimeout(()=>te.install(i),0));return}hi||(hi=!0,setTimeout(()=>hi=!1,500),v("cta_click"),v("conversion"),fi("cta"),qn(i||Me))},emit(i,e){let t=kt(i);if(!lr.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${i} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let n=Zn(t,e);qt(n,!!mi.analytics),bt(t,n)},gameStart(){te.start()},gameEnd(){te.finish()},ctaClick(i,e){v("cta_click",{url:i||Me,manual:!0}),(e==null?void 0:e.open)!==!1&&qn(i||Me)},ctaShow(i){v("cta_show",i)},ctaDismiss(i){v("cta_dismiss",i)},getGameTimeMs(){return Jn()},endSession(i="manual"){fi(i)},setAttribution(i){et=i},abTest(i,e){if(!i)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(mr(`${Yn}:${i}`))%e.length,n=e[t];return et={...et||{},experiment_id:i},_e.variant_id=n,v("ab_assign",{experiment_id:i,variant_id:n}),n},levelStart(i,e){Se||(Se=Date.now()),v("level_start",{level_id:i,...e})},levelComplete(i,e){v("level_complete",{level_id:i,...e})},levelFail(i,e){v("level_fail",{level_id:i,...e})},checkpoint(i,e){v("checkpoint",{checkpoint_id:i,...e})},reward(i,e){v("reward",{reward_id:i,...e})},tutorialStart(i,e){v("tutorial_start",{step_id:i,...e})},tutorialComplete(i,e){v("tutorial_complete",{step_id:i,...e})},tutorialSkip(i,e){v("tutorial_skip",{step_id:i,...e})},timerStart(i){i&&Ct.set(i,Date.now())},timerEnd(i,e="custom",t){if(!i)return;let n=Ct.get(i);if(!n)return;Ct.delete(i);let a=Date.now()-n;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){v("engagement",{action:"timer",key:i,duration_ms:a,...t});return}v(e,{key:i,duration_ms:a,...t})}},fps(i,e){v("fps",{value:i,...e})},memory(i,e){v("memory",{bytes:i,...e})},assetLoadStart(i,e){v("asset_load_start",{asset_id:i,...e})},assetLoadComplete(i,e){v("asset_load_complete",{asset_id:i,...e})},reportError(i,e,t){v("error",{code:i,message:e,...t})},retry(){var i,e,t;if(Le())(i=window.gameRetry)==null||i.call(window);else if(Wt()){let n=window.NUC;(t=(e=n==null?void 0:n.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}v("engagement",{action:"retry"})},pause(){ze(!0)},resume(){at(!0)},resize(i,e){be(i,e)}},Ze=te;function mr(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function br(i){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 n;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),(n=this.options)!=null&&n.aspectRatio&&this.applyAspectRatio(this.options.aspectRatio),this.fitToCanvas()}applyAspectRatio(e){if(!this.image)return;let t=this.image.width/this.image.height,n=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,n-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,n=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,n,a),this.ctx.strokeStyle="#ffffff",this.ctx.lineWidth=2,this.ctx.strokeRect(e,t,n,a),this.ctx.fillStyle="#ffffff";let r=8;[[e,t],[e+n-r,t],[e,t+a-r],[e+n-r,t+a-r]].forEach(([s,l])=>{var d;(d=this.ctx)==null||d.fillRect(s,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 n=150;e.width=n,e.height=n;let a=n/this.cropWidth,r=n/this.cropHeight,o=Math.min(a,r),s=this.cropWidth*o,l=this.cropHeight*o,d=(n-s)/2,u=(n-l)/2;t.drawImage(this.image,this.cropX,this.cropY,this.cropWidth,this.cropHeight,d,u,s,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",n=>{let a=parseFloat(n.target.value);this.setZoom(a)});let t=this.modal.querySelector(".asset-crop-aspect-select");t==null||t.addEventListener("change",n=>{let a=n.target.value;this.setAspectRatio(a)}),this.modal.addEventListener("click",n=>{switch(n.target.dataset.action){case"reset":this.reset();break;case"apply":this.applyCrop();break;case"cancel":case"close":this.close();break}}),this.modal.addEventListener("click",n=>{n.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,n=e.clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,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,n=e.touches[0].clientY-this.dragStartY;this.panX=this.lastPanX+t,this.panY=this.lastPanY+n,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 n=e.toDataURL("image/png");this.options.onCrop(n),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(i){new Ti().open(i)};Se();var ht=require("pixi.js");$t();var rr=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",Li=rr;if(typeof window!="undefined")try{let i=new XMLHttpRequest;if(i.open("GET","./build-settings.json",!1),i.send(),i.status===200&&i.responseText){let e=JSON.parse(i.responseText);e!=null&&e.buildMode&&(Li=e.buildMode,console.log(`[ObjectFactory] Build mode overridden by settings: ${Li}`))}}catch{}function or(i){var t,n,a,r,o;if(typeof window!="undefined"&&window.resolveAnchorVec2)return window.resolveAnchorVec2(i);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(i))return{x:(t=i[0])!=null?t:.5,y:(n=i[1])!=null?n:.5};if(i&&typeof i=="object"&&"x"in i&&"y"in i)return{x:(a=i.x)!=null?a:.5,y:(r=i.y)!=null?r:.5};if(typeof i=="string"){let s=i.trim().toLowerCase();return(o=e[s])!=null?o:{x:.5,y:.5}}return null}var Le=class{static async create(e,t,n){var l,d,u,c,p,g,m;console.log(`[ObjectFactory] create() called for: ${e}, __BUILD_MODE__: ${Li}`);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 o=await Ce.load(e,a,n,r);console.log(`[ObjectFactory] AssetLoader.load() completed for: ${e}, rawAsset type: ${(u=o==null?void 0:o.constructor)==null?void 0:u.name}`);let s;if(a.type==="image")console.log("[ObjectFactory] Creating Sprite from texture:",o,"for object:",e),s=new ht.Sprite(o),console.log("[ObjectFactory] Created object:",s,"type:",(c=s==null?void 0:s.constructor)==null?void 0:c.name),this.applyTransform(s,t==null?void 0:t.transform,t);else if(a.type==="json")if(console.log("[ObjectFactory] JSON asset for",e,"rawAsset type:",(p=o==null?void 0:o.constructor)==null?void 0:p.name,o),o&&(((g=o.constructor)==null?void 0:g.name)==="Container"||o 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){s=await h.json(),console.log("[ObjectFactory] Reloaded JSON directly from:",b,"type:",(m=s==null?void 0:s.constructor)==null?void 0:m.name),A=!0;break}}catch{continue}A||(console.error("[ObjectFactory] Failed to reload JSON from any path"),s=o)}else s=o;else s=o,s&&typeof s=="object"&&("x"in s||"position"in s)&&this.applyTransform(s,t==null?void 0:t.transform,t);return s}static applyTransform(e,t,n){var a,r,o,s;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((o=t.position.x)!=null?o:0,(s=t.position.y)!=null?s: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))}}};Se();var Nn=_t(require("lottie-web"),1);Nt(Cn);typeof window!="undefined"&&!window.lottie&&(window.lottie=Nn.default);ui();Se();var ki=rn.version,lr=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"]);an();var Wn={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"},Yn=Math.random().toString(36).slice(2),qe=null,Ue={...Wn},Kn="web_embed",Oi={},bt,Pi=!1,mt=!1,vt=!1,Xn=!1,zi=1,Bt=0,qt=!1,pe=!1,Ge="",Ve=Math.floor(window.innerWidth),We=Math.floor(window.innerHeight),Ii=Ve>We,ue=!1,yt=!1,Fn=!1,Bn=!1,Mi=!1,Ut=null,Re=null,ji=!1,Ri=!1,Ft=new Map;function Jn(){if(!Re)return null;let i=Date.now()-Re;return!Number.isFinite(i)||i<0?null:i}function _i(i){if(ji)return;let e=Jn();e!==null&&(ji=!0,x("session_time",{duration_ms:e,reason:i}))}function Un(){if(qe)return qe;let i=document.createElement("div");return i.id="handler-root",i.setAttribute("data-handler-root","true"),document.body.appendChild(i),qe=i,i}function Gt(i){switch(i){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return i}}function Zn(i,e){return{event_name:i,ts:Date.now(),session_id:Yn,deployment_id:Ue.deployment_id,variant_id:Ue.variant_id,export_profile_id:Ue.profile_id,instance_id:Ue.instance_id||"default",env:Kn==="mraid"?"mraid":"web",attribution:bt,payload:e}}function x(i,e){let t=Gt(i),n=Zn(t,e);si(n,!!Oi.analytics),It(t,n),t!==i&&It(i,n)}function wt(){Ut&&(Ut(Ve,We),Ut=null)}function Ye(i){zi=i,x("volume",i)}function Ke(i){i&&(Xn=!0),!vt&&(vt=!0,x("pause"),Ye(0))}function xt(i){!i&&Xn||vt&&(vt=!1,x("resume"),Ye(zi))}function ke(i,e){Ve=Math.floor(i||window.innerWidth),We=Math.floor(e||window.innerHeight),Ii=Ve>We,x("resize",{width:Ve,height:We})}function cr(){if(bn())try{let i=mraid.getMaxSize();ke(i.width,i.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,n)=>{console.warn("mraid error:",t,"action:",n)}),qt=!0,mraid.isViewable()&&mraid.getState()!=="hidden")ue=!0,x("boot"),x("view"),x("ready"),pe=!0,wt();else{let t=()=>{ue=!0,x("boot"),x("view"),x("ready"),pe=!0,wt()};mraid.addEventListener("ready",t)}}catch(i){console.warn("MRAID hook skipped",i)}}function dr(){if(yn())try{let i=dapi.getScreenSize();ke(i.width,i.height),dapi.addEventListener("viewableChange",t=>{t.isViewable?xt():Ke()}),dapi.addEventListener("adResized",t=>{let n=dapi.getScreenSize();ke(t.width||n.width,t.height||n.height)});let e=dapi.getAudioVolume();if(Ye(e?1:0),dapi.addEventListener("audioVolumeChange",t=>Ye(t?1:0)),qt=!0,dapi.isViewable())ue=!0,x("boot"),x("view"),x("ready"),pe=!0,wt();else{let t=()=>{ue=!0,x("boot"),x("view"),x("ready"),pe=!0,wt()};dapi.addEventListener("ready",t)}}catch(i){console.warn("DAPI hook skipped",i)}}function Gn(){let i=()=>{ue||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(ue=!0,x("boot"),x("view"),x("ready"),pe=!0,wt(),yt&&(yt=!1,oe.start()))};window.addEventListener("resize",()=>ke()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(xt(),i()):Ke()}),document.readyState==="complete"||document.readyState==="interactive"?i():window.addEventListener("load",i),qt=!0}function pr(){let i=e=>{typeof TouchEvent!="undefined"&&e instanceof TouchEvent&&(Fn=!0),!(Fn&&e instanceof MouseEvent)&&(Bt+=1,Ri||(Ri=!0,x("first_interaction",{count:Bt})),x("interaction",Bt))};document.addEventListener("mousedown",i),document.addEventListener("touchstart",i)}function qn(i){var n,a,r,o,s,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{(n=window.ExitApi)==null||n.exit();return}catch{}if(e==="mraid"&&typeof mraid!="undefined")mraid.open(i||"");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(vn())(s=(o=window.FbPlayableAd)==null?void 0:o.onCTAClick)==null||s.call(o);else if(Sn())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(En())try{(c=(u=window.smxTracking)==null?void 0:u.redirect)==null||c.call(u)}catch(f){console.warn("Smadex redirect failed",f)}else if(wn()){let f=window.ExitApi;f&&typeof f.exit=="function"?f.exit(i||Ge||""):i&&window.open(i)}else Ne()?(p=window.install)==null||p.call(window):xn()?(g=window.openAppStore)==null||g.call(window):li()?(m=parent==null?void 0:parent.postMessage)==null||m.call(parent,"download","*"):i&&window.open(i)}function ur(){let i=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",e=t=>{if(!t)return;let n=new Image;n.src=t};if(i==="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 n=()=>e(t.complete);J("complete",n),Ot("engagement",a=>{var r;((r=a==null?void 0:a.payload)==null?void 0:r.count)>3&&n()}),J("cta_click",()=>e(t.click))}else if(i==="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(n=>setTimeout(()=>e(t[`Spent_${n}_Seconds`]),n*1e3))})}}function gr(){if(!Fe())return;let i=window.TJ_API;i&&i.setPlayableAPI&&i.setPlayableAPI({skipAd:()=>{try{oe.finish()}catch(e){console.warn("Tapjoy skip failed",e)}}})}function Vn(){var e,t,n;let i=window.TJ_API;(e=i==null?void 0:i.objectiveComplete)==null||e.call(i),(t=i==null?void 0:i.playableFinished)==null||t.call(i),(n=i==null?void 0:i.gameplayFinished)==null||n.call(i)}function hr(){Ne()&&(window.mintGameStart=()=>{xt(!0),ke()},window.mintGameClose=()=>{Ke(!0)})}function fr(){if(!ci())return;let i=window.NUC;!i||!i.trigger||(oe.on("cta_click",()=>{var e,t;return(t=(e=i.trigger).convert)==null?void 0:t.call(e,Ge)}),oe.on("complete",()=>{var e,t;return(t=(e=i.trigger).tryAgain)==null?void 0:t.call(e)}))}var oe={init(i={},e){var t;if(Kn=i.profile||"web_embed",Oi=i.consent||{},Ue={...Wn,...i.ids||{}},qe=i.rootEl||qe,bt=void 0,Xi((t=i.telemetry)!=null&&t.endpoint?i.telemetry:null),Re=null,ji=!1,Ri=!1,Ft.clear(),Ge=i.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,Un(),br(qe),An(),cr(),dr(),!qt){if(document.readyState==="complete")Gn();else if(!Bn){Bn=!0;let n=()=>{Gn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}pr(),ur(),gr(),hr(),fr(),console.log(`%c @handler/playable-sdk %c v${ki} `,"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;"),ue&&!pe&&(x("boot"),x("view"),x("ready"),yt&&(yt=!1,oe.start()),pe=!0),pe=ue},getRoot(){return Un()},get version(){return ki},get maxWidth(){return Ve},get maxHeight(){return We},get isLandscape(){return Ii},get isReady(){return pe},get isStarted(){return Pi},get isPaused(){return vt},get isFinished(){return mt},get volume(){return zi},get interactions(){return Bt},on(i,e){Ot(Gt(i),e)},off(i,e){oi(Gt(i),e)},start(){var i,e;if(!Pi){if(!ue){yt=!0;return}if(Pi=!0,Re||(Re=Date.now()),x("start"),ke(),Ne())Ke(),(i=window.gameReady)==null||i.call(window);else if(Fe()){let t=window.TJ_API;(e=t==null?void 0:t.setPlayableBuild)==null||e.call(t,{orientation:Ii?"landscape":"portrait",buildID:ki})}}},finish(){var i,e;mt||(mt=!0,x("complete"),_i("complete"),Ne()?(i=window.gameEnd)==null||i.call(window):li()?(e=parent==null?void 0:parent.postMessage)==null||e.call(parent,"complete","*"):Fe()&&Vn())},install(i){if(!mt){mt=!0,Fe()?(Vn(),setTimeout(()=>oe.install(i),300)):(x("complete"),setTimeout(()=>oe.install(i),0));return}Mi||(Mi=!0,setTimeout(()=>Mi=!1,500),x("cta_click"),x("conversion"),_i("cta"),qn(i||Ge))},emit(i,e){let t=Gt(i);if(!lr.has(t)&&t!=="resize"&&t!=="volume"&&!t.startsWith("custom."))throw new Error(`Event ${i} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let n=Zn(t,e);si(n,!!Oi.analytics),It(t,n)},gameStart(){oe.start()},gameEnd(){oe.finish()},ctaClick(i,e){x("cta_click",{url:i||Ge,manual:!0}),(e==null?void 0:e.open)!==!1&&qn(i||Ge)},ctaShow(i){x("cta_show",i)},ctaDismiss(i){x("cta_dismiss",i)},getGameTimeMs(){return Jn()},endSession(i="manual"){_i(i)},setAttribution(i){bt=i},abTest(i,e){if(!i)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(mr(`${Yn}:${i}`))%e.length,n=e[t];return bt={...bt||{},experiment_id:i},Ue.variant_id=n,x("ab_assign",{experiment_id:i,variant_id:n}),n},levelStart(i,e){Re||(Re=Date.now()),x("level_start",{level_id:i,...e})},levelComplete(i,e){x("level_complete",{level_id:i,...e})},levelFail(i,e){x("level_fail",{level_id:i,...e})},checkpoint(i,e){x("checkpoint",{checkpoint_id:i,...e})},reward(i,e){x("reward",{reward_id:i,...e})},tutorialStart(i,e){x("tutorial_start",{step_id:i,...e})},tutorialComplete(i,e){x("tutorial_complete",{step_id:i,...e})},tutorialSkip(i,e){x("tutorial_skip",{step_id:i,...e})},timerStart(i){i&&Ft.set(i,Date.now())},timerEnd(i,e="custom",t){if(!i)return;let n=Ft.get(i);if(!n)return;Ft.delete(i);let a=Date.now()-n;if(!(!Number.isFinite(a)||a<0)){if(e==="custom"){x("engagement",{action:"timer",key:i,duration_ms:a,...t});return}x(e,{key:i,duration_ms:a,...t})}},fps(i,e){x("fps",{value:i,...e})},memory(i,e){x("memory",{bytes:i,...e})},assetLoadStart(i,e){x("asset_load_start",{asset_id:i,...e})},assetLoadComplete(i,e){x("asset_load_complete",{asset_id:i,...e})},reportError(i,e,t){x("error",{code:i,message:e,...t})},retry(){var i,e,t;if(Ne())(i=window.gameRetry)==null||i.call(window);else if(ci()){let n=window.NUC;(t=(e=n==null?void 0:n.trigger)==null?void 0:e.tryAgain)==null||t.call(e)}x("engagement",{action:"retry"})},pause(){Ke(!0)},resume(){xt(!0)},resize(i,e){ke(i,e)}},ft=oe;function mr(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e|0}function br(i){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(){
|
|
@@ -242,14 +242,14 @@ Style guidelines: ${n.summary}`;this.promptInput.value=a,this.currentPrompt=a}}c
|
|
|
242
242
|
}
|
|
243
243
|
events.forEach(function(e){ document.addEventListener(e, unlock, false); });
|
|
244
244
|
})();
|
|
245
|
-
`,i.appendChild(e)}async function _t(i,e={}){let t=new Qn.Application;await t.init({resizeTo:i,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let n=o=>{var l,p,g,m;if(!t.renderer)return;let s=(l=o==null?void 0:o.width)!=null?l:i.clientWidth,d=(p=o==null?void 0:o.height)!=null?p:i.clientHeight,c=s&&s>0?s:(g=window.innerWidth)!=null?g:320,u=d&&d>0?d:(m=window.innerHeight)!=null?m:480;t.renderer.resize(c,u)};i.appendChild(t.canvas),i.style.position="relative",i.style.display="flex",i.style.flexDirection="column",i.style.alignItems="stretch",i.style.width="100%",i.style.height="100dvh",i.style.minHeight="100vh",i.style.maxWidth="100%",i.style.maxHeight="100%",i.style.boxSizing="border-box",i.style.overflow="hidden",e.background&&(i.style.background=e.background),n();let a=document.createElement("div");return a.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),i.appendChild(a),Ze.on("pause",()=>{t.ticker.stop(),document.querySelectorAll("audio").forEach(s=>s.pause())}),Ze.on("resume",()=>{t.ticker.start(),document.querySelectorAll("audio").forEach(s=>{s.currentTime>0&&!s.ended&&s.play().catch(()=>{})})}),Ze.on("resize",({payload:o})=>{n({width:o==null?void 0:o.width,height:o==null?void 0:o.height})}),window.addEventListener("resize",()=>n()),requestAnimationFrame(()=>n()),new ResizeObserver(o=>{let s=o[0];if(s&&s.contentRect.width>0&&s.contentRect.height>0){let d=Math.round(s.contentRect.width),c=Math.round(s.contentRect.height);if(n({width:d,height:c}),typeof window!="undefined"&&window.gameApp&&window.gameObjectManager){let u={width:d,height:c,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:"auto-resize",isLandscape:d>c};window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:u}))}}}).observe(i),{app:t,stage:t.stage,overlay:a,applySize:n}}var U=require("pixi.js"),rt=class{constructor(e){var a,r;let t=e==null?void 0:e.position,n=e==null?void 0:e.offset;this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0},this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0},this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y},this.scale=(a=e==null?void 0:e.scale)!=null?a:1,this.rotation=(r=e==null?void 0:e.rotation)!=null?r:0}update(e){let t=e.position,n=e.offset;t!==void 0&&(this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0}),n!==void 0&&(this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0}),(t!==void 0||n!==void 0)&&(this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y}),e.scale!==void 0&&(this.scale=e.scale),e.rotation!==void 0&&(this.rotation=e.rotation)}syncToPixi(e){e&&(e.position.set(this.position.x,this.position.y),e.scale.set(this.scale),e.rotation=this.rotation)}},ot=class{constructor(e){var t,n,a,r;this.z_index=(t=e==null?void 0:e.z_index)!=null?t:0,this.alpha=(n=e==null?void 0:e.alpha)!=null?n:1,this.visible=(a=e==null?void 0:e.visible)!=null?a:!0,this.tint=(r=e==null?void 0:e.tint)!=null?r:null}update(e){e.z_index!==void 0&&(this.z_index=e.z_index),e.alpha!==void 0&&(this.alpha=e.alpha),e.visible!==void 0&&(this.visible=e.visible),e.tint!==void 0&&(this.tint=e.tint)}syncToPixi(e,t){if(!e)return;if(e.zIndex=this.z_index,t!=null&&t.startsWith("ui_endgame_")||(e.alpha=this.alpha),e.visible=this.visible,this.tint!==null&&"tint"in e&&(e.tint=this.tint),t&&"texture"in e)try{let{AssetTextures:a}=require("handler-playable-sdk/pixi");if(a&&a[t]){let r=a[t];r&&(e.texture=r)}}catch{}}},st=class{constructor(e,t,n,a){this._tickerCleanup=null;this.onRebuildRequired=null;this.instanceId=e,this.objectConfig=t,this.pixiObject=n,this._config=a,this.transform=new rt(a.transform),this.renderer=new ot(a.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject,this.instanceId),this.applyAnchor(),this.applyEffectsScale(),this.applyEffects(),this.syncTextProperties(),(!this._initialized||this._shouldReplayIntro)&&(this.applyIntro(),this._initialized=!0,this._shouldReplayIntro=!1),this.applyMotion()}syncTextProperties(){var t;if(!this.pixiObject||!("text"in this.pixiObject))return;let e=(t=this._config)==null?void 0:t.ui;e&&(e.text!==void 0&&this.pixiObject.text!==e.text&&(this.pixiObject.text=e.text),this.pixiObject.style&&(e.fontSize!==void 0&&(this.pixiObject.style.fontSize=e.fontSize),e.color!==void 0&&(this.pixiObject.style.fill=e.color),e.align!==void 0&&(this.pixiObject.style.align=e.align)))}destroy(){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null),this._introTicker&&(U.Ticker.shared.remove(this._introTicker),this._introTicker=null),this.pixiObject&&this.pixiObject.parent&&this.pixiObject.parent.removeChild(this.pixiObject)}updateConfig(e){var d,c,u,l,p,g,m,f,S,b,h;let t=(c=(d=this._config)==null?void 0:d.motion)==null?void 0:c.intro,n=(u=e==null?void 0:e.motion)==null?void 0:u.intro;n!=null&&n.enabled&&JSON.stringify(t)!==JSON.stringify(n)&&(this._shouldReplayIntro=!0);let a=(g=(p=(l=this._config)==null?void 0:l.render)==null?void 0:p.asset)==null?void 0:g.type,r=(f=(m=e==null?void 0:e.render)==null?void 0:m.asset)==null?void 0:f.type,o=(b=(S=this._config)==null?void 0:S.ui)==null?void 0:b.renderMode,s=(h=e==null?void 0:e.ui)==null?void 0:h.renderMode;if((a!==r||o!==s)&&(console.log(`[GameObject] Rebuild required for ${this.instanceId}: type changed from ${a}/${o} to ${r}/${s}`),this.onRebuildRequired)){this.onRebuildRequired(this,e);return}this._config=e,e.transform&&this.transform.update(e.transform),e.render&&this.renderer.update(e.render),this.sync()}applyAnchor(){var a,r,o,s;if(!this.pixiObject||!("anchor"in this.pixiObject)||!this.pixiObject.anchor)return;let e=(r=(a=this._config)==null?void 0:a.render)==null?void 0:r.anchor,t=(s=(o=this._config)==null?void 0:o.transform)==null?void 0:s.anchor,n=e&&typeof e=="object"?e:t&&typeof t=="object"?t:null;n&&typeof n.x=="number"&&typeof n.y=="number"&&this.pixiObject.anchor.set(n.x,n.y)}applyEffectsScale(){var r,o,s;if(!((r=this.pixiObject)!=null&&r.scale))return;let e=(o=this._config)==null?void 0:o.effects,t=typeof(e==null?void 0:e.scale_x)=="number"?e.scale_x:1,n=typeof(e==null?void 0:e.scale_y)=="number"?e.scale_y:1;if(t===1&&n===1)return;let a=(s=this.transform.scale)!=null?s:1;typeof this.pixiObject.scale.set=="function"?this.pixiObject.scale.set(a*t,a*n):(this.pixiObject.scale.x=a*t,this.pixiObject.scale.y=a*n)}applyEffects(){var n,a,r,o,s,d,c,u,l;if(!this.pixiObject)return;let e=(n=this._config)==null?void 0:n.effects;if(!e||e.enabled===!1){this.pixiObject.filters=null;return}let t=[];if((a=e.blur)!=null&&a.enabled){let p=new U.BlurFilter;p.blur=(r=e.blur.strength)!=null?r:4,t.push(p)}if((o=e.shadow)!=null&&o.enabled){let p=e.shadow,g=new U.BlurFilter;g.blur=(s=p.blur)!=null?s:4,g.blendMode="multiply",t.push(g),(p.offsetX!==0||p.offsetY!==0)&&console.warn("[Effects] Drop shadow offset requires pixi-filters. Install: npm install pixi-filters")}if((d=e.glow)!=null&&d.enabled){let p=e.glow,g=new U.BlurFilter;if(g.blur=(c=p.blur)!=null?c:8,t.push(g),p.color){let m=new U.ColorMatrixFilter,f=typeof p.color=="string"?parseInt(p.color.replace("#",""),16):p.color;m.tint(f),t.push(m)}}(u=e.stroke)!=null&&u.enabled&&console.warn("[Effects] Stroke/outline effect requires pixi-filters. Install: npm install pixi-filters"),(l=e.distortion)!=null&&l.enabled&&console.warn("[Effects] Distortion effect requires pixi-filters or a displacement map. Install: npm install pixi-filters"),this.pixiObject.filters=t.length>0?t:null}applyIntro(){var u,l,p,g,m,f,S;let e=(u=this._config)==null?void 0:u.motion;if(!e||!((l=e.intro)!=null&&l.enabled)||!this.pixiObject)return;let t=e.intro,n=(t.duration||0)/1e3,a=(t.delay||0)/1e3,r=this.transform.position.y,o=this.transform.scale*(((g=(p=this._config)==null?void 0:p.effects)==null?void 0:g.scale_x)||1),s=this.transform.scale*(((f=(m=this._config)==null?void 0:m.effects)==null?void 0:f.scale_y)||1);if(this.pixiObject.alpha=(S=t.startAlpha)!=null?S:0,t.startScale!==void 0&&this.pixiObject.scale.set(o*t.startScale,s*t.startScale),t.startYOffset!==void 0&&(this.pixiObject.y=r+(t.startYOffset||0)),this._introTicker&&U.Ticker.shared.remove(this._introTicker),n<=0&&a<=0){this.pixiObject.alpha=this.renderer.alpha,this.pixiObject.y=this.transform.position.y,this.pixiObject.scale.set(o,s);return}let d=0,c=b=>{var $,N,j,C,E,A;if(d+=b.deltaTime/60,d<a)return;let h=n>0?Math.min(1,(d-a)/n):1,w=1-Math.pow(1-h,3),x=this.renderer.alpha,y=this.transform.scale*(((N=($=this._config)==null?void 0:$.effects)==null?void 0:N.scale_x)||1),I=this.transform.scale*(((C=(j=this._config)==null?void 0:j.effects)==null?void 0:C.scale_y)||1),R=this.transform.position.y,H=this.transform.position.x;if(this.pixiObject.alpha=((E=t.startAlpha)!=null?E:0)+(x-((A=t.startAlpha)!=null?A:0))*w,t.startScale!==void 0){let T=t.startScale+(1-t.startScale)*w;this.pixiObject.scale.set(y*T,I*T)}t.startYOffset!==void 0&&(this.pixiObject.y=R+t.startYOffset+(R-(R+t.startYOffset))*w),h>=1&&(U.Ticker.shared.remove(c),this._introTicker=null,this.pixiObject.alpha=x,this.pixiObject.x=H,this.pixiObject.y=R,this.pixiObject.scale.set(y,I))};this._introTicker=c,U.Ticker.shared.add(c)}applyMotion(){var a,r,o;let e=(a=this._config)==null?void 0:a.motion,t=e&&e.enabled!==!1,n=JSON.stringify(e);if(!(this._lastMotionStr===n&&this._tickerCleanup)){if(this._lastMotionStr=n,!t){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null);return}if(this._tickerCleanup&&this._tickerCleanup(),(r=e.pulse)!=null&&r.enabled||(o=e.swing)!=null&&o.enabled){let s=0,d=c=>{var f,S,b,h,w,x,y,I,R,H,$;s+=c.deltaTime*.05;let u=this.transform.scale,l=u*(((S=(f=this._config)==null?void 0:f.effects)==null?void 0:S.scale_x)||1),p=u*(((h=(b=this._config)==null?void 0:b.effects)==null?void 0:h.scale_y)||1),g=this.transform.position.x,m=this.transform.position.y;if((w=e.pulse)!=null&&w.enabled){let N=(x=e.pulse.intensity)!=null?x:.1,j=(y=e.pulse.speed)!=null?y:1,E=1+Math.sin(s*j)*N;(I=this.pixiObject.scale)!=null&&I.set?this.pixiObject.scale.set(l*E,p*E):this.pixiObject.scale&&(this.pixiObject.scale.x=l*E,this.pixiObject.scale.y=p*E)}if((R=e.swing)!=null&&R.enabled){let N=(H=e.swing.amplitude)!=null?H:10,j=($=e.swing.speed)!=null?$:1,C=Math.sin(s*j)*N;e.swing.axis==="vertical"?this.pixiObject.y=m+C:e.swing.axis==="both"?(this.pixiObject.x=g+C,this.pixiObject.y=m+C):this.pixiObject.x=g+C}};U.Ticker.shared.add(d),this._tickerCleanup=()=>{var c,u,l,p,g;if(U.Ticker.shared.remove(d),this.pixiObject){let m=this.transform.scale*(((u=(c=this._config)==null?void 0:c.effects)==null?void 0:u.scale_x)||1),f=this.transform.scale*(((p=(l=this._config)==null?void 0:l.effects)==null?void 0:p.scale_y)||1);this.pixiObject.x=this.transform.position.x,this.pixiObject.y=this.transform.position.y,(g=this.pixiObject.scale)!=null&&g.set?this.pixiObject.scale.set(m,f):this.pixiObject.scale&&(this.pixiObject.scale.x=m,this.pixiObject.scale.y=f)}}}}}getComponent(e){return this._config[e]}getPosition(){return{...this.transform.position}}setPosition(e,t){this.transform.position={x:e,y:t},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(e){this.renderer.alpha=e,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(e){this.renderer.visible=e,this.renderer.syncToPixi(this.pixiObject)}},De=class{constructor(e){this.objects=new Map;this.onObjectRebuildRequired=null;this.config=e}create(e,t){let n=this.config.objects.get(e);if(!n)throw new Error(`Object config not found: ${e}`);let a=new st(e,n.object_config||e,t,n);return this.objects.set(e,a),a.onRebuildRequired=async(r,o)=>{if(this.onObjectRebuildRequired){console.log(`[GameObjectManager] Triggering rebuild for ${e}`);let s=await this.onObjectRebuildRequired(e,o);s&&this.objects.get(e)===s&&console.log(`[GameObjectManager] \u2705 Rebuilt ${e} successfully`)}else console.warn(`[GameObjectManager] Rebuild required for ${e} but no factory provided`),r.updateConfig(o)},a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[t,n]of this.objects.entries()){let a=e.objects.get(t);a&&n.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(e){let t=this.objects.get(e);t&&t.destroy(),this.objects.delete(e)}clear(){for(let e of this.objects.values())e.destroy();this.objects.clear()}};var Mt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function ea(i){let e=Mt[i];return e?e.family:(console.warn(`Font ID "${i}" not found in registry, using fallback`),"Arial, sans-serif")}function ta(i){var t;let e=Mt[i];return e&&(t=e.weight)!=null?t:"400"}function ia(i,e){Mt[i]=e}function na(){return Object.keys(Mt)}var $e=null;function yr(){return console.log("[LottieOverlay] getLottie called, lottieLib cached?",!!$e),console.log("[LottieOverlay] window.lottie exists?",typeof window!="undefined"&&!!window.lottie),$e||(typeof window!="undefined"&&window.lottie?($e=window.lottie,console.log("[LottieOverlay] \u2705 Found window.lottie, cached it")):(console.warn("[LottieOverlay] \u274C lottie-web is not available globally. Make sure it is loaded before using Lottie animations."),console.log("[LottieOverlay] window keys:",typeof window!="undefined"?Object.keys(window).filter(i=>i.toLowerCase().includes("lottie")):"no window"),$e=null)),$e}function vr(i){return!i||i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`}function wr(i){try{let e=new XMLHttpRequest;return e.open("GET",vr(i),!1),e.send(null),e.status<200||e.status>=300||!e.responseText?null:JSON.parse(e.responseText)}catch{return null}}function aa(i){return!i||typeof i!="object"||!Array.isArray(i.layers)?null:(Array.isArray(i.assets)||(i.assets=[]),Array.isArray(i.chars)||(i.chars=[]),i)}function At(i){$e=i}function ra(i,e,t,n){var I,R,H,$,N,j,C,E,A,T,k,X,ye,Ue,Ge,qe,Ve,We,Ye;let a=t.objects.get(i);if(!a)return console.warn(`[LottieOverlay] Object config not found: ${i}`),null;let r=((I=a.effects)==null?void 0:I.lottie)||{},o=a.transform||{},s=a.render||{};if(r.enabled===!1||s.visible===!1)return null;let d=n==null?void 0:n[i],c=aa(d);if(!c){let J=(H=(R=a.render)==null?void 0:R.asset)==null?void 0:H.path;if(typeof J=="string"&&J.toLowerCase().endsWith(".json")){let dt=wr(J);if(c=aa(dt),c)try{n[i]=c}catch{}}}if(!c){let J=d&&typeof d=="object"?Object.prototype.toString.call(d):typeof d;return console.warn(`[LottieOverlay] Lottie JSON invalid for: ${i}`,{kind:J}),null}let u=yr();if(!u)return console.warn(`[LottieOverlay] lottie-web is not available. Cannot play animation: ${i}`),null;let l=($=r.width)!=null?$:300,p=(N=r.height)!=null?N:300,g=(j=o.scale)!=null?j:1,m=((E=(C=o.position)==null?void 0:C.x)!=null?E:0)+((T=(A=o.offset)==null?void 0:A.x)!=null?T:0),f=((X=(k=o.position)==null?void 0:k.y)!=null?X:0)+((Ue=(ye=o.offset)==null?void 0:ye.y)!=null?Ue:0),S=(Ge=o.rotation)!=null?Ge:0,b=(qe=s.z_index)!=null?qe:100,h=(Ve=s.alpha)!=null?Ve:1,w=document.createElement("div");w.style.cssText=`
|
|
245
|
+
`,i.appendChild(e)}async function Vt(i,e={}){let t=new Qn.Application;await t.init({resizeTo:i,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let n=o=>{var c,p,g,m;if(!t.renderer)return;let s=(c=o==null?void 0:o.width)!=null?c:i.clientWidth,l=(p=o==null?void 0:o.height)!=null?p:i.clientHeight,d=s&&s>0?s:(g=window.innerWidth)!=null?g:320,u=l&&l>0?l:(m=window.innerHeight)!=null?m:480;t.renderer.resize(d,u)};i.appendChild(t.canvas),i.style.position="relative",i.style.display="flex",i.style.flexDirection="column",i.style.alignItems="stretch",i.style.width="100%",i.style.height="100dvh",i.style.minHeight="100vh",i.style.maxWidth="100%",i.style.maxHeight="100%",i.style.boxSizing="border-box",i.style.overflow="hidden",e.background&&(i.style.background=e.background),n();let a=document.createElement("div");return a.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","align-items:center","justify-content:flex-start","gap:12px","pointer-events:none","font-family:Arial,sans-serif","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),i.appendChild(a),ft.on("pause",()=>{t.ticker.stop(),document.querySelectorAll("audio").forEach(s=>s.pause())}),ft.on("resume",()=>{t.ticker.start(),document.querySelectorAll("audio").forEach(s=>{s.currentTime>0&&!s.ended&&s.play().catch(()=>{})})}),ft.on("resize",({payload:o})=>{n({width:o==null?void 0:o.width,height:o==null?void 0:o.height})}),window.addEventListener("resize",()=>n()),requestAnimationFrame(()=>n()),new ResizeObserver(o=>{let s=o[0];if(s&&s.contentRect.width>0&&s.contentRect.height>0){let l=Math.round(s.contentRect.width),d=Math.round(s.contentRect.height);if(n({width:l,height:d}),typeof window!="undefined"&&window.gameApp&&window.gameObjectManager){let u={width:l,height:d,dpr:Math.max(1,Math.floor(window.devicePixelRatio||1)),presetId:"auto-resize",isLandscape:l>d};window.dispatchEvent(new CustomEvent("handler-preview:screen",{detail:u}))}}}).observe(i),{app:t,stage:t.stage,overlay:a,applySize:n}}var W=require("pixi.js"),Et=class{constructor(e){var a,r;let t=e==null?void 0:e.position,n=e==null?void 0:e.offset;this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0},this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0},this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y},this.scale=(a=e==null?void 0:e.scale)!=null?a:1,this.rotation=(r=e==null?void 0:e.rotation)!=null?r:0}update(e){let t=e.position,n=e.offset;t!==void 0&&(this._basePosition={x:typeof(t==null?void 0:t.x)=="number"?t.x:0,y:typeof(t==null?void 0:t.y)=="number"?t.y:0}),n!==void 0&&(this._offset={x:typeof(n==null?void 0:n.x)=="number"?n.x:0,y:typeof(n==null?void 0:n.y)=="number"?n.y:0}),(t!==void 0||n!==void 0)&&(this.position={x:this._basePosition.x+this._offset.x,y:this._basePosition.y+this._offset.y}),e.scale!==void 0&&(this.scale=e.scale),e.rotation!==void 0&&(this.rotation=e.rotation)}syncToPixi(e){e&&(e.position.set(this.position.x,this.position.y),e.scale.set(this.scale),e.rotation=this.rotation)}},St=class{constructor(e){var t,n,a,r;this.z_index=(t=e==null?void 0:e.z_index)!=null?t:0,this.alpha=(n=e==null?void 0:e.alpha)!=null?n:1,this.visible=(a=e==null?void 0:e.visible)!=null?a:!0,this.tint=(r=e==null?void 0:e.tint)!=null?r:null}update(e){e.z_index!==void 0&&(this.z_index=e.z_index),e.alpha!==void 0&&(this.alpha=e.alpha),e.visible!==void 0&&(this.visible=e.visible),e.tint!==void 0&&(this.tint=e.tint)}syncToPixi(e,t){if(!e)return;if(e.zIndex=this.z_index,t!=null&&t.startsWith("ui_endgame_")||(e.alpha=this.alpha),e.visible=this.visible,this.tint!==null&&"tint"in e&&(e.tint=this.tint),t&&"texture"in e)try{let{AssetTextures:a}=require("handler-playable-sdk/pixi");if(a&&a[t]){let r=a[t];r&&(e.texture=r)}}catch{}}},At=class{constructor(e,t,n,a){this._tickerCleanup=null;this.onRebuildRequired=null;this.instanceId=e,this.objectConfig=t,this.pixiObject=n,this._config=a,this.transform=new Et(a.transform),this.renderer=new St(a.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject,this.instanceId),this.applyAnchor(),this.applyEffectsScale(),this.applyEffects(),this.syncTextProperties(),(!this._initialized||this._shouldReplayIntro)&&(this.applyIntro(),this._initialized=!0,this._shouldReplayIntro=!1),this.applyMotion()}syncTextProperties(){var t;if(!this.pixiObject||!("text"in this.pixiObject))return;let e=(t=this._config)==null?void 0:t.ui;e&&(e.text!==void 0&&this.pixiObject.text!==e.text&&(this.pixiObject.text=e.text),this.pixiObject.style&&(e.fontSize!==void 0&&(this.pixiObject.style.fontSize=e.fontSize),e.color!==void 0&&(this.pixiObject.style.fill=e.color),e.align!==void 0&&(this.pixiObject.style.align=e.align)))}destroy(){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null),this._introTicker&&(W.Ticker.shared.remove(this._introTicker),this._introTicker=null),this.pixiObject&&this.pixiObject.parent&&this.pixiObject.parent.removeChild(this.pixiObject)}updateConfig(e){var l,d,u,c,p,g,m,f,A,b,h;let t=(d=(l=this._config)==null?void 0:l.motion)==null?void 0:d.intro,n=(u=e==null?void 0:e.motion)==null?void 0:u.intro;n!=null&&n.enabled&&JSON.stringify(t)!==JSON.stringify(n)&&(this._shouldReplayIntro=!0);let a=(g=(p=(c=this._config)==null?void 0:c.render)==null?void 0:p.asset)==null?void 0:g.type,r=(f=(m=e==null?void 0:e.render)==null?void 0:m.asset)==null?void 0:f.type,o=(b=(A=this._config)==null?void 0:A.ui)==null?void 0:b.renderMode,s=(h=e==null?void 0:e.ui)==null?void 0:h.renderMode;if((a!==r||o!==s)&&(console.log(`[GameObject] Rebuild required for ${this.instanceId}: type changed from ${a}/${o} to ${r}/${s}`),this.onRebuildRequired)){this.onRebuildRequired(this,e);return}this._config=e,e.transform&&this.transform.update(e.transform),e.render&&this.renderer.update(e.render),this.sync()}applyAnchor(){var a,r,o,s;if(!this.pixiObject||!("anchor"in this.pixiObject)||!this.pixiObject.anchor)return;let e=(r=(a=this._config)==null?void 0:a.render)==null?void 0:r.anchor,t=(s=(o=this._config)==null?void 0:o.transform)==null?void 0:s.anchor,n=e&&typeof e=="object"?e:t&&typeof t=="object"?t:null;n&&typeof n.x=="number"&&typeof n.y=="number"&&this.pixiObject.anchor.set(n.x,n.y)}applyEffectsScale(){var r,o,s;if(!((r=this.pixiObject)!=null&&r.scale))return;let e=(o=this._config)==null?void 0:o.effects,t=typeof(e==null?void 0:e.scale_x)=="number"?e.scale_x:1,n=typeof(e==null?void 0:e.scale_y)=="number"?e.scale_y:1;if(t===1&&n===1)return;let a=(s=this.transform.scale)!=null?s:1;typeof this.pixiObject.scale.set=="function"?this.pixiObject.scale.set(a*t,a*n):(this.pixiObject.scale.x=a*t,this.pixiObject.scale.y=a*n)}applyEffects(){var n,a,r,o,s,l,d,u,c;if(!this.pixiObject)return;let e=(n=this._config)==null?void 0:n.effects;if(!e||e.enabled===!1){this.pixiObject.filters=null;return}let t=[];if((a=e.blur)!=null&&a.enabled){let p=new W.BlurFilter;p.blur=(r=e.blur.strength)!=null?r:4,t.push(p)}if((o=e.shadow)!=null&&o.enabled){let p=e.shadow,g=new W.BlurFilter;g.blur=(s=p.blur)!=null?s:4,g.blendMode="multiply",t.push(g),(p.offsetX!==0||p.offsetY!==0)&&console.warn("[Effects] Drop shadow offset requires pixi-filters. Install: npm install pixi-filters")}if((l=e.glow)!=null&&l.enabled){let p=e.glow,g=new W.BlurFilter;if(g.blur=(d=p.blur)!=null?d:8,t.push(g),p.color){let m=new W.ColorMatrixFilter,f=typeof p.color=="string"?parseInt(p.color.replace("#",""),16):p.color;m.tint(f),t.push(m)}}(u=e.stroke)!=null&&u.enabled&&console.warn("[Effects] Stroke/outline effect requires pixi-filters. Install: npm install pixi-filters"),(c=e.distortion)!=null&&c.enabled&&console.warn("[Effects] Distortion effect requires pixi-filters or a displacement map. Install: npm install pixi-filters"),this.pixiObject.filters=t.length>0?t:null}applyIntro(){var u,c,p,g,m,f,A;let e=(u=this._config)==null?void 0:u.motion;if(!e||!((c=e.intro)!=null&&c.enabled)||!this.pixiObject)return;let t=e.intro,n=(t.duration||0)/1e3,a=(t.delay||0)/1e3,r=this.transform.position.y,o=this.transform.scale*(((g=(p=this._config)==null?void 0:p.effects)==null?void 0:g.scale_x)||1),s=this.transform.scale*(((f=(m=this._config)==null?void 0:m.effects)==null?void 0:f.scale_y)||1);if(this.pixiObject.alpha=(A=t.startAlpha)!=null?A:0,t.startScale!==void 0&&this.pixiObject.scale.set(o*t.startScale,s*t.startScale),t.startYOffset!==void 0&&(this.pixiObject.y=r+(t.startYOffset||0)),this._introTicker&&W.Ticker.shared.remove(this._introTicker),n<=0&&a<=0){this.pixiObject.alpha=this.renderer.alpha,this.pixiObject.y=this.transform.position.y,this.pixiObject.scale.set(o,s);return}let l=0,d=b=>{var R,H,z,T,E,S;if(l+=b.deltaTime/60,l<a)return;let h=n>0?Math.min(1,(l-a)/n):1,v=1-Math.pow(1-h,3),w=this.renderer.alpha,y=this.transform.scale*(((H=(R=this._config)==null?void 0:R.effects)==null?void 0:H.scale_x)||1),P=this.transform.scale*(((T=(z=this._config)==null?void 0:z.effects)==null?void 0:T.scale_y)||1),_=this.transform.position.y,B=this.transform.position.x;if(this.pixiObject.alpha=((E=t.startAlpha)!=null?E:0)+(w-((S=t.startAlpha)!=null?S:0))*v,t.startScale!==void 0){let C=t.startScale+(1-t.startScale)*v;this.pixiObject.scale.set(y*C,P*C)}t.startYOffset!==void 0&&(this.pixiObject.y=_+t.startYOffset+(_-(_+t.startYOffset))*v),h>=1&&(W.Ticker.shared.remove(d),this._introTicker=null,this.pixiObject.alpha=w,this.pixiObject.x=B,this.pixiObject.y=_,this.pixiObject.scale.set(y,P))};this._introTicker=d,W.Ticker.shared.add(d)}applyMotion(){var c,p,g,m,f,A;let e=(c=this._config)==null?void 0:c.motion,t=e&&e.enabled!==!1,n=JSON.stringify(e);if(this._lastMotionStr===n&&this._tickerCleanup)return;if(this._lastMotionStr=n,!t){this._tickerCleanup&&(this._tickerCleanup(),this._tickerCleanup=null);return}if(this._tickerCleanup&&this._tickerCleanup(),!(((p=e.pulse)==null?void 0:p.enabled)||((g=e.swing)==null?void 0:g.enabled)||((m=e.continuousMove)==null?void 0:m.enabled)||((f=e.continuousRotate)==null?void 0:f.enabled)||((A=e.orbit)==null?void 0:A.enabled)))return;let r=0,o=0,s=0,l=0,d=1/60,u=b=>{var z,T,E,S,C,L,G,ie,fe,me,be,ye,ve,we,q,Pe,it,nt,at,rt,ot,st,lt,ct,dt,pt;let h=((z=b.deltaTime)!=null?z:1)*d;r+=b.deltaTime*.05;let v=this.transform.scale,w=v*(((E=(T=this._config)==null?void 0:T.effects)==null?void 0:E.scale_x)||1),y=v*(((C=(S=this._config)==null?void 0:S.effects)==null?void 0:C.scale_y)||1),P=this.transform.position.x,_=this.transform.position.y,B=this.transform.rotation,R=0,H=0;if((L=e.swing)!=null&&L.enabled){let N=(G=e.swing.amplitude)!=null?G:10,K=(ie=e.swing.speed)!=null?ie:1,U=Math.sin(r*K)*N;e.swing.axis==="vertical"?H+=U:e.swing.axis==="both"?(R+=U,H+=U):R+=U}if((fe=e.continuousMove)!=null&&fe.enabled){let N=(me=e.continuousMove.axis)!=null?me:"x",K=Math.max(0,(be=e.continuousMove.speed)!=null?be:50),U=Math.sign((ye=e.continuousMove.direction)!=null?ye:1)||1,X=Math.max(0,(ve=e.continuousMove.lifetime)!=null?ve:0);o+=h;let $e=X>0?Math.min(o,X):o,Me=K*U*$e;(N==="x"||N==="both")&&(R+=Me),(N==="y"||N==="both")&&(H+=Me)}if((we=e.orbit)!=null&&we.enabled){let N=Math.max(0,(q=e.orbit.radius)!=null?q:50),K=Math.max(0,(Pe=e.orbit.speed)!=null?Pe:45),U=Math.sign((it=e.orbit.direction)!=null?it:1)||1,X=K*Math.PI/180;l+=X*U*h;let $e=(nt=e.orbit.pivotOffsetX)!=null?nt:0,Me=(at=e.orbit.pivotOffsetY)!=null?at:0;R+=$e+N*Math.cos(l),H+=Me+N*Math.sin(l)}if(this.pixiObject.x=P+R,this.pixiObject.y=_+H,(rt=e.pulse)!=null&&rt.enabled){let N=(ot=e.pulse.intensity)!=null?ot:.1,K=(st=e.pulse.speed)!=null?st:1,X=1+Math.sin(r*K)*N;(lt=this.pixiObject.scale)!=null&<.set?this.pixiObject.scale.set(w*X,y*X):this.pixiObject.scale&&(this.pixiObject.scale.x=w*X,this.pixiObject.scale.y=y*X)}if((ct=e.continuousRotate)!=null&&ct.enabled){let N=Math.max(0,(dt=e.continuousRotate.speed)!=null?dt:90),K=Math.sign((pt=e.continuousRotate.direction)!=null?pt:1)||1,U=N*Math.PI/180;s+=U*K*h,this.pixiObject.rotation=B+s}};W.Ticker.shared.add(u),this._tickerCleanup=()=>{var b,h,v,w,y;if(W.Ticker.shared.remove(u),this.pixiObject){let P=this.transform.scale*(((h=(b=this._config)==null?void 0:b.effects)==null?void 0:h.scale_x)||1),_=this.transform.scale*(((w=(v=this._config)==null?void 0:v.effects)==null?void 0:w.scale_y)||1);this.pixiObject.x=this.transform.position.x,this.pixiObject.y=this.transform.position.y,this.pixiObject.rotation=this.transform.rotation,(y=this.pixiObject.scale)!=null&&y.set?this.pixiObject.scale.set(P,_):this.pixiObject.scale&&(this.pixiObject.scale.x=P,this.pixiObject.scale.y=_)}}}getComponent(e){return this._config[e]}getPosition(){return{...this.transform.position}}setPosition(e,t){this.transform.position={x:e,y:t},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(e){this.renderer.alpha=e,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(e){this.renderer.visible=e,this.renderer.syncToPixi(this.pixiObject)}},Xe=class{constructor(e){this.objects=new Map;this.onObjectRebuildRequired=null;this.config=e}create(e,t){let n=this.config.objects.get(e);if(!n)throw new Error(`Object config not found: ${e}`);let a=new At(e,n.object_config||e,t,n);return this.objects.set(e,a),a.onRebuildRequired=async(r,o)=>{if(this.onObjectRebuildRequired){console.log(`[GameObjectManager] Triggering rebuild for ${e}`);let s=await this.onObjectRebuildRequired(e,o);s&&this.objects.get(e)===s&&console.log(`[GameObjectManager] \u2705 Rebuilt ${e} successfully`)}else console.warn(`[GameObjectManager] Rebuild required for ${e} but no factory provided`),r.updateConfig(o)},a}get(e){return this.objects.get(e)}updateConfig(e){this.config=e;for(let[t,n]of this.objects.entries()){let a=e.objects.get(t);a&&n.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(e){let t=this.objects.get(e);t&&t.destroy(),this.objects.delete(e)}clear(){for(let e of this.objects.values())e.destroy();this.objects.clear()}};var Wt={"brand.primary":{family:"Arial, sans-serif",weight:"400"},"brand.warning":{family:"Arial Black, Arial, sans-serif",weight:"900"},"brand.heading":{family:"Arial Black, Arial, sans-serif",weight:"800"},"brand.body":{family:"Arial, sans-serif",weight:"400"}};function ea(i){let e=Wt[i];return e?e.family:(console.warn(`Font ID "${i}" not found in registry, using fallback`),"Arial, sans-serif")}function ta(i){var t;let e=Wt[i];return e&&(t=e.weight)!=null?t:"400"}function ia(i,e){Wt[i]=e}function na(){return Object.keys(Wt)}var Je=null;function yr(){return console.log("[LottieOverlay] getLottie called, lottieLib cached?",!!Je),console.log("[LottieOverlay] window.lottie exists?",typeof window!="undefined"&&!!window.lottie),Je||(typeof window!="undefined"&&window.lottie?(Je=window.lottie,console.log("[LottieOverlay] \u2705 Found window.lottie, cached it")):(console.warn("[LottieOverlay] \u274C lottie-web is not available globally. Make sure it is loaded before using Lottie animations."),console.log("[LottieOverlay] window keys:",typeof window!="undefined"?Object.keys(window).filter(i=>i.toLowerCase().includes("lottie")):"no window"),Je=null)),Je}function vr(i){return!i||i.startsWith("http://")||i.startsWith("https://")||i.startsWith("/")?i:`/${i.replace(/^\.\//,"")}`}function wr(i){try{let e=new XMLHttpRequest;return e.open("GET",vr(i),!1),e.send(null),e.status<200||e.status>=300||!e.responseText?null:JSON.parse(e.responseText)}catch{return null}}function aa(i){return!i||typeof i!="object"||!Array.isArray(i.layers)?null:(Array.isArray(i.assets)||(i.assets=[]),Array.isArray(i.chars)||(i.chars=[]),i)}function Nt(i){Je=i}function ra(i,e,t,n){var P,_,B,R,H,z,T,E,S,C,L,G,ie,fe,me,be,ye,ve,we;let a=t.objects.get(i);if(!a)return console.warn(`[LottieOverlay] Object config not found: ${i}`),null;let r=((P=a.effects)==null?void 0:P.lottie)||{},o=a.transform||{},s=a.render||{};if(r.enabled===!1||s.visible===!1)return null;let l=n==null?void 0:n[i],d=aa(l);if(!d){let q=(B=(_=a.render)==null?void 0:_.asset)==null?void 0:B.path;if(typeof q=="string"&&q.toLowerCase().endsWith(".json")){let Pe=wr(q);if(d=aa(Pe),d)try{n[i]=d}catch{}}}if(!d){let q=l&&typeof l=="object"?Object.prototype.toString.call(l):typeof l;return console.warn(`[LottieOverlay] Lottie JSON invalid for: ${i}`,{kind:q}),null}let u=yr();if(!u)return console.warn(`[LottieOverlay] lottie-web is not available. Cannot play animation: ${i}`),null;let c=(R=r.width)!=null?R:300,p=(H=r.height)!=null?H:300,g=(z=o.scale)!=null?z:1,m=((E=(T=o.position)==null?void 0:T.x)!=null?E:0)+((C=(S=o.offset)==null?void 0:S.x)!=null?C:0),f=((G=(L=o.position)==null?void 0:L.y)!=null?G:0)+((fe=(ie=o.offset)==null?void 0:ie.y)!=null?fe:0),A=(me=o.rotation)!=null?me:0,b=(be=s.z_index)!=null?be:100,h=(ye=s.alpha)!=null?ye:1,v=document.createElement("div");v.style.cssText=`
|
|
246
246
|
position: absolute;
|
|
247
247
|
top: calc(50% + ${f}px);
|
|
248
248
|
left: calc(50% + ${m}px);
|
|
249
|
-
transform: translate(-50%, -50%) scale(${g}) rotate(${
|
|
250
|
-
width: ${
|
|
249
|
+
transform: translate(-50%, -50%) scale(${g}) rotate(${A}deg);
|
|
250
|
+
width: ${c}px;
|
|
251
251
|
height: ${p}px;
|
|
252
252
|
pointer-events: none;
|
|
253
253
|
z-index: ${b};
|
|
254
254
|
opacity: ${h};
|
|
255
|
-
`,e.appendChild(w);let x;try{x=u.loadAnimation({container:w,renderer:r.renderer||"svg",loop:(We=r.loop)!=null?We:!1,autoplay:(Ye=r.autoplay)!=null?Ye:!0,animationData:c})}catch(J){return w.parentNode&&w.parentNode.removeChild(w),console.warn(`[LottieOverlay] Failed to start animation: ${i}`,J),null}r.speed!==void 0&&x.setSpeed(r.speed);let y=()=>{x.destroy(),w.parentNode&&w.parentNode.removeChild(w)};return r.loop||x.addEventListener("complete",y),{animation:x,cleanup:y}}Et();Qt();var Ot=class{constructor(e,t,n){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=n}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:n}=await _t(this.root,{background:e.background_color,text:e.text_color,primary:e.cta_background,cta_text:e.cta_text});this.app=t,this.stage=n,this.gameObjectManager=new De(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:n}=e.detail;this.resize(t,n)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let n of this.systems)n.update&&n.update(t,this.totalTime)}resize(e,t){for(let n of this.systems)n.onResize&&n.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(n=>n instanceof e);if(!t)throw new Error(`System ${e.name} not found!`);return t}};var He=class{setContext(e){this.context=e}};var Ne=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=ft(require("pixi.js"),1),sa=oa;typeof window!="undefined"&&(window.__basePixi=oa);Xe();var le=require("pixi.js");Xe();var la=i=>i*Math.PI/180;function xr(i,e){var o,s,d,c,u;let t=e.ui;if(!(t!=null&&t.text))return null;let n="#ffffff";(o=e.render)!=null&&o.tint&&(n=e.render.tint);let a=new le.TextStyle({fontFamily:(s=t.font)!=null?s:"Arial",fontSize:(d=t.fontSize)!=null?d:16,fill:n,align:(c=t.align)!=null?c:"center",letterSpacing:(u=t.letterSpacing)!=null?u:0}),r=new le.Text({text:t.text,style:a});return r.label=i,r}function ca(i){var u,l,p,g,m,f,S,b,h,w;let{stage:e,mainContainer:t,activeConfig:n,gameObjectManager:a,allowList:r,denyList:o}=i,s={},d={},c={};t.sortableChildren=!0;for(let[x,y]of n.objects.entries()){if(o!=null&&o.has(x)||r&&!r.has(x)||(y==null?void 0:y.enabled)===!1)continue;let I=(l=(u=y==null?void 0:y.render)==null?void 0:u.asset)==null?void 0:l.path,R=(g=(p=y==null?void 0:y.render)==null?void 0:p.asset)==null?void 0:g.type,H=!!(I&&R==="image"),$=!!((m=y==null?void 0:y.ui)!=null&&m.text),N=$?(f=y==null?void 0:y.ui)==null?void 0:f.renderMode:void 0,j;if(N==="png"&&H?j="png":N==="text"&&$?j="text":H?j="png":$?j="text":j="skip",j!=="skip"){if(j==="text"){let C=xr(x,y);if(!C)continue;let E=y.render;C.alpha=typeof(E==null?void 0:E.alpha)=="number"?E.alpha:1,C.visible=(E==null?void 0:E.visible)!==!1,C.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"?C.anchor.set(E.anchor.x,E.anchor.y):C.anchor.set(.5,.5);let A=y.transform,T=(A==null?void 0:A.position)||(A==null?void 0:A.offset);T&&C.position.set((S=T.x)!=null?S:0,(b=T.y)!=null?b:0);let k=typeof(A==null?void 0:A.scale)=="number"?A.scale:1;C.scale.set(k,k);let X=typeof(A==null?void 0:A.rotation)=="number"?A.rotation:0;C.rotation=la(X),C.parent||t.addChild(C);try{a.create(x,C)}catch{}s[x]=C,c[x]=C}else if(j==="png"){let C=fe[x]||(typeof le.Texture!="undefined"?le.Texture.EMPTY:void 0),E=new le.Sprite(C);E.label=x;let A=y.render;E.alpha=typeof(A==null?void 0:A.alpha)=="number"?A.alpha:1,E.visible=(A==null?void 0:A.visible)!==!1,E.zIndex=typeof(A==null?void 0:A.z_index)=="number"?A.z_index:0,A!=null&&A.anchor&&typeof A.anchor.x=="number"&&typeof A.anchor.y=="number"&&E.anchor.set(A.anchor.x,A.anchor.y);let T=y.transform,k=(T==null?void 0:T.position)||(T==null?void 0:T.offset);k&&E.position.set((h=k.x)!=null?h:0,(w=k.y)!=null?w:0);let X=typeof(T==null?void 0:T.scale)=="number"?T.scale:1;E.scale.set(X,X);let ye=typeof(T==null?void 0:T.rotation)=="number"?T.rotation:0;E.rotation=la(ye),E.parent||t.addChild(E);try{a.create(x,E)}catch{}s[x]=E,d[x]=E}}}return t.parent||e.addChild(t),{objects:s,sprites:d,texts:c}}var xi=class{constructor(){this.instanceCache=new Map;this.readyPromise=null;this.app=null;this.registry=new Ne}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 n=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async r=>{var s;let o=this.registry.get(r);if(!o){console.warn("[Assets] No config found for object:",r);return}try{let d=await me.create(r,o,this.app);this.instanceCache.set(r,d),console.log("[Assets] Loaded object:",r,(s=d==null?void 0:d.constructor)==null?void 0:s.name)}catch(d){console.error("[Assets] Failed to load object:",r,d)}})))};return this.readyPromise=(async()=>{await n(t);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await n(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 n=await me.create(e,t,this.app);this.instanceCache.set(e,n)}}get(e){return this.instanceCache.get(e)}},da=new xi,pa=new Proxy(da,{get(i,e){if(e in i&&typeof i[e]=="function")return i[e].bind(i);if(i.get(e))return i.get(e)}});function ua(i,e){da.init(i,e)}Xe();var It=class extends He{async init(){St(this.context.config,this.context.app),await fe.ready(),console.log("[AssetSystem] All assets preloaded and ready")}async onStart(){}onConfigUpdate(){console.log("[AssetSystem] Config updated - systems will refresh textures")}};var Dt=require("pixi.js"),ce={width:400,height:600,designWidth:400,scaleFactor:1},ct={scale:1,position:1},$t=[];function Er(i,e,t,n,a,r,o){$t.push({element:i,originalScale:r,positionHelper:e,heightPercent:a}),e(i,t,n,a,r,o,!1)}function Sr(){$t.forEach(({element:i,originalScale:e,positionHelper:t,heightPercent:n})=>{let a=e*ce.scaleFactor;t(i,ce.width,ce.height,n,a,!0,!1)})}function ga(){$t.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Rt(i,e){console.log(`[SCREEN] updateScreenState called: ${i}x${e}`),ce.width=i,ce.height=e,ce.scaleFactor=Math.min(i/ce.designWidth,1.15),ct.scale=ce.scaleFactor,ct.position=1,console.log(`[SCREEN] Global multipliers - scale: ${ct.scale.toFixed(3)}`),Sr()}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 Ar(i,e,t){let n=O[i];n&&n[e]!==void 0&&(n[e]=t,console.log(`Updated ${i}.${e} = ${t}`))}function Cr(){return O}var Tr={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 jt(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function Ce(i,e={x:.5,y:.5}){var t;if(Array.isArray(i))return{x:jt(i[0],e.x),y:jt(i[1],e.y)};if(i&&typeof i=="object"){let n=i;return{x:jt(n.x,e.x),y:jt(n.y,e.y)}}if(typeof i=="string"){let n=i.trim().toLowerCase();return(t=Tr[n])!=null?t:e}return e}function Fe(i,e,t,n={}){var g,m,f,S,b,h;let a=Ce(t),r=(g=n.inset)!=null?g:{},o=(m=n.padding)!=null?m:{x:0,y:0},s=((f=r.left)!=null?f:0)+o.x,d=((S=r.right)!=null?S:0)+o.x,c=((b=r.top)!=null?b:0)+o.y,u=((h=r.bottom)!=null?h:0)+o.y,l=Math.max(0,i-s-d),p=Math.max(0,e-c-u);return{x:s+l*a.x,y:c+p*a.y}}function Be(i,e,t,n={}){var f,S,b,h,w,x;let a=(f=n.inset)!=null?f:{},r=(S=n.padding)!=null?S:{x:0,y:0},o=((b=a.left)!=null?b:0)+r.x,s=((h=a.right)!=null?h:0)+r.x,d=((w=a.top)!=null?w:0)+r.y,c=((x=a.bottom)!=null?x:0)+r.y,u=Math.max(0,i-o-s),l=Math.max(0,e-d-c),p=Ce(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:o+u*g,y:d+l*m}}function zt(i,e,t,n={}){var u,l,p;if(!i)return;let a=n.positionRatio?Be(e,t,n.positionRatio,{inset:n.inset,padding:n.screenPadding}):Fe(e,t,n.anchor,{inset:n.inset,padding:n.screenPadding}),r=(u=n.offset)!=null?u:{x:0,y:0},o=a.x+r.x,s=a.y+r.y;i.anchor&&n.renderAnchor&&i.anchor.set(n.renderAnchor.x,n.renderAnchor.y),K(i,o,s);let d=(l=n.scale)!=null?l:1,c=(p=n.scaleMultiplier)!=null?p:1;(n.scale!==void 0||n.scaleMultiplier!==void 0)&&ie(i,d*c)}if(typeof window!="undefined"){let i=window.innerWidth,e=window.innerHeight,t=()=>{let n=window.innerWidth,a=window.innerHeight;(n!==i||a!==e)&&(i=n,e=a,Rt(n,a))};window.addEventListener("resize",t),window.addEventListener("orientationchange",()=>{setTimeout(t,100)}),window.mraid&&(window.mraid.addEventListener("viewableChange",t),window.mraid.addEventListener("sizeChange",t)),Rt(window.innerWidth,window.innerHeight),window.updateDebugConfig=Ar,window.getDebugConfig=Cr,window.copyConfig=Dr,window.applyConfig=lt,window.applyConfigForRatio=$r,window.positionAtBottom=ha,window.positionAtTop=Pr,window.positionAtCenter=_r,window.positionAtLeft=Mr,window.positionAtRight=Or,window.positionAtBottomLeft=Ir,window.positionAtBottomRight=jr,window.positionAtTopLeft=Rr,window.positionAtTopRight=zr,window.applyPositionContract=kr,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 Ht(i,e,t=0){return i*e+t}function Nt(i,e,t=0){return i*(1-e)+t}function Ft(i,e,t=0){return i*e+t}function Bt(i,e,t=0){return i*(1-e)+t}function W(i,e=0){return i/2+e}function Lr(i,e){return i*e}function kr(i,e,t,n){var o,s,d,c,u,l,p,g,m,f,S,b,h,w,x,y,I,R,H,$;let a=0,r=0;switch(n.type){case"top":a=W(e,(s=(o=n.offset)==null?void 0:o.x)!=null?s:0),r=Ht(t,n.percent,(c=(d=n.offset)==null?void 0:d.y)!=null?c:0);break;case"bottom":a=W(e,(l=(u=n.offset)==null?void 0:u.x)!=null?l:0),r=Nt(t,n.percent,(g=(p=n.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=Ft(e,n.percent,(f=(m=n.offset)==null?void 0:m.x)!=null?f:0),r=W(t,(b=(S=n.offset)==null?void 0:S.y)!=null?b:0);break;case"right":a=Bt(e,n.percent,(w=(h=n.offset)==null?void 0:h.x)!=null?w:0),r=W(t,(y=(x=n.offset)==null?void 0:x.y)!=null?y:0);break;case"center":a=W(e,(R=(I=n.offset)==null?void 0:I.x)!=null?R:0),r=W(t,($=(H=n.offset)==null?void 0:H.y)!=null?$:0);break}i.position?i.position.set(a,r):(i.x=a,i.y=r),n.scale!==void 0&&n.scale!==1&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(n.scale,n.scale):(i.scale.x=n.scale,i.scale.y=n.scale))}function ha(i,e,t,n=.2,a=1,r=!0,o=!1){let s=Lr(t,n),d=Nt(t,n/2);K(i,W(e),d);let c=r?a*ce.scaleFactor:a;ie(i,c),o&&!$t.find(u=>u.element===i)&&Er(i,ha,e,t,n,a,r)}function Pr(i,e,t,n=.1,a=1){K(i,W(e),Ht(t,n)),ie(i,a)}function _r(i,e,t,n=0,a=0,r=1){K(i,W(e,n),W(t,a)),ie(i,r)}function Mr(i,e,t,n=.1,a=1){K(i,Ft(e,n),W(t)),ie(i,a)}function Or(i,e,t,n=.1,a=1){K(i,Bt(e,n),W(t)),ie(i,a)}function Ir(i,e,t,n=.05,a=.05,r=1){K(i,Ft(e,a),Nt(t,n)),ie(i,r)}function jr(i,e,t,n=.05,a=.05,r=1){K(i,Bt(e,a),Nt(t,n)),ie(i,r)}function Rr(i,e,t,n=.05,a=.05,r=1){K(i,Ft(e,a),Ht(t,n)),ie(i,r)}function zr(i,e,t,n=.05,a=.05,r=1){K(i,Bt(e,a),Ht(t,n)),ie(i,r)}function K(i,e,t){i&&i.position?typeof i.position.set=="function"?i.position.set(e,t):(i.position.x=e,i.position.y=t):i&&(i.x=e,i.y=t)}function ie(i,e){e!==1&&i&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(e,e):i.scale.x!==void 0&&i.scale.y!==void 0&&(i.scale.x=e,i.scale.y=e))}var Ae={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(i){return i&&Ae[i]?JSON.parse(JSON.stringify(Ae[i])):JSON.parse(JSON.stringify(O))}function lt(i){Object.keys(i).forEach(e=>{let t=e;O[t]&&i[t]&&Object.assign(O[t],i[t])}),console.log("Config applied:",i)}function $r(i,e){let t=i/e;t>1.6?(lt(Ae.wide),console.log("Applied WIDE config for ratio:",t)):t<.7?(lt(Ae.tall),console.log("Applied TALL config for ratio:",t)):t>.8&&t<1.2?(lt(Ae.square),console.log("Applied SQUARE config for ratio:",t)):(lt(Ae.default),console.log("Applied DEFAULT config for ratio:",t))}if(typeof window!="undefined"){let i=window;i.configPresets=Ae,i.resolveAnchorVec2=i.resolveAnchorVec2||Ce,i.resolveScreenAnchorPoint=i.resolveScreenAnchorPoint||Fe,i.resolveScreenRatioPoint=i.resolveScreenRatioPoint||Be}var G=null;function fa(i,e,t,n,a,r={}){var X,ye,Ue,Ge,qe,Ve,We,Ye,J,dt,Ei,Si,Ai,Ci,Ti,Li,ki,Pi,_i,Mi,Oi,Ii,ji,Ri,zi,Di,$i,Hi,Ni,Fi,Bi,Ui,Gi,qi;let o=(X=r.enableDebugLogs)!=null?X:!1;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:n.width,height:n.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",r));let{mainContainer:s,label:d,background:c,backgroundTexture:u,app:l}=i;if(!l||!l.renderer){o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] App renderer dimensions:",{width:l.renderer.width,height:l.renderer.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] App screen dimensions:",{width:l.screen.width,height:l.screen.height}));let p=n.width,g=n.height;o&&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,S=p/2,b=e.engine.runtime||{},h=b.layout||{};o&&(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:S}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Engine runtime:",b),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Layout config:",h));let w=h.design_width_portrait||400,x=m/w;x=Math.min(x,1.15);let y=x*((ye=O.engine.scale)!=null?ye:1),I=(Ue=r.skipMainContainerTransform)!=null?Ue:!1;!I&&s&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(y):(s.scale.x=y,s.scale.y=y));let R=(Ge=h.main_container_anchor)!=null?Ge:"center",H=(qe=h.main_container_position_ratio)!=null?qe:{x:.5,y:.5},$=(Ve=h.main_container_offset)!=null?Ve:{x:0,y:0},N=h.main_container_position_ratio?Be(p,g,H):Fe(p,g,R),j=N.x+$.x+O.layout.position_offset.x,C=N.y+$.y+O.layout.position_offset.y;if(!I&&s&&s.position&&(typeof s.position.set=="function"?s.position.set(j,C):(s.position.x=j,s.position.y=C)),a&&(s!=null&&s.toLocal))for(let[B,F]of e.objects.entries()){let _=F==null?void 0:F.transform;if(!_||((We=_.position_mode)!=null?We:"static")!=="static")continue;let L=(Ye=a.get)==null?void 0:Ye.call(a,B),Z=((J=L==null?void 0:L.getDisplayObject)==null?void 0:J.call(L))||(L==null?void 0:L.pixiObject)||L;if(!Z||Z.parent!==s)continue;let pt=_.position_ratio!=null?Be(p,g,_.position_ratio):Fe(p,g,(dt=_.anchor)!=null?dt:"center"),ut=s.toLocal(new Dt.Point(pt.x,pt.y)),gt=(Ei=_.position)!=null?Ei:{x:0,y:0},ve=ut.x+gt.x,Ut=ut.y+gt.y;typeof(L==null?void 0:L.setPosition)=="function"?L.setPosition(ve,Ut):(K(Z,ve,Ut),(Si=L==null?void 0:L.transform)!=null&&Si.position&&(L.transform.position.x=ve,L.transform.position.y=Ut))}let E=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,T=((E==null?void 0:E.buildMode)||(typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"dev"))==="dev";if(O.layout.debug_rect_visible&&T){(!G||G.parent!==l.stage)&&(G==null||G.destroy(),G=new Dt.Graphics,G.zIndex=9999,l.stage.addChild(G)),G.clear();let B=O.layout.debug_rect_scale_x,F=O.layout.debug_rect_scale_y,_=(p-4)*B,de=(g-4)*F,L=(p-_)/2,Z=(g-de)/2;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:_,rectH:de,offsetX:L,offsetY:Z}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+L,y:2+Z,width:_,height:de})),G.rect(2+L,2+Z,_,de).stroke({width:O.layout.debug_rect_thickness,color:O.layout.debug_rect_color})}else G&&(G.destroy(),G=null);let k=((Ai=i.label)==null?void 0:Ai.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(d&&d.position&&k){let B=(Ti=(Ci=k==null?void 0:k.transform)==null?void 0:Ci.anchor)!=null?Ti:"center",F=(Li=k==null?void 0:k.transform)==null?void 0:Li.position_ratio,_=((ki=k==null?void 0:k.transform)==null?void 0:ki.offset)||{x:0,y:0};zt(d,p,g,{anchor:B,positionRatio:F,offset:{x:_.x*y,y:_.y*y},renderAnchor:Ce(B)})}if(d&&d.alpha>0){let B=1+Math.sin(t*O.engine.label_pulse_speed)*O.engine.label_pulse_intensity,F=(_i=(Pi=k==null?void 0:k.transform)==null?void 0:Pi.scale)!=null?_i:1,_=B*y*F;d.scale&&(typeof d.scale.set=="function"?d.scale.set(_):(d.scale.x=_,d.scale.y=_))}if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),c){o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background object exists:",!!c),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background type:",(Mi=c.constructor)==null?void 0:Mi.name)),c.alpha=((Ii=(Oi=b.background)==null?void 0:Oi.alpha)!=null?Ii:.98)*O.engine.background_alpha,o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",c.alpha);let B=e.objects.get("background_1");o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",B);let F=(B==null?void 0:B.transform)||{};o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",F);let _=F.offset||{x:0,y:0},de=((Ri=(ji=b.background)==null?void 0:ji.offset_y)!=null?Ri:0)+O.engine.background_offset_y,L=(zi=F.anchor)!=null?zi:"center",Z=F.position_ratio;if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:_,bgRuntimeOffsetY:de,bgScreenAnchor:L,bgPositionRatio:Z,baseWidth:p,baseHeight:g,finalScale:y}),zt(c,p,g,{anchor:L,positionRatio:Z,offset:{x:_.x*y,y:_.y*y+de},renderAnchor:Ce(L)}),o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background position after applyScreenAnchor:",{x:c.x,y:c.y,scaleX:(Di=c.scale)==null?void 0:Di.x,scaleY:($i=c.scale)==null?void 0:$i.y,anchorX:(Hi=c.anchor)==null?void 0:Hi.x,anchorY:(Ni=c.anchor)==null?void 0:Ni.y,pivotX:(Fi=c.pivot)==null?void 0:Fi.x,pivotY:(Bi=c.pivot)==null?void 0:Bi.y,width:c.width,height:c.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 pt=Math.max(m/u.width,f/u.height),ut=(Gi=(Ui=b.background)==null?void 0:Ui.scale_multiplier)!=null?Gi:1.05,gt=(qi=F.scale)!=null?qi:1,ve=pt*ut*O.engine.background_scale*gt;c.scale&&(typeof c.scale.set=="function"?c.scale.set(ve):(c.scale.x=ve,c.scale.y=ve))}else c&&typeof c.clear=="function"&&(c.clear(),c.rect(-m/2,-f/2,m,f).fill({color:1444375}))}}function ma(i){var s,d,c;let{setState:e,updateLabelAlpha:t,updateHandAlpha:n,config:a,states:r}=i,o=((d=(s=a.engine)==null?void 0:s.runtime)==null?void 0:d.timeline)||{};e(r.showHook),setTimeout(()=>{t(1),n(1),e(r.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(c=o.tutorial_delay_ms)!=null?c: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:(ve=r.loop)!=null?ve:!1,autoplay:(we=r.autoplay)!=null?we:!0,animationData:d})}catch(q){return v.parentNode&&v.parentNode.removeChild(v),console.warn(`[LottieOverlay] Failed to start animation: ${i}`,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}}$t();fi();var Yt=class{constructor(e,t,n){this.systems=[];this.totalTime=0;this.context=null;this.root=e,this.config=t,this.destinationUrl=n}async createApp(e){if(this.context)return{app:this.app,gameObjectManager:this.gameObjectManager};let{app:t,stage:n}=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=n,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:n}=e.detail;this.resize(t,n)})}update(e){let t=e.deltaTime/60;this.totalTime+=t;for(let n of this.systems)n.update&&n.update(t,this.totalTime)}resize(e,t){for(let n of this.systems)n.onResize&&n.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(n=>n 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=_t(require("pixi.js"),1),sa=oa;typeof window!="undefined"&&(window.__basePixi=oa);gt();var ge=require("pixi.js");gt();var la=i=>i*Math.PI/180;function xr(i,e){var o,s,l,d,u;let t=e.ui;if(!(t!=null&&t.text))return null;let n="#ffffff";(o=e.render)!=null&&o.tint&&(n=e.render.tint);let a=new ge.TextStyle({fontFamily:(s=t.font)!=null?s:"Arial",fontSize:(l=t.fontSize)!=null?l:16,fill:n,align:(d=t.align)!=null?d:"center",letterSpacing:(u=t.letterSpacing)!=null?u:0}),r=new ge.Text({text:t.text,style:a});return r.label=i,r}function ca(i){var u,c,p,g,m,f,A,b,h,v;let{stage:e,mainContainer:t,activeConfig:n,gameObjectManager:a,allowList:r,denyList:o}=i,s={},l={},d={};t.sortableChildren=!0;for(let[w,y]of n.objects.entries()){if(o!=null&&o.has(w)||r&&!r.has(w)||(y==null?void 0:y.enabled)===!1)continue;let P=(c=(u=y==null?void 0:y.render)==null?void 0:u.asset)==null?void 0:c.path,_=(g=(p=y==null?void 0:y.render)==null?void 0:p.asset)==null?void 0:g.type,B=!!(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=xr(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=la(G),T.parent||t.addChild(T);try{a.create(w,T)}catch{}s[w]=T,d[w]=T}else if(z==="png"){let T=Te[w]||(typeof ge.Texture!="undefined"?ge.Texture.EMPTY:void 0),E=new ge.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 ie=typeof(C==null?void 0:C.rotation)=="number"?C.rotation:0;E.rotation=la(ie),E.parent||t.addChild(E);try{a.create(w,E)}catch{}s[w]=E,l[w]=E}}}return t.parent||e.addChild(t),{objects:s,sprites:l,texts:d}}var Di=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 n=async a=>{a.length&&(console.log("[Assets] Loading objects:",a),await Promise.all(a.map(async r=>{var s;let o=this.registry.get(r);if(!o){console.warn("[Assets] No config found for object:",r);return}try{let l=await Le.create(r,o,this.app);this.instanceCache.set(r,l),console.log("[Assets] Loaded object:",r,(s=l==null?void 0:l.constructor)==null?void 0:s.name)}catch(l){console.error("[Assets] Failed to load object:",r,l)}})))};return this.readyPromise=(async()=>{await n(t);let a=this.registry.getAllIds().filter(r=>!this.instanceCache.has(r));a.length>0&&(console.warn("[Assets] Retrying missing assets:",a),await n(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 n=await Le.create(e,t,this.app);this.instanceCache.set(e,n)}}get(e){return this.instanceCache.get(e)}},da=new Di,pa=new Proxy(da,{get(i,e){if(e in i&&typeof i[e]=="function")return i[e].bind(i);if(i.get(e))return i.get(e)}});function ua(i,e){da.init(i,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"),he={width:400,height:600,designWidth:400,scaleFactor:1},Tt={scale:1,position:1},ei=[];function Er(i,e,t,n,a,r,o){ei.push({element:i,originalScale:r,positionHelper:e,heightPercent:a}),e(i,t,n,a,r,o,!1)}function Sr(){ei.forEach(({element:i,originalScale:e,positionHelper:t,heightPercent:n})=>{let a=e*he.scaleFactor;t(i,he.width,he.height,n,a,!0,!1)})}function ga(){ei.length=0,console.log("[LAYOUT] Cleared all responsive elements")}function Jt(i,e){console.log(`[SCREEN] updateScreenState called: ${i}x${e}`),he.width=i,he.height=e,he.scaleFactor=Math.min(i/he.designWidth,1.15),Tt.scale=he.scaleFactor,Tt.position=1,console.log(`[SCREEN] Global multipliers - scale: ${Tt.scale.toFixed(3)}`),Sr()}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 Ar(i,e,t){let n=j[i];n&&n[e]!==void 0&&(n[e]=t,console.log(`Updated ${i}.${e} = ${t}`))}function Cr(){return j}var Tr={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(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function De(i,e={x:.5,y:.5}){var t;if(Array.isArray(i))return{x:Xt(i[0],e.x),y:Xt(i[1],e.y)};if(i&&typeof i=="object"){let n=i;return{x:Xt(n.x,e.x),y:Xt(n.y,e.y)}}if(typeof i=="string"){let n=i.trim().toLowerCase();return(t=Tr[n])!=null?t:e}return e}function et(i,e,t,n={}){var g,m,f,A,b,h;let a=De(t),r=(g=n.inset)!=null?g:{},o=(m=n.padding)!=null?m:{x:0,y:0},s=((f=r.left)!=null?f:0)+o.x,l=((A=r.right)!=null?A:0)+o.x,d=((b=r.top)!=null?b:0)+o.y,u=((h=r.bottom)!=null?h:0)+o.y,c=Math.max(0,i-s-l),p=Math.max(0,e-d-u);return{x:s+c*a.x,y:d+p*a.y}}function tt(i,e,t,n={}){var f,A,b,h,v,w;let a=(f=n.inset)!=null?f:{},r=(A=n.padding)!=null?A:{x:0,y:0},o=((b=a.left)!=null?b:0)+r.x,s=((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,i-o-s),c=Math.max(0,e-l-d),p=De(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:o+u*g,y:l+c*m}}function Zt(i,e,t,n={}){var u,c,p;if(!i)return;let a=n.positionRatio?tt(e,t,n.positionRatio,{inset:n.inset,padding:n.screenPadding}):et(e,t,n.anchor,{inset:n.inset,padding:n.screenPadding}),r=(u=n.offset)!=null?u:{x:0,y:0},o=a.x+r.x,s=a.y+r.y;i.anchor&&n.renderAnchor&&i.anchor.set(n.renderAnchor.x,n.renderAnchor.y),te(i,o,s);let l=(c=n.scale)!=null?c:1,d=(p=n.scaleMultiplier)!=null?p:1;(n.scale!==void 0||n.scaleMultiplier!==void 0)&&se(i,l*d)}if(typeof window!="undefined"){let i=window.innerWidth,e=window.innerHeight,t=()=>{let n=window.innerWidth,a=window.innerHeight;(n!==i||a!==e)&&(i=n,e=a,Jt(n,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=Ar,window.getDebugConfig=Cr,window.copyConfig=Dr,window.applyConfig=Ct,window.applyConfigForRatio=$r,window.positionAtBottom=ha,window.positionAtTop=Pr,window.positionAtCenter=Mr,window.positionAtLeft=_r,window.positionAtRight=Or,window.positionAtBottomLeft=Ir,window.positionAtBottomRight=jr,window.positionAtTopLeft=Rr,window.positionAtTopRight=zr,window.applyPositionContract=kr,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 ti(i,e,t=0){return i*e+t}function ii(i,e,t=0){return i*(1-e)+t}function ni(i,e,t=0){return i*e+t}function ai(i,e,t=0){return i*(1-e)+t}function Q(i,e=0){return i/2+e}function Lr(i,e){return i*e}function kr(i,e,t,n){var o,s,l,d,u,c,p,g,m,f,A,b,h,v,w,y,P,_,B,R;let a=0,r=0;switch(n.type){case"top":a=Q(e,(s=(o=n.offset)==null?void 0:o.x)!=null?s:0),r=ti(t,n.percent,(d=(l=n.offset)==null?void 0:l.y)!=null?d:0);break;case"bottom":a=Q(e,(c=(u=n.offset)==null?void 0:u.x)!=null?c:0),r=ii(t,n.percent,(g=(p=n.offset)==null?void 0:p.y)!=null?g:0);break;case"left":a=ni(e,n.percent,(f=(m=n.offset)==null?void 0:m.x)!=null?f:0),r=Q(t,(b=(A=n.offset)==null?void 0:A.y)!=null?b:0);break;case"right":a=ai(e,n.percent,(v=(h=n.offset)==null?void 0:h.x)!=null?v:0),r=Q(t,(y=(w=n.offset)==null?void 0:w.y)!=null?y:0);break;case"center":a=Q(e,(_=(P=n.offset)==null?void 0:P.x)!=null?_:0),r=Q(t,(R=(B=n.offset)==null?void 0:B.y)!=null?R:0);break}i.position?i.position.set(a,r):(i.x=a,i.y=r),n.scale!==void 0&&n.scale!==1&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(n.scale,n.scale):(i.scale.x=n.scale,i.scale.y=n.scale))}function ha(i,e,t,n=.2,a=1,r=!0,o=!1){let s=Lr(t,n),l=ii(t,n/2);te(i,Q(e),l);let d=r?a*he.scaleFactor:a;se(i,d),o&&!ei.find(u=>u.element===i)&&Er(i,ha,e,t,n,a,r)}function Pr(i,e,t,n=.1,a=1){te(i,Q(e),ti(t,n)),se(i,a)}function Mr(i,e,t,n=0,a=0,r=1){te(i,Q(e,n),Q(t,a)),se(i,r)}function _r(i,e,t,n=.1,a=1){te(i,ni(e,n),Q(t)),se(i,a)}function Or(i,e,t,n=.1,a=1){te(i,ai(e,n),Q(t)),se(i,a)}function Ir(i,e,t,n=.05,a=.05,r=1){te(i,ni(e,a),ii(t,n)),se(i,r)}function jr(i,e,t,n=.05,a=.05,r=1){te(i,ai(e,a),ii(t,n)),se(i,r)}function Rr(i,e,t,n=.05,a=.05,r=1){te(i,ni(e,a),ti(t,n)),se(i,r)}function zr(i,e,t,n=.05,a=.05,r=1){te(i,ai(e,a),ti(t,n)),se(i,r)}function te(i,e,t){i&&i.position?typeof i.position.set=="function"?i.position.set(e,t):(i.position.x=e,i.position.y=t):i&&(i.x=e,i.y=t)}function se(i,e){e!==1&&i&&i.scale&&(typeof i.scale.set=="function"?i.scale.set(e,e):i.scale.x!==void 0&&i.scale.y!==void 0&&(i.scale.x=e,i.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(i){return i&&ze[i]?JSON.parse(JSON.stringify(ze[i])):JSON.parse(JSON.stringify(j))}function Ct(i){Object.keys(i).forEach(e=>{let t=e;j[t]&&i[t]&&Object.assign(j[t],i[t])}),console.log("Config applied:",i)}function $r(i,e){let t=i/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 i=window;i.configPresets=ze,i.resolveAnchorVec2=i.resolveAnchorVec2||De,i.resolveScreenAnchorPoint=i.resolveScreenAnchorPoint||et,i.resolveScreenRatioPoint=i.resolveScreenRatioPoint||tt}var Y=null;function fa(i,e,t,n,a,r={}){var G,ie,fe,me,be,ye,ve,we,q,Pe,it,nt,at,rt,ot,st,lt,ct,dt,pt,N,K,U,X,$e,Me,$i,Hi,Ni,Fi,Bi,Ui,Gi,qi;let o=(G=r.enableDebugLogs)!=null?G:!1;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== STARTING LAYOUT CALCULATION ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Screen dimensions:",{width:n.width,height:n.height}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Time:",t),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Options:",r));let{mainContainer:s,label:l,background:d,backgroundTexture:u,app:c}=i;if(!c||!c.renderer){o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] \u274C No app or renderer, skipping layout");return}o&&(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=n.width,g=n.height;o&&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||{};o&&(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*((ie=j.engine.scale)!=null?ie:1),P=(fe=r.skipMainContainerTransform)!=null?fe:!1;!P&&s&&s.scale&&(typeof s.scale.set=="function"?s.scale.set(y):(s.scale.x=y,s.scale.y=y));let _=(me=h.main_container_anchor)!=null?me:"center",B=(be=h.main_container_position_ratio)!=null?be:{x:.5,y:.5},R=(ye=h.main_container_offset)!=null?ye:{x:0,y:0},H=h.main_container_position_ratio?tt(p,g,B):et(p,g,_),z=H.x+R.x+j.layout.position_offset.x,T=H.y+R.y+j.layout.position_offset.y;if(!P&&s&&s.position&&(typeof s.position.set=="function"?s.position.set(z,T):(s.position.x=z,s.position.y=T)),a&&(s!=null&&s.toLocal))for(let[V,F]of e.objects.entries()){let O=F==null?void 0:F.transform;if(!O||((ve=O.position_mode)!=null?ve:"static")!=="static")continue;let k=(we=a.get)==null?void 0:we.call(a,V),ne=((q=k==null?void 0:k.getDisplayObject)==null?void 0:q.call(k))||(k==null?void 0:k.pixiObject)||k;if(!ne||ne.parent!==s)continue;let Lt=O.position_ratio!=null?tt(p,g,O.position_ratio):et(p,g,(Pe=O.anchor)!=null?Pe:"center"),kt=s.toLocal(new Qt.Point(Lt.x,Lt.y)),Pt=(it=O.position)!=null?it:{x:0,y:0},_e=kt.x+Pt.x,ri=kt.y+Pt.y;typeof(k==null?void 0:k.setPosition)=="function"?k.setPosition(_e,ri):(te(ne,_e,ri),(nt=k==null?void 0:k.transform)!=null&&nt.position&&(k.transform.position.x=_e,k.transform.position.y=ri))}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,O=(p-4)*V,xe=(g-4)*F,k=(p-O)/2,ne=(g-xe)/2;o&&(console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== DEBUG RECT POSITIONING ====="),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect calculations:",{baseWidth:p,baseHeight:g,rectW:O,rectH:xe,offsetX:k,offsetY:ne}),console.log("\u{1F3AF} [LAYOUT_DEBUGS] Debug rect final position:",{x:2+k,y:2+ne,width:O,height:xe})),Y.rect(2+k,2+ne,O,xe).stroke({width:j.layout.debug_rect_thickness,color:j.layout.debug_rect_color})}else Y&&(Y.destroy(),Y=null);let L=((at=i.label)==null?void 0:at.config)||e.objects.get("label_1")||e.objects.get("ui_tutorial_1");if(l&&l.position&&L){let V=(ot=(rt=L==null?void 0:L.transform)==null?void 0:rt.anchor)!=null?ot:"center",F=(st=L==null?void 0:L.transform)==null?void 0:st.position_ratio,O=((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:O.x*y,y:O.y*y},renderAnchor:De(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,O=V*y*F;l.scale&&(typeof l.scale.set=="function"?l.scale.set(O):(l.scale.x=O,l.scale.y=O))}if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] ===== BACKGROUND POSITIONING ====="),d){o&&(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,o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background alpha set to:",d.alpha);let V=e.objects.get("background_1");o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background config:",V);let F=(V==null?void 0:V.transform)||{};o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background transform:",F);let O=F.offset||{x:0,y:0},xe=((X=(U=b.background)==null?void 0:U.offset_y)!=null?X:0)+j.engine.background_offset_y,k=($e=F.anchor)!=null?$e:"center",ne=F.position_ratio;if(o&&console.log("\u{1F3AF} [LAYOUT_DEBUGS] Background positioning params:",{bgOffset:O,bgRuntimeOffsetY:xe,bgScreenAnchor:k,bgPositionRatio:ne,baseWidth:p,baseHeight:g,finalScale:y}),Zt(d,p,g,{anchor:k,positionRatio:ne,offset:{x:O.x*y,y:O.y*y+xe},renderAnchor:De(k)}),o&&(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:($i=d.scale)==null?void 0:$i.y,anchorX:(Hi=d.anchor)==null?void 0:Hi.x,anchorY:(Ni=d.anchor)==null?void 0:Ni.y,pivotX:(Fi=d.pivot)==null?void 0:Fi.x,pivotY:(Bi=d.pivot)==null?void 0:Bi.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=(Gi=(Ui=b.background)==null?void 0:Ui.scale_multiplier)!=null?Gi:1.05,Pt=(qi=F.scale)!=null?qi:1,_e=Lt*kt*j.engine.background_scale*Pt;d.scale&&(typeof d.scale.set=="function"?d.scale.set(_e):(d.scale.x=_e,d.scale.y=_e))}else d&&typeof d.clear=="function"&&(d.clear(),d.rect(-m/2,-f/2,m,f).fill({color:1444375}))}}function ma(i){var s,l,d;let{setState:e,updateLabelAlpha:t,updateHandAlpha:n,config:a,states:r}=i,o=((l=(s=a.engine)==null?void 0:s.runtime)==null?void 0:l.timeline)||{};e(r.showHook),setTimeout(()=>{t(1),n(1),e(r.waitInput),console.log("[GAME] \u23F3 Game ready for user input - tutorial shown")},(d=o.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});
|