handler-playable-sdk 0.1.8 → 0.1.10

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.
@@ -0,0 +1,17 @@
1
+ var u={};function I(e,t,n=!1){u[e]||(u[e]=[]),u[e].push({fn:t,once:n})}function V(e,t){if(u[e]){if(!t){delete u[e];return}u[e]=u[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=u[e];if(n)for(let i of[...n])i.fn(...t),i.once&&V(e,i.fn)}function a(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.1.10",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var s=0,Se=s++,Z=s++,ee=s++,te=s++,ne=s++,ie=s++,oe=s++,re=s++,ae=s++,se=s++,de=s++,le=s++,r=Se;function ce(){return r===Z}function ue(){return r===ee}function fe(){return r===te}function pe(){return r===ne}function g(){return r===ie}function y(){return r===oe}function me(){return r===re}function ge(){return r===ae}function ye(){return r===se}function H(){return r===de}function F(){return r===le}function we(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=Z;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=ee;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=te)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ne)}catch{}else if(t==="mintegral")window.gameReady&&(r=ie);else if(t==="tapjoy")window.TJ_API&&(r=oe);else if(t==="tiktok")window.openAppStore&&(r=re);else if(t==="smadex")try{window.smxTracking&&(r=ae)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=se)}catch{}else t==="vungle"?r=de:(e==="nucleo"||t==="nucleo")&&(r=le)}var Ee={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"},Ce=Math.random().toString(36).slice(2),w=null,A={...Ee},Ae="web_embed",De={},G=!1,E=!1,T=!1,ke=!1,B=1,W=0,z=!1,d=!1,j="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),K=h>b,l=!1,k=!1,he=!1,be=!1,U=!1,M=null;function _e(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function N(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Te(e,t){return{event_name:e,ts:Date.now(),session_id:Ce,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:Ae==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=N(e),i=Te(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){B=e,o("volume",e)}function v(e){e&&(ke=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&ke||T&&(T=!1,o("resume"),_(B))}function p(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),K=h>b,o("resize",{width:h,height:b})}function Le(){if(ce())try{let e=mraid.getMaxSize();p(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();p(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ie(){if(ue())try{let e=dapi.getScreenSize();p(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();p(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())l=!0,o("boot"),o("view"),o("ready"),d=!0,O();else{let n=()=>{l=!0,o("boot"),o("view"),o("ready"),d=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function ve(){let e=()=>{l||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(l=!0,o("boot"),o("view"),o("ready"),d=!0,O(),k&&(k=!1,f.start()))};window.addEventListener("resize",()=>p()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function Pe(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(he=!0),!(he&&t instanceof MouseEvent)&&(W+=1,o("interaction",W))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Re(e){var i,c,x,C,J,D,q,L,$,X,Y,Q;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(c=window.TJ_API)==null?void 0:c.click)==null||x.call(c);else if(fe())(J=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||J.call(C);else if(ye())(q=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||q.call(D);else if(ge())try{($=(L=window.smxTracking)==null?void 0:L.redirect)==null||$.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(pe()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||j||""):e&&window.open(e)}else g()?(X=window.install)==null||X.call(window):me()?(Y=window.openAppStore)==null||Y.call(window):H()?(Q=parent==null?void 0:parent.postMessage)==null||Q.call(parent,"download","*"):e&&window.open(e)}function Me(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;a("view",()=>t(n.mraid_viewable)),a("start",()=>t(n.game_viewable)),a("engagement",()=>t(n.engagement));let i=()=>t(n.complete);a("complete",i),I("engagement",c=>{var x;((x=c==null?void 0:c.payload)==null?void 0:x.count)>3&&i()}),a("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;a("view",()=>t(n.Ad_Load_Start)),a("start",()=>t(n.Ad_Viewable)),a("engagement",()=>t(n.First_Engagement)),a("complete",()=>t(n.Gameplay_Complete)),a("cta_click",()=>t(n.DSP_Click)),a("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ne(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{f.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function xe(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function je(){g()&&(window.mintGameStart=()=>{S(!0),p()},window.mintGameClose=()=>{v(!0)})}function ze(){if(!F())return;let e=window.NUC;!e||!e.trigger||(f.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,j)}),f.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var f={init(e={},t){if(Ae=e.profile||"web_embed",De=e.consent||{},A={...Ee,...e.ids||{}},w=e.rootEl||w,j=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,_e(),Ve(w),we(),Le(),Ie(),!z){if(document.readyState==="complete")ve();else if(!be){be=!0;let n=()=>{ve(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}Pe(),Me(),Ne(),je(),ze(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),l&&!d&&(o("boot"),o("view"),o("ready"),k&&(k=!1,f.start()),d=!0),d=l},getRoot(){return _e()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return K},get isReady(){return d},get isStarted(){return G},get isPaused(){return T},get isFinished(){return E},get volume(){return B},get interactions(){return W},on(e,t){I(N(e),t)},off(e,t){V(N(e),t)},start(){var e,t;if(!G){if(!l){k=!0;return}if(G=!0,o("start"),p(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:K?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):H()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&xe())},install(e){if(!E){E=!0,y()?(xe(),setTimeout(()=>f.install(e),300)):(o("complete"),setTimeout(()=>f.install(e),0));return}U||(U=!0,setTimeout(()=>U=!1,500),o("cta_click"),o("conversion"),Re(e||j))},emit(e,t){let n=N(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Te(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(F()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){p(e,t)}},Be=f;function Ve(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
2
+ (function(){
3
+ var events = ['touchstart','touchend','mousedown','keydown'];
4
+ function unlock(){
5
+ if(window.AudioContext && AudioContext.prototype.resume){
6
+ if(!window.__handler_audio_ctx){
7
+ window.__handler_audio_ctx = new AudioContext();
8
+ }
9
+ if(window.__handler_audio_ctx.state === 'suspended'){
10
+ window.__handler_audio_ctx.resume();
11
+ }
12
+ }
13
+ events.forEach(function(e){ document.removeEventListener(e, unlock); });
14
+ }
15
+ events.forEach(function(e){ document.addEventListener(e, unlock, false); });
16
+ })();
17
+ `,e.appendChild(t)}export{f as a,Be as b};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var V=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ce(t))!De.call(e,a)&&a!==n&&V(e,a,{get:()=>t[a],enumerable:!(i=Se(t,a))||i.enumerable});return e};var Pe=e=>Ie(V({},"__esModule",{value:!0}),e);var qe={};Le(qe,{Handler:()=>u,default:()=>Be});module.exports=Pe(qe);var f={};function I(e,t,n=!1){f[e]||(f[e]=[]),f[e].push({fn:t,once:n})}function H(e,t){if(f[e]){if(!t){delete f[e];return}f[e]=f[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=f[e];if(n)for(let i of[...n])i.fn(...t),i.once&&H(e,i.fn)}function s(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.1.8",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var d=0,Me=d++,ee=d++,te=d++,ne=d++,ie=d++,oe=d++,re=d++,ae=d++,se=d++,de=d++,le=d++,ce=d++,r=Me;function ue(){return r===ee}function fe(){return r===te}function pe(){return r===ne}function me(){return r===ie}function g(){return r===oe}function y(){return r===re}function ge(){return r===ae}function ye(){return r===se}function we(){return r===de}function F(){return r===le}function G(){return r===ce}function he(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=ee;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=te;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=ne)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ie)}catch{}else if(t==="mintegral")window.gameReady&&(r=oe);else if(t==="tapjoy")window.TJ_API&&(r=re);else if(t==="tiktok")window.openAppStore&&(r=ae);else if(t==="smadex")try{window.smxTracking&&(r=se)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=de)}catch{}else t==="vungle"?r=le:(e==="nucleo"||t==="nucleo")&&(r=ce)}var Ae={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"},Ne=Math.random().toString(36).slice(2),w=null,A={...Ae},ke="web_embed",je={},U=!1,E=!1,T=!1,Te=!1,J=1,K=0,z=!1,l=!1,j="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),B=h>b,c=!1,k=!1,be=!1,_e=!1,W=!1,M=null;function ve(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function N(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Oe(e,t){return{event_name:e,ts:Date.now(),session_id:Ne,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:ke==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=N(e),i=Oe(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){J=e,o("volume",e)}function v(e){e&&(Te=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&Te||T&&(T=!1,o("resume"),_(J))}function p(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),B=h>b,o("resize",{width:h,height:b})}function ze(){if(ue())try{let e=mraid.getMaxSize();p(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();p(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ve(){if(fe())try{let e=dapi.getScreenSize();p(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();p(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function xe(){let e=()=>{c||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(c=!0,o("boot"),o("view"),o("ready"),l=!0,O(),k&&(k=!1,u.start()))};window.addEventListener("resize",()=>p()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function He(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(be=!0),!(be&&t instanceof MouseEvent)&&(K+=1,o("interaction",K))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Fe(e){var i,a,x,C,q,D,$,L,X,Y,Q,Z;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(a=window.TJ_API)==null?void 0:a.click)==null||x.call(a);else if(pe())(q=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||q.call(C);else if(we())($=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||$.call(D);else if(ye())try{(X=(L=window.smxTracking)==null?void 0:L.redirect)==null||X.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(me()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||j||""):e&&window.open(e)}else g()?(Y=window.install)==null||Y.call(window):ge()?(Q=window.openAppStore)==null||Q.call(window):F()?(Z=parent==null?void 0:parent.postMessage)==null||Z.call(parent,"download","*"):e&&window.open(e)}function Ge(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;s("view",()=>t(n.mraid_viewable)),s("start",()=>t(n.game_viewable)),s("engagement",()=>t(n.engagement));let i=()=>t(n.complete);s("complete",i),I("engagement",a=>{var x;((x=a==null?void 0:a.payload)==null?void 0:x.count)>3&&i()}),s("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;s("view",()=>t(n.Ad_Load_Start)),s("start",()=>t(n.Ad_Viewable)),s("engagement",()=>t(n.First_Engagement)),s("complete",()=>t(n.Gameplay_Complete)),s("cta_click",()=>t(n.DSP_Click)),s("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ue(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{u.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Ee(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function We(){g()&&(window.mintGameStart=()=>{S(!0),p()},window.mintGameClose=()=>{v(!0)})}function Ke(){if(!G())return;let e=window.NUC;!e||!e.trigger||(u.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,j)}),u.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var u={init(e={},t){if(ke=e.profile||"web_embed",je=e.consent||{},A={...Ae,...e.ids||{}},w=e.rootEl||w,j=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,ve(),Je(w),he(),ze(),Ve(),!z){if(document.readyState==="complete")xe();else if(!_e){_e=!0;let n=()=>{xe(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}He(),Ge(),Ue(),We(),Ke(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),c&&!l&&(o("boot"),o("view"),o("ready"),k&&(k=!1,u.start()),l=!0),l=c},getRoot(){return ve()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return B},get isReady(){return l},get isStarted(){return U},get isPaused(){return T},get isFinished(){return E},get volume(){return J},get interactions(){return K},on(e,t){I(N(e),t)},off(e,t){H(N(e),t)},start(){var e,t;if(!U){if(!c){k=!0;return}if(U=!0,o("start"),p(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:B?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):F()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&Ee())},install(e){if(!E){E=!0,y()?(Ee(),setTimeout(()=>u.install(e),300)):(o("complete"),setTimeout(()=>u.install(e),0));return}W||(W=!0,setTimeout(()=>W=!1,500),o("cta_click"),o("conversion"),Fe(e||j))},emit(e,t){let n=N(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Oe(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(G()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){p(e,t)}},Be=u;function Je(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
1
+ "use strict";var V=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ce(t))!De.call(e,a)&&a!==n&&V(e,a,{get:()=>t[a],enumerable:!(i=Se(t,a))||i.enumerable});return e};var Pe=e=>Ie(V({},"__esModule",{value:!0}),e);var qe={};Le(qe,{Handler:()=>u,default:()=>Be});module.exports=Pe(qe);var f={};function I(e,t,n=!1){f[e]||(f[e]=[]),f[e].push({fn:t,once:n})}function H(e,t){if(f[e]){if(!t){delete f[e];return}f[e]=f[e].filter(n=>n.fn!==t)}}function P(e,...t){let n=f[e];if(n)for(let i of[...n])i.fn(...t),i.once&&H(e,i.fn)}function s(e,t){I(e,t,!0)}var R={name:"handler-playable-sdk",version:"0.1.10",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var d=0,Me=d++,ee=d++,te=d++,ne=d++,ie=d++,oe=d++,re=d++,ae=d++,se=d++,de=d++,le=d++,ce=d++,r=Me;function ue(){return r===ee}function fe(){return r===te}function pe(){return r===ne}function me(){return r===ie}function g(){return r===oe}function y(){return r===re}function ge(){return r===ae}function ye(){return r===se}function we(){return r===de}function F(){return r===le}function G(){return r===ce}function he(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),r=ee;return}catch{}else if(e==="dapi")try{dapi.isReady(),r=te;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(r=ne)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(r=ie)}catch{}else if(t==="mintegral")window.gameReady&&(r=oe);else if(t==="tapjoy")window.TJ_API&&(r=re);else if(t==="tiktok")window.openAppStore&&(r=ae);else if(t==="smadex")try{window.smxTracking&&(r=se)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(r=de)}catch{}else t==="vungle"?r=le:(e==="nucleo"||t==="nucleo")&&(r=ce)}var Ae={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"},Ne=Math.random().toString(36).slice(2),w=null,A={...Ae},ke="web_embed",je={},U=!1,E=!1,T=!1,Te=!1,J=1,K=0,z=!1,l=!1,j="",h=Math.floor(window.innerWidth),b=Math.floor(window.innerHeight),B=h>b,c=!1,k=!1,be=!1,_e=!1,W=!1,M=null;function ve(){if(w)return w;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),w=e,e}function N(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Oe(e,t){return{event_name:e,ts:Date.now(),session_id:Ne,deployment_id:A.deployment_id,variant_id:A.variant_id,export_profile_id:A.profile_id,instance_id:A.instance_id||"default",env:ke==="mraid"?"mraid":"web",payload:t}}function o(e,t){let n=N(e),i=Oe(n,t);P(n,i),n!==e&&P(e,i)}function O(){M&&(M(h,b),M=null)}function _(e){J=e,o("volume",e)}function v(e){e&&(Te=!0),!T&&(T=!0,o("pause"),_(0))}function S(e){!e&&Te||T&&(T=!1,o("resume"),_(J))}function p(e,t){h=Math.floor(e||window.innerWidth),b=Math.floor(t||window.innerHeight),B=h>b,o("resize",{width:h,height:b})}function ze(){if(ue())try{let e=mraid.getMaxSize();p(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?S():v()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();p(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();_(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&_(n>0?1:0)}),mraid.addEventListener("error",(n,i)=>{console.warn("mraid error:",n,"action:",i)}),z=!0,mraid.isViewable()&&mraid.getState()!=="hidden")c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function Ve(){if(fe())try{let e=dapi.getScreenSize();p(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?S():v()}),dapi.addEventListener("adResized",n=>{let i=dapi.getScreenSize();p(n.width||i.width,n.height||i.height)});let t=dapi.getAudioVolume();if(_(t?1:0),dapi.addEventListener("audioVolumeChange",n=>_(n?1:0)),z=!0,dapi.isViewable())c=!0,o("boot"),o("view"),o("ready"),l=!0,O();else{let n=()=>{c=!0,o("boot"),o("view"),o("ready"),l=!0,O()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function xe(){let e=()=>{c||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(c=!0,o("boot"),o("view"),o("ready"),l=!0,O(),k&&(k=!1,u.start()))};window.addEventListener("resize",()=>p()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(S(),e()):v()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),z=!0}function He(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(be=!0),!(be&&t instanceof MouseEvent)&&(K+=1,o("interaction",K))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function Fe(e){var i,a,x,C,q,D,$,L,X,Y,Q,Z;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(i=window.ExitApi)==null||i.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(y())(x=(a=window.TJ_API)==null?void 0:a.click)==null||x.call(a);else if(pe())(q=(C=window.FbPlayableAd)==null?void 0:C.onCTAClick)==null||q.call(C);else if(we())($=(D=window.ScPlayableAd)==null?void 0:D.onCTAClick)==null||$.call(D);else if(ye())try{(X=(L=window.smxTracking)==null?void 0:L.redirect)==null||X.call(L)}catch(m){console.warn("Smadex redirect failed",m)}else if(me()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||j||""):e&&window.open(e)}else g()?(Y=window.install)==null||Y.call(window):ge()?(Q=window.openAppStore)==null||Q.call(window):F()?(Z=parent==null?void 0:parent.postMessage)==null||Z.call(parent,"download","*"):e&&window.open(e)}function Ge(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let i=new Image;i.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;s("view",()=>t(n.mraid_viewable)),s("start",()=>t(n.game_viewable)),s("engagement",()=>t(n.engagement));let i=()=>t(n.complete);s("complete",i),I("engagement",a=>{var x;((x=a==null?void 0:a.payload)==null?void 0:x.count)>3&&i()}),s("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;s("view",()=>t(n.Ad_Load_Start)),s("start",()=>t(n.Ad_Viewable)),s("engagement",()=>t(n.First_Engagement)),s("complete",()=>t(n.Gameplay_Complete)),s("cta_click",()=>t(n.DSP_Click)),s("start",()=>{[5,10,15,20,25,30].forEach(i=>setTimeout(()=>t(n[`Spent_${i}_Seconds`]),i*1e3))})}}function Ue(){if(!y())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{u.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Ee(){var t,n,i;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(i=e==null?void 0:e.gameplayFinished)==null||i.call(e)}function We(){g()&&(window.mintGameStart=()=>{S(!0),p()},window.mintGameClose=()=>{v(!0)})}function Ke(){if(!G())return;let e=window.NUC;!e||!e.trigger||(u.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,j)}),u.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var u={init(e={},t){if(ke=e.profile||"web_embed",je=e.consent||{},A={...Ae,...e.ids||{}},w=e.rootEl||w,j=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(M=t),o("init"),document.body.oncontextmenu=()=>!1,ve(),Je(w),he(),ze(),Ve(),!z){if(document.readyState==="complete")xe();else if(!_e){_e=!0;let n=()=>{xe(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}He(),Ge(),Ue(),We(),Ke(),console.log(`%c @handler/playable-sdk %c v${R.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),c&&!l&&(o("boot"),o("view"),o("ready"),k&&(k=!1,u.start()),l=!0),l=c},getRoot(){return ve()},get version(){return R.version||"0.0.0"},get maxWidth(){return h},get maxHeight(){return b},get isLandscape(){return B},get isReady(){return l},get isStarted(){return U},get isPaused(){return T},get isFinished(){return E},get volume(){return J},get interactions(){return K},on(e,t){I(N(e),t)},off(e,t){H(N(e),t)},start(){var e,t;if(!U){if(!c){k=!0;return}if(U=!0,o("start"),p(),g())v(),(e=window.gameReady)==null||e.call(window);else if(y()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:B?"landscape":"portrait",buildID:R.version||"dev"})}}},finish(){var e,t;E||(E=!0,o("complete"),g()?(e=window.gameEnd)==null||e.call(window):F()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):y()&&Ee())},install(e){if(!E){E=!0,y()?(Ee(),setTimeout(()=>u.install(e),300)):(o("complete"),setTimeout(()=>u.install(e),0));return}W||(W=!0,setTimeout(()=>W=!1,500),o("cta_click"),o("conversion"),Fe(e||j))},emit(e,t){let n=N(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let i=Oe(n,t);P(n,i)},retry(){var e,t,n;if(g())(e=window.gameRetry)==null||e.call(window);else if(G()){let i=window.NUC;(n=(t=i==null?void 0:i.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}o("engagement",{action:"retry"})},pause(){v(!0)},resume(){S(!0)},resize(e,t){p(e,t)}},Be=u;function Je(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
2
2
  (function(){
3
3
  var events = ['touchstart','touchend','mousedown','keydown'];
4
4
  function unlock(){
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a,b}from"./chunk-5XZYWKIQ.mjs";export{a as Handler,b as default};
1
+ import{a,b}from"./chunk-LQX44TET.mjs";export{a as Handler,b as default};
@@ -1,4 +1,4 @@
1
- "use strict";var Ke=Object.defineProperty;var Ka=Object.getOwnPropertyDescriptor;var $a=Object.getOwnPropertyNames;var Ja=Object.prototype.hasOwnProperty;var Qa=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},Za=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $a(t))!Ja.call(e,o)&&o!==n&&Ke(e,o,{get:()=>t[o],enumerable:!(a=Ka(t,o))||a.enumerable});return e};var Ua=e=>Za(Ke({},"__esModule",{value:!0}),e);var bi={};Qa(bi,{GameObject:()=>Ae,GameObjectManager:()=>Ie,Renderer:()=>Ce,Transform:()=>Se,animateHandClick:()=>ia,animatePanelEntrance:()=>aa,createBrushTexture:()=>ca,createEndGamePanel:()=>na,createHandTutorial:()=>oa,createPixiBase:()=>Un,createTutorialLabel:()=>sa,getRegisteredFontIds:()=>ta,loadAsset:()=>at,loadCharacterFrames:()=>la,registerFont:()=>ea,resolveFont:()=>G,resolveFontWeight:()=>j,updateHandAnimation:()=>ra});module.exports=Ua(bi);var Zn=require("pixi.js");var ee={};function Re(e,t,n=!1){ee[e]||(ee[e]=[]),ee[e].push({fn:t,once:n})}function $e(e,t){if(ee[e]){if(!t){delete ee[e];return}ee[e]=ee[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=ee[e];if(n)for(let a of[...n])a.fn(...t),a.once&&$e(e,a.fn)}function W(e,t){Re(e,t,!0)}var He={name:"handler-playable-sdk",version:"0.1.8",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var N=0,ti=N++,Sn=N++,Cn=N++,An=N++,En=N++,kn=N++,Dn=N++,Pn=N++,Mn=N++,Fn=N++,Ln=N++,Rn=N++,_=ti;function zn(){return _===Sn}function Hn(){return _===Cn}function On(){return _===An}function Wn(){return _===En}function de(){return _===kn}function ue(){return _===Dn}function Nn(){return _===Pn}function Yn(){return _===Mn}function Bn(){return _===Fn}function Je(){return _===Ln}function Qe(){return _===Rn}function In(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),_=Sn;return}catch{}else if(e==="dapi")try{dapi.isReady(),_=Cn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(_=An)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(_=En)}catch{}else if(t==="mintegral")window.gameReady&&(_=kn);else if(t==="tapjoy")window.TJ_API&&(_=Dn);else if(t==="tiktok")window.openAppStore&&(_=Pn);else if(t==="smadex")try{window.smxTracking&&(_=Mn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(_=Fn)}catch{}else t==="vungle"?_=Ln:(e==="nucleo"||t==="nucleo")&&(_=Rn)}var Kn={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"},ni=Math.random().toString(36).slice(2),pe=null,be={...Kn},$n="web_embed",ai={},Ze=!1,_e=!1,xe=!1,Jn=!1,nt=1,et=0,Ye=!1,J=!1,Ne="",fe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),tt=fe>me,Q=!1,we=!1,Gn=!1,jn=!1,Ue=!1,Oe=null;function Vn(){if(pe)return pe;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),pe=e,e}function We(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Qn(e,t){return{event_name:e,ts:Date.now(),session_id:ni,deployment_id:be.deployment_id,variant_id:be.variant_id,export_profile_id:be.profile_id,instance_id:be.instance_id||"default",env:$n==="mraid"?"mraid":"web",payload:t}}function y(e,t){let n=We(e),a=Qn(n,t);ze(n,a),n!==e&&ze(e,a)}function Te(){Oe&&(Oe(fe,me),Oe=null)}function he(e){nt=e,y("volume",e)}function ye(e){e&&(Jn=!0),!xe&&(xe=!0,y("pause"),he(0))}function ve(e){!e&&Jn||xe&&(xe=!1,y("resume"),he(nt))}function ne(e,t){fe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),tt=fe>me,y("resize",{width:fe,height:me})}function ii(){if(zn())try{let e=mraid.getMaxSize();ne(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ve():ye()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ne(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();he(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&he(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Ye=!0,mraid.isViewable()&&mraid.getState()!=="hidden")Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function oi(){if(Hn())try{let e=dapi.getScreenSize();ne(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ve():ye()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();ne(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(he(t?1:0),dapi.addEventListener("audioVolumeChange",n=>he(n?1:0)),Ye=!0,dapi.isViewable())Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function qn(){let e=()=>{Q||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te(),we&&(we=!1,te.start()))};window.addEventListener("resize",()=>ne()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ve(),e()):ye()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ye=!0}function si(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(Gn=!0),!(Gn&&t instanceof MouseEvent)&&(et+=1,y("interaction",et))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function ri(e){var a,o,i,s,r,l,d,p,f,u,c,h;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(a=window.ExitApi)==null||a.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ue())(i=(o=window.TJ_API)==null?void 0:o.click)==null||i.call(o);else if(On())(r=(s=window.FbPlayableAd)==null?void 0:s.onCTAClick)==null||r.call(s);else if(Bn())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Yn())try{(f=(p=window.smxTracking)==null?void 0:p.redirect)==null||f.call(p)}catch(m){console.warn("Smadex redirect failed",m)}else if(Wn()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||Ne||""):e&&window.open(e)}else de()?(u=window.install)==null||u.call(window):Nn()?(c=window.openAppStore)==null||c.call(window):Je()?(h=parent==null?void 0:parent.postMessage)==null||h.call(parent,"download","*"):e&&window.open(e)}function li(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let a=new Image;a.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;W("view",()=>t(n.mraid_viewable)),W("start",()=>t(n.game_viewable)),W("engagement",()=>t(n.engagement));let a=()=>t(n.complete);W("complete",a),Re("engagement",o=>{var i;((i=o==null?void 0:o.payload)==null?void 0:i.count)>3&&a()}),W("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;W("view",()=>t(n.Ad_Load_Start)),W("start",()=>t(n.Ad_Viewable)),W("engagement",()=>t(n.First_Engagement)),W("complete",()=>t(n.Gameplay_Complete)),W("cta_click",()=>t(n.DSP_Click)),W("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function ci(){if(!ue())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Xn(){var t,n,a;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(a=e==null?void 0:e.gameplayFinished)==null||a.call(e)}function di(){de()&&(window.mintGameStart=()=>{ve(!0),ne()},window.mintGameClose=()=>{ye(!0)})}function ui(){if(!Qe())return;let e=window.NUC;!e||!e.trigger||(te.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ne)}),te.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var te={init(e={},t){if($n=e.profile||"web_embed",ai=e.consent||{},be={...Kn,...e.ids||{}},pe=e.rootEl||pe,Ne=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),y("init"),document.body.oncontextmenu=()=>!1,Vn(),pi(pe),In(),ii(),oi(),!Ye){if(document.readyState==="complete")qn();else if(!jn){jn=!0;let n=()=>{qn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}si(),li(),ci(),di(),ui(),console.log(`%c @handler/playable-sdk %c v${He.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),Q&&!J&&(y("boot"),y("view"),y("ready"),we&&(we=!1,te.start()),J=!0),J=Q},getRoot(){return Vn()},get version(){return He.version||"0.0.0"},get maxWidth(){return fe},get maxHeight(){return me},get isLandscape(){return tt},get isReady(){return J},get isStarted(){return Ze},get isPaused(){return xe},get isFinished(){return _e},get volume(){return nt},get interactions(){return et},on(e,t){Re(We(e),t)},off(e,t){$e(We(e),t)},start(){var e,t;if(!Ze){if(!Q){we=!0;return}if(Ze=!0,y("start"),ne(),de())ye(),(e=window.gameReady)==null||e.call(window);else if(ue()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:tt?"landscape":"portrait",buildID:He.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,y("complete"),de()?(e=window.gameEnd)==null||e.call(window):Je()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ue()&&Xn())},install(e){if(!_e){_e=!0,ue()?(Xn(),setTimeout(()=>te.install(e),300)):(y("complete"),setTimeout(()=>te.install(e),0));return}Ue||(Ue=!0,setTimeout(()=>Ue=!1,500),y("cta_click"),y("conversion"),ri(e||Ne))},emit(e,t){let n=We(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let a=Qn(n,t);ze(n,a)},retry(){var e,t,n;if(de())(e=window.gameRetry)==null||e.call(window);else if(Qe()){let a=window.NUC;(n=(t=a==null?void 0:a.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}y("engagement",{action:"retry"})},pause(){ye(!0)},resume(){ve(!0)},resize(e,t){ne(e,t)}},Be=te;function pi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
1
+ "use strict";var Ke=Object.defineProperty;var Ka=Object.getOwnPropertyDescriptor;var $a=Object.getOwnPropertyNames;var Ja=Object.prototype.hasOwnProperty;var Qa=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},Za=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $a(t))!Ja.call(e,o)&&o!==n&&Ke(e,o,{get:()=>t[o],enumerable:!(a=Ka(t,o))||a.enumerable});return e};var Ua=e=>Za(Ke({},"__esModule",{value:!0}),e);var bi={};Qa(bi,{GameObject:()=>Ae,GameObjectManager:()=>Ie,Renderer:()=>Ce,Transform:()=>Se,animateHandClick:()=>ia,animatePanelEntrance:()=>aa,createBrushTexture:()=>ca,createEndGamePanel:()=>na,createHandTutorial:()=>oa,createPixiBase:()=>Un,createTutorialLabel:()=>sa,getRegisteredFontIds:()=>ta,loadAsset:()=>at,loadCharacterFrames:()=>la,registerFont:()=>ea,resolveFont:()=>G,resolveFontWeight:()=>j,updateHandAnimation:()=>ra});module.exports=Ua(bi);var Zn=require("pixi.js");var ee={};function Re(e,t,n=!1){ee[e]||(ee[e]=[]),ee[e].push({fn:t,once:n})}function $e(e,t){if(ee[e]){if(!t){delete ee[e];return}ee[e]=ee[e].filter(n=>n.fn!==t)}}function ze(e,...t){let n=ee[e];if(n)for(let a of[...n])a.fn(...t),a.once&&$e(e,a.fn)}function W(e,t){Re(e,t,!0)}var He={name:"handler-playable-sdk",version:"0.1.10",description:"Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.mjs",require:"./dist/index.js"},"./pixi":{types:"./dist/pixi/index.d.ts",import:"./dist/pixi/index.mjs",require:"./dist/pixi/index.js"},"./three":{types:"./dist/three/index.d.ts",import:"./dist/three/index.mjs",require:"./dist/three/index.js"}},scripts:{build:"tsup src/index.ts src/pixi/index.ts src/three/index.ts --format cjs,esm --dts --clean --minify",lint:"eslint 'src/**/*.{ts,tsx}'",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},author:"Handler",license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/HandlerAIGames/handler-playable-sdk.git"},files:["dist","LICENSE","README.md"],peerDependencies:{"pixi.js":"^8.0.0",three:"^0.160.0"},peerDependenciesMeta:{"pixi.js":{optional:!0},three:{optional:!0}},devDependencies:{"@types/three":"^0.160.0",eslint:"^8.57.1","pixi.js":"^8.8.1",three:"^0.160.0","ts-node":"^10.9.2",tsup:"^8.4.0",typescript:"^5.7.2"}};var N=0,ti=N++,Sn=N++,Cn=N++,An=N++,En=N++,kn=N++,Dn=N++,Pn=N++,Mn=N++,Fn=N++,Ln=N++,Rn=N++,_=ti;function zn(){return _===Sn}function Hn(){return _===Cn}function On(){return _===An}function Wn(){return _===En}function de(){return _===kn}function ue(){return _===Dn}function Nn(){return _===Pn}function Yn(){return _===Mn}function Bn(){return _===Fn}function Je(){return _===Ln}function Qe(){return _===Rn}function In(){let e=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none",t=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed";if(e==="mraid")try{mraid.getState(),_=Sn;return}catch{}else if(e==="dapi")try{dapi.isReady(),_=Cn;return}catch{}if(t==="facebook")try{typeof FbPlayableAd!="undefined"&&(_=An)}catch{}else if(t==="google")try{typeof ExitApi!="undefined"&&(_=En)}catch{}else if(t==="mintegral")window.gameReady&&(_=kn);else if(t==="tapjoy")window.TJ_API&&(_=Dn);else if(t==="tiktok")window.openAppStore&&(_=Pn);else if(t==="smadex")try{window.smxTracking&&(_=Mn)}catch{}else if(t==="snapchat")try{window.ScPlayableAd&&(_=Fn)}catch{}else t==="vungle"?_=Ln:(e==="nucleo"||t==="nucleo")&&(_=Rn)}var Kn={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"},ni=Math.random().toString(36).slice(2),pe=null,be={...Kn},$n="web_embed",ai={},Ze=!1,_e=!1,xe=!1,Jn=!1,nt=1,et=0,Ye=!1,J=!1,Ne="",fe=Math.floor(window.innerWidth),me=Math.floor(window.innerHeight),tt=fe>me,Q=!1,we=!1,Gn=!1,jn=!1,Ue=!1,Oe=null;function Vn(){if(pe)return pe;let e=document.createElement("div");return e.id="handler-root",e.setAttribute("data-handler-root","true"),document.body.appendChild(e),pe=e,e}function We(e){switch(e){case"interaction":return"engagement";case"finish":return"complete";case"install":return"cta_click";default:return e}}function Qn(e,t){return{event_name:e,ts:Date.now(),session_id:ni,deployment_id:be.deployment_id,variant_id:be.variant_id,export_profile_id:be.profile_id,instance_id:be.instance_id||"default",env:$n==="mraid"?"mraid":"web",payload:t}}function y(e,t){let n=We(e),a=Qn(n,t);ze(n,a),n!==e&&ze(e,a)}function Te(){Oe&&(Oe(fe,me),Oe=null)}function he(e){nt=e,y("volume",e)}function ye(e){e&&(Jn=!0),!xe&&(xe=!0,y("pause"),he(0))}function ve(e){!e&&Jn||xe&&(xe=!1,y("resume"),he(nt))}function ne(e,t){fe=Math.floor(e||window.innerWidth),me=Math.floor(t||window.innerHeight),tt=fe>me,y("resize",{width:fe,height:me})}function ii(){if(zn())try{let e=mraid.getMaxSize();ne(e.width,e.height);let t=()=>{mraid.isViewable()&&mraid.getState()!=="hidden"?ve():ye()};if(mraid.addEventListener("viewableChange",t),mraid.addEventListener("stateChange",t),mraid.addEventListener("sizeChange",()=>{let n=mraid.getMaxSize();ne(n.width,n.height)}),mraid.getAudioVolume){let n=mraid.getAudioVolume();he(n?1:0)}if(mraid.addEventListener("audioVolumeChange",n=>{n!==null&&he(n>0?1:0)}),mraid.addEventListener("error",(n,a)=>{console.warn("mraid error:",n,"action:",a)}),Ye=!0,mraid.isViewable()&&mraid.getState()!=="hidden")Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};mraid.addEventListener("ready",n)}}catch(e){console.warn("MRAID hook skipped",e)}}function oi(){if(Hn())try{let e=dapi.getScreenSize();ne(e.width,e.height),dapi.addEventListener("viewableChange",n=>{n.isViewable?ve():ye()}),dapi.addEventListener("adResized",n=>{let a=dapi.getScreenSize();ne(n.width||a.width,n.height||a.height)});let t=dapi.getAudioVolume();if(he(t?1:0),dapi.addEventListener("audioVolumeChange",n=>he(n?1:0)),Ye=!0,dapi.isViewable())Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te();else{let n=()=>{Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te()};dapi.addEventListener("ready",n)}}catch(e){console.warn("DAPI hook skipped",e)}}function qn(){let e=()=>{Q||document.visibilityState==="visible"&&(document.readyState==="complete"||document.readyState==="interactive")&&(Q=!0,y("boot"),y("view"),y("ready"),J=!0,Te(),we&&(we=!1,te.start()))};window.addEventListener("resize",()=>ne()),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(ve(),e()):ye()}),document.readyState==="complete"||document.readyState==="interactive"?e():window.addEventListener("load",e),Ye=!0}function si(){let e=t=>{typeof TouchEvent!="undefined"&&t instanceof TouchEvent&&(Gn=!0),!(Gn&&t instanceof MouseEvent)&&(et+=1,y("interaction",et))};document.addEventListener("mousedown",e),document.addEventListener("touchstart",e)}function ri(e){var a,o,i,s,r,l,d,p,f,u,c,h;let t=typeof AD_PROTOCOL!="undefined"?AD_PROTOCOL:"none";if((typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed")==="google")try{(a=window.ExitApi)==null||a.exit();return}catch{}if(t==="mraid"&&typeof mraid!="undefined")mraid.open(e||"");else if(t==="dapi"&&typeof dapi!="undefined")dapi.openStoreUrl();else if(ue())(i=(o=window.TJ_API)==null?void 0:o.click)==null||i.call(o);else if(On())(r=(s=window.FbPlayableAd)==null?void 0:s.onCTAClick)==null||r.call(s);else if(Bn())(d=(l=window.ScPlayableAd)==null?void 0:l.onCTAClick)==null||d.call(l);else if(Yn())try{(f=(p=window.smxTracking)==null?void 0:p.redirect)==null||f.call(p)}catch(m){console.warn("Smadex redirect failed",m)}else if(Wn()){let m=window.ExitApi;m&&typeof m.exit=="function"?m.exit(e||Ne||""):e&&window.open(e)}else de()?(u=window.install)==null||u.call(window):Nn()?(c=window.openAppStore)==null||c.call(window):Je()?(h=parent==null?void 0:parent.postMessage)==null||h.call(parent,"download","*"):e&&window.open(e)}function li(){let e=typeof AD_NETWORK!="undefined"?AD_NETWORK:"web_embed",t=n=>{if(!n)return;let a=new Image;a.src=n};if(e==="bigabid"){let n=window.BIGABID_BIDTIMEMACROS;if(!n)return;W("view",()=>t(n.mraid_viewable)),W("start",()=>t(n.game_viewable)),W("engagement",()=>t(n.engagement));let a=()=>t(n.complete);W("complete",a),Re("engagement",o=>{var i;((i=o==null?void 0:o.payload)==null?void 0:i.count)>3&&a()}),W("cta_click",()=>t(n.click))}else if(e==="inmobi"){let n=window.INMOBI_DSPMACROS;if(!n)return;W("view",()=>t(n.Ad_Load_Start)),W("start",()=>t(n.Ad_Viewable)),W("engagement",()=>t(n.First_Engagement)),W("complete",()=>t(n.Gameplay_Complete)),W("cta_click",()=>t(n.DSP_Click)),W("start",()=>{[5,10,15,20,25,30].forEach(a=>setTimeout(()=>t(n[`Spent_${a}_Seconds`]),a*1e3))})}}function ci(){if(!ue())return;let e=window.TJ_API;e&&e.setPlayableAPI&&e.setPlayableAPI({skipAd:()=>{try{te.finish()}catch(t){console.warn("Tapjoy skip failed",t)}}})}function Xn(){var t,n,a;let e=window.TJ_API;(t=e==null?void 0:e.objectiveComplete)==null||t.call(e),(n=e==null?void 0:e.playableFinished)==null||n.call(e),(a=e==null?void 0:e.gameplayFinished)==null||a.call(e)}function di(){de()&&(window.mintGameStart=()=>{ve(!0),ne()},window.mintGameClose=()=>{ye(!0)})}function ui(){if(!Qe())return;let e=window.NUC;!e||!e.trigger||(te.on("cta_click",()=>{var t,n;return(n=(t=e.trigger).convert)==null?void 0:n.call(t,Ne)}),te.on("complete",()=>{var t,n;return(n=(t=e.trigger).tryAgain)==null?void 0:n.call(t)}))}var te={init(e={},t){if($n=e.profile||"web_embed",ai=e.consent||{},be={...Kn,...e.ids||{}},pe=e.rootEl||pe,Ne=e.destinationUrl||(/android/i.test(navigator.userAgent)?"https://play.google.com/store":"https://www.apple.com/app-store/"),t&&(Oe=t),y("init"),document.body.oncontextmenu=()=>!1,Vn(),pi(pe),In(),ii(),oi(),!Ye){if(document.readyState==="complete")qn();else if(!jn){jn=!0;let n=()=>{qn(),window.removeEventListener("load",n),document.removeEventListener("DOMContentLoaded",n)};window.addEventListener("load",n),document.addEventListener("DOMContentLoaded",n)}}si(),li(),ci(),di(),ui(),console.log(`%c @handler/playable-sdk %c v${He.version||"0.0.0"} `,"background: #007acc; color: #fff; font-size: 14px; padding: 4px 8px; border-top-left-radius: 4px; border-bottom-left-radius: 4px;","background: #e1e4e8; color: #333; font-size: 14px; padding: 4px 8px; border-top-right-radius: 4px; border-bottom-right-radius: 4px;"),Q&&!J&&(y("boot"),y("view"),y("ready"),we&&(we=!1,te.start()),J=!0),J=Q},getRoot(){return Vn()},get version(){return He.version||"0.0.0"},get maxWidth(){return fe},get maxHeight(){return me},get isLandscape(){return tt},get isReady(){return J},get isStarted(){return Ze},get isPaused(){return xe},get isFinished(){return _e},get volume(){return nt},get interactions(){return et},on(e,t){Re(We(e),t)},off(e,t){$e(We(e),t)},start(){var e,t;if(!Ze){if(!Q){we=!0;return}if(Ze=!0,y("start"),ne(),de())ye(),(e=window.gameReady)==null||e.call(window);else if(ue()){let n=window.TJ_API;(t=n==null?void 0:n.setPlayableBuild)==null||t.call(n,{orientation:tt?"landscape":"portrait",buildID:He.version||"dev"})}}},finish(){var e,t;_e||(_e=!0,y("complete"),de()?(e=window.gameEnd)==null||e.call(window):Je()?(t=parent==null?void 0:parent.postMessage)==null||t.call(parent,"complete","*"):ue()&&Xn())},install(e){if(!_e){_e=!0,ue()?(Xn(),setTimeout(()=>te.install(e),300)):(y("complete"),setTimeout(()=>te.install(e),0));return}Ue||(Ue=!0,setTimeout(()=>Ue=!1,500),y("cta_click"),y("conversion"),ri(e||Ne))},emit(e,t){let n=We(e);if(!["view","boot","start","engagement","complete","cta_click","conversion","retry","pause","resume","resize","volume","error"].includes(n)&&!n.startsWith("custom."))throw new Error(`Event ${e} must be canonical or namespaced as custom.<mechanic_id>.<event>`);let a=Qn(n,t);ze(n,a)},retry(){var e,t,n;if(de())(e=window.gameRetry)==null||e.call(window);else if(Qe()){let a=window.NUC;(n=(t=a==null?void 0:a.trigger)==null?void 0:t.tryAgain)==null||n.call(t)}y("engagement",{action:"retry"})},pause(){ye(!0)},resume(){ve(!0)},resize(e,t){ne(e,t)}},Be=te;function pi(e){let t=document.createElement("script");t.type="text/javascript",t.textContent=`
2
2
  (function(){
3
3
  var events = ['touchstart','touchend','mousedown','keydown'];
4
4
  function unlock(){
@@ -1 +1 @@
1
- import{b as lt}from"../chunk-5XZYWKIQ.mjs";import{Application as Pn}from"pixi.js";async function Mn(e,t={}){let a=new Pn;await a.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let o=n=>{var c,d,p,u,h,l;let i=(p=(d=(c=n==null?void 0:n.width)!=null?c:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(l=(h=(u=n==null?void 0:n.height)!=null?u:e.clientHeight)!=null?h:window.innerHeight)!=null?l:480;a.renderer.resize(i,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(a.canvas);let s=document.createElement("div");return s.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(";")),e.appendChild(s),lt.on("pause",()=>{a.ticker.stop(),document.querySelectorAll("audio").forEach(i=>i.pause())}),lt.on("resume",()=>{a.ticker.start(),document.querySelectorAll("audio").forEach(i=>{i.currentTime>0&&!i.ended&&i.play().catch(()=>{})})}),lt.on("resize",({payload:n})=>{o({width:n==null?void 0:n.width,height:n==null?void 0:n.height})}),window.addEventListener("resize",()=>o()),requestAnimationFrame(()=>o()),{app:a,stage:a.stage,overlay:s,applySize:o}}var ct=class{constructor(t){var a,o;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(a=t==null?void 0:t.scale)!=null?a:1,this.rotation=(o=t==null?void 0:t.rotation)!=null?o:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},dt=class{constructor(t){var a,o,s,n;this.z_index=(a=t==null?void 0:t.z_index)!=null?a:0,this.alpha=(o=t==null?void 0:t.alpha)!=null?o:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(n=t==null?void 0:t.tint)!=null?n:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},ht=class{constructor(t,a,o,s){this.instanceId=t,this.objectConfig=a,this.pixiObject=o,this._config=s,this.transform=new ct(s.transform),this.renderer=new dt(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,a){this.transform.position={x:t,y:a},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},gt=class{constructor(t){this.objects=new Map;this.config=t}create(t,a){let o=this.config.objects.get(t);if(!o)throw new Error(`Object config not found: ${t}`);let s=new ht(t,o.object_config||t,a,o);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[a,o]of this.objects.entries()){let s=t.objects.get(a);s&&o.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var pt={"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 X(e){let t=pt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var a;let t=pt[e];return t&&(a=t.weight)!=null?a:"400"}function En(e,t){pt[e]=t}function Dn(){return Object.keys(pt)}import{Container as Yn,Graphics as ut,Text as tt,Sprite as Le,Texture as _t}from"pixi.js";function kn(e,t,a){var Dt,Yt,kt,zt,Ht,Wt,Bt,Rt,Lt,Gt,Nt,Xt,qt,$t,Vt,jt,Jt,Kt,Qt,Zt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,de,he,pe,ue,me,fe,ye,ge,_e,be,xe,we,Te,Ce,Se,ve,Ae,Fe,Pe,Me,Ee,De,Ye,ke,ze,He,We;let o=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),n=e.objects.get("ui_endgame_title_1"),i=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),c=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),u=e.engine.runtime||{},h=new Yn;h.alpha=0,h.visible=!1;let l=((Dt=o==null?void 0:o.gameplay)==null?void 0:Dt.tuning)||{},m=(o==null?void 0:o.render)||{},f=(Yt=l.panel_width)!=null?Yt:320,y=(kt=l.panel_height)!=null?kt:400,_=(zt=l.panel_padding)!=null?zt:32,b=(Ht=l.panel_radius)!=null?Ht:24,C=m.background_color||l.panel_bg_color||"#1a0a0a",x=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(Wt=l.panel_bg_alpha)!=null?Wt:.98,S=m.border_color||l.panel_border_color||"#ffffff",v=(Bt=l.panel_border_width)!=null?Bt:2,w=(Rt=l.panel_border_alpha)!=null?Rt:.3,T=new ut;T.roundRect(-f/2,-y/2,f,y,b);let g=C.replace("#","");T.fill({color:parseInt(g,16),alpha:x});let A=S.replace("#","");T.stroke({color:parseInt(A,16),width:v,alpha:w});let M=new ut;M.roundRect(-f/2+2,-y/2+2,f-4,y-4,b-2),M.stroke({color:16777215,width:1,alpha:.1}),T.addChild(M),h.addChild(T);let B=((Lt=s==null?void 0:s.gameplay)==null?void 0:Lt.tuning)||{},$=(s==null?void 0:s.transform)||{},z=(Gt=B.logo_size)!=null?Gt:56,R=(Nt=$.scale)!=null?Nt:1,j=(qt=(Xt=$.offset)==null?void 0:Xt.y)!=null?qt:-130,qe=($t=B.logo_alpha)!=null?$t:1,F=new Le(a||_t.EMPTY);F.anchor.set(.5);let K=0,Q=0;if(a&&a!==_t.EMPTY){let P=a.frame,N=a.baseTexture;P&&P.width&&P.height?(K=P.width,Q=P.height):N&&N.width&&N.height?(K=N.width,Q=N.height):a.width&&a.height&&(K=a.width,Q=a.height)}if(K>0&&Q>0){let P=K/Q,N,yt;P>1?(N=z,yt=z/P):(yt=z,N=z*P);let Be=N/K,Re=yt/Q;Be*=R,Re*=R,F.scale.set(Be,Re)}else{let P=z/100*R;F.scale.set(P)}F.position.set(0,j),F.alpha=0,F.visible=!0,F.targetAlpha=qe,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,h.addChild(F);let E=n==null?void 0:n.ui,H=((Vt=n==null?void 0:n.gameplay)==null?void 0:Vt.tuning)||{},$e=(E==null?void 0:E.text)||"MISSION ACCOMPLISHED",xt=(E==null?void 0:E.font)||"brand.heading",Ve=(E==null?void 0:E.fontSize)||24,je=(jt=E==null?void 0:E.letterSpacing)!=null?jt:1,et=(Jt=n==null?void 0:n.render)==null?void 0:Jt.tint,Je=typeof et=="string"?et:et?`#${et.toString(16).padStart(6,"0")}`:"#00FF88",wt=f-_*2-30,Ke=H.font_weight_override?H.font_weight_override:q(xt),V=new tt({text:$e,style:{fontFamily:X(xt),fontSize:Ve,fontWeight:Ke,fill:Je,align:"center",letterSpacing:je,wordWrap:!1,stroke:{color:H.stroke_color||"#000000",width:(Kt=H.stroke_width)!=null?Kt:2},dropShadow:{color:H.shadow_color||"#000000",alpha:(Qt=H.shadow_alpha)!=null?Qt:.9,angle:(Zt=H.shadow_angle)!=null?Zt:0,blur:(Ot=H.shadow_blur)!=null?Ot:8,distance:(It=H.shadow_distance)!=null?It:4}}});if(V.width>wt){let P=wt/V.width;V.scale.set(P)}V.anchor.set(.5);let Tt=(Ut=l.title_offset_y)!=null?Ut:30,Qe=Tt+((te=H.animation_start_y_offset)!=null?te:-20);V.position.set(0,Qe),V.alpha=0,h.addChild(V);let D=i==null?void 0:i.ui,Ct=((ee=i==null?void 0:i.gameplay)==null?void 0:ee.tuning)||{},Ze=(D==null?void 0:D.text)||"RESCUE COMPLETE",St=(D==null?void 0:D.font)||"brand.body",Oe=(D==null?void 0:D.fontSize)||11,Ie=(ne=D==null?void 0:D.letterSpacing)!=null?ne:.5,nt=(ae=i==null?void 0:i.render)==null?void 0:ae.tint,Ue=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=new tt({text:Ze,style:{fontFamily:X(St),fontSize:Oe,fontWeight:q(St),fill:Ue,align:"center",letterSpacing:Ie}});Z.anchor.set(.5);let tn=Tt+20+((se=Ct.animation_start_y_offset)!=null?se:-10);Z.position.set(0,tn),Z.alpha=0,Z.animationStartYOffset=(ie=Ct.animation_start_y_offset)!=null?ie:-10,h.addChild(Z);let L=r==null?void 0:r.ui,vt=((oe=r==null?void 0:r.gameplay)==null?void 0:oe.tuning)||{},en=(L==null?void 0:L.text)||((re=u.ui)==null?void 0:re.cta_hint)||"Continue the adventure!",At=(L==null?void 0:L.font)||"brand.body",nn=(L==null?void 0:L.fontSize)||16,at=(le=r==null?void 0:r.render)==null?void 0:le.tint,an=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#FFFFFF",sn=(ce=vt.max_width)!=null?ce:f-_*2,on=(de=vt.line_height)!=null?de:1.4,O=new tt({text:en,style:{fontFamily:X(At),fontSize:nn,fontWeight:q(At),fill:an,align:"center",wordWrap:!0,wordWrapWidth:sn,lineHeight:on}});O.anchor.set(.5);let rn=(he=l.footer_offset_y)!=null?he:120;O.position.set(0,rn);let ln=((pe=r==null?void 0:r.render)==null?void 0:pe.alpha)!==void 0&&((ue=r==null?void 0:r.render)==null?void 0:ue.alpha)!==null?r.render.alpha:1;O.alpha=0,O.targetAlpha=ln,h.addChild(O);let G=((me=c==null?void 0:c.gameplay)==null?void 0:me.tuning)||{},Y=c==null?void 0:c.ui,st=(fe=G.button_width)!=null?fe:260,it=(ye=G.button_height)!=null?ye:56,Ft=(ge=G.button_radius)!=null?ge:16,cn=G.button_bg_color||((_e=u.theme)==null?void 0:_e.cta_background)||"#ffb43b",dn=(be=G.button_bg_alpha)!=null?be:1,hn=G.button_border_color||"#ffffff",pn=(xe=G.button_border_width)!=null?xe:2,un=(we=G.button_border_alpha)!=null?we:.2,ot=(Te=l.cta_offset_y)!=null?Te:160,W=new ut;W.roundRect(-st/2,-it/2,st,it,Ft);let mn=cn.replace("#","");W.fill({color:parseInt(mn,16),alpha:dn});let fn=hn.replace("#","");W.stroke({color:parseInt(fn,16),width:pn,alpha:un});let mt=new ut;mt.roundRect(-st/2+2,-it/2+2,st-4,it-4,Ft-2),mt.stroke({color:0,width:1,alpha:.15}),W.addChild(mt),W.position.set(0,ot),W.alpha=0,W.eventMode="static",W.cursor="pointer",h.addChild(W);let yn=(Y==null?void 0:Y.text)||((Ce=u.ui)==null?void 0:Ce.cta_label_end)||"DOWNLOAD",Pt=(Y==null?void 0:Y.font)||"brand.heading",gn=(Y==null?void 0:Y.fontSize)||20,_n=G.button_text_color||((Se=u.theme)==null?void 0:Se.cta_text)||"#1a0a0a",U=new tt({text:yn,style:{fontFamily:X(Pt),fontSize:gn,fontWeight:q(Pt),fill:_n,align:"center",letterSpacing:(ve=Y==null?void 0:Y.letterSpacing)!=null?ve:1}});U.anchor.set(.5),U.position.set(0,ot),U.alpha=0,h.addChild(U);let k=d==null?void 0:d.ui,Mt=((Ae=d==null?void 0:d.gameplay)==null?void 0:Ae.tuning)||{},bn=(k==null?void 0:k.text)||"Play the full game",Et=(k==null?void 0:k.font)||"brand.body",xn=(k==null?void 0:k.fontSize)||11,wn=(Fe=k==null?void 0:k.letterSpacing)!=null?Fe:0,rt=(Pe=d==null?void 0:d.render)==null?void 0:Pe.tint,Tn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",I=new tt({text:bn,style:{fontFamily:X(Et),fontSize:xn,fontWeight:q(Et),fill:Tn,align:"center",letterSpacing:wn}});I.anchor.set(.5);let Cn=ot+35+((Me=Mt.animation_start_y_offset)!=null?Me:5);I.position.set(0,Cn),I.alpha=0,I.animationStartYOffset=(Ee=Mt.animation_start_y_offset)!=null?Ee:5,h.addChild(I);let ft=((De=p==null?void 0:p.gameplay)==null?void 0:De.tuning)||{},Sn=(Ye=ft.hand_offset_x)!=null?Ye:50,vn=(ke=ft.hand_offset_y)!=null?ke:50,An=(He=(ze=p==null?void 0:p.transform)==null?void 0:ze.scale)!=null?He:.1875,Fn=(We=ft.hand_scale_multiplier)!=null?We:2.5,J=new Le(t||_t.EMPTY);return J.anchor.set(.5),J.scale.set(An*Fn),J.position.set(Sn,ot+vn),J.alpha=0,J.visible=!1,h.addChild(J),{panel:h,logo:F,title:V,subtitle:Z,footer:O,ctaButton:W,ctaText:U,ctaHint:I,hand:J}}function zn(e,t,a){var v,w,T,g,A,M,B,$;let o=t.objects.get("ui_endgame_1"),s=((v=o==null?void 0:o.gameplay)==null?void 0:v.tuning)||{},n=(w=s.animation_duration_ms)!=null?w:800,i=(T=s.fade_in_duration_ms)!=null?T:600,r=(g=s.scale_animation_intensity)!=null?g:.1,c=(A=s.logo_animation_delay_ms)!=null?A:100,d=(M=s.title_animation_delay_ms)!=null?M:200,p=(B=s.footer_animation_delay_ms)!=null?B:300,u=($=s.cta_animation_delay_ms)!=null?$:400,{panel:h,logo:l,title:m,subtitle:f,footer:y,ctaButton:_,ctaText:b,ctaHint:C}=e;h.visible=!0;let x=Date.now(),S=()=>{let z=Date.now()-x,R=Math.min(z/i,1),j=1-Math.pow(1-R,3);h.alpha=j,h.scale.set(1+r*(1-j)),R<1?requestAnimationFrame(S):(setTimeout(()=>Hn(l,n,t),c),setTimeout(()=>{Wn(m,n),setTimeout(()=>Bn(f,n),50)},d),setTimeout(()=>Rn(y,n),p),setTimeout(()=>{Ln(_,b,n),setTimeout(()=>Gn(C,n),50),a&&a()},u))};S()}function Hn(e,t,a){var h,l,m,f,y;let o=a==null?void 0:a.objects.get("ui_endgame_logo_1"),n=(l=(((h=o==null?void 0:o.gameplay)==null?void 0:h.tuning)||{}).animation_start_scale)!=null?l:1.2,i=Date.now(),r=e.alpha,c=(m=e.targetAlpha)!=null?m:1,d=(f=e.baseScaleX)!=null?f:e.scale.x,p=(y=e.baseScaleY)!=null?y:e.scale.y,u=()=>{let _=Date.now()-i,b=Math.min(_/t,1),C=1-Math.pow(1-b,2);e.alpha=r+(c-r)*C;let x=n+(1-n)*C;e.scale.set(d*x,p*x),b<1&&requestAnimationFrame(u)};u()}function Wn(e,t){let a=Date.now(),o=e.alpha,s=e.y,n=()=>{let i=Date.now()-a,r=Math.min(i/t,1),c=1-Math.pow(1-r,2);e.alpha=o+(1-o)*c,e.y=s-20*(1-c),r<1&&requestAnimationFrame(n)};n()}function Bn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:-10),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Rn(e,t){var i;let a=Date.now(),o=e.alpha,s=(i=e.targetAlpha)!=null?i:1,n=()=>{let r=Date.now()-a,c=Math.min(r/t,1),d=1-Math.pow(1-c,2);e.alpha=o+(s-o)*d,c<1&&requestAnimationFrame(n)};n()}function Ln(e,t,a){let o=Date.now(),s=e.alpha,n=()=>{let i=Date.now()-o,r=Math.min(i/a,1),c=1-Math.pow(1-r,2);e.alpha=s+(1-s)*c,t.alpha=s+(1-s)*c,e.scale.set(1+.1*(1-c)),r<1&&requestAnimationFrame(n)};n()}function Gn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:5),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Nn(e,t,a,o){var p,u,h,l;let s=a.objects.get("ui_endgame_hand_1"),n=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},i=(u=n.click_animation_duration_ms)!=null?u:600,r=(h=n.click_delay_ms)!=null?h:2e3,c=(l=n.click_repeat_delay_ms)!=null?l:3e3,d=()=>{var v,w;e.visible=!0,e.alpha=1;let m=e.x,f=e.y,y=(v=n.hand_offset_x)!=null?v:50,_=(w=n.hand_offset_y)!=null?w:50,b=t.x+y,C=t.y+_,x=Date.now(),S=()=>{var z,R,j;let T=Date.now()-x,g=Math.min(T/i,1),A=g<.5?2*g*g:1-Math.pow(-2*g+2,2)/2;e.x=m+(b-m)*A,e.y=f+(C-f)*A;let M=(R=(z=s==null?void 0:s.transform)==null?void 0:z.scale)!=null?R:.1875,B=(j=n.hand_scale_multiplier)!=null?j:2.5,$=M*B;e.scale.set($+$*.2*Math.sin(g*Math.PI)),g<1?requestAnimationFrame(S):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),o()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=m,e.y=f,d()},c)},500))};S()};setTimeout(d,r)}import{Sprite as Xn,Text as qn}from"pixi.js";function $n(e,t,a){var p,u,h,l;let o=t.objects.get("hand_tutorial_1"),s=((p=o==null?void 0:o.gameplay)==null?void 0:p.tuning)||{},n=(o==null?void 0:o.render)||{},i=(o==null?void 0:o.transform)||{},r=new Xn(e);r.anchor.set(.5),r.alpha=0;let c=(u=s.hand_scale_multiplier)!=null?u:2.5,d=(h=i.scale)!=null?h:.1875;return r.scale.set(d*c),r.zIndex=(l=n.z_index)!=null?l:99999,r}function Vn(e){var m,f,y,_,b,C,x,S,v,w;let t=e.objects.get("ui_tutorial_1"),a=t==null?void 0:t.ui,o=(t==null?void 0:t.render)||{},s=((m=e.engine.runtime)==null?void 0:m.ui_styles)||{},n=((f=e.engine.runtime)==null?void 0:f.ui)||{},i=(a==null?void 0:a.text)||n.tutorial_label||n.label_text||"CLEAN!",r=(a==null?void 0:a.font)||"brand.warning",c=(a==null?void 0:a.fontSize)||s.label_font_size||52,d=(_=a==null?void 0:a.letterSpacing)!=null?_:(y=s.label_letter_spacing)!=null?y:-1,p=(a==null?void 0:a.align)||"center",u=o.tint,h=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",l=new qn({text:i,style:{fontFamily:X(r),fontSize:c,fontWeight:q(r),fill:h,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(b=s.label_shadow_alpha)!=null?b:.8,angle:(C=s.label_shadow_angle)!=null?C:0,blur:(x=s.label_shadow_blur)!=null?x:4,distance:(S=s.label_shadow_distance)!=null?S:2}}});return l.anchor.set(.5,0),l.alpha=(v=o.alpha)!=null?v:0,l.visible=(w=o.visible)!=null?w:!0,l}function jn(e,t,a,o,s){var c,d,p,u,h,l,m;let n=s.objects.get("hand_tutorial_1"),i=((c=n==null?void 0:n.gameplay)==null?void 0:c.tuning)||{},r=(n==null?void 0:n.transform)||{};if(!o){let f=(d=i.animation_duration)!=null?d:1.5,y=a%f/f,_=y<.5?2*y*y:-1+(4-2*y)*y,b=(p=i.x_offset)!=null?p:0,C=(u=i.y_offset)!=null?u:0,x=(h=i.animation_range)!=null?h:40,S=x*.7,v=x,w=t.x+b+S,T=t.y+C+v,g=w+S,A=T+v;e.x=w+(g-w)*_,e.y=T+(A-T)*_;let M=(l=r.scale)!=null?l:.1875,B=(m=i.hand_scale_multiplier)!=null?m:2.5;e.scale.set(M*B)}}import{Graphics as Ge,Assets as Ne,Texture as Jn,Rectangle as Kn,Color as bt}from"pixi.js";async function Xe(e,t,a=16777215,o=!1){try{let n=(globalThis.INLINE_ASSETS||{})[e];return await Ne.load(n||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let n=new Ge;return o?n.roundRect(0,0,60,120,10).fill({color:a}):(n.circle(30,30,30).fill({color:a}),n.rect(25,30,10,40).fill({color:a})),t.renderer.generateTexture(n)}}async function Qn(e,t,a){var f,y,_,b,C,x,S,v,w,T;let s=(globalThis.INLINE_ASSETS||{})[e]||e,n;try{n=await Ne.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(g){let M=(a.gameplay.character_sheet||{}).fallback_color||"#ff00ff";n=await Xe(e,t,new bt(M).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:g})}let i=n.source||n.baseTexture||n;i&&"valid"in i&&i.valid===!1&&typeof i.once=="function"&&await new Promise(g=>i.once("loaded",g));let r=a.gameplay.character_sheet||{},c=(f=r.cols)!=null?f:3,d=(y=r.rows)!=null?y:2,p=(x=(C=(_=i==null?void 0:i.width)!=null?_:i==null?void 0:i.pixelWidth)!=null?C:(b=i==null?void 0:i.baseTexture)==null?void 0:b.width)!=null?x:n.width,u=(T=(w=(S=i==null?void 0:i.height)!=null?S:i==null?void 0:i.pixelHeight)!=null?w:(v=i==null?void 0:i.baseTexture)==null?void 0:v.height)!=null?T:n.height,h=p/c,l=u/d;if(!Number.isFinite(h)||!Number.isFinite(l)||h<=0||l<=0||!i)return[n];let m=[];for(let g=0;g<d;g++)for(let A=0;A<c;A++)m.push(new Jn({source:i,frame:new Kn(A*h,g*l,h,l)}));return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function Zn(e,t){var p,u,h,l;let a=t.gameplay.brush||{},o=new bt(t.theme.brush_color||"#ffffff").toNumber(),s=(p=a.radius)!=null?p:20,n=(u=a.inner_radius)!=null?u:15,i=(h=a.alpha)!=null?h:.8,r=(l=a.inner_alpha)!=null?l:.3,c=a.inner_color||"#ffffff",d=new Ge;return d.circle(0,0,s).fill({color:o,alpha:i}),d.circle(0,0,n).fill({color:new bt(c).toNumber(),alpha:r}),e.renderer.generateTexture(d)}export{ht as GameObject,gt as GameObjectManager,dt as Renderer,ct as Transform,Nn as animateHandClick,zn as animatePanelEntrance,Zn as createBrushTexture,kn as createEndGamePanel,$n as createHandTutorial,Mn as createPixiBase,Vn as createTutorialLabel,Dn as getRegisteredFontIds,Xe as loadAsset,Qn as loadCharacterFrames,En as registerFont,X as resolveFont,q as resolveFontWeight,jn as updateHandAnimation};
1
+ import{b as lt}from"../chunk-LQX44TET.mjs";import{Application as Pn}from"pixi.js";async function Mn(e,t={}){let a=new Pn;await a.init({resizeTo:e,autoDensity:!0,resolution:window.devicePixelRatio||1,antialias:!0,backgroundAlpha:0});let o=n=>{var c,d,p,u,h,l;let i=(p=(d=(c=n==null?void 0:n.width)!=null?c:e.clientWidth)!=null?d:window.innerWidth)!=null?p:320,r=(l=(h=(u=n==null?void 0:n.height)!=null?u:e.clientHeight)!=null?h:window.innerHeight)!=null?l:480;a.renderer.resize(i,r)};e.innerHTML="",e.style.position="relative",e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="stretch",e.style.width="100%",e.style.height="100dvh",e.style.minHeight="100vh",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",t.background&&(e.style.background=t.background),e.appendChild(a.canvas);let s=document.createElement("div");return s.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(";")),e.appendChild(s),lt.on("pause",()=>{a.ticker.stop(),document.querySelectorAll("audio").forEach(i=>i.pause())}),lt.on("resume",()=>{a.ticker.start(),document.querySelectorAll("audio").forEach(i=>{i.currentTime>0&&!i.ended&&i.play().catch(()=>{})})}),lt.on("resize",({payload:n})=>{o({width:n==null?void 0:n.width,height:n==null?void 0:n.height})}),window.addEventListener("resize",()=>o()),requestAnimationFrame(()=>o()),{app:a,stage:a.stage,overlay:s,applySize:o}}var ct=class{constructor(t){var a,o;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(a=t==null?void 0:t.scale)!=null?a:1,this.rotation=(o=t==null?void 0:t.rotation)!=null?o:0}update(t){t.position!==void 0&&(this.position={...t.position}),t.scale!==void 0&&(this.scale=t.scale),t.rotation!==void 0&&(this.rotation=t.rotation)}syncToPixi(t){t.position.set(this.position.x,this.position.y),t.scale.set(this.scale),t.rotation=this.rotation}},dt=class{constructor(t){var a,o,s,n;this.z_index=(a=t==null?void 0:t.z_index)!=null?a:0,this.alpha=(o=t==null?void 0:t.alpha)!=null?o:1,this.visible=(s=t==null?void 0:t.visible)!=null?s:!0,this.tint=(n=t==null?void 0:t.tint)!=null?n:null}update(t){t.z_index!==void 0&&(this.z_index=t.z_index),t.alpha!==void 0&&(this.alpha=t.alpha),t.visible!==void 0&&(this.visible=t.visible),t.tint!==void 0&&(this.tint=t.tint)}syncToPixi(t){t.zIndex=this.z_index,t.alpha=this.alpha,t.visible=this.visible,this.tint!==null&&"tint"in t&&(t.tint=this.tint)}},ht=class{constructor(t,a,o,s){this.instanceId=t,this.objectConfig=a,this.pixiObject=o,this._config=s,this.transform=new ct(s.transform),this.renderer=new dt(s.render),this.sync()}sync(){this.transform.syncToPixi(this.pixiObject),this.renderer.syncToPixi(this.pixiObject)}updateConfig(t){this._config=t,t.transform&&this.transform.update(t.transform),t.render&&this.renderer.update(t.render),this.sync()}getComponent(t){return this._config[t]}getPosition(){return{...this.transform.position}}setPosition(t,a){this.transform.position={x:t,y:a},this.transform.syncToPixi(this.pixiObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToPixi(this.pixiObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToPixi(this.pixiObject)}},gt=class{constructor(t){this.objects=new Map;this.config=t}create(t,a){let o=this.config.objects.get(t);if(!o)throw new Error(`Object config not found: ${t}`);let s=new ht(t,o.object_config||t,a,o);return this.objects.set(t,s),s}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[a,o]of this.objects.entries()){let s=t.objects.get(a);s&&o.updateConfig(s)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var pt={"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 X(e){let t=pt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function q(e){var a;let t=pt[e];return t&&(a=t.weight)!=null?a:"400"}function En(e,t){pt[e]=t}function Dn(){return Object.keys(pt)}import{Container as Yn,Graphics as ut,Text as tt,Sprite as Le,Texture as _t}from"pixi.js";function kn(e,t,a){var Dt,Yt,kt,zt,Ht,Wt,Bt,Rt,Lt,Gt,Nt,Xt,qt,$t,Vt,jt,Jt,Kt,Qt,Zt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,de,he,pe,ue,me,fe,ye,ge,_e,be,xe,we,Te,Ce,Se,ve,Ae,Fe,Pe,Me,Ee,De,Ye,ke,ze,He,We;let o=e.objects.get("ui_endgame_1"),s=e.objects.get("ui_endgame_logo_1"),n=e.objects.get("ui_endgame_title_1"),i=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),c=e.objects.get("ui_endgame_cta_1"),d=e.objects.get("ui_endgame_cta_hint_1"),p=e.objects.get("ui_endgame_hand_1"),u=e.engine.runtime||{},h=new Yn;h.alpha=0,h.visible=!1;let l=((Dt=o==null?void 0:o.gameplay)==null?void 0:Dt.tuning)||{},m=(o==null?void 0:o.render)||{},f=(Yt=l.panel_width)!=null?Yt:320,y=(kt=l.panel_height)!=null?kt:400,_=(zt=l.panel_padding)!=null?zt:32,b=(Ht=l.panel_radius)!=null?Ht:24,C=m.background_color||l.panel_bg_color||"#1a0a0a",x=m.background_alpha!==void 0&&m.background_alpha!==null?m.background_alpha:(Wt=l.panel_bg_alpha)!=null?Wt:.98,S=m.border_color||l.panel_border_color||"#ffffff",v=(Bt=l.panel_border_width)!=null?Bt:2,w=(Rt=l.panel_border_alpha)!=null?Rt:.3,T=new ut;T.roundRect(-f/2,-y/2,f,y,b);let g=C.replace("#","");T.fill({color:parseInt(g,16),alpha:x});let A=S.replace("#","");T.stroke({color:parseInt(A,16),width:v,alpha:w});let M=new ut;M.roundRect(-f/2+2,-y/2+2,f-4,y-4,b-2),M.stroke({color:16777215,width:1,alpha:.1}),T.addChild(M),h.addChild(T);let B=((Lt=s==null?void 0:s.gameplay)==null?void 0:Lt.tuning)||{},$=(s==null?void 0:s.transform)||{},z=(Gt=B.logo_size)!=null?Gt:56,R=(Nt=$.scale)!=null?Nt:1,j=(qt=(Xt=$.offset)==null?void 0:Xt.y)!=null?qt:-130,qe=($t=B.logo_alpha)!=null?$t:1,F=new Le(a||_t.EMPTY);F.anchor.set(.5);let K=0,Q=0;if(a&&a!==_t.EMPTY){let P=a.frame,N=a.baseTexture;P&&P.width&&P.height?(K=P.width,Q=P.height):N&&N.width&&N.height?(K=N.width,Q=N.height):a.width&&a.height&&(K=a.width,Q=a.height)}if(K>0&&Q>0){let P=K/Q,N,yt;P>1?(N=z,yt=z/P):(yt=z,N=z*P);let Be=N/K,Re=yt/Q;Be*=R,Re*=R,F.scale.set(Be,Re)}else{let P=z/100*R;F.scale.set(P)}F.position.set(0,j),F.alpha=0,F.visible=!0,F.targetAlpha=qe,F.baseScaleX=F.scale.x,F.baseScaleY=F.scale.y,h.addChild(F);let E=n==null?void 0:n.ui,H=((Vt=n==null?void 0:n.gameplay)==null?void 0:Vt.tuning)||{},$e=(E==null?void 0:E.text)||"MISSION ACCOMPLISHED",xt=(E==null?void 0:E.font)||"brand.heading",Ve=(E==null?void 0:E.fontSize)||24,je=(jt=E==null?void 0:E.letterSpacing)!=null?jt:1,et=(Jt=n==null?void 0:n.render)==null?void 0:Jt.tint,Je=typeof et=="string"?et:et?`#${et.toString(16).padStart(6,"0")}`:"#00FF88",wt=f-_*2-30,Ke=H.font_weight_override?H.font_weight_override:q(xt),V=new tt({text:$e,style:{fontFamily:X(xt),fontSize:Ve,fontWeight:Ke,fill:Je,align:"center",letterSpacing:je,wordWrap:!1,stroke:{color:H.stroke_color||"#000000",width:(Kt=H.stroke_width)!=null?Kt:2},dropShadow:{color:H.shadow_color||"#000000",alpha:(Qt=H.shadow_alpha)!=null?Qt:.9,angle:(Zt=H.shadow_angle)!=null?Zt:0,blur:(Ot=H.shadow_blur)!=null?Ot:8,distance:(It=H.shadow_distance)!=null?It:4}}});if(V.width>wt){let P=wt/V.width;V.scale.set(P)}V.anchor.set(.5);let Tt=(Ut=l.title_offset_y)!=null?Ut:30,Qe=Tt+((te=H.animation_start_y_offset)!=null?te:-20);V.position.set(0,Qe),V.alpha=0,h.addChild(V);let D=i==null?void 0:i.ui,Ct=((ee=i==null?void 0:i.gameplay)==null?void 0:ee.tuning)||{},Ze=(D==null?void 0:D.text)||"RESCUE COMPLETE",St=(D==null?void 0:D.font)||"brand.body",Oe=(D==null?void 0:D.fontSize)||11,Ie=(ne=D==null?void 0:D.letterSpacing)!=null?ne:.5,nt=(ae=i==null?void 0:i.render)==null?void 0:ae.tint,Ue=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=new tt({text:Ze,style:{fontFamily:X(St),fontSize:Oe,fontWeight:q(St),fill:Ue,align:"center",letterSpacing:Ie}});Z.anchor.set(.5);let tn=Tt+20+((se=Ct.animation_start_y_offset)!=null?se:-10);Z.position.set(0,tn),Z.alpha=0,Z.animationStartYOffset=(ie=Ct.animation_start_y_offset)!=null?ie:-10,h.addChild(Z);let L=r==null?void 0:r.ui,vt=((oe=r==null?void 0:r.gameplay)==null?void 0:oe.tuning)||{},en=(L==null?void 0:L.text)||((re=u.ui)==null?void 0:re.cta_hint)||"Continue the adventure!",At=(L==null?void 0:L.font)||"brand.body",nn=(L==null?void 0:L.fontSize)||16,at=(le=r==null?void 0:r.render)==null?void 0:le.tint,an=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#FFFFFF",sn=(ce=vt.max_width)!=null?ce:f-_*2,on=(de=vt.line_height)!=null?de:1.4,O=new tt({text:en,style:{fontFamily:X(At),fontSize:nn,fontWeight:q(At),fill:an,align:"center",wordWrap:!0,wordWrapWidth:sn,lineHeight:on}});O.anchor.set(.5);let rn=(he=l.footer_offset_y)!=null?he:120;O.position.set(0,rn);let ln=((pe=r==null?void 0:r.render)==null?void 0:pe.alpha)!==void 0&&((ue=r==null?void 0:r.render)==null?void 0:ue.alpha)!==null?r.render.alpha:1;O.alpha=0,O.targetAlpha=ln,h.addChild(O);let G=((me=c==null?void 0:c.gameplay)==null?void 0:me.tuning)||{},Y=c==null?void 0:c.ui,st=(fe=G.button_width)!=null?fe:260,it=(ye=G.button_height)!=null?ye:56,Ft=(ge=G.button_radius)!=null?ge:16,cn=G.button_bg_color||((_e=u.theme)==null?void 0:_e.cta_background)||"#ffb43b",dn=(be=G.button_bg_alpha)!=null?be:1,hn=G.button_border_color||"#ffffff",pn=(xe=G.button_border_width)!=null?xe:2,un=(we=G.button_border_alpha)!=null?we:.2,ot=(Te=l.cta_offset_y)!=null?Te:160,W=new ut;W.roundRect(-st/2,-it/2,st,it,Ft);let mn=cn.replace("#","");W.fill({color:parseInt(mn,16),alpha:dn});let fn=hn.replace("#","");W.stroke({color:parseInt(fn,16),width:pn,alpha:un});let mt=new ut;mt.roundRect(-st/2+2,-it/2+2,st-4,it-4,Ft-2),mt.stroke({color:0,width:1,alpha:.15}),W.addChild(mt),W.position.set(0,ot),W.alpha=0,W.eventMode="static",W.cursor="pointer",h.addChild(W);let yn=(Y==null?void 0:Y.text)||((Ce=u.ui)==null?void 0:Ce.cta_label_end)||"DOWNLOAD",Pt=(Y==null?void 0:Y.font)||"brand.heading",gn=(Y==null?void 0:Y.fontSize)||20,_n=G.button_text_color||((Se=u.theme)==null?void 0:Se.cta_text)||"#1a0a0a",U=new tt({text:yn,style:{fontFamily:X(Pt),fontSize:gn,fontWeight:q(Pt),fill:_n,align:"center",letterSpacing:(ve=Y==null?void 0:Y.letterSpacing)!=null?ve:1}});U.anchor.set(.5),U.position.set(0,ot),U.alpha=0,h.addChild(U);let k=d==null?void 0:d.ui,Mt=((Ae=d==null?void 0:d.gameplay)==null?void 0:Ae.tuning)||{},bn=(k==null?void 0:k.text)||"Play the full game",Et=(k==null?void 0:k.font)||"brand.body",xn=(k==null?void 0:k.fontSize)||11,wn=(Fe=k==null?void 0:k.letterSpacing)!=null?Fe:0,rt=(Pe=d==null?void 0:d.render)==null?void 0:Pe.tint,Tn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",I=new tt({text:bn,style:{fontFamily:X(Et),fontSize:xn,fontWeight:q(Et),fill:Tn,align:"center",letterSpacing:wn}});I.anchor.set(.5);let Cn=ot+35+((Me=Mt.animation_start_y_offset)!=null?Me:5);I.position.set(0,Cn),I.alpha=0,I.animationStartYOffset=(Ee=Mt.animation_start_y_offset)!=null?Ee:5,h.addChild(I);let ft=((De=p==null?void 0:p.gameplay)==null?void 0:De.tuning)||{},Sn=(Ye=ft.hand_offset_x)!=null?Ye:50,vn=(ke=ft.hand_offset_y)!=null?ke:50,An=(He=(ze=p==null?void 0:p.transform)==null?void 0:ze.scale)!=null?He:.1875,Fn=(We=ft.hand_scale_multiplier)!=null?We:2.5,J=new Le(t||_t.EMPTY);return J.anchor.set(.5),J.scale.set(An*Fn),J.position.set(Sn,ot+vn),J.alpha=0,J.visible=!1,h.addChild(J),{panel:h,logo:F,title:V,subtitle:Z,footer:O,ctaButton:W,ctaText:U,ctaHint:I,hand:J}}function zn(e,t,a){var v,w,T,g,A,M,B,$;let o=t.objects.get("ui_endgame_1"),s=((v=o==null?void 0:o.gameplay)==null?void 0:v.tuning)||{},n=(w=s.animation_duration_ms)!=null?w:800,i=(T=s.fade_in_duration_ms)!=null?T:600,r=(g=s.scale_animation_intensity)!=null?g:.1,c=(A=s.logo_animation_delay_ms)!=null?A:100,d=(M=s.title_animation_delay_ms)!=null?M:200,p=(B=s.footer_animation_delay_ms)!=null?B:300,u=($=s.cta_animation_delay_ms)!=null?$:400,{panel:h,logo:l,title:m,subtitle:f,footer:y,ctaButton:_,ctaText:b,ctaHint:C}=e;h.visible=!0;let x=Date.now(),S=()=>{let z=Date.now()-x,R=Math.min(z/i,1),j=1-Math.pow(1-R,3);h.alpha=j,h.scale.set(1+r*(1-j)),R<1?requestAnimationFrame(S):(setTimeout(()=>Hn(l,n,t),c),setTimeout(()=>{Wn(m,n),setTimeout(()=>Bn(f,n),50)},d),setTimeout(()=>Rn(y,n),p),setTimeout(()=>{Ln(_,b,n),setTimeout(()=>Gn(C,n),50),a&&a()},u))};S()}function Hn(e,t,a){var h,l,m,f,y;let o=a==null?void 0:a.objects.get("ui_endgame_logo_1"),n=(l=(((h=o==null?void 0:o.gameplay)==null?void 0:h.tuning)||{}).animation_start_scale)!=null?l:1.2,i=Date.now(),r=e.alpha,c=(m=e.targetAlpha)!=null?m:1,d=(f=e.baseScaleX)!=null?f:e.scale.x,p=(y=e.baseScaleY)!=null?y:e.scale.y,u=()=>{let _=Date.now()-i,b=Math.min(_/t,1),C=1-Math.pow(1-b,2);e.alpha=r+(c-r)*C;let x=n+(1-n)*C;e.scale.set(d*x,p*x),b<1&&requestAnimationFrame(u)};u()}function Wn(e,t){let a=Date.now(),o=e.alpha,s=e.y,n=()=>{let i=Date.now()-a,r=Math.min(i/t,1),c=1-Math.pow(1-r,2);e.alpha=o+(1-o)*c,e.y=s-20*(1-c),r<1&&requestAnimationFrame(n)};n()}function Bn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:-10),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Rn(e,t){var i;let a=Date.now(),o=e.alpha,s=(i=e.targetAlpha)!=null?i:1,n=()=>{let r=Date.now()-a,c=Math.min(r/t,1),d=1-Math.pow(1-c,2);e.alpha=o+(s-o)*d,c<1&&requestAnimationFrame(n)};n()}function Ln(e,t,a){let o=Date.now(),s=e.alpha,n=()=>{let i=Date.now()-o,r=Math.min(i/a,1),c=1-Math.pow(1-r,2);e.alpha=s+(1-s)*c,t.alpha=s+(1-s)*c,e.scale.set(1+.1*(1-c)),r<1&&requestAnimationFrame(n)};n()}function Gn(e,t){var r;let a=Date.now(),o=e.alpha,s=e.position.y,n=s-((r=e.animationStartYOffset)!=null?r:5),i=()=>{let c=Date.now()-a,d=Math.min(c/t,1),p=1-Math.pow(1-d,2);e.alpha=o+(1-o)*p,e.position.y=s+(n-s)*p,d<1&&requestAnimationFrame(i)};i()}function Nn(e,t,a,o){var p,u,h,l;let s=a.objects.get("ui_endgame_hand_1"),n=((p=s==null?void 0:s.gameplay)==null?void 0:p.tuning)||{},i=(u=n.click_animation_duration_ms)!=null?u:600,r=(h=n.click_delay_ms)!=null?h:2e3,c=(l=n.click_repeat_delay_ms)!=null?l:3e3,d=()=>{var v,w;e.visible=!0,e.alpha=1;let m=e.x,f=e.y,y=(v=n.hand_offset_x)!=null?v:50,_=(w=n.hand_offset_y)!=null?w:50,b=t.x+y,C=t.y+_,x=Date.now(),S=()=>{var z,R,j;let T=Date.now()-x,g=Math.min(T/i,1),A=g<.5?2*g*g:1-Math.pow(-2*g+2,2)/2;e.x=m+(b-m)*A,e.y=f+(C-f)*A;let M=(R=(z=s==null?void 0:s.transform)==null?void 0:z.scale)!=null?R:.1875,B=(j=n.hand_scale_multiplier)!=null?j:2.5,$=M*B;e.scale.set($+$*.2*Math.sin(g*Math.PI)),g<1?requestAnimationFrame(S):(t.scale.set(.95),setTimeout(()=>{t.scale.set(1),o()},100),setTimeout(()=>{e.alpha=0,setTimeout(()=>{e.x=m,e.y=f,d()},c)},500))};S()};setTimeout(d,r)}import{Sprite as Xn,Text as qn}from"pixi.js";function $n(e,t,a){var p,u,h,l;let o=t.objects.get("hand_tutorial_1"),s=((p=o==null?void 0:o.gameplay)==null?void 0:p.tuning)||{},n=(o==null?void 0:o.render)||{},i=(o==null?void 0:o.transform)||{},r=new Xn(e);r.anchor.set(.5),r.alpha=0;let c=(u=s.hand_scale_multiplier)!=null?u:2.5,d=(h=i.scale)!=null?h:.1875;return r.scale.set(d*c),r.zIndex=(l=n.z_index)!=null?l:99999,r}function Vn(e){var m,f,y,_,b,C,x,S,v,w;let t=e.objects.get("ui_tutorial_1"),a=t==null?void 0:t.ui,o=(t==null?void 0:t.render)||{},s=((m=e.engine.runtime)==null?void 0:m.ui_styles)||{},n=((f=e.engine.runtime)==null?void 0:f.ui)||{},i=(a==null?void 0:a.text)||n.tutorial_label||n.label_text||"CLEAN!",r=(a==null?void 0:a.font)||"brand.warning",c=(a==null?void 0:a.fontSize)||s.label_font_size||52,d=(_=a==null?void 0:a.letterSpacing)!=null?_:(y=s.label_letter_spacing)!=null?y:-1,p=(a==null?void 0:a.align)||"center",u=o.tint,h=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:s.label_fill||"#FFF1C1",l=new qn({text:i,style:{fontFamily:X(r),fontSize:c,fontWeight:q(r),fill:h,align:p,letterSpacing:d,stroke:{color:s.label_stroke||"#8B0000",width:2},dropShadow:{color:s.label_shadow_color||"#000000",alpha:(b=s.label_shadow_alpha)!=null?b:.8,angle:(C=s.label_shadow_angle)!=null?C:0,blur:(x=s.label_shadow_blur)!=null?x:4,distance:(S=s.label_shadow_distance)!=null?S:2}}});return l.anchor.set(.5,0),l.alpha=(v=o.alpha)!=null?v:0,l.visible=(w=o.visible)!=null?w:!0,l}function jn(e,t,a,o,s){var c,d,p,u,h,l,m;let n=s.objects.get("hand_tutorial_1"),i=((c=n==null?void 0:n.gameplay)==null?void 0:c.tuning)||{},r=(n==null?void 0:n.transform)||{};if(!o){let f=(d=i.animation_duration)!=null?d:1.5,y=a%f/f,_=y<.5?2*y*y:-1+(4-2*y)*y,b=(p=i.x_offset)!=null?p:0,C=(u=i.y_offset)!=null?u:0,x=(h=i.animation_range)!=null?h:40,S=x*.7,v=x,w=t.x+b+S,T=t.y+C+v,g=w+S,A=T+v;e.x=w+(g-w)*_,e.y=T+(A-T)*_;let M=(l=r.scale)!=null?l:.1875,B=(m=i.hand_scale_multiplier)!=null?m:2.5;e.scale.set(M*B)}}import{Graphics as Ge,Assets as Ne,Texture as Jn,Rectangle as Kn,Color as bt}from"pixi.js";async function Xe(e,t,a=16777215,o=!1){try{let n=(globalThis.INLINE_ASSETS||{})[e];return await Ne.load(n||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let n=new Ge;return o?n.roundRect(0,0,60,120,10).fill({color:a}):(n.circle(30,30,30).fill({color:a}),n.rect(25,30,10,40).fill({color:a})),t.renderer.generateTexture(n)}}async function Qn(e,t,a){var f,y,_,b,C,x,S,v,w,T;let s=(globalThis.INLINE_ASSETS||{})[e]||e,n;try{n=await Ne.load(s),console.log("[character] loaded sheet",{path:e,sourceUsed:s})}catch(g){let M=(a.gameplay.character_sheet||{}).fallback_color||"#ff00ff";n=await Xe(e,t,new bt(M).toNumber(),!0),console.warn("[character] fallback loadAsset used",{path:e,err:g})}let i=n.source||n.baseTexture||n;i&&"valid"in i&&i.valid===!1&&typeof i.once=="function"&&await new Promise(g=>i.once("loaded",g));let r=a.gameplay.character_sheet||{},c=(f=r.cols)!=null?f:3,d=(y=r.rows)!=null?y:2,p=(x=(C=(_=i==null?void 0:i.width)!=null?_:i==null?void 0:i.pixelWidth)!=null?C:(b=i==null?void 0:i.baseTexture)==null?void 0:b.width)!=null?x:n.width,u=(T=(w=(S=i==null?void 0:i.height)!=null?S:i==null?void 0:i.pixelHeight)!=null?w:(v=i==null?void 0:i.baseTexture)==null?void 0:v.height)!=null?T:n.height,h=p/c,l=u/d;if(!Number.isFinite(h)||!Number.isFinite(l)||h<=0||l<=0||!i)return[n];let m=[];for(let g=0;g<d;g++)for(let A=0;A<c;A++)m.push(new Jn({source:i,frame:new Kn(A*h,g*l,h,l)}));return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function Zn(e,t){var p,u,h,l;let a=t.gameplay.brush||{},o=new bt(t.theme.brush_color||"#ffffff").toNumber(),s=(p=a.radius)!=null?p:20,n=(u=a.inner_radius)!=null?u:15,i=(h=a.alpha)!=null?h:.8,r=(l=a.inner_alpha)!=null?l:.3,c=a.inner_color||"#ffffff",d=new Ge;return d.circle(0,0,s).fill({color:o,alpha:i}),d.circle(0,0,n).fill({color:new bt(c).toNumber(),alpha:r}),e.renderer.generateTexture(d)}export{ht as GameObject,gt as GameObjectManager,dt as Renderer,ct as Transform,Nn as animateHandClick,zn as animatePanelEntrance,Zn as createBrushTexture,kn as createEndGamePanel,$n as createHandTutorial,Mn as createPixiBase,Vn as createTutorialLabel,Dn as getRegisteredFontIds,Xe as loadAsset,Qn as loadCharacterFrames,En as registerFont,X as resolveFont,q as resolveFontWeight,jn as updateHandAnimation};
@@ -1,5 +1,74 @@
1
1
  import * as THREE from 'three';
2
2
 
3
+ /**
4
+ * Handler SDK - Responsive UI System for Three.js
5
+ *
6
+ * Unity-style aspect-aware layout system that handles all responsive UI math.
7
+ * Provides UI safe frame management and debug panel positioning.
8
+ *
9
+ * DO NOT EDIT - Handler SDK Core
10
+ */
11
+ /**
12
+ * Aspect ratio classes for layout switching (Unity-style)
13
+ */
14
+ declare enum AspectClass {
15
+ PHONE_TALL = 0,// aspect <= 0.62 (9:16, 9:19)
16
+ TABLET = 1,// 0.62 < aspect <= 0.85 (3:4)
17
+ LANDSCAPE = 2
18
+ }
19
+ /**
20
+ * Get aspect class from width and height
21
+ *
22
+ * @param width - Container width
23
+ * @param height - Container height
24
+ * @returns AspectClass enum value
25
+ */
26
+ declare function getAspectClass(width: number, height: number): AspectClass;
27
+ /**
28
+ * Responsive UI System
29
+ *
30
+ * Manages UI safe frame and aspect-aware layout switching.
31
+ * All HTML UI must be placed inside the UI frame for proper responsive behavior.
32
+ */
33
+ declare class ResponsiveUISystem {
34
+ private uiFrame;
35
+ private uiContainer;
36
+ private stage;
37
+ private root;
38
+ /**
39
+ * Create a new ResponsiveUISystem
40
+ *
41
+ * @param root - Root HTML element
42
+ * @param stage - Stage HTML element (where Three.js canvas is rendered)
43
+ */
44
+ constructor(root: HTMLElement, stage: HTMLElement);
45
+ /**
46
+ * Get the UI frame element
47
+ * All UI elements should be appended to this frame
48
+ *
49
+ * @returns The UI frame HTMLElement
50
+ */
51
+ getUIFrame(): HTMLElement;
52
+ /**
53
+ * Get the UI container element (inside the frame)
54
+ * This is where most UI content should be placed
55
+ *
56
+ * @returns The UI container HTMLElement
57
+ */
58
+ getUIContainer(): HTMLElement;
59
+ /**
60
+ * Update layout based on current dimensions
61
+ * Call this on resize events
62
+ */
63
+ updateLayout(): void;
64
+ /**
65
+ * Get current aspect class
66
+ *
67
+ * @returns Current AspectClass based on stage dimensions
68
+ */
69
+ getAspectClass(): AspectClass;
70
+ }
71
+
3
72
  /**
4
73
  * Handler SDK - Three.js Base Context
5
74
  *
@@ -25,9 +94,9 @@ type ThreeTheme = {
25
94
  */
26
95
  type ThreeBaseContext = {
27
96
  scene: THREE.Scene;
28
- camera: THREE.OrthographicCamera;
97
+ camera: THREE.PerspectiveCamera;
29
98
  renderer: THREE.WebGLRenderer;
30
- overlay: HTMLElement;
99
+ uiSystem: ResponsiveUISystem;
31
100
  applySize: (size?: {
32
101
  width?: number;
33
102
  height?: number;
@@ -43,11 +112,13 @@ type ThreeBaseContext = {
43
112
  * @example
44
113
  * ```typescript
45
114
  * const root = Handler.getRoot();
46
- * const { scene, camera, renderer, overlay } = await createThreeBase(root, {
115
+ * const { scene, camera, renderer, uiSystem } = await createThreeBase(root, {
47
116
  * background: '#160a17',
48
117
  * text: '#fef4dd',
49
118
  * primary: '#ffb43b'
50
119
  * });
120
+ * const uiFrame = uiSystem.getUIFrame();
121
+ * // Append all UI to uiFrame
51
122
  * ```
52
123
  */
53
124
  declare function createThreeBase(root: HTMLElement, theme?: ThreeTheme): Promise<ThreeBaseContext>;
@@ -395,8 +466,13 @@ interface EndGamePanelElements {
395
466
  }
396
467
  /**
397
468
  * Create EndGame success panel with all UI elements
469
+ *
470
+ * @param config - Object-centric configuration
471
+ * @param handTexture - Texture for tutorial hand sprite
472
+ * @param logoTexture - Texture for brand logo sprite
473
+ * @param uiFrame - UI frame element from ResponsiveUISystem (all UI must be inside this frame)
398
474
  */
399
- declare function createEndGamePanel(config: ObjectCentricConfig, handTexture: THREE.Texture | null, logoTexture: THREE.Texture | null): EndGamePanelElements;
475
+ declare function createEndGamePanel(config: ObjectCentricConfig, handTexture: THREE.Texture | null, logoTexture: THREE.Texture | null, uiFrame: HTMLElement): EndGamePanelElements;
400
476
  /**
401
477
  * Animate panel entrance with staggered animations
402
478
  */
@@ -490,4 +566,4 @@ declare function loadCharacterFrames(path: string, renderer: THREE.WebGLRenderer
490
566
  */
491
567
  declare function createBrushTexture(renderer: THREE.WebGLRenderer, config: ObjectCentricConfig): THREE.Texture;
492
568
 
493
- export { type EndGamePanelElements, GameObject, GameObjectManager, type ObjectCentricConfig, Renderer, type ThreeBaseContext, type ThreeTheme, Transform, animateHandClick, animatePanelEntrance, createBrushTexture, createEndGamePanel, createHandTutorial, createThreeBase, createTutorialLabel, getRegisteredFontIds, loadAsset, loadCharacterFrames, registerFont, resolveFont, resolveFontWeight, updateHandAnimation };
569
+ export { AspectClass, type EndGamePanelElements, GameObject, GameObjectManager, type ObjectCentricConfig, Renderer, ResponsiveUISystem, type ThreeBaseContext, type ThreeTheme, Transform, animateHandClick, animatePanelEntrance, createBrushTexture, createEndGamePanel, createHandTutorial, createThreeBase, createTutorialLabel, getAspectClass, getRegisteredFontIds, loadAsset, loadCharacterFrames, registerFont, resolveFont, resolveFontWeight, updateHandAnimation };
@@ -1,5 +1,74 @@
1
1
  import * as THREE from 'three';
2
2
 
3
+ /**
4
+ * Handler SDK - Responsive UI System for Three.js
5
+ *
6
+ * Unity-style aspect-aware layout system that handles all responsive UI math.
7
+ * Provides UI safe frame management and debug panel positioning.
8
+ *
9
+ * DO NOT EDIT - Handler SDK Core
10
+ */
11
+ /**
12
+ * Aspect ratio classes for layout switching (Unity-style)
13
+ */
14
+ declare enum AspectClass {
15
+ PHONE_TALL = 0,// aspect <= 0.62 (9:16, 9:19)
16
+ TABLET = 1,// 0.62 < aspect <= 0.85 (3:4)
17
+ LANDSCAPE = 2
18
+ }
19
+ /**
20
+ * Get aspect class from width and height
21
+ *
22
+ * @param width - Container width
23
+ * @param height - Container height
24
+ * @returns AspectClass enum value
25
+ */
26
+ declare function getAspectClass(width: number, height: number): AspectClass;
27
+ /**
28
+ * Responsive UI System
29
+ *
30
+ * Manages UI safe frame and aspect-aware layout switching.
31
+ * All HTML UI must be placed inside the UI frame for proper responsive behavior.
32
+ */
33
+ declare class ResponsiveUISystem {
34
+ private uiFrame;
35
+ private uiContainer;
36
+ private stage;
37
+ private root;
38
+ /**
39
+ * Create a new ResponsiveUISystem
40
+ *
41
+ * @param root - Root HTML element
42
+ * @param stage - Stage HTML element (where Three.js canvas is rendered)
43
+ */
44
+ constructor(root: HTMLElement, stage: HTMLElement);
45
+ /**
46
+ * Get the UI frame element
47
+ * All UI elements should be appended to this frame
48
+ *
49
+ * @returns The UI frame HTMLElement
50
+ */
51
+ getUIFrame(): HTMLElement;
52
+ /**
53
+ * Get the UI container element (inside the frame)
54
+ * This is where most UI content should be placed
55
+ *
56
+ * @returns The UI container HTMLElement
57
+ */
58
+ getUIContainer(): HTMLElement;
59
+ /**
60
+ * Update layout based on current dimensions
61
+ * Call this on resize events
62
+ */
63
+ updateLayout(): void;
64
+ /**
65
+ * Get current aspect class
66
+ *
67
+ * @returns Current AspectClass based on stage dimensions
68
+ */
69
+ getAspectClass(): AspectClass;
70
+ }
71
+
3
72
  /**
4
73
  * Handler SDK - Three.js Base Context
5
74
  *
@@ -25,9 +94,9 @@ type ThreeTheme = {
25
94
  */
26
95
  type ThreeBaseContext = {
27
96
  scene: THREE.Scene;
28
- camera: THREE.OrthographicCamera;
97
+ camera: THREE.PerspectiveCamera;
29
98
  renderer: THREE.WebGLRenderer;
30
- overlay: HTMLElement;
99
+ uiSystem: ResponsiveUISystem;
31
100
  applySize: (size?: {
32
101
  width?: number;
33
102
  height?: number;
@@ -43,11 +112,13 @@ type ThreeBaseContext = {
43
112
  * @example
44
113
  * ```typescript
45
114
  * const root = Handler.getRoot();
46
- * const { scene, camera, renderer, overlay } = await createThreeBase(root, {
115
+ * const { scene, camera, renderer, uiSystem } = await createThreeBase(root, {
47
116
  * background: '#160a17',
48
117
  * text: '#fef4dd',
49
118
  * primary: '#ffb43b'
50
119
  * });
120
+ * const uiFrame = uiSystem.getUIFrame();
121
+ * // Append all UI to uiFrame
51
122
  * ```
52
123
  */
53
124
  declare function createThreeBase(root: HTMLElement, theme?: ThreeTheme): Promise<ThreeBaseContext>;
@@ -395,8 +466,13 @@ interface EndGamePanelElements {
395
466
  }
396
467
  /**
397
468
  * Create EndGame success panel with all UI elements
469
+ *
470
+ * @param config - Object-centric configuration
471
+ * @param handTexture - Texture for tutorial hand sprite
472
+ * @param logoTexture - Texture for brand logo sprite
473
+ * @param uiFrame - UI frame element from ResponsiveUISystem (all UI must be inside this frame)
398
474
  */
399
- declare function createEndGamePanel(config: ObjectCentricConfig, handTexture: THREE.Texture | null, logoTexture: THREE.Texture | null): EndGamePanelElements;
475
+ declare function createEndGamePanel(config: ObjectCentricConfig, handTexture: THREE.Texture | null, logoTexture: THREE.Texture | null, uiFrame: HTMLElement): EndGamePanelElements;
400
476
  /**
401
477
  * Animate panel entrance with staggered animations
402
478
  */
@@ -490,4 +566,4 @@ declare function loadCharacterFrames(path: string, renderer: THREE.WebGLRenderer
490
566
  */
491
567
  declare function createBrushTexture(renderer: THREE.WebGLRenderer, config: ObjectCentricConfig): THREE.Texture;
492
568
 
493
- export { type EndGamePanelElements, GameObject, GameObjectManager, type ObjectCentricConfig, Renderer, type ThreeBaseContext, type ThreeTheme, Transform, animateHandClick, animatePanelEntrance, createBrushTexture, createEndGamePanel, createHandTutorial, createThreeBase, createTutorialLabel, getRegisteredFontIds, loadAsset, loadCharacterFrames, registerFont, resolveFont, resolveFontWeight, updateHandAnimation };
569
+ export { AspectClass, type EndGamePanelElements, GameObject, GameObjectManager, type ObjectCentricConfig, Renderer, ResponsiveUISystem, type ThreeBaseContext, type ThreeTheme, Transform, animateHandClick, animatePanelEntrance, createBrushTexture, createEndGamePanel, createHandTutorial, createThreeBase, createTutorialLabel, getAspectClass, getRegisteredFontIds, loadAsset, loadCharacterFrames, registerFont, resolveFont, resolveFontWeight, updateHandAnimation };