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.
@@ -1,12 +1,35 @@
1
- import{b as ot}from"../chunk-5XZYWKIQ.mjs";import*as I from"three";async function $n(e,t={}){let n=()=>{let h=e.style.width||"",u=e.style.height||"",y=320,f=480,_=window.getComputedStyle(e),x=h||_.width,E=u||_.height;if(x&&x!=="auto"&&!x.includes("%")){let T=parseFloat(x);!isNaN(T)&&T>0&&isFinite(T)&&(y=T)}if(E&&E!=="auto"&&!E.includes("%")){let T=parseFloat(E);!isNaN(T)&&T>0&&isFinite(T)&&(f=T)}let S=e.clientWidth,w=e.clientHeight;if((y===320||y<=0||!isFinite(y))&&S&&S>0&&(y=S),(f===480||f<=0||!isFinite(f))&&w&&w>0&&(f=w),y<=0||f<=0||!isFinite(y)||!isFinite(f)){let T=e.getBoundingClientRect();T.width>0&&isFinite(T.width)&&(y=T.width),T.height>0&&isFinite(T.height)&&(f=T.height)}return(y<=0||!isFinite(y))&&(y=e.clientWidth||window.innerWidth||320),(f<=0||!isFinite(f))&&(f=e.clientHeight||window.innerHeight||480),console.log("[THREE-BASE] getSize result:",{width:y,height:f,styleWidth:h,styleHeight:u,effectiveWidth:x,effectiveHeight:E,computedWidth:_.width,computedHeight:_.height,clientWidth:S,clientHeight:w,boundingRect:e.getBoundingClientRect()}),{width:y,height:f}},i=e.style.width&&!e.style.width.includes("%"),a=e.style.height&&!e.style.height.includes("%");e.style.position=e.style.position||"relative",e.style.display=e.style.display||"flex",e.style.flexDirection=e.style.flexDirection||"column",e.style.alignItems=e.style.alignItems||"stretch",e.style.width=e.style.width||"100%",e.style.height=e.style.height||"100dvh",e.style.minHeight=e.style.minHeight||"100vh",e.style.maxWidth=e.style.maxWidth||"100%",e.style.maxHeight=e.style.maxHeight||"100%",e.style.boxSizing=e.style.boxSizing||"border-box",e.style.overflow=e.style.overflow||"hidden",t.background&&(e.style.background=t.background);let s=document.createElement("div");s.setAttribute("style",["position:relative","width:100%","height:100%","display:flex","align-items:center","justify-content:center",`background:${t.background||"transparent"}`,"color:var(--h-text, #f4f6ff)",'font-family:var(--h-font-main, "Inter", "Helvetica Neue", Arial, sans-serif)',"box-sizing:border-box"].join(";")),e.appendChild(s);let o=document.createElement("div");o.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","pointer-events:auto"].join(";")),s.appendChild(o);let l=new I.Scene,{width:d,height:m}=n(),r=new I.OrthographicCamera(-d/2,d/2,m/2,-m/2,.1,1e3);r.position.set(0,0,1),r.lookAt(0,0,0),r.updateMatrixWorld();let c=new I.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});c.setPixelRatio(window.devicePixelRatio||1),c.setSize(d,m),c.setClearColor(0,0),c.domElement.style.position="absolute",c.domElement.style.top="0",c.domElement.style.left="0",c.domElement.style.width="100%",c.domElement.style.height="100%",c.domElement.style.display="block",c.domElement.style.pointerEvents="auto",o.appendChild(c.domElement);let p=h=>{let u,y;if(typeof(h==null?void 0:h.width)=="number"&&h.width>0?u=h.width:u=n().width,typeof(h==null?void 0:h.height)=="number"&&h.height>0?y=h.height:y=n().height,u<=0||y<=0||!isFinite(u)||!isFinite(y)){console.warn("[THREE-BASE] Invalid size in applySize, using getSize fallback",{newWidth:u,newHeight:y,size:h});let f=n();u=f.width,y=f.height}console.log("[THREE-BASE] applySize:",{newWidth:u,newHeight:y,providedSize:h,containerSize:n()}),c.setSize(u,y),c.setPixelRatio(window.devicePixelRatio||1),r.left=-u/2,r.right=u/2,r.top=y/2,r.bottom=-y/2,r.updateProjectionMatrix()};requestAnimationFrame(()=>p());let g=!1;ot.on("pause",()=>{g=!0,document.querySelectorAll("audio").forEach(u=>u.pause())}),ot.on("resume",()=>{g=!1,document.querySelectorAll("audio").forEach(u=>{u.currentTime>0&&!u.ended&&u.play().catch(()=>{})})}),ot.on("resize",({payload:h})=>{p({width:h==null?void 0:h.width,height:h==null?void 0:h.height})}),window.addEventListener("resize",()=>p());let b=document.createElement("div");return b.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","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(";")),s.appendChild(b),{scene:l,camera:r,renderer:c,overlay:b,applySize:p}}import*as v from"three";var rt=class{constructor(t){var n,i;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(i=t==null?void 0:t.rotation)!=null?i: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)}syncToThree(t){let n=t.position.z,i=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,i),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},lt=class{constructor(t){var n,i,a,s;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(i=t==null?void 0:t.alpha)!=null?i:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(s=t==null?void 0:t.tint)!=null?s: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)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof v.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof v.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof v.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof v.Mesh&&t.material){let n=typeof this.tint=="string"?new v.Color(this.tint):new v.Color(this.tint);Array.isArray(t.material)?t.material.forEach(i=>{(i instanceof v.MeshBasicMaterial||i instanceof v.MeshStandardMaterial)&&i.color.copy(n)}):(t.material instanceof v.MeshBasicMaterial||t.material instanceof v.MeshStandardMaterial)&&t.material.color.copy(n)}}},ct=class{constructor(t,n,i,a){this.instanceId=t,this.objectConfig=n,this.threeObject=i,this._config=a,this.transform=new rt(a.transform),this.renderer=new lt(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}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,n){this.transform.position={x:t,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToThree(this.threeObject)}},Tt=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let i=this.config.objects.get(t);if(!i)throw new Error(`Object config not found: ${t}`);let a=new ct(t,i.object_config||t,n,i);return this.objects.set(t,a),a}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,i]of this.objects.entries()){let a=t.objects.get(n);a&&i.updateConfig(a)}}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 N(e){let t=pt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function G(e){var n;let t=pt[e];return t&&(n=t.weight)!=null?n:"400"}function An(e,t){pt[e]=t}function Ln(){return Object.keys(pt)}import*as U from"three";function Q(e){return{element:e,get alpha(){return parseFloat(e.style.opacity||"1")},set alpha(t){e.style.opacity=t.toString()},get visible(){return e.style.display!=="none"},set visible(t){e.style.display=t?"":"none"},position:{set(t,n){e.style.left=`${t}px`,e.style.top=`${n}px`},get x(){return parseFloat(e.style.left||"0")},get y(){return parseFloat(e.style.top||"0")}},scale:{set(t,n){e.style.transform=`scale(${t})`},get x(){let t=e.style.transform.match(/scale\(([^)]+)\)/);return t?parseFloat(t[1]):1}}}}function Dn(e,t,n){var Lt,Dt,Wt,kt,zt,Bt,Yt,Pt,Nt,Gt,Xt,qt,Vt,Zt,Jt,Kt,Qt,jt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,pe,de,me,he,ue,ye,fe,ge,be,Te,xe,_e,Ee,we,Se,He,ve,Re,Ce,Me,Fe,$e,Ae,Le,De,We,ke,ze,Be,Ye,Pe;let i=e.objects.get("ui_endgame_1"),a=e.objects.get("ui_endgame_logo_1"),s=e.objects.get("ui_endgame_title_1"),o=e.objects.get("ui_endgame_subtitle_1"),l=e.objects.get("ui_endgame_footer_1"),d=e.objects.get("ui_endgame_cta_1"),m=e.objects.get("ui_endgame_cta_hint_1"),r=e.objects.get("ui_endgame_hand_1"),c=e.engine.runtime||{},p=((Lt=i==null?void 0:i.gameplay)==null?void 0:Lt.tuning)||{},g=(i==null?void 0:i.render)||{},b=(Dt=p.panel_width)!=null?Dt:320,h=(Wt=p.panel_height)!=null?Wt:400,u=(kt=p.panel_padding)!=null?kt:32,y=(zt=p.panel_radius)!=null?zt:24,f=g.background_color||p.panel_bg_color||"#1a0a0a",_=g.background_alpha!==void 0&&g.background_alpha!==null?g.background_alpha:(Bt=p.panel_bg_alpha)!=null?Bt:.98,x=g.border_color||p.panel_border_color||"#ffffff",E=(Yt=p.panel_border_width)!=null?Yt:2,S=(Pt=p.panel_border_alpha)!=null?Pt:.3,w=document.createElement("div");w.style.cssText=`
1
+ import{b as lt}from"../chunk-LQX44TET.mjs";import*as I from"three";var qe=(s=>(s[s.PHONE_TALL=0]="PHONE_TALL",s[s.TABLET=1]="TABLET",s[s.LANDSCAPE=2]="LANDSCAPE",s))(qe||{});function Et(e,t){let n=e/t;return n<=.62?0:n<=.85?1:2}var nt=class{constructor(t,n){this.root=t,this.stage=n,this.uiFrame=document.createElement("div"),this.uiFrame.style.position="absolute",this.uiFrame.style.top="0",this.uiFrame.style.bottom="0",this.uiFrame.style.left="50%",this.uiFrame.style.transform="translateX(-50%)",this.uiFrame.style.width="100%",this.uiFrame.style.maxWidth="420px",this.uiFrame.style.pointerEvents="none",this.stage.appendChild(this.uiFrame),this.uiContainer=document.createElement("div"),this.uiContainer.setAttribute("style",["position:absolute","inset:0","display:flex","flex-direction:column","justify-content:flex-start","gap:12px","pointer-events:none","padding:20px 16px","padding-bottom:clamp(24px, 6vh, 96px)","box-sizing:border-box","z-index:2"].join(";")),this.uiFrame.appendChild(this.uiContainer),this.updateLayout()}getUIFrame(){return this.uiFrame}getUIContainer(){return this.uiContainer}updateLayout(){let t=this.stage.getBoundingClientRect(),n=Et(t.width,t.height);n===0?this.uiFrame.style.maxWidth="420px":n===1?this.uiFrame.style.maxWidth="520px":this.uiFrame.style.maxWidth="640px"}getAspectClass(){let t=this.stage.getBoundingClientRect();return Et(t.width,t.height)}};async function Dn(e,t={}){let n=()=>{let d=e.style.width||"",g=e.style.height||"",h=320,f=480,E=window.getComputedStyle(e),w=d||E.width,S=g||E.height;if(w&&w!=="auto"&&!w.includes("%")){let T=parseFloat(w);!isNaN(T)&&T>0&&isFinite(T)&&(h=T)}if(S&&S!=="auto"&&!S.includes("%")){let T=parseFloat(S);!isNaN(T)&&T>0&&isFinite(T)&&(f=T)}let H=e.clientWidth,_=e.clientHeight;if((h===320||h<=0||!isFinite(h))&&H&&H>0&&(h=H),(f===480||f<=0||!isFinite(f))&&_&&_>0&&(f=_),h<=0||f<=0||!isFinite(h)||!isFinite(f)){let T=e.getBoundingClientRect();T.width>0&&isFinite(T.width)&&(h=T.width),T.height>0&&isFinite(T.height)&&(f=T.height)}return(h<=0||!isFinite(h))&&(h=e.clientWidth||window.innerWidth||320),(f<=0||!isFinite(f))&&(f=e.clientHeight||window.innerHeight||480),console.log("[THREE-BASE] getSize result:",{width:h,height:f,styleWidth:d,styleHeight:g,effectiveWidth:w,effectiveHeight:S,computedWidth:E.width,computedHeight:E.height,clientWidth:H,clientHeight:_,boundingRect:e.getBoundingClientRect()}),{width:h,height:f}},s=e.style.width&&!e.style.width.includes("%"),a=e.style.height&&!e.style.height.includes("%");e.style.position||(e.style.position="relative"),e.style.display||(e.style.display="block"),e.style.width=e.style.width||"100%",e.style.height=e.style.height||"100%",e.style.minWidth="100%",e.style.minHeight="100%",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.boxSizing="border-box",e.style.overflow="hidden",e.style.margin="0",e.style.padding="0",e.style.border="none";let i=t.background||"linear-gradient(160deg, #0d1020, #0f1c2f)";e.style.setProperty("background",i,"important"),e.style.setProperty("background-size","cover","important"),e.style.setProperty("background-position","center","important"),e.style.setProperty("background-repeat","no-repeat","important");let o=document.createElement("div");o.style.cssText=`
2
+ position: absolute !important;
3
+ top: 0 !important;
4
+ left: 0 !important;
5
+ right: 0 !important;
6
+ bottom: 0 !important;
7
+ width: 100% !important;
8
+ height: 100% !important;
9
+ min-width: 100% !important;
10
+ min-height: 100% !important;
11
+ display: flex;
12
+ align-items: center;
13
+ justify-content: center;
14
+ background: ${i} !important;
15
+ background-size: cover !important;
16
+ background-position: center !important;
17
+ background-repeat: no-repeat !important;
18
+ color: var(--h-text, #f4f6ff);
19
+ font-family: var(--h-font-main, "Inter", "Helvetica Neue", Arial, sans-serif);
20
+ box-sizing: border-box !important;
21
+ margin: 0 !important;
22
+ padding: 0 !important;
23
+ border: none !important;
24
+ `,e.appendChild(o);let p=document.createElement("div");p.setAttribute("style",["position:absolute","inset:0","width:100%","height:100%","pointer-events:auto"].join(";")),o.appendChild(p);let r=new I.Scene,{width:y,height:c}=n(),u=new I.PerspectiveCamera(55,y/c,.1,100);u.position.set(0,0,3.2),u.lookAt(0,0,0),u.updateMatrixWorld();let l=new I.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});l.setPixelRatio(window.devicePixelRatio||1),l.setSize(y,c),l.setClearColor(0,0),l.domElement.style.position="absolute",l.domElement.style.top="0",l.domElement.style.left="0",l.domElement.style.width="100%",l.domElement.style.height="100%",l.domElement.style.display="block",l.domElement.style.pointerEvents="auto",p.appendChild(l.domElement);let m=d=>{let g,h;if(typeof(d==null?void 0:d.width)=="number"&&d.width>0?g=d.width:g=n().width,typeof(d==null?void 0:d.height)=="number"&&d.height>0?h=d.height:h=n().height,g<=0||h<=0||!isFinite(g)||!isFinite(h)){console.warn("[THREE-BASE] Invalid size in applySize, using getSize fallback",{newWidth:g,newHeight:h,size:d});let f=n();g=f.width,h=f.height}console.log("[THREE-BASE] applySize:",{newWidth:g,newHeight:h,providedSize:d,containerSize:n()}),l.setSize(g,h),l.setPixelRatio(window.devicePixelRatio||1),u.aspect=g/h,u.updateProjectionMatrix()};requestAnimationFrame(()=>m());let b=!1;lt.on("pause",()=>{b=!0,document.querySelectorAll("audio").forEach(g=>g.pause())}),lt.on("resume",()=>{b=!1,document.querySelectorAll("audio").forEach(g=>{g.currentTime>0&&!g.ended&&g.play().catch(()=>{})})});let x=new nt(e,o);return lt.on("resize",({payload:d})=>{m({width:d==null?void 0:d.width,height:d==null?void 0:d.height}),x.updateLayout()}),window.addEventListener("resize",()=>{m(),x.updateLayout()}),{scene:r,camera:u,renderer:l,uiSystem:x,applySize:m}}import*as v from"three";var ct=class{constructor(t){var n,s;this.position=(t==null?void 0:t.position)||{x:0,y:0},this.scale=(n=t==null?void 0:t.scale)!=null?n:1,this.rotation=(s=t==null?void 0:t.rotation)!=null?s: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)}syncToThree(t){let n=t.position.z,s=n===0||!isFinite(n)?.5:n;t.position.set(this.position.x,this.position.y,s),t.scale.set(this.scale,this.scale,this.scale),t.rotation.z=this.rotation}},pt=class{constructor(t){var n,s,a,i;this.z_index=(n=t==null?void 0:t.z_index)!=null?n:0,this.alpha=(s=t==null?void 0:t.alpha)!=null?s:1,this.visible=(a=t==null?void 0:t.visible)!=null?a:!0,this.tint=(i=t==null?void 0:t.tint)!=null?i: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)}syncToThree(t){if(t.renderOrder=this.z_index,t.visible=this.visible,t instanceof v.Mesh&&t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n instanceof v.Material&&(n.opacity=this.alpha,n.transparent=this.alpha<1)}):t.material instanceof v.Material&&(t.material.opacity=this.alpha,t.material.transparent=this.alpha<1)),this.tint!==null&&t instanceof v.Mesh&&t.material){let n=typeof this.tint=="string"?new v.Color(this.tint):new v.Color(this.tint);Array.isArray(t.material)?t.material.forEach(s=>{(s instanceof v.MeshBasicMaterial||s instanceof v.MeshStandardMaterial)&&s.color.copy(n)}):(t.material instanceof v.MeshBasicMaterial||t.material instanceof v.MeshStandardMaterial)&&t.material.color.copy(n)}}},mt=class{constructor(t,n,s,a){this.instanceId=t,this.objectConfig=n,this.threeObject=s,this._config=a,this.transform=new ct(a.transform),this.renderer=new pt(a.render),this.sync()}sync(){this.transform.syncToThree(this.threeObject),this.renderer.syncToThree(this.threeObject)}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,n){this.transform.position={x:t,y:n},this.transform.syncToThree(this.threeObject)}getAlpha(){return this.renderer.alpha}setAlpha(t){this.renderer.alpha=t,this.renderer.syncToThree(this.threeObject)}getVisible(){return this.renderer.visible}setVisible(t){this.renderer.visible=t,this.renderer.syncToThree(this.threeObject)}},_t=class{constructor(t){this.objects=new Map;this.config=t}create(t,n){let s=this.config.objects.get(t);if(!s)throw new Error(`Object config not found: ${t}`);let a=new mt(t,s.object_config||t,n,s);return this.objects.set(t,a),a}get(t){return this.objects.get(t)}updateConfig(t){this.config=t;for(let[n,s]of this.objects.entries()){let a=t.objects.get(n);a&&s.updateConfig(a)}}getAll(){return Array.from(this.objects.values())}remove(t){this.objects.delete(t)}clear(){this.objects.clear()}};var dt={"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 Y(e){let t=dt[e];return t?t.family:(console.warn(`Font ID "${e}" not found in registry, using fallback`),"Arial, sans-serif")}function N(e){var n;let t=dt[e];return t&&(n=t.weight)!=null?n:"400"}function kn(e,t){dt[e]=t}function zn(){return Object.keys(dt)}import*as U from"three";function Q(e){return{element:e,get alpha(){return parseFloat(e.style.opacity||"1")},set alpha(t){e.style.opacity=t.toString()},get visible(){return e.style.display!=="none"},set visible(t){e.style.display=t?"":"none"},position:{set(t,n){e.style.left=`${t}px`,e.style.top=`${n}px`},get x(){return parseFloat(e.style.left||"0")},get y(){return parseFloat(e.style.top||"0")}},scale:{set(t,n){e.style.transform=`scale(${t})`},get x(){let t=e.style.transform.match(/scale\(([^)]+)\)/);return t?parseFloat(t[1]):1}}}}function Bn(e,t,n,s){var kt,zt,Bt,Pt,Yt,Nt,Gt,Xt,qt,Vt,Zt,Jt,Kt,Qt,jt,Ot,It,Ut,te,ee,ne,ae,se,ie,oe,re,le,ce,pe,me,de,ue,he,ye,fe,ge,be,Te,xe,Ee,_e,we,Se,He,Ce,ve,Re,Fe,Me,Ae,$e,Le,We,De,ke,ze,Be,Pe,Ye,Ne,Ge,Xe;let a=e.objects.get("ui_endgame_1"),i=e.objects.get("ui_endgame_logo_1"),o=e.objects.get("ui_endgame_title_1"),p=e.objects.get("ui_endgame_subtitle_1"),r=e.objects.get("ui_endgame_footer_1"),y=e.objects.get("ui_endgame_cta_1"),c=e.objects.get("ui_endgame_cta_hint_1"),u=e.objects.get("ui_endgame_hand_1"),l=e.engine.runtime||{},m=((kt=a==null?void 0:a.gameplay)==null?void 0:kt.tuning)||{},b=(a==null?void 0:a.render)||{},x=(zt=m.panel_width)!=null?zt:320,d=(Bt=m.panel_height)!=null?Bt:400,g=(Pt=m.panel_padding)!=null?Pt:32,h=(Yt=m.panel_radius)!=null?Yt:24,f=b.background_color||m.panel_bg_color||"#1a0a0a",E=b.background_alpha!==void 0&&b.background_alpha!==null?b.background_alpha:(Nt=m.panel_bg_alpha)!=null?Nt:.98,w=b.border_color||m.panel_border_color||"#ffffff",S=(Gt=m.panel_border_width)!=null?Gt:2,H=(Xt=m.panel_border_alpha)!=null?Xt:.3,_=document.createElement("div");_.style.cssText=`
2
25
  position: absolute;
3
- width: ${b}px;
4
- height: ${h}px;
26
+ width: ${x}px;
27
+ height: ${d}px;
5
28
  background: ${f};
6
- opacity: ${_};
7
- border: ${E}px solid ${x};
8
- border-opacity: ${S};
9
- border-radius: ${y}px;
29
+ opacity: ${E};
30
+ border: ${S}px solid ${w};
31
+ border-opacity: ${H};
32
+ border-radius: ${h}px;
10
33
  display: flex;
11
34
  flex-direction: column;
12
35
  align-items: center;
@@ -15,79 +38,82 @@ import{b as ot}from"../chunk-5XZYWKIQ.mjs";import*as I from"three";async functio
15
38
  opacity: 0;
16
39
  visibility: hidden;
17
40
  pointer-events: auto;
18
- `;let T=Q(w);T.element=w;let W=((Nt=a==null?void 0:a.gameplay)==null?void 0:Nt.tuning)||{},R=(a==null?void 0:a.transform)||{},M=(Gt=W.logo_size)!=null?Gt:56,D=(Xt=R.scale)!=null?Xt:1,k=(Vt=(qt=R.offset)==null?void 0:qt.y)!=null?Vt:-130,j=(Zt=W.logo_alpha)!=null?Zt:1,X=new U.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),H=new U.Sprite(X);H.position.set(0,k,0),H.material.opacity=0;let z=0,q=0;if(n&&(z=((Jt=n.image)==null?void 0:Jt.width)||100,q=((Kt=n.image)==null?void 0:Kt.height)||100),z>0&&q>0){let O=z/q,gt,bt;O>1?(gt=M,bt=M/O):(bt=M,gt=M*O);let Mn=gt/z*D,Fn=bt/q*D;H.scale.set(Mn,Fn,1)}else{let O=M/100*D;H.scale.set(O,O,1)}H.targetAlpha=j,H.baseScaleX=H.scale.x,H.baseScaleY=H.scale.y;let F=s==null?void 0:s.ui,B=((Qt=s==null?void 0:s.gameplay)==null?void 0:Qt.tuning)||{},Xe=(F==null?void 0:F.text)||"MISSION ACCOMPLISHED",xt=(F==null?void 0:F.font)||"brand.heading",qe=(F==null?void 0:F.fontSize)||24,Ve=(jt=F==null?void 0:F.letterSpacing)!=null?jt:1,nt=(Ot=s==null?void 0:s.render)==null?void 0:Ot.tint,Ze=typeof nt=="string"?nt:nt?`#${nt.toString(16).padStart(6,"0")}`:"#00FF88",Je=b-u*2-30,Ke=B.font_weight_override?B.font_weight_override:G(xt),V=document.createElement("div");V.textContent=Xe,V.style.cssText=`
19
- font-family: ${N(xt)};
20
- font-size: ${qe}px;
21
- font-weight: ${Ke};
22
- color: ${Ze};
41
+ left: 50%;
42
+ top: 50%;
43
+ z-index: 1000;
44
+ `,s.appendChild(_);let T=Q(_);T.element=_;let R=((qt=i==null?void 0:i.gameplay)==null?void 0:qt.tuning)||{},k=(i==null?void 0:i.transform)||{},M=(Vt=R.logo_size)!=null?Vt:56,D=(Zt=k.scale)!=null?Zt:1,j=(Kt=(Jt=k.offset)==null?void 0:Jt.y)!=null?Kt:-130,X=(Qt=R.logo_alpha)!=null?Qt:1,G=new U.SpriteMaterial({map:n||void 0,transparent:!0,alphaTest:.1}),C=new U.Sprite(G);C.position.set(0,j,0),C.material.opacity=0;let q=0,at=0;if(n&&(q=((jt=n.image)==null?void 0:jt.width)||100,at=((Ot=n.image)==null?void 0:Ot.height)||100),q>0&&at>0){let O=q/at,Tt,xt;O>1?(Tt=M,xt=M/O):(xt=M,Tt=M*O);let Ln=Tt/q*D,Wn=xt/at*D;C.scale.set(Ln,Wn,1)}else{let O=M/100*D;C.scale.set(O,O,1)}C.targetAlpha=X,C.baseScaleX=C.scale.x,C.baseScaleY=C.scale.y;let A=o==null?void 0:o.ui,z=((It=o==null?void 0:o.gameplay)==null?void 0:It.tuning)||{},Je=(A==null?void 0:A.text)||"MISSION ACCOMPLISHED",wt=(A==null?void 0:A.font)||"brand.heading",Ke=(A==null?void 0:A.fontSize)||24,Qe=(Ut=A==null?void 0:A.letterSpacing)!=null?Ut:1,st=(te=o==null?void 0:o.render)==null?void 0:te.tint,je=typeof st=="string"?st:st?`#${st.toString(16).padStart(6,"0")}`:"#00FF88",Oe=x-g*2-30,Ie=z.font_weight_override?z.font_weight_override:N(wt),V=document.createElement("div");V.textContent=Je,V.style.cssText=`
45
+ font-family: ${Y(wt)};
46
+ font-size: ${Ke}px;
47
+ font-weight: ${Ie};
48
+ color: ${je};
23
49
  text-align: center;
24
- letter-spacing: ${Ve}px;
25
- -webkit-text-stroke: ${(It=B.stroke_width)!=null?It:2}px ${B.stroke_color||"#000000"};
26
- text-shadow: ${(Ut=B.shadow_distance)!=null?Ut:4}px ${(te=B.shadow_distance)!=null?te:4}px ${(ee=B.shadow_blur)!=null?ee:8}px rgba(0,0,0,${(ne=B.shadow_alpha)!=null?ne:.9});
50
+ letter-spacing: ${Qe}px;
51
+ -webkit-text-stroke: ${(ee=z.stroke_width)!=null?ee:2}px ${z.stroke_color||"#000000"};
52
+ text-shadow: ${(ne=z.shadow_distance)!=null?ne:4}px ${(ae=z.shadow_distance)!=null?ae:4}px ${(se=z.shadow_blur)!=null?se:8}px rgba(0,0,0,${(ie=z.shadow_alpha)!=null?ie:.9});
27
53
  opacity: 0;
28
54
  position: absolute;
29
55
  transform: translate(-50%, -50%);
30
56
  white-space: nowrap;
31
- max-width: ${Je}px;
32
- `;let _t=(ae=p.title_offset_y)!=null?ae:30,Qe=_t+((se=B.animation_start_y_offset)!=null?se:-20);V.style.top=`${Qe}px`,V.style.left="50%";let Et=Q(V);Et.element=V,w.appendChild(V);let $=o==null?void 0:o.ui,wt=((ie=o==null?void 0:o.gameplay)==null?void 0:ie.tuning)||{},je=($==null?void 0:$.text)||"RESCUE COMPLETE",St=($==null?void 0:$.font)||"brand.body",Oe=($==null?void 0:$.fontSize)||11,Ie=(oe=$==null?void 0:$.letterSpacing)!=null?oe:.5,at=(re=o==null?void 0:o.render)==null?void 0:re.tint,Ue=typeof at=="string"?at:at?`#${at.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=document.createElement("div");Z.textContent=je,Z.style.cssText=`
33
- font-family: ${N(St)};
34
- font-size: ${Oe}px;
35
- font-weight: ${G(St)};
36
- color: ${Ue};
57
+ max-width: ${Oe}px;
58
+ `;let St=(oe=m.title_offset_y)!=null?oe:30,Ue=St+((re=z.animation_start_y_offset)!=null?re:-20);V.style.top=`${Ue}px`,V.style.left="50%";let Ht=Q(V);Ht.element=V,_.appendChild(V);let $=p==null?void 0:p.ui,Ct=((le=p==null?void 0:p.gameplay)==null?void 0:le.tuning)||{},tn=($==null?void 0:$.text)||"RESCUE COMPLETE",vt=($==null?void 0:$.font)||"brand.body",en=($==null?void 0:$.fontSize)||11,nn=(ce=$==null?void 0:$.letterSpacing)!=null?ce:.5,it=(pe=p==null?void 0:p.render)==null?void 0:pe.tint,an=typeof it=="string"?it:it?`#${it.toString(16).padStart(6,"0")}`:"#B0B0B0",Z=document.createElement("div");Z.textContent=tn,Z.style.cssText=`
59
+ font-family: ${Y(vt)};
60
+ font-size: ${en}px;
61
+ font-weight: ${N(vt)};
62
+ color: ${an};
37
63
  text-align: center;
38
- letter-spacing: ${Ie}px;
64
+ letter-spacing: ${nn}px;
39
65
  opacity: 0;
40
66
  position: absolute;
41
67
  transform: translate(-50%, -50%);
42
68
  white-space: nowrap;
43
- `;let tn=_t+20+((le=wt.animation_start_y_offset)!=null?le:-10);Z.style.top=`${tn}px`,Z.style.left="50%";let mt=Q(Z);mt.element=Z,mt.animationStartYOffset=(ce=wt.animation_start_y_offset)!=null?ce:-10,w.appendChild(Z);let Y=l==null?void 0:l.ui,Ht=((pe=l==null?void 0:l.gameplay)==null?void 0:pe.tuning)||{},en=(Y==null?void 0:Y.text)||((de=c.ui)==null?void 0:de.cta_hint)||"Continue the adventure!",vt=(Y==null?void 0:Y.font)||"brand.body",nn=(Y==null?void 0:Y.fontSize)||16,st=(me=l==null?void 0:l.render)==null?void 0:me.tint,an=typeof st=="string"?st:st?`#${st.toString(16).padStart(6,"0")}`:"#FFFFFF",sn=(he=Ht.max_width)!=null?he:b-u*2,on=(ue=Ht.line_height)!=null?ue:1.4,J=document.createElement("div");J.textContent=en,J.style.cssText=`
44
- font-family: ${N(vt)};
45
- font-size: ${nn}px;
46
- font-weight: ${G(vt)};
47
- color: ${an};
69
+ `;let sn=St+20+((me=Ct.animation_start_y_offset)!=null?me:-10);Z.style.top=`${sn}px`,Z.style.left="50%";let ht=Q(Z);ht.element=Z,ht.animationStartYOffset=(de=Ct.animation_start_y_offset)!=null?de:-10,_.appendChild(Z);let B=r==null?void 0:r.ui,Rt=((ue=r==null?void 0:r.gameplay)==null?void 0:ue.tuning)||{},on=(B==null?void 0:B.text)||((he=l.ui)==null?void 0:he.cta_hint)||"Continue the adventure!",Ft=(B==null?void 0:B.font)||"brand.body",rn=(B==null?void 0:B.fontSize)||16,ot=(ye=r==null?void 0:r.render)==null?void 0:ye.tint,ln=typeof ot=="string"?ot:ot?`#${ot.toString(16).padStart(6,"0")}`:"#FFFFFF",cn=(fe=Rt.max_width)!=null?fe:x-g*2,pn=(ge=Rt.line_height)!=null?ge:1.4,J=document.createElement("div");J.textContent=on,J.style.cssText=`
70
+ font-family: ${Y(Ft)};
71
+ font-size: ${rn}px;
72
+ font-weight: ${N(Ft)};
73
+ color: ${ln};
48
74
  text-align: center;
49
75
  opacity: 0;
50
76
  position: absolute;
51
77
  transform: translate(-50%, -50%);
52
- max-width: ${sn}px;
53
- line-height: ${on};
78
+ max-width: ${cn}px;
79
+ line-height: ${pn};
54
80
  word-wrap: break-word;
55
- `;let rn=(ye=p.footer_offset_y)!=null?ye:120;J.style.top=`${rn}px`,J.style.left="50%";let ht=Q(J);ht.element=J;let ln=((fe=l==null?void 0:l.render)==null?void 0:fe.alpha)!==void 0&&((ge=l==null?void 0:l.render)==null?void 0:ge.alpha)!==null?l.render.alpha:1;ht.targetAlpha=ln,w.appendChild(J);let P=((be=d==null?void 0:d.gameplay)==null?void 0:be.tuning)||{},A=d==null?void 0:d.ui,cn=(Te=P.button_width)!=null?Te:260,pn=(xe=P.button_height)!=null?xe:56,dn=(_e=P.button_radius)!=null?_e:16,mn=P.button_bg_color||((Ee=c.theme)==null?void 0:Ee.cta_background)||"#ffb43b",hn=(we=P.button_bg_alpha)!=null?we:1,un=P.button_border_color||"#ffffff",yn=(Se=P.button_border_width)!=null?Se:2,Qn=(He=P.button_border_alpha)!=null?He:.2,ut=(ve=p.cta_offset_y)!=null?ve:160,C=document.createElement("button");C.style.cssText=`
56
- width: ${cn}px;
57
- height: ${pn}px;
58
- background: ${mn};
59
- opacity: ${hn};
60
- border: ${yn}px solid ${un};
61
- border-radius: ${dn}px;
81
+ `;let mn=(be=m.footer_offset_y)!=null?be:120;J.style.top=`${mn}px`,J.style.left="50%";let yt=Q(J);yt.element=J;let dn=((Te=r==null?void 0:r.render)==null?void 0:Te.alpha)!==void 0&&((xe=r==null?void 0:r.render)==null?void 0:xe.alpha)!==null?r.render.alpha:1;yt.targetAlpha=dn,_.appendChild(J);let P=((Ee=y==null?void 0:y.gameplay)==null?void 0:Ee.tuning)||{},L=y==null?void 0:y.ui,un=(_e=P.button_width)!=null?_e:260,hn=(we=P.button_height)!=null?we:56,yn=(Se=P.button_radius)!=null?Se:16,fn=P.button_bg_color||((He=l.theme)==null?void 0:He.cta_background)||"#ffb43b",gn=(Ce=P.button_bg_alpha)!=null?Ce:1,bn=P.button_border_color||"#ffffff",Tn=(ve=P.button_border_width)!=null?ve:2,Un=(Re=P.button_border_alpha)!=null?Re:.2,ft=(Fe=m.cta_offset_y)!=null?Fe:160,F=document.createElement("button");F.style.cssText=`
82
+ width: ${un}px;
83
+ height: ${hn}px;
84
+ background: ${fn};
85
+ opacity: ${gn};
86
+ border: ${Tn}px solid ${bn};
87
+ border-radius: ${yn}px;
62
88
  cursor: pointer;
63
89
  opacity: 0;
64
90
  position: absolute;
65
91
  transform: translate(-50%, -50%);
66
92
  box-shadow: inset 0 0 1px rgba(0,0,0,0.15);
67
- `,C.style.top=`${ut}px`,C.style.left="50%";let Rt=Q(C);Rt.element=C,w.appendChild(C);let fn=(A==null?void 0:A.text)||((Re=c.ui)==null?void 0:Re.cta_label_end)||"DOWNLOAD",Ct=(A==null?void 0:A.font)||"brand.heading",gn=(A==null?void 0:A.fontSize)||20,bn=P.button_text_color||((Ce=c.theme)==null?void 0:Ce.cta_text)||"#1a0a0a";C.textContent=fn,C.style.fontFamily=N(Ct),C.style.fontSize=`${gn}px`,C.style.fontWeight=String(G(Ct)),C.style.color=bn,C.style.letterSpacing=`${(Me=A==null?void 0:A.letterSpacing)!=null?Me:1}px`;let Mt=Q(C);Mt.element=C;let L=m==null?void 0:m.ui,Ft=((Fe=m==null?void 0:m.gameplay)==null?void 0:Fe.tuning)||{},Tn=(L==null?void 0:L.text)||"Play the full game",$t=(L==null?void 0:L.font)||"brand.body",xn=(L==null?void 0:L.fontSize)||11,_n=($e=L==null?void 0:L.letterSpacing)!=null?$e:0,it=(Ae=m==null?void 0:m.render)==null?void 0:Ae.tint,En=typeof it=="string"?it:it?`#${it.toString(16).padStart(6,"0")}`:"#CCCCCC",K=document.createElement("div");K.textContent=Tn,K.style.cssText=`
68
- font-family: ${N($t)};
69
- font-size: ${xn}px;
70
- font-weight: ${G($t)};
71
- color: ${En};
93
+ `,F.style.top=`${ft}px`,F.style.left="50%";let Mt=Q(F);Mt.element=F,_.appendChild(F);let xn=(L==null?void 0:L.text)||((Me=l.ui)==null?void 0:Me.cta_label_end)||"DOWNLOAD",At=(L==null?void 0:L.font)||"brand.heading",En=(L==null?void 0:L.fontSize)||20,_n=P.button_text_color||((Ae=l.theme)==null?void 0:Ae.cta_text)||"#1a0a0a";F.textContent=xn,F.style.fontFamily=Y(At),F.style.fontSize=`${En}px`,F.style.fontWeight=String(N(At)),F.style.color=_n,F.style.letterSpacing=`${($e=L==null?void 0:L.letterSpacing)!=null?$e:1}px`;let $t=Q(F);$t.element=F;let W=c==null?void 0:c.ui,Lt=((Le=c==null?void 0:c.gameplay)==null?void 0:Le.tuning)||{},wn=(W==null?void 0:W.text)||"Play the full game",Wt=(W==null?void 0:W.font)||"brand.body",Sn=(W==null?void 0:W.fontSize)||11,Hn=(We=W==null?void 0:W.letterSpacing)!=null?We:0,rt=(De=c==null?void 0:c.render)==null?void 0:De.tint,Cn=typeof rt=="string"?rt:rt?`#${rt.toString(16).padStart(6,"0")}`:"#CCCCCC",K=document.createElement("div");K.textContent=wn,K.style.cssText=`
94
+ font-family: ${Y(Wt)};
95
+ font-size: ${Sn}px;
96
+ font-weight: ${N(Wt)};
97
+ color: ${Cn};
72
98
  text-align: center;
73
- letter-spacing: ${_n}px;
99
+ letter-spacing: ${Hn}px;
74
100
  opacity: 0;
75
101
  position: absolute;
76
102
  transform: translate(-50%, -50%);
77
103
  white-space: nowrap;
78
- `;let wn=ut+35+((Le=Ft.animation_start_y_offset)!=null?Le:5);K.style.top=`${wn}px`,K.style.left="50%";let yt=Q(K);yt.element=K,yt.animationStartYOffset=(De=Ft.animation_start_y_offset)!=null?De:5,w.appendChild(K);let ft=((We=r==null?void 0:r.gameplay)==null?void 0:We.tuning)||{},Sn=(ke=ft.hand_offset_x)!=null?ke:50,Hn=(ze=ft.hand_offset_y)!=null?ze:50,vn=(Ye=(Be=r==null?void 0:r.transform)==null?void 0:Be.scale)!=null?Ye:.1875,Rn=(Pe=ft.hand_scale_multiplier)!=null?Pe:2.5,Cn=new U.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),et=new U.Sprite(Cn),At=vn*Rn*100;return et.scale.set(At,At,1),et.position.set(Sn,ut+Hn,0),et.material.opacity=0,et.visible=!1,{panel:T,logo:H,title:Et,subtitle:mt,footer:ht,ctaButton:Rt,ctaText:Mt,ctaHint:yt,hand:et}}function Wn(e,t,n){var S,w,T,W,R,M,D,k;let i=t.objects.get("ui_endgame_1"),a=((S=i==null?void 0:i.gameplay)==null?void 0:S.tuning)||{},s=(w=a.animation_duration_ms)!=null?w:800,o=(T=a.fade_in_duration_ms)!=null?T:600,l=(W=a.scale_animation_intensity)!=null?W:.1,d=(R=a.logo_animation_delay_ms)!=null?R:100,m=(M=a.title_animation_delay_ms)!=null?M:200,r=(D=a.footer_animation_delay_ms)!=null?D:300,c=(k=a.cta_animation_delay_ms)!=null?k:400,{panel:p,logo:g,title:b,subtitle:h,footer:u,ctaButton:y,ctaText:f,ctaHint:_}=e;p.visible=!0,p.element.style.visibility="visible";let x=Date.now(),E=()=>{let j=Date.now()-x,X=Math.min(j/o,1),H=1-Math.pow(1-X,3);p.alpha=H,p.element.style.opacity=H.toString();let z=1+l*(1-H);p.element.style.transform=`translate(-50%, -50%) scale(${z})`,X<1?requestAnimationFrame(E):(setTimeout(()=>kn(g,s,t),d),setTimeout(()=>{zn(b,s),setTimeout(()=>Bn(h,s),50)},m),setTimeout(()=>Yn(u,s),r),setTimeout(()=>{Pn(y,f,s),setTimeout(()=>Nn(_,s),50),n&&n()},c))};E()}function kn(e,t,n){var p,g,b,h,u;let i=n==null?void 0:n.objects.get("ui_endgame_logo_1"),s=(g=(((p=i==null?void 0:i.gameplay)==null?void 0:p.tuning)||{}).animation_start_scale)!=null?g:1.2,o=Date.now(),l=e.material.opacity,d=(b=e.targetAlpha)!=null?b:1,m=(h=e.baseScaleX)!=null?h:e.scale.x,r=(u=e.baseScaleY)!=null?u:e.scale.y,c=()=>{let y=Date.now()-o,f=Math.min(y/t,1),_=1-Math.pow(1-f,2);e.material.opacity=l+(d-l)*_;let x=s+(1-s)*_;e.scale.set(m*x,r*x,1),f<1&&requestAnimationFrame(c)};c()}function zn(e,t){let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=()=>{let o=Date.now()-n,l=Math.min(o/t,1),d=1-Math.pow(1-l,2);e.element.style.opacity=(i+(1-i)*d).toString(),e.element.style.top=`${a-20*(1-d)}px`,l<1&&requestAnimationFrame(s)};s()}function Bn(e,t){var l;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((l=e.animationStartYOffset)!=null?l:-10),o=()=>{let d=Date.now()-n,m=Math.min(d/t,1),r=1-Math.pow(1-m,2);e.element.style.opacity=(i+(1-i)*r).toString(),e.element.style.top=`${a+(s-a)*r}px`,m<1&&requestAnimationFrame(o)};o()}function Yn(e,t){var o;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=(o=e.targetAlpha)!=null?o:1,s=()=>{let l=Date.now()-n,d=Math.min(l/t,1),m=1-Math.pow(1-d,2);e.element.style.opacity=(i+(a-i)*m).toString(),d<1&&requestAnimationFrame(s)};s()}function Pn(e,t,n){let i=Date.now(),a=parseFloat(e.element.style.opacity||"0"),s=()=>{let o=Date.now()-i,l=Math.min(o/n,1),d=1-Math.pow(1-l,2);e.element.style.opacity=(a+(1-a)*d).toString(),t.element.style.opacity=(a+(1-a)*d).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-d)})`,l<1&&requestAnimationFrame(s)};s()}function Nn(e,t){var l;let n=Date.now(),i=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),s=a-((l=e.animationStartYOffset)!=null?l:5),o=()=>{let d=Date.now()-n,m=Math.min(d/t,1),r=1-Math.pow(1-m,2);e.element.style.opacity=(i+(1-i)*r).toString(),e.element.style.top=`${a+(s-a)*r}px`,m<1&&requestAnimationFrame(o)};o()}function Gn(e,t,n,i){var r,c,p,g;let a=n.objects.get("ui_endgame_hand_1"),s=((r=a==null?void 0:a.gameplay)==null?void 0:r.tuning)||{},o=(c=s.click_animation_duration_ms)!=null?c:600,l=(p=s.click_delay_ms)!=null?p:2e3,d=(g=s.click_repeat_delay_ms)!=null?g:3e3,m=()=>{var w,T;e.visible=!0,e.material.opacity=1;let b=e.position.x,h=e.position.y,u=(w=s.hand_offset_x)!=null?w:50,y=(T=s.hand_offset_y)!=null?T:50,f=t.element.getBoundingClientRect(),_=u,x=y,E=Date.now(),S=()=>{var H,z,q;let W=Date.now()-E,R=Math.min(W/o,1),M=R<.5?2*R*R:1-Math.pow(-2*R+2,2)/2;e.position.set(b+(_-b)*M,h+(x-h)*M,0);let D=(z=(H=a==null?void 0:a.transform)==null?void 0:H.scale)!=null?z:.1875,k=(q=s.hand_scale_multiplier)!=null?q:2.5,j=D*k*100,X=j+j*.2*Math.sin(R*Math.PI);e.scale.set(X,X,1),R<1?requestAnimationFrame(S):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",i()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(b,h,0),m()},d)},500))};S()};setTimeout(m,l)}import*as dt from"three";function Xn(e,t,n){var c,p,g,b;let i=t.objects.get("hand_tutorial_1"),a=((c=i==null?void 0:i.gameplay)==null?void 0:c.tuning)||{},s=(i==null?void 0:i.render)||{},o=(i==null?void 0:i.transform)||{},l=new dt.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),d=new dt.Sprite(l);d.position.set(n.x,n.y,0),d.material.opacity=0;let m=(p=a.hand_scale_multiplier)!=null?p:2.5,r=(g=o.scale)!=null?g:.1875;return d.scale.set(r*m*100,r*m*100,1),d.renderOrder=(b=s.z_index)!=null?b:99999,d}function qn(e){var b,h,u,y,f,_,x,E,S;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,i=(t==null?void 0:t.render)||{},a=((b=e.engine.runtime)==null?void 0:b.ui_styles)||{},s=((h=e.engine.runtime)==null?void 0:h.ui)||{},o=(n==null?void 0:n.text)||s.tutorial_label||s.label_text||"CLEAN!",l=(n==null?void 0:n.font)||"brand.warning",d=(n==null?void 0:n.fontSize)||a.label_font_size||52,m=(y=n==null?void 0:n.letterSpacing)!=null?y:(u=a.label_letter_spacing)!=null?u:-1,r=(n==null?void 0:n.align)||"center",c=i.tint,p=typeof c=="string"?c:c?`#${c.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",g=document.createElement("div");return g.textContent=o,g.style.cssText=`
79
- font-family: ${N(l)};
80
- font-size: ${d}px;
81
- font-weight: ${G(l)};
82
- color: ${p};
83
- text-align: ${r};
84
- letter-spacing: ${m}px;
85
- text-shadow: ${(f=a.label_shadow_distance)!=null?f:2}px ${(_=a.label_shadow_distance)!=null?_:2}px ${(x=a.label_shadow_blur)!=null?x:4}px rgba(0,0,0,${(E=a.label_shadow_alpha)!=null?E:.8});
104
+ `;let vn=ft+35+((ke=Lt.animation_start_y_offset)!=null?ke:5);K.style.top=`${vn}px`,K.style.left="50%";let gt=Q(K);gt.element=K,gt.animationStartYOffset=(ze=Lt.animation_start_y_offset)!=null?ze:5,_.appendChild(K);let bt=((Be=u==null?void 0:u.gameplay)==null?void 0:Be.tuning)||{},Rn=(Pe=bt.hand_offset_x)!=null?Pe:50,Fn=(Ye=bt.hand_offset_y)!=null?Ye:50,Mn=(Ge=(Ne=u==null?void 0:u.transform)==null?void 0:Ne.scale)!=null?Ge:.1875,An=(Xe=bt.hand_scale_multiplier)!=null?Xe:2.5,$n=new U.SpriteMaterial({map:t||void 0,transparent:!0,alphaTest:.1}),et=new U.Sprite($n),Dt=Mn*An*100;return et.scale.set(Dt,Dt,1),et.position.set(Rn,ft+Fn,0),et.material.opacity=0,et.visible=!1,{panel:T,logo:C,title:Ht,subtitle:ht,footer:yt,ctaButton:Mt,ctaText:$t,ctaHint:gt,hand:et}}function Pn(e,t,n){var S,H,_,T,R,k,M,D;let s=t.objects.get("ui_endgame_1"),a=((S=s==null?void 0:s.gameplay)==null?void 0:S.tuning)||{},i=(H=a.animation_duration_ms)!=null?H:800,o=(_=a.fade_in_duration_ms)!=null?_:600,p=(T=a.scale_animation_intensity)!=null?T:.1,r=(R=a.logo_animation_delay_ms)!=null?R:100,y=(k=a.title_animation_delay_ms)!=null?k:200,c=(M=a.footer_animation_delay_ms)!=null?M:300,u=(D=a.cta_animation_delay_ms)!=null?D:400,{panel:l,logo:m,title:b,subtitle:x,footer:d,ctaButton:g,ctaText:h,ctaHint:f}=e;l.visible=!0,l.element.style.visibility="visible";let E=Date.now(),w=()=>{let j=Date.now()-E,X=Math.min(j/o,1),G=1-Math.pow(1-X,3);l.alpha=G,l.element.style.opacity=G.toString();let C=1+p*(1-G);l.element.style.transform=`translate(-50%, -50%) scale(${C})`,X<1?requestAnimationFrame(w):(setTimeout(()=>Yn(m,i,t),r),setTimeout(()=>{Nn(b,i),setTimeout(()=>Gn(x,i),50)},y),setTimeout(()=>Xn(d,i),c),setTimeout(()=>{qn(g,h,i),setTimeout(()=>Vn(f,i),50),n&&n()},u))};w()}function Yn(e,t,n){var l,m,b,x,d;let s=n==null?void 0:n.objects.get("ui_endgame_logo_1"),i=(m=(((l=s==null?void 0:s.gameplay)==null?void 0:l.tuning)||{}).animation_start_scale)!=null?m:1.2,o=Date.now(),p=e.material.opacity,r=(b=e.targetAlpha)!=null?b:1,y=(x=e.baseScaleX)!=null?x:e.scale.x,c=(d=e.baseScaleY)!=null?d:e.scale.y,u=()=>{let g=Date.now()-o,h=Math.min(g/t,1),f=1-Math.pow(1-h,2);e.material.opacity=p+(r-p)*f;let E=i+(1-i)*f;e.scale.set(y*E,c*E,1),h<1&&requestAnimationFrame(u)};u()}function Nn(e,t){let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=()=>{let o=Date.now()-n,p=Math.min(o/t,1),r=1-Math.pow(1-p,2);e.element.style.opacity=(s+(1-s)*r).toString(),e.element.style.top=`${a-20*(1-r)}px`,p<1&&requestAnimationFrame(i)};i()}function Gn(e,t){var p;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=a-((p=e.animationStartYOffset)!=null?p:-10),o=()=>{let r=Date.now()-n,y=Math.min(r/t,1),c=1-Math.pow(1-y,2);e.element.style.opacity=(s+(1-s)*c).toString(),e.element.style.top=`${a+(i-a)*c}px`,y<1&&requestAnimationFrame(o)};o()}function Xn(e,t){var o;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=(o=e.targetAlpha)!=null?o:1,i=()=>{let p=Date.now()-n,r=Math.min(p/t,1),y=1-Math.pow(1-r,2);e.element.style.opacity=(s+(a-s)*y).toString(),r<1&&requestAnimationFrame(i)};i()}function qn(e,t,n){let s=Date.now(),a=parseFloat(e.element.style.opacity||"0"),i=()=>{let o=Date.now()-s,p=Math.min(o/n,1),r=1-Math.pow(1-p,2);e.element.style.opacity=(a+(1-a)*r).toString(),t.element.style.opacity=(a+(1-a)*r).toString(),e.element.style.transform=`translate(-50%, -50%) scale(${1+.1*(1-r)})`,p<1&&requestAnimationFrame(i)};i()}function Vn(e,t){var p;let n=Date.now(),s=parseFloat(e.element.style.opacity||"0"),a=parseFloat(e.element.style.top||"0"),i=a-((p=e.animationStartYOffset)!=null?p:5),o=()=>{let r=Date.now()-n,y=Math.min(r/t,1),c=1-Math.pow(1-y,2);e.element.style.opacity=(s+(1-s)*c).toString(),e.element.style.top=`${a+(i-a)*c}px`,y<1&&requestAnimationFrame(o)};o()}function Zn(e,t,n,s){var c,u,l,m;let a=n.objects.get("ui_endgame_hand_1"),i=((c=a==null?void 0:a.gameplay)==null?void 0:c.tuning)||{},o=(u=i.click_animation_duration_ms)!=null?u:600,p=(l=i.click_delay_ms)!=null?l:2e3,r=(m=i.click_repeat_delay_ms)!=null?m:3e3,y=()=>{var H,_;e.visible=!0,e.material.opacity=1;let b=e.position.x,x=e.position.y,d=(H=i.hand_offset_x)!=null?H:50,g=(_=i.hand_offset_y)!=null?_:50,h=t.element.getBoundingClientRect(),f=d,E=g,w=Date.now(),S=()=>{var G,C,q;let T=Date.now()-w,R=Math.min(T/o,1),k=R<.5?2*R*R:1-Math.pow(-2*R+2,2)/2;e.position.set(b+(f-b)*k,x+(E-x)*k,0);let M=(C=(G=a==null?void 0:a.transform)==null?void 0:G.scale)!=null?C:.1875,D=(q=i.hand_scale_multiplier)!=null?q:2.5,j=M*D*100,X=j+j*.2*Math.sin(R*Math.PI);e.scale.set(X,X,1),R<1?requestAnimationFrame(S):(t.element.style.transform="translate(-50%, -50%) scale(0.95)",setTimeout(()=>{t.element.style.transform="translate(-50%, -50%) scale(1)",s()},100),setTimeout(()=>{e.material.opacity=0,setTimeout(()=>{e.position.set(b,x,0),y()},r)},500))};S()};setTimeout(y,p)}import*as ut from"three";function Jn(e,t,n){var u,l,m,b;let s=t.objects.get("hand_tutorial_1"),a=((u=s==null?void 0:s.gameplay)==null?void 0:u.tuning)||{},i=(s==null?void 0:s.render)||{},o=(s==null?void 0:s.transform)||{},p=new ut.SpriteMaterial({map:e||void 0,transparent:!0,alphaTest:.1}),r=new ut.Sprite(p);r.position.set(n.x,n.y,0),r.material.opacity=0;let y=(l=a.hand_scale_multiplier)!=null?l:2.5,c=(m=o.scale)!=null?m:.1875;return r.scale.set(c*y*100,c*y*100,1),r.renderOrder=(b=i.z_index)!=null?b:99999,r}function Kn(e){var b,x,d,g,h,f,E,w,S;let t=e.objects.get("ui_tutorial_1"),n=t==null?void 0:t.ui,s=(t==null?void 0:t.render)||{},a=((b=e.engine.runtime)==null?void 0:b.ui_styles)||{},i=((x=e.engine.runtime)==null?void 0:x.ui)||{},o=(n==null?void 0:n.text)||i.tutorial_label||i.label_text||"CLEAN!",p=(n==null?void 0:n.font)||"brand.warning",r=(n==null?void 0:n.fontSize)||a.label_font_size||52,y=(g=n==null?void 0:n.letterSpacing)!=null?g:(d=a.label_letter_spacing)!=null?d:-1,c=(n==null?void 0:n.align)||"center",u=s.tint,l=typeof u=="string"?u:u?`#${u.toString(16).padStart(6,"0")}`:a.label_fill||"#FFF1C1",m=document.createElement("div");return m.textContent=o,m.style.cssText=`
105
+ font-family: ${Y(p)};
106
+ font-size: ${r}px;
107
+ font-weight: ${N(p)};
108
+ color: ${l};
109
+ text-align: ${c};
110
+ letter-spacing: ${y}px;
111
+ text-shadow: ${(h=a.label_shadow_distance)!=null?h:2}px ${(f=a.label_shadow_distance)!=null?f:2}px ${(E=a.label_shadow_blur)!=null?E:4}px rgba(0,0,0,${(w=a.label_shadow_alpha)!=null?w:.8});
86
112
  -webkit-text-stroke: ${a.label_stroke||"#8B0000"} 2px;
87
- opacity: ${(S=i.alpha)!=null?S:0};
88
- visibility: ${i.visible!==!1?"visible":"hidden"};
113
+ opacity: ${(S=s.alpha)!=null?S:0};
114
+ visibility: ${s.visible!==!1?"visible":"hidden"};
89
115
  pointer-events: none;
90
116
  position: absolute;
91
117
  transform: translate(-50%, -50%);
92
118
  white-space: nowrap;
93
- `,g}function Vn(e,t,n,i,a){var d,m,r,c,p,g,b;let s=a.objects.get("hand_tutorial_1"),o=((d=s==null?void 0:s.gameplay)==null?void 0:d.tuning)||{},l=(s==null?void 0:s.transform)||{};if(!i){let h=(m=o.animation_duration)!=null?m:1.5,u=n%h/h,y=u<.5?2*u*u:-1+(4-2*u)*u,f=(r=o.x_offset)!=null?r:0,_=(c=o.y_offset)!=null?c:0,x=(p=o.animation_range)!=null?p:40,E=x*.7,S=x,w=t.x+f+E,T=t.y+_+S,W=w+E,R=T+S;e.position.set(w+(W-w)*y,T+(R-T)*y,0);let M=(g=l.scale)!=null?g:.1875,D=(b=o.hand_scale_multiplier)!=null?b:2.5,k=M*D*100;e.scale.set(k,k,1)}}import*as tt from"three";var Ne=new tt.TextureLoader;async function Ge(e,t,n=16777215,i=!1){try{let s=(globalThis.INLINE_ASSETS||{})[e];return await Ne.loadAsync(s||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let s=document.createElement("canvas");s.width=64,s.height=64;let o=s.getContext("2d");return o&&(o.fillStyle=`#${n.toString(16).padStart(6,"0")}`,i?o.fillRect(0,0,30,60):(o.beginPath(),o.arc(32,32,30,0,Math.PI*2),o.fill(),o.fillRect(27,32,10,40))),new tt.CanvasTexture(s)}}async function Zn(e,t,n){var b,h,u,y;let a=(globalThis.INLINE_ASSETS||{})[e]||e,s;try{s=await Ne.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(f){let E=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");s=await Ge(e,t,parseInt(E,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:f})}if(!s)return[];let o=n.gameplay.character_sheet||{},l=(b=o.cols)!=null?b:3,d=(h=o.rows)!=null?h:2,m=((u=s.image)==null?void 0:u.width)||0,r=((y=s.image)==null?void 0:y.height)||0,c=m/l,p=r/d;if(!Number.isFinite(c)||!Number.isFinite(p)||c<=0||p<=0)return[s];let g=[];for(let f=0;f<d;f++)for(let _=0;_<l;_++){let x=document.createElement("canvas");x.width=c,x.height=p;let E=x.getContext("2d");E&&s.image&&E.drawImage(s.image,_*c,f*p,c,p,0,0,c,p),g.push(new tt.CanvasTexture(x))}return g.length>2&&g.push(...g.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:g.length}),g}function Jn(e,t){var c,p,g,b;let n=t.gameplay.brush||{},i=t.theme.brush_color||"#ffffff",a=(c=n.radius)!=null?c:20,s=(p=n.inner_radius)!=null?p:15,o=(g=n.alpha)!=null?g:.8,l=(b=n.inner_alpha)!=null?b:.3,d=n.inner_color||"#ffffff",m=document.createElement("canvas");m.width=a*2,m.height=a*2;let r=m.getContext("2d");return r&&(r.clearRect(0,0,m.width,m.height),r.beginPath(),r.arc(a,a,a,0,Math.PI*2),r.fillStyle=i,r.globalAlpha=o,r.fill(),r.beginPath(),r.arc(a,a,s,0,Math.PI*2),r.fillStyle=d,r.globalAlpha=l,r.fill()),new tt.CanvasTexture(m)}export{ct as GameObject,Tt as GameObjectManager,lt as Renderer,rt as Transform,Gn as animateHandClick,Wn as animatePanelEntrance,Jn as createBrushTexture,Dn as createEndGamePanel,Xn as createHandTutorial,$n as createThreeBase,qn as createTutorialLabel,Ln as getRegisteredFontIds,Ge as loadAsset,Zn as loadCharacterFrames,An as registerFont,N as resolveFont,G as resolveFontWeight,Vn as updateHandAnimation};
119
+ `,m}function Qn(e,t,n,s,a){var r,y,c,u,l,m,b;let i=a.objects.get("hand_tutorial_1"),o=((r=i==null?void 0:i.gameplay)==null?void 0:r.tuning)||{},p=(i==null?void 0:i.transform)||{};if(!s){let x=(y=o.animation_duration)!=null?y:1.5,d=n%x/x,g=d<.5?2*d*d:-1+(4-2*d)*d,h=(c=o.x_offset)!=null?c:0,f=(u=o.y_offset)!=null?u:0,E=(l=o.animation_range)!=null?l:40,w=E*.7,S=E,H=t.x+h+w,_=t.y+f+S,T=H+w,R=_+S;e.position.set(H+(T-H)*g,_+(R-_)*g,0);let k=(m=p.scale)!=null?m:.1875,M=(b=o.hand_scale_multiplier)!=null?b:2.5,D=k*M*100;e.scale.set(D,D,1)}}import*as tt from"three";var Ve=new tt.TextureLoader;async function Ze(e,t,n=16777215,s=!1){try{let i=(globalThis.INLINE_ASSETS||{})[e];return await Ve.loadAsync(i||e)}catch{console.warn(`Asset missing: ${e}. Using placeholder.`);let i=document.createElement("canvas");i.width=64,i.height=64;let o=i.getContext("2d");return o&&(o.fillStyle=`#${n.toString(16).padStart(6,"0")}`,s?o.fillRect(0,0,30,60):(o.beginPath(),o.arc(32,32,30,0,Math.PI*2),o.fill(),o.fillRect(27,32,10,40))),new tt.CanvasTexture(i)}}async function jn(e,t,n){var b,x,d,g;let a=(globalThis.INLINE_ASSETS||{})[e]||e,i;try{i=await Ve.loadAsync(a),console.log("[character] loaded sheet",{path:e,sourceUsed:a})}catch(h){let w=((n.gameplay.character_sheet||{}).fallback_color||"#ff00ff").replace("#","");i=await Ze(e,t,parseInt(w,16),!0),console.warn("[character] fallback loadAsset used",{path:e,err:h})}if(!i)return[];let o=n.gameplay.character_sheet||{},p=(b=o.cols)!=null?b:3,r=(x=o.rows)!=null?x:2,y=((d=i.image)==null?void 0:d.width)||0,c=((g=i.image)==null?void 0:g.height)||0,u=y/p,l=c/r;if(!Number.isFinite(u)||!Number.isFinite(l)||u<=0||l<=0)return[i];let m=[];for(let h=0;h<r;h++)for(let f=0;f<p;f++){let E=document.createElement("canvas");E.width=u,E.height=l;let w=E.getContext("2d");w&&i.image&&w.drawImage(i.image,f*u,h*l,u,l,0,0,u,l),m.push(new tt.CanvasTexture(E))}return m.length>2&&m.push(...m.slice(1,-1).reverse()),console.log("[character] frames prepared",{count:m.length}),m}function On(e,t){var u,l,m,b;let n=t.gameplay.brush||{},s=t.theme.brush_color||"#ffffff",a=(u=n.radius)!=null?u:20,i=(l=n.inner_radius)!=null?l:15,o=(m=n.alpha)!=null?m:.8,p=(b=n.inner_alpha)!=null?b:.3,r=n.inner_color||"#ffffff",y=document.createElement("canvas");y.width=a*2,y.height=a*2;let c=y.getContext("2d");return c&&(c.clearRect(0,0,y.width,y.height),c.beginPath(),c.arc(a,a,a,0,Math.PI*2),c.fillStyle=s,c.globalAlpha=o,c.fill(),c.beginPath(),c.arc(a,a,i,0,Math.PI*2),c.fillStyle=r,c.globalAlpha=p,c.fill()),new tt.CanvasTexture(y)}export{qe as AspectClass,mt as GameObject,_t as GameObjectManager,pt as Renderer,nt as ResponsiveUISystem,ct as Transform,Zn as animateHandClick,Pn as animatePanelEntrance,On as createBrushTexture,Bn as createEndGamePanel,Jn as createHandTutorial,Dn as createThreeBase,Kn as createTutorialLabel,Et as getAspectClass,zn as getRegisteredFontIds,Ze as loadAsset,jn as loadCharacterFrames,kn as registerFont,Y as resolveFont,N as resolveFontWeight,Qn as updateHandAnimation};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handler-playable-sdk",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Handler Playable SDK v0.1 with contract-aligned surface (root sandbox, canonical event envelope).",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,17 +0,0 @@
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.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 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};