@tora-editor/tora 0.2.0 → 0.3.0

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.
Files changed (107) hide show
  1. package/README.md +5 -6
  2. package/bin/tora.mjs +255 -29
  3. package/crates/packer/trusted/native-3d-meta.json +3 -3
  4. package/crates/packer/trusted/native-3d.js +180 -180
  5. package/crates/packer/trusted/native-meta.json +3 -3
  6. package/crates/packer/trusted/native.js +5 -5
  7. package/crates/packer/trusted/release-manifest.json +17 -17
  8. package/crates/packer/trusted/review-runtime-meta.json +3 -3
  9. package/crates/packer/trusted/review-runtime.js +182 -182
  10. package/docs/MIGRATION_0_3.md +39 -0
  11. package/docs/NATIVE_AGENT_TOOLS.md +12 -363
  12. package/docs/TORA_AGENT_SETUP.md +24 -106
  13. package/docs/TORA_CREATION_API.md +63 -365
  14. package/docs/reference/CORE_AUTHORING.md +8 -2
  15. package/docs/reference/PLAYABLE_STARTERS.md +1 -1
  16. package/docs/reference/packs/3d.md +2 -0
  17. package/package.json +6 -6
  18. package/packages/creative-project/project-v21.schema.json +108 -1
  19. package/scripts/lean/editor/entry.js +11 -6
  20. package/scripts/lean/editor/project-launcher.js +116 -0
  21. package/scripts/lean/editor/quick-edit-panel.js +479 -0
  22. package/scripts/lean/editor/review-editor.css +246 -68
  23. package/scripts/lean/editor/review-editor.js +1731 -1099
  24. package/scripts/lean/editor-state.mjs +6 -0
  25. package/scripts/lean/editor.mjs +6 -3
  26. package/scripts/lean/matrix.mjs +5 -0
  27. package/scripts/lean/native/agent-tools.mjs +35 -58
  28. package/scripts/lean/native/api.mjs +148 -134
  29. package/scripts/lean/native/audio-assets.mjs +30 -0
  30. package/scripts/lean/native/browser-pool.mjs +34 -0
  31. package/scripts/lean/native/build-cache.mjs +36 -5
  32. package/scripts/lean/native/contracts.mjs +8 -6
  33. package/scripts/lean/native/creative-qa.mjs +66 -12
  34. package/scripts/lean/native/demos.mjs +11 -20
  35. package/scripts/lean/native/document.mjs +14 -2
  36. package/scripts/lean/native/local-bundle.mjs +4 -2
  37. package/scripts/lean/native/mcp-server.mjs +16 -35
  38. package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
  39. package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
  40. package/scripts/lean/native/modules/star-salvage.mjs +3 -368
  41. package/scripts/lean/native/project-bundle.mjs +3 -2
  42. package/scripts/lean/native/project-index.mjs +0 -2
  43. package/scripts/lean/native/qa-adapters.mjs +10 -0
  44. package/scripts/lean/native/quick-edit.mjs +328 -0
  45. package/scripts/lean/native/review.mjs +203 -572
  46. package/scripts/lean/native/schema-vocabulary.mjs +10 -0
  47. package/scripts/lean/native/schema.mjs +1 -1
  48. package/scripts/lean/native/scope.mjs +45 -0
  49. package/scripts/lean/native/service.mjs +242 -70
  50. package/scripts/lean/native/starters.mjs +135 -8
  51. package/scripts/lean/native/variant-adapters.mjs +8 -0
  52. package/scripts/lean/native/variants-core.mjs +186 -0
  53. package/scripts/lean/native/variants.mjs +63 -0
  54. package/scripts/lean/native/win-cues.mjs +1 -1
  55. package/skills/tora-playables/SKILL.md +1 -1
  56. package/scripts/lean/editor/review-intake.js +0 -837
  57. package/scripts/lean/model-client.mjs +0 -119
  58. package/scripts/lean/native/author-expansion-proofs.mjs +0 -143
  59. package/scripts/lean/native/author-fps.mjs +0 -545
  60. package/scripts/lean/native/author-games.mjs +0 -160
  61. package/scripts/lean/native/author-harvest.mjs +0 -74
  62. package/scripts/lean/native/author-primitive-proofs.mjs +0 -875
  63. package/scripts/lean/native/author-salvage.mjs +0 -71
  64. package/scripts/lean/native/chat-compose.mjs +0 -287
  65. package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -190
  66. package/scripts/lean/native/check-salvage.mjs +0 -200
  67. package/scripts/lean/native/compatibility.mjs +0 -34
  68. package/scripts/lean/native/concept.mjs +0 -633
  69. package/scripts/lean/native/draw-stroke.mjs +0 -26
  70. package/scripts/lean/native/erase-mask.mjs +0 -18
  71. package/scripts/lean/native/glb-loader.mjs +0 -468
  72. package/scripts/lean/native/harvest-recipe.mjs +0 -21
  73. package/scripts/lean/native/instance-steering.mjs +0 -24
  74. package/scripts/lean/native/intake-creator-agent.mjs +0 -98
  75. package/scripts/lean/native/intake-creator-tools.mjs +0 -218
  76. package/scripts/lean/native/interaction-gestures.mjs +0 -45
  77. package/scripts/lean/native/match-board.mjs +0 -138
  78. package/scripts/lean/native/modules/index.mjs +0 -54
  79. package/scripts/lean/native/modules/tap-collect.mjs +0 -54
  80. package/scripts/lean/native/path-network.mjs +0 -132
  81. package/scripts/lean/native/physics-2d.mjs +0 -154
  82. package/scripts/lean/native/physics-3d.mjs +0 -259
  83. package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
  84. package/scripts/lean/native/prepare-fps-assets.mjs +0 -330
  85. package/scripts/lean/native/prepare-game-audio.mjs +0 -372
  86. package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
  87. package/scripts/lean/native/prepare-golf-assets.py +0 -211
  88. package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
  89. package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
  90. package/scripts/lean/native/prepare-primitive-images.py +0 -25
  91. package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
  92. package/scripts/lean/native/prepare-traffic-assets.py +0 -329
  93. package/scripts/lean/native/presentation.mjs +0 -335
  94. package/scripts/lean/native/review-agent-tools.mjs +0 -561
  95. package/scripts/lean/native/review-connection.mjs +0 -303
  96. package/scripts/lean/native/review-fields.mjs +0 -24
  97. package/scripts/lean/native/review-intake.mjs +0 -385
  98. package/scripts/lean/native/review-intents.mjs +0 -217
  99. package/scripts/lean/native/review-provider.mjs +0 -580
  100. package/scripts/lean/native/review-receipts.mjs +0 -76
  101. package/scripts/lean/native/review-resolver.mjs +0 -429
  102. package/scripts/lean/native/review-targets.mjs +0 -35
  103. package/scripts/lean/native/runtime.mjs +0 -1809
  104. package/scripts/lean/native/salvage-recipe.mjs +0 -20
  105. package/scripts/lean/native/stage-3d.mjs +0 -1121
  106. package/scripts/lean/native/verify.mjs +0 -4
  107. package/scripts/lean/scene-document.mjs +0 -48
@@ -1,5 +1,5 @@
1
- var ToraNative=(()=>{var Fa=Object.defineProperty;var Sf=Object.getOwnPropertyDescriptor;var kf=Object.getOwnPropertyNames;var Cf=Object.prototype.hasOwnProperty;var Ef=(e,t)=>{for(var n in t)Fa(e,n,{get:t[n],enumerable:!0})},Pf=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of kf(t))!Cf.call(e,l)&&l!==n&&Fa(e,l,{get:()=>t[l],enumerable:!(a=Sf(t,l))||a.enumerable});return e};var Tf=e=>Pf(Fa({},"__esModule",{value:!0}),e);var od={};Ef(od,{computeSafeArea:()=>lo,createNetworkBridge:()=>Tl,layoutStandardText:()=>Al,mountNative:()=>ad});var Fo=function(e,t){if(!e)throw Error(t)},jt=function(){return[1,0,0,1,0,0]};function Xa(e){return Fo(Array.isArray(e)&&e.length===6&&e.every(Number.isFinite),"E_SCENE_MATRIX"),e}function ai(e,t){return Xa(e),Xa(t),[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function Yt(e){Xa(e);var t=e[0]*e[3]-e[1]*e[2];return Fo(Math.abs(t)>1e-12,"E_SCENE_SINGULAR_TRANSFORM"),[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[3]*e[4])/t,(e[1]*e[4]-e[0]*e[5])/t]}var Ya=function(){return Ya=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},Ya.apply(this,arguments)},_t=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Fn=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},Ua=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Xo(e){var t=e.rows,n=e.columns,a=e.seed,l=e.slots,i=e.paint,v=e.onEvent,c=l.map(function(X){return X.group}),E=Fn([],_t(new Set(c)),!1),f=Fn([],_t(c),!1),M=a,k="idle",B=0,re,U,Y=[],oe=[],_=0,ee=0,y=0,O,Re,Pe=function(X,ve){return X*n+ve},be=function(X){return Math.floor(X/n)},Le=function(X){return X%n},Z=function(){return M=Math.imul(M,1664525)+1013904223>>>0,M/4294967296};function ue(X){for(var ve=new Set,Ne=0;Ne<t;Ne++)for(var se=0;se<n;se++){var ke=Pe(Ne,se),$e=X[ke];if(se+2<n&&$e===X[ke+1]&&$e===X[ke+2])for(var Ue=0;Ue<3;Ue++)ve.add(ke+Ue);if(Ne+2<t&&$e===X[ke+n]&&$e===X[ke+n*2])for(var Ue=0;Ue<3;Ue++)ve.add(ke+n*Ue)}return Fn([],_t(ve),!1)}function ae(X,ve){var Ne;if(f[X]===f[ve])return!1;var se=Fn([],_t(f),!1);return Ne=_t([se[ve],se[X]],2),se[X]=Ne[0],se[ve]=Ne[1],ue(se).some(function(ke){return ke===X||ke===ve})}function he(){for(var X=[],ve=0;ve<f.length;ve++)Le(ve)+1<n&&ae(ve,ve+1)&&X.push({from:l[ve].id,to:l[ve+1].id}),be(ve)+1<t&&ae(ve,ve+n)&&X.push({from:l[ve].id,to:l[ve+n].id});return X}function R(){for(var X=0;X<64;X++){f=[];for(var ve=function(se){var ke=E.filter(function($e){return!(Le(se)>=2&&f[se-1]===$e&&f[se-2]===$e)&&!(be(se)>=2&&f[se-n]===$e&&f[se-n*2]===$e)});f.push(ke[Math.floor(Z()*ke.length)])},Ne=0;Ne<l.length;Ne++)ve(Ne);if(he().length)return}f=l.map(function(se,ke){return E[(be(ke)*2+Le(ke))%3]}),f[0]=E[0],f[1]=E[1],f[2]=E[0],f[n+1]=E[0]}function b(){for(var X=0;X<l.length;X++)i(X,f[X],{})}function K(){M=a,f=Fn([],_t(c),!1),k="idle",B=0,re=void 0,U=void 0,Y=[],oe=[],_=0,ee=0,y=0,O=void 0,Re=void 0,(ue(f).length||!he().length)&&R(),b()}function L(X,ve){if(k!=="idle")return!1;var Ne=l.findIndex(function(ke){return ke.id===X}),se=l.findIndex(function(ke){return ke.id===ve});return Ne<0||se<0||Math.abs(be(Ne)-be(se))+Math.abs(Le(Ne)-Le(se))!==1?!1:(re=void 0,O=void 0,b(),U=[Ne,se],k="swap",B=0,!0)}function fe(X){if(k==="idle"){if(re===X){re=void 0;return}if(!(re&&L(re,X)))return re=X,re}}function J(){Y=ue(f),y+=Y.length,Re={group:f[Y[0]],from:l[Y[0]].id,count:Y.length},v("matchClear"),k="clear",B=0}function Q(){var X=new Set(Y),ve=Fn([],_t(f),!1);oe=[];for(var Ne=0;Ne<n;Ne++){for(var se=[],ke=t-1;ke>=0;ke--)X.has(Pe(ke,Ne))||se.push(Pe(ke,Ne));for(var $e=0,ke=t-1;ke>=0;ke--){var Ue=Pe(ke,Ne),lr=se[t-1-ke];lr!==void 0?(ve[Ue]=f[lr],oe.push({cell:Ue,from:lr,offsetRows:0})):(ve[Ue]=E[Math.floor(Z()*E.length)],oe.push({cell:Ue,from:Ue,offsetRows:-(ke+1+$e++)}))}}f=ve,k="fall",B=0}function j(){if(ue(f).length&&_<3){_++,J();return}(ue(f).length||!he().length)&&R(),b(),k="idle",B=0,U=void 0,Y=[],oe=[],ee++,v("validMatch")}function ye(X){var ve,Ne,se,ke,$e,Ue,lr;if(k==="idle"){if(O){O.elapsed+=X;var Pr=1+.065*Math.sin(Math.min(1,O.elapsed/.8)*Math.PI*4),zr=function(Ar){i(l.findIndex(function(tn){return tn.id===Ar}),f[l.findIndex(function(tn){return tn.id===Ar})],{scale:Pr})};try{for(var Wr=Ua(O.ids),Tr=Wr.next();!Tr.done;Tr=Wr.next()){var pn=Tr.value;zr(pn)}}catch(Ar){ve={error:Ar}}finally{try{Tr&&!Tr.done&&(Ne=Wr.return)&&Ne.call(Wr)}finally{if(ve)throw ve.error}}O.elapsed>=.8&&(O=void 0,b())}return}if(B+=X,k==="swap"||k==="reverse"){var Ke=Math.min(1,B/.14),It=Ke*Ke*(3-2*Ke),Ze=_t(U,2),Gt=Ze[0],tt=Ze[1];if(i(Gt,f[Gt],{from:tt,progress:k==="swap"?It:1-It}),i(tt,f[tt],{from:Gt,progress:k==="swap"?It:1-It}),Ke<1)return;if(k==="reverse"){b(),k="idle",U=void 0,v("invalidMatch");return}if(!ae(Gt,tt)){k="reverse",B=0;return}se=_t([f[tt],f[Gt]],2),f[Gt]=se[0],f[tt]=se[1],b(),J();return}if(k==="clear"){var At=Math.min(1,B/.18),Pr=At<.22?1+At*.45:Math.max(.05,1.1*(1-At)/.78);try{for(var mn=Ua(Y),xt=mn.next();!xt.done;xt=mn.next()){var Rt=xt.value;i(Rt,f[Rt],{scale:Pr,opacity:1-At})}}catch(tn){ke={error:tn}}finally{try{xt&&!xt.done&&($e=mn.return)&&$e.call(mn)}finally{if(ke)throw ke.error}}At===1&&Q();return}var Dt=Math.min(1,B/.25),rn=1-Math.pow(1-Dt,3);try{for(var bt=Ua(oe),lt=bt.next();!lt.done;lt=bt.next()){var yt=lt.value;i(yt.cell,f[yt.cell],{from:yt.from,offsetRows:yt.offsetRows,progress:1-rn})}}catch(Ar){Ue={error:Ar}}finally{try{lt&&!lt.done&&(lr=bt.return)&&lr.call(bt)}finally{if(Ue)throw Ue.error}}Dt===1&&j()}function le(){if(k==="idle"){re=void 0;var X=he()[0];X&&(O={ids:[X.from,X.to],elapsed:0})}}function Ie(){var X;return{phase:k,busy:k!=="idle",selected:re!=null?re:null,moves:ee,cleared:y,groups:Fn([],_t(f),!1),legalMoves:k==="idle"?he():[],hint:(X=O==null?void 0:O.ids)!==null&&X!==void 0?X:[],lastMatch:Re?Ya({},Re):null}}return{reset:K,select:fe,swap:L,tick:ye,showHint:le,snapshot:Ie,cancelSelection:function(){re=void 0,O&&(O=void 0,b())}}}var na=function(){return na=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},na.apply(this,arguments)},Uo=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Af=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},Yo=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Go(){var e=new Map,t=new Map,n=function(l){var i,v,c=t.get(l);c!==void 0&&((i=e.get(c))===null||i===void 0||i.delete(l),((v=e.get(c))===null||v===void 0?void 0:v.size)===0&&e.delete(c)),t.delete(l)},a=function(l,i){n(l),i!=null&&(e.has(i)||e.set(i,new Set),e.get(i).add(l),t.set(l,i))};return{occupants:e,itemZone:t,release:n,place:a,clear:function(){e.clear(),t.clear()},items:function(l){var i;return Af([],Uo((i=e.get(l))!==null&&i!==void 0?i:[]),!1).sort()},zoneOf:function(l){return t.get(l)},snapshot:function(){return{itemZone:Object.fromEntries(t)}}}}function ia(e){var t,n,a=e.itemId,l=e.tag,i=l===void 0?"":l,v=e.zones,c=e.occupancy,E=v.filter(function(U){var Y,oe,_;return U.id!==a&&(((oe=(Y=U.acceptTags)===null||Y===void 0?void 0:Y.length)!==null&&oe!==void 0?oe:0)===0||((_=U.acceptTags)===null||_===void 0?void 0:_.includes(i)))});E.sort(function(U,Y){return Number(Y.itemTarget)-Number(U.itemTarget)||Y.paintOrder-U.paintOrder||U.distance-Y.distance||U.id.localeCompare(Y.id)});try{for(var f=Yo(E),M=f.next();!M.done;M=f.next()){var k=M.value,B=c.items(k.id).filter(function(U){return U!==a}),re=k.capacity>0&&B.length>=k.capacity;return k.snapMode==="reject"?{kind:"reject",zone:k,occupantId:B[0]}:re?k.onOccupied==="emit"?{kind:"emit",zone:k,occupantId:B[0]}:k.onOccupied==="swap"&&B.length?{kind:"swap",zone:k,occupantId:B[0]}:{kind:"reject",zone:k,occupantId:B[0]}:{kind:"accept",zone:k}}}catch(U){t={error:U}}finally{try{M&&!M.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}return null}function Zo(e,t,n,a,l,i){if(n===void 0&&(n=28),a===void 0&&(a=-1/0),l===void 0&&(l=0),i===void 0&&(i=80),l-a<i)return null;var v=t.x-e.x,c=t.y-e.y;return Math.max(Math.abs(v),Math.abs(c))<n?null:Math.abs(v)>Math.abs(c)?v<0?"left":"right":c<0?"up":"down"}function $o(e,t){var n=t,a=1;return{tick:function(l){return e.pingPong?(n+=a*e.ratePerSecond*l,n>=e.max?(n=e.max,a=-1):n<=e.min&&(n=e.min,a=1)):n=Math.max(e.min,Math.min(e.max,n+e.ratePerSecond*l)),n}}}function Ko(){var e=new Map;return{to:function(t,n,a,l,i){l===void 0&&(l=.18),e.set(t,{from:na({},n),to:na({},a),seconds:Math.max(.02,l),elapsed:0,onDone:i})},cancel:function(t){e.delete(t)},clear:function(){e.clear()},tick:function(t,n){var a,l,i;try{for(var v=Yo(e),c=v.next();!c.done;c=v.next()){var E=Uo(c.value,2),f=E[0],M=E[1];M.elapsed+=t;var k=Math.min(1,M.elapsed/M.seconds),B=1-Math.pow(1-k,3);n(f,{x:M.from.x+(M.to.x-M.from.x)*B,y:M.from.y+(M.to.y-M.from.y)*B}),k===1&&(e.delete(f),(i=M.onDone)===null||i===void 0||i.call(M))}}catch(re){a={error:re}}finally{try{c&&!c.done&&(l=v.return)&&l.call(v)}finally{if(a)throw a.error}}}}}function Ga(e,t,n,a){n===void 0&&(n=56),a===void 0&&(a=.12);var l=Math.max(1,n),i=t.x-e.x,v=t.y-e.y,c=Math.hypot(i,v),E=Math.min(c,l),f=E/l,M=c>1e-6?i/c:0,k=c>1e-6?v/c:0,B=e.x+M*E,re=e.y+k*E;if(f<=a)return{nx:0,ny:0,magnitude:0,angle:0,knobX:B,knobY:re};var U=(f-a)/Math.max(1e-6,1-a);return{nx:M*U,ny:k*U,magnitude:U,angle:Math.atan2(k,M)*180/Math.PI,knobX:B,knobY:re}}var Za=function(){return Za=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},Za.apply(this,arguments)},Qo=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function $a(e){var t,n,a=2166136261;try{for(var l=Qo(String(e)),i=l.next();!i.done;i=l.next()){var v=i.value;a^=v.codePointAt(0),a=Math.imul(a,16777619)}}catch(c){t={error:c}}finally{try{i&&!i.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return a>>>0||1}function Ka(e){var t=e>>>0||1,n=t;return{next:function(){return n=Math.imul(n,1664525)+1013904223>>>0,n/4294967296},between:function(a,l,i){if(i===void 0&&(i=!1),i){var v=Math.ceil(a),c=Math.floor(l);return c<v?v:Math.min(c,v+Math.floor((c-v+1)*this.next()))}return a+(l-a)*this.next()},reset:function(){n=t}}}function Jo(e,t,n,a,l){var i,v;a===void 0&&(a=0);var c=null,E=1/0;try{for(var f=Qo(t),M=f.next();!M.done;M=f.next()){var k=M.value;if(!(k.id===l||k.team!==n)){var B=Math.hypot(k.x-e.x,k.y-e.y);a>0&&B>a||(B<E||B===E&&k.id<(c==null?void 0:c.id))&&(c=k,E=B)}}}catch(re){i={error:re}}finally{try{M&&!M.done&&(v=f.return)&&v.call(f)}finally{if(i)throw i.error}}return c}function qo(e,t,n){var a=((t-e+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return e+Math.max(-n,Math.min(n,a))}function jo(e){var t=Ka(e),n=new Map,a=new Map;return{rng:t,states:n,headings:a,reset:function(){t.reset(),n.clear(),a.clear()},initialize:function(l,i){var v;return n.has(l)||n.set(l,{hp:i.hp,maxHp:i.maxHp,value:i.value,tag:(v=i.tag)!==null&&v!==void 0?v:"",team:i.team}),n.get(l)},remove:function(l){n.delete(l),a.delete(l)},snapshot:function(l){var i=n.get(l);return i?Za({},i):void 0}}}function _o(e,t){var n,a,l,i,v=t===void 0?{}:t,c=v.width,E=v.height,f=v.onProgress,M=f===void 0?function(){}:f,k=v.onComplete,B=k===void 0?function(){}:k,re=v.canvasFactory,U=v.source,Y=e,oe=Y.gridSize,_=new Uint8Array(oe*oe),ee=0,y=!1,O=-1,Re=!1,Pe=Math.max(1,c),be=Math.max(1,E),Le=Math.min(1,512/Math.max(Pe,be)),Z=(n=re==null?void 0:re())!==null&&n!==void 0?n:!((a=globalThis.document)===null||a===void 0)&&a.createElement?globalThis.document.createElement("canvas"):void 0;Z&&(Z.width=Math.max(1,Math.round(Pe*Le)),Z.height=Math.max(1,Math.round(be*Le)));var ue=(l=Z==null?void 0:Z.getContext)===null||l===void 0?void 0:l.call(Z,"2d"),ae=(i=Y.maskColor)!==null&&i!==void 0?i:"#dceeff",he=function(){return!!(U&&U.complete&&U.naturalWidth>0)},R=function(){ue&&(ue.globalCompositeOperation="source-over",ue.clearRect(0,0,Z.width,Z.height),Y.mode==="erase"&&(he()?(ue.drawImage(U,0,0,Z.width,Z.height),Re=!0):(ue.fillStyle=ae,ue.fillRect(0,0,Z.width,Z.height),Re=!1)))};R();var b=function(){if(!y){var L=Math.round(ee/_.length*100),fe=Math.min(100,L);fe!==O&&(O=fe,M(fe)),fe>=Y.targetPercent&&(y=!0,B(fe))}},K=function(L,fe){for(var J=Math.max(0,Math.min(oe-1,Math.floor(L/Pe*oe))),Q=Math.max(0,Math.min(oe-1,Math.floor(fe/be*oe))),j=Math.max(0,Math.ceil(Y.brushRadiusPx/Pe*oe)),ye=Math.max(0,Math.ceil(Y.brushRadiusPx/be*oe)),le=Math.max(0,Q-ye);le<=Math.min(oe-1,Q+ye);le++)for(var Ie=Math.max(0,J-j);Ie<=Math.min(oe-1,J+j);Ie++)if(!(Math.hypot((Ie+.5)/oe*Pe-L,(le+.5)/oe*be-fe)>Y.brushRadiusPx)){var X=le*oe+Ie;_[X]||(_[X]=1,ee++)}ue&&(ue.save(),ue.scale(Le,Le),ue.globalCompositeOperation=Y.mode==="erase"?"destination-out":"source-over",ue.fillStyle=ae,ue.beginPath(),ue.arc(L,fe,Y.brushRadiusPx,0,Math.PI*2),ue.fill(),Y.mode==="reveal"&&U&&(ue.globalCompositeOperation="source-in",ue.drawImage(U,0,0,Pe,be)),ue.restore()),b()};return{canvas:Z,stampSegment:function(L,fe){for(var J=Math.hypot(fe.x-L.x,fe.y-L.y),Q=Math.max(1,Math.ceil(J/Math.max(1,Y.brushRadiusPx*.45))),j=0;j<=Q;j++)K(L.x+(fe.x-L.x)*j/Q,L.y+(fe.y-L.y)*j/Q)},reset:function(){_.fill(0),ee=0,y=!1,O=-1,R(),b()},get progress(){return Math.round(ee/_.length*100)},render:function(L){Y.mode==="erase"&&ee===0&&!Re&&he()&&R(),Z?L.drawImage(Z,0,0,Z.width,Z.height,0,0,c,E):Y.mode==="erase"&&this.progress<100&&(L.save(),L.globalAlpha=1-this.progress/100,L.fillStyle=ae,L.fillRect(0,0,c,E),L.restore())}}}var Xn=function(){return Xn=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},Xn.apply(this,arguments)},Rf=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Qa(e,t,n,a){var l=function(M,k,B){return(k.x-M.x)*(B.y-M.y)-(k.y-M.y)*(B.x-M.x)},i=l(e,t,n),v=l(e,t,a),c=l(n,a,e),E=l(n,a,t),f=1e-8;return Math.abs(i)<f&&Math.abs(v)<f&&Math.abs(c)<f&&Math.abs(E)<f?Math.max(Math.min(e.x,t.x),Math.min(n.x,a.x))<=Math.min(Math.max(e.x,t.x),Math.max(n.x,a.x))+f&&Math.max(Math.min(e.y,t.y),Math.min(n.y,a.y))<=Math.min(Math.max(e.y,t.y),Math.max(n.y,a.y))+f:i>0!=v>0&&c>0!=E>0}function el(e,t){for(var n=!1,a=0,l=t.length-1;a<t.length;l=a++){var i=t[a],v=t[l];i.y>e.y!=v.y>e.y&&e.x<(v.x-i.x)*(e.y-i.y)/(v.y-i.y)+i.x&&(n=!n)}return n}function rl(e,t,n){if(n.length>=3&&(el(e,n)||el(t,n)))return!0;for(var a=0;a<n.length;a++)if(Qa(e,t,n[a],n[(a+1)%n.length]))return!0;return!1}function tl(e){var t=e,n=[],a=null,l=0,i=function(v){return Xn(Xn({},v),{points:v.points.map(function(c){return Xn({},c)})})};return{begin:function(v){var c={id:++l,points:[Xn({},v)],age:0,hitIds:new Set};return a=c,n.push(c),n.length>t.maxStrokes&&n.shift(),c},add:function(v){if(!a||a.points.length>=t.maxPoints)return!1;var c=a.points[a.points.length-1];return Math.hypot(v.x-c.x,v.y-c.y)<t.minSegmentPx?!1:(a.points.push(Xn({},v)),!0)},end:function(){var v=a;return a=null,v?i(v):void 0},cancel:function(){a&&(n=n.filter(function(v){return v!==a})),a=null},clear:function(){a=null,n=[]},tick:function(v){var c,E;try{for(var f=Rf(n),M=f.next();!M.done;M=f.next()){var k=M.value;k.age+=v}}catch(B){c={error:B}}finally{try{M&&!M.done&&(E=f.return)&&E.call(f)}finally{if(c)throw c.error}}n=n.filter(function(B){return B===a||B.age<.18||t.mode!=="slice-blade"})},get active(){return a},get strokes(){return n}}}function nl(e,t){for(var n=[],a=1;a<e.points.length;a++){var l=e.points[a-1],i=e.points[a],v=Math.hypot(i.x-l.x,i.y-l.y);v<.001||n.push({id:"stroke-".concat(e.id,"-").concat(a),strokeId:e.id,mode:"static",shape:"box",x:(l.x+i.x)/2,y:(l.y+i.y)/2,width:v,height:Math.max(2,t),angle:Math.atan2(i.y-l.y,i.x-l.x),restitution:.8})}return n}var ki=function(){return ki=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},ki.apply(this,arguments)},dl=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},En=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Of=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},hn=function(e,t){return Math.hypot(e,t)},il=function(e,t,n){return Math.max(t,Math.min(n,e))},Un=function(e){return Math.max(1,Math.min(e.width,e.height)/2)};function al(e){var t,n,a=Math.cos((t=e.angle)!==null&&t!==void 0?t:0),l=Math.sin((n=e.angle)!==null&&n!==void 0?n:0),i=e.width/2,v=e.height/2;return[[-i,-v],[i,-v],[i,v],[-i,v]].map(function(c){var E=dl(c,2),f=E[0],M=E[1];return{x:e.x+f*a-M*l,y:e.y+f*l+M*a}})}function Vf(e,t){var n,a,l,i,v,c,E,f,M,k,B=al(e),re=al(t),U=[(E=e.angle)!==null&&E!==void 0?E:0,((f=e.angle)!==null&&f!==void 0?f:0)+Math.PI/2,(M=t.angle)!==null&&M!==void 0?M:0,((k=t.angle)!==null&&k!==void 0?k:0)+Math.PI/2],Y=1/0,oe=1,_=0;try{for(var ee=En(U),y=ee.next();!y.done;y=ee.next()){var O=y.value,Re=Math.cos(O),Pe=Math.sin(O),be=1/0,Le=-1/0,Z=1/0,ue=-1/0;try{for(var ae=(l=void 0,En(B)),he=ae.next();!he.done;he=ae.next()){var R=he.value,b=R.x*Re+R.y*Pe;b<be&&(be=b),b>Le&&(Le=b)}}catch(J){l={error:J}}finally{try{he&&!he.done&&(i=ae.return)&&i.call(ae)}finally{if(l)throw l.error}}try{for(var K=(v=void 0,En(re)),L=K.next();!L.done;L=K.next()){var R=L.value,b=R.x*Re+R.y*Pe;b<Z&&(Z=b),b>ue&&(ue=b)}}catch(J){v={error:J}}finally{try{L&&!L.done&&(c=K.return)&&c.call(K)}finally{if(v)throw v.error}}var fe=Math.min(Le,ue)-Math.max(be,Z);if(fe<=0)return null;fe<Y&&(Y=fe,oe=Re,_=Pe)}}catch(J){n={error:J}}finally{try{y&&!y.done&&(a=ee.return)&&a.call(ee)}finally{if(n)throw n.error}}return(e.x-t.x)*oe+(e.y-t.y)*_<0&&(oe=-oe,_=-_),{nx:oe,ny:_,penetration:Y}}function ol(e,t){var n,a,l,i=Un(e),v=-((n=t.angle)!==null&&n!==void 0?n:0),c=Math.cos(v),E=Math.sin(v),f=e.x-t.x,M=e.y-t.y,k=f*c-M*E,B=f*E+M*c,re=t.width/2,U=t.height/2,Y=il(k,-re,re),oe=il(B,-U,U),_=k-Y,ee=B-oe,y=hn(_,ee),O;if(y>=i)return null;if(y<1e-4){var Re=[{d:re-Math.abs(k),x:k>=0?1:-1,y:0},{d:U-Math.abs(B),x:0,y:B>=0?1:-1}].sort(function(Le,Z){return Le.d-Z.d});_=Re[0].x,ee=Re[0].y,O=i+Re[0].d}else _/=y,ee/=y,O=i-y;var Pe=Math.cos((a=t.angle)!==null&&a!==void 0?a:0),be=Math.sin((l=t.angle)!==null&&l!==void 0?l:0);return{nx:_*Pe-ee*be,ny:_*be+ee*Pe,penetration:O}}function ll(e,t){var n;return!!(e.ignoreGroup&&e.ignoreGroup!=="none"&&(e.ignoreGroup==="all"||e.ignoreGroup===((n=t.collisionGroup)!==null&&n!==void 0?n:"all")))}function fl(e,t,n){var a,l,i,v,c,E;if(!(e.captured||t.captured||ll(e,t)||ll(t,e))){var f=e.x-t.x,M=e.y-t.y,k;if(e.shape==="circle"&&t.shape==="circle"){var B=hn(f,M),re=Un(e)+Un(t)-B;if(re<=0)return;k=re,B>1e-4?(f/=B,M/=B):(f=1,M=0)}else if(e.shape==="circle"&&t.shape==="box"){var U=ol(e,t);if(!U)return;f=U.nx,M=U.ny,k=U.penetration}else if(e.shape==="box"&&t.shape==="circle"){var U=ol(t,e);if(!U)return;f=-U.nx,M=-U.ny,k=U.penetration}else if(e.shape==="box"&&t.shape==="box"){var U=Vf(e,t);if(!U)return;f=U.nx,M=U.ny,k=U.penetration}else return;var Y=e.mode==="dynamic"?1/((a=e.mass)!==null&&a!==void 0?a:1):0,oe=t.mode==="dynamic"?1/((l=t.mass)!==null&&l!==void 0?l:1):0,_=Y+oe;if(_){e.x+=f*k*Y/_,e.y+=M*k*Y/_,t.mode==="dynamic"&&(t.x-=f*k*oe/_,t.y-=M*k*oe/_);var ee=e.vx-((i=t.vx)!==null&&i!==void 0?i:0),y=e.vy-((v=t.vy)!==null&&v!==void 0?v:0),O=ee*f+y*M;if(!(O>=0)){var Re=Math.max((c=e.restitution)!==null&&c!==void 0?c:0,(E=t.restitution)!==null&&E!==void 0?E:0),Pe=-(1+Re)*O/_;e.vx+=f*Pe*Y,e.vy+=M*Pe*Y,t.mode==="dynamic"&&(t.vx-=f*Pe*oe,t.vy-=M*Pe*oe),e.atRest=!1,e.restElapsed=0,t.mode==="dynamic"&&(t.atRest=!1,t.restElapsed=0),Math.abs(O)>4&&(n("bodyBounce",e,t,{speed:Math.abs(O)}),t.mode==="dynamic"&&n("bodyBounce",t,e,{speed:Math.abs(O)}))}}}}function Nf(e,t,n,a){var l,i;if(!(e.mode!=="dynamic"||e.captured))try{for(var v=En(t),c=v.next();!c.done;c=v.next()){var E=c.value,f=E.x-e.x,M=E.y-e.y,k=hn(f,M);if(!(k>=E.radius*2.5)){if(k>E.radius&&k>.001&&E.pullStrength>0){var B=E.pullStrength*(1-k/(E.radius*2.5));e.vx+=f/k*B*n,e.vy+=M/k*B*n}if(k<E.radius&&hn(e.vx,e.vy)<=E.maxCaptureSpeed){e.captured=!0,e.atRest=!0,e.vx=E.stopBody?0:e.vx,e.vy=E.stopBody?0:e.vy,E.stopBody&&(e.x=E.x,e.y=E.y),a("zoneCapture",e,E,{});return}}}}catch(re){l={error:re}}finally{try{c&&!c.done&&(i=v.return)&&i.call(v)}finally{if(l)throw l.error}}}function Bf(e,t){var n,a,l,i,v,c,E=function(B){if(B.broken)return"continue";var re=t.find(function(be){return be.id===B.bodyId}),U=t.find(function(be){return be.id===B.anchorId});if(!re||re.mode!=="dynamic")return"continue";var Y=(i=(l=U==null?void 0:U.x)!==null&&l!==void 0?l:B.x)!==null&&i!==void 0?i:0,oe=(c=(v=U==null?void 0:U.y)!==null&&v!==void 0?v:B.y)!==null&&c!==void 0?c:0,_=re.x-Y,ee=re.y-oe,y=hn(_,ee);if(y<=B.lengthPx||y<1e-4)return"continue";var O=_/y,Re=ee/y;re.x=Y+O*B.lengthPx,re.y=oe+Re*B.lengthPx;var Pe=re.vx*O+re.vy*Re;Pe>0&&(re.vx-=O*Pe,re.vy-=Re*Pe)};try{for(var f=En(e),M=f.next();!M.done;M=f.next()){var k=M.value;E(k)}}catch(B){n={error:B}}finally{try{M&&!M.done&&(a=f.return)&&a.call(f)}finally{if(n)throw n.error}}}function Ja(e){for(var t,n,a,l,i,v,c,E,f,M,k,B=e.bodies,re=e.zones,U=re===void 0?[]:re,Y=e.joints,oe=Y===void 0?[]:Y,_=e.bounds,ee=e.dt,y=e.onEvent,O=y===void 0?function(){}:y,Re=B.filter(function(se){return se.mode==="dynamic"&&!se.captured}),Pe=Re.reduce(function(se,ke){return Math.max(se,hn(ke.vx,ke.vy))},0),be=Re.reduce(function(se,ke){return Math.min(se,Un(ke))},24),Le=Math.min(16,Math.max(1,Math.ceil(Pe*ee/(be*.45)))),Z=ee/Le,ue=0;ue<Le;ue++){try{for(var ae=(t=void 0,En(Re)),he=ae.next();!he.done;he=ae.next()){var R=he.value;R.vy+=((c=R.gravity)!==null&&c!==void 0?c:0)*Z;var b=hn(R.vx,R.vy);if(b>R.maxSpeed){var K=R.maxSpeed/b;R.vx*=K,R.vy*=K,b=R.maxSpeed}R.x+=R.vx*Z,R.y+=R.vy*Z;var L=Math.max(0,b-((E=R.friction)!==null&&E!==void 0?E:0)*Z),fe=Math.exp(-((f=R.linearDamping)!==null&&f!==void 0?f:0)*Z);if(b>1e-4){var J=L/b*fe;R.vx*=J,R.vy*=J}R.spinToRotation&&(R.angle=((M=R.angle)!==null&&M!==void 0?M:0)+hn(R.vx,R.vy)*Z/Un(R)*(R.vx<0?-1:1))}}catch(se){t={error:se}}finally{try{he&&!he.done&&(n=ae.return)&&n.call(ae)}finally{if(t)throw t.error}}for(var Q=0;Q<Re.length;Q++){var R=Re[Q];try{for(var j=(a=void 0,En(B)),ye=j.next();!ye.done;ye=j.next()){var le=ye.value;le.id!==R.id&&le.mode!=="dynamic"&&fl(R,le,O)}}catch(ke){a={error:ke}}finally{try{ye&&!ye.done&&(l=j.return)&&l.call(j)}finally{if(a)throw a.error}}for(var le=Q+1;le<Re.length;le++)fl(Re[le],R,O);var Ie=R.shape==="box"?R.width/2:Un(R),X=R.shape==="box"?R.height/2:Un(R);R.wallBounce?(R.x-Ie<_.left&&(R.x=_.left+Ie,R.vx<0&&(O("bodyBounce",R,null,{speed:Math.abs(R.vx)}),R.vx=-R.vx*R.restitution)),R.x+Ie>_.right&&(R.x=_.right-Ie,R.vx>0&&(O("bodyBounce",R,null,{speed:Math.abs(R.vx)}),R.vx=-R.vx*R.restitution)),R.y-X<_.top&&(R.y=_.top+X,R.vy<0&&(O("bodyBounce",R,null,{speed:Math.abs(R.vy)}),R.vy=-R.vy*R.restitution)),R.y+X>_.bottom&&(R.y=_.bottom-X,R.vy>0&&(O("bodyBounce",R,null,{speed:Math.abs(R.vy)}),R.vy=-R.vy*R.restitution))):!R.exited&&(R.x+Ie<_.left||R.x-Ie>_.right||R.y+X<_.top||R.y-X>_.bottom)&&(R.exited=!0,O("boundaryExit",R,null,{})),Nf(R,U,Z,O)}Bf(oe,B)}try{for(var ve=En(Re),Ne=ve.next();!Ne.done;Ne=ve.next()){var R=Ne.value,b=hn(R.vx,R.vy);b<R.restSpeed&&!R.captured?(R.restElapsed=((k=R.restElapsed)!==null&&k!==void 0?k:0)+ee,R.restElapsed>=R.restDelaySeconds&&!R.atRest&&(R.atRest=!0,R.vx=0,R.vy=0,O("bodyRest",R,null,{}))):b>=R.restSpeed&&(R.restElapsed=0,R.atRest=!1)}}catch(se){i={error:se}}finally{try{Ne&&!Ne.done&&(v=ve.return)&&v.call(ve)}finally{if(i)throw i.error}}}function ul(e){for(var t=e.body,n=e.bodies,a=e.zones,l=a===void 0?[]:a,i=e.bounds,v=e.dots,c=v===void 0?8:v,E=e.bounces,f=E===void 0?1:E,M=function(y){return ki({},y)},k=M(t),B=n.filter(function(y){return y.id!==t.id}).map(M),re=Of([k],dl(B),!1),U=[],Y=0,oe=!1,_=function(y,O,Re,Pe){y==="bodyBounce"&&Pe.sourceId===t.id&&Y++,y==="zoneCapture"&&Pe.sourceId===t.id&&(oe=!0)},ee=0;ee<90&&U.length<c&&!oe&&Y<=f;ee++)Ja({bodies:re,zones:l,bounds:i,dt:1/60,onEvent:function(y,O,Re,Pe){return _(y,O,Re,ki(ki({},Pe),{sourceId:O.id}))}}),ee%Math.max(1,Math.floor(90/c))===0&&U.push({x:k.x,y:k.y});return U}var yn=function(){return yn=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},yn.apply(this,arguments)},Wt=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Lt=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},Ci=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},vl=function(e,t,n){return Math.max(t,Math.min(n,e))},Pn=function(e,t){return Math.hypot(t.x-e.x,t.y-e.y)};function sl(e){var t=e.id,n=e.nodes,a=e.edges,l=e.gates,i=l===void 0?[]:l,v=e.onEvent,c=v===void 0?function(){}:v,E=new Map(n.map(function(b){return[b.id,yn({},b)]})),f=new Map(a.map(function(b){return[b.id,yn({speedScale:1,enabled:!0,bidirectional:!1,cost:0},b)]})),M=new Map(i.map(function(b){return[b.id,yn({},b)]})),k=new Map,B=k,re=0,U=0,Y=function(b){return E.get(b)},oe=function(b){return Lt([],Wt(M.values()),!1).find(function(K){return K.parameters.nodeId===b})},_=function(b){var K=b.parameters;if(K.mode==="open")return!0;if(K.mode==="closed")return!1;var L=K.openSeconds+K.closedSeconds,fe=(re+K.phaseOffsetSeconds)%L;return fe<K.openSeconds},ee=function(b){return Lt([],Wt(f.values()),!1).filter(function(K){return K.enabled&&(K.from===b||K.bidirectional&&K.to===b)}).sort(function(K,L){return K.id<L.id?-1:K.id>L.id?1:0})},y=function(b,K){return Lt([],Wt(f.values()),!1).find(function(L){return L.enabled&&(L.from===b&&L.to===K||L.bidirectional&&L.from===K&&L.to===b)})};function O(b,K){var L,fe,J,Q;if(b===K)return[b];for(var j=new Map([[b,0]]),ye=new Map,le=new Set([b]);le.size;){var Ie=Lt([],Wt(le),!1).sort(function(Wr,Tr){return j.get(Wr)-j.get(Tr)||(Wr<Tr?-1:Wr>Tr?1:0)})[0];if(le.delete(Ie),Ie===K)break;try{for(var X=(L=void 0,Ci(ee(Ie))),ve=X.next();!ve.done;ve=X.next()){var Ne=ve.value,se=Ne.from===Ie?Ne.to:Ne.from,ke=oe(se),$e=Y(se),Ue=ke?ke.parameters.holdSeconds*90+(_(ke)?0:ke.parameters.closedSeconds*90):0,lr=j.get(Ie)+Pn(Y(Ie),$e)/Ne.speedScale+Ne.cost+((J=$e.cost)!==null&&J!==void 0?J:0)+Ue;lr>=((Q=j.get(se))!==null&&Q!==void 0?Q:1/0)||(j.set(se,lr),ye.set(se,Ie),le.add(se))}}catch(Wr){L={error:Wr}}finally{try{ve&&!ve.done&&(fe=X.return)&&fe.call(X)}finally{if(L)throw L.error}}}if(!j.has(K))return[];for(var Pr=[K],zr=K;zr!==b;)zr=ye.get(zr),Pr.unshift(zr);return Pr}function Re(b){var K,L=b.route.length>=2&&b.segment<b.route.length-1;if(!L){var fe=(K=b.route[Math.min(b.segment,b.route.length-1)])!==null&&K!==void 0?K:b.startNode,J=O(fe,b.target);b.route=J.length?J:[fe],b.segment=0,b.distance=0,b.arrived=!1,b.active=b.route.length>=2;return}var Q=b.route[b.segment],j=b.route[b.segment+1],ye=Pn(Y(Q),Y(j));if(b.arrived||b.distance>=ye-1e-4){var J=O(j,b.target);b.route=J.length?J:[j],b.segment=0,b.distance=0,b.arrived=!1,b.active=b.route.length>=2;return}var le=O(j,b.target);b.route=le.length?Lt([Q],Wt(le),!1):[Q,j],b.segment=0}function Pe(b){var K,L=O(b.startNode,b.targetNode),fe=Y(b.startNode),J=L.length>=2?Y(L[1]):fe,Q=L.length>=2?Math.atan2(J.y-fe.y,J.x-fe.x):0,j=Math.floor((Q%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4,ye=yn(yn({},b),{loop:(K=b.loop)!==null&&K!==void 0?K:"none",originNode:b.startNode,destinationNode:b.targetNode,target:b.targetNode,networkId:t,route:L.length?L:[b.startNode],segment:0,distance:0,x:fe.x,y:fe.y,heading:Q,frame:[0,1,2,3][j],flipX:Math.cos(Q)<0,hold:0,arrived:!1,active:b.active&&L.length>=2,blockedTicks:0,blockedEmitted:!1,speedMultiplier:1});return k.set(ye.id,ye),ye}function be(b){if(Le("pathArrive",b,b.target),b.loop==="none"){b.active=!1;return}var K=b.target,L=b.loop==="ping-pong"?K===b.destinationNode?b.originNode:b.destinationNode:K===b.originNode?b.destinationNode:b.originNode;b.startNode=K,b.target=L,b.route=O(K,L),b.segment=0,b.distance=0,b.arrived=!1,b.route.length<2&&(b.active=!1)}function Le(b,K,L){c(b,{componentId:K.id,nodeId:L})}function Z(b,K){var L,fe,J=b.route[b.segment+1],Q=oe(J);if(Q&&!_(Q)){b.blockedTicks++,b.blockedTicks>=30&&!b.blockedEmitted&&(b.blockedEmitted=!0,Le("pathBlocked",b,J));return}if(!b.arrived){if(b.arrived=!0,b.segment+1===b.route.length-1){J===b.target?be(b):(b.active=!1,b.blockedEmitted||(b.blockedEmitted=!0,Le("pathBlocked",b,J)));return}b.hold=Math.max((L=Y(J).holdSeconds)!==null&&L!==void 0?L:0,(fe=Q==null?void 0:Q.parameters.holdSeconds)!==null&&fe!==void 0?fe:0)}if(b.hold>0){b.hold=Math.max(0,b.hold-K),b.blockedTicks++,b.blockedTicks>=30&&!b.blockedEmitted&&(b.blockedEmitted=!0,Le("pathBlocked",b,J));return}b.segment++,b.distance=0,b.arrived=!1,b.blockedTicks=0,b.blockedEmitted=!1}function ue(b,K){var L,fe;if(b.spacing<=0)return K;var J=b.route[b.segment],Q=b.route[b.segment+1],j=Pn(Y(J),Y(Q)),ye=j-b.distance,le=K;try{for(var Ie=Ci(B.values()),X=Ie.next();!X.done;X=Ie.next()){var ve=X.value;if(!(ve.id===b.id||!ve.active||ve.route.length<2||ve.segment>=ve.route.length-1)){var Ne=ve.route[ve.segment],se=ve.route[ve.segment+1],ke=1/0;if(Ne===J&&se===Q&&(ve.distance>b.distance||ve.distance===b.distance&&ve.id<b.id))ke=ve.distance-b.distance;else if(Ne===Q)ke=ye+ve.distance;else if(se===Q&&Ne!==J){var $e=Pn(Y(Ne),Y(se))-ve.distance;$e<b.spacing&&($e<ye||$e===ye&&ve.id<b.id)&&(ke=ye)}ke<1/0&&(le=Math.min(le,Math.max(0,ke-b.spacing)))}}}catch(Ue){L={error:Ue}}finally{try{X&&!X.done&&(fe=Ie.return)&&fe.call(Ie)}finally{if(L)throw L.error}}return le}function ae(b){var K=Y(b.route[b.segment]),L=Y(b.route[b.segment+1]),fe=Pn(K,L),J=vl(b.distance/Math.max(1e-4,fe),0,1),Q=K.x+(L.x-K.x)*J,j=K.y+(L.y-K.y)*J,ye=Math.atan2(L.y-K.y,L.x-K.x),le=Math.min(b.cornerRadius,fe/3),Ie=b.route[b.segment+2];if(le>0&&Ie){var X=Y(Ie),ve=Pn(L,X),Ne=Math.min(le,ve/3);if(b.distance>fe-le){var se={x:L.x-(L.x-K.x)/fe*le,y:L.y-(L.y-K.y)/fe*le},ke={x:L.x+(X.x-L.x)/ve*Ne,y:L.y+(X.y-L.y)/ve*Ne},$e=vl((b.distance-(fe-le))/(le*2),0,.5),Ue=1-$e;Q=Ue*Ue*se.x+2*Ue*$e*L.x+$e*$e*ke.x,j=Ue*Ue*se.y+2*Ue*$e*L.y+$e*$e*ke.y;var lr=2*Ue*(L.x-se.x)+2*$e*(ke.x-L.x),Pr=2*Ue*(L.y-se.y)+2*$e*(ke.y-L.y);Math.abs(lr)+Math.abs(Pr)>.001&&(ye=Math.atan2(Pr,lr))}}return{x:Q,y:j,heading:ye}}function he(b){var K,L,fe,J;re+=b,U++;var Q=Lt([],Wt(k.values()),!1).sort(function(Ke,It){return Ke.id<It.id?-1:Ke.id>It.id?1:0}),j=Q.length?U%Q.length:0,ye=Lt(Lt([],Wt(Q.slice(j)),!1),Wt(Q.slice(0,j)),!1);try{for(var le=Ci(ye),Ie=le.next();!Ie.done;Ie=le.next()){var X=Ie.value;if(!(!X.active||X.route.length<2||X.segment>=X.route.length-1)){var ve=X.route[X.segment],Ne=X.route[X.segment+1],se=Pn(Y(ve),Y(Ne));if(!(X.distance>=se-1e-4&&(Z(X,b),!X.active||X.route.length<2||X.segment>=X.route.length-1))){var ke=X.route[X.segment],$e=X.route[X.segment+1],Ue=Pn(Y(ke),Y($e)),lr=Ue-X.distance,Pr=(J=(fe=y(ke,$e))===null||fe===void 0?void 0:fe.speedScale)!==null&&J!==void 0?J:1,zr=Math.min(lr,X.speed*Pr*Math.max(0,X.speedMultiplier)*b),Wr=ue(X,zr);Wr<=1e-4?(X.blockedTicks++,X.blockedTicks>=30&&!X.blockedEmitted&&(X.blockedEmitted=!0,Le("pathBlocked",X,$e))):(X.distance+=Wr,X.blockedTicks=0,X.blockedEmitted=!1);var Tr=ae(X);X.x=Tr.x,X.y=Tr.y,X.heading=Tr.heading;var pn=Math.floor((X.heading%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4;X.frame=[0,1,2,3][pn],X.flipX=Math.cos(X.heading)<0}}}}catch(Ke){K={error:Ke}}finally{try{Ie&&!Ie.done&&(L=le.return)&&L.call(le)}finally{if(K)throw K.error}}}function R(){return{id:t,nodeCount:E.size,edgeCount:f.size,activeAgents:Lt([],Wt(k.values()),!1).filter(function(b){return b.active}).length,queuedAgents:Lt([],Wt(k.values()),!1).filter(function(b){return b.active&&b.blockedTicks>0}).length,agents:Lt([],Wt(k.values()),!1).map(function(b){var K;return{id:b.id,x:b.x,y:b.y,heading:b.heading,frame:(K=b.frame)!==null&&K!==void 0?K:0,flipX:!!b.flipX,active:b.active,targetNode:b.target,route:Lt([],Wt(b.route),!1),segment:b.segment,distance:b.distance,blocked:b.blockedTicks>0}})}}return{addAgent:Pe,removeAgent:function(b){return k.delete(b)},getAgent:function(b){return k.get(b)},setTarget:function(b,K){var L=k.get(b);return!L||!Y(K)?!1:(L.target=K,L.destinationNode=K,L.active=!0,Re(L),!0)},setEdge:function(b,K,L){var fe,J,Q=f.get(b);if(!Q)return!1;Q.enabled=K,L!==void 0&&(Q.cost=L);try{for(var j=Ci(k.values()),ye=j.next();!ye.done;ye=j.next()){var le=ye.value;Re(le)}}catch(Ie){fe={error:Ie}}finally{try{ye&&!ye.done&&(J=j.return)&&J.call(j)}finally{if(fe)throw fe.error}}return!0},setGate:function(b,K,L){var fe,J,Q=M.get(b);if(!Q)return!1;Q.parameters=yn(yn({},Q.parameters),{mode:K,holdSeconds:L});try{for(var j=Ci(k.values()),ye=j.next();!ye.done;ye=j.next()){var le=ye.value;Re(le)}}catch(Ie){fe={error:Ie}}finally{try{ye&&!ye.done&&(J=j.return)&&J.call(j)}finally{if(fe)throw fe.error}}return!0},tick:he,snapshot:R}}var Ei=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},aa=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},oa=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},la={A:["01110","10001","10001","11111","10001","10001","10001"],B:["11110","10001","10001","11110","10001","10001","11110"],C:["01111","10000","10000","10000","10000","10000","01111"],D:["11110","10001","10001","10001","10001","10001","11110"],E:["11111","10000","10000","11110","10000","10000","11111"],F:["11111","10000","10000","11110","10000","10000","10000"],G:["01111","10000","10000","10111","10001","10001","01111"],H:["10001","10001","10001","11111","10001","10001","10001"],I:["11111","00100","00100","00100","00100","00100","11111"],J:["00111","00010","00010","00010","10010","10010","01100"],K:["10001","10010","10100","11000","10100","10010","10001"],L:["10000","10000","10000","10000","10000","10000","11111"],M:["10001","11011","10101","10101","10001","10001","10001"],N:["10001","11001","10101","10011","10001","10001","10001"],O:["01110","10001","10001","10001","10001","10001","01110"],P:["11110","10001","10001","11110","10000","10000","10000"],Q:["01110","10001","10001","10001","10101","10010","01101"],R:["11110","10001","10001","11110","10100","10010","10001"],S:["01111","10000","10000","01110","00001","00001","11110"],T:["11111","00100","00100","00100","00100","00100","00100"],U:["10001","10001","10001","10001","10001","10001","01110"],V:["10001","10001","10001","10001","10001","01010","00100"],W:["10001","10001","10001","10101","10101","10101","01010"],X:["10001","10001","01010","00100","01010","10001","10001"],Y:["10001","10001","01010","00100","00100","00100","00100"],Z:["11111","00001","00010","00100","01000","10000","11111"],0:["01110","10001","10011","10101","11001","10001","01110"],1:["00100","01100","00100","00100","00100","00100","01110"],2:["01110","10001","00001","00010","00100","01000","11111"],3:["11110","00001","00001","01110","00001","00001","11110"],4:["00010","00110","01010","10010","11111","00010","00010"],5:["11111","10000","10000","11110","00001","00001","11110"],6:["01110","10000","10000","11110","10001","10001","01110"],7:["11111","00001","00010","00100","01000","01000","01000"],8:["01110","10001","10001","01110","10001","10001","01110"],9:["01110","10001","10001","01111","00001","00001","01110"],"!":["00100","00100","00100","00100","00100","00000","00100"],"?":["01110","10001","00001","00010","00100","00000","00100"],".":["00000","00000","00000","00000","00000","00110","00110"],",":["00000","00000","00000","00000","00110","00110","00100"],":":["00000","00110","00110","00000","00110","00110","00000"],"+":["00000","00100","00100","11111","00100","00100","00000"],"-":["00000","00000","00000","11111","00000","00000","00000"],"/":["00001","00010","00010","00100","01000","01000","10000"],"'":["00100","00100","00000","00000","00000","00000","00000"]," ":["000","000","000","000","000","000","000"]},Pi=function(e){var t,n,a,l,i=0;try{for(var v=Ei(e),c=v.next();!c.done;c=v.next()){var E=c.value;i+=((l=(a=la[E])===null||a===void 0?void 0:a[0].length)!==null&&l!==void 0?l:5)+1}}catch(f){t={error:f}}finally{try{c&&!c.done&&(n=v.return)&&n.call(v)}finally{if(t)throw t.error}}return Math.max(0,i-1)},zf=function(e,t){var n,a,l=[],i="";try{for(var v=Ei(e),c=v.next();!c.done;c=v.next()){var E=c.value;i&&Pi(i+E)>t&&(l.push(i),i=""),i+=E}}catch(f){n={error:f}}finally{try{c&&!c.done&&(a=v.return)&&a.call(v)}finally{if(n)throw n.error}}return i&&l.push(i),l};function Wf(e,t,n){var a,l,i,v,c;n===void 0&&(n=1);var E=Math.max(1,Math.floor(t/Math.max(1,n))),f=[];try{for(var M=Ei(String(e).toUpperCase().split(`
2
- `)),k=M.next();!k.done;k=M.next()){var B=k.value,re=B.split(/\s+/).filter(Boolean);if(!re.length){f.push("");continue}var U="";try{for(var Y=(i=void 0,Ei(re)),oe=Y.next();!oe.done;oe=Y.next()){var _=oe.value;if(Pi(_)>E){U&&f.push(U);var ee=zf(_,E);f.push.apply(f,oa([],aa(ee.slice(0,-1)),!1)),U=(c=ee.at(-1))!==null&&c!==void 0?c:""}else{var y=U?U+" "+_:_;Pi(y)<=E?U=y:(U&&f.push(U),U=_)}}}catch(O){i={error:O}}finally{try{oe&&!oe.done&&(v=Y.return)&&v.call(Y)}finally{if(i)throw i.error}}U&&f.push(U)}}catch(O){a={error:O}}finally{try{k&&!k.done&&(l=M.return)&&l.call(M)}finally{if(a)throw a.error}}return f}var cl=function(e){var t,n=Math.max(0,(t=e.padding)!==null&&t!==void 0?t:4),a=e.pixelPanel&&e.padding===void 0;return{x:a?8:n,y:a?4:n}},Lf=function(e,t,n,a){var l,i=t.wrap===!1?String(e).toUpperCase().split(`
3
- `):Wf(e,a,n),v=i.slice(0,16),c=Math.round(n*8*((l=t.lineHeight)!==null&&l!==void 0?l:1.2));return{allLines:i,lines:v,renderedWidth:Math.max.apply(Math,oa([0],aa(v.map(function(E){return Pi(E)*n})),!1)),renderedHeight:(v.length-1)*c+7*n}};function qa(e,t){for(var n,a=cl(t),l=Math.max(0,t.width-2*a.x),i=Math.max(0,t.height-2*a.y),v=Math.max(1,Math.floor(t.fontSize/8)),c=t.autoFit===!1?v:Math.min(v,Math.max(1,Math.ceil(((n=t.minFontSize)!==null&&n!==void 0?n:12)/8))),E=oa([],aa(new Set(oa([],aa(String(e).toUpperCase()),!1).filter(function(U){return U!==`
4
- `&&!la[U]}))),!1),f,M=v;M>=c;M--){var k=Lf(e,t,M,l),B=k.renderedWidth>l,re=k.allLines.length>16||k.renderedHeight>i;if(f={lines:k.lines,scale:M,fontSize:M*8,renderedWidth:k.renderedWidth,renderedHeight:k.renderedHeight,overflowsWidth:B,overflowsHeight:re,unsupportedChars:E},t.autoFit===!1||!B&&!re)break}return f}function hl(e,t,n){var a,l=qa(t,n),i=l.lines,v=l.scale,c=cl(n),E=Math.max(0,n.width-2*c.x),f=Math.max(0,n.height-2*c.y),M=Math.round(l.fontSize*((a=n.lineHeight)!==null&&a!==void 0?a:1.2)),k=c.y+(f-l.renderedHeight)/2;return e.fillStyle=n.color,i.forEach(function(B,re){var U,Y,oe,_=Pi(B)*v,ee=n.align==="left"?c.x:n.align==="right"?n.width-_-c.x:c.x+(E-_)/2,y=ee;try{for(var O=Ei(B),Re=O.next();!Re.done;Re=O.next()){var Pe=Re.value,be=(oe=la[Pe])!==null&&oe!==void 0?oe:la["?"];be.forEach(function(Le,Z){for(var ue=0;ue<Le.length;ue++)Le[ue]==="1"&&e.fillRect(Math.round(y+ue*v),Math.round(k+re*M+Z*v),v,v)}),y+=(be[0].length+1)*v}}catch(Le){U={error:Le}}finally{try{Re&&!Re.done&&(Y=O.return)&&Y.call(O)}finally{if(U)throw U.error}}}),l}var en=function(){return en=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},en.apply(this,arguments)},_a=Math.PI*2,Mr=function(e,t){return((Math.imul(e+1,2654435769)^Math.imul(t,2246822507))>>>0)/4294967296};function eo(e,t,n){var a,l,i=[e.color,e.color2,e.color3].filter(Boolean),v=((a=e.spread)!==null&&a!==void 0?a:360)*Math.PI/180,c=((l=e.direction)!==null&&l!==void 0?l:-90)*Math.PI/180;return Array.from({length:e.count},function(E,f){var M,k,B=c+((f+.2+Mr(f,1)*.6)/e.count-.5)*v,re=e.speed*(.42+.65*Mr(f,2));return en(en({},t),{clipId:n,shape:"pixel-confetti",age:-.12*Mr(f,3),vx:Math.cos(B)*re,vy:Math.sin(B)*re,gravity:(M=e.gravity)!==null&&M!==void 0?M:250,life:((k=e.lifetime)!==null&&k!==void 0?k:.7)*(.6+.4*Mr(f,4)),color:i[f%i.length],size:3+Math.floor(3*Mr(f,5)),angle:_a*Mr(f,6),spin:(Mr(f,7)-.5)*12})})}function yl(e){var t=Math.min(12,Math.ceil(Math.sqrt(e.count))),n=Math.ceil(e.count/t),a=e.speed;return eo(e).map(function(l,i){return en(en({},l),{screen:!0,x:(i%t+.15+.7*Mr(i,8))/t,y:(Math.floor(i/t)+.15+.7*Mr(i,9))/n,vx:a*(Mr(i,10)-.5)*.7,vy:a*(.3+.5*Mr(i,11)),size:l.size+1})})}var da=function(e,t){return(e%t+t)%t};function pl(e,t,n){var a=t.x,l=t.y,i=t.vx,v=t.vy,c=t.age,E=t.life,f=t.gravity,M=t.size,k=t.angle,B=t.spin,re=t.color;if(!(c<0)){var U=i*c,Y=v*c+f*c*c/2,oe=Math.round(n?n.x+da(a*n.width+U,n.width):a+U),_=Math.round(n?n.y+da(l*n.height+Y,n.height):l+Y),ee=Math.round((k+B*c)/(Math.PI/4))&3;if(e.globalAlpha*=Math.min(1,(E-c)*4),e.fillStyle="#3c293388",ee===0)e.fillRect(oe-M+1,_+1,M*2+1,M+1);else if(ee===2)e.fillRect(oe+1,_-M+1,M+1,M*2+1);else for(var y=-1;y<=1;y++)e.fillRect(oe+y*M+1,_+y*M*(ee===1?1:-1)+1,M+1,M+1);if(e.fillStyle=re,ee===0)e.fillRect(oe-M,_,M*2,M);else if(ee===2)e.fillRect(oe,_-M,M,M*2);else for(var y=-1;y<=1;y++)e.fillRect(oe+y*M,_+y*M*(ee===1?1:-1),M,M)}}function ro(e,t,n){var a,l,i=[e.color,e.color2,e.color3,"#ff6b6b","#4ecdc4","#fff3b0"].filter(Boolean),v=((a=e.spread)!==null&&a!==void 0?a:360)*Math.PI/180,c=((l=e.direction)!==null&&l!==void 0?l:-90)*Math.PI/180;return Array.from({length:e.count},function(E,f){var M,k,B=c+((f+.2+Mr(f,11)*.6)/e.count-.5)*v,re=e.speed*(.45+.65*Mr(f,12));return en(en({},t),{clipId:n,shape:"confetti",age:-.15*Mr(f,13),vx:Math.cos(B)*re,vy:Math.sin(B)*re,gravity:(M=e.gravity)!==null&&M!==void 0?M:140,life:((k=e.lifetime)!==null&&k!==void 0?k:2.6)*(.75+.35*Mr(f,14)),color:i[f%i.length],size:5+Math.floor(5*Mr(f,15)),kind:f%5===0?"star":"ribbon",angle:_a*Mr(f,16),spin:(Mr(f,17)-.5)*5.5,flutter:1.6+2.2*Mr(f,18),phase:_a*Mr(f,19)})})}function ml(e){var t=Math.min(14,Math.ceil(Math.sqrt(e.count))),n=Math.ceil(e.count/t),a=e.speed;return ro(e,{x:0,y:0}).map(function(l,i){var v;return en(en({},l),{screen:!0,x:(i%t+.12+.76*Mr(i,20))/t,y:(Math.floor(i/t)+.08+.84*Mr(i,21))/n,vx:a*(Mr(i,22)-.5)*.65,vy:a*(.38+.55*Mr(i,23)),gravity:Math.min((v=e.gravity)!==null&&v!==void 0?v:90,90)})})}function gl(e,t,n){var a=t.x,l=t.y,i=t.vx,v=t.vy,c=t.age,E=t.life,f=t.gravity,M=t.size,k=t.angle,B=t.spin,re=t.flutter,U=t.phase,Y=t.color,oe=t.kind;if(!(c<0)){var _=Math.sin(c*re+U)*14,ee=i*c+_,y=v*c+f*c*c/2,O=n?n.x+da(a*n.width+ee,n.width):a+ee,Re=n?n.y+da(l*n.height+y,n.height):l+y,Pe=Math.min(1,c*2.8,(E-c)*2.2);if(!(Pe<=0)){e.save(),e.globalAlpha*=Pe,e.translate(O,Re),e.rotate(k+B*c);var be=Math.cos(c*re*1.4+U);if(e.scale(1,Math.max(.22,Math.abs(be))),e.fillStyle=Y,oe==="star"){var Le=M*.85;e.beginPath();for(var Z=0;Z<8;Z++){var ue=Z%2===0?Le:Le*.38,ae=Z*Math.PI/4;Z===0?e.moveTo(Math.cos(ae)*ue,Math.sin(ae)*ue):e.lineTo(Math.cos(ae)*ue,Math.sin(ae)*ue)}e.closePath(),e.fill()}else e.fillRect(-M*.7,-M*.34,M*1.4,M*.68),e.fillStyle="#ffffff55",e.fillRect(-M*.7,-M*.34,M*1.4,M*.2);e.restore()}}}function Il(e,t,n,a,l){var i=t.width,v=t.height;if(!(i<=0||v<=0)){var c=Math.min(3,Math.floor(Math.min(i,v)/8));if(!c){e.fillStyle=n,e.fillRect(0,0,i,v);return}var E=a?c*2:0,f=v-(a?c:c*3),M=l>=0?.5+.5*Math.sin(l*4):0;t.enabled&&!a&&l>=0&&(e.save(),e.shadowColor="#ffd05a99",e.shadowBlur=8+M*9,e.fillStyle=n,e.fillRect(c,E+c,i-2*c,v-E-2*c),e.restore()),e.fillStyle=t.stroke,e.fillRect(c,0,i-2*c,v),e.fillRect(0,c,i,v-2*c),e.fillStyle=n,e.fillRect(c,E+c,i-2*c,v-E-2*c),e.fillStyle="#431d1380",e.fillRect(c,f,i-2*c,v-c-f),e.fillStyle=t.enabled?"#fff4be":"#ffffff55",e.fillRect(2*c,E+c,i-4*c,a?c:c*2),e.fillStyle="#ffffff55",e.fillRect(c,E+3*c,c,Math.max(0,f-E-3*c)),e.fillStyle="#521b2444",e.fillRect(i-2*c,E+3*c,c,Math.max(0,f-E-3*c));var k=l>=0?l%1.9:-1,B=(k-.1)/.55;if(t.enabled&&!a&&B>=0&&B<1){e.save(),e.beginPath(),e.rect(2*c,E+3*c,i-4*c,Math.max(0,f-E-3*c)),e.clip();for(var re=Math.floor(((i+14*c)*B-6*c)/c)*c,U=E+3*c,Y=0;U<f;U+=c,Y++){var oe=re-Math.floor(Y/2)*c;e.fillStyle="#fff4be44",e.fillRect(oe-2*c,U,9*c,c),e.fillStyle="#fffef0aa",e.fillRect(oe,U,4*c,c)}e.restore()}if(t.enabled&&!a&&l>=0){var _=Math.max(0,Math.sin(l*4.2)),ee=Math.max(0,Math.sin(l*4.2+2.2)),y=function(O,Re,Pe){if(!(Pe<.25)){e.save(),e.globalAlpha*=Pe*.95,e.fillStyle="#fffef4";var be=Pe>.65?c*2:c;e.fillRect(Math.round(O-be),Math.round(Re-c/2),be*2+c,c),e.fillRect(Math.round(O-c/2),Math.round(Re-be),c,be*2+c),e.restore()}};y(5*c,E+4*c,_),y(i-6*c,E+5*c,ee)}}}function fa(e,t,n,a,l,i){var v=Math.max(0,Math.min(i,a/2,l/2));e.beginPath(),typeof e.roundRect=="function"?e.roundRect(t,n,a,l,v):(e.moveTo(t+v,n),e.arcTo(t+a,n,t+a,n+l,v),e.arcTo(t+a,n+l,t,n+l,v),e.arcTo(t,n+l,t,n,v),e.arcTo(t,n,t+a,n,v),e.closePath())}function ja(e,t,n,a,l){if(!(l<=.02||a<=.5)){e.save(),e.translate(t,n),e.globalAlpha*=l,e.fillStyle="#fffef0",e.beginPath();for(var i=0;i<8;i++){var v=i%2===0?a:a*.24,c=i*Math.PI/4;i===0?e.moveTo(Math.cos(c)*v,Math.sin(c)*v):e.lineTo(Math.cos(c)*v,Math.sin(c)*v)}e.closePath(),e.fill(),e.restore()}}function xl(e,t,n,a,l){var i,v,c,E=t.width,f=t.height;if(!(E<=0||f<=0)){var M=Math.min((i=t.radius)!==null&&i!==void 0?i:16,E/2,f/2),k=a?2:6,B=a?3:0,re=l>=0?.5-.5*Math.cos(l*2.4):0;t.enabled&&!a&&l>=0&&(e.save(),e.shadowColor="#ffd23f99",e.shadowBlur=10+re*12,fa(e,0,B,E,f-B,M),e.fillStyle=n,e.fill(),e.restore()),e.save(),fa(e,0,B+2,E,Math.max(4,f-B-2),M),e.fillStyle="#0e2830",e.fill(),e.restore(),e.save(),fa(e,0,B,E,Math.max(4,f-k),M),e.fillStyle=n,e.fill(),e.clip();var U=(v=e.createLinearGradient)===null||v===void 0?void 0:v.call(e,0,B,0,f-k);if(U!=null&&U.addColorStop&&(U.addColorStop(0,"#ffffffa8"),U.addColorStop(.42,"#ffffff26"),U.addColorStop(.45,"#00000000"),U.addColorStop(1,"#00000024"),e.fillStyle=U,e.fillRect(0,B,E,f-k)),e.fillStyle="#fffef0bb",e.fillRect(M*.55,B+3,Math.max(0,E-M*1.1),3),t.enabled&&!a&&l>=0){var Y=(l%2.4-.15)/.95;if(Y>0&&Y<1){var oe=Y*Y*(3-2*Y),_=Math.sin(Y*Math.PI),ee=-E*.36+E*1.72*oe;e.save(),e.globalAlpha*=_,e.translate(ee,B),e.transform(1,0,-.36,1,0,0);var y=(c=e.createLinearGradient)===null||c===void 0?void 0:c.call(e,-48,0,48,0);y!=null&&y.addColorStop?(y.addColorStop(0,"#ffffff00"),y.addColorStop(.32,"#ffffff48"),y.addColorStop(.5,"#fffef8cc"),y.addColorStop(.68,"#ffffff48"),y.addColorStop(1,"#ffffff00"),e.fillStyle=y,e.fillRect(-48,0,96,f)):(e.fillStyle="#fffef8a8",e.fillRect(-14,0,28,f)),e.restore()}}if(e.restore(),t.strokeWidth&&(e.save(),fa(e,0,B,E,Math.max(4,f-k),M),e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,e.stroke(),e.restore()),t.enabled&&!a&&l>=0){var O=Math.max(0,Math.sin(l*2.4)),Re=O*O,Pe=Math.max(0,Math.sin(l*2.4+2.1)),be=Pe*Pe,Le=Math.max(0,Math.sin(l*2.4+4.2)),Z=Le*Le;ja(e,E*.12,B+9,4+Re*6,Re*.92),ja(e,E*.88,B+10,3.8+be*5.5,be*.9),ja(e,E*.76,Math.max(B+14,f-k-8),3+Z*4.2,Z*.8)}}}function ua(e){if(/\s/.test(e)||e.length>512)return!1;var t=/^https:\/\/play\.google\.com\/store\/apps\/details\?id=[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*){1,9}$/,n=/^https:\/\/apps\.apple\.com\/([a-z]{2}\/)?app\/([a-zA-Z0-9-]+\/)?id[1-9][0-9]{5,19}$/;return t.test(e)&&!/id=example\.|[.=]placeholder(\.|$)|id=com\.example(\.|$)/.test(e)||n.test(e)}var Ti=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ai=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},to=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))};function bl(e){var t,n,a;e===void 0&&(e={});var l=(t=e.timeoutMs)!==null&&t!==void 0?t:5e3,i=(n=e.pollMs)!==null&&n!==void 0?n:25;if(![l,i].every(function(J){return Number.isFinite(J)&&J>=1&&J<=6e4}))throw Error("Invalid Unity host deadline/poll interval");var v=(a=e.getHost)!==null&&a!==void 0?a:(function(){return window.mraid}),c=new Set,E=new Set,f=[],M={},k=!1,B=!1,re=!1,U=!1,Y=!1,oe=!1,_,ee,y,O,Re,Pe,be=function(){return re||U};function Le(){var J,Q,j;clearTimeout(Re),clearTimeout(Pe);try{for(var ye=Ti(f.splice(0)),le=ye.next();!le.done;le=ye.next()){var Ie=Ai(le.value,2),X=Ie[0],ve=Ie[1];try{(j=M.mraid)===null||j===void 0||j.removeEventListener(X,ve)}catch{}}}catch(Ne){J={error:Ne}}finally{try{le&&!le.done&&(Q=ye.return)&&Q.call(ye)}finally{if(J)throw J.error}}}function Z(J){O==null||O(J instanceof Error?J:Error(String(J))),y=void 0,O=void 0}function ue(J){var Q,j;if(!be()){var ye=k;if(re=!0,k=!1,B=!1,Le(),Z(J),ye)try{for(var le=Ti(to([],Ai(E),!1)),Ie=le.next();!Ie.done;Ie=le.next()){var X=Ie.value;X()}}catch(ve){Q={error:ve}}finally{try{Ie&&!Ie.done&&(j=le.return)&&j.call(le)}finally{if(Q)throw Q.error}}c.clear(),E.clear()}}function ae(J,Q){return f.push([J,Q]),M.mraid.addEventListener(J,Q),he(J,Q)}function he(J,Q){if(be()){try{M.mraid.removeEventListener(J,Q)}catch{}return!1}return!0}function R(J){var Q,j;if(!be()){if(typeof J!="boolean"){ue(Error("Invalid Unity viewability event"));return}if(!k){_=J;return}if(B!==J){B=J;try{for(var ye=Ti(to([],Ai(c),!1)),le=ye.next();!le.done;le=ye.next()){var Ie=le.value;if(be())break;Ie(B)}}catch(X){Q={error:X}}finally{try{le&&!le.done&&(j=ye.return)&&j.call(ye)}finally{if(Q)throw Q.error}}}}}var b=function(J){J==="hidden"&&ue(Error("Unity host closed"))},K=function(){var J;k&&!be()&&((J=e.onResize)===null||J===void 0||J.call(e))};function L(){var J,Q,j,ye;if(!(!Y||k||oe||be())){oe=!0;try{var le=M.mraid.getState();if(be()||le==="loading")return;if(le==="hidden")throw Error("Unity host closed before ready");if(!["default","expanded","resized"].includes(le))throw Error("Invalid Unity host state");var Ie=M.mraid.getVersion();if(be())return;if(Ie!=="3.0")throw Error("Unity Ads UA requires MRAID 3.0");try{for(var X=Ti([["viewableChange",R],["stateChange",b],["sizeChange",K]]),ve=X.next();!ve.done;ve=X.next()){var Ne=Ai(ve.value,2),se=Ne[0],ke=Ne[1];if(!ae(se,ke))return}}catch(zr){J={error:zr}}finally{try{ve&&!ve.done&&(Q=X.return)&&Q.call(X)}finally{if(J)throw J.error}}var $e=M.mraid.isViewable();if(be())return;if(typeof $e!="boolean")throw Error("Invalid Unity initial viewability");B=_!=null?_:$e,k=!0,clearTimeout(Re),clearTimeout(Pe),y==null||y(),y=void 0,O=void 0;try{for(var Ue=Ti(to([],Ai(c),!1)),lr=Ue.next();!lr.done;lr=Ue.next()){var Pr=lr.value;if(be())break;Pr(B)}}catch(zr){j={error:zr}}finally{try{lr&&!lr.done&&(ye=Ue.return)&&ye.call(Ue)}finally{if(j)throw j.error}}}catch(zr){ue(zr)}finally{oe=!1}}}function fe(){if(!be())try{var J=v();if(be())return;if(!J){Pe=setTimeout(fe,i);return}if(M.mraid=J,f.push(["ready",L]),M.mraid.addEventListener("ready",L),!he("ready",L))return;Y=!0,L()}catch(Q){ue(Q)}}return{init:function(){return ee||(ee=new Promise(function(J,Q){y=J,O=Q}),be()?(Z(Error("Unity bridge destroyed")),ee):(Re=setTimeout(function(){return ue(Error("Unity MRAID readiness timed out"))},l),fe(),ee))},isReady:function(){return k&&!be()},isVisible:function(){return k&&B&&!be()},isClosed:be,onVisibilityChanged:function(J){return be()||c.add(J),function(){return c.delete(J)}},onClosed:function(J){return be()||E.add(J),function(){return E.delete(J)}},openStore:function(J){if(!k||!B||be()||!ua(J))throw Error("Unity store request not permitted");M.mraid.open(J)},destroy:function(){U||(U=!0,k=!1,B=!1,Le(),Z(Error("Unity bridge destroyed")),c.clear(),E.clear())}}}var oi=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},li=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},no=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))};function wl(e){var t;e===void 0&&(e={});var n=(t=e.getHost)!==null&&t!==void 0?t:(function(){return window.mraid}),a,l=!1,i=!1,v=!1,c=!1,E=!1,f,M,k,B,re,U=new Set,Y=new Set,oe=[];function _(){var ae,he;clearTimeout(B),clearTimeout(re);try{for(var R=oi(oe.splice(0)),b=R.next();!b.done;b=R.next()){var K=li(b.value,2),L=K[0],fe=K[1];try{a==null||a.removeEventListener(L,fe)}catch{}}}catch(J){ae={error:J}}finally{try{b&&!b.done&&(he=R.return)&&he.call(R)}finally{if(ae)throw ae.error}}}function ee(ae,he){if(oe.push([ae,he]),a.addEventListener(ae,he),v||c){try{a.removeEventListener(ae,he)}catch{}return!1}return!0}function y(ae){var he=ae instanceof Error?ae:Error(String(ae));k==null||k(he),M=void 0,k=void 0}function O(ae,he){var R,b;if(!(v||c)&&(v=!0,l=!1,i=!1,_(),y(ae),he))try{for(var K=oi(no([],li(Y),!1)),L=K.next();!L.done;L=K.next()){var fe=L.value;fe()}}catch(J){R={error:J}}finally{try{L&&!L.done&&(b=K.return)&&b.call(K)}finally{if(R)throw R.error}}}function Re(){var ae,he,R,b;if(!(!E||l||v||c))try{var K=a.getState();if(v||c||K==="loading")return;if(K==="hidden"){O(Error("MRAID closed before ready"),!0);return}if(!["default","expanded","resized"].includes(K))throw Error("Invalid MRAID state");try{for(var L=oi([["viewableChange",be],["stateChange",Le],["sizeChange",Z]]),fe=L.next();!fe.done;fe=L.next()){var J=li(fe.value,2),Q=J[0],j=J[1];if(!ee(Q,j))return}}catch(X){ae={error:X}}finally{try{fe&&!fe.done&&(he=L.return)&&he.call(L)}finally{if(ae)throw ae.error}}var ye=a.isViewable();if(v||c)return;if(typeof ye!="boolean")throw Error("Invalid MRAID viewability");i=ye,l=!0,clearTimeout(B),clearTimeout(re),M==null||M(),M=void 0,k=void 0;try{for(var le=oi(no([],li(U),!1)),Ie=le.next();!Ie.done;Ie=le.next()){var j=Ie.value;j(i)}}catch(X){R={error:X}}finally{try{Ie&&!Ie.done&&(b=le.return)&&b.call(le)}finally{if(R)throw R.error}}}catch(X){O(X,l)}}var Pe=function(){return Re()},be=function(ae){var he,R;if(!(!l||v||c)){if(typeof ae!="boolean"){O(Error("Invalid MRAID visibility event"),!0);return}i=ae;try{for(var b=oi(no([],li(U),!1)),K=b.next();!K.done;K=b.next()){var L=K.value;L(i)}}catch(fe){he={error:fe}}finally{try{K&&!K.done&&(R=b.return)&&R.call(b)}finally{if(he)throw he.error}}}},Le=function(ae){ae==="hidden"&&O(Error("MRAID closed"),!0)},Z=function(){var ae;l&&!v&&!c&&((ae=e.onResize)===null||ae===void 0||ae.call(e))};function ue(){var ae,he,R;if(!(v||c))try{if(a=n(),v||c)return;if(!a){re=setTimeout(ue,(R=e.pollMs)!==null&&R!==void 0?R:50);return}if(![a.getState,a.isViewable,a.addEventListener,a.removeEventListener,a.open].every(function(Q){return typeof Q=="function"}))throw Error("Incomplete MRAID 2 interface");try{for(var b=oi([["ready",Pe]]),K=b.next();!K.done;K=b.next()){var L=li(K.value,2),fe=L[0],J=L[1];if(!ee(fe,J))return}}catch(Q){ae={error:Q}}finally{try{K&&!K.done&&(he=b.return)&&he.call(b)}finally{if(ae)throw ae.error}}E=!0,Re()}catch(Q){O(Q,!1)}}return{init:function(){var ae;return f||(f=new Promise(function(he,R){M=he,k=R}),v||c?(y(Error("MRAID bridge destroyed")),f):(B=setTimeout(function(){return O(Error("MRAID readiness timed out"),!1)},(ae=e.timeoutMs)!==null&&ae!==void 0?ae:5e3),ue(),f))},isReady:function(){return l&&!v&&!c},isVisible:function(){return i&&l&&!v&&!c},isClosed:function(){return v||c},onVisibilityChanged:function(ae){return!v&&!c&&U.add(ae),function(){return U.delete(ae)}},onClosed:function(ae){return!v&&!c&&Y.add(ae),function(){return Y.delete(ae)}},openStore:function(ae){if(!l||!i||v||c||!ua(ae))throw Error("MRAID store request not permitted");a.open(ae)},destroy:function(){c||(c=!0,l=!1,i=!1,_(),y(Error("MRAID bridge destroyed")),U.clear(),Y.clear())}}}var Yn=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Gn=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Ri=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))};function Ml(e){e===void 0&&(e={});var t=new Set,n=new Set,a=new Set,l=[],i,v=!1,c=!1,E=!1,f=!1,M,k,B,re,U,Y=function(){return E||f};function oe(){var Z,ue;clearTimeout(re),clearTimeout(U);try{for(var ae=Yn(l.splice(0)),he=ae.next();!he.done;he=ae.next()){var R=Gn(he.value,2),b=R[0],K=R[1];try{i==null||i.removeEventListener(b,K)}catch{}}}catch(L){Z={error:L}}finally{try{he&&!he.done&&(ue=ae.return)&&ue.call(ae)}finally{if(Z)throw Z.error}}}function _(Z){var ue,ae;if(!Y()){E=!0,v=!1,c=!1,oe(),B==null||B(Z instanceof Error?Z:Error(String(Z))),k=void 0,B=void 0;try{for(var he=Yn(Ri([],Gn(n),!1)),R=he.next();!R.done;R=he.next()){var b=R.value;b()}}catch(K){ue={error:K}}finally{try{R&&!R.done&&(ae=he.return)&&ae.call(he)}finally{if(ue)throw ue.error}}}}var ee=function(Z){if(!(typeof Z!="number"||!Number.isFinite(Z)||Z<0))return Math.min(1,Z>1?Z/100:Z)},y=function(Z){if(typeof Z=="boolean")return Z;if(Z&&typeof Z=="object"&&typeof Z.isViewable=="boolean")return Z.isViewable},O=function(){var Z,ue,ae,he,R,b;if(!(v||Y()||!i||((R=i.isReady)===null||R===void 0?void 0:R.call(i))===!1))try{c=i.isViewable();var K=(b=i.getAudioVolume)===null||b===void 0?void 0:b.call(i),L=K===void 0?void 0:ee(K);if(typeof c!="boolean"||K!==void 0&&L===void 0)throw Error("Invalid DAPI initial state");if(v=!0,clearTimeout(re),clearTimeout(U),k==null||k(),k=void 0,B=void 0,L!==void 0)try{for(var fe=Yn(Ri([],Gn(a),!1)),J=fe.next();!J.done;J=fe.next()){var Q=J.value;Q(L)}}catch(le){Z={error:le}}finally{try{J&&!J.done&&(ue=fe.return)&&ue.call(fe)}finally{if(Z)throw Z.error}}try{for(var j=Yn(Ri([],Gn(t),!1)),ye=j.next();!ye.done;ye=j.next()){var Q=ye.value;Q(c)}}catch(le){ae={error:le}}finally{try{ye&&!ye.done&&(he=j.return)&&he.call(j)}finally{if(ae)throw ae.error}}}catch(le){_(le)}},Re=function(Z){var ue,ae;if(!Y()){var he=y(Z);if(he===void 0){_(Error("Invalid DAPI visibility"));return}c=he;try{for(var R=Yn(Ri([],Gn(t),!1)),b=R.next();!b.done;b=R.next()){var K=b.value;K(he)}}catch(L){ue={error:L}}finally{try{b&&!b.done&&(ae=R.return)&&ae.call(R)}finally{if(ue)throw ue.error}}}},Pe=function(Z){var ue,ae;if(!Y()){var he=ee(Z);if(he===void 0){_(Error("Invalid DAPI volume"));return}try{for(var R=Yn(Ri([],Gn(a),!1)),b=R.next();!b.done;b=R.next()){var K=b.value;K(he)}}catch(L){ue={error:L}}finally{try{b&&!b.done&&(ae=R.return)&&ae.call(R)}finally{if(ue)throw ue.error}}}},be=function(){var Z;v&&!Y()&&((Z=e.onResize)===null||Z===void 0||Z.call(e))};function Le(){var Z,ue,ae;if(!Y()){if(i=window.dapi,!i){U=setTimeout(Le,(ae=e.pollMs)!==null&&ae!==void 0?ae:25);return}try{try{for(var he=Yn([["ready",O],["viewableChange",Re],["audioVolumeChange",Pe],["adResized",be]]),R=he.next();!R.done;R=he.next()){var b=Gn(R.value,2),K=b[0],L=b[1];l.push([K,L]),i.addEventListener(K,L)}}catch(fe){Z={error:fe}}finally{try{R&&!R.done&&(ue=he.return)&&ue.call(he)}finally{if(Z)throw Z.error}}O()}catch(fe){_(fe)}}}return{init:function(){var Z;return M||(M=new Promise(function(ue,ae){k=ue,B=ae}),Y()?(B==null||B(Error("DAPI bridge closed")),M):(re=setTimeout(function(){return _(Error("DAPI readiness timed out"))},(Z=e.timeoutMs)!==null&&Z!==void 0?Z:5e3),Le(),M))},isReady:function(){return v&&!Y()},isVisible:function(){return v&&c&&!Y()},isClosed:Y,onVisibilityChanged:function(Z){return Y()||t.add(Z),function(){return t.delete(Z)}},onClosed:function(Z){return Y()||n.add(Z),function(){return n.delete(Z)}},onVolumeChanged:function(Z){return Y()||a.add(Z),function(){return a.delete(Z)}},openStore:function(){if(!v||!c||Y()||typeof(i==null?void 0:i.openStoreUrl)!="function")throw Error("DAPI store host unavailable");i.openStoreUrl()},destroy:function(){f||(f=!0,v=!1,c=!1,oe(),B==null||B(Error("DAPI bridge destroyed")),t.clear(),n.clear(),a.clear())}}}var Df=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(M){try{f(a.next(M))}catch(k){v(k)}}function E(M){try{f(a.throw(M))}catch(k){v(k)}}function f(M){M.done?i(M.value):l(M.value).then(c,E)}f((a=a.apply(e,t||[])).next())})},Hf=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(M){return E([f,M])}}function E(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(M){f=[6,M],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},Ff=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Xf=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},Uf=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Sl(){var e=new Set,t=!1,n=!1,a=!1,l=function(){var i,v;if(!a){n=document.visibilityState!=="hidden";try{for(var c=Uf(Xf([],Ff(e),!1)),E=c.next();!E.done;E=c.next()){var f=E.value;f(n)}}catch(M){i={error:M}}finally{try{E&&!E.done&&(v=c.return)&&v.call(c)}finally{if(i)throw i.error}}}};return{init:function(){return Df(this,void 0,void 0,function(){return Hf(this,function(i){switch(i.label){case 0:if(a)throw Error("Meta bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(v){return document.addEventListener("DOMContentLoaded",function(){return v()},{once:!0})})];case 1:i.sent(),i.label=2;case 2:if(a)throw Error("Meta bridge destroyed");return document.addEventListener("visibilitychange",l),n=document.visibilityState!=="hidden",t=!0,l(),[2]}})})},isReady:function(){return t&&!a},isVisible:function(){return t&&n&&!a},isClosed:function(){return a},onVisibilityChanged:function(i){return a||e.add(i),function(){return e.delete(i)}},onClosed:function(){return function(){}},openStore:function(){var i=window.FbPlayableAd;if(!t||!n||a||typeof(i==null?void 0:i.onCTAClick)!="function")throw Error("Meta CTA host unavailable");i.onCTAClick()},destroy:function(){a=!0,t=!1,n=!1,document.removeEventListener("visibilitychange",l),e.clear()}}}var Yf=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(M){try{f(a.next(M))}catch(k){v(k)}}function E(M){try{f(a.throw(M))}catch(k){v(k)}}function f(M){M.done?i(M.value):l(M.value).then(c,E)}f((a=a.apply(e,t||[])).next())})},Gf=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(M){return E([f,M])}}function E(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(M){f=[6,M],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},Zf=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},$f=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},Kf=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function kl(){var e=new Set,t=!1,n=!1,a=!1,l=function(){var i,v;if(!a){n=document.visibilityState!=="hidden";try{for(var c=Kf($f([],Zf(e),!1)),E=c.next();!E.done;E=c.next()){var f=E.value;f(n)}}catch(M){i={error:M}}finally{try{E&&!E.done&&(v=c.return)&&v.call(c)}finally{if(i)throw i.error}}}};return{init:function(){return Yf(this,void 0,void 0,function(){return Gf(this,function(i){switch(i.label){case 0:if(a)throw Error("Google Ads bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(v){return document.addEventListener("DOMContentLoaded",function(){return v()},{once:!0})})];case 1:i.sent(),i.label=2;case 2:if(a)throw Error("Google Ads bridge destroyed");return document.addEventListener("visibilitychange",l),n=document.visibilityState!=="hidden",t=!0,l(),[2]}})})},isReady:function(){return t&&!a},isVisible:function(){return t&&n&&!a},isClosed:function(){return a},onVisibilityChanged:function(i){return a||e.add(i),function(){return e.delete(i)}},onClosed:function(){return function(){}},openStore:function(){var i=window.ExitApi;if(!t||!n||a||typeof(i==null?void 0:i.exit)!="function")throw Error("Google ExitApi unavailable");i.exit()},destroy:function(){a=!0,t=!1,n=!1,document.removeEventListener("visibilitychange",l),e.clear()}}}var Qf=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(M){try{f(a.next(M))}catch(k){v(k)}}function E(M){try{f(a.throw(M))}catch(k){v(k)}}function f(M){M.done?i(M.value):l(M.value).then(c,E)}f((a=a.apply(e,t||[])).next())})},Jf=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(M){return E([f,M])}}function E(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(M){f=[6,M],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},io=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},ao=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},oo=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Cl(){var e=window,t=new Set,n=new Set,a=e.gameStart,l=e.gameClose,i=!1,v=!1,c=!1,E=!1,f=function(){var k,B;if(!(c||E)){var re=!v||!i;if(i=!0,v=!0,re)try{for(var U=oo(ao([],io(t),!1)),Y=U.next();!Y.done;Y=U.next()){var oe=Y.value;oe(!0)}}catch(_){k={error:_}}finally{try{Y&&!Y.done&&(B=U.return)&&B.call(U)}finally{if(k)throw k.error}}}},M=function(){var k,B,re,U;if(!(c||E)){i=!1,v=!1,c=!0;try{for(var Y=oo(ao([],io(t),!1)),oe=Y.next();!oe.done;oe=Y.next()){var _=oe.value;_(!1)}}catch(O){k={error:O}}finally{try{oe&&!oe.done&&(B=Y.return)&&B.call(Y)}finally{if(k)throw k.error}}try{for(var ee=oo(ao([],io(n),!1)),y=ee.next();!y.done;y=ee.next()){var _=y.value;_()}}catch(O){re={error:O}}finally{try{y&&!y.done&&(U=ee.return)&&U.call(ee)}finally{if(re)throw re.error}}}};return e.gameStart=f,e.gameClose=M,{init:function(){return Qf(this,void 0,void 0,function(){return Jf(this,function(k){if(c||E)throw Error("Mintegral bridge closed");if(typeof e.gameReady!="function")throw Error("Mintegral gameReady host unavailable");return e.gameReady(),[2]})})},isReady:function(){return i&&!c&&!E},isVisible:function(){return i&&v&&!c&&!E},isClosed:function(){return c||E},onVisibilityChanged:function(k){return!c&&!E&&t.add(k),function(){return t.delete(k)}},onClosed:function(k){return!c&&!E&&n.add(k),function(){return n.delete(k)}},notifyGameEnd:function(){var k;!c&&!E&&((k=e.gameEnd)===null||k===void 0||k.call(e))},notifyGameRetry:function(){var k;!c&&!E&&((k=e.gameRetry)===null||k===void 0||k.call(e))},openStore:function(){if(!i||!v||c||E||typeof e.install!="function")throw Error("Mintegral install host unavailable");e.install()},destroy:function(){E||(E=!0,i=!1,v=!1,e.gameStart===f&&(a?e.gameStart=a:delete e.gameStart),e.gameClose===M&&(l?e.gameClose=l:delete e.gameClose),t.clear(),n.clear())}}}var qf=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(M){try{f(a.next(M))}catch(k){v(k)}}function E(M){try{f(a.throw(M))}catch(k){v(k)}}function f(M){M.done?i(M.value):l(M.value).then(c,E)}f((a=a.apply(e,t||[])).next())})},jf=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(M){return E([f,M])}}function E(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(M){f=[6,M],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},_f=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},ed=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},rd=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function El(){var e=new Set,t=!1,n=!1,a=!1,l=function(){var i,v;if(!a){n=document.visibilityState!=="hidden";try{for(var c=rd(ed([],_f(e),!1)),E=c.next();!E.done;E=c.next()){var f=E.value;f(n)}}catch(M){i={error:M}}finally{try{E&&!E.done&&(v=c.return)&&v.call(c)}finally{if(i)throw i.error}}}};return{init:function(){return qf(this,void 0,void 0,function(){return jf(this,function(i){switch(i.label){case 0:if(a)throw Error("TikTok bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(v){return document.addEventListener("DOMContentLoaded",function(){return v()},{once:!0})})];case 1:i.sent(),i.label=2;case 2:if(a)throw Error("TikTok bridge destroyed");return document.addEventListener("visibilitychange",l),n=document.visibilityState!=="hidden",t=!0,l(),[2]}})})},isReady:function(){return t&&!a},isVisible:function(){return t&&n&&!a},isClosed:function(){return a},onVisibilityChanged:function(i){return a||e.add(i),function(){return e.delete(i)}},onClosed:function(){return function(){}},openStore:function(){var i,v,c=window,E=typeof c.openAppStore=="function"?c.openAppStore.bind(c):(v=(i=c.playableSDK)===null||i===void 0?void 0:i.openAppStore)===null||v===void 0?void 0:v.bind(c.playableSDK);if(!t||!n||a||!E)throw Error("TikTok store host unavailable");E()},destroy:function(){a=!0,t=!1,n=!1,document.removeEventListener("visibilitychange",l),e.clear()}}}var ge=function(){return ge=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},ge.apply(this,arguments)},td=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(M){try{f(a.next(M))}catch(k){v(k)}}function E(M){try{f(a.throw(M))}catch(k){v(k)}}function f(M){M.done?i(M.value):l(M.value).then(c,E)}f((a=a.apply(e,t||[])).next())})},nd=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(M){return E([f,M])}}function E(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(M){f=[6,M],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},$=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},ie=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},q=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Tl(e){if(e!=="standalone"){if(e==="unity-ads-ua-playable")return bl();if(e==="applovin-growth-playable")return wl();if(e==="ironsource-levelplay-playable")return Ml();if(e==="meta-audience-playable")return Sl();if(e==="google-ads-app-playable")return kl();if(e==="mintegral-appgrowth-zip")return Cl();if(e==="tiktok-ads-playable")return El();throw Error("E_NATIVE_TARGET")}}function lo(e){var t,n,a,l,i=(t=e.left)!==null&&t!==void 0?t:0,v=(n=e.top)!==null&&n!==void 0?n:0,c=(a=e.right)!==null&&a!==void 0?a:i+e.width,E=(l=e.bottom)!==null&&l!==void 0?l:v+e.height,f=[{id:"sdk-top-left",left:i,top:v,right:Math.min(i+48,c),bottom:Math.min(v+48,E)},{id:"sdk-top-right",left:Math.max(i,c-56),top:v,right:c,bottom:Math.min(v+56,E)},{id:"sdk-bottom-left",left:i,top:Math.max(v,E-28),right:Math.min(i+48,c),bottom:E}];return{left:Math.min(i+48,c),top:Math.min(v+56,E),right:Math.max(i,c-56),bottom:Math.max(v,E-28),zones:f}}function va(e,t){var n,a,l=(a=(n=e.measureText)===null||n===void 0?void 0:n.call(e,t))===null||a===void 0?void 0:a.width,i=/(\d+(?:\.\d+)?)px/.exec(e.font||"");return Number.isFinite(l)?l:ie([],$(t),!1).length*(i?Number(i[1]):16)*.6}function Pl(e,t,n,a){var l,i,v,c,E,f,M;e.font=n.fontWeight+" "+a+"px "+n.fontFamily;var k=Math.max(0,n.width-2*((M=n.padding)!==null&&M!==void 0?M:4)),B=[];try{for(var re=q(String(t).split(`
5
- `)),U=re.next();!U.done;U=re.next()){var Y=U.value;if(n.wrap===!1){B.push(Y);continue}var oe=Y.trim()?Y.trim().split(/\s+/):[""],_=void 0;try{for(var ee=(v=void 0,q(oe)),y=ee.next();!y.done;y=ee.next()){var O=y.value,Re=_?_+" "+O:O;if(va(e,Re)<=k){_=Re;continue}if(_&&B.push(_),va(e,O)<=k){_=O;continue}var Pe="";try{for(var be=(E=void 0,q(O)),Le=be.next();!Le.done;Le=be.next()){var Z=Le.value;Pe&&va(e,Pe+Z)>k?(B.push(Pe),Pe=Z):Pe+=Z}}catch(ue){E={error:ue}}finally{try{Le&&!Le.done&&(f=be.return)&&f.call(be)}finally{if(E)throw E.error}}_=Pe}}catch(ue){v={error:ue}}finally{try{y&&!y.done&&(c=ee.return)&&c.call(ee)}finally{if(v)throw v.error}}B.push(_)}}catch(ue){l={error:ue}}finally{try{U&&!U.done&&(i=re.return)&&i.call(re)}finally{if(l)throw l.error}}return B}function Al(e,t,n){var a,l,i=(a=n.padding)!==null&&a!==void 0?a:4,v=Math.max(0,n.width-2*i),c=Math.max(0,n.height-2*i),E=Math.min(n.fontSize,(l=n.minFontSize)!==null&&l!==void 0?l:12),f=n.fontSize,M=Pl(e,t,n,f),k,B=function(){var re;e.font=n.fontWeight+" "+f+"px "+n.fontFamily;var U=Math.max.apply(Math,ie([0],$(M.map(function(ee){return va(e,ee)})),!1)),Y=f*((re=n.lineHeight)!==null&&re!==void 0?re:1.2),oe=M.length>16;oe&&(M=M.slice(0,16));var _=M.length*Y;return{lines:M,fontSize:f,scale:f/n.fontSize,renderedWidth:U,renderedHeight:_,availableWidth:v,availableHeight:c,padding:i,lineHeight:Y,overflowsWidth:U>v+.01,overflowsHeight:oe||_>c+.01,unsupportedChars:[]}};if(k=B(),n.autoFit!==!1)for(;(k.overflowsWidth||k.overflowsHeight)&&f>E;)f=Math.max(E,f-1),M=Pl(e,t,n,f),k=B();return k}function id(e,t,n){var a=Al(e,t,n),l=a.padding;e.fillStyle=n.color,e.font=n.fontWeight+" "+a.fontSize+"px "+n.fontFamily,e.textAlign=n.align,e.textBaseline="middle";var i=n.align==="left"?l:n.align==="right"?n.width-l:n.width/2,v=(n.height-a.renderedHeight)/2;return a.lines.forEach(function(c,E){return e.fillText(c,i,v+(E+.5)*a.lineHeight)}),a}function ad(e,t,n){var a,l,i,v,c,E,f=n===void 0?{}:n,M=f.edit,k=M===void 0?!1:M,B=f.sceneId,re=B===void 0?e.base.startScene:B,U=f.onSelect,Y=U===void 0?function(){}:U,oe=f.network,_=oe===void 0?"standalone":oe,ee=Tl(_),y=t.getContext("2d"),O=new Map(e.components.map(function(r){return[r.id,r]})),Re=new Map(e.assets.map(function(r){return[r.id,r]})),Pe=new Map,be=new Map(e.events.map(function(r){return[r.id,r]})),Le=new Map(e.gameplay.filter(function(r){return r.kind==="responsive-layout"}).map(function(r){return[r.componentId,r.parameters]})),Z=(i=globalThis.matchMedia)===null||i===void 0?void 0:i.call(globalThis,"(prefers-reduced-motion: reduce)"),ue,ae=new Map,he=ae;function R(){var r=Le.size>0&&t.clientWidth>t.clientHeight;return{width:r?Math.max(e.base.width,e.base.height):e.base.width,height:r?Math.min(e.base.width,e.base.height):e.base.height,landscape:r}}function b(){ue!==R().landscape&&(Kt(),it())}try{for(var K=q(e.assets),L=K.next();!L.done;L=K.next()){var fe=L.value;if(fe.mime.startsWith("image/")){var J=new Image;J.src="data:"+fe.mime+";base64,"+fe.data,Pe.set(fe.id,J)}}}catch(r){a={error:r}}finally{try{L&&!L.done&&(l=K.return)&&l.call(K)}finally{if(a)throw a.error}}var Q=re,j={},ye=[],le=[],Ie=[],X=[],ve=new Set,Ne=new Map,se=0,ke=0,$e=0,Ue=0,lr=0,Pr=!1,zr=0,Wr=0,Tr=!1,pn=[],Ke,It,Ze,Gt,tt,At,mn,xt,Rt,Dt,rn=[],bt,lt=[],yt=[],Ar,tn=0,Oi=!1,fi=0,gn=_==="standalone",di=_==="standalone",Zn=_==="standalone",Tn=!1,Vi=!1,Qe=new Map,An=new Map,mr=new Map,ui=new Map,In=new Set,fo=new Map,uo=new Map,$n=new Set,Kn=new Map,Ni=new Map,sa=new Map,ca=new Map,xn=new Map,Ht=new Map,vi=0,ha=0,Fr,nt,ya=1,pa,wt=new Map,vo=new Map,Ot=new Map,Zt=new Map,Rn=new Map,On=new Map,Bi=new Map,Rr=Go(),Qn=Ko(),zi=new Map,Wi=new Map,Ft=jo($a(e.projectId)),Jn=new Map,nn=new Map,Vn=new Map,Li=new Set,an=new Map,Xe,Rl=1,Ol=1,gr,bn,si={x:0,y:0},$r,$t=[],wn=[],Be=function(r){var o;return(o=mr.get(r))!==null&&o!==void 0?o:O.get(r)},Mt=function(r,o){return e.gameplay.find(function(d){return d.kind===r&&d.componentId===o})},ci=function(){var r,o;vi++,$n.clear(),Kn.clear(),sa.clear(),ca.clear();try{for(var d=q(In),u=d.next();!u.done;u=d.next()){var s=u.value;try{s.stop()}catch{}}}catch(p){r={error:p}}finally{try{u&&!u.done&&(o=d.return)&&o.call(d)}finally{if(r)throw r.error}}In.clear(),Ni.clear()},so=function(r){var o,d;if(!Xe||r!==void 0&&Xe.pointerId!==r)return!1;var u=Xe.pointerId;Xe.behavior.parameters.powerVariableId&&(j[Xe.behavior.parameters.powerVariableId]=0),Xe=void 0;try{!((o=t.hasPointerCapture)===null||o===void 0)&&o.call(t,u)&&((d=t.releasePointerCapture)===null||d===void 0||d.call(t,u))}catch{}return!0},ma=function(r){var o=r.behavior.parameters;o.axisXVariableId&&(j[o.axisXVariableId]=r.nx),o.axisYVariableId&&(j[o.axisYVariableId]=r.ny),o.magnitudeVariableId&&(j[o.magnitudeVariableId]=r.magnitude),o.angleVariableId&&r.magnitude>0&&(j[o.angleVariableId]=r.angle)},ga=function(r,o){var d,u,s,p;o===void 0&&(o=!1);try{for(var h=q(an.values()),g=h.next();!g.done;g=h.next()){var I=g.value;if(!(I.pointerId===null||r!==void 0&&I.pointerId!==r)){var S=I.pointerId;I.pointerId=null,I.nx=0,I.ny=0,I.magnitude=0,I.knobX=I.origin.x,I.knobY=I.origin.y,ma(I);try{!((s=t.hasPointerCapture)===null||s===void 0)&&s.call(t,S)&&((p=t.releasePointerCapture)===null||p===void 0||p.call(t,S))}catch{}o&&rr(dt("joystickEnd",I.c))}}}catch(m){d={error:m}}finally{try{g&&!g.done&&(u=h.return)&&u.call(h)}finally{if(d)throw d.error}}},Di=function(r,o){var d,u;if(o===void 0&&(o=!0),!Ze||r!==void 0&&Ze.pointerId!==r)return!1;var s=Ze,p=s.pointerId;if(Ze=void 0,bn=void 0,o){var h=Be(s.targetId);h&&s.b.parameters.snapBack&&(Qt(h,s.origin.x,s.origin.y),s.originZone&&Rr.place(h.id,s.originZone))}try{!((d=t.hasPointerCapture)===null||d===void 0)&&d.call(t,p)&&((u=t.releasePointerCapture)===null||u===void 0||u.call(t,p))}catch{}return!0},Ia=function(r){var o,d;(bt==null?void 0:bt.pointerId)===r.pointerId&&(bt=void 0);try{for(var u=q(xn.values()),s=u.next();!s.done;s=u.next()){var p=s.value;p.pointerId===r.pointerId&&p.held&&(p.held=!1,p.releasedAt=se)}}catch(g){o={error:g}}finally{try{s&&!s.done&&(d=u.return)&&d.call(u)}finally{if(o)throw o.error}}var h=Di(r.pointerId);return At===r.pointerId?(tt=void 0,At=void 0,!0):h},Hi=function(r){var o,d,u,s,p,h,g,I;if(r){Ze&&((g=mr.get(Ze.targetId))===null||g===void 0?void 0:g.instanceId)===r&&Di(void 0,!1),Xe&&((I=mr.get(Xe.targetId))===null||I===void 0?void 0:I.instanceId)===r&&so();var S=[];Rr.release(r),Qn.cancel(r),Jn.delete(r),Vn.delete(r),Ft.remove(r),ye=ye.filter(function(H){return H.id!==r});try{for(var m=q(mr),C=m.next();!C.done;C=m.next()){var w=$(C.value,2),P=w[0],x=w[1];if(x.instanceId===r){S.push(P),Rr.release(P),Qn.cancel(P),mr.delete(P),Qe.delete(P),ui.delete(P),Ot.delete(P),Rn.delete(P),On.delete(P);try{for(var T=(u=void 0,q(Zt.values())),A=T.next();!A.done;A=T.next()){var N=A.value;N.removeAgent(P)}}catch(H){u={error:H}}finally{try{A&&!A.done&&(s=T.return)&&s.call(T)}finally{if(u)throw u.error}}try{for(var W=(p=void 0,q(An.keys())),D=W.next();!D.done;D=W.next()){var V=D.value;V.endsWith(":"+P)&&An.delete(V)}}catch(H){p={error:H}}finally{try{D&&!D.done&&(h=W.return)&&h.call(W)}finally{if(p)throw p.error}}}}}catch(H){o={error:H}}finally{try{C&&!C.done&&(d=m.return)&&d.call(m)}finally{if(o)throw o.error}}Ie=Ie.filter(function(H){return!S.includes(H.targetId)})}},qn=function(r){for(;r;){if(r.prototype)return r.id;r=Be(r.parentId)}},Vl=function(){var r,o,d;return{viewport:R(),components:Object.fromEntries(ie([],$(Qe),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,ge(ge({},h),{parameters:ge({},h.parameters)})]})),mode:k?"edit":"play",scene:Q,variables:ge({},j),time:se,instances:ye.map(function(u){return ge({id:u.id,prototypeId:u.prototypeId,x:u.transform[4],y:u.transform[5]},Ft.snapshot(u.id))}),particles:le.length,animations:Ie.length,contacts:ve.size,spriteFrames:Object.fromEntries(ie([],$(ui),!1).map(function(u){var s,p=$(u,2),h=p[0],g=p[1];return[h,(s=g.frame)!==null&&s!==void 0?s:0]})),input:{dragging:!!Ze,pointerId:(o=(r=Ze==null?void 0:Ze.pointerId)!==null&&r!==void 0?r:gr==null?void 0:gr.pointerId)!==null&&o!==void 0?o:null,pressed:tt!=null?tt:null,holding:!!(gr!=null&&gr.holds.length),occupancy:Rr.snapshot(),joysticks:Object.fromEntries(ie([],$(an),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,{active:h.pointerId!==null,x:h.nx,y:h.ny,magnitude:h.magnitude,angle:h.angle}]}))},feedback:{presses:xn.size,floatingTexts:lt.length,flashes:yt.length,shaking:!!Ar,tutorialHands:fi},match:{boards:Object.fromEntries(ie([],$(wt),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,h.snapshot()]})),selected:Fr!=null?Fr:null,cells:ie([],$(Ht),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return ge({id:p},h)})},physics:Hl(),paths:Object.fromEntries(ie([],$(Zt),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,h.snapshot()]})),canvas:{masks:Object.fromEntries(ie([],$(Jn),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,{progress:h.progress}]})),strokes:Object.fromEntries(ie([],$(nn),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,h.strokes.length]})),walls:$t.length,joints:wn.filter(function(u){return!u.broken}).length},audio:{state:(d=Ke==null?void 0:Ke.state)!==null&&d!==void 0?d:"locked",voices:In.size,blocked:ha},network:{target:_,ready:di,visible:Zn,started:gn,closed:Tn,hostVolume:ya},diagnostics:ie([],$(pn),!1)}},jn=function(){return!k&&!Pr&&!document.hidden&&di&&Zn&&gn&&!Tn},Kt=function(){var r,o,d,u;bt=void 0,so(),ga(),Di(),gr=void 0,bn=void 0,$r=void 0;try{for(var s=q(nn.values()),p=s.next();!p.done;p=s.next()){var h=p.value;h.cancel()}}catch(m){r={error:m}}finally{try{p&&!p.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}Qn.clear(),nt=void 0;try{for(var g=q(wt.values()),I=g.next();!I.done;I=g.next()){var S=I.value;S.cancelSelection()}}catch(m){d={error:m}}finally{try{I&&!I.done&&(u=g.return)&&u.call(g)}finally{if(d)throw d.error}}wt.size&&(Fr=void 0),tt=void 0,At=void 0,xn.clear()},ft=function(r){Tr=!0,pn.push(r),pn=pn.slice(-16),X=[]},Fe=function(r){var o,d,u;return ge(ge(ge({},r.parameters),r.prototypeId?(o=Qe.get(r.prototypeId))===null||o===void 0?void 0:o.parameters:{}),(u=Qe.get((d=r.runtimeId)!==null&&d!==void 0?d:r.id))===null||u===void 0?void 0:u.parameters)};function xa(r,o){var d,u=xn.get(r.id);if(!u||Z!=null&&Z.matches)return o;var s=ie([],$(o),!1),p=u.held?0:se-((d=u.releasedAt)!==null&&d!==void 0?d:se),h=u.held?0:Math.min(1,p/u.behavior.springBackSeconds),g=u.held?u.behavior.scaleDown:u.behavior.scaleDown+(1-u.behavior.scaleDown)*(1-Math.pow(1-h,3)),I=Fe(r);s[4]+=(1-g)*(s[0]*I.width+s[2]*I.height)/2,s[5]+=(1-g)*(s[1]*I.width+s[3]*I.height)/2;for(var S=0;S<4;S++)s[S]*=g;return s}function Fi(r){return{left:0,top:0,right:r.width,bottom:r.height,width:r.width,height:r.height}}function St(r){var o,d,u,s,p,h,g,I=r.transform,S=(u=(d=Qe.get((o=r.runtimeId)!==null&&o!==void 0?o:r.id))===null||d===void 0?void 0:d.transform)!==null&&u!==void 0?u:I,m=Le.get((s=r.prototypeId)!==null&&s!==void 0?s:r.id);if(!m)return xa(r,S);var C=R(),w=ie([],$(S),!1);C.landscape&&(w[4]+=m.x-I[4],w[5]+=m.y-I[5],w[0]*=m.scaleX,w[1]*=m.scaleX,w[2]*=m.scaleY,w[3]*=m.scaleY);var P=(p=m.anchor)!==null&&p!==void 0?p:"none";if(P==="none"&&!m.respectSafeArea)return xa(r,w);var x=Fi(C),T=m.respectSafeArea?lo(x):x,A=Fe(r),N=(h=m.marginX)!==null&&h!==void 0?h:0,W=(g=m.marginY)!==null&&g!==void 0?g:0,D=Math.abs(w[0])*A.width+Math.abs(w[2])*A.height,V=Math.abs(w[1])*A.width+Math.abs(w[3])*A.height;return P!=="none"?(w[4]=P.endsWith("left")?T.left+N:P.endsWith("right")?T.right-D-N:(T.left+T.right-D)/2,w[5]=P.startsWith("top")?T.top+W:P.startsWith("bottom")?T.bottom-V-W:(T.top+T.bottom-V)/2):(w[4]=Math.max(T.left+N,Math.min(T.right-D-N,w[4])),w[5]=Math.max(T.top+W,Math.min(T.bottom-V-W,w[5]))),xa(r,w)}var Xi=function(r){return(mr.has(r)?ie([],$(mr.values()),!1):ie(ie([],$(e.components),!1),$(ye),!1)).filter(function(o){return o.parentId===r&&!o.prototype}).sort(function(o,d){return o.order-d.order||(o.id<d.id?-1:o.id>d.id?1:0)})},co=function(){return e.components.filter(function(r){return r.sceneId===Q&&!r.parentId&&!r.prototype}).sort(function(r,o){return r.order-o.order||(r.id<o.id?-1:r.id>o.id?1:0)})},rr=function(r){var o,d;if(r.kind==="sceneEnter"&&((o=e.scenes.find(function(u){return u.id===r.sceneId}))===null||o===void 0?void 0:o.role)==="end-card"&&pa!==r.sceneId&&(pa=r.sceneId,(d=ee==null?void 0:ee.notifyGameEnd)===null||d===void 0||d.call(ee)),X.length>=256){ft("Event queue budget exhausted");return}X.push(r)},dt=function(r,o,d,u){var s,p,h,g;return u===void 0&&(u={}),ge(ge({kind:r,componentId:(s=o.prototypeId)!==null&&s!==void 0?s:o.id,selfInstanceId:(p=o.instanceId)!==null&&p!==void 0?p:o.id,instanceId:o.instanceId},d?{otherId:(h=d.prototypeId)!==null&&h!==void 0?h:d.id,otherInstanceId:(g=d.instanceId)!==null&&g!==void 0?g:d.id}:{}),u)};function ba(r){for(var o,d=r;d;d=Be(d.parentId)){var u=Ft.states.get((o=d.instanceId)!==null&&o!==void 0?o:d.id);if(u)return u}}function ho(r){var o,d,u=Mt("instance-state",(o=r.prototypeId)!==null&&o!==void 0?o:r.id);return u?Ft.initialize((d=r.instanceId)!==null&&d!==void 0?d:r.id,u.parameters):void 0}function Nl(){var r,o,d,u;try{for(var s=q(e.gameplay.filter(function(m){return m.kind==="instance-state"})),p=s.next();!p.done;p=s.next()){var h=p.value;try{for(var g=(d=void 0,q(Xr(O.get(h.componentId)))),I=g.next();!I.done;I=g.next()){var S=I.value;ho(S)}}catch(m){d={error:m}}finally{try{I&&!I.done&&(u=g.return)&&u.call(g)}finally{if(d)throw d.error}}}}catch(m){r={error:m}}finally{try{p&&!p.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}}function Bl(r,o,d,u){var s=ba(r);if(s){var p=s.hp;if(o==="tag")s.tag=d==="set"?String(u):s.tag;else{var h=Number(u);if(s[o]=d==="add"?s[o]+h:d==="sub"?s[o]-h:h,!Number.isFinite(s[o])){ft("Instance state range exceeded");return}o==="hp"&&(s.hp=Math.max(0,Math.min(s.maxHp,s.hp)))}p>0&&s.hp<=0&&rr(dt("instanceDepleted",r))}}function Ui(r,o){var d,u,s;if(!r)return!0;if(r.all)return r.all.every(function(S){return Ui(S,o)});if(r.any)return r.any.some(function(S){return Ui(S,o)});var p=r.instanceTarget==="other"?o==null?void 0:o.otherInstanceId:(d=o==null?void 0:o.selfInstanceId)!==null&&d!==void 0?d:o==null?void 0:o.instanceId,h=r.instanceField?(u=Be(p))!==null&&u!==void 0?u:ie([],$(mr.values()),!1).find(function(S){return S.instanceId===p}):void 0,g=r.instanceField?(s=ba(h))===null||s===void 0?void 0:s[r.instanceField]:j[r.variableId],I=r.compareVariableId?j[r.compareVariableId]:r.value;return{eq:function(){return g===I},ne:function(){return g!==I},lt:function(){return g<I},lte:function(){return g<=I},gt:function(){return g>I},gte:function(){return g>=I}}[r.op]()}function yo(r){var o,d,u;Fr=void 0,nt=void 0,r||Ht.clear();try{for(var s=q(e.gameplay),p=s.next();!p.done;p=s.next()){var h=p.value;if(h.kind==="match-tile"){var g=O.get(h.componentId);if(r&&g.id!==r&&!kt(g,r))continue;Qe.delete(g.id),Ht.set(g.id,{row:h.parameters.row,column:h.parameters.column,group:h.parameters.group,sceneId:g.sceneId,boardId:(u=g.parentId)!==null&&u!==void 0?u:g.sceneId})}}}catch(I){o={error:I}}finally{try{p&&!p.done&&(d=s.return)&&d.call(s)}finally{if(o)throw o.error}}}function zl(){var r,o,d=function(h){var g,I;if(wt.has(h.componentId))return"continue";var S=h.componentId,m=h.parameters,C=e.gameplay.filter(function(V){return V.kind==="match-tile"&&O.get(V.componentId).parentId===S}).sort(function(V,H){return V.parameters.row-H.parameters.row||V.parameters.column-H.parameters.column}).map(function(V){return ge({id:V.componentId},V.parameters)}),w=new Map;try{for(var P=(g=void 0,q(C)),x=P.next();!x.done;x=P.next()){var T=x.value;if(!w.has(T.group)){var A=O.get(T.id);w.set(T.group,{fill:A.parameters.fill,children:Xi(T.id).filter(function(V){return["native.image.v1","native.text.v1"].includes(V.contract)})})}}}catch(V){g={error:V}}finally{try{x&&!x.done&&(I=P.return)&&I.call(P)}finally{if(g)throw g.error}}vo.set(S,w);var N=O.get(C[m.columns].id).transform[5]-O.get(C[0].id).transform[5],W=function(V,H,G){var F,te=G.from,de=te===void 0?V:te,ne=G.progress,pe=ne===void 0?0:ne,Ce=G.offsetRows,We=Ce===void 0?0:Ce,De=G.scale,me=De===void 0?1:De,xe=G.opacity,we=xe===void 0?1:xe,Te=C[V],Oe=O.get(Te.id),ce=O.get(C[de].id),yr=w.get(H),Ae=ie([],$(Oe.transform),!1);Ae[4]+=(ce.transform[4]-Oe.transform[4])*pe,Ae[5]+=(ce.transform[5]-Oe.transform[5]+We*N)*pe,Ae[4]+=(1-me)*(Ae[0]*Oe.parameters.width+Ae[2]*Oe.parameters.height)/2,Ae[5]+=(1-me)*(Ae[1]*Oe.parameters.width+Ae[3]*Oe.parameters.height)/2;for(var fr=0;fr<4;fr++)Ae[fr]*=me;Qe.set(Te.id,ge(ge({},Qe.get(Te.id)),{transform:Ae,parameters:ge(ge({},(F=Qe.get(Te.id))===null||F===void 0?void 0:F.parameters),{fill:yr.fill,opacity:we})})),Ht.get(Te.id).group=H;var Me=Xi(Te.id).filter(function(nr){return["native.image.v1","native.text.v1"].includes(nr.contract)});Me.forEach(function(nr,Ge){var Je,kr,ir=yr.children[Ge];if(!(!ir||ir.contract!==nr.contract)){var _e=(Je=Qe.get(nr.id))!==null&&Je!==void 0?Je:{transform:ie([],$(nr.transform),!1),parameters:{}};nr.contract==="native.image.v1"?_e.assetId=(kr=ir.assetSlots[0])===null||kr===void 0?void 0:kr.assetId:_e.parameters.text=ir.parameters.text,Qe.set(nr.id,_e)}})},D=Xo(ge(ge({},m),{slots:C,paint:W,onEvent:function(V){Fr=void 0,rr({kind:V,componentId:S})}}));wt.set(S,D)};try{for(var u=q(e.gameplay.filter(function(h){return h.kind==="match-board"})),s=u.next();!s.done;s=u.next()){var p=s.value;d(p)}}catch(h){r={error:h}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}function po(r){var o,d;zl();try{for(var u=q(wt),s=u.next();!s.done;s=u.next()){var p=$(s.value,2),h=p[0],g=p[1];(!r||r===h||kt(O.get(h),r))&&g.reset()}}catch(I){o={error:I}}finally{try{s&&!s.done&&(d=u.return)&&d.call(u)}finally{if(o)throw o.error}}}function Xr(r){return qn(r)?ie([],$(mr.values()),!1).filter(function(o){return o.prototypeId===r.id}):[r]}function Or(r){var o=Fe(r);return vr(hr(r),o.width/2,o.height/2)}function Nn(r,o,d){var u;d===void 0&&(d="self");var s=O.get(r),p=d==="other"?o.otherInstanceId:(u=o.selfInstanceId)!==null&&u!==void 0?u:o.instanceId,h=!!(s&&qn(s));if(p!==void 0){if(r){var g=ie([],$(mr.values()),!1).find(function(I){return I.prototypeId===r&&(I.instanceId===p||I.id===p)});if(g)return g}if(d==="other"||!r)return Be(p);if(h&&typeof p=="string"&&p.startsWith("instance."))return}return s?h?Xr(s)[0]:Be(r):void 0}function Qt(r,o,d){var u,s=Fe(r),p=(u=Qe.get(r.id))!==null&&u!==void 0?u:{transform:ie([],$(r.transform),!1),parameters:{}},h=ie([],$(p.transform),!1),g=r.parentId?hr(Be(r.parentId)):jt(),I=vr(Yt(g),o,d);h[4]=I.x-(h[0]*s.width+h[2]*s.height)/2,h[5]=I.y-(h[1]*s.width+h[3]*s.height)/2,Qe.set(r.id,ge(ge({},p),{transform:h})),r.prototypeId&&(r.transform=ie([],$(h),!1))}function _n(r,o,d){var u,s,p,h;d===void 0&&(d=!1);var g=(u=Qe.get(r.id))!==null&&u!==void 0?u:{transform:ie([],$(r.transform),!1),parameters:{}},I=(h=(p=O.get((s=r.prototypeId)!==null&&s!==void 0?s:r.id))===null||p===void 0?void 0:p.transform)!==null&&h!==void 0?h:r.transform,S=Math.hypot(I[0],I[1])*(d?-1:1),m=Math.hypot(I[2],I[3]),C=o+(d?0:Math.atan2(I[1],I[0])),w=Math.cos(C),P=Math.sin(C),x=ie([],$(g.transform),!1);x[0]=w*S,x[1]=P*S,x[2]=-P*m,x[3]=w*m,Qe.set(r.id,ge(ge({},g),{transform:x}))}function Bn(r,o){var d=Ot.get(r.id);if(d)return d;var u=hr(r),s=Fe(r),p=vr(u,s.width/2,s.height/2);return d=ge({id:r.id,sourceId:o.componentId,instanceId:r.instanceId,x:p.x,y:p.y,vx:0,vy:0,width:Math.hypot(u[0],u[1])*s.width,height:Math.hypot(u[2],u[3])*s.height,angle:Math.atan2(u[1],u[0]),restElapsed:0,atRest:!0},o.parameters),Ot.set(r.id,d),d}function hi(r,o){var d,u=Jn.get(r.id);if(u)return u;var s=Fe(r),p=o.parameters;return u=_o(p,{width:s.width,height:s.height,source:r.contract==="native.image.v1"?Pe.get((d=r.assetSlots[0])===null||d===void 0?void 0:d.assetId):void 0,onProgress:function(h){p.progressVariableId&&(j[p.progressVariableId]=h),rr(dt("maskProgress",r))},onComplete:function(){return rr(dt("maskComplete",r))}}),Jn.set(r.id,u),u}function Wl(r){var o=nn.get(r.componentId);return o||(o=tl(r.parameters),nn.set(r.componentId,o)),o}function mo(){var r,o,d,u,s,p,h,g,I,S,m,C,w=new Set,P=[];try{for(var x=q(e.gameplay.filter(function(Ae){return Ae.kind==="physics-body"})),T=x.next();!T.done;T=x.next()){var A=T.value,N=O.get(A.componentId);if(N.sceneId===Q)try{for(var W=(d=void 0,q(Xr(N))),D=W.next();!D.done;D=W.next()){var V=D.value;if(Sr(V)){if(P.length>=64){ft("Physics body budget exhausted");break}var H=Bn(V,A),G=hr(V),F=Fe(V),te=vr(G,F.width/2,F.height/2);if(w.add(V.id),H.width=Math.hypot(G[0],G[1])*F.width,H.height=Math.hypot(G[2],G[3])*F.height,H.mode!=="dynamic"){var de=Rn.get(V.id),ne=V.parentId?hr(Be(V.parentId)):jt(),pe=(m=de==null?void 0:de.vx)!==null&&m!==void 0?m:0,Ce=(C=de==null?void 0:de.vy)!==null&&C!==void 0?C:0;H.x=te.x,H.y=te.y,H.angle=Math.atan2(G[1],G[0]),H.vx=ne[0]*pe+ne[2]*Ce,H.vy=ne[1]*pe+ne[3]*Ce}else H.atRest&&(H.x=te.x,H.y=te.y);P.push(H)}}}catch(Ae){d={error:Ae}}finally{try{D&&!D.done&&(u=W.return)&&u.call(W)}finally{if(d)throw d.error}}}}catch(Ae){r={error:Ae}}finally{try{T&&!T.done&&(o=x.return)&&o.call(x)}finally{if(r)throw r.error}}try{for(var We=q(Ot.keys()),De=We.next();!De.done;De=We.next()){var me=De.value;!w.has(me)&&!mr.has(me)&&Ot.delete(me)}}catch(Ae){s={error:Ae}}finally{try{De&&!De.done&&(p=We.return)&&p.call(We)}finally{if(s)throw s.error}}var xe=[];try{for(var we=q(e.gameplay.filter(function(Ae){return Ae.kind==="capture-zone"})),Te=we.next();!Te.done;Te=we.next()){var A=Te.value,N=O.get(A.componentId);if(N.sceneId===Q)try{for(var Oe=(I=void 0,q(Xr(N))),ce=Oe.next();!ce.done;ce=Oe.next()){var V=ce.value;if(Sr(V)){var G=hr(V),F=Fe(V),te=vr(G,F.width/2,F.height/2),yr=Math.max(.1,Math.min(Math.hypot(G[0],G[1]),Math.hypot(G[2],G[3])));xe.push(ge(ge({id:V.id,sourceId:N.id,instanceId:V.instanceId,x:te.x,y:te.y},A.parameters),{radius:A.parameters.radius*yr}))}}}catch(Me){I={error:Me}}finally{try{ce&&!ce.done&&(S=Oe.return)&&S.call(Oe)}finally{if(I)throw I.error}}}}catch(Ae){h={error:Ae}}finally{try{Te&&!Te.done&&(g=we.return)&&g.call(we)}finally{if(h)throw h.error}}return{bodies:ie(ie([],$(P),!1),$($t),!1),zones:xe}}function Ll(r){var o,d,u,s,p,h,g,I=mo(),S=I.bodies,m=I.zones,C=R();wn=[];try{for(var w=q(e.gameplay.filter(function(ne){return ne.kind==="physics-joint"})),P=w.next();!P.done;P=w.next()){var x=P.value,T=O.get(x.componentId);if(T.sceneId===Q){var A=Be(x.parameters.anchorComponentId),N=Mt("physics-body",T.id);if(!(!A||!N))try{for(var W=(u=void 0,q(Xr(T))),D=W.next();!D.done;D=W.next()){var V=D.value;Bn(V,N);var H=Or(A),G=x.id+":"+V.id;wn.push(ge(ge({},x.parameters),{id:x.id,key:G,componentId:T.id,bodyId:V.id,anchorId:A.id,x:H.x,y:H.y,broken:Li.has(G)}))}}catch(ne){u={error:ne}}finally{try{D&&!D.done&&(s=W.return)&&s.call(W)}finally{if(u)throw u.error}}}}}catch(ne){o={error:ne}}finally{try{P&&!P.done&&(d=w.return)&&d.call(w)}finally{if(o)throw o.error}}Ja({bodies:S,zones:m,joints:wn,bounds:{left:0,top:0,right:C.width,bottom:C.height},dt:r,onEvent:function(ne,pe,Ce){var We,De,me,xe;if(!(ne==="bodyBounce"&&Ce&&pe.sourceId===Ce.sourceId&&pe.id>Ce.id)){var we=(We=pe.instanceId)!==null&&We!==void 0?We:pe.id,Te=Ce?(De=Ce.instanceId)!==null&&De!==void 0?De:Ce.id:void 0,Oe=ge(ge({kind:ne,componentId:pe.sourceId,selfInstanceId:we},Te?{otherInstanceId:Te}:{}),{instanceId:(me=pe.instanceId)!==null&&me!==void 0?me:Ce==null?void 0:Ce.instanceId});if(Ce&&(Oe.otherId=Ce.sourceId),rr(Oe),ne==="zoneCapture"){var ce=Be(pe.id),yr=O.get(Ce.sourceId);if(Ce.hideCaptured&&ce){var Ae=(xe=Qe.get(ce.id))!==null&&xe!==void 0?xe:{transform:ie([],$(ce.transform),!1),parameters:{}};Ae.parameters.visible=!1,Qe.set(ce.id,Ae)}Ce.stopBody&&yr&&ce&&Qt(ce,Ce.x,Ce.y)}}}});try{for(var F=q(S),te=F.next();!te.done;te=F.next()){var de=te.value,V=Be(de.id);!V||de.mode!=="dynamic"||(de.spinToRotation&&_n(V,(g=de.angle)!==null&&g!==void 0?g:0),Qt(V,de.x,de.y))}}catch(ne){p={error:ne}}finally{try{te&&!te.done&&(h=F.return)&&h.call(F)}finally{if(p)throw p.error}}}function Dl(){var r,o,d,u,s;try{for(var p=q(e.gameplay.filter(function(D){return D.kind==="oscillate"})),h=p.next();!h.done;h=p.next()){var g=h.value,I=O.get(g.componentId);if(I.sceneId===Q)try{for(var S=(d=void 0,q(Xr(I))),m=S.next();!m.done;m=S.next()){var C=m.value,w=Rn.get(C.id);w||(w={base:ie([],$(St(C)),!1),vx:0,vy:0},Rn.set(C.id,w));var P=g.parameters,x=(se/P.periodSeconds+P.phase)*Math.PI*2,T=Math.sin(x)*P.amplitude,A=Math.cos(x)*P.amplitude*Math.PI*2/P.periodSeconds,N=(s=Qe.get(C.id))!==null&&s!==void 0?s:{parameters:{}},W=ie([],$(w.base),!1);P.axis==="x"?(W[4]+=T,w.vx=A,w.vy=0):(W[5]+=T,w.vy=A,w.vx=0),Qe.set(C.id,ge(ge({},N),{transform:W})),Rn.set(C.id,w)}}catch(D){d={error:D}}finally{try{m&&!m.done&&(u=S.return)&&u.call(S)}finally{if(d)throw d.error}}}}catch(D){r={error:D}}finally{try{h&&!h.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}}function go(){var r,o;Zt.clear();var d=function(h){var g=e.gameplay.filter(function(S){return S.kind==="path-gate"&&S.parameters.networkBehaviorId===h.id}),I=sl({id:h.id,nodes:h.parameters.nodes,edges:h.parameters.edges,gates:g,onEvent:function(S,m){var C,w=Be(m.componentId),P=(C=w==null?void 0:w.prototypeId)!==null&&C!==void 0?C:m.componentId;rr(ge({kind:S,componentId:P,instanceId:w==null?void 0:w.instanceId},m.nodeId?{nodeId:m.nodeId}:{}))}});Zt.set(h.id,I)};try{for(var u=q(e.gameplay.filter(function(h){return h.kind==="path-network"})),s=u.next();!s.done;s=u.next()){var p=s.value;d(p)}}catch(h){r={error:h}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}function Yi(r,o){var d,u,s,p,h,g,I,S,m,C,w,P,x;o===void 0&&(o=!0);var T=0;try{for(var A=q(e.gameplay.filter(function(Ae){return Ae.kind==="path-agent"})),N=A.next();!N.done;N=A.next()){var W=N.value,D=O.get(W.componentId),V=Zt.get(W.parameters.networkBehaviorId);if(!(D.sceneId!==Q||!V))try{for(var H=(s=void 0,q(Xr(D))),G=H.next();!G.done;G=H.next()){var F=G.value;if(++T>64){ft("Path agent budget exhausted");break}var te=V.getAgent(F.id);te||(te=V.addAgent(ge(ge({},W.parameters),{id:F.id,startNode:(w=F.pathStartNode)!==null&&w!==void 0?w:W.parameters.startNode,targetNode:(P=F.pathTargetNode)!==null&&P!==void 0?P:W.parameters.targetNode}))),te.speedMultiplier=Math.max(0,Number(W.parameters.speedMultiplierVariableId?j[W.parameters.speedMultiplierVariableId]:1))}}catch(Ae){s={error:Ae}}finally{try{G&&!G.done&&(p=H.return)&&p.call(H)}finally{if(s)throw s.error}}}}catch(Ae){d={error:Ae}}finally{try{N&&!N.done&&(u=A.return)&&u.call(A)}finally{if(d)throw d.error}}if(o){var de=function(Ae,fr){var Me=e.gameplay.find(function(nr){return nr.id===Ae});O.get(Me.componentId).sceneId===Q&&fr.tick(r)};try{for(var ne=q(Zt),pe=ne.next();!pe.done;pe=ne.next()){var Ce=$(pe.value,2),We=Ce[0],De=Ce[1];de(We,De)}}catch(Ae){h={error:Ae}}finally{try{pe&&!pe.done&&(g=ne.return)&&g.call(ne)}finally{if(h)throw h.error}}}try{for(var me=q(e.gameplay.filter(function(Ae){return Ae.kind==="path-agent"})),xe=me.next();!xe.done;xe=me.next()){var W=xe.value,D=O.get(W.componentId),we=Zt.get(W.parameters.networkBehaviorId);if(!(D.sceneId!==Q||!we))try{for(var Te=(m=void 0,q(Xr(D))),Oe=Te.next();!Oe.done;Oe=Te.next()){var F=Oe.value,te=we.getAgent(F.id);if(te){if(te.orientToPath==="rotate")_n(F,te.heading);else if(te.orientToPath==="flip-x")_n(F,0,te.flipX);else if(te.orientToPath==="iso-4"){var ce=(x=Qe.get(F.id))!==null&&x!==void 0?x:{transform:ie([],$(F.transform),!1),parameters:{}};ce.pathFrame=te.frame,Qe.set(F.id,ce)}var yr=F.parentId?vr(hr(Be(F.parentId)),te.x,te.y):te;Qt(F,yr.x,yr.y)}}}catch(Me){m={error:Me}}finally{try{Oe&&!Oe.done&&(C=Te.return)&&C.call(Te)}finally{if(m)throw m.error}}}}catch(Ae){I={error:Ae}}finally{try{xe&&!xe.done&&(S=me.return)&&S.call(me)}finally{if(I)throw I.error}}}function wa(r){var o,d,u,s,p,h,g,I,S,m,C=new Set;try{for(var w=q(e.gameplay.filter(function(_e){return _e.kind==="value-meter"})),P=w.next();!P.done;P=w.next()){var x=P.value,T=O.get(x.componentId);if(T.sceneId===Q)try{for(var A=(u=void 0,q(Xr(T))),N=A.next();!N.done;N=A.next()){var W=N.value,D=x.parameters,V=D.instanceField?ba(W):void 0,H=D.instanceField==="hp"&&V?V.hp/V.maxHp*(D.max-D.min)+D.min:D.instanceField==="value"&&V?V.value:Number(j[D.variableId]),G=On.get(W.id);G||(G={base:ie([],$(St(W)),!1),value:Number.isFinite(H)?Math.max(D.min,Math.min(D.max,H)):D.min},On.set(W.id,G)),C.add(W.id);var F=Math.max(D.min,Math.min(D.max,H)),te=D.smoothingSeconds?1-Math.exp(-r/D.smoothingSeconds):1;G.value+=((Number.isFinite(F)?F:D.min)-G.value)*te;var de=Math.max(0,Math.min(1,(G.value-D.min)/(D.max-D.min))),ne=ie([],$(G.base),!1),pe=(S=Qe.get(W.id))!==null&&S!==void 0?S:{parameters:{}},Ce=D.axis==="x"?Fe(W).width:Fe(W).height;if(D.axis==="x"?(ne[0]*=de,ne[1]*=de):(ne[2]*=de,ne[3]*=de),D.direction==="negative"){var We=Ce*(1-de);D.axis==="x"?(ne[4]+=G.base[0]*We,ne[5]+=G.base[1]*We):(ne[4]+=G.base[2]*We,ne[5]+=G.base[3]*We)}Qe.set(W.id,ge(ge({},pe),{transform:ne}))}}catch(_e){u={error:_e}}finally{try{N&&!N.done&&(s=A.return)&&s.call(A)}finally{if(u)throw u.error}}}}catch(_e){o={error:_e}}finally{try{P&&!P.done&&(d=w.return)&&d.call(w)}finally{if(o)throw o.error}}try{for(var De=q(On.keys()),me=De.next();!me.done;me=De.next()){var xe=me.value;C.has(xe)||On.delete(xe)}}catch(_e){p={error:_e}}finally{try{me&&!me.done&&(h=De.return)&&h.call(De)}finally{if(p)throw p.error}}try{for(var we=q(e.gameplay.filter(function(_e){return _e.kind==="camera-follow"})),Te=we.next();!Te.done;Te=we.next()){var x=Te.value,Oe=O.get(x.componentId),F=Be(x.parameters.targetId);if(!(Oe.sceneId!==Q||!F)){var ce=Bi.get(Oe.id);ce||(ce={base:ie([],$(Oe.transform),!1),x:x.parameters.minX,y:x.parameters.minY},Bi.set(Oe.id,ce));var yr=function(Cr,qr){for(var jr=[],Yr=Cr;Yr&&Yr.id!==qr.id;Yr=Be(Yr.parentId))jr.unshift(Yr);return jr.reduce(function(Kr,pr){return ai(Kr,St(pr))},jt())},ne=kt(F,Oe.id)?yr(F,Oe):hr(F),D=Fe(F),Ae=vr(ne,D.width/2,D.height/2),fr=R(),Me=x.parameters,nr=Math.max(Me.minX,Me.maxX-fr.width/Me.zoom),Ge=Math.max(Me.minY,Me.maxY-fr.height/Me.zoom),Je=Math.max(Me.minX,Math.min(nr,Ae.x-fr.width/(2*Me.zoom))),kr=Math.max(Me.minY,Math.min(Ge,Ae.y-fr.height/(2*Me.zoom))),te=1-Math.exp(-Me.smoothing*r);ce.x+=(Je-ce.x)*te,ce.y+=(kr-ce.y)*te;var pe=(m=Qe.get(Oe.id))!==null&&m!==void 0?m:{parameters:{}},ir=ie([],$(ce.base),!1);ir[0]*=Me.zoom,ir[1]*=Me.zoom,ir[2]*=Me.zoom,ir[3]*=Me.zoom,ir[4]-=ce.x*Me.zoom,ir[5]-=ce.y*Me.zoom,Qe.set(Oe.id,ge(ge({},pe),{transform:ir}))}}}catch(_e){g={error:_e}}finally{try{Te&&!Te.done&&(I=we.return)&&I.call(we)}finally{if(g)throw g.error}}}function Hl(){return{bodies:ie([],$(Ot.values()),!1).map(function(r){return{id:r.id,sourceId:r.sourceId,x:r.x,y:r.y,vx:r.vx,vy:r.vy,atRest:!!r.atRest,captured:!!r.captured}}),aiming:Xe?{componentId:Xe.sourceId,pointerId:Xe.pointerId,power:Xe.power}:null}}function Ma(){Rt=void 0,pa=void 0,Kt(),an.clear(),Rr.clear(),zi.clear(),Wi.clear(),Ft.reset(),Jn.clear(),nn.clear(),$t=[],wn=[],Vn.clear(),Li.clear(),ae.clear(),lt=[],yt=[],Ar=void 0,tn=0,Oi=!1,fi=0,j=Object.fromEntries(e.variables.map(function(r){return[r.id,r.initial]})),ci(),ha=0,mr.clear(),ui.clear(),Ot.clear(),Rn.clear(),On.clear(),Bi.clear(),Xe=void 0,ye=[],le=[],Ie=[],Qe.clear(),yo(),An.clear(),ve.clear(),Ne.clear(),X=[],se=0,ke=0,$e=0,Tr=!1,Ue=0,Q=e.base.startScene,tt=void 0,At=void 0,Gt=void 0,xt=void 0,k||(Nl(),po(),go(),Yi(0,!1),Ea(),wa(0),rr({kind:"sceneEnter",sceneId:Q}))}function Sa(){var r,o;if(!(!Ke||Ke.state!=="running"||!Kn.size)){var d=ie([],$(Kn.values()),!1);Kn.clear();try{for(var u=q(d),s=u.next();!s.done;s=u.next()){var p=s.value;xo(p)}}catch(h){r={error:h}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}function yi(r){if(r===void 0&&(r=!1),!Ke)return Promise.resolve(void 0);if(Ke.state==="running")return Promise.resolve().then(Sa),Promise.resolve(Ke);if(!It||r){var o=Ke,d=Promise.resolve().then(function(){return o.resume()}).then(function(){if(o.state==="running")return Sa(),o}).catch(function(){}).finally(function(){It===d&&(It=void 0)});It=d}return It}function ka(){var r,o,d=ie([],$(Ni.values()),!1),u=d.some(function(m){return m.bus==="voice"}),s=d.some(function(m){return m.bus==="stinger"}),p=s?.2:u?.25:1;try{for(var h=q(d),g=h.next();!g.done;g=h.next()){var I=g.value,S=I.volume*ya*(I.bus==="music"?p:1);I.gain.gain.setTargetAtTime?I.gain.gain.setTargetAtTime(S,Ke.currentTime,.04):I.gain.gain.value=S}}catch(m){r={error:m}}finally{try{g&&!g.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}}function Fl(r,o){if(!o||typeof r.createBuffer!="function"||typeof o.getChannelData!="function"||!o.numberOfChannels)return o;var d=o.sampleRate||44100,u=o.length;if(u<Math.round(d*.2))return o;for(var s=o.numberOfChannels,p=.002,h=u,g=0,I=0;I<s;I++){for(var S=o.getChannelData(I),m=0;m<h;m++)if(Math.abs(S[m])>p){h=m;break}for(var m=u-1;m>g;m--)if(Math.abs(S[m])>p){g=m;break}}if(h>=g)return o;var C=g-h+1;if(C<Math.round(d*.15))return o;var w=Math.min(Math.round(d*.06),Math.floor(C*.1)),P=C-w;if(w<8||P<Math.round(d*.1))return o;for(var x=r.createBuffer(s,P,d),I=0;I<s;I++){for(var T=o.getChannelData(I),A=x.getChannelData(I),m=0;m<w;m++){var N=m/w;A[m]=T[h+m]*Math.sin(N*Math.PI*.5)+T[h+P+m]*Math.cos(N*Math.PI*.5)}for(var m=w;m<P;m++)A[m]=T[h+m]}return x}function Io(r,o,d){var u,s=(u=d.parameters.bus)!==null&&u!==void 0?u:"sfx";r.connect(o),o.connect(Ke.destination),In.add(r),Ni.set(r,{gain:o,bus:s,volume:d.parameters.volume}),r.onended=function(){In.delete(r),Ni.delete(r),d.parameters.loop&&$n.delete(d.id),ka()},ka()}function xo(r){return td(this,void 0,void 0,function(){var o,d,u,s,p,h,g,I,S,m,C,w,P,x,T,A,N,W,D,V,H,G,F,te,de,ne,pe,Ce,We,De,me,xe;return nd(this,function(we){switch(we.label){case 0:return In.size>=32?[2]:(o=!!r.parameters.loop,Ke?(d=Ke,u=vi,s=(ne=r.parameters.cooldownMs)!==null&&ne!==void 0?ne:45,p=d.currentTime,s>0&&p-((pe=sa.get(r.id))!==null&&pe!==void 0?pe:-1/0)<s/1e3?[2]:o&&$n.has(r.id)?[2]:(h=O.get(r.componentId),g=Re.get((Ce=h==null?void 0:h.assetSlots[0])===null||Ce===void 0?void 0:Ce.assetId),I=(g==null?void 0:g.mime)==="audio/wav"||(g==null?void 0:g.mime)==="audio/mpeg",!I&&r.parameters.allowSynthFallback===!1?(ha++,[2]):(sa.set(r.id,p),S=d.state!=="running",S?[4,yi()]:[3,2]))):(o&&Kn.set(r.id,r),[2]));case 1:S=!we.sent(),we.label=2;case 2:if(S)return o&&Kn.set(r.id,r),[2];if(Ke!==d||d.state!=="running"||u!==vi||In.size>=32)return[2];if(m=(We=ca.get(r.id))!==null&&We!==void 0?We:0,C=[0,-.5,.5,-1,1],w=((De=r.parameters.pitchJitter)!==null&&De!==void 0?De:0)*C[m%C.length],P=Number((me=j[r.parameters.pitchVariableId])!==null&&me!==void 0?me:0),x=Math.max(-12,Math.min(12,w+P*((xe=r.parameters.pitchStep)!==null&&xe!==void 0?xe:0))),T=Math.pow(2,x/12),ca.set(r.id,m+1),!I)return[3,8];o&&$n.add(r.id),we.label=3;case 3:if(we.trys.push([3,6,,7]),A=fo.get(g.hash),A)return[3,5];for(N=atob(g.data),W=new Uint8Array(N.length),D=0;D<N.length;D++)W[D]=N.charCodeAt(D);return[4,new Promise(function(Te,Oe){var ce=d.decodeAudioData(W.buffer,Te,Oe);ce&&typeof ce.then=="function"&&ce.then(Te,Oe)})];case 4:A=we.sent(),fo.set(g.hash,A),we.label=5;case 5:return Ke!==d||d.state!=="running"||u!==vi||In.size>=32?(o&&u===vi&&$n.delete(r.id),[2]):(V=A,o&&(V=uo.get(g.hash),V||(V=Fl(d,A),uo.set(g.hash,V))),H=d.createBufferSource(),G=d.createGain(),H.buffer=V,H.loop=o,H.playbackRate&&(H.playbackRate.value=T),o&&G.gain.setValueAtTime&&G.gain.linearRampToValueAtTime?(G.gain.setValueAtTime(1e-4,d.currentTime),G.gain.linearRampToValueAtTime(r.parameters.volume,d.currentTime+.025)):G.gain.value=r.parameters.volume,Io(H,G,r),H.start(),[3,7]);case 6:return F=we.sent(),$n.delete(r.id),ft("Audio decode failed"),[3,7];case 7:return[2];case 8:return te=d.createOscillator(),de=d.createGain(),te.frequency.value=r.parameters.frequency*T,te.type="sine",de.gain.setValueAtTime(r.parameters.volume,d.currentTime),de.gain.exponentialRampToValueAtTime(.001,d.currentTime+r.parameters.seconds),Io(te,de,r),te.start(),te.stop(d.currentTime+r.parameters.seconds),[2]}})})}function Xl(r,o){for(var d=ie([],$(Ht.values()),!1).filter(function(m){return m.boardId===r}),u=function(m,C){var w;return(w=d.find(function(P){return P.row===m&&P.column===C}))===null||w===void 0?void 0:w.group},s=function(m){for(var C=function(x){var T=u(m,x);if(T&&T===u(m,x+1)&&T===u(m,x+2)&&o.some(function(A){return A.row===m&&A.column>=x&&A.column<=x+2}))return{value:!0}},w=0;w<14;w++){var P=C(w);if(typeof P=="object")return P}},p=0;p<16;p++){var h=s(p);if(typeof h=="object")return h.value}for(var g=function(m){for(var C=function(x){var T=u(x,m);if(T&&T===u(x+1,m)&&T===u(x+2,m)&&o.some(function(A){return A.column===m&&A.row>=x&&A.row<=x+2}))return{value:!0}},w=0;w<14;w++){var P=C(w);if(typeof P=="object")return P}},I=0;I<16;I++){var S=g(I);if(typeof S=="object")return S.value}return!1}function Ul(r){var o,d,u,s=Ht.get(r.id);if(!(!s||s.sceneId!==Q||!Fe(r).enabled||!Sr(r))){var p=wt.get(r.parentId);if(p){Fr=p.select(r.id);return}if(Fr===r.id){Fr=void 0;return}var h=Ht.get(Fr);if(!h||h.sceneId!==Q||h.boardId!==s.boardId){Fr=r.id;return}var g=O.get(Fr);if(Math.abs(h.row-s.row)+Math.abs(h.column-s.column)!==1){Fr=r.id;return}if(h.group===s.group){Fr=void 0,rr({kind:"invalidMatch",componentId:(o=r.parentId)!==null&&o!==void 0?o:r.id});return}var I=h.row,S=h.column,m=s.row,C=s.column,w=ie([],$(St(g)),!1),P=ie([],$(St(r)),!1);if(h.row=m,h.column=C,s.row=I,s.column=S,Xl(s.boardId,[h,s])){var x=function(T,A){var N,W=(N=Qe.get(T.id))!==null&&N!==void 0?N:{transform:ie([],$(St(T)),!1),parameters:{}};W.transform=ie([],$(W.transform),!1),W.transform[4]=A[4],W.transform[5]=A[5],Qe.set(T.id,W)};x(g,P),x(r,w),Fr=void 0,rr({kind:"validMatch",componentId:(d=r.parentId)!==null&&d!==void 0?d:r.id})}else h.row=I,h.column=S,s.row=m,s.column=C,Fr=void 0,rr({kind:"invalidMatch",componentId:(u=r.parentId)!==null&&u!==void 0?u:r.id})}}function Ca(r){var o,d,u,s,p=[],h=ut(r,hr(r)),g=Or(r),I=Mt("drag",(u=r.prototypeId)!==null&&u!==void 0?u:r.id),S=function(P){var x,T,A=O.get(P.componentId),N=P.parameters;if(A.sceneId!==Q)return"continue";var W=function(G){if(G.id===r.id||kt(G,r.id)||!Sr(G))return"continue";var F=ut(G,hr(G)),te=Or(G),de=Math.hypot(te.x-g.x,te.y-g.y),ne=N.radiusPx>0?de<=N.radiusPx:h.left<F.right&&h.right>F.left&&h.top<F.bottom&&h.bottom>F.top;if(!ne)return"continue";p.push(ge({id:G.id,c:G,sourceId:A.id,paintOrder:rn.findIndex(function(pe){return pe.c.id===G.id}),distance:de,itemTarget:e.gameplay.some(function(pe){return pe.kind==="drag"&&pe.componentId===A.id})},N))};try{for(var D=(x=void 0,q(Xr(A))),V=D.next();!V.done;V=D.next()){var H=V.value;W(H)}}catch(G){x={error:G}}finally{try{V&&!V.done&&(T=D.return)&&T.call(D)}finally{if(x)throw x.error}}};try{for(var m=q(e.gameplay.filter(function(P){return P.kind==="drop-zone"})),C=m.next();!C.done;C=m.next()){var w=C.value;S(w)}}catch(P){o={error:P}}finally{try{C&&!C.done&&(d=m.return)&&d.call(m)}finally{if(o)throw o.error}}return{zones:p,tag:(s=I==null?void 0:I.parameters.tag)!==null&&s!==void 0?s:""}}function Ea(r){var o,d,u=r?[r]:e.gameplay.filter(function(C){return C.kind==="drag"}).flatMap(function(C){return Xr(O.get(C.componentId))});try{for(var s=q(u),p=s.next();!p.done;p=s.next()){var h=p.value;if(!(!h||!Sr(h)||Rr.zoneOf(h.id))){var g=Ca(h),I=g.zones,S=g.tag,m=ia({itemId:h.id,tag:S,zones:I.filter(function(C){return!C.itemTarget}),occupancy:Rr});(m==null?void 0:m.kind)==="accept"&&Rr.place(h.id,m.zone.id)}}}catch(C){o={error:C}}finally{try{p&&!p.done&&(d=s.return)&&d.call(s)}finally{if(o)throw o.error}}}function zn(r,o,d){d===void 0&&(d=.18),r&&Qn.to(r.id,Or(r),o,d)}function Pa(r,o,d,u){var s,p,h=u!=null?u:d==null?void 0:d.c;rr(ge(ge({},dt(r,o,h,ge({},d?{otherId:d.sourceId}:{}))),{instanceId:(s=o.instanceId)!==null&&s!==void 0?s:(p=d==null?void 0:d.c)===null||p===void 0?void 0:p.instanceId}))}function Yl(r){var o,d,u,s,p,h,g;if(!Ze||Ze.pointerId!==r.pointerId)return!1;var I=Ze,S=Be(I.targetId),m=I.b.parameters;Ze=void 0,bn=void 0;try{!((o=t.hasPointerCapture)===null||o===void 0)&&o.call(t,r.pointerId)&&((d=t.releasePointerCapture)===null||d===void 0||d.call(t,r.pointerId))}catch{}if(!S)return!0;var C=Ca(S),w=C.zones,P=C.tag,x=ia({itemId:S.id,tag:P,zones:w,occupancy:Rr}),T=I.origin,A=I.originZone;if(!x)return Pa("dragReject",S,void 0,void 0),m.snapBack&&(A&&Rr.place(S.id,A),zn(S,T,(u=m.snapBackSeconds)!==null&&u!==void 0?u:.18)),!0;var N=x.zone,W=x.occupantId?Be(x.occupantId):void 0;return x.kind==="reject"?(Pa("dragReject",S,N,W),m.snapBack&&(A&&Rr.place(S.id,A),zn(S,T,(s=m.snapBackSeconds)!==null&&s!==void 0?s:.18)),!0):(x.kind==="accept"?(Rr.place(S.id,N.id),N.snapMode==="center"&&zn(S,Or(N.c),(p=m.snapBackSeconds)!==null&&p!==void 0?p:.18)):x.kind==="swap"&&W&&(Rr.place(S.id,N.id),A?Rr.place(W.id,A):Rr.release(W.id),zn(S,Or(N.c),(h=m.snapBackSeconds)!==null&&h!==void 0?h:.18),zn(W,T,(g=m.snapBackSeconds)!==null&&g!==void 0?g:.18)),Pa("dragDrop",S,N,x.kind==="accept"?N.c:W),!0)}function Gl(r){var o,d,u,s,p;Qn.tick(r,function(x,T){var A=Be(x);A&&Qt(A,T.x,T.y)});try{for(var h=q(ie([],$(Rr.itemZone.keys()),!1)),g=h.next();!g.done;g=h.next()){var I=g.value,S=Be(I);(!S||!Sr(S))&&Rr.release(I)}}catch(x){o={error:x}}finally{try{g&&!g.done&&(d=h.return)&&d.call(h)}finally{if(o)throw o.error}}if(gr)try{for(var m=q(gr.holds),C=m.next();!C.done;C=m.next()){var w=C.value,P=w.charge.tick(r);P!==j[w.behavior.parameters.variableId]&&(j[w.behavior.parameters.variableId]=P,rr({kind:"variableChange",variableId:w.behavior.parameters.variableId,instanceId:w.c.instanceId,selfInstanceId:(p=w.c.instanceId)!==null&&p!==void 0?p:w.c.id}))}}catch(x){u={error:x}}finally{try{C&&!C.done&&(s=m.return)&&s.call(m)}finally{if(u)throw u.error}}}function bo(r,o){var d,u,s,p,h=o.targetMode;if(h==="pointer")return ge({},si);if(h==="component"){var g=Be(o.targetComponentId);return g?Or(g):void 0}if(h==="nearest-team"){var I=Or(r),S=[],m=o.team,C=(s=o.maxRangePx)!==null&&s!==void 0?s:0;try{for(var w=q(Ft.states),P=w.next();!P.done;P=w.next()){var x=$(P.value,2),T=x[0],A=x[1],g=Be(T);g&&Sr(g)&&S.push(ge(ge({id:T},Or(g)),{team:A.team}))}}catch(N){d={error:N}}finally{try{P&&!P.done&&(u=w.return)&&u.call(w)}finally{if(d)throw d.error}}return Jo(I,S,m,C,(p=r.instanceId)!==null&&p!==void 0?p:r.id)}}function Zl(r){var o,d,u,s,p;try{for(var h=q(e.gameplay.filter(function(H){return H.kind==="steer"})),g=h.next();!g.done;g=h.next()){var I=g.value,S=O.get(I.componentId),m=I.parameters;if(S.sceneId===Q)try{for(var C=(u=void 0,q(Xr(S))),w=C.next();!w.done;w=C.next()){var P=w.value;if(Sr(P)){var x=bo(P,m);if(x){var T=Or(P),A=x.x-T.x,N=x.y-T.y;if(!(m.maxRangePx>0&&Math.hypot(A,N)>m.maxRangePx)){var W=Math.atan2(N,A);m.mode==="flee"?W+=Math.PI:m.mode==="orbit"&&(W+=Math.PI/2);var D=(p=Ft.headings.get(P.id))!==null&&p!==void 0?p:W,V=qo(D,W,m.turnRateDegPerSec*Math.PI/180*r);Ft.headings.set(P.id,V),Qt(P,T.x+Math.cos(V)*m.speed*r,T.y+Math.sin(V)*m.speed*r),m.orientToVelocity!==!1&&_n(P,V)}}}}}catch(H){u={error:H}}finally{try{w&&!w.done&&(s=C.return)&&s.call(C)}finally{if(u)throw u.error}}}}catch(H){o={error:H}}finally{try{g&&!g.done&&(d=h.return)&&d.call(h)}finally{if(o)throw o.error}}}function Ta(r,o,d,u){var s;if(ye.length>=128){ft("Instance budget exhausted");return}var p=O.get(r),h=function(m){return 1+e.components.filter(function(C){return C.parentId===m}).reduce(function(C,w){return C+h(w.id)},0)};if(mr.size+h(p.id)>4096){ft("Runtime node budget exhausted");return}var g="instance."+ ++$e;function I(m,C){var w,P,x=m.id===p.id?g:g+":"+m.id,T=ge(ge({},m),{id:x,runtimeId:x,instanceId:g,prototypeId:m.id,prototype:!1,parentId:C,transform:ie([],$(m.transform),!1),spawnTime:se});mr.set(x,T);try{for(var A=q(e.components.filter(function(D){return D.parentId===m.id})),N=A.next();!N.done;N=A.next()){var W=N.value;I(W,x)}}catch(D){w={error:D}}finally{try{N&&!N.done&&(P=A.return)&&P.call(A)}finally{if(w)throw w.error}}return T}var S=I(p,void 0);return S.transform[4]=o,S.transform[5]=d,u&&(S.pathStartNode=u.startNode,S.pathTargetNode=u.targetNode,S.parentId=(s=e.gameplay.find(function(m){return m.id===u.networkBehaviorId}))===null||s===void 0?void 0:s.componentId),ye.push(S),ho(S),Ea(S),u&&Yi(0,!1),S}function $l(r,o,d){var u,s,p,h,g,I,S,m,C,w,P,x,T,A,N,W,D,V,H,G,F,te,de,ne,pe,Ce,We,De,me,xe,we;if(++Wr>1024){ft("Action budget exhausted");return}if(r.kind==="add"||r.kind==="set"){var Te=j[r.variableId],Oe=r.kind==="add"?Te+r.value:r.value;if(typeof Oe=="number"&&(!Number.isFinite(Oe)||Math.abs(Oe)>1e12)){ft("Variable range exceeded");return}j[r.variableId]=Oe,Te!==Oe&&rr({kind:"variableChange",variableId:r.variableId,instanceId:o.instanceId})}else if(r.kind==="setComponent"||r.kind==="setAsset"){var ce=Be(r.componentId);if(!ce)return;var yr=(C=Qe.get(ce.id))!==null&&C!==void 0?C:{transform:ie([],$(ce.transform),!1),parameters:{}};r.kind==="setComponent"?yr.parameters[r.key]=r.valueVariableId?j[r.valueVariableId]:r.value:yr.assetId=r.assetId,Qe.set(ce.id,yr),r.kind==="setComponent"&&r.key==="visible"&&r.value===!1&&(Rr.release(ce.id),Qn.cancel(ce.id))}else if(r.kind==="resetMatch")yo(r.componentId),po(r.componentId);else if(r.kind==="clearStrokes")(w=nn.get(r.componentId))===null||w===void 0||w.clear(),$t=$t.filter(function(ot){return ot.owner!==r.componentId});else if(r.kind==="resetMask"){var ce=Be(r.componentId),Ae=Mt("erase-mask",r.componentId);ce&&Ae&&hi(ce,Ae).reset()}else if(r.kind==="copyMatchAsset"){var fr=(P=wt.get(r.boardId))===null||P===void 0?void 0:P.snapshot().lastMatch,Me=O.get(r.componentId),nr=fr&&((T=(x=vo.get(r.boardId))===null||x===void 0?void 0:x.get(fr.group))===null||T===void 0?void 0:T.children.find(function(ot){return ot.contract==="native.image.v1"}));if(fr&&nr){var Ge=O.get(fr.from),Je=vr(hr(Ge),Ge.parameters.width/2,Ge.parameters.height/2),kr=Me.parentId?hr(O.get(Me.parentId)):jt(),ir=vr(Yt(kr),Je.x,Je.y),_e=(A=Qe.get(Me.id))!==null&&A!==void 0?A:{transform:ie([],$(Me.transform),!1),parameters:{}};_e.transform=ie([],$(_e.transform),!1),_e.transform[4]=ir.x-Me.parameters.width/2,_e.transform[5]=ir.y-Me.parameters.height/2,_e.assetId=(N=nr.assetSlots[0])===null||N===void 0?void 0:N.assetId,Qe.set(Me.id,_e)}}else if(r.kind==="hintMatch")Fr=void 0,(W=wt.get(r.componentId))===null||W===void 0||W.showHint();else if(r.kind==="spawn")Ta(r.prototypeId,r.x,r.y);else if(r.kind==="spawnAt"){var Ur=(r.at==="self"||r.at==="midpoint")&&(o.selfInstanceId!==void 0||o.instanceId!==void 0)?Be((D=o.selfInstanceId)!==null&&D!==void 0?D:o.instanceId):Nn(r.targetComponentId,o,"self"),Vt=(r.at==="other"||r.at==="midpoint")&&o.otherInstanceId!==void 0?Be(o.otherInstanceId):void 0,Me=r.at==="other"?Vt:Ur;if(r.at==="pointer"||(r.at==="midpoint"?Ur&&Vt:Me))for(var Nt=Ur?Or(Ur):void 0,Ct=Vt?Or(Vt):void 0,Je=r.at==="pointer"?si:r.at==="midpoint"?{x:(Nt.x+Ct.x)/2,y:(Nt.y+Ct.y)/2}:Or(Me),Jr=O.get(r.prototypeId),Cr=Math.max(0,Math.min(16,Math.floor(r.countVariableId?Number(j[r.countVariableId]):(V=r.count)!==null&&V!==void 0?V:1))),qr=0;qr<Cr;qr++){var jr=r.jitterX?(Ft.rng.next()*2-1)*r.jitterX:0,Yr=r.jitterY?(Ft.rng.next()*2-1)*r.jitterY:0;Ta(r.prototypeId,Je.x+r.offsetX+jr-Jr.parameters.width/2,Je.y+r.offsetY+Yr-Jr.parameters.height/2)}}else if(r.kind==="random"){var Te=j[r.variableId],Oe=Ft.rng.between(r.min,r.max,r.integer===!0);j[r.variableId]=Oe,Te!==Oe&&rr({kind:"variableChange",variableId:r.variableId,instanceId:o.instanceId})}else if(r.kind==="modifyInstanceState"){var ce=r.target==="component"?Be(r.componentId):Nn(r.componentId,o,r.target);ce&&Bl(ce,r.field,r.op,r.variableId?j[r.variableId]:r.value)}else if(r.kind==="launchToward"){var Ge=O.get(r.componentId),Kr=Xr(Ge),pr=(H=o.selfInstanceId)!==null&&H!==void 0?H:o.instanceId,ce=Ge.prototype?(G=Kr.find(function(xr){return xr.instanceId===pr||xr.id===pr}))!==null&&G!==void 0?G:Kr[Kr.length-1]:(F=Nn(r.componentId,o,"self"))!==null&&F!==void 0?F:Be(r.componentId),Ae=Mt("physics-body",r.componentId),tr=ce&&Bn(ce,Ae);if(!tr)return;var _r=void 0;if(r.targetMode==="angle-variable")_r=Number(j[r.angleVariableId])*Math.PI/180;else{var Me=bo(ce,r);if(!Me)return;var Je=Or(ce);_r=Math.atan2(Me.y-Je.y,Me.x-Je.x)}var at=Number(r.speedVariableId?j[r.speedVariableId]:r.speed);if(!Number.isFinite(at)){ft("Launch speed invalid");return}tr.vx=Math.cos(_r)*at,tr.vy=Math.sin(_r)*at,tr.atRest=!1,tr.restElapsed=0,tr.captured=!1,tr.exited=!1,r.orientToVelocity!==!1&&_n(ce,_r),rr(dt("launch",ce))}else if(r.kind==="moveToComponent"){var He=O.get(r.targetComponentId),ce=Nn(r.componentId,o,(te=r.target)!==null&&te!==void 0?te:"self"),Me=He&&qn(He)?(de=Nn(r.targetComponentId,o,r.target==="other"?"self":"other"))!==null&&de!==void 0?de:Xr(He)[0]:Be(r.targetComponentId);ce&&Me&&zn(ce,Or(Me),r.seconds)}else if(r.kind==="returnToOrigin"){var ce=Nn(r.componentId,o,"self"),ar=ce&&zi.get(ce.id);ce&&ar&&zn(ce,ar,r.seconds)}else if(r.kind==="spawnOnPath")Ta(r.prototypeId,0,0,{startNode:r.startNode,targetNode:r.targetNode,networkBehaviorId:r.networkBehaviorId});else if(["setVelocity","applyImpulse","stopBody"].includes(r.kind)){var Se=O.get(r.componentId),Vr=o.instanceId?ie([],$(mr.values()),!1).filter(function(dr){return dr.instanceId===o.instanceId&&dr.prototypeId===Se.id}):Xr(Se),Ae=Mt("physics-body",Se.id);try{for(var vt=q(Vr),pt=vt.next();!pt.done;pt=vt.next()){var ce=pt.value,tr=Bn(ce,Ae);r.kind==="setVelocity"?(tr.vx=r.vxVariableId?j[r.vxVariableId]:r.vx,tr.vy=r.vyVariableId?j[r.vyVariableId]:r.vy):r.kind==="applyImpulse"?(tr.vx+=r.vxVariableId?j[r.vxVariableId]:r.ix,tr.vy+=r.vyVariableId?j[r.vyVariableId]:r.iy):(tr.vx=0,tr.vy=0,tr.atRest=!0),tr.captured=!1,tr.exited=!1,tr.restElapsed=0,r.kind!=="stopBody"&&(tr.atRest=!1)}}catch(dr){u={error:dr}}finally{try{pt&&!pt.done&&(s=vt.return)&&s.call(vt)}finally{if(u)throw u.error}}}else if(r.kind==="setPosition"){var or=O.get(r.componentId),Vr=o.instanceId?ie([],$(mr.values()),!1).filter(function(Qr){return Qr.instanceId===o.instanceId&&Qr.prototypeId===or.id}):Xr(or),Ae=Mt("physics-body",or.id);try{for(var st=q(Vr),Et=st.next();!Et.done;Et=st.next()){var ce=Et.value,tr=Bn(ce,Ae);tr.x=r.xVariableId?j[r.xVariableId]:r.x,tr.y=r.yVariableId?j[r.yVariableId]:r.y,tr.vx=0,tr.vy=0,tr.captured=!1,tr.exited=!1,tr.atRest=!0,Qt(ce,tr.x,tr.y)}}catch(Qr){p={error:Qr}}finally{try{Et&&!Et.done&&(h=st.return)&&h.call(st)}finally{if(p)throw p.error}}}else if(r.kind==="setPathEdge")(ne=Zt.get(r.behaviorId))===null||ne===void 0||ne.setEdge(r.edgeId,r.enabled,r.cost);else if(r.kind==="setPathGate")(Ce=Zt.get((pe=e.gameplay.find(function(ot){return ot.id===r.behaviorId}))===null||pe===void 0?void 0:pe.parameters.networkBehaviorId))===null||Ce===void 0||Ce.setGate(r.behaviorId,r.mode,r.holdSeconds);else if(r.kind==="setPathTarget"){var Sn=O.get(r.componentId),Ae=Mt("path-agent",Sn.id),ln=Zt.get(Ae.parameters.networkBehaviorId);try{for(var Pt=q(o.instanceId?ie([],$(mr.values()),!1).filter(function(dr){return dr.instanceId===o.instanceId&&dr.prototypeId===Sn.id}):Xr(Sn)),ct=Pt.next();!ct.done;ct=Pt.next()){var ce=ct.value;ce.pathTargetNode=r.targetNode,ln==null||ln.setTarget(ce.id,r.targetNode)}}catch(dr){g={error:dr}}finally{try{ct&&!ct.done&&(I=Pt.return)&&I.call(Pt)}finally{if(g)throw g.error}}}else if(r.kind==="compute"){var Lr=Number(j[r.variableId]),Gr=r.operandVariableId!==void 0?Number(j[r.operandVariableId]):r.value;if(["div","mod"].includes(r.op)&&Gr===0){ft("Division by zero");return}var Oe={add:function(){return Lr+Gr},sub:function(){return Lr-Gr},mul:function(){return Lr*Gr},div:function(){return Gr===0?Lr:Lr/Gr},mod:function(){return Gr===0?Lr:Lr%Gr},min:function(){return Math.min(Lr,Gr)},max:function(){return Math.max(Lr,Gr)},set:function(){return Gr},floor:function(){return Math.floor(Lr)},ceil:function(){return Math.ceil(Lr)},abs:function(){return Math.abs(Lr)},clamp:function(){return Math.max(r.min,Math.min(r.max,Lr))}}[r.op]();if(r.round&&(Oe=Math.round(Oe)),!Number.isFinite(Oe)||Math.abs(Oe)>1e12){ft("Variable range exceeded");return}var Te=j[r.variableId];j[r.variableId]=Oe,Te!==Oe&&rr({kind:"variableChange",variableId:r.variableId,instanceId:o.instanceId})}else if(r.kind==="despawn"){var Ur=(We=o.selfInstanceId)!==null&&We!==void 0?We:o.instanceId;r.target==="other"?Hi(o.otherInstanceId):r.target==="both"?(Hi(Ur),Hi(o.otherInstanceId)):Hi(Ur)}else if(r.kind==="changeScene")r.delaySeconds>0?r.sceneId!==Q&&(Rt!=null||(Rt={sceneId:r.sceneId,at:se+r.delaySeconds})):xt=r.sceneId;else if(r.kind==="restart")(De=ee==null?void 0:ee.notifyGameRetry)===null||De===void 0||De.call(ee),xt="__restart";else if(r.kind==="cameraShake")Z!=null&&Z.matches||(Ar={intensity:r.intensity,seconds:r.seconds,elapsed:0});else if(r.kind==="screenFlash")yt.push({color:r.color,opacity:r.opacity,seconds:r.seconds,elapsed:0}),yt.length>8&&yt.shift();else if(r.kind==="floatingText"){var fn=O.get(r.componentId),Ge=o.instanceId?(me=ie([],$(mr.values()),!1).find(function(Qr){return Qr.instanceId===o.instanceId&&Qr.prototypeId===r.componentId}))!==null&&me!==void 0?me:fn:(xe=Be(r.componentId))!==null&&xe!==void 0?xe:fn,Me=(Ge==null?void 0:Ge.sceneId)===Q?Ge:fn;if(Me){var Je=void 0;if(!Je){var ht=Fe(Me);Je=vr(hr(Me),ht.width/2,ht.height/2)}lt.push({x:Je.x,y:Je.y,text:r.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(xr,br){var Nr;return String((Nr=j[br])!==null&&Nr!==void 0?Nr:"")}),color:r.color,fontSize:r.fontSize,risePx:r.risePx,seconds:r.seconds,elapsed:0}),lt.length>32&&lt.shift()}}else if(r.kind==="store")o.kind==="click"&&o.pointerId!==void 0&&!bt&&(bt={pointerId:o.pointerId,targetId:o.targetId,condition:d},(we=t.setPointerCapture)===null||we===void 0||we.call(t,o.pointerId));else if(r.behaviorId){var et=e.gameplay.find(function(ot){return ot.id===r.behaviorId});if(r.kind==="playAudio")xo(et);else if(r.kind==="animate"){var Tt=O.get(et.componentId),Vr=qn(Tt)?ie([],$(mr.values()),!1).filter(function(dr){return dr.prototypeId===Tt.id&&(!o.instanceId||dr.instanceId===o.instanceId)}):[Tt],dn=function(dr){var Qr=et.id+":"+dr.id;Ie=Ie.filter(function(br){return br.id!==Qr});var xr=ge({},et.parameters);xr.fromCurrent&&(xr.from=xr.property==="opacity"?Fe(dr).opacity:St(dr)[xr.property==="x"?4:5]),Ie.push(ge(ge({},et),{parameters:xr,id:Qr,behaviorId:et.id,targetId:dr.id,elapsed:0,baseTransform:ie([],$(dr.transform),!1)}))};try{for(var Ir=q(Vr),Ye=Ir.next();!Ye.done;Ye=Ir.next()){var Me=Ye.value;dn(Me)}}catch(dr){S={error:dr}}finally{try{Ye&&!Ye.done&&(m=Ir.return)&&m.call(Ir)}finally{if(S)throw S.error}}}else r.kind==="stopAnimation"?Ie=Ie.filter(function(ot){return ot.behaviorId!==et.id}):r.kind==="emit"&&Kl(et,o)}}function Kl(r,o){var d,u,s,p,h,g=r.parameters,I=g.shape==="pixel-confetti",S=g.shape==="confetti",m=I||S;if(!(m&&(Z!=null&&Z.matches))){if(le.length+g.count>256){ft("Particle budget exhausted");return}if(I&&g.coverage==="screen"){le.push.apply(le,ie([],$(yl(g)),!1));return}if(S&&g.coverage==="screen"){le.push.apply(le,ie([],$(ml(g)),!1));return}for(var C=O.get(r.componentId),w=o.instanceId&&(d=ie([],$(mr.values()),!1).find(function(G){return G.instanceId===o.instanceId&&G.prototypeId===C.id}))!==null&&d!==void 0?d:C,P=St(w),x,T=Be(w.parentId);T;T=Be(T.parentId)){if(m&&T.contract==="native.group.v1"&&Fe(T).clip){x=T.id;break}P=ai(St(T),P)}var A=Fe(w),N=g.origin==="anchor"?vr(P,0,0):m||g.origin==="center"?vr(P,A.width/2,A.height/2):{x:P[4]+w.parameters.width/2,y:P[5]+w.parameters.height/2};if(I){le.push.apply(le,ie([],$(eo(g,N,x)),!1));return}if(S){le.push.apply(le,ie([],$(ro(g,N,x)),!1));return}for(var W=Ka($a(w.id+":"+se.toFixed(3))),D=0;D<g.count;D++){var V=-Math.PI/2+((D+W.next())/g.count-.5)*((u=g.spread)!==null&&u!==void 0?u:360)*Math.PI/180,H=g.speed*W.between(.5,.95);le.push(ge(ge({},N),{vx:Math.cos(V)*H,vy:Math.sin(V)*H,life:(s=g.lifetime)!==null&&s!==void 0?s:.7,gravity:(p=g.gravity)!==null&&p!==void 0?p:250,color:g.color,shape:(h=g.shape)!==null&&h!==void 0?h:"circle"}))}}}function wo(r){var o,d;if(r==="__restart"){Ma();return}if(r!==Q){Rt=void 0;var u=Q;ci(),Q=r,an.clear(),Rr.clear(),zi.clear(),Wi.clear(),Jn.clear(),nn.clear(),$t=[],wn=[],Vn.clear(),Li.clear(),Fr=void 0,ye=[],le=[],lt=[],yt=[],Ar=void 0,Oi=!1,fi=0,mr.clear(),Ot.clear(),Rn.clear(),On.clear(),Bi.clear(),Xe=void 0,go(),X=X.filter(function(g){return g.kind==="variableChange"}),Qe.clear(),nt=void 0;try{for(var s=q(wt.values()),p=s.next();!p.done;p=s.next()){var h=p.value;h.reset()}}catch(g){o={error:g}}finally{try{p&&!p.done&&(d=s.return)&&d.call(s)}finally{if(o)throw o.error}}ve.clear(),Ne.clear(),An.clear(),Ie=[],Kt(),ae.clear(),tt=void 0,At=void 0,Yi(0,!1),Ea(),wa(0),rr({kind:"sceneExit",sceneId:u}),rr({kind:"sceneEnter",sceneId:Q})}}function on(){for(var r=function(){var o,d,u,s,p=X.shift();zr++;var h=function(x){return x===void 0||!!Be(x)||ie([],$(mr.values()),!1).some(function(T){return T.instanceId===x})};if(!h(p.selfInstanceId)||!h(p.otherInstanceId)||["contactBegin","boundaryExit"].includes(p.kind)&&p.instanceId&&!mr.has(p.instanceId))return"continue";try{for(var g=(o=void 0,q(e.eventBindings)),I=g.next();!I.done;I=g.next()){var S=I.value;if(Object.entries(be.get(S.eventId)).every(function(x){var T=$(x,2),A=T[0],N=T[1];return A==="id"||p[A]===N})&&Ui(S.condition,p)){try{for(var m=(u=void 0,q(S.actions)),C=m.next();!C.done;C=m.next()){var w=C.value;if(Wr>=1024||Tr)break;$l(w,p,S.condition)}}catch(x){u={error:x}}finally{try{C&&!C.done&&(s=m.return)&&s.call(m)}finally{if(u)throw u.error}}if(xt)break}}}catch(x){o={error:x}}finally{try{I&&!I.done&&(d=g.return)&&d.call(g)}finally{if(o)throw o.error}}if(xt){var P=xt;xt=void 0,wo(P)}};X.length&&!Tr&&zr<256&&Wr<1024;)r();X.length&&ft("Event/action budget exhausted")}function hr(r){return ai(r.parentId?hr(Be(r.parentId)):jt(),St(r))}var vr=function(r,o,d){return{x:r[0]*o+r[2]*d+r[4],y:r[1]*o+r[3]*d+r[5]}};function ut(r,o){var d=Fe(r),u=[[0,0],[d.width,0],[d.width,d.height],[0,d.height]].map(function(s){var p=$(s,2),h=p[0],g=p[1];return vr(o,h,g)});return{left:Math.min.apply(Math,ie([],$(u.map(function(s){return s.x})),!1)),right:Math.max.apply(Math,ie([],$(u.map(function(s){return s.x})),!1)),top:Math.min.apply(Math,ie([],$(u.map(function(s){return s.y})),!1)),bottom:Math.max.apply(Math,ie([],$(u.map(function(s){return s.y})),!1))}}function Sr(r){return Fe(r).visible&&Fe(r).opacity>0&&(!r.parentId||Sr(Be(r.parentId)))}function Mo(r,o){for(var d=Fe(r),u=hr(r),s=Math.min(d.width,d.height)/2,p=o==="circle"?Array.from({length:32},function(I,S){return vr(u,d.width/2+Math.cos(S*Math.PI/16)*s,d.height/2+Math.sin(S*Math.PI/16)*s)}):[[0,0],[d.width,0],[d.width,d.height],[0,d.height]].map(function(I){var S=$(I,2),m=S[0],C=S[1];return vr(u,m,C)}),h=r.parentId?Be(r.parentId):void 0,g=function(){var I=Fe(h);if(h.contract==="native.group.v1"&&I.clip){for(var S=hr(h),m=[[0,0],[I.width,0],[I.width,I.height],[0,I.height]].map(function(T){var A=$(T,2),N=A[0],W=A[1];return vr(S,N,W)}),C=0,w=0;w<4;w++)C+=m[w].x*m[(w+1)%4].y-m[(w+1)%4].x*m[w].y;for(var P=C>=0?1:-1,x=function(T){var A,N,W=m[T],D=m[(T+1)%4],V=function(We){return P*((D.x-W.x)*(We.y-W.y)-(D.y-W.y)*(We.x-W.x))},H=p;p=[];var G=H[H.length-1],F=V(G);try{for(var te=(A=void 0,q(H)),de=te.next();!de.done;de=te.next()){var ne=de.value,pe=V(ne);if(pe>=0!=F>=0){var Ce=F/(F-pe);p.push({x:G.x+(ne.x-G.x)*Ce,y:G.y+(ne.y-G.y)*Ce})}pe>=0&&p.push(ne),G=ne,F=pe}}catch(We){A={error:We}}finally{try{de&&!de.done&&(N=te.return)&&N.call(te)}finally{if(A)throw A.error}}},w=0;w<4&&p.length;w++)x(w)}h=h.parentId?Be(h.parentId):void 0};h;)g();return p}function Ql(r,o){var d,u,s,p,h,g;if(r.length<3||o.length<3)return!1;try{for(var I=q([r,o]),S=I.next();!S.done;S=I.next())for(var m=S.value,C=0;C<m.length;C++){var w=m[C],P=m[(C+1)%m.length],x=w.y-P.y,T=P.x-w.x,A=1/0,N=-1/0,W=1/0,D=-1/0;try{for(var V=(s=void 0,q(r)),H=V.next();!H.done;H=V.next()){var G=H.value,F=G.x*x+G.y*T;A=Math.min(A,F),N=Math.max(N,F)}}catch(ne){s={error:ne}}finally{try{H&&!H.done&&(p=V.return)&&p.call(V)}finally{if(s)throw s.error}}try{for(var te=(h=void 0,q(o)),de=te.next();!de.done;de=te.next()){var G=de.value,F=G.x*x+G.y*T;W=Math.min(W,F),D=Math.max(D,F)}}catch(ne){h={error:ne}}finally{try{de&&!de.done&&(g=te.return)&&g.call(te)}finally{if(h)throw h.error}}if(N<W||D<A)return!1}}catch(ne){d={error:ne}}finally{try{S&&!S.done&&(u=I.return)&&u.call(I)}finally{if(d)throw d.error}}return!0}function Jl(r){var o,d,u,s,p=R();try{for(var h=q(an.values()),g=h.next();!g.done;g=h.next()){var I=g.value,S=I.behavior.parameters;if(!(!S.moveComponentId||I.magnitude<=0)){var m=Be(S.moveComponentId);if(!(!m||!Sr(m))){var C=(u=S.moveSpeed)!==null&&u!==void 0?u:220,w=Mt("physics-body",(s=m.prototypeId)!==null&&s!==void 0?s:m.id);if(w&&w.parameters.mode==="dynamic"){var P=Bn(m,w);P.vx=I.nx*C,P.vy=I.ny*C,P.atRest=!1,P.restElapsed=0}else{var x=Or(m),T=Fe(m),A=x.x+I.nx*C*r,N=x.y+I.ny*C*r;So(m)||(A=Math.max(T.width/2,Math.min(p.width-T.width/2,A)),N=Math.max(T.height/2,Math.min(p.height-T.height/2,N))),Qt(m,A,N)}S.orientToMove&&_n(m,Math.atan2(I.ny,I.nx))}}}}catch(W){o={error:W}}finally{try{g&&!g.done&&(d=h.return)&&d.call(h)}finally{if(o)throw o.error}}}function ql(r){var o,d,u,s,p,h,g,I,S,m,C,w,P,x,T,A,N,W,D,V,H,G,F,te,de,ne,pe,Ce,We,De,me,xe,we=R();se+=r,Rt&&se>=Rt.at&&wo(Rt.sceneId),sf(r),Gl(r),Jl(r),Zl(r),Dl();try{for(var Te=q(xn),Oe=Te.next();!Oe.done;Oe=Te.next()){var ce=$(Oe.value,2),yr=ce[0],Ae=ce[1];!Ae.held&&se-((F=Ae.releasedAt)!==null&&F!==void 0?F:se)>=Ae.behavior.springBackSeconds&&xn.delete(yr)}}catch(Ve){o={error:Ve}}finally{try{Oe&&!Oe.done&&(d=Te.return)&&d.call(Te)}finally{if(o)throw o.error}}Ar&&(Ar.elapsed+=r,Ar.elapsed>=Ar.seconds&&(Ar=void 0));try{for(var fr=q(yt),Me=fr.next();!Me.done;Me=fr.next()){var nr=Me.value;nr.elapsed+=r}}catch(Ve){u={error:Ve}}finally{try{Me&&!Me.done&&(s=fr.return)&&s.call(fr)}finally{if(u)throw u.error}}yt=yt.filter(function(Ve){return Ve.elapsed<Ve.seconds});try{for(var Ge=q(lt),Je=Ge.next();!Je.done;Je=Ge.next()){var kr=Je.value;kr.elapsed+=r}}catch(Ve){p={error:Ve}}finally{try{Je&&!Je.done&&(h=Ge.return)&&h.call(Ge)}finally{if(p)throw p.error}}lt=lt.filter(function(Ve){return Ve.elapsed<Ve.seconds});try{for(var ir=q(wt),_e=ir.next();!_e.done;_e=ir.next()){var Ur=$(_e.value,2),yr=Ur[0],Vt=Ur[1];O.get(yr).sceneId===Q&&Sr(O.get(yr))&&Vt.tick(r)}}catch(Ve){g={error:Ve}}finally{try{_e&&!_e.done&&(I=ir.return)&&I.call(ir)}finally{if(g)throw g.error}}var Nt=function(Ve){var ur,Dr,Zr=O.get(Ve.componentId);if(Zr.sceneId!==Q)return"continue";var Er=qn(Zr)?ie([],$(mr.values()),!1).filter(function(Hn){return Hn.prototypeId===Zr.id}):[Zr];try{for(var rt=(ur=void 0,q(Er)),sr=rt.next();!sr.done;sr=rt.next()){var Br=sr.value,Cn=Ve.id+":"+Br.id;if(Ve.kind==="motion"){var gt=(te=Qe.get(Br.id))!==null&&te!==void 0?te:{transform:ie([],$(Br.transform),!1),parameters:{}},zt=(de=gt.velocity)!==null&&de!==void 0?de:{x:Ve.parameters.vx,y:Ve.parameters.vy};zt.y+=Ve.parameters.gravity*r,gt.transform[4]+=zt.x*r,gt.transform[5]+=zt.y*r,gt.velocity=zt,Qe.set(Br.id,gt),Br.prototypeId&&(Br.transform=gt.transform);var un=hr(Br);(un[5]>we.height||un[4]<-300||un[4]>we.width+300)&&(gt.exited||(gt.exited=!0,rr({kind:"boundaryExit",componentId:Zr.id,instanceId:Br.instanceId})))}else if(Ve.kind==="timer"){var Dn=((ne=An.get(Cn))!==null&&ne!==void 0?ne:0)+r;An.set(Cn,Dn),Dn>=Ve.parameters.seconds&&Dn-r<Ve.parameters.seconds&&(rr(ge({kind:"timer",behaviorId:Ve.id,componentId:Zr.id},Br.instanceId?{instanceId:Br.instanceId,selfInstanceId:Br.instanceId}:{})),Ve.parameters.repeat&&An.set(Cn,Dn-Ve.parameters.seconds))}}}catch(Hn){ur={error:Hn}}finally{try{sr&&!sr.done&&(Dr=rt.return)&&Dr.call(rt)}finally{if(ur)throw ur.error}}};try{for(var Ct=q(e.gameplay),Jr=Ct.next();!Jr.done;Jr=Ct.next()){var Cr=Jr.value;Nt(Cr)}}catch(Ve){S={error:Ve}}finally{try{Jr&&!Jr.done&&(m=Ct.return)&&m.call(Ct)}finally{if(S)throw S.error}}Ll(r),Yi(r),wa(r);var qr=[],jr=function(Ve){var ur,Dr,Zr=O.get(Ve.componentId);if(Zr.sceneId!==Q)return"continue";try{for(var Er=(ur=void 0,q(qn(Zr)?ie([],$(mr.values()),!1).filter(function(Br){return Br.prototypeId===Zr.id}):[Zr])),rt=Er.next();!rt.done;rt=Er.next()){var sr=rt.value;if(Sr(sr)){if(qr.length>=256){ft("Collider budget exhausted");break}qr.push({b:Ve,c:sr,box:ut(sr,hr(sr)),polygon:Mo(sr,Ve.parameters.shape)})}}}catch(Br){ur={error:Br}}finally{try{rt&&!rt.done&&(Dr=Er.return)&&Dr.call(Er)}finally{if(ur)throw ur.error}}};try{for(var Yr=q(e.gameplay.filter(function(Ve){return Ve.kind==="collider"})),Kr=Yr.next();!Kr.done;Kr=Yr.next()){var Cr=Kr.value;jr(Cr)}}catch(Ve){C={error:Ve}}finally{try{Kr&&!Kr.done&&(w=Yr.return)&&w.call(Yr)}finally{if(C)throw C.error}}var pr=new Set,tr=new Map,_r=function(Ve,ur,Dr){var Zr,Er,rt;((Zr=ur.c.prototypeId)!==null&&Zr!==void 0?Zr:ur.c.id)===((Er=Dr.c.prototypeId)!==null&&Er!==void 0?Er:Dr.c.id)&&ur.c.id>Dr.c.id||rr(ge(ge({},dt(Ve,ur.c,Dr.c)),{instanceId:(rt=ur.c.instanceId)!==null&&rt!==void 0?rt:Dr.c.instanceId}))},at=0;e:for(var He=0;He<qr.length;He++)for(var Cr=He+1;Cr<qr.length;Cr++){var ar=qr[He],Se=qr[Cr];if(!(ar.c.instanceId&&ar.c.instanceId===Se.c.instanceId)){var Vr=ar.box,vt=Se.box,pt=Vr.left<vt.right&&Vr.right>vt.left&&Vr.top<vt.bottom&&Vr.bottom>vt.top;if(pt){if(++at>4096){ft("Collision budget exhausted");break e}pt=Ql(ar.polygon,Se.polygon)}if(pt){var or=[ar.c.id,Se.c.id].sort().join("|");if(pr.add(or),tr.set(or,[ar,Se]),!ve.has(or))try{for(var st=(P=void 0,q([[ar,Se],[Se,ar]])),Et=st.next();!Et.done;Et=st.next()){var Sn=$(Et.value,2),ln=Sn[0],Pt=Sn[1];_r("contactBegin",ln,Pt)}}catch(ur){P={error:ur}}finally{try{Et&&!Et.done&&(x=st.return)&&x.call(st)}finally{if(P)throw P.error}}}}}try{for(var ct=q(Ne),Lr=ct.next();!Lr.done;Lr=ct.next()){var Gr=$(Lr.value,2),or=Gr[0],fn=$(Gr[1],2),ar=fn[0],Se=fn[1];if(!pr.has(or))try{for(var ht=(N=void 0,q([[ar,Se],[Se,ar]])),et=ht.next();!et.done;et=ht.next()){var Tt=$(et.value,2),ln=Tt[0],Pt=Tt[1];_r("contactEnd",ln,Pt)}}catch(Zr){N={error:Zr}}finally{try{et&&!et.done&&(W=ht.return)&&W.call(ht)}finally{if(N)throw N.error}}}}catch(Ve){T={error:Ve}}finally{try{Lr&&!Lr.done&&(A=ct.return)&&A.call(ct)}finally{if(T)throw T.error}}ve=pr,Ne=tr;try{for(var dn=q(Ie),Ir=dn.next();!Ir.done;Ir=dn.next()){var He=Ir.value;He.elapsed+=r;var Ye=He.parameters,ot=(pe=Ye.delay)!==null&&pe!==void 0?pe:0,dr=He.elapsed-ot;if(!(dr<0)){var Qr=dr/Ye.seconds,xr=Ye.loop?Qr%1:Math.min(1,Qr),br=(Ce=Ye.easing)!==null&&Ce!==void 0?Ce:"ease-out",Nr=xr;Ye.loop&&br==="ease-in-out"?Nr=.5-.5*Math.cos(xr*Math.PI*2):br==="ease-out"?Nr=1-Math.pow(1-xr,3):br==="ease-in"?Nr=Math.pow(xr,3):br==="ease-in-out"?Nr=xr<.5?4*Math.pow(xr,3):1-Math.pow(-2*xr+2,3)/2:br==="back-out"&&(Nr=1+2.70158*Math.pow(xr-1,3)+1.70158*Math.pow(xr-1,2));var je=Ye.from+(Ye.to-Ye.from)*Nr,qe=Be((We=He.targetId)!==null&&We!==void 0?We:He.componentId);if(qe){var mt=(De=Qe.get(qe.id))!==null&&De!==void 0?De:{transform:ie([],$(qe.transform),!1),parameters:{}},Xt=(me=He.baseTransform)!==null&&me!==void 0?me:qe.transform;if(Ye.property==="opacity")mt.parameters.opacity=Math.max(0,Math.min(1,je));else if(["scale","scaleX","scaleY","rotation"].includes(Ye.property)){(xe=mt.animationAxes)!==null&&xe!==void 0||(mt.animationAxes={scale:1,scaleX:1,scaleY:1,rotation:0}),mt.animationAxes[Ye.property]=je;var Ut=mt.animationAxes,kn=Ut.rotation*Math.PI/180,ri=Math.cos(kn),Wn=Math.sin(kn),ti=Ut.scale*Ut.scaleX,ni=Ut.scale*Ut.scaleY;mt.transform[0]=(Xt[0]*ri+Xt[2]*Wn)*ti,mt.transform[1]=(Xt[1]*ri+Xt[3]*Wn)*ti,mt.transform[2]=(-Xt[0]*Wn+Xt[2]*ri)*ni,mt.transform[3]=(-Xt[1]*Wn+Xt[3]*ri)*ni}else mt.transform[Ye.property==="x"?4:5]=je;Qe.set(qe.id,mt),Ye.loop&&dr>=Ye.seconds&&(He.elapsed=ot+dr%Ye.seconds)}}}}catch(Ve){D={error:Ve}}finally{try{Ir&&!Ir.done&&(V=dn.return)&&V.call(dn)}finally{if(D)throw D.error}}Ie=Ie.filter(function(Ve){var ur,Dr;return Be((ur=Ve.targetId)!==null&&ur!==void 0?ur:Ve.componentId)&&(Ve.elapsed<Ve.parameters.seconds+((Dr=Ve.parameters.delay)!==null&&Dr!==void 0?Dr:0)||Ve.parameters.loop)});try{for(var Ln=q(le),Bt=Ln.next();!Bt.done;Bt=Ln.next()){var Ye=Bt.value;if(Ye.age!==void 0){Ye.age+=r;continue}Ye.life-=r,Ye.x+=Ye.vx*r,Ye.y+=Ye.vy*r,Ye.vy+=Ye.gravity*r}}catch(Ve){H={error:Ve}}finally{try{Bt&&!Bt.done&&(G=Ln.return)&&G.call(Ln)}finally{if(H)throw H.error}}le=le.filter(function(Ve){var ur;return Ve.life>((ur=Ve.age)!==null&&ur!==void 0?ur:0)}),on()}function Gi(r,o){var d,u,s;if(y.beginPath(),r.contract==="native.ellipse.v1")y.ellipse(o.width/2,o.height/2,o.width/2,o.height/2,0,0,Math.PI*2);else if(r.contract==="native.path.v1"){var p=function(w,P){({M:function(){return y.moveTo.apply(y,ie([],$(P),!1))},L:function(){return y.lineTo.apply(y,ie([],$(P),!1))},C:function(){return y.bezierCurveTo.apply(y,ie([],$(P),!1))},Q:function(){return y.quadraticCurveTo.apply(y,ie([],$(P),!1))},Z:function(){return y.closePath()}})[w]()};try{for(var h=q(o.commands),g=h.next();!g.done;g=h.next()){var I=$(g.value),S=I[0],m=I.slice(1);p(S,m)}}catch(w){d={error:w}}finally{try{g&&!g.done&&(u=h.return)&&u.call(h)}finally{if(d)throw d.error}}}else{var C=Math.min((s=o.radius)!==null&&s!==void 0?s:0,o.width/2,o.height/2);typeof y.roundRect=="function"?y.roundRect(0,0,o.width,o.height,C):(y.moveTo(C,0),y.arcTo(o.width,0,o.width,o.height,C),y.arcTo(o.width,o.height,0,o.height,C),y.arcTo(0,o.height,0,0,C),y.arcTo(0,0,o.width,0,C),y.closePath())}}function jl(r,o,d){var u,s,p,h=(u=Qe.get(r.id))===null||u===void 0?void 0:u.pathFrame;if(h!==void 0)return Math.min(o.frameCount-1,h);if(k||!o.frameRate)return 0;if(r.contract!=="native.walk-sprite.v1")return Math.floor(Math.max(0,se-((s=r.spawnTime)!==null&&s!==void 0?s:0))*o.frameRate)%o.frameCount;var g=(p=r.runtimeId)!==null&&p!==void 0?p:r.id,I=ui.get(g);if(!I)return ui.set(g,{x:d[4],y:d[5],phase:0,lastMove:-1/0,frame:0}),0;var S=Math.hypot(d[4]-I.x,d[5]-I.y)>.3;if(S){var m=se-I.lastMove;I.phase=Number.isFinite(m)&&m<.25?I.phase+Math.min(m,.12)*o.frameRate:0,I.lastMove=se}return I.x=d[4],I.y=d[5],se-I.lastMove>.11&&(I.phase=0),I.frame=Math.floor(I.phase)%o.frameCount,I.frame}var pi=!1,ei={width:390,height:700};function Aa(r){var o,d;r!==pi&&(r?(y.save(),y.beginPath(),y.rect((o=ei.left)!==null&&o!==void 0?o:0,(d=ei.top)!==null&&d!==void 0?d:0,ei.width,ei.height),y.clip(),pi=!0):(y.restore(),pi=!1))}function mi(r,o,d,u,s){var p,h,g,I,S,m,C,w,P;if(o===void 0&&(o=jt()),d===void 0&&(d=[]),s===void 0&&(s=!1),r.contract!=="native.mesh3d.v1"){var x=Fe(r),T=Mt("erase-mask",(g=r.prototypeId)!==null&&g!==void 0?g:r.id);if(!(!x.visible||x.opacity<=0)){var A=ai(o,St(r));pi||Aa(!0),y.save(),y.transform.apply(y,ie([],$(s?A:St(r)),!1)),y.globalAlpha*=x.opacity;var N=xn.get(r.id);N!=null&&N.behavior.liftShadow&&(y.shadowColor="#00000055",y.shadowBlur=8,y.shadowOffsetY=4);var W=d;r.contract==="native.group.v1"&&x.clip&&(y.beginPath(),y.rect(0,0,x.width,x.height),y.clip(),W=ie(ie([],$(d),!1),[{matrix:A,width:x.width,height:x.height}],!1));var D=!1;if(!["native.group.v1","native.text.v1","native.image.v1","native.sprite.v1","native.walk-sprite.v1","native.stage3d.v1","native.mesh3d.v1"].includes(r.contract)){var V=r.contract==="native.button.v1",H=tt===r.id,G=V?x.enabled?H?x.pressedFill:Gt===r.id?x.hoverFill:x.fill:x.disabledFill:x.fill;if(V&&(x.presentation==="pixel-cta"||x.presentation==="shiny-cta")){var F=(I=he.get(r.id))!==null&&I!==void 0?I:ke;ae.set(r.id,F);var te=!k&&!(Z!=null&&Z.matches)?ke-F:-1;x.presentation==="shiny-cta"?xl(y,x,G,H,te):Il(y,x,G,H,te)}else x.pixelFrame&&(y.save(),y.translate(3,4),Gi(r,x),y.fillStyle="#3c293366",y.fill(),y.restore()),Gi(r,x),T?(y.save(),y.clip(),hi(r,T).render(y),y.restore(),D=!0,Gi(r,x)):(y.fillStyle=G,y.fill()),x.pixelFrame&&!(x.radius>0)&&(y.fillStyle="#ffffff22",y.fillRect(2,2,Math.max(0,x.width-4),2),y.fillRect(2,2,2,Math.max(0,x.height-4))),x.strokeWidth&&(y.strokeStyle=x.stroke,y.lineWidth=x.strokeWidth,y.stroke());Fr===r.id&&(Gi(r,x),y.strokeStyle="#ffffff",y.lineWidth=5,y.stroke())}var de;if(r.contract==="native.text.v1"){var ne=x.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Je,kr){var ir;return String((ir=j[kr])!==null&&ir!==void 0?ir:"")});x.pixelPanel&&(y.fillStyle="#3c293366",y.fillRect(3,4,x.width,x.height),y.fillStyle=x.panelFill,y.fillRect(0,0,x.width,x.height),y.strokeStyle=(S=x.panelStroke)!==null&&S!==void 0?S:x.color,y.lineWidth=2,y.strokeRect(1,1,x.width-2,x.height-2),y.fillStyle="#ffffff22",y.fillRect(3,3,Math.max(0,x.width-6),2));var pe=x.fontFamily==="pixel"?qa(ne,x):void 0;pe&&!pe.unsupportedChars.length?de=hl(y,ne,x):de=id(y,ne,pe?ge(ge({},x),{fontFamily:"sans-serif",fontWeight:"700"}):x)}if(["native.image.v1","native.sprite.v1","native.walk-sprite.v1"].includes(r.contract)&&!T){var Ce=Pe.get((C=(m=Qe.get(r.id))===null||m===void 0?void 0:m.assetId)!==null&&C!==void 0?C:(w=r.assetSlots[0])===null||w===void 0?void 0:w.assetId);if(Ce!=null&&Ce.complete&&Ce.naturalWidth){y.save(),y.beginPath(),y.rect(0,0,x.width,x.height),y.clip();var We=r.contract!=="native.image.v1",De=We?Math.min(x.frameColumns,x.frameCount):1,me=We?Math.ceil(x.frameCount/De):1,xe=Ce.width/De,we=Ce.height/me,Te=We?jl(r,x,A):0,Oe=Te%De*xe,ce=Math.floor(Te/De)*we,yr=x.fit==="cover"?Math.max(x.width/xe,x.height/we):Math.min(x.width/xe,x.height/we),Ae=x.fit==="stretch"?x.width:xe*yr,fr=x.fit==="stretch"?x.height:we*yr;y.imageSmoothingEnabled=(P=x.smoothing)!==null&&P!==void 0?P:!0,y.drawImage(Ce,Oe,ce,xe,we,(x.width-Ae)/2,(x.height-fr)/2,Ae,fr),y.restore()}}T&&!D&&hi(r,T).render(y),rn.push({c:r,m:A,clips:W,instance:u!=null?u:r.prototypeId,textMetrics:de});try{for(var Me=q(Xi(r.id)),nr=Me.next();!nr.done;nr=Me.next()){var Ge=nr.value;mi(Ge,A,W,u!=null?u:r.prototypeId)}}catch(Je){p={error:Je}}finally{try{nr&&!nr.done&&(h=Me.return)&&h.call(Me)}finally{if(p)throw p.error}}x.clip&&r.contract==="native.group.v1"&&Ra(r.id),y.restore()}}}function Ra(r,o){var d,u;if(!(Z!=null&&Z.matches))try{for(var s=q(le),p=s.next();!p.done;p=s.next()){var h=p.value;h.shape!=="pixel-confetti"&&h.shape!=="confetti"||h.clipId!==r||!!h.screen!=!!o||(y.save(),h.shape==="confetti"?gl(y,h,o):pl(y,h,o),y.restore())}}catch(g){d={error:g}}finally{try{p&&!p.done&&(u=s.return)&&u.call(s)}finally{if(d)throw d.error}}}function _l(r,o,d,u){y.save(),y.translate(r,o),y.globalAlpha=.92,y.lineWidth=2,y.lineJoin="round",d==="tap"&&(y.strokeStyle="#fff0bd",y.globalAlpha=.7*(1-u),y.beginPath(),y.arc(0,0,12+u*12,0,Math.PI*2),y.stroke(),y.globalAlpha=.92),y.fillStyle="#fff0bd",y.strokeStyle="#193b46",y.beginPath(),y.moveTo(-7,10),y.lineTo(-9,-1),y.quadraticCurveTo(-9,-5,-5,-5),y.lineTo(-3,-3),y.lineTo(-3,-17),y.quadraticCurveTo(-3,-22,1,-22),y.quadraticCurveTo(5,-22,5,-17),y.lineTo(5,-6),y.quadraticCurveTo(9,-9,11,-5),y.quadraticCurveTo(15,-7,16,-2),y.lineTo(14,9),y.quadraticCurveTo(12,18,3,18),y.lineTo(-1,18),y.quadraticCurveTo(-5,17,-7,10),y.closePath(),y.fill(),y.stroke(),y.restore()}function ef(){var r,o,d,u,s,p,h,g,I,S,m,C,w,P,x,T,A,N,W;if(fi=0,!k)try{for(var D=q(e.gameplay.filter(function(or){return or.kind==="tutorial-hand"})),V=D.next();!V.done;V=D.next()){var H=V.value,G=O.get(H.componentId),F=Be(H.parameters.targetId);if(!(!G||G.sceneId!==Q||!F||F.sceneId!==Q||!Sr(F))&&!(H.parameters.hideOnFirstInput&&Oi)){var te=gn?se:ke;if(!(te-tn<H.parameters.idleDelaySeconds)){fi++;var de=H.parameters.destinationId?Be(H.parameters.destinationId):void 0,ne=Fe(F),pe=void 0;pe||(pe=vr(hr(F),ne.width/2,ne.height/2));var Ce=te%1.2/1.2,We=Z!=null&&Z.matches?0:Ce*Ce*(3-2*Ce),De=pe.x,me=pe.y;if(H.parameters.mode!=="tap"){var xe=de?vr(hr(de),Fe(de).width/2,Fe(de).height/2):{x:pe.x-36,y:pe.y+48};De=pe.x+(xe.x-pe.x)*We,me=pe.y+(xe.y-pe.y)*We}_l(De+8,me+22,H.parameters.mode,We)}}}}catch(or){r={error:or}}finally{try{V&&!V.done&&(o=D.return)&&o.call(D)}finally{if(r)throw r.error}}try{for(var we=q(nn),Te=we.next();!Te.done;Te=we.next()){var Oe=$(Te.value,2),ce=Oe[0],yr=Oe[1],Ae=Mt("draw-stroke",ce).parameters;try{for(var fr=(s=void 0,q(yr.strokes)),Me=fr.next();!Me.done;Me=fr.next()){var nr=Me.value;if(!(nr.points.length<2)){y.save(),y.globalAlpha=Ae.mode==="slice-blade"?Math.max(0,1-nr.age/.18):1,y.strokeStyle=Ae.color,y.lineWidth=Ae.strokeWidth,y.lineCap="round",y.lineJoin="round",y.beginPath(),y.moveTo(nr.points[0].x,nr.points[0].y);try{for(var Ge=(h=void 0,q(nr.points.slice(1))),Je=Ge.next();!Je.done;Je=Ge.next()){var kr=Je.value;y.lineTo(kr.x,kr.y)}}catch(or){h={error:or}}finally{try{Je&&!Je.done&&(g=Ge.return)&&g.call(Ge)}finally{if(h)throw h.error}}y.stroke(),y.restore()}}}catch(or){s={error:or}}finally{try{Me&&!Me.done&&(p=fr.return)&&p.call(fr)}finally{if(s)throw s.error}}}}catch(or){d={error:or}}finally{try{Te&&!Te.done&&(u=we.return)&&u.call(we)}finally{if(d)throw d.error}}try{for(var ir=q(wn),_e=ir.next();!_e.done;_e=ir.next()){var Ur=_e.value;if(!(Ur.broken||!Ur.drawRope)){var Vt=Ot.get(Ur.bodyId),Nt=Be(Ur.anchorId);if(!(!Vt||!Nt)){var Ct=Or(Nt);y.save(),y.strokeStyle=Ur.ropeColor,y.lineWidth=Ur.ropeWidth,y.beginPath(),y.moveTo(Ct.x,Ct.y),y.lineTo(Vt.x,Vt.y),y.stroke(),y.restore()}}}}catch(or){I={error:or}}finally{try{_e&&!_e.done&&(S=ir.return)&&S.call(ir)}finally{if(I)throw I.error}}try{for(var Jr=q(e.gameplay.filter(function(or){var st;return or.kind==="virtual-joystick"&&((st=O.get(or.componentId))===null||st===void 0?void 0:st.sceneId)===Q})),Cr=Jr.next();!Cr.done;Cr=Jr.next()){var H=Cr.value,qr=Be(H.componentId),ne=H.parameters;if(!(!qr||!Sr(qr)||ne.drawControl===!1)){var jr=an.get(H.id),Yr=jr&&jr.pointerId!==null?jr.origin:Or(qr),Kr=jr&&jr.pointerId!==null?jr.knobX:Yr.x,pr=jr&&jr.pointerId!==null?jr.knobY:Yr.y,tr=(A=ne.radiusPx)!==null&&A!==void 0?A:56;y.save(),y.fillStyle=(N=ne.baseColor)!==null&&N!==void 0?N:"#ffffff44",y.strokeStyle="#ffffffaa",y.lineWidth=2.5,y.beginPath(),y.arc(Yr.x,Yr.y,tr,0,Math.PI*2),y.fill(),y.stroke(),y.fillStyle=(W=ne.knobColor)!==null&&W!==void 0?W:"#fff0bdee",y.strokeStyle="#193b46aa",y.lineWidth=2,y.beginPath(),y.arc(Kr,pr,tr*.42,0,Math.PI*2),y.fill(),y.stroke(),y.restore()}}}catch(or){m={error:or}}finally{try{Cr&&!Cr.done&&(C=Jr.return)&&C.call(Jr)}finally{if(m)throw m.error}}try{for(var _r=q(lt),at=_r.next();!at.done;at=_r.next()){var He=at.value,ar=Math.min(1,He.elapsed/He.seconds);y.save(),y.globalAlpha=1-ar,y.fillStyle=He.color,y.strokeStyle="#193b46",y.lineWidth=3,y.font="900 "+He.fontSize+"px sans-serif",y.textAlign="center",y.textBaseline="middle";var me=He.y-(Z!=null&&Z.matches?0:He.risePx*ar);y.strokeText(He.text,He.x,me),y.fillText(He.text,He.x,me),y.restore()}}catch(or){w={error:or}}finally{try{at&&!at.done&&(P=_r.return)&&P.call(_r)}finally{if(w)throw w.error}}try{for(var Se=q(yt),Vr=Se.next();!Vr.done;Vr=Se.next()){var vt=Vr.value,ar=Math.min(1,vt.elapsed/vt.seconds),pt=R();y.save(),y.globalAlpha=vt.opacity*(1-ar),y.fillStyle=vt.color,y.fillRect(0,0,pt.width,pt.height),y.restore()}}catch(or){x={error:or}}finally{try{Vr&&!Vr.done&&(T=Se.return)&&T.call(Se)}finally{if(x)throw x.error}}}function rf(){if(Xe){var r=Ot.get(Xe.targetId),o=Xe.behavior.parameters;if(r){var d=Xe.current.x-Xe.start.x,u=Xe.current.y-Xe.start.y,s=Math.hypot(d,u),p=Math.min(o.maxPullPx,s),h=s>.001?p/s:0;y.save(),y.lineCap="round";var g=Math.max(12,Math.min(r.width,r.height)*.62);if(y.strokeStyle="#173a2f66",y.lineWidth=3.5,y.beginPath(),y.arc(r.x,r.y,g,0,Math.PI*2),y.stroke(),y.strokeStyle=o.trajectoryColor,y.lineWidth=2,y.beginPath(),y.arc(r.x,r.y,g,0,Math.PI*2),y.stroke(),o.showTrajectory&&s>=o.minPullPx){var I=Va(),S=mo(),m=S.bodies,C=S.zones,w=R(),P=ul({body:ge(ge({},r),{vx:I.vx,vy:I.vy,atRest:!1}),bodies:m,zones:C,bounds:{left:0,top:0,right:w.width,bottom:w.height},dots:o.trajectoryDots,bounces:o.trajectoryBounces});P.forEach(function(A,N){var W=.96-.52*(N/Math.max(1,P.length)),D=Math.max(2.2,4.5-N*.22);y.globalAlpha=W,y.fillStyle="#173a2f88",y.beginPath(),y.arc(A.x,A.y,D+1.3,0,Math.PI*2),y.fill(),y.fillStyle=o.trajectoryColor,y.beginPath(),y.arc(A.x,A.y,D,0,Math.PI*2),y.fill()})}if(s>=4){var x=r.x+d*h,T=r.y+u*h;y.globalAlpha=.9,y.strokeStyle="#173a2f66",y.lineWidth=5,y.beginPath(),y.moveTo(r.x,r.y),y.lineTo(x,T),y.stroke(),y.strokeStyle=o.trajectoryColor,y.lineWidth=2.6,y.beginPath(),y.moveTo(r.x,r.y),y.lineTo(x,T),y.stroke(),y.fillStyle="#173a2f88",y.beginPath(),y.arc(x,T,5.2,0,Math.PI*2),y.fill(),y.fillStyle=o.trajectoryColor,y.beginPath(),y.arc(x,T,3.6,0,Math.PI*2),y.fill()}y.restore()}}}function tf(r){var o,d,u,s;try{for(var p=q(co()),h=p.next();!h.done;h=p.next()){var g=h.value,I=g.contract==="native.group.v1"?Xi(g.id):[g];try{for(var S=(u=void 0,q(I)),m=S.next();!m.done;m=S.next()){var C=m.value;if(C.contract==="native.stage3d.v1"&&Sr(C)&&Fe(C).skyColor)return Fe(C).skyColor;if(!(C.contract!=="native.rectangle.v1"||!Sr(C))){var w=Fe(C);if(!(w.opacity<.95||!w.fill||w.fill==="transparent")&&(/(?:^|\.)(background|backdrop|bg)(?:\.fill)?$/.test(C.id)||w.width>=r.width*.9&&w.height>=r.height*.9))return w.fill}}}catch(P){u={error:P}}finally{try{m&&!m.done&&(s=S.return)&&s.call(S)}finally{if(u)throw u.error}}}}catch(P){o={error:P}}finally{try{h&&!h.done&&(d=p.return)&&d.call(p)}finally{if(o)throw o.error}}return"#102a34"}function nf(){var r;if(bn&&Sr(bn.c)){var o=bn.c,d=Fe(o);y.save(),y.transform.apply(y,ie([],$(hr(o)),!1)),y.strokeStyle=(r=bn.highlightColor)!==null&&r!==void 0?r:"#ffffff",y.lineWidth=4,y.globalAlpha=.85,y.strokeRect(-4,-4,d.width+8,d.height+8),y.restore()}if(Ze!=null&&Ze.b.parameters.bringToFront){var o=Be(Ze.targetId);o&&mi(o,o.parentId?hr(Be(o.parentId)):jt(),[],o.prototypeId)}}function it(){var r,o,d,u,s,p;he=ae,ae=new Map;var h=R();ue!==void 0&&ue!==h.landscape&&Kt(),ue=h.landscape;var g=Math.min(devicePixelRatio||1,2),I=t.clientWidth,S=t.clientHeight;(t.width!==Math.round(I*g)||t.height!==Math.round(S*g))&&(t.width=Math.round(I*g),t.height=Math.round(S*g)),y.setTransform(g,0,0,g,0,0),y.fillStyle=tf(h),y.fillRect(0,0,I,S);var m=Math.min(I/h.width,S/h.height),C=(I-h.width*m)/2,w=(S-h.height*m)/2;if(Rl=m||1,Ol=g,y.translate(C,w),y.scale(m,m),Ar){var P=Math.min(1,Ar.elapsed/Ar.seconds),x=Ar.intensity*(1-P);y.translate(Math.sin(Ar.elapsed*95)*x,Math.cos(Ar.elapsed*113)*x)}ei=h,pi=!1,ei=Fi(h),rn=[];try{for(var T=q(co()),A=T.next();!A.done;A=T.next()){var N=A.value;mi(N)}}catch(me){r={error:me}}finally{try{A&&!A.done&&(o=T.return)&&o.call(T)}finally{if(r)throw r.error}}Aa(!0);try{for(var W=q(ye),D=W.next();!D.done;D=W.next()){var N=D.value;N.parentId||mi(N,jt(),[],N.prototypeId)}}catch(me){d={error:me}}finally{try{D&&!D.done&&(u=W.return)&&u.call(W)}finally{if(d)throw d.error}}if(nf(),rf(),k&&Dt){for(var V=O.get(Dt);V!=null&&V.parentId;)V=O.get(V.parentId);V!=null&&V.prototype&&mi(V)}Ra(),y.save();try{for(var H=q(le),G=H.next();!G.done;G=H.next()){var F=G.value;if(F.age===void 0){var te=Math.min(1,F.life*2),de=1.5+2.5*te;if(y.globalAlpha=te,y.globalCompositeOperation=F.shape==="square"?"source-over":"lighter",y.fillStyle=F.color,F.shape==="square"){var ne=Math.max(2,Math.round(de*1.6));y.fillRect(Math.round(F.x-ne/2),Math.round(F.y-ne/2),ne,ne);continue}y.globalCompositeOperation="lighter",y.shadowColor=F.color,y.shadowBlur=le.length<=16?6:0,y.strokeStyle=F.color,y.lineWidth=1.5+te,y.beginPath(),y.moveTo(F.x-F.vx*.025,F.y-F.vy*.025),y.lineTo(F.x,F.y),y.stroke(),y.beginPath(),y.arc(F.x,F.y,de,0,Math.PI*2),y.fill()}}}catch(me){s={error:me}}finally{try{G&&!G.done&&(p=H.return)&&p.call(H)}finally{if(s)throw s.error}}if(y.restore(),ef(),k&&Dt){var pe=rn.filter(function(me){return me.c.contract!=="native.group.v1"&&(me.c.id===Dt||kt(me.c,Dt))});if(pe.length){var Ce=pe.map(function(me){return ut(me.c,me.m)}),We=Math.min.apply(Math,ie([],$(Ce.map(function(me){return me.left})),!1)),De=Math.min.apply(Math,ie([],$(Ce.map(function(me){return me.top})),!1));y.strokeStyle="#55e6ef",y.lineWidth=2/m,y.strokeRect(We,De,Math.max.apply(Math,ie([],$(Ce.map(function(me){return me.right})),!1))-We,Math.max.apply(Math,ie([],$(Ce.map(function(me){return me.bottom})),!1))-De)}}Aa(!1),m>0&&Ra(void 0,{x:-C/m,y:-w/m,width:I/m,height:S/m})}function af(r){var o,d,u,s,p=Array.isArray(r)?ie([],$(new Set(r)),!1):void 0;it();var h=R(),g=Fi(h),I=new Set,S=[];try{for(var m=q(rn),C=m.next();!C.done;C=m.next()){var w=C.value,P=(u=w.c.prototypeId)!==null&&u!==void 0?u:w.c.id;if(!(w.c.contract==="native.group.v1"||p&&!p.includes(P))){I.add(P);var x=ut(w.c,w.m),T=((s=Fe(w.c).strokeWidth)!==null&&s!==void 0?s:0)/2;x.left-=T,x.right+=T,x.top-=T,x.bottom+=T;var A={left:Math.max(0,g.left-x.left),right:Math.max(0,x.right-g.right),top:Math.max(0,g.top-x.top),bottom:Math.max(0,x.bottom-g.bottom)};Object.values(A).some(function(W){return W>.01})&&S.push({id:P,contract:w.c.contract,bounds:x,overflow:A})}}}catch(W){o={error:W}}finally{try{C&&!C.done&&(d=m.return)&&d.call(m)}finally{if(o)throw o.error}}var N=p?p.filter(function(W){return!I.has(W)}):[];return{ok:S.length===0&&N.length===0,viewport:ge(ge({},h),{canvasWidth:t.clientWidth,canvasHeight:t.clientHeight}),issues:S,missing:N}}function of(r){var o,d,u,s,p,h,g,I,S,m,C,w,P,x,T,A,N,W,D,V,H,G,F,te,de,ne,pe,Ce,We,De,me,xe,we,Te=r===void 0?{}:r,Oe=Te.ids,ce=Te.interactiveIds,yr=Te.network,Ae=yr===void 0?"standalone":yr,fr=Te.minTouchPx,Me=fr===void 0?44:fr,nr=Array.isArray(Oe)?ie([],$(new Set(Oe)),!1):void 0;it();var Ge=R(),Je=Fi(Ge),kr=Math.min(t.clientWidth/Ge.width,t.clientHeight/Ge.height),ir=lo(Je,Ae),_e=[],Ur=new Set,Vt=function(z){var Ee;return!nr||nr.includes((Ee=z.c.prototypeId)!==null&&Ee!==void 0?Ee:z.c.id)},Nt=rn.filter(Vt),Ct=new Set(e.events.filter(function(z){return z.kind==="click"}).map(function(z){return z.componentId}));try{for(var Jr=q(e.gameplay),Cr=Jr.next();!Cr.done;Cr=Jr.next()){var qr=Cr.value;["drag","match-tile","aim-launch","aim-launch-3d","swipe-input","hold-charge","virtual-joystick","draw-stroke","erase-mask"].includes(qr.kind)&&Ct.add(qr.componentId)}}catch(z){o={error:z}}finally{try{Cr&&!Cr.done&&(d=Jr.return)&&d.call(Jr)}finally{if(o)throw o.error}}var jr=new Set(ce!=null?ce:Ct),Yr=new Set(ie(ie([],$(e.gameplay.filter(function(z){return["aim-launch","aim-launch-3d","swipe-input","hold-charge","draw-stroke","virtual-joystick"].includes(z.kind)&&(z.parameters.dragMode==="anywhere"||z.kind==="draw-stroke"||z.kind==="virtual-joystick"&&z.parameters.mode==="floating")}).map(function(z){return z.componentId})),!1),$(e.components.filter(function(z){return z.contract==="native.stage3d.v1"}).map(function(z){return z.id})),!1)),Kr=function(z){var Ee;return jr.has((Ee=z.c.prototypeId)!==null&&Ee!==void 0?Ee:z.c.id)},pr=function(z,Ee,ze,er,Hr,wr){return _e.push(ge(ge({kind:z,severity:Ee,id:ze},wr?{otherId:wr}:{}),{detail:er,metrics:Hr}))},tr=function(z){var Ee=[[0,0],[z.width,0],[z.width,z.height],[0,z.height]].map(function(ze){var er=$(ze,2),Hr=er[0],wr=er[1];return vr(z.matrix,Hr,wr)});return{left:Math.min.apply(Math,ie([],$(Ee.map(function(ze){return ze.x})),!1)),right:Math.max.apply(Math,ie([],$(Ee.map(function(ze){return ze.x})),!1)),top:Math.min.apply(Math,ie([],$(Ee.map(function(ze){return ze.y})),!1)),bottom:Math.max.apply(Math,ie([],$(Ee.map(function(ze){return ze.y})),!1))}};try{for(var _r=q(Nt),at=_r.next();!at.done;at=_r.next()){var He=at.value,ar=(F=He.c.prototypeId)!==null&&F!==void 0?F:He.c.id;Ur.add(ar);var Se=ut(He.c,He.m),Vr=((te=Fe(He.c).strokeWidth)!==null&&te!==void 0?te:0)/2;Se.left-=Vr,Se.right+=Vr,Se.top-=Vr,Se.bottom+=Vr;var vt=He.c.contract==="native.group.v1"&&!Fe(He.c).clip,pt=He.c.contract==="native.image.v1"&&He.clips.length===0&&Fe(He.c).fit==="cover"&&Se.left<=0&&Se.top<=0&&Se.right>=Ge.width&&Se.bottom>=Ge.height||He.c.contract==="native.stage3d.v1"&&Se.left<=0&&Se.top<=0&&Se.right>=Ge.width&&Se.bottom>=Ge.height,or=He.c.contract==="native.rectangle.v1"&&Vr===0&&Se.left<=0&&Se.top<=0&&Se.right>=Ge.width&&Se.bottom>=Ge.height||pt;if(!vt){var st={left:Math.max(0,Je.left-Se.left),right:Math.max(0,Se.right-Je.right),top:Math.max(0,Je.top-Se.top),bottom:Math.max(0,Se.bottom-Je.bottom)};if(!or&&!So(He.c)&&Object.values(st).some(function(z){return z>.01})&&pr("stage-overflow","blocker",ar,"Component extends beyond the active stage.",{bounds:Se,overflow:st}),He.c.contract==="native.image.v1"&&He.clips.length===0){var Et=Se.right-Se.left,Sn=Se.bottom-Se.top,ln=/(?:^|\.)(backdrop|background|bg)$/.test(ar)||Fe(He.c).fit==="cover"&&!He.c.parentId&&Se.left<=1&&Se.top<=1&&(Et>=Ge.width*.4||Sn>=Ge.height*.4);ln&&(Se.left>.5||Se.top>.5||Se.right<Ge.width-.5||Se.bottom<Ge.height-.5)&&pr("backdrop-incomplete","blocker",ar,"Backdrop image does not cover the full active stage, leaving a visible seam.",{bounds:Se,stage:{width:Ge.width,height:Ge.height}})}try{for(var Pt=(p=void 0,q(He.clips)),ct=Pt.next();!ct.done;ct=Pt.next()){var Lr=ct.value,Gr=tr(Lr),fn={left:Math.max(0,Gr.left-Se.left),right:Math.max(0,Se.right-Gr.right),top:Math.max(0,Gr.top-Se.top),bottom:Math.max(0,Se.bottom-Gr.bottom)};Object.values(fn).some(function(z){return z>.01})&&pr("parent-clip-crop","blocker",ar,"Component is cropped by an ancestor clipping group.",{bounds:Se,clip:Gr,crop:fn})}}catch(z){p={error:z}}finally{try{ct&&!ct.done&&(h=Pt.return)&&h.call(Pt)}finally{if(p)throw p.error}}}if(He.textMetrics){var ht=He.textMetrics;(ht.overflowsWidth||ht.overflowsHeight)&&pr("text-overflow","blocker",ar,"Text does not fit its component after wrapping and auto-fit.",ht);var et=(de=ht.fontSize)!==null&&de!==void 0?de:ht.scale*8;et<12&&pr("text-illegible",et<8?"blocker":"warning",ar,"Rendered text is below the recommended legible size.",ge({renderedFontSize:et},ht));var Tt=Fe(He.c);if(Tt.pixelPanel&&Tt.align!=="center"){var dn=Math.max(0,Tt.width-2*(Tt.padding===void 0?8:Tt.padding));dn-((ne=ht.renderedWidth)!==null&&ne!==void 0?ne:0)>12&&pr("panel-off-center","blocker",ar,"Text inside a framed pixel panel is not horizontally centered.",{align:Tt.align,innerWidth:dn,renderedWidth:(pe=ht.renderedWidth)!==null&&pe!==void 0?pe:0})}}if(Kr(He)&&!Yr.has(ar)&&(He.c.contract!=="native.group.v1"||Se.right>Se.left&&Se.bottom>Se.top)){var Ir=(Se.right-Se.left)*kr,Ye=(Se.bottom-Se.top)*kr;(Ir<Me-.01||Ye<Me-.01)&&pr("touch-target-small","blocker",ar,"Interactive target is smaller than the required physical touch size.",{width:Ir,height:Ye,minTouchPx:Me,scale:kr})}if(Kr(He)&&!Yr.has(ar)||He.c.contract==="native.text.v1")try{for(var ot=(g=void 0,q(ir.zones)),dr=ot.next();!dr.done;dr=ot.next()){var Qr=dr.value,Ir=Math.min(Se.right,Qr.right)-Math.max(Se.left,Qr.left),Ye=Math.min(Se.bottom,Qr.bottom)-Math.max(Se.top,Qr.top);Ir>.01&&Ye>.01&&pr("sdk-safe-area-collision","blocker",ar,"Component intersects a reserved ad-SDK overlay zone.",{bounds:Se,zone:Qr,intersection:{width:Ir,height:Ye},network:Ae})}}catch(z){g={error:z}}finally{try{dr&&!dr.done&&(I=ot.return)&&I.call(ot)}finally{if(g)throw g.error}}}}catch(z){u={error:z}}finally{try{at&&!at.done&&(s=_r.return)&&s.call(_r)}finally{if(u)throw u.error}}for(var xr=Nt.filter(function(z){return Kr(z)&&z.c.contract!=="native.group.v1"&&z.c.contract!=="native.stage3d.v1"}),br=0;br<xr.length;br++)for(var Nr=br+1;Nr<xr.length;Nr++){var je=xr[br],qe=xr[Nr],mt=(Ce=je.c.prototypeId)!==null&&Ce!==void 0?Ce:je.c.id,Xt=(We=qe.c.prototypeId)!==null&&We!==void 0?We:qe.c.id;if(!(mt===Xt||kt(je.c,qe.c.id)||kt(qe.c,je.c.id))){var Ut=ut(je.c,je.m),kn=ut(qe.c,qe.m),Ir=Math.min(Ut.right,kn.right)-Math.max(Ut.left,kn.left),Ye=Math.min(Ut.bottom,kn.bottom)-Math.max(Ut.top,kn.top);Ir>1&&Ye>1&&pr("interactive-overlap","blocker",mt,"Interactive targets overlap.",{intersection:{width:Ir,height:Ye},first:Ut,second:kn},Xt)}}var ri=function(z){if(!z||z==="transparent")return!1;var Ee=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(z);if(Ee)return Ee[1].length===4?Ee[1][3].toLowerCase()==="f":Ee[1].slice(6).toLowerCase()==="ff";var ze=/^rgba\([^,]+,[^,]+,[^,]+,\s*([0-9.]+)\s*\)$/i.exec(z);return ze?Number(ze[1])>=.95:!0},Wn=[];Nt.forEach(function(z,Ee){var ze,er;z.c.contract==="native.rectangle.v1"&&!Kr(z)&&((ze=Fe(z.c).opacity)!==null&&ze!==void 0?ze:1)>=.95&&ri(Fe(z.c).fill)&&Wn.push({rowIndex:Ee,row:z,order:(er=z.c.order)!==null&&er!==void 0?er:0,bounds:ut(z.c,z.m)})});var ti=Nt.filter(function(z,Ee){var ze,er=ut(z.c,z.m),Hr=(ze=z.c.order)!==null&&ze!==void 0?ze:0;return!Wn.some(function(wr){return wr.rowIndex>Ee&&wr.order>Hr&&wr.row.c.id!==z.c.id&&!kt(wr.row.c,z.c.id)&&!kt(z.c,wr.row.c.id)&&wr.bounds.left<=er.left+1&&wr.bounds.right>=er.right-1&&wr.bounds.top<=er.top+1&&wr.bounds.bottom>=er.bottom-1})}),ni=ti.map(function(z,Ee){return{row:z,rowIndex:Ee}}).filter(function(z){var Ee,ze=z.row;if(ze.c.contract!=="native.rectangle.v1")return!1;var er=ut(ze.c,ze.m),Hr=er.right-er.left,wr=er.bottom-er.top,vn=((Ee=Fe(ze.c).strokeWidth)!==null&&Ee!==void 0?Ee:0)===0&&er.left<=0&&er.right>=Ge.width;return!vn&&Hr>=180&&wr>=140&&!Kr(ze)}).map(function(z){var Ee,ze=z.row,er=z.rowIndex;return{id:(Ee=ze.c.prototypeId)!==null&&Ee!==void 0?Ee:ze.c.id,row:ze,rowIndex:er,bounds:ut(ze.c,ze.m)}}),Ln=function(z,Ee,ze,er){var Hr,wr;er===void 0&&(er=!1);var vn=(Hr=z.c.prototypeId)!==null&&Hr!==void 0?Hr:z.c.id,Si=(ze.left+ze.right)/2,sn=(ze.top+ze.bottom)/2,Ha=(wr=z.c.order)!==null&&wr!==void 0?wr:0;return ni.filter(function(cr){var cn;return cr.id!==vn&&(!er||cr.rowIndex<Ee||((cn=cr.row.c.order)!==null&&cn!==void 0?cn:0)===Ha)&&ze.right-ze.left<=cr.bounds.right-cr.bounds.left+4&&ze.bottom-ze.top<=cr.bounds.bottom-cr.bounds.top+4&&Si>=cr.bounds.left&&Si<=cr.bounds.right&&sn>=cr.bounds.top&&sn<=cr.bounds.bottom}).sort(function(cr,cn){return(cr.bounds.right-cr.bounds.left)*(cr.bounds.bottom-cr.bounds.top)-(cn.bounds.right-cn.bounds.left)*(cn.bounds.bottom-cn.bounds.top)||cn.rowIndex-cr.rowIndex})[0]},Bt=new Map,Ve=new Map;if(ni.length){ti.forEach(function(z,Ee){var ze,er=(ze=z.c.prototypeId)!==null&&ze!==void 0?ze:z.c.id,Hr=ut(z.c,z.m),wr=(Hr.left+Hr.right)/2,vn=(Hr.top+Hr.bottom)/2,Si=z.c.contract==="native.button.v1"&&!Ht.has(z.c.id),sn=z.c.parentId?Be(z.c.parentId):void 0,Ha=z.c.contract==="native.text.v1"&&Fe(z.c).align==="center"&&(sn==null?void 0:sn.contract)!=="native.button.v1";if(Si||Ha){var cr=Ln(z,Ee,Hr,!1);cr&&(Bt.has(cr.id)||Bt.set(cr.id,{panel:cr,items:[]}),Bt.get(cr.id).items.push({id:er,bounds:Hr,cx:wr,cy:vn,isBtn:Si}))}if(["native.text.v1","native.image.v1","native.button.v1"].includes(z.c.contract)&&(sn==null?void 0:sn.contract)!=="native.button.v1"){var cr=Ln(z,Ee,Hr,!0);cr&&(Ve.has(cr.id)||Ve.set(cr.id,{panel:cr,content:[]}),Ve.get(cr.id).content.push({row:z,id:er,bounds:Hr}))}});try{for(var ur=q(Bt.values()),Dr=ur.next();!Dr.done;Dr=ur.next()){var Zr=Dr.value,Er=Zr.panel,rt=Zr.items;if(rt.some(function(z){return z.isBtn})){var sr=Er.bounds,Br=(sr.left+sr.right)/2;try{for(var Cn=(C=void 0,q(rt)),gt=Cn.next();!gt.done;gt=Cn.next()){var zt=gt.value,un={left:zt.bounds.left-sr.left,right:sr.right-zt.bounds.right,top:zt.bounds.top-sr.top,bottom:sr.bottom-zt.bounds.bottom},Dn=Math.min(un.left,un.right,un.top,un.bottom);(Dn<10||Dn*kr<8)&&pr("panel-edge-cramped","blocker",zt.id,"Element sits too close to its enclosing panel edge.",{panelId:Er.id,margins:un,scale:kr,minStagePx:10,minCssPx:8},Er.id)}}catch(z){C={error:z}}finally{try{gt&&!gt.done&&(w=Cn.return)&&w.call(Cn)}finally{if(C)throw C.error}}var Hn=[],pf=function(z){var Ee=Hn.find(function(ze){return Math.abs(ze.cy-z.cy)<=16&&ze.isBtn===z.isBtn});Ee?Ee.items.push(z):Hn.push({cy:z.cy,isBtn:z.isBtn,items:[z]})};try{for(var Qi=(P=void 0,q(rt)),gi=Qi.next();!gi.done;gi=Qi.next()){var zt=gi.value;pf(zt)}}catch(z){P={error:z}}finally{try{gi&&!gi.done&&(x=Qi.return)&&x.call(Qi)}finally{if(P)throw P.error}}try{for(var Ji=(T=void 0,q(Hn)),Ii=Ji.next();!Ii.done;Ii=Ji.next()){var La=Ii.value,mf=Math.min.apply(Math,ie([],$(La.items.map(function(z){return z.bounds.left})),!1)),gf=Math.max.apply(Math,ie([],$(La.items.map(function(z){return z.bounds.right})),!1)),No=(mf+gf)/2,Bo=No-Br;Math.abs(Bo)>3&&pr("panel-off-center","blocker",La.items[0].id,"Element is not horizontally centered inside its enclosing panel.",{panelId:Er.id,offsetX:Bo,groupCenterX:No,panelCenterX:Br,scale:kr},Er.id)}}catch(z){T={error:z}}finally{try{Ii&&!Ii.done&&(A=Ji.return)&&A.call(Ji)}finally{if(T)throw T.error}}}}}catch(z){S={error:z}}finally{try{Dr&&!Dr.done&&(m=ur.return)&&m.call(ur)}finally{if(S)throw S.error}}try{for(var qi=q(Ve.values()),xi=qi.next();!xi.done;xi=qi.next())for(var zo=xi.value,Er=zo.panel,ji=zo.content,If=Bt.has(Er.id),br=0;br<ji.length;br++)for(var Nr=br+1;Nr<ji.length;Nr++){var je=ji[br],qe=ji[Nr];if(!(je.id===qe.id||kt(je.row.c,qe.row.c.id)||kt(qe.row.c,je.row.c.id))){var xf=je.row.c.contract==="native.image.v1"&&qe.row.c.contract==="native.image.v1";if(!(xf&&(!If||je.row.c.parentId&&je.row.c.parentId===qe.row.c.parentId))){var Ir=Math.min(je.bounds.right,qe.bounds.right)-Math.max(je.bounds.left,qe.bounds.left),Ye=Math.min(je.bounds.bottom,qe.bounds.bottom)-Math.max(je.bounds.top,qe.bounds.top);Ir>2&&Ye>2&&pr("panel-content-overlap","blocker",je.id,"Panel elements overlap each other.",{panelId:Er.id,intersection:{width:Ir,height:Ye},first:je.bounds,second:qe.bounds},qe.id)}}}}catch(z){N={error:z}}finally{try{xi&&!xi.done&&(W=qi.return)&&W.call(qi)}finally{if(N)throw N.error}}}var ii=ti.filter(function(z){if(z.c.contract!=="native.text.v1")return!1;var Ee=z.c.parentId?Be(z.c.parentId):void 0;return(Ee==null?void 0:Ee.contract)!=="native.button.v1"}).map(function(z){var Ee,ze,er=String((Ee=Fe(z.c).text)!==null&&Ee!==void 0?Ee:"").replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Hr,wr){var vn;return String((vn=j[wr])!==null&&vn!==void 0?vn:"")}).trim();return{row:z,id:(ze=z.c.prototypeId)!==null&&ze!==void 0?ze:z.c.id,bounds:ut(z.c,z.m),raw:er,norm:er.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}}).filter(function(z){return z.raw.length>0}),bf=ni.filter(function(z){var Ee,ze;return((Ee=Bt.get(z.id))===null||Ee===void 0?void 0:Ee.items.some(function(er){return er.isBtn}))||((ze=Ve.get(z.id))===null||ze===void 0?void 0:ze.content.some(function(er){return er.row.c.contract==="native.button.v1"}))});try{for(var _i=q(bf),bi=_i.next();!bi.done;bi=_i.next()){var Er=bi.value,sr=Er.bounds,Br=(sr.left+sr.right)/2,wf=sr.right-sr.left;try{for(var ea=(H=void 0,q(ii)),wi=ea.next();!wi.done;wi=ea.next()){var Jt=wi.value;if(Fe(Jt.row.c).align==="center"&&!(Jt.bounds.bottom>sr.top+6||sr.top-Jt.bounds.bottom>48)){var Wo=Jt.bounds.right-Jt.bounds.left,Mi=(Jt.bounds.left+Jt.bounds.right)/2,Mf=Math.min(Jt.bounds.right,sr.right)-Math.max(Jt.bounds.left,sr.left);(Mi>=sr.left&&Mi<=sr.right||Mf>=Wo*.6)&&Wo<=wf+60&&Math.abs(Mi-Br)>4&&pr("header-off-center","blocker",Jt.id,"Centered text above a panel is not horizontally aligned with the panel below it.",{panelId:Er.id,offsetX:Mi-Br,textCenterX:Mi,panelCenterX:Br,scale:kr},Er.id)}}}catch(er){H={error:er}}finally{try{wi&&!wi.done&&(G=ea.return)&&G.call(ea)}finally{if(H)throw H.error}}}}catch(z){D={error:z}}finally{try{bi&&!bi.done&&(V=_i.return)&&V.call(_i)}finally{if(D)throw D.error}}for(var br=0;br<ii.length;br++)for(var Nr=br+1;Nr<ii.length;Nr++){var je=ii[br],qe=ii[Nr];if(!(je.id===qe.id||kt(je.row.c,qe.row.c.id)||kt(qe.row.c,je.row.c.id))){var Ir=Math.min(je.bounds.right,qe.bounds.right)-Math.max(je.bounds.left,qe.bounds.left),Ye=Math.min(je.bounds.bottom,qe.bounds.bottom)-Math.max(je.bounds.top,qe.bounds.top);if(Ir>2&&Ye>2&&pr("panel-content-overlap","blocker",je.id,"Visible text elements overlap.",{intersection:{width:Ir,height:Ye},first:je.bounds,second:qe.bounds},qe.id),je.norm&&qe.norm){var Lo=$(je.norm.length<=qe.norm.length?[je.norm,qe.norm]:[qe.norm,je.norm],2),ra=Lo[0],Do=Lo[1];(ra===Do&&ra.length>=6||ra.length>=12&&Do.includes(ra))&&pr("duplicate-visible-copy","blocker",je.id,"Duplicate visible copy appears in multiple text elements simultaneously.",{first:je.raw,second:qe.raw},qe.id)}}}var qt=ii.filter(function(z){return!/^[\d\s/.,:%+\-x]+$/i.test(z.raw)}),ta=qt.reduce(function(z,Ee){return z+(Ee.norm?Ee.norm.split(" ").filter(Boolean).length:0)},0),Da=qt.reduce(function(z,Ee){return z+Ee.raw.replace(/\s+/g," ").length},0);ta>20||Da>130||qt.length>5?pr("text-clutter-heavy","blocker",(me=(De=qt[0])===null||De===void 0?void 0:De.id)!==null&&me!==void 0?me:null,"Too much visible copy on one screen; keep playable ads visual and concise.",{blocks:qt.length,wordCount:ta,charCount:Da,texts:qt.map(function(z){return z.raw})}):(ta>12||qt.length>4)&&pr("text-clutter-heavy","warning",(we=(xe=qt[0])===null||xe===void 0?void 0:xe.id)!==null&&we!==void 0?we:null,"Screen copy is getting dense; consider trimming narration so gameplay carries the experience.",{blocks:qt.length,wordCount:ta,charCount:Da,texts:qt.map(function(z){return z.raw})});var Ho=nr?nr.filter(function(z){if(Ur.has(z))return!1;var Ee=Be(z);return(Ee==null?void 0:Ee.contract)==="native.mesh3d.v1"?!1:!Ee||Sr(Ee)}):[];return{ok:!_e.some(function(z){return z.severity==="blocker"})&&Ho.length===0,viewport:ge(ge({},Ge),{canvasWidth:t.clientWidth,canvasHeight:t.clientHeight,scale:kr}),defects:_e,missing:Ho,interactive:xr.map(function(z){var Ee;return{id:(Ee=z.c.prototypeId)!==null&&Ee!==void 0?Ee:z.c.id,bounds:ut(z.c,z.m)}}),safeArea:ir}}function kt(r,o){for(;r.parentId;){if(r.parentId===o)return!0;r=Be(r.parentId)}return!1}function So(r){for(var o=function(s){if(e.gameplay.some(function(p){var h;return p.kind==="camera-follow"&&p.componentId===((h=s.prototypeId)!==null&&h!==void 0?h:s.id)}))return{value:!0}},d=r;d;d=d.parentId?Be(d.parentId):void 0){var u=o(d);if(typeof u=="object")return u.value}return!1}function Oa(r){var o=R(),d=t.getBoundingClientRect(),u=Math.min(d.width/o.width,d.height/o.height);return{x:(r.clientX-d.left-(d.width-o.width*u)/2)/u,y:(r.clientY-d.top-(d.height-o.height*u)/2)/u}}function lf(r,o){var d,u,s,p;try{try{for(var h=q(r.clips),g=h.next();!g.done;g=h.next()){var I=g.value,S=vr(Yt(I.matrix),o.x,o.y);if(S.x<0||S.y<0||S.x>I.width||S.y>I.height)return!1}}catch(V){d={error:V}}finally{try{g&&!g.done&&(u=h.return)&&u.call(h)}finally{if(d)throw d.error}}var m=vr(Yt(r.m),o.x,o.y),C=Fe(r.c);if(r.c.contract==="native.path.v1"){var w=new Path2D,P=function(V,H){({M:function(){return w.moveTo.apply(w,ie([],$(H),!1))},L:function(){return w.lineTo.apply(w,ie([],$(H),!1))},C:function(){return w.bezierCurveTo.apply(w,ie([],$(H),!1))},Q:function(){return w.quadraticCurveTo.apply(w,ie([],$(H),!1))},Z:function(){return w.closePath()}})[V]()};try{for(var x=q(C.commands),T=x.next();!T.done;T=x.next()){var A=$(T.value),N=A[0],W=A.slice(1);P(N,W)}}catch(V){s={error:V}}finally{try{T&&!T.done&&(p=x.return)&&p.call(x)}finally{if(s)throw s.error}}y.save(),y.setTransform(1,0,0,1,0,0),y.lineWidth=C.strokeWidth;var D=y.isPointInPath(w,m.x,m.y)||C.strokeWidth>0&&y.isPointInStroke(w,m.x,m.y);return y.restore(),D}return r.c.contract==="native.ellipse.v1"?Math.pow((m.x-C.width/2)/(C.width/2),2)+Math.pow((m.y-C.height/2)/(C.height/2),2)<=1:m.x>=0&&m.y>=0&&m.x<=C.width&&m.y<=C.height}catch{return!1}}function Zi(r){return ie([],$(rn),!1).reverse().find(function(o){return o.c.contract!=="native.group.v1"&&o.c.sceneId===Q&&Be(o.c.id)&&Sr(o.c)&&lf(o,r)})}function $i(r){for(var o=[];r;)o.push(r),r=Be(r.parentId);return o}function Va(){if(!Xe)return{vx:0,vy:0,power:0,pull:0};var r=Xe.behavior.parameters,o=Xe.current.x-Xe.start.x,d=Xe.current.y-Xe.start.y,u=Math.hypot(o,d),s=Math.max(0,Math.min(1,(u-r.minPullPx)/Math.max(1,r.maxPullPx-r.minPullPx))),p=r.minSpeed+(r.maxSpeed-r.minSpeed)*s,h=r.invert?-1:1;return{vx:u?o/u*p*h:0,vy:u?d/u*p*h:0,power:s,pull:u}}function ko(r){if(Xe){Xe.current=r;var o=Va();Xe.power=o.power,Xe.behavior.parameters.powerVariableId&&(j[Xe.behavior.parameters.powerVariableId]=o.power)}}function Co(r){var o,d;r===void 0&&(r=!1);try{var u=(o=globalThis.AudioContext)!==null&&o!==void 0?o:globalThis.webkitAudioContext;u&&!Ke&&(Ke=new u,(d=Ke.addEventListener)===null||d===void 0||d.call(Ke,"statechange",function(){(Ke==null?void 0:Ke.state)==="running"&&Sa()})),yi(r)}catch{}}function ff(r,o,d){var u,s,p,h,g,I,S=function(H){var G=d.find(function(de){var ne;return((ne=de.prototypeId)!==null&&ne!==void 0?ne:de.id)===H.componentId});if(!G)return"continue";var F=vr(Yt(hr(G)),o.x,o.y),te=hi(G,H);return te.stampSegment(F,F),$r={kind:"mask",pointerId:r.pointerId,c:G,behavior:H,last:F},(g=t.setPointerCapture)===null||g===void 0||g.call(t,r.pointerId),{value:!0}};try{for(var m=q(e.gameplay.filter(function(H){var G;return H.kind==="erase-mask"&&((G=O.get(H.componentId))===null||G===void 0?void 0:G.sceneId)===Q})),C=m.next();!C.done;C=m.next()){var w=C.value,P=S(w);if(typeof P=="object")return P.value}}catch(H){u={error:H}}finally{try{C&&!C.done&&(s=m.return)&&s.call(m)}finally{if(u)throw u.error}}if(d.some(function(H){return H.contract==="native.button.v1"||e.events.some(function(G){var F;return G.kind==="click"&&G.componentId===((F=H.prototypeId)!==null&&F!==void 0?F:H.id)})}))return!1;try{for(var x=q(e.gameplay.filter(function(H){var G;return H.kind==="draw-stroke"&&((G=O.get(H.componentId))===null||G===void 0?void 0:G.sceneId)===Q})),T=x.next();!T.done;T=x.next()){var w=T.value,A=O.get(w.componentId),N=Yt(hr(A)),W=vr(N,o.x,o.y),D=Fe(A);if(!(W.x<0||W.y<0||W.x>D.width||W.y>D.height)){var V=Wl(w);return V.begin(o),$r={kind:"stroke",pointerId:r.pointerId,c:A,behavior:w,store:V,last:o},rr({kind:"strokeStart",componentId:A.id}),(I=t.setPointerCapture)===null||I===void 0||I.call(t,r.pointerId),!0}}}catch(H){p={error:H}}finally{try{T&&!T.done&&(h=x.return)&&h.call(x)}finally{if(p)throw p.error}}return!1}function df(r,o,d){var u,s,p,h,g,I,S,m=d.store.active;if(m){try{for(var C=q(e.gameplay.filter(function(te){var de;return te.kind==="collider"&&((de=O.get(te.componentId))===null||de===void 0?void 0:de.sceneId)===Q})),w=C.next();!w.done;w=C.next()){var P=w.value,x=O.get(P.componentId);try{for(var T=(p=void 0,q(Xr(x))),A=T.next();!A.done;A=T.next()){var N=A.value;!Sr(N)||m.hitIds.has(N.id)||rl(r,o,Mo(N,P.parameters.shape))&&(m.hitIds.add(N.id),rr(dt("sliceHit",N)))}}catch(te){p={error:te}}finally{try{A&&!A.done&&(h=T.return)&&h.call(T)}finally{if(p)throw p.error}}}}catch(te){u={error:te}}finally{try{w&&!w.done&&(s=C.return)&&s.call(C)}finally{if(u)throw u.error}}try{for(var W=q(wn),D=W.next();!D.done;D=W.next()){var V=D.value;if(!(V.broken||!V.breakable||m.hitIds.has(V.key))){var H=Ot.get(V.bodyId),G=Be(V.anchorId);if(!(!H||!G)){var F=Or(G);Qa(r,o,{x:F.x,y:F.y},{x:H.x,y:H.y})&&(m.hitIds.add(V.key),V.broken=!0,Li.add(V.key),rr({kind:"jointBreak",behaviorId:V.id,componentId:V.componentId,selfInstanceId:V.bodyId,instanceId:(S=Be(V.bodyId))===null||S===void 0?void 0:S.instanceId}))}}}}catch(te){g={error:te}}finally{try{D&&!D.done&&(I=W.return)&&I.call(W)}finally{if(g)throw g.error}}}}function uf(r,o){var d,u=o.last,s=o.behavior.parameters;if(s.inkVariableId){var p=s.inkVariableId,h=Math.hypot(r.x-u.x,r.y-u.y);if(((d=j[p])!==null&&d!==void 0?d:0)<h)return;j[p]-=h}o.store.add(r)&&(s.mode==="slice-blade"&&df(u,r,o),o.last=r)}function vf(r){var o,d;if(!(!$r||$r.pointerId!==r.pointerId)){var u=$r;$r=void 0;try{!((o=t.hasPointerCapture)===null||o===void 0)&&o.call(t,r.pointerId)&&((d=t.releasePointerCapture)===null||d===void 0||d.call(t,r.pointerId))}catch{}if(u.kind==="stroke"){var s=u.store.end(),p=u.behavior.parameters;if(s){if(p.mode==="physics-wall"){var h=new Set(u.store.strokes.map(function(I){return I.id}));$t=$t.filter(function(I){return I.owner!==u.c.id||h.has(I.strokeId)}),$t.push.apply($t,ie([],$(nl(s,p.strokeWidth).map(function(I){return ge(ge({},I),{owner:u.c.id})})),!1))}else if(p.mode==="path-trace"){var g=Be(p.followComponentId);g&&s.points.length>1&&Vn.set(g.id,{points:s.points,index:1,speed:p.followSpeed})}}rr({kind:"strokeEnd",componentId:u.c.id})}}}function sf(r){var o,d,u,s;try{for(var p=q(nn.values()),h=p.next();!h.done;h=p.next()){var g=h.value;g.tick(r)}}catch(V){o={error:V}}finally{try{h&&!h.done&&(d=p.return)&&d.call(p)}finally{if(o)throw o.error}}try{for(var I=q(Vn),S=I.next();!S.done;S=I.next()){var m=$(S.value,2),C=m[0],w=m[1],P=Be(C);if(!P){Vn.delete(C);continue}var x=w.points[w.index];if(!x){Vn.delete(C),rr(dt("pathArrive",P));continue}var T=Or(P),A=x.x-T.x,N=x.y-T.y,W=Math.hypot(A,N),D=w.speed*r;W<=D?(Qt(P,x.x,x.y),w.index++):W>.001&&Qt(P,T.x+A/W*D,T.y+N/W*D)}}catch(V){u={error:V}}finally{try{S&&!S.done&&(s=I.return)&&s.call(I)}finally{if(u)throw u.error}}}function cf(r,o,d){var u,s,p=[],h=[],g=function(C){var w=O.get(C.componentId),P=C.parameters.dragMode==="anywhere"?Xr(w).find(function(A){return Sr(A)}):d.find(function(A){var N;return((N=A.prototypeId)!==null&&N!==void 0?N:A.id)===w.id});if(!P)return"continue";if(C.kind==="swipe-input")h.push({behavior:C,c:P});else{var x=C.parameters,T=Math.max(x.min,Math.min(x.max,Number(j[x.variableId])));j[x.variableId]=T,p.push({behavior:C,c:P,charge:$o(x,T)}),rr(dt("holdStart",P))}};try{for(var I=q(e.gameplay.filter(function(C){var w;return["swipe-input","hold-charge"].includes(C.kind)&&((w=O.get(C.componentId))===null||w===void 0?void 0:w.sceneId)===Q})),S=I.next();!S.done;S=I.next()){var m=S.value;g(m)}}catch(C){u={error:C}}finally{try{S&&!S.done&&(s=I.return)&&s.call(I)}finally{if(u)throw u.error}}(p.length||h.length)&&(gr={pointerId:r.pointerId,start:o,current:o,holds:p,swipes:h})}function hf(r,o){var d,u,s,p,h,g,I,S;if(!(!gr||gr.pointerId!==r.pointerId)){var m=gr,C=new Set;gr=void 0;try{for(var w=q(ie(ie([],$(m.holds),!1),$(m.swipes),!1)),P=w.next();!P.done;P=w.next()){var x=P.value,T=x.behavior,A=x.c;C.has(T.componentId)||(C.add(T.componentId),rr(dt("pointerUp",A,void 0,{targetId:A.id,pointerId:r.pointerId})))}}catch(ne){d={error:ne}}finally{try{P&&!P.done&&(u=w.return)&&u.call(w)}finally{if(d)throw d.error}}try{for(var N=q(m.holds),W=N.next();!W.done;W=N.next()){var D=W.value,V=D.behavior.parameters;if(rr(dt("holdRelease",D.c)),V.resetOnRelease!==!1){var H=j[V.variableId];j[V.variableId]=V.min,H!==V.min&&rr({kind:"variableChange",variableId:V.variableId,selfInstanceId:(I=D.c.instanceId)!==null&&I!==void 0?I:D.c.id,instanceId:D.c.instanceId})}}}catch(ne){s={error:ne}}finally{try{W&&!W.done&&(p=N.return)&&p.call(N)}finally{if(s)throw s.error}}try{for(var G=q(m.swipes),F=G.next();!F.done;F=G.next()){var te=F.value,de=Zo(m.start,o,te.behavior.parameters.minDistancePx,(S=Wi.get(te.behavior.id))!==null&&S!==void 0?S:-1/0,se*1e3,te.behavior.parameters.cooldownMs);de&&(Wi.set(te.behavior.id,se*1e3),rr(dt("swipe",te.c,void 0,{direction:de})))}}catch(ne){h={error:ne}}finally{try{F&&!F.done&&(g=G.return)&&g.call(G)}finally{if(h)throw h.error}}return C}}function yf(r,o,d){var u,s,p;if(d.some(function(T){return T.contract==="native.button.v1"&&Fe(T).enabled}))return!1;try{for(var h=q(e.gameplay.filter(function(T){var A;return T.kind==="virtual-joystick"&&((A=O.get(T.componentId))===null||A===void 0?void 0:A.sceneId)===Q})),g=h.next();!g.done;g=h.next()){var I=g.value,S=O.get(I.componentId);if(Sr(S)){var m=an.get(I.id);if(!(m&&m.pointerId!==null)){var C=vr(Yt(hr(S)),o.x,o.y),w=Fe(S);if(!(C.x<0||C.y<0||C.x>w.width||C.y>w.height)){var P=I.parameters.mode==="floating"?ge({},o):Or(S),x=Ga(P,o,I.parameters.radiusPx,I.parameters.deadZone);return m=ge({behavior:I,c:S,pointerId:r.pointerId,origin:P,current:o},x),an.set(I.id,m),ma(m),rr(dt("joystickStart",S)),(p=t.setPointerCapture)===null||p===void 0||p.call(t,r.pointerId),!0}}}}}catch(T){u={error:T}}finally{try{g&&!g.done&&(s=h.return)&&s.call(h)}finally{if(u)throw u.error}}return!1}var Eo=function(r){var o,d,u,s,p,h,g,I,S,m,C;b();var w=Oa(r),P=Zi(w);if(si=w,!(!P&&k)){if(k){P&&(Dt=P.c.id,Y((p=P.c.prototypeId)!==null&&p!==void 0?p:P.c.id));return}var x=e.gameplay.some(function(xe){return xe.kind==="virtual-joystick"||xe.kind==="fps-controller-3d"});if(!(!r.isTrusted||r.button!==void 0&&r.button!==0||!x&&r.isPrimary===!1||Pr||Tn||!x&&(Ze&&Ze.pointerId!==r.pointerId||gr&&gr.pointerId!==r.pointerId||Xe&&Xe.pointerId!==r.pointerId)||ee&&(!di||!Zn))){var T=!gn;tn=se,Oi=!0,gn=!0,Co(!0),T&&!Tr&&(zr=Wr=0,on());var A=P?$i(P.c):[];if(yf(r,w,A)){zr=Wr=0,Tr=!1,on(),it();return}if(ff(r,w,A)){on(),it();return}cf(r,w,A);var N=e.gameplay.find(function(xe){return xe.kind==="aim-launch"&&O.get(xe.componentId).sceneId===Q&&(xe.parameters.dragMode==="anywhere"&&!A.some(function(we){return we.contract==="native.button.v1"})||A.some(function(we){var Te;return((Te=we.prototypeId)!==null&&Te!==void 0?Te:we.id)===xe.componentId}))});if(N){var W=O.get(N.componentId),D=(h=A.find(function(xe){var we;return((we=xe.prototypeId)!==null&&we!==void 0?we:xe.id)===W.id}))!==null&&h!==void 0?h:Xr(W).find(function(xe){return Sr(xe)}),V=D&&Bn(D,Mt("physics-body",W.id));if(V&&(!N.parameters.onlyWhenAtRest||V.atRest)){Xe={behavior:N,targetId:D.id,sourceId:W.id,pointerId:r.pointerId,start:w,current:w,power:0},ko(w),(g=t.setPointerCapture)===null||g===void 0||g.call(t,r.pointerId),it();return}}try{for(var H=q(A),G=H.next();!G.done;G=H.next()){var F=G.value,te=Mt("press-feedback",(I=F.prototypeId)!==null&&I!==void 0?I:F.id);te&&(F.contract!=="native.button.v1"||Fe(F).enabled)&&xn.set(F.id,{behavior:te.parameters,pointerId:r.pointerId,held:!0})}}catch(xe){o={error:xe}}finally{try{G&&!G.done&&(d=H.return)&&d.call(H)}finally{if(o)throw o.error}}var de=A.find(function(xe){var we;return((we=Ht.get(xe.id))===null||we===void 0?void 0:we.sceneId)===Q});if(de){var ne=wt.get(de.parentId);if(ne!=null&&ne.snapshot().busy)return;Ul(de),ne&&!ne.snapshot().busy&&(nt={pointerId:r.pointerId,boardId:de.parentId,tileId:de.id,start:w},(S=t.setPointerCapture)===null||S===void 0||S.call(t,r.pointerId))}tt=(m=A.find(function(xe){return xe.contract==="native.button.v1"&&Fe(xe).enabled}))===null||m===void 0?void 0:m.id,At=tt?r.pointerId:void 0;var pe=e.gameplay.find(function(xe){return xe.kind==="drag"&&A.some(function(we){var Te;return((Te=we.prototypeId)!==null&&Te!==void 0?Te:we.id)===xe.componentId})});if(pe){var F=A.find(function(we){var Te;return((Te=we.prototypeId)!==null&&Te!==void 0?Te:we.id)===pe.componentId}),Ce=Or(F),We=Rr.zoneOf(F.id);zi.set(F.id,Ce),Rr.release(F.id),Ze={b:pe,targetId:F.id,start:w,current:w,origin:Ce,originZone:We,m:ie([],$(St(F)),!1),pointerId:r.pointerId},rr(dt("dragStart",F)),t.setPointerCapture(r.pointerId)}zr=Wr=0,Tr=!1;try{for(var De=q(A),me=De.next();!me.done;me=De.next()){var F=me.value;(F.contract!=="native.button.v1"||Fe(F).enabled)&&rr({kind:"click",componentId:(C=F.prototypeId)!==null&&C!==void 0?C:F.id,instanceId:F.instanceId,targetId:F.id,pointerId:r.pointerId})}}catch(xe){u={error:xe}}finally{try{me&&!me.done&&(s=De.return)&&s.call(De)}finally{if(u)throw u.error}}on(),it()}}};function Po(r,o){if(!nt||nt.pointerId!==r.pointerId)return!1;if(!r.isTrusted||!jn())return!0;var d=nt,u=wt.get(d.boardId);if(u.snapshot().busy)return nt=void 0,!0;var s=Yt(hr(O.get(d.boardId))),p=vr(s,d.start.x,d.start.y),h=vr(s,o.x,o.y),g=h.x-p.x,I=h.y-p.y,S=O.get(d.tileId);if(Math.max(Math.abs(g),Math.abs(I))<Math.min(S.parameters.width,S.parameters.height)*.35)return!0;var m=Ht.get(S.id),C=Math.abs(g)>Math.abs(I),w=m.row+(C?0:Math.sign(I)),P=m.column+(C?Math.sign(g):0),x=ie([],$(Ht),!1).find(function(T){var A=$(T,2),N=A[1];return N.boardId===d.boardId&&N.row===w&&N.column===P});return x&&u.swap(S.id,x[0])&&(Fr=void 0,it()),nt=void 0,!0}var To=function(r){var o,d,u,s;if(!Pr){b();var p=R(),h=Oa(r);si=h,(gr==null?void 0:gr.pointerId)===r.pointerId&&(gr.current=h);try{for(var g=q(an.values()),I=g.next();!I.done;I=g.next()){var S=I.value;if(S.pointerId===r.pointerId){var m=h.x-S.current.x,C=h.y-S.current.y;Object.assign(S,{current:h},Ga(S.origin,h,S.behavior.parameters.radiusPx,S.behavior.parameters.deadZone)),ma(S),it();return}}}catch(we){o={error:we}}finally{try{I&&!I.done&&(d=g.return)&&d.call(g)}finally{if(o)throw o.error}}if(($r==null?void 0:$r.pointerId)===r.pointerId){if($r.kind==="mask"){var w=$r,P=vr(Yt(hr(w.c)),h.x,h.y);hi(w.c,w.behavior).stampSegment(w.last,P),w.last=P}else uf(h,$r);on(),it();return}if((Xe==null?void 0:Xe.pointerId)===r.pointerId){r.isTrusted&&jn()&&ko(h),it();return}var x=Zi(h);if(Gt=x?(u=$i(x.c).find(function(we){return we.contract==="native.button.v1"}))===null||u===void 0?void 0:u.id:void 0,!Po(r,h)&&!(!Ze||Ze.pointerId!==r.pointerId)){var T=Be(Ze.targetId);if(!T){Di();return}var A=T.parentId?hr(Be(T.parentId)):jt(),N=Yt(A),W=vr(N,Ze.start.x,Ze.start.y),D=vr(N,h.x,h.y),V=ie([],$(Ze.m),!1),H=Ze.b.parameters.axis;if(H!=="y"){var G=Ze.m[4]+D.x-W.x;Number.isFinite(Ze.b.parameters.minX)&&(G=Math.max(Ze.b.parameters.minX,G)),Number.isFinite(Ze.b.parameters.maxX)&&(G=Math.min(Ze.b.parameters.maxX,G)),V[4]=G}if(H!=="x"){var F=Ze.m[5]+D.y-W.y;Number.isFinite(Ze.b.parameters.minY)&&(F=Math.max(Ze.b.parameters.minY,F)),Number.isFinite(Ze.b.parameters.maxY)&&(F=Math.min(Ze.b.parameters.maxY,F)),V[5]=F}if(!T.parentId)H!=="y"&&(V[4]=Math.max(0,Math.min(p.width-T.parameters.width,V[4])));else{var te=ut(T,ai(A,V)),de=0;te.left<0||te.right-te.left>p.width?de=-te.left:te.right>p.width&&(de=p.width-te.right);var ne=H==="y"?0:A[0],pe=H==="x"?0:A[2];Math.abs(ne)>=Math.abs(pe)&&Math.abs(ne)>1e-8?V[4]+=de/ne:Math.abs(pe)>1e-8&&(V[5]+=de/pe)}var Ce=(s=Qe.get(T.id))!==null&&s!==void 0?s:{parameters:{}};Qe.set(T.id,ge(ge({},Ce),{transform:V})),Ze.current=h;var We=Ca(T),De=We.zones,me=We.tag,xe=ia({itemId:T.id,tag:me,zones:De,occupancy:Rr});bn=xe&&xe.kind!=="reject"?xe.zone:void 0}}},Ao=function(r){var o,d,u,s;b();var p=Oa(r),h=bt;si=p,ga(r.pointerId,!0),vf(r);var g=(u=hf(r,p))!==null&&u!==void 0?u:new Set;if(Yl(r),r.isTrusted&&jn()){var I=Zi(p);try{for(var S=q(I?$i(I.c):[]),m=S.next();!m.done;m=S.next()){var C=m.value;!g.has((s=C.prototypeId)!==null&&s!==void 0?s:C.id)&&(C.contract!=="native.button.v1"||Fe(C).enabled)&&rr(dt("pointerUp",C,void 0,{targetId:C.id,pointerId:r.pointerId}))}}catch(A){o={error:A}}finally{try{m&&!m.done&&(d=S.return)&&d.call(S)}finally{if(o)throw o.error}}}if(on(),it(),(Xe==null?void 0:Xe.pointerId)===r.pointerId){var w=Xe,P=Va(),x=Ot.get(w.targetId);Xe=void 0,w.behavior.parameters.powerVariableId&&(j[w.behavior.parameters.powerVariableId]=0),x&&r.isTrusted&&jn()&&P.pull>=w.behavior.parameters.minPullPx&&(x.vx=P.vx,x.vy=P.vy,x.atRest=!1,x.restElapsed=0,x.captured=!1,x.exited=!1,rr({kind:"launch",componentId:w.sourceId,instanceId:x.instanceId})),Ia(r),on(),it();return}if(Po(r,p),(nt==null?void 0:nt.pointerId)===r.pointerId&&(nt=void 0),Ia(r),!((h==null?void 0:h.pointerId)!==r.pointerId||!r.isTrusted||!jn()||navigator.userActivation&&navigator.userActivation.isActive!==!0||!Ui(h.condition))){var T=Zi(p);!T||!$i(T.c).some(function(A){return A.id===h.targetId&&(A.contract!=="native.button.v1"||Fe(A).enabled)})||(ee?ee.openStore(e.base.storeUrl):window.open(e.base.storeUrl,"_blank","noopener"))}},Ki=function(r){var o,d;if(ga(r.pointerId,!0),(Xe==null?void 0:Xe.pointerId)===r.pointerId&&(Xe.behavior.parameters.powerVariableId&&(j[Xe.behavior.parameters.powerVariableId]=0),Xe=void 0),(nt==null?void 0:nt.pointerId)===r.pointerId&&(nt=void 0),($r==null?void 0:$r.pointerId)===r.pointerId&&($r.kind==="stroke"&&$r.store.cancel(),$r=void 0),(gr==null?void 0:gr.pointerId)===r.pointerId){try{for(var u=q(gr.holds),s=u.next();!s.done;s=u.next()){var p=s.value;p.behavior.parameters.resetOnRelease!==!1&&(j[p.behavior.parameters.variableId]=p.behavior.parameters.min)}}catch(h){o={error:h}}finally{try{s&&!s.done&&(d=u.return)&&d.call(u)}finally{if(o)throw o.error}}gr=void 0}Ia(r)},Ro=function(r){r!=null&&r.isTrusted&&!k&&!Pr&&!Tn&&Co(!0)},Na=function(){Vi||it()},Mn=typeof globalThis.ResizeObserver=="function"?new globalThis.ResizeObserver(Na):void 0;try{(v=Mn==null?void 0:Mn.observe)===null||v===void 0||v.call(Mn,t)}catch{}var Oo=function(){Ue=0,lr=0,document.hidden&&Kt(),Ke&&(document.hidden?Ke.suspend().catch(function(){}):!Pr&&gn&&yi())};document.addEventListener("visibilitychange",Oo),(c=globalThis.addEventListener)===null||c===void 0||c.call(globalThis,"resize",Na),t.addEventListener("pointerdown",Eo),t.addEventListener("pointermove",To),t.addEventListener("pointerup",Ao),t.addEventListener("pointercancel",Ki),t.addEventListener("lostpointercapture",Ki),t.addEventListener("click",Ro);var Ba=ee==null?void 0:ee.onVisibilityChanged(function(r){Zn=r,Ue=0,lr=0,r||Kt(),Ke&&(r?!Pr&&gn&&yi():Ke.suspend().catch(function(){}))}),za=ee==null?void 0:ee.onClosed(function(){Tn=!0,Ue=0,lr=0,Kt(),ci()}),Wa=(E=ee==null?void 0:ee.onVolumeChanged)===null||E===void 0?void 0:E.call(ee,function(r){typeof r=="number"&&Number.isFinite(r)&&r>=0&&(ya=Math.min(1,r>1?r/100:r),ka())});function Vo(r){var o=!k&&!Pr&&!document.hidden&&di&&Zn&&!Tn;if(o&&lr&&(ke+=Math.min((r-lr)/1e3,5/60)),jn()){zr=Wr=0,Tr=!1,lr&&(Ue+=Math.min((r-lr)/1e3,5/60));for(var d=0;d<5&&Ue>=1/60;d++)ql(1/60),Ue-=1/60;on()}else Ue=0;lr=r,it(),mn=requestAnimationFrame(Vo)}return Ma(),k&&(Q=re),it(),mn=requestAnimationFrame(Vo),ee&&ee.init().then(function(){Vi||(di=!0,Zn=ee.isVisible(),Ue=0,lr=0)}).catch(function(){Vi||(Tn=!0,Kt(),ci())}),{state:Vl,auditViewport:af,auditSceneLayout:of,restart:function(){var r;(r=ee==null?void 0:ee.notifyGameRetry)===null||r===void 0||r.call(ee),Ma(),it()},select:function(r){Dt=r},inspectScene:function(r){k&&e.scenes.some(function(o){return o.id===r})&&(Q=r,Dt=void 0)},pause:function(r){Pr=r,Ue=0,lr=0,r&&Kt(),Ke&&(r?Ke.suspend().catch(function(){}):gn&&yi())},destroy:function(){var r,o;Vi=!0,cancelAnimationFrame(mn),Kt(),ci(),Ba==null||Ba(),za==null||za(),Wa==null||Wa(),ee==null||ee.destroy(),(r=Mn==null?void 0:Mn.disconnect)===null||r===void 0||r.call(Mn),document.removeEventListener("visibilitychange",Oo),(o=globalThis.removeEventListener)===null||o===void 0||o.call(globalThis,"resize",Na),t.removeEventListener("pointerdown",Eo),t.removeEventListener("pointermove",To),t.removeEventListener("pointerup",Ao),t.removeEventListener("pointercancel",Ki),t.removeEventListener("lostpointercapture",Ki),t.removeEventListener("click",Ro),Ke==null||Ke.close().catch(function(){})}}}return Tf(od);})();
1
+ var ToraNative=(()=>{var Ua=Object.defineProperty;var Pf=Object.getOwnPropertyDescriptor;var Tf=Object.getOwnPropertyNames;var Ef=Object.prototype.hasOwnProperty;var Af=(e,t)=>{for(var n in t)Ua(e,n,{get:t[n],enumerable:!0})},Rf=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of Tf(t))!Ef.call(e,l)&&l!==n&&Ua(e,l,{get:()=>t[l],enumerable:!(a=Pf(t,l))||a.enumerable});return e};var Vf=e=>Rf(Ua({},"__esModule",{value:!0}),e);var dd={};Af(dd,{computeSafeArea:()=>uo,createNetworkBridge:()=>Rl,layoutStandardText:()=>Vl,mountNative:()=>fd});var Uo=function(e,t){if(!e)throw Error(t)},nn=function(){return[1,0,0,1,0,0]};function Ga(e){return Uo(Array.isArray(e)&&e.length===6&&e.every(Number.isFinite),"E_SCENE_MATRIX"),e}function ii(e,t){return Ga(e),Ga(t),[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function Ut(e){Ga(e);var t=e[0]*e[3]-e[1]*e[2];return Uo(Math.abs(t)>1e-12,"E_SCENE_SINGULAR_TRANSFORM"),[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[3]*e[4])/t,(e[1]*e[4]-e[0]*e[5])/t]}var Za=function(){return Za=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},Za.apply(this,arguments)},an=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Hn=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},Ya=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Go(e){var t=e.rows,n=e.columns,a=e.seed,l=e.slots,i=e.paint,v=e.onEvent,c=l.map(function(H){return H.group}),P=Hn([],an(new Set(c)),!1),f=Hn([],an(c),!1),w=a,S="idle",W=0,re,U,G=[],oe=[],q=0,ee=0,y=0,O,Te,Se=function(H,de){return H*n+de},be=function(H){return Math.floor(H/n)},Le=function(H){return H%n},Z=function(){return w=Math.imul(w,1664525)+1013904223>>>0,w/4294967296};function ve(H){for(var de=new Set,ze=0;ze<t;ze++)for(var Ae=0;Ae<n;Ae++){var ce=Se(ze,Ae),$e=H[ce];if(Ae+2<n&&$e===H[ce+1]&&$e===H[ce+2])for(var je=0;je<3;je++)de.add(ce+je);if(ze+2<t&&$e===H[ce+n]&&$e===H[ce+n*2])for(var je=0;je<3;je++)de.add(ce+n*je)}return Hn([],an(de),!1)}function ae(H,de){var ze;if(f[H]===f[de])return!1;var Ae=Hn([],an(f),!1);return ze=an([Ae[de],Ae[H]],2),Ae[H]=ze[0],Ae[de]=ze[1],ve(Ae).some(function(ce){return ce===H||ce===de})}function me(){for(var H=[],de=0;de<f.length;de++)Le(de)+1<n&&ae(de,de+1)&&H.push({from:l[de].id,to:l[de+1].id}),be(de)+1<t&&ae(de,de+n)&&H.push({from:l[de].id,to:l[de+n].id});return H}function R(){for(var H=0;H<64;H++){f=[];for(var de=function(Ae){var ce=P.filter(function($e){return!(Le(Ae)>=2&&f[Ae-1]===$e&&f[Ae-2]===$e)&&!(be(Ae)>=2&&f[Ae-n]===$e&&f[Ae-n*2]===$e)});f.push(ce[Math.floor(Z()*ce.length)])},ze=0;ze<l.length;ze++)de(ze);if(me().length)return}f=l.map(function(Ae,ce){return P[(be(ce)*2+Le(ce))%3]}),f[0]=P[0],f[1]=P[1],f[2]=P[0],f[n+1]=P[0]}function b(){for(var H=0;H<l.length;H++)i(H,f[H],{})}function K(){w=a,f=Hn([],an(c),!1),S="idle",W=0,re=void 0,U=void 0,G=[],oe=[],q=0,ee=0,y=0,O=void 0,Te=void 0,(ve(f).length||!me().length)&&R(),b()}function D(H,de){if(S!=="idle")return!1;var ze=l.findIndex(function(ce){return ce.id===H}),Ae=l.findIndex(function(ce){return ce.id===de});return ze<0||Ae<0||Math.abs(be(ze)-be(Ae))+Math.abs(Le(ze)-Le(Ae))!==1?!1:(re=void 0,O=void 0,b(),U=[ze,Ae],S="swap",W=0,!0)}function le(H){if(S==="idle"){if(re===H){re=void 0;return}if(!(re&&D(re,H)))return re=H,re}}function Q(){G=ve(f),y+=G.length,Te={group:f[G[0]],from:l[G[0]].id,count:G.length},v("matchClear"),S="clear",W=0}function fe(){var H=new Set(G),de=Hn([],an(f),!1);oe=[];for(var ze=0;ze<n;ze++){for(var Ae=[],ce=t-1;ce>=0;ce--)H.has(Se(ce,ze))||Ae.push(Se(ce,ze));for(var $e=0,ce=t-1;ce>=0;ce--){var je=Se(ce,ze),lr=Ae[t-1-ce];lr!==void 0?(de[je]=f[lr],oe.push({cell:je,from:lr,offsetRows:0})):(de[je]=P[Math.floor(Z()*P.length)],oe.push({cell:je,from:je,offsetRows:-(ce+1+$e++)}))}}f=de,S="fall",W=0}function _(){if(ve(f).length&&q<3){q++,Q();return}(ve(f).length||!me().length)&&R(),b(),S="idle",W=0,U=void 0,G=[],oe=[],ee++,v("validMatch")}function j(H){var de,ze,Ae,ce,$e,je,lr;if(S==="idle"){if(O){O.elapsed+=H;var Sr=1+.065*Math.sin(Math.min(1,O.elapsed/.8)*Math.PI*4),Tr=function(et){i(l.findIndex(function(Wr){return Wr.id===et}),f[l.findIndex(function(Wr){return Wr.id===et})],{scale:Sr})};try{for(var Lr=Ya(O.ids),zr=Lr.next();!zr.done;zr=Lr.next()){var Rt=zr.value;Tr(Rt)}}catch(et){de={error:et}}finally{try{zr&&!zr.done&&(ze=Lr.return)&&ze.call(Lr)}finally{if(de)throw de.error}}O.elapsed>=.8&&(O=void 0,b())}return}if(W+=H,S==="swap"||S==="reverse"){var pt=Math.min(1,W/.14),_e=pt*pt*(3-2*pt),mn=an(U,2),Ge=mn[0],Gt=mn[1];if(i(Ge,f[Ge],{from:Gt,progress:S==="swap"?_e:1-_e}),i(Gt,f[Gt],{from:Ge,progress:S==="swap"?_e:1-_e}),pt<1)return;if(S==="reverse"){b(),S="idle",U=void 0,v("invalidMatch");return}if(!ae(Ge,Gt)){S="reverse",W=0;return}Ae=an([f[Gt],f[Ge]],2),f[Ge]=Ae[0],f[Gt]=Ae[1],b(),Q();return}if(S==="clear"){var it=Math.min(1,W/.18),Sr=it<.22?1+it*.45:Math.max(.05,1.1*(1-it)/.78);try{for(var Lt=Ya(G),ln=Lt.next();!ln.done;ln=Lt.next()){var Yt=ln.value;i(Yt,f[Yt],{scale:Sr,opacity:1-it})}}catch(Wr){ce={error:Wr}}finally{try{ln&&!ln.done&&($e=Lt.return)&&$e.call(Lt)}finally{if(ce)throw ce.error}}it===1&&fe();return}var Vt=Math.min(1,W/.25),Zt=1-Math.pow(1-Vt,3);try{for(var Ot=Ya(oe),mt=Ot.next();!mt.done;mt=Ot.next()){var st=mt.value;i(st.cell,f[st.cell],{from:st.from,offsetRows:st.offsetRows,progress:1-Zt})}}catch(et){je={error:et}}finally{try{mt&&!mt.done&&(lr=Ot.return)&&lr.call(Ot)}finally{if(je)throw je.error}}Vt===1&&_()}function se(){if(S==="idle"){re=void 0;var H=me()[0];H&&(O={ids:[H.from,H.to],elapsed:0})}}function ye(){var H;return{phase:S,busy:S!=="idle",selected:re!=null?re:null,moves:ee,cleared:y,groups:Hn([],an(f),!1),legalMoves:S==="idle"?me():[],hint:(H=O==null?void 0:O.ids)!==null&&H!==void 0?H:[],lastMatch:Te?Za({},Te):null}}return{reset:K,select:le,swap:D,tick:j,showHint:se,snapshot:ye,cancelSelection:function(){re=void 0,O&&(O=void 0,b())}}}var na=function(){return na=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},na.apply(this,arguments)},Yo=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Of=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},Zo=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function $o(){var e=new Map,t=new Map,n=function(l){var i,v,c=t.get(l);c!==void 0&&((i=e.get(c))===null||i===void 0||i.delete(l),((v=e.get(c))===null||v===void 0?void 0:v.size)===0&&e.delete(c)),t.delete(l)},a=function(l,i){n(l),i!=null&&(e.has(i)||e.set(i,new Set),e.get(i).add(l),t.set(l,i))};return{occupants:e,itemZone:t,release:n,place:a,clear:function(){e.clear(),t.clear()},items:function(l){var i;return Of([],Yo((i=e.get(l))!==null&&i!==void 0?i:[]),!1).sort()},zoneOf:function(l){return t.get(l)},snapshot:function(){return{itemZone:Object.fromEntries(t)}}}}function ia(e){var t,n,a=e.itemId,l=e.tag,i=l===void 0?"":l,v=e.zones,c=e.occupancy,P=v.filter(function(U){var G,oe,q;return U.id!==a&&(((oe=(G=U.acceptTags)===null||G===void 0?void 0:G.length)!==null&&oe!==void 0?oe:0)===0||((q=U.acceptTags)===null||q===void 0?void 0:q.includes(i)))});P.sort(function(U,G){return Number(G.itemTarget)-Number(U.itemTarget)||G.paintOrder-U.paintOrder||U.distance-G.distance||U.id.localeCompare(G.id)});try{for(var f=Zo(P),w=f.next();!w.done;w=f.next()){var S=w.value,W=c.items(S.id).filter(function(U){return U!==a}),re=S.capacity>0&&W.length>=S.capacity;return S.snapMode==="reject"?{kind:"reject",zone:S,occupantId:W[0]}:re?S.onOccupied==="emit"?{kind:"emit",zone:S,occupantId:W[0]}:S.onOccupied==="swap"&&W.length?{kind:"swap",zone:S,occupantId:W[0]}:{kind:"reject",zone:S,occupantId:W[0]}:{kind:"accept",zone:S}}}catch(U){t={error:U}}finally{try{w&&!w.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}return null}function Ko(e,t,n,a,l,i){if(n===void 0&&(n=28),a===void 0&&(a=-1/0),l===void 0&&(l=0),i===void 0&&(i=80),l-a<i)return null;var v=t.x-e.x,c=t.y-e.y;return Math.max(Math.abs(v),Math.abs(c))<n?null:Math.abs(v)>Math.abs(c)?v<0?"left":"right":c<0?"up":"down"}function Qo(e,t){var n=t,a=1;return{tick:function(l){return e.pingPong?(n+=a*e.ratePerSecond*l,n>=e.max?(n=e.max,a=-1):n<=e.min&&(n=e.min,a=1)):n=Math.max(e.min,Math.min(e.max,n+e.ratePerSecond*l)),n}}}function Jo(){var e=new Map;return{to:function(t,n,a,l,i){l===void 0&&(l=.18),e.set(t,{from:na({},n),to:na({},a),seconds:Math.max(.02,l),elapsed:0,onDone:i})},cancel:function(t){e.delete(t)},clear:function(){e.clear()},tick:function(t,n){var a,l,i;try{for(var v=Zo(e),c=v.next();!c.done;c=v.next()){var P=Yo(c.value,2),f=P[0],w=P[1];w.elapsed+=t;var S=Math.min(1,w.elapsed/w.seconds),W=1-Math.pow(1-S,3);n(f,{x:w.from.x+(w.to.x-w.from.x)*W,y:w.from.y+(w.to.y-w.from.y)*W}),S===1&&(e.delete(f),(i=w.onDone)===null||i===void 0||i.call(w))}}catch(re){a={error:re}}finally{try{c&&!c.done&&(l=v.return)&&l.call(v)}finally{if(a)throw a.error}}}}}function $a(e,t,n,a){n===void 0&&(n=56),a===void 0&&(a=.12);var l=Math.max(1,n),i=t.x-e.x,v=t.y-e.y,c=Math.hypot(i,v),P=Math.min(c,l),f=P/l,w=c>1e-6?i/c:0,S=c>1e-6?v/c:0,W=e.x+w*P,re=e.y+S*P;if(f<=a)return{nx:0,ny:0,magnitude:0,angle:0,knobX:W,knobY:re};var U=(f-a)/Math.max(1e-6,1-a);return{nx:w*U,ny:S*U,magnitude:U,angle:Math.atan2(S,w)*180/Math.PI,knobX:W,knobY:re}}var Ka=function(){return Ka=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},Ka.apply(this,arguments)},qo=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Qa(e){var t,n,a=2166136261;try{for(var l=qo(String(e)),i=l.next();!i.done;i=l.next()){var v=i.value;a^=v.codePointAt(0),a=Math.imul(a,16777619)}}catch(c){t={error:c}}finally{try{i&&!i.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return a>>>0||1}function Ja(e){var t=e>>>0||1,n=t;return{next:function(){return n=Math.imul(n,1664525)+1013904223>>>0,n/4294967296},between:function(a,l,i){if(i===void 0&&(i=!1),i){var v=Math.ceil(a),c=Math.floor(l);return c<v?v:Math.min(c,v+Math.floor((c-v+1)*this.next()))}return a+(l-a)*this.next()},reset:function(){n=t}}}function jo(e,t,n,a,l){var i,v;a===void 0&&(a=0);var c=null,P=1/0;try{for(var f=qo(t),w=f.next();!w.done;w=f.next()){var S=w.value;if(!(S.id===l||S.team!==n)){var W=Math.hypot(S.x-e.x,S.y-e.y);a>0&&W>a||(W<P||W===P&&S.id<(c==null?void 0:c.id))&&(c=S,P=W)}}}catch(re){i={error:re}}finally{try{w&&!w.done&&(v=f.return)&&v.call(f)}finally{if(i)throw i.error}}return c}function _o(e,t,n){var a=((t-e+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return e+Math.max(-n,Math.min(n,a))}function el(e){var t=Ja(e),n=new Map,a=new Map;return{rng:t,states:n,headings:a,reset:function(){t.reset(),n.clear(),a.clear()},initialize:function(l,i){var v;return n.has(l)||n.set(l,{hp:i.hp,maxHp:i.maxHp,value:i.value,tag:(v=i.tag)!==null&&v!==void 0?v:"",team:i.team}),n.get(l)},remove:function(l){n.delete(l),a.delete(l)},snapshot:function(l){var i=n.get(l);return i?Ka({},i):void 0}}}function rl(e,t){var n,a,l,i,v=t===void 0?{}:t,c=v.width,P=v.height,f=v.onProgress,w=f===void 0?function(){}:f,S=v.onComplete,W=S===void 0?function(){}:S,re=v.canvasFactory,U=v.source,G=e,oe=G.gridSize,q=new Uint8Array(oe*oe),ee=0,y=!1,O=-1,Te=!1,Se=Math.max(1,c),be=Math.max(1,P),Le=Math.min(1,512/Math.max(Se,be)),Z=(n=re==null?void 0:re())!==null&&n!==void 0?n:!((a=globalThis.document)===null||a===void 0)&&a.createElement?globalThis.document.createElement("canvas"):void 0;Z&&(Z.width=Math.max(1,Math.round(Se*Le)),Z.height=Math.max(1,Math.round(be*Le)));var ve=(l=Z==null?void 0:Z.getContext)===null||l===void 0?void 0:l.call(Z,"2d"),ae=(i=G.maskColor)!==null&&i!==void 0?i:"#dceeff",me=function(){return!!(U&&U.complete&&U.naturalWidth>0)},R=function(){ve&&(ve.globalCompositeOperation="source-over",ve.clearRect(0,0,Z.width,Z.height),G.mode==="erase"&&(me()?(ve.drawImage(U,0,0,Z.width,Z.height),Te=!0):(ve.fillStyle=ae,ve.fillRect(0,0,Z.width,Z.height),Te=!1)))};R();var b=function(){if(!y){var D=Math.round(ee/q.length*100),le=Math.min(100,D);le!==O&&(O=le,w(le)),le>=G.targetPercent&&(y=!0,W(le))}},K=function(D,le){for(var Q=Math.max(0,Math.min(oe-1,Math.floor(D/Se*oe))),fe=Math.max(0,Math.min(oe-1,Math.floor(le/be*oe))),_=Math.max(0,Math.ceil(G.brushRadiusPx/Se*oe)),j=Math.max(0,Math.ceil(G.brushRadiusPx/be*oe)),se=Math.max(0,fe-j);se<=Math.min(oe-1,fe+j);se++)for(var ye=Math.max(0,Q-_);ye<=Math.min(oe-1,Q+_);ye++)if(!(Math.hypot((ye+.5)/oe*Se-D,(se+.5)/oe*be-le)>G.brushRadiusPx)){var H=se*oe+ye;q[H]||(q[H]=1,ee++)}ve&&(ve.save(),ve.scale(Le,Le),ve.globalCompositeOperation=G.mode==="erase"?"destination-out":"source-over",ve.fillStyle=ae,ve.beginPath(),ve.arc(D,le,G.brushRadiusPx,0,Math.PI*2),ve.fill(),G.mode==="reveal"&&U&&(ve.globalCompositeOperation="source-in",ve.drawImage(U,0,0,Se,be)),ve.restore()),b()};return{canvas:Z,stampSegment:function(D,le){for(var Q=Math.hypot(le.x-D.x,le.y-D.y),fe=Math.max(1,Math.ceil(Q/Math.max(1,G.brushRadiusPx*.45))),_=0;_<=fe;_++)K(D.x+(le.x-D.x)*_/fe,D.y+(le.y-D.y)*_/fe)},reset:function(){q.fill(0),ee=0,y=!1,O=-1,R(),b()},get progress(){return Math.round(ee/q.length*100)},render:function(D){G.mode==="erase"&&ee===0&&!Te&&me()&&R(),Z?D.drawImage(Z,0,0,Z.width,Z.height,0,0,c,P):G.mode==="erase"&&this.progress<100&&(D.save(),D.globalAlpha=1-this.progress/100,D.fillStyle=ae,D.fillRect(0,0,c,P),D.restore())}}}var Fn=function(){return Fn=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},Fn.apply(this,arguments)},Bf=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function qa(e,t,n,a){var l=function(w,S,W){return(S.x-w.x)*(W.y-w.y)-(S.y-w.y)*(W.x-w.x)},i=l(e,t,n),v=l(e,t,a),c=l(n,a,e),P=l(n,a,t),f=1e-8;return Math.abs(i)<f&&Math.abs(v)<f&&Math.abs(c)<f&&Math.abs(P)<f?Math.max(Math.min(e.x,t.x),Math.min(n.x,a.x))<=Math.min(Math.max(e.x,t.x),Math.max(n.x,a.x))+f&&Math.max(Math.min(e.y,t.y),Math.min(n.y,a.y))<=Math.min(Math.max(e.y,t.y),Math.max(n.y,a.y))+f:i>0!=v>0&&c>0!=P>0}function tl(e,t){for(var n=!1,a=0,l=t.length-1;a<t.length;l=a++){var i=t[a],v=t[l];i.y>e.y!=v.y>e.y&&e.x<(v.x-i.x)*(e.y-i.y)/(v.y-i.y)+i.x&&(n=!n)}return n}function nl(e,t,n){if(n.length>=3&&(tl(e,n)||tl(t,n)))return!0;for(var a=0;a<n.length;a++)if(qa(e,t,n[a],n[(a+1)%n.length]))return!0;return!1}function il(e){var t=e,n=[],a=null,l=0,i=function(v){return Fn(Fn({},v),{points:v.points.map(function(c){return Fn({},c)})})};return{begin:function(v){var c={id:++l,points:[Fn({},v)],age:0,hitIds:new Set};return a=c,n.push(c),n.length>t.maxStrokes&&n.shift(),c},add:function(v){if(!a||a.points.length>=t.maxPoints)return!1;var c=a.points[a.points.length-1];return Math.hypot(v.x-c.x,v.y-c.y)<t.minSegmentPx?!1:(a.points.push(Fn({},v)),!0)},end:function(){var v=a;return a=null,v?i(v):void 0},cancel:function(){a&&(n=n.filter(function(v){return v!==a})),a=null},clear:function(){a=null,n=[]},tick:function(v){var c,P;try{for(var f=Bf(n),w=f.next();!w.done;w=f.next()){var S=w.value;S.age+=v}}catch(W){c={error:W}}finally{try{w&&!w.done&&(P=f.return)&&P.call(f)}finally{if(c)throw c.error}}n=n.filter(function(W){return W===a||W.age<.18||t.mode!=="slice-blade"})},get active(){return a},get strokes(){return n}}}function al(e,t){for(var n=[],a=1;a<e.points.length;a++){var l=e.points[a-1],i=e.points[a],v=Math.hypot(i.x-l.x,i.y-l.y);v<.001||n.push({id:"stroke-".concat(e.id,"-").concat(a),strokeId:e.id,mode:"static",shape:"box",x:(l.x+i.x)/2,y:(l.y+i.y)/2,width:v,height:Math.max(2,t),angle:Math.atan2(i.y-l.y,i.x-l.x),restitution:.8})}return n}var Si=function(){return Si=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},Si.apply(this,arguments)},vl=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},An=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},zf=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},yn=function(e,t){return Math.hypot(e,t)},ol=function(e,t,n){return Math.max(t,Math.min(n,e))},Xn=function(e){return Math.max(1,Math.min(e.width,e.height)/2)};function ll(e){var t,n,a=Math.cos((t=e.angle)!==null&&t!==void 0?t:0),l=Math.sin((n=e.angle)!==null&&n!==void 0?n:0),i=e.width/2,v=e.height/2;return[[-i,-v],[i,-v],[i,v],[-i,v]].map(function(c){var P=vl(c,2),f=P[0],w=P[1];return{x:e.x+f*a-w*l,y:e.y+f*l+w*a}})}function Wf(e,t){var n,a,l,i,v,c,P,f,w,S,W=ll(e),re=ll(t),U=[(P=e.angle)!==null&&P!==void 0?P:0,((f=e.angle)!==null&&f!==void 0?f:0)+Math.PI/2,(w=t.angle)!==null&&w!==void 0?w:0,((S=t.angle)!==null&&S!==void 0?S:0)+Math.PI/2],G=1/0,oe=1,q=0;try{for(var ee=An(U),y=ee.next();!y.done;y=ee.next()){var O=y.value,Te=Math.cos(O),Se=Math.sin(O),be=1/0,Le=-1/0,Z=1/0,ve=-1/0;try{for(var ae=(l=void 0,An(W)),me=ae.next();!me.done;me=ae.next()){var R=me.value,b=R.x*Te+R.y*Se;b<be&&(be=b),b>Le&&(Le=b)}}catch(Q){l={error:Q}}finally{try{me&&!me.done&&(i=ae.return)&&i.call(ae)}finally{if(l)throw l.error}}try{for(var K=(v=void 0,An(re)),D=K.next();!D.done;D=K.next()){var R=D.value,b=R.x*Te+R.y*Se;b<Z&&(Z=b),b>ve&&(ve=b)}}catch(Q){v={error:Q}}finally{try{D&&!D.done&&(c=K.return)&&c.call(K)}finally{if(v)throw v.error}}var le=Math.min(Le,ve)-Math.max(be,Z);if(le<=0)return null;le<G&&(G=le,oe=Te,q=Se)}}catch(Q){n={error:Q}}finally{try{y&&!y.done&&(a=ee.return)&&a.call(ee)}finally{if(n)throw n.error}}return(e.x-t.x)*oe+(e.y-t.y)*q<0&&(oe=-oe,q=-q),{nx:oe,ny:q,penetration:G}}function fl(e,t){var n,a,l,i=Xn(e),v=-((n=t.angle)!==null&&n!==void 0?n:0),c=Math.cos(v),P=Math.sin(v),f=e.x-t.x,w=e.y-t.y,S=f*c-w*P,W=f*P+w*c,re=t.width/2,U=t.height/2,G=ol(S,-re,re),oe=ol(W,-U,U),q=S-G,ee=W-oe,y=yn(q,ee),O;if(y>=i)return null;if(y<1e-4){var Te=[{d:re-Math.abs(S),x:S>=0?1:-1,y:0},{d:U-Math.abs(W),x:0,y:W>=0?1:-1}].sort(function(Le,Z){return Le.d-Z.d});q=Te[0].x,ee=Te[0].y,O=i+Te[0].d}else q/=y,ee/=y,O=i-y;var Se=Math.cos((a=t.angle)!==null&&a!==void 0?a:0),be=Math.sin((l=t.angle)!==null&&l!==void 0?l:0);return{nx:q*Se-ee*be,ny:q*be+ee*Se,penetration:O}}function dl(e,t){var n;return!!(e.ignoreGroup&&e.ignoreGroup!=="none"&&(e.ignoreGroup==="all"||e.ignoreGroup===((n=t.collisionGroup)!==null&&n!==void 0?n:"all")))}function ul(e,t,n){var a,l,i,v,c,P;if(!(e.captured||t.captured||dl(e,t)||dl(t,e))){var f=e.x-t.x,w=e.y-t.y,S;if(e.shape==="circle"&&t.shape==="circle"){var W=yn(f,w),re=Xn(e)+Xn(t)-W;if(re<=0)return;S=re,W>1e-4?(f/=W,w/=W):(f=1,w=0)}else if(e.shape==="circle"&&t.shape==="box"){var U=fl(e,t);if(!U)return;f=U.nx,w=U.ny,S=U.penetration}else if(e.shape==="box"&&t.shape==="circle"){var U=fl(t,e);if(!U)return;f=-U.nx,w=-U.ny,S=U.penetration}else if(e.shape==="box"&&t.shape==="box"){var U=Wf(e,t);if(!U)return;f=U.nx,w=U.ny,S=U.penetration}else return;var G=e.mode==="dynamic"?1/((a=e.mass)!==null&&a!==void 0?a:1):0,oe=t.mode==="dynamic"?1/((l=t.mass)!==null&&l!==void 0?l:1):0,q=G+oe;if(q){e.x+=f*S*G/q,e.y+=w*S*G/q,t.mode==="dynamic"&&(t.x-=f*S*oe/q,t.y-=w*S*oe/q);var ee=e.vx-((i=t.vx)!==null&&i!==void 0?i:0),y=e.vy-((v=t.vy)!==null&&v!==void 0?v:0),O=ee*f+y*w;if(!(O>=0)){var Te=Math.max((c=e.restitution)!==null&&c!==void 0?c:0,(P=t.restitution)!==null&&P!==void 0?P:0),Se=-(1+Te)*O/q;e.vx+=f*Se*G,e.vy+=w*Se*G,t.mode==="dynamic"&&(t.vx-=f*Se*oe,t.vy-=w*Se*oe),e.atRest=!1,e.restElapsed=0,t.mode==="dynamic"&&(t.atRest=!1,t.restElapsed=0),Math.abs(O)>4&&(n("bodyBounce",e,t,{speed:Math.abs(O)}),t.mode==="dynamic"&&n("bodyBounce",t,e,{speed:Math.abs(O)}))}}}}function Nf(e,t,n,a){var l,i;if(!(e.mode!=="dynamic"||e.captured))try{for(var v=An(t),c=v.next();!c.done;c=v.next()){var P=c.value,f=P.x-e.x,w=P.y-e.y,S=yn(f,w);if(!(S>=P.radius*2.5)){if(S>P.radius&&S>.001&&P.pullStrength>0){var W=P.pullStrength*(1-S/(P.radius*2.5));e.vx+=f/S*W*n,e.vy+=w/S*W*n}if(S<P.radius&&yn(e.vx,e.vy)<=P.maxCaptureSpeed){e.captured=!0,e.atRest=!0,e.vx=P.stopBody?0:e.vx,e.vy=P.stopBody?0:e.vy,P.stopBody&&(e.x=P.x,e.y=P.y),a("zoneCapture",e,P,{});return}}}}catch(re){l={error:re}}finally{try{c&&!c.done&&(i=v.return)&&i.call(v)}finally{if(l)throw l.error}}}function Lf(e,t){var n,a,l,i,v,c,P=function(W){if(W.broken)return"continue";var re=t.find(function(be){return be.id===W.bodyId}),U=t.find(function(be){return be.id===W.anchorId});if(!re||re.mode!=="dynamic")return"continue";var G=(i=(l=U==null?void 0:U.x)!==null&&l!==void 0?l:W.x)!==null&&i!==void 0?i:0,oe=(c=(v=U==null?void 0:U.y)!==null&&v!==void 0?v:W.y)!==null&&c!==void 0?c:0,q=re.x-G,ee=re.y-oe,y=yn(q,ee);if(y<=W.lengthPx||y<1e-4)return"continue";var O=q/y,Te=ee/y;re.x=G+O*W.lengthPx,re.y=oe+Te*W.lengthPx;var Se=re.vx*O+re.vy*Te;Se>0&&(re.vx-=O*Se,re.vy-=Te*Se)};try{for(var f=An(e),w=f.next();!w.done;w=f.next()){var S=w.value;P(S)}}catch(W){n={error:W}}finally{try{w&&!w.done&&(a=f.return)&&a.call(f)}finally{if(n)throw n.error}}}function ja(e){for(var t,n,a,l,i,v,c,P,f,w,S,W=e.bodies,re=e.zones,U=re===void 0?[]:re,G=e.joints,oe=G===void 0?[]:G,q=e.bounds,ee=e.dt,y=e.onEvent,O=y===void 0?function(){}:y,Te=W.filter(function(Ae){return Ae.mode==="dynamic"&&!Ae.captured}),Se=Te.reduce(function(Ae,ce){return Math.max(Ae,yn(ce.vx,ce.vy))},0),be=Te.reduce(function(Ae,ce){return Math.min(Ae,Xn(ce))},24),Le=Math.min(16,Math.max(1,Math.ceil(Se*ee/(be*.45)))),Z=ee/Le,ve=0;ve<Le;ve++){try{for(var ae=(t=void 0,An(Te)),me=ae.next();!me.done;me=ae.next()){var R=me.value;R.vy+=((c=R.gravity)!==null&&c!==void 0?c:0)*Z;var b=yn(R.vx,R.vy);if(b>R.maxSpeed){var K=R.maxSpeed/b;R.vx*=K,R.vy*=K,b=R.maxSpeed}R.x+=R.vx*Z,R.y+=R.vy*Z;var D=Math.max(0,b-((P=R.friction)!==null&&P!==void 0?P:0)*Z),le=Math.exp(-((f=R.linearDamping)!==null&&f!==void 0?f:0)*Z);if(b>1e-4){var Q=D/b*le;R.vx*=Q,R.vy*=Q}R.spinToRotation&&(R.angle=((w=R.angle)!==null&&w!==void 0?w:0)+yn(R.vx,R.vy)*Z/Xn(R)*(R.vx<0?-1:1))}}catch(Ae){t={error:Ae}}finally{try{me&&!me.done&&(n=ae.return)&&n.call(ae)}finally{if(t)throw t.error}}for(var fe=0;fe<Te.length;fe++){var R=Te[fe];try{for(var _=(a=void 0,An(W)),j=_.next();!j.done;j=_.next()){var se=j.value;se.id!==R.id&&se.mode!=="dynamic"&&ul(R,se,O)}}catch(ce){a={error:ce}}finally{try{j&&!j.done&&(l=_.return)&&l.call(_)}finally{if(a)throw a.error}}for(var se=fe+1;se<Te.length;se++)ul(Te[se],R,O);var ye=R.shape==="box"?R.width/2:Xn(R),H=R.shape==="box"?R.height/2:Xn(R);R.wallBounce?(R.x-ye<q.left&&(R.x=q.left+ye,R.vx<0&&(O("bodyBounce",R,null,{speed:Math.abs(R.vx)}),R.vx=-R.vx*R.restitution)),R.x+ye>q.right&&(R.x=q.right-ye,R.vx>0&&(O("bodyBounce",R,null,{speed:Math.abs(R.vx)}),R.vx=-R.vx*R.restitution)),R.y-H<q.top&&(R.y=q.top+H,R.vy<0&&(O("bodyBounce",R,null,{speed:Math.abs(R.vy)}),R.vy=-R.vy*R.restitution)),R.y+H>q.bottom&&(R.y=q.bottom-H,R.vy>0&&(O("bodyBounce",R,null,{speed:Math.abs(R.vy)}),R.vy=-R.vy*R.restitution))):!R.exited&&(R.x+ye<q.left||R.x-ye>q.right||R.y+H<q.top||R.y-H>q.bottom)&&(R.exited=!0,O("boundaryExit",R,null,{})),Nf(R,U,Z,O)}Lf(oe,W)}try{for(var de=An(Te),ze=de.next();!ze.done;ze=de.next()){var R=ze.value,b=yn(R.vx,R.vy);b<R.restSpeed&&!R.captured?(R.restElapsed=((S=R.restElapsed)!==null&&S!==void 0?S:0)+ee,R.restElapsed>=R.restDelaySeconds&&!R.atRest&&(R.atRest=!0,R.vx=0,R.vy=0,O("bodyRest",R,null,{}))):b>=R.restSpeed&&(R.restElapsed=0,R.atRest=!1)}}catch(Ae){i={error:Ae}}finally{try{ze&&!ze.done&&(v=de.return)&&v.call(de)}finally{if(i)throw i.error}}}function sl(e){for(var t=e.body,n=e.bodies,a=e.zones,l=a===void 0?[]:a,i=e.bounds,v=e.dots,c=v===void 0?8:v,P=e.bounces,f=P===void 0?1:P,w=function(y){return Si({},y)},S=w(t),W=n.filter(function(y){return y.id!==t.id}).map(w),re=zf([S],vl(W),!1),U=[],G=0,oe=!1,q=function(y,O,Te,Se){y==="bodyBounce"&&Se.sourceId===t.id&&G++,y==="zoneCapture"&&Se.sourceId===t.id&&(oe=!0)},ee=0;ee<90&&U.length<c&&!oe&&G<=f;ee++)ja({bodies:re,zones:l,bounds:i,dt:1/60,onEvent:function(y,O,Te,Se){return q(y,O,Te,Si(Si({},Se),{sourceId:O.id}))}}),ee%Math.max(1,Math.floor(90/c))===0&&U.push({x:S.x,y:S.y});return U}var pn=function(){return pn=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},pn.apply(this,arguments)},Wt=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Nt=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},Ci=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},cl=function(e,t,n){return Math.max(t,Math.min(n,e))},Rn=function(e,t){return Math.hypot(t.x-e.x,t.y-e.y)};function hl(e){var t=e.id,n=e.nodes,a=e.edges,l=e.gates,i=l===void 0?[]:l,v=e.onEvent,c=v===void 0?function(){}:v,P=new Map(n.map(function(b){return[b.id,pn({},b)]})),f=new Map(a.map(function(b){return[b.id,pn({speedScale:1,enabled:!0,bidirectional:!1,cost:0},b)]})),w=new Map(i.map(function(b){return[b.id,pn({},b)]})),S=new Map,W=S,re=0,U=0,G=function(b){return P.get(b)},oe=function(b){return Nt([],Wt(w.values()),!1).find(function(K){return K.parameters.nodeId===b})},q=function(b){var K=b.parameters;if(K.mode==="open")return!0;if(K.mode==="closed")return!1;var D=K.openSeconds+K.closedSeconds,le=(re+K.phaseOffsetSeconds)%D;return le<K.openSeconds},ee=function(b){return Nt([],Wt(f.values()),!1).filter(function(K){return K.enabled&&(K.from===b||K.bidirectional&&K.to===b)}).sort(function(K,D){return K.id<D.id?-1:K.id>D.id?1:0})},y=function(b,K){return Nt([],Wt(f.values()),!1).find(function(D){return D.enabled&&(D.from===b&&D.to===K||D.bidirectional&&D.from===K&&D.to===b)})};function O(b,K){var D,le,Q,fe;if(b===K)return[b];for(var _=new Map([[b,0]]),j=new Map,se=new Set([b]);se.size;){var ye=Nt([],Wt(se),!1).sort(function(Lr,zr){return _.get(Lr)-_.get(zr)||(Lr<zr?-1:Lr>zr?1:0)})[0];if(se.delete(ye),ye===K)break;try{for(var H=(D=void 0,Ci(ee(ye))),de=H.next();!de.done;de=H.next()){var ze=de.value,Ae=ze.from===ye?ze.to:ze.from,ce=oe(Ae),$e=G(Ae),je=ce?ce.parameters.holdSeconds*90+(q(ce)?0:ce.parameters.closedSeconds*90):0,lr=_.get(ye)+Rn(G(ye),$e)/ze.speedScale+ze.cost+((Q=$e.cost)!==null&&Q!==void 0?Q:0)+je;lr>=((fe=_.get(Ae))!==null&&fe!==void 0?fe:1/0)||(_.set(Ae,lr),j.set(Ae,ye),se.add(Ae))}}catch(Lr){D={error:Lr}}finally{try{de&&!de.done&&(le=H.return)&&le.call(H)}finally{if(D)throw D.error}}}if(!_.has(K))return[];for(var Sr=[K],Tr=K;Tr!==b;)Tr=j.get(Tr),Sr.unshift(Tr);return Sr}function Te(b){var K,D=b.route.length>=2&&b.segment<b.route.length-1;if(!D){var le=(K=b.route[Math.min(b.segment,b.route.length-1)])!==null&&K!==void 0?K:b.startNode,Q=O(le,b.target);b.route=Q.length?Q:[le],b.segment=0,b.distance=0,b.arrived=!1,b.active=b.route.length>=2;return}var fe=b.route[b.segment],_=b.route[b.segment+1],j=Rn(G(fe),G(_));if(b.arrived||b.distance>=j-1e-4){var Q=O(_,b.target);b.route=Q.length?Q:[_],b.segment=0,b.distance=0,b.arrived=!1,b.active=b.route.length>=2;return}var se=O(_,b.target);b.route=se.length?Nt([fe],Wt(se),!1):[fe,_],b.segment=0}function Se(b){var K,D=O(b.startNode,b.targetNode),le=G(b.startNode),Q=D.length>=2?G(D[1]):le,fe=D.length>=2?Math.atan2(Q.y-le.y,Q.x-le.x):0,_=Math.floor((fe%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4,j=pn(pn({},b),{loop:(K=b.loop)!==null&&K!==void 0?K:"none",originNode:b.startNode,destinationNode:b.targetNode,target:b.targetNode,networkId:t,route:D.length?D:[b.startNode],segment:0,distance:0,x:le.x,y:le.y,heading:fe,frame:[0,1,2,3][_],flipX:Math.cos(fe)<0,hold:0,arrived:!1,active:b.active&&D.length>=2,blockedTicks:0,blockedEmitted:!1,speedMultiplier:1});return S.set(j.id,j),j}function be(b){if(Le("pathArrive",b,b.target),b.loop==="none"){b.active=!1;return}var K=b.target,D=b.loop==="ping-pong"?K===b.destinationNode?b.originNode:b.destinationNode:K===b.originNode?b.destinationNode:b.originNode;b.startNode=K,b.target=D,b.route=O(K,D),b.segment=0,b.distance=0,b.arrived=!1,b.route.length<2&&(b.active=!1)}function Le(b,K,D){c(b,{componentId:K.id,nodeId:D})}function Z(b,K){var D,le,Q=b.route[b.segment+1],fe=oe(Q);if(fe&&!q(fe)){b.blockedTicks++,b.blockedTicks>=30&&!b.blockedEmitted&&(b.blockedEmitted=!0,Le("pathBlocked",b,Q));return}if(!b.arrived){if(b.arrived=!0,b.segment+1===b.route.length-1){Q===b.target?be(b):(b.active=!1,b.blockedEmitted||(b.blockedEmitted=!0,Le("pathBlocked",b,Q)));return}b.hold=Math.max((D=G(Q).holdSeconds)!==null&&D!==void 0?D:0,(le=fe==null?void 0:fe.parameters.holdSeconds)!==null&&le!==void 0?le:0)}if(b.hold>0){b.hold=Math.max(0,b.hold-K),b.blockedTicks++,b.blockedTicks>=30&&!b.blockedEmitted&&(b.blockedEmitted=!0,Le("pathBlocked",b,Q));return}b.segment++,b.distance=0,b.arrived=!1,b.blockedTicks=0,b.blockedEmitted=!1}function ve(b,K){var D,le;if(b.spacing<=0)return K;var Q=b.route[b.segment],fe=b.route[b.segment+1],_=Rn(G(Q),G(fe)),j=_-b.distance,se=K;try{for(var ye=Ci(W.values()),H=ye.next();!H.done;H=ye.next()){var de=H.value;if(!(de.id===b.id||!de.active||de.route.length<2||de.segment>=de.route.length-1)){var ze=de.route[de.segment],Ae=de.route[de.segment+1],ce=1/0;if(ze===Q&&Ae===fe&&(de.distance>b.distance||de.distance===b.distance&&de.id<b.id))ce=de.distance-b.distance;else if(ze===fe)ce=j+de.distance;else if(Ae===fe&&ze!==Q){var $e=Rn(G(ze),G(Ae))-de.distance;$e<b.spacing&&($e<j||$e===j&&de.id<b.id)&&(ce=j)}ce<1/0&&(se=Math.min(se,Math.max(0,ce-b.spacing)))}}}catch(je){D={error:je}}finally{try{H&&!H.done&&(le=ye.return)&&le.call(ye)}finally{if(D)throw D.error}}return se}function ae(b){var K=G(b.route[b.segment]),D=G(b.route[b.segment+1]),le=Rn(K,D),Q=cl(b.distance/Math.max(1e-4,le),0,1),fe=K.x+(D.x-K.x)*Q,_=K.y+(D.y-K.y)*Q,j=Math.atan2(D.y-K.y,D.x-K.x),se=Math.min(b.cornerRadius,le/3),ye=b.route[b.segment+2];if(se>0&&ye){var H=G(ye),de=Rn(D,H),ze=Math.min(se,de/3);if(b.distance>le-se){var Ae={x:D.x-(D.x-K.x)/le*se,y:D.y-(D.y-K.y)/le*se},ce={x:D.x+(H.x-D.x)/de*ze,y:D.y+(H.y-D.y)/de*ze},$e=cl((b.distance-(le-se))/(se*2),0,.5),je=1-$e;fe=je*je*Ae.x+2*je*$e*D.x+$e*$e*ce.x,_=je*je*Ae.y+2*je*$e*D.y+$e*$e*ce.y;var lr=2*je*(D.x-Ae.x)+2*$e*(ce.x-D.x),Sr=2*je*(D.y-Ae.y)+2*$e*(ce.y-D.y);Math.abs(lr)+Math.abs(Sr)>.001&&(j=Math.atan2(Sr,lr))}}return{x:fe,y:_,heading:j}}function me(b){var K,D,le,Q;re+=b,U++;var fe=Nt([],Wt(S.values()),!1).sort(function(pt,_e){return pt.id<_e.id?-1:pt.id>_e.id?1:0}),_=fe.length?U%fe.length:0,j=Nt(Nt([],Wt(fe.slice(_)),!1),Wt(fe.slice(0,_)),!1);try{for(var se=Ci(j),ye=se.next();!ye.done;ye=se.next()){var H=ye.value;if(!(!H.active||H.route.length<2||H.segment>=H.route.length-1)){var de=H.route[H.segment],ze=H.route[H.segment+1],Ae=Rn(G(de),G(ze));if(!(H.distance>=Ae-1e-4&&(Z(H,b),!H.active||H.route.length<2||H.segment>=H.route.length-1))){var ce=H.route[H.segment],$e=H.route[H.segment+1],je=Rn(G(ce),G($e)),lr=je-H.distance,Sr=(Q=(le=y(ce,$e))===null||le===void 0?void 0:le.speedScale)!==null&&Q!==void 0?Q:1,Tr=Math.min(lr,H.speed*Sr*Math.max(0,H.speedMultiplier)*b),Lr=ve(H,Tr);Lr<=1e-4?(H.blockedTicks++,H.blockedTicks>=30&&!H.blockedEmitted&&(H.blockedEmitted=!0,Le("pathBlocked",H,$e))):(H.distance+=Lr,H.blockedTicks=0,H.blockedEmitted=!1);var zr=ae(H);H.x=zr.x,H.y=zr.y,H.heading=zr.heading;var Rt=Math.floor((H.heading%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4;H.frame=[0,1,2,3][Rt],H.flipX=Math.cos(H.heading)<0}}}}catch(pt){K={error:pt}}finally{try{ye&&!ye.done&&(D=se.return)&&D.call(se)}finally{if(K)throw K.error}}}function R(){return{id:t,nodeCount:P.size,edgeCount:f.size,activeAgents:Nt([],Wt(S.values()),!1).filter(function(b){return b.active}).length,queuedAgents:Nt([],Wt(S.values()),!1).filter(function(b){return b.active&&b.blockedTicks>0}).length,agents:Nt([],Wt(S.values()),!1).map(function(b){var K;return{id:b.id,x:b.x,y:b.y,heading:b.heading,frame:(K=b.frame)!==null&&K!==void 0?K:0,flipX:!!b.flipX,active:b.active,targetNode:b.target,route:Nt([],Wt(b.route),!1),segment:b.segment,distance:b.distance,blocked:b.blockedTicks>0}})}}return{addAgent:Se,removeAgent:function(b){return S.delete(b)},getAgent:function(b){return S.get(b)},setTarget:function(b,K){var D=S.get(b);return!D||!G(K)?!1:(D.target=K,D.destinationNode=K,D.active=!0,Te(D),!0)},setEdge:function(b,K,D){var le,Q,fe=f.get(b);if(!fe)return!1;fe.enabled=K,D!==void 0&&(fe.cost=D);try{for(var _=Ci(S.values()),j=_.next();!j.done;j=_.next()){var se=j.value;Te(se)}}catch(ye){le={error:ye}}finally{try{j&&!j.done&&(Q=_.return)&&Q.call(_)}finally{if(le)throw le.error}}return!0},setGate:function(b,K,D){var le,Q,fe=w.get(b);if(!fe)return!1;fe.parameters=pn(pn({},fe.parameters),{mode:K,holdSeconds:D});try{for(var _=Ci(S.values()),j=_.next();!j.done;j=_.next()){var se=j.value;Te(se)}}catch(ye){le={error:ye}}finally{try{j&&!j.done&&(Q=_.return)&&Q.call(_)}finally{if(le)throw le.error}}return!0},tick:me,snapshot:R}}var Pi=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},aa=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},oa=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},la={A:["01110","10001","10001","11111","10001","10001","10001"],B:["11110","10001","10001","11110","10001","10001","11110"],C:["01111","10000","10000","10000","10000","10000","01111"],D:["11110","10001","10001","10001","10001","10001","11110"],E:["11111","10000","10000","11110","10000","10000","11111"],F:["11111","10000","10000","11110","10000","10000","10000"],G:["01111","10000","10000","10111","10001","10001","01111"],H:["10001","10001","10001","11111","10001","10001","10001"],I:["11111","00100","00100","00100","00100","00100","11111"],J:["00111","00010","00010","00010","10010","10010","01100"],K:["10001","10010","10100","11000","10100","10010","10001"],L:["10000","10000","10000","10000","10000","10000","11111"],M:["10001","11011","10101","10101","10001","10001","10001"],N:["10001","11001","10101","10011","10001","10001","10001"],O:["01110","10001","10001","10001","10001","10001","01110"],P:["11110","10001","10001","11110","10000","10000","10000"],Q:["01110","10001","10001","10001","10101","10010","01101"],R:["11110","10001","10001","11110","10100","10010","10001"],S:["01111","10000","10000","01110","00001","00001","11110"],T:["11111","00100","00100","00100","00100","00100","00100"],U:["10001","10001","10001","10001","10001","10001","01110"],V:["10001","10001","10001","10001","10001","01010","00100"],W:["10001","10001","10001","10101","10101","10101","01010"],X:["10001","10001","01010","00100","01010","10001","10001"],Y:["10001","10001","01010","00100","00100","00100","00100"],Z:["11111","00001","00010","00100","01000","10000","11111"],0:["01110","10001","10011","10101","11001","10001","01110"],1:["00100","01100","00100","00100","00100","00100","01110"],2:["01110","10001","00001","00010","00100","01000","11111"],3:["11110","00001","00001","01110","00001","00001","11110"],4:["00010","00110","01010","10010","11111","00010","00010"],5:["11111","10000","10000","11110","00001","00001","11110"],6:["01110","10000","10000","11110","10001","10001","01110"],7:["11111","00001","00010","00100","01000","01000","01000"],8:["01110","10001","10001","01110","10001","10001","01110"],9:["01110","10001","10001","01111","00001","00001","01110"],"!":["00100","00100","00100","00100","00100","00000","00100"],"?":["01110","10001","00001","00010","00100","00000","00100"],".":["00000","00000","00000","00000","00000","00110","00110"],",":["00000","00000","00000","00000","00110","00110","00100"],":":["00000","00110","00110","00000","00110","00110","00000"],"+":["00000","00100","00100","11111","00100","00100","00000"],"-":["00000","00000","00000","11111","00000","00000","00000"],"/":["00001","00010","00010","00100","01000","01000","10000"],"'":["00100","00100","00000","00000","00000","00000","00000"]," ":["000","000","000","000","000","000","000"]},Ti=function(e){var t,n,a,l,i=0;try{for(var v=Pi(e),c=v.next();!c.done;c=v.next()){var P=c.value;i+=((l=(a=la[P])===null||a===void 0?void 0:a[0].length)!==null&&l!==void 0?l:5)+1}}catch(f){t={error:f}}finally{try{c&&!c.done&&(n=v.return)&&n.call(v)}finally{if(t)throw t.error}}return Math.max(0,i-1)},Df=function(e,t){var n,a,l=[],i="";try{for(var v=Pi(e),c=v.next();!c.done;c=v.next()){var P=c.value;i&&Ti(i+P)>t&&(l.push(i),i=""),i+=P}}catch(f){n={error:f}}finally{try{c&&!c.done&&(a=v.return)&&a.call(v)}finally{if(n)throw n.error}}return i&&l.push(i),l};function Hf(e,t,n){var a,l,i,v,c;n===void 0&&(n=1);var P=Math.max(1,Math.floor(t/Math.max(1,n))),f=[];try{for(var w=Pi(String(e).toUpperCase().split(`
2
+ `)),S=w.next();!S.done;S=w.next()){var W=S.value,re=W.split(/\s+/).filter(Boolean);if(!re.length){f.push("");continue}var U="";try{for(var G=(i=void 0,Pi(re)),oe=G.next();!oe.done;oe=G.next()){var q=oe.value;if(Ti(q)>P){U&&f.push(U);var ee=Df(q,P);f.push.apply(f,oa([],aa(ee.slice(0,-1)),!1)),U=(c=ee.at(-1))!==null&&c!==void 0?c:""}else{var y=U?U+" "+q:q;Ti(y)<=P?U=y:(U&&f.push(U),U=q)}}}catch(O){i={error:O}}finally{try{oe&&!oe.done&&(v=G.return)&&v.call(G)}finally{if(i)throw i.error}}U&&f.push(U)}}catch(O){a={error:O}}finally{try{S&&!S.done&&(l=w.return)&&l.call(w)}finally{if(a)throw a.error}}return f}var yl=function(e){var t,n=Math.max(0,(t=e.padding)!==null&&t!==void 0?t:4),a=e.pixelPanel&&e.padding===void 0;return{x:a?8:n,y:a?4:n}},Ff=function(e,t,n,a){var l,i=t.wrap===!1?String(e).toUpperCase().split(`
3
+ `):Hf(e,a,n),v=i.slice(0,16),c=Math.round(n*8*((l=t.lineHeight)!==null&&l!==void 0?l:1.2));return{allLines:i,lines:v,renderedWidth:Math.max.apply(Math,oa([0],aa(v.map(function(P){return Ti(P)*n})),!1)),renderedHeight:(v.length-1)*c+7*n}};function _a(e,t){for(var n,a=yl(t),l=Math.max(0,t.width-2*a.x),i=Math.max(0,t.height-2*a.y),v=Math.max(1,Math.floor(t.fontSize/8)),c=t.autoFit===!1?v:Math.min(v,Math.max(1,Math.ceil(((n=t.minFontSize)!==null&&n!==void 0?n:12)/8))),P=oa([],aa(new Set(oa([],aa(String(e).toUpperCase()),!1).filter(function(U){return U!==`
4
+ `&&!la[U]}))),!1),f,w=v;w>=c;w--){var S=Ff(e,t,w,l),W=S.renderedWidth>l,re=S.allLines.length>16||S.renderedHeight>i;if(f={lines:S.lines,scale:w,fontSize:w*8,renderedWidth:S.renderedWidth,renderedHeight:S.renderedHeight,overflowsWidth:W,overflowsHeight:re,unsupportedChars:P},t.autoFit===!1||!W&&!re)break}return f}function pl(e,t,n){var a,l=_a(t,n),i=l.lines,v=l.scale,c=yl(n),P=Math.max(0,n.width-2*c.x),f=Math.max(0,n.height-2*c.y),w=Math.round(l.fontSize*((a=n.lineHeight)!==null&&a!==void 0?a:1.2)),S=c.y+(f-l.renderedHeight)/2;return e.fillStyle=n.color,i.forEach(function(W,re){var U,G,oe,q=Ti(W)*v,ee=n.align==="left"?c.x:n.align==="right"?n.width-q-c.x:c.x+(P-q)/2,y=ee;try{for(var O=Pi(W),Te=O.next();!Te.done;Te=O.next()){var Se=Te.value,be=(oe=la[Se])!==null&&oe!==void 0?oe:la["?"];be.forEach(function(Le,Z){for(var ve=0;ve<Le.length;ve++)Le[ve]==="1"&&e.fillRect(Math.round(y+ve*v),Math.round(S+re*w+Z*v),v,v)}),y+=(be[0].length+1)*v}}catch(Le){U={error:Le}}finally{try{Te&&!Te.done&&(G=O.return)&&G.call(O)}finally{if(U)throw U.error}}}),l}var on=function(){return on=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},on.apply(this,arguments)},ro=Math.PI*2,Pr=function(e,t){return((Math.imul(e+1,2654435769)^Math.imul(t,2246822507))>>>0)/4294967296};function to(e,t,n){var a,l,i=[e.color,e.color2,e.color3].filter(Boolean),v=((a=e.spread)!==null&&a!==void 0?a:360)*Math.PI/180,c=((l=e.direction)!==null&&l!==void 0?l:-90)*Math.PI/180;return Array.from({length:e.count},function(P,f){var w,S,W=c+((f+.2+Pr(f,1)*.6)/e.count-.5)*v,re=e.speed*(.42+.65*Pr(f,2));return on(on({},t),{clipId:n,shape:"pixel-confetti",age:-.12*Pr(f,3),vx:Math.cos(W)*re,vy:Math.sin(W)*re,gravity:(w=e.gravity)!==null&&w!==void 0?w:250,life:((S=e.lifetime)!==null&&S!==void 0?S:.7)*(.6+.4*Pr(f,4)),color:i[f%i.length],size:3+Math.floor(3*Pr(f,5)),angle:ro*Pr(f,6),spin:(Pr(f,7)-.5)*12})})}function ml(e){var t=Math.min(12,Math.ceil(Math.sqrt(e.count))),n=Math.ceil(e.count/t),a=e.speed;return to(e).map(function(l,i){return on(on({},l),{screen:!0,x:(i%t+.15+.7*Pr(i,8))/t,y:(Math.floor(i/t)+.15+.7*Pr(i,9))/n,vx:a*(Pr(i,10)-.5)*.7,vy:a*(.3+.5*Pr(i,11)),size:l.size+1})})}var da=function(e,t){return(e%t+t)%t};function gl(e,t,n){var a=t.x,l=t.y,i=t.vx,v=t.vy,c=t.age,P=t.life,f=t.gravity,w=t.size,S=t.angle,W=t.spin,re=t.color;if(!(c<0)){var U=i*c,G=v*c+f*c*c/2,oe=Math.round(n?n.x+da(a*n.width+U,n.width):a+U),q=Math.round(n?n.y+da(l*n.height+G,n.height):l+G),ee=Math.round((S+W*c)/(Math.PI/4))&3;if(e.globalAlpha*=Math.min(1,(P-c)*4),e.fillStyle="#3c293388",ee===0)e.fillRect(oe-w+1,q+1,w*2+1,w+1);else if(ee===2)e.fillRect(oe+1,q-w+1,w+1,w*2+1);else for(var y=-1;y<=1;y++)e.fillRect(oe+y*w+1,q+y*w*(ee===1?1:-1)+1,w+1,w+1);if(e.fillStyle=re,ee===0)e.fillRect(oe-w,q,w*2,w);else if(ee===2)e.fillRect(oe,q-w,w,w*2);else for(var y=-1;y<=1;y++)e.fillRect(oe+y*w,q+y*w*(ee===1?1:-1),w,w)}}function no(e,t,n){var a,l,i=[e.color,e.color2,e.color3,"#ff6b6b","#4ecdc4","#fff3b0"].filter(Boolean),v=((a=e.spread)!==null&&a!==void 0?a:360)*Math.PI/180,c=((l=e.direction)!==null&&l!==void 0?l:-90)*Math.PI/180;return Array.from({length:e.count},function(P,f){var w,S,W=c+((f+.2+Pr(f,11)*.6)/e.count-.5)*v,re=e.speed*(.45+.65*Pr(f,12));return on(on({},t),{clipId:n,shape:"confetti",age:-.15*Pr(f,13),vx:Math.cos(W)*re,vy:Math.sin(W)*re,gravity:(w=e.gravity)!==null&&w!==void 0?w:140,life:((S=e.lifetime)!==null&&S!==void 0?S:2.6)*(.75+.35*Pr(f,14)),color:i[f%i.length],size:5+Math.floor(5*Pr(f,15)),kind:f%5===0?"star":"ribbon",angle:ro*Pr(f,16),spin:(Pr(f,17)-.5)*5.5,flutter:1.6+2.2*Pr(f,18),phase:ro*Pr(f,19)})})}function xl(e){var t=Math.min(14,Math.ceil(Math.sqrt(e.count))),n=Math.ceil(e.count/t),a=e.speed;return no(e,{x:0,y:0}).map(function(l,i){var v;return on(on({},l),{screen:!0,x:(i%t+.12+.76*Pr(i,20))/t,y:(Math.floor(i/t)+.08+.84*Pr(i,21))/n,vx:a*(Pr(i,22)-.5)*.65,vy:a*(.38+.55*Pr(i,23)),gravity:Math.min((v=e.gravity)!==null&&v!==void 0?v:90,90)})})}function Il(e,t,n){var a=t.x,l=t.y,i=t.vx,v=t.vy,c=t.age,P=t.life,f=t.gravity,w=t.size,S=t.angle,W=t.spin,re=t.flutter,U=t.phase,G=t.color,oe=t.kind;if(!(c<0)){var q=Math.sin(c*re+U)*14,ee=i*c+q,y=v*c+f*c*c/2,O=n?n.x+da(a*n.width+ee,n.width):a+ee,Te=n?n.y+da(l*n.height+y,n.height):l+y,Se=Math.min(1,c*2.8,(P-c)*2.2);if(!(Se<=0)){e.save(),e.globalAlpha*=Se,e.translate(O,Te),e.rotate(S+W*c);var be=Math.cos(c*re*1.4+U);if(e.scale(1,Math.max(.22,Math.abs(be))),e.fillStyle=G,oe==="star"){var Le=w*.85;e.beginPath();for(var Z=0;Z<8;Z++){var ve=Z%2===0?Le:Le*.38,ae=Z*Math.PI/4;Z===0?e.moveTo(Math.cos(ae)*ve,Math.sin(ae)*ve):e.lineTo(Math.cos(ae)*ve,Math.sin(ae)*ve)}e.closePath(),e.fill()}else e.fillRect(-w*.7,-w*.34,w*1.4,w*.68),e.fillStyle="#ffffff55",e.fillRect(-w*.7,-w*.34,w*1.4,w*.2);e.restore()}}}function bl(e,t,n,a,l){var i=t.width,v=t.height;if(!(i<=0||v<=0)){var c=Math.min(3,Math.floor(Math.min(i,v)/8));if(!c){e.fillStyle=n,e.fillRect(0,0,i,v);return}var P=a?c*2:0,f=v-(a?c:c*3),w=l>=0?.5+.5*Math.sin(l*4):0;t.enabled&&!a&&l>=0&&(e.save(),e.shadowColor="#ffd05a99",e.shadowBlur=8+w*9,e.fillStyle=n,e.fillRect(c,P+c,i-2*c,v-P-2*c),e.restore()),e.fillStyle=t.stroke,e.fillRect(c,0,i-2*c,v),e.fillRect(0,c,i,v-2*c),e.fillStyle=n,e.fillRect(c,P+c,i-2*c,v-P-2*c),e.fillStyle="#431d1380",e.fillRect(c,f,i-2*c,v-c-f),e.fillStyle=t.enabled?"#fff4be":"#ffffff55",e.fillRect(2*c,P+c,i-4*c,a?c:c*2),e.fillStyle="#ffffff55",e.fillRect(c,P+3*c,c,Math.max(0,f-P-3*c)),e.fillStyle="#521b2444",e.fillRect(i-2*c,P+3*c,c,Math.max(0,f-P-3*c));var S=l>=0?l%1.9:-1,W=(S-.1)/.55;if(t.enabled&&!a&&W>=0&&W<1){e.save(),e.beginPath(),e.rect(2*c,P+3*c,i-4*c,Math.max(0,f-P-3*c)),e.clip();for(var re=Math.floor(((i+14*c)*W-6*c)/c)*c,U=P+3*c,G=0;U<f;U+=c,G++){var oe=re-Math.floor(G/2)*c;e.fillStyle="#fff4be44",e.fillRect(oe-2*c,U,9*c,c),e.fillStyle="#fffef0aa",e.fillRect(oe,U,4*c,c)}e.restore()}if(t.enabled&&!a&&l>=0){var q=Math.max(0,Math.sin(l*4.2)),ee=Math.max(0,Math.sin(l*4.2+2.2)),y=function(O,Te,Se){if(!(Se<.25)){e.save(),e.globalAlpha*=Se*.95,e.fillStyle="#fffef4";var be=Se>.65?c*2:c;e.fillRect(Math.round(O-be),Math.round(Te-c/2),be*2+c,c),e.fillRect(Math.round(O-c/2),Math.round(Te-be),c,be*2+c),e.restore()}};y(5*c,P+4*c,q),y(i-6*c,P+5*c,ee)}}}function fa(e,t,n,a,l,i){var v=Math.max(0,Math.min(i,a/2,l/2));e.beginPath(),typeof e.roundRect=="function"?e.roundRect(t,n,a,l,v):(e.moveTo(t+v,n),e.arcTo(t+a,n,t+a,n+l,v),e.arcTo(t+a,n+l,t,n+l,v),e.arcTo(t,n+l,t,n,v),e.arcTo(t,n,t+a,n,v),e.closePath())}function eo(e,t,n,a,l){if(!(l<=.02||a<=.5)){e.save(),e.translate(t,n),e.globalAlpha*=l,e.fillStyle="#fffef0",e.beginPath();for(var i=0;i<8;i++){var v=i%2===0?a:a*.24,c=i*Math.PI/4;i===0?e.moveTo(Math.cos(c)*v,Math.sin(c)*v):e.lineTo(Math.cos(c)*v,Math.sin(c)*v)}e.closePath(),e.fill(),e.restore()}}function wl(e,t,n,a,l){var i,v,c,P=t.width,f=t.height;if(!(P<=0||f<=0)){var w=Math.min((i=t.radius)!==null&&i!==void 0?i:16,P/2,f/2),S=a?2:6,W=a?3:0,re=l>=0?.5-.5*Math.cos(l*2.4):0;t.enabled&&!a&&l>=0&&(e.save(),e.shadowColor="#ffd23f99",e.shadowBlur=10+re*12,fa(e,0,W,P,f-W,w),e.fillStyle=n,e.fill(),e.restore()),e.save(),fa(e,0,W+2,P,Math.max(4,f-W-2),w),e.fillStyle="#0e2830",e.fill(),e.restore(),e.save(),fa(e,0,W,P,Math.max(4,f-S),w),e.fillStyle=n,e.fill(),e.clip();var U=(v=e.createLinearGradient)===null||v===void 0?void 0:v.call(e,0,W,0,f-S);if(U!=null&&U.addColorStop&&(U.addColorStop(0,"#ffffffa8"),U.addColorStop(.42,"#ffffff26"),U.addColorStop(.45,"#00000000"),U.addColorStop(1,"#00000024"),e.fillStyle=U,e.fillRect(0,W,P,f-S)),e.fillStyle="#fffef0bb",e.fillRect(w*.55,W+3,Math.max(0,P-w*1.1),3),t.enabled&&!a&&l>=0){var G=(l%2.4-.15)/.95;if(G>0&&G<1){var oe=G*G*(3-2*G),q=Math.sin(G*Math.PI),ee=-P*.36+P*1.72*oe;e.save(),e.globalAlpha*=q,e.translate(ee,W),e.transform(1,0,-.36,1,0,0);var y=(c=e.createLinearGradient)===null||c===void 0?void 0:c.call(e,-48,0,48,0);y!=null&&y.addColorStop?(y.addColorStop(0,"#ffffff00"),y.addColorStop(.32,"#ffffff48"),y.addColorStop(.5,"#fffef8cc"),y.addColorStop(.68,"#ffffff48"),y.addColorStop(1,"#ffffff00"),e.fillStyle=y,e.fillRect(-48,0,96,f)):(e.fillStyle="#fffef8a8",e.fillRect(-14,0,28,f)),e.restore()}}if(e.restore(),t.strokeWidth&&(e.save(),fa(e,0,W,P,Math.max(4,f-S),w),e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,e.stroke(),e.restore()),t.enabled&&!a&&l>=0){var O=Math.max(0,Math.sin(l*2.4)),Te=O*O,Se=Math.max(0,Math.sin(l*2.4+2.1)),be=Se*Se,Le=Math.max(0,Math.sin(l*2.4+4.2)),Z=Le*Le;eo(e,P*.12,W+9,4+Te*6,Te*.92),eo(e,P*.88,W+10,3.8+be*5.5,be*.9),eo(e,P*.76,Math.max(W+14,f-S-8),3+Z*4.2,Z*.8)}}}function ua(e){if(/\s/.test(e)||e.length>512)return!1;var t=/^https:\/\/play\.google\.com\/store\/apps\/details\?id=[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*){1,9}$/,n=/^https:\/\/apps\.apple\.com\/([a-z]{2}\/)?app\/([a-zA-Z0-9-]+\/)?id[1-9][0-9]{5,19}$/;return t.test(e)&&!/id=example\.|[.=]placeholder(\.|$)|id=com\.example(\.|$)/.test(e)||n.test(e)}var Ei=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ai=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},io=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))};function Ml(e){var t,n,a;e===void 0&&(e={});var l=(t=e.timeoutMs)!==null&&t!==void 0?t:5e3,i=(n=e.pollMs)!==null&&n!==void 0?n:25;if(![l,i].every(function(Q){return Number.isFinite(Q)&&Q>=1&&Q<=6e4}))throw Error("Invalid Unity host deadline/poll interval");var v=(a=e.getHost)!==null&&a!==void 0?a:(function(){return window.mraid}),c=new Set,P=new Set,f=[],w={},S=!1,W=!1,re=!1,U=!1,G=!1,oe=!1,q,ee,y,O,Te,Se,be=function(){return re||U};function Le(){var Q,fe,_;clearTimeout(Te),clearTimeout(Se);try{for(var j=Ei(f.splice(0)),se=j.next();!se.done;se=j.next()){var ye=Ai(se.value,2),H=ye[0],de=ye[1];try{(_=w.mraid)===null||_===void 0||_.removeEventListener(H,de)}catch{}}}catch(ze){Q={error:ze}}finally{try{se&&!se.done&&(fe=j.return)&&fe.call(j)}finally{if(Q)throw Q.error}}}function Z(Q){O==null||O(Q instanceof Error?Q:Error(String(Q))),y=void 0,O=void 0}function ve(Q){var fe,_;if(!be()){var j=S;if(re=!0,S=!1,W=!1,Le(),Z(Q),j)try{for(var se=Ei(io([],Ai(P),!1)),ye=se.next();!ye.done;ye=se.next()){var H=ye.value;H()}}catch(de){fe={error:de}}finally{try{ye&&!ye.done&&(_=se.return)&&_.call(se)}finally{if(fe)throw fe.error}}c.clear(),P.clear()}}function ae(Q,fe){return f.push([Q,fe]),w.mraid.addEventListener(Q,fe),me(Q,fe)}function me(Q,fe){if(be()){try{w.mraid.removeEventListener(Q,fe)}catch{}return!1}return!0}function R(Q){var fe,_;if(!be()){if(typeof Q!="boolean"){ve(Error("Invalid Unity viewability event"));return}if(!S){q=Q;return}if(W!==Q){W=Q;try{for(var j=Ei(io([],Ai(c),!1)),se=j.next();!se.done;se=j.next()){var ye=se.value;if(be())break;ye(W)}}catch(H){fe={error:H}}finally{try{se&&!se.done&&(_=j.return)&&_.call(j)}finally{if(fe)throw fe.error}}}}}var b=function(Q){Q==="hidden"&&ve(Error("Unity host closed"))},K=function(){var Q;S&&!be()&&((Q=e.onResize)===null||Q===void 0||Q.call(e))};function D(){var Q,fe,_,j;if(!(!G||S||oe||be())){oe=!0;try{var se=w.mraid.getState();if(be()||se==="loading")return;if(se==="hidden")throw Error("Unity host closed before ready");if(!["default","expanded","resized"].includes(se))throw Error("Invalid Unity host state");var ye=w.mraid.getVersion();if(be())return;if(ye!=="3.0")throw Error("Unity Ads UA requires MRAID 3.0");try{for(var H=Ei([["viewableChange",R],["stateChange",b],["sizeChange",K]]),de=H.next();!de.done;de=H.next()){var ze=Ai(de.value,2),Ae=ze[0],ce=ze[1];if(!ae(Ae,ce))return}}catch(Tr){Q={error:Tr}}finally{try{de&&!de.done&&(fe=H.return)&&fe.call(H)}finally{if(Q)throw Q.error}}var $e=w.mraid.isViewable();if(be())return;if(typeof $e!="boolean")throw Error("Invalid Unity initial viewability");W=q!=null?q:$e,S=!0,clearTimeout(Te),clearTimeout(Se),y==null||y(),y=void 0,O=void 0;try{for(var je=Ei(io([],Ai(c),!1)),lr=je.next();!lr.done;lr=je.next()){var Sr=lr.value;if(be())break;Sr(W)}}catch(Tr){_={error:Tr}}finally{try{lr&&!lr.done&&(j=je.return)&&j.call(je)}finally{if(_)throw _.error}}}catch(Tr){ve(Tr)}finally{oe=!1}}}function le(){if(!be())try{var Q=v();if(be())return;if(!Q){Se=setTimeout(le,i);return}if(w.mraid=Q,f.push(["ready",D]),w.mraid.addEventListener("ready",D),!me("ready",D))return;G=!0,D()}catch(fe){ve(fe)}}return{init:function(){return ee||(ee=new Promise(function(Q,fe){y=Q,O=fe}),be()?(Z(Error("Unity bridge destroyed")),ee):(Te=setTimeout(function(){return ve(Error("Unity MRAID readiness timed out"))},l),le(),ee))},isReady:function(){return S&&!be()},isVisible:function(){return S&&W&&!be()},isClosed:be,onVisibilityChanged:function(Q){return be()||c.add(Q),function(){return c.delete(Q)}},onClosed:function(Q){return be()||P.add(Q),function(){return P.delete(Q)}},openStore:function(Q){if(!S||!W||be()||!ua(Q))throw Error("Unity store request not permitted");w.mraid.open(Q)},destroy:function(){U||(U=!0,S=!1,W=!1,Le(),Z(Error("Unity bridge destroyed")),c.clear(),P.clear())}}}var ai=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},oi=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},ao=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))};function kl(e){var t;e===void 0&&(e={});var n=(t=e.getHost)!==null&&t!==void 0?t:(function(){return window.mraid}),a,l=!1,i=!1,v=!1,c=!1,P=!1,f,w,S,W,re,U=new Set,G=new Set,oe=[];function q(){var ae,me;clearTimeout(W),clearTimeout(re);try{for(var R=ai(oe.splice(0)),b=R.next();!b.done;b=R.next()){var K=oi(b.value,2),D=K[0],le=K[1];try{a==null||a.removeEventListener(D,le)}catch{}}}catch(Q){ae={error:Q}}finally{try{b&&!b.done&&(me=R.return)&&me.call(R)}finally{if(ae)throw ae.error}}}function ee(ae,me){if(oe.push([ae,me]),a.addEventListener(ae,me),v||c){try{a.removeEventListener(ae,me)}catch{}return!1}return!0}function y(ae){var me=ae instanceof Error?ae:Error(String(ae));S==null||S(me),w=void 0,S=void 0}function O(ae,me){var R,b;if(!(v||c)&&(v=!0,l=!1,i=!1,q(),y(ae),me))try{for(var K=ai(ao([],oi(G),!1)),D=K.next();!D.done;D=K.next()){var le=D.value;le()}}catch(Q){R={error:Q}}finally{try{D&&!D.done&&(b=K.return)&&b.call(K)}finally{if(R)throw R.error}}}function Te(){var ae,me,R,b;if(!(!P||l||v||c))try{var K=a.getState();if(v||c||K==="loading")return;if(K==="hidden"){O(Error("MRAID closed before ready"),!0);return}if(!["default","expanded","resized"].includes(K))throw Error("Invalid MRAID state");try{for(var D=ai([["viewableChange",be],["stateChange",Le],["sizeChange",Z]]),le=D.next();!le.done;le=D.next()){var Q=oi(le.value,2),fe=Q[0],_=Q[1];if(!ee(fe,_))return}}catch(H){ae={error:H}}finally{try{le&&!le.done&&(me=D.return)&&me.call(D)}finally{if(ae)throw ae.error}}var j=a.isViewable();if(v||c)return;if(typeof j!="boolean")throw Error("Invalid MRAID viewability");i=j,l=!0,clearTimeout(W),clearTimeout(re),w==null||w(),w=void 0,S=void 0;try{for(var se=ai(ao([],oi(U),!1)),ye=se.next();!ye.done;ye=se.next()){var _=ye.value;_(i)}}catch(H){R={error:H}}finally{try{ye&&!ye.done&&(b=se.return)&&b.call(se)}finally{if(R)throw R.error}}}catch(H){O(H,l)}}var Se=function(){return Te()},be=function(ae){var me,R;if(!(!l||v||c)){if(typeof ae!="boolean"){O(Error("Invalid MRAID visibility event"),!0);return}i=ae;try{for(var b=ai(ao([],oi(U),!1)),K=b.next();!K.done;K=b.next()){var D=K.value;D(i)}}catch(le){me={error:le}}finally{try{K&&!K.done&&(R=b.return)&&R.call(b)}finally{if(me)throw me.error}}}},Le=function(ae){ae==="hidden"&&O(Error("MRAID closed"),!0)},Z=function(){var ae;l&&!v&&!c&&((ae=e.onResize)===null||ae===void 0||ae.call(e))};function ve(){var ae,me,R;if(!(v||c))try{if(a=n(),v||c)return;if(!a){re=setTimeout(ve,(R=e.pollMs)!==null&&R!==void 0?R:50);return}if(![a.getState,a.isViewable,a.addEventListener,a.removeEventListener,a.open].every(function(fe){return typeof fe=="function"}))throw Error("Incomplete MRAID 2 interface");try{for(var b=ai([["ready",Se]]),K=b.next();!K.done;K=b.next()){var D=oi(K.value,2),le=D[0],Q=D[1];if(!ee(le,Q))return}}catch(fe){ae={error:fe}}finally{try{K&&!K.done&&(me=b.return)&&me.call(b)}finally{if(ae)throw ae.error}}P=!0,Te()}catch(fe){O(fe,!1)}}return{init:function(){var ae;return f||(f=new Promise(function(me,R){w=me,S=R}),v||c?(y(Error("MRAID bridge destroyed")),f):(W=setTimeout(function(){return O(Error("MRAID readiness timed out"),!1)},(ae=e.timeoutMs)!==null&&ae!==void 0?ae:5e3),ve(),f))},isReady:function(){return l&&!v&&!c},isVisible:function(){return i&&l&&!v&&!c},isClosed:function(){return v||c},onVisibilityChanged:function(ae){return!v&&!c&&U.add(ae),function(){return U.delete(ae)}},onClosed:function(ae){return!v&&!c&&G.add(ae),function(){return G.delete(ae)}},openStore:function(ae){if(!l||!i||v||c||!ua(ae))throw Error("MRAID store request not permitted");a.open(ae)},destroy:function(){c||(c=!0,l=!1,i=!1,q(),y(Error("MRAID bridge destroyed")),U.clear(),G.clear())}}}var Un=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Gn=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Ri=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))};function Sl(e){e===void 0&&(e={});var t=new Set,n=new Set,a=new Set,l=[],i,v=!1,c=!1,P=!1,f=!1,w,S,W,re,U,G=function(){return P||f};function oe(){var Z,ve;clearTimeout(re),clearTimeout(U);try{for(var ae=Un(l.splice(0)),me=ae.next();!me.done;me=ae.next()){var R=Gn(me.value,2),b=R[0],K=R[1];try{i==null||i.removeEventListener(b,K)}catch{}}}catch(D){Z={error:D}}finally{try{me&&!me.done&&(ve=ae.return)&&ve.call(ae)}finally{if(Z)throw Z.error}}}function q(Z){var ve,ae;if(!G()){P=!0,v=!1,c=!1,oe(),W==null||W(Z instanceof Error?Z:Error(String(Z))),S=void 0,W=void 0;try{for(var me=Un(Ri([],Gn(n),!1)),R=me.next();!R.done;R=me.next()){var b=R.value;b()}}catch(K){ve={error:K}}finally{try{R&&!R.done&&(ae=me.return)&&ae.call(me)}finally{if(ve)throw ve.error}}}}var ee=function(Z){if(!(typeof Z!="number"||!Number.isFinite(Z)||Z<0))return Math.min(1,Z>1?Z/100:Z)},y=function(Z){if(typeof Z=="boolean")return Z;if(Z&&typeof Z=="object"&&typeof Z.isViewable=="boolean")return Z.isViewable},O=function(){var Z,ve,ae,me,R,b;if(!(v||G()||!i||((R=i.isReady)===null||R===void 0?void 0:R.call(i))===!1))try{c=i.isViewable();var K=(b=i.getAudioVolume)===null||b===void 0?void 0:b.call(i),D=K===void 0?void 0:ee(K);if(typeof c!="boolean"||K!==void 0&&D===void 0)throw Error("Invalid DAPI initial state");if(v=!0,clearTimeout(re),clearTimeout(U),S==null||S(),S=void 0,W=void 0,D!==void 0)try{for(var le=Un(Ri([],Gn(a),!1)),Q=le.next();!Q.done;Q=le.next()){var fe=Q.value;fe(D)}}catch(se){Z={error:se}}finally{try{Q&&!Q.done&&(ve=le.return)&&ve.call(le)}finally{if(Z)throw Z.error}}try{for(var _=Un(Ri([],Gn(t),!1)),j=_.next();!j.done;j=_.next()){var fe=j.value;fe(c)}}catch(se){ae={error:se}}finally{try{j&&!j.done&&(me=_.return)&&me.call(_)}finally{if(ae)throw ae.error}}}catch(se){q(se)}},Te=function(Z){var ve,ae;if(!G()){var me=y(Z);if(me===void 0){q(Error("Invalid DAPI visibility"));return}c=me;try{for(var R=Un(Ri([],Gn(t),!1)),b=R.next();!b.done;b=R.next()){var K=b.value;K(me)}}catch(D){ve={error:D}}finally{try{b&&!b.done&&(ae=R.return)&&ae.call(R)}finally{if(ve)throw ve.error}}}},Se=function(Z){var ve,ae;if(!G()){var me=ee(Z);if(me===void 0){q(Error("Invalid DAPI volume"));return}try{for(var R=Un(Ri([],Gn(a),!1)),b=R.next();!b.done;b=R.next()){var K=b.value;K(me)}}catch(D){ve={error:D}}finally{try{b&&!b.done&&(ae=R.return)&&ae.call(R)}finally{if(ve)throw ve.error}}}},be=function(){var Z;v&&!G()&&((Z=e.onResize)===null||Z===void 0||Z.call(e))};function Le(){var Z,ve,ae;if(!G()){if(i=window.dapi,!i){U=setTimeout(Le,(ae=e.pollMs)!==null&&ae!==void 0?ae:25);return}try{try{for(var me=Un([["ready",O],["viewableChange",Te],["audioVolumeChange",Se],["adResized",be]]),R=me.next();!R.done;R=me.next()){var b=Gn(R.value,2),K=b[0],D=b[1];l.push([K,D]),i.addEventListener(K,D)}}catch(le){Z={error:le}}finally{try{R&&!R.done&&(ve=me.return)&&ve.call(me)}finally{if(Z)throw Z.error}}O()}catch(le){q(le)}}}return{init:function(){var Z;return w||(w=new Promise(function(ve,ae){S=ve,W=ae}),G()?(W==null||W(Error("DAPI bridge closed")),w):(re=setTimeout(function(){return q(Error("DAPI readiness timed out"))},(Z=e.timeoutMs)!==null&&Z!==void 0?Z:5e3),Le(),w))},isReady:function(){return v&&!G()},isVisible:function(){return v&&c&&!G()},isClosed:G,onVisibilityChanged:function(Z){return G()||t.add(Z),function(){return t.delete(Z)}},onClosed:function(Z){return G()||n.add(Z),function(){return n.delete(Z)}},onVolumeChanged:function(Z){return G()||a.add(Z),function(){return a.delete(Z)}},openStore:function(){if(!v||!c||G()||typeof(i==null?void 0:i.openStoreUrl)!="function")throw Error("DAPI store host unavailable");i.openStoreUrl()},destroy:function(){f||(f=!0,v=!1,c=!1,oe(),W==null||W(Error("DAPI bridge destroyed")),t.clear(),n.clear(),a.clear())}}}var Xf=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(w){try{f(a.next(w))}catch(S){v(S)}}function P(w){try{f(a.throw(w))}catch(S){v(S)}}function f(w){w.done?i(w.value):l(w.value).then(c,P)}f((a=a.apply(e,t||[])).next())})},Uf=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(w){return P([f,w])}}function P(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(w){f=[6,w],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},Gf=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Yf=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},Zf=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Cl(){var e=new Set,t=!1,n=!1,a=!1,l=function(){var i,v;if(!a){n=document.visibilityState!=="hidden";try{for(var c=Zf(Yf([],Gf(e),!1)),P=c.next();!P.done;P=c.next()){var f=P.value;f(n)}}catch(w){i={error:w}}finally{try{P&&!P.done&&(v=c.return)&&v.call(c)}finally{if(i)throw i.error}}}};return{init:function(){return Xf(this,void 0,void 0,function(){return Uf(this,function(i){switch(i.label){case 0:if(a)throw Error("Meta bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(v){return document.addEventListener("DOMContentLoaded",function(){return v()},{once:!0})})];case 1:i.sent(),i.label=2;case 2:if(a)throw Error("Meta bridge destroyed");return document.addEventListener("visibilitychange",l),n=document.visibilityState!=="hidden",t=!0,l(),[2]}})})},isReady:function(){return t&&!a},isVisible:function(){return t&&n&&!a},isClosed:function(){return a},onVisibilityChanged:function(i){return a||e.add(i),function(){return e.delete(i)}},onClosed:function(){return function(){}},openStore:function(){var i=window.FbPlayableAd;if(!t||!n||a||typeof(i==null?void 0:i.onCTAClick)!="function")throw Error("Meta CTA host unavailable");i.onCTAClick()},destroy:function(){a=!0,t=!1,n=!1,document.removeEventListener("visibilitychange",l),e.clear()}}}var $f=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(w){try{f(a.next(w))}catch(S){v(S)}}function P(w){try{f(a.throw(w))}catch(S){v(S)}}function f(w){w.done?i(w.value):l(w.value).then(c,P)}f((a=a.apply(e,t||[])).next())})},Kf=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(w){return P([f,w])}}function P(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(w){f=[6,w],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},Qf=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},Jf=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},qf=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Pl(){var e=new Set,t=!1,n=!1,a=!1,l=function(){var i,v;if(!a){n=document.visibilityState!=="hidden";try{for(var c=qf(Jf([],Qf(e),!1)),P=c.next();!P.done;P=c.next()){var f=P.value;f(n)}}catch(w){i={error:w}}finally{try{P&&!P.done&&(v=c.return)&&v.call(c)}finally{if(i)throw i.error}}}};return{init:function(){return $f(this,void 0,void 0,function(){return Kf(this,function(i){switch(i.label){case 0:if(a)throw Error("Google Ads bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(v){return document.addEventListener("DOMContentLoaded",function(){return v()},{once:!0})})];case 1:i.sent(),i.label=2;case 2:if(a)throw Error("Google Ads bridge destroyed");return document.addEventListener("visibilitychange",l),n=document.visibilityState!=="hidden",t=!0,l(),[2]}})})},isReady:function(){return t&&!a},isVisible:function(){return t&&n&&!a},isClosed:function(){return a},onVisibilityChanged:function(i){return a||e.add(i),function(){return e.delete(i)}},onClosed:function(){return function(){}},openStore:function(){var i=window.ExitApi;if(!t||!n||a||typeof(i==null?void 0:i.exit)!="function")throw Error("Google ExitApi unavailable");i.exit()},destroy:function(){a=!0,t=!1,n=!1,document.removeEventListener("visibilitychange",l),e.clear()}}}var jf=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(w){try{f(a.next(w))}catch(S){v(S)}}function P(w){try{f(a.throw(w))}catch(S){v(S)}}function f(w){w.done?i(w.value):l(w.value).then(c,P)}f((a=a.apply(e,t||[])).next())})},_f=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(w){return P([f,w])}}function P(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(w){f=[6,w],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},oo=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},lo=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},fo=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Tl(){var e=window,t=new Set,n=new Set,a=e.gameStart,l=e.gameClose,i=!1,v=!1,c=!1,P=!1,f=function(){var S,W;if(!(c||P)){var re=!v||!i;if(i=!0,v=!0,re)try{for(var U=fo(lo([],oo(t),!1)),G=U.next();!G.done;G=U.next()){var oe=G.value;oe(!0)}}catch(q){S={error:q}}finally{try{G&&!G.done&&(W=U.return)&&W.call(U)}finally{if(S)throw S.error}}}},w=function(){var S,W,re,U;if(!(c||P)){i=!1,v=!1,c=!0;try{for(var G=fo(lo([],oo(t),!1)),oe=G.next();!oe.done;oe=G.next()){var q=oe.value;q(!1)}}catch(O){S={error:O}}finally{try{oe&&!oe.done&&(W=G.return)&&W.call(G)}finally{if(S)throw S.error}}try{for(var ee=fo(lo([],oo(n),!1)),y=ee.next();!y.done;y=ee.next()){var q=y.value;q()}}catch(O){re={error:O}}finally{try{y&&!y.done&&(U=ee.return)&&U.call(ee)}finally{if(re)throw re.error}}}};return e.gameStart=f,e.gameClose=w,{init:function(){return jf(this,void 0,void 0,function(){return _f(this,function(S){if(c||P)throw Error("Mintegral bridge closed");if(typeof e.gameReady!="function")throw Error("Mintegral gameReady host unavailable");return e.gameReady(),[2]})})},isReady:function(){return i&&!c&&!P},isVisible:function(){return i&&v&&!c&&!P},isClosed:function(){return c||P},onVisibilityChanged:function(S){return!c&&!P&&t.add(S),function(){return t.delete(S)}},onClosed:function(S){return!c&&!P&&n.add(S),function(){return n.delete(S)}},notifyGameEnd:function(){var S;!c&&!P&&((S=e.gameEnd)===null||S===void 0||S.call(e))},notifyGameRetry:function(){var S;!c&&!P&&((S=e.gameRetry)===null||S===void 0||S.call(e))},openStore:function(){if(!i||!v||c||P||typeof e.install!="function")throw Error("Mintegral install host unavailable");e.install()},destroy:function(){P||(P=!0,i=!1,v=!1,e.gameStart===f&&(a?e.gameStart=a:delete e.gameStart),e.gameClose===w&&(l?e.gameClose=l:delete e.gameClose),t.clear(),n.clear())}}}var ed=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(w){try{f(a.next(w))}catch(S){v(S)}}function P(w){try{f(a.throw(w))}catch(S){v(S)}}function f(w){w.done?i(w.value):l(w.value).then(c,P)}f((a=a.apply(e,t||[])).next())})},rd=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(w){return P([f,w])}}function P(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(w){f=[6,w],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},td=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},nd=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},id=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function El(){var e=new Set,t=!1,n=!1,a=!1,l=function(){var i,v;if(!a){n=document.visibilityState!=="hidden";try{for(var c=id(nd([],td(e),!1)),P=c.next();!P.done;P=c.next()){var f=P.value;f(n)}}catch(w){i={error:w}}finally{try{P&&!P.done&&(v=c.return)&&v.call(c)}finally{if(i)throw i.error}}}};return{init:function(){return ed(this,void 0,void 0,function(){return rd(this,function(i){switch(i.label){case 0:if(a)throw Error("TikTok bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(v){return document.addEventListener("DOMContentLoaded",function(){return v()},{once:!0})})];case 1:i.sent(),i.label=2;case 2:if(a)throw Error("TikTok bridge destroyed");return document.addEventListener("visibilitychange",l),n=document.visibilityState!=="hidden",t=!0,l(),[2]}})})},isReady:function(){return t&&!a},isVisible:function(){return t&&n&&!a},isClosed:function(){return a},onVisibilityChanged:function(i){return a||e.add(i),function(){return e.delete(i)}},onClosed:function(){return function(){}},openStore:function(){var i,v,c=window,P=typeof c.openAppStore=="function"?c.openAppStore.bind(c):(v=(i=c.playableSDK)===null||i===void 0?void 0:i.openAppStore)===null||v===void 0?void 0:v.bind(c.playableSDK);if(!t||!n||a||!P)throw Error("TikTok store host unavailable");P()},destroy:function(){a=!0,t=!1,n=!1,document.removeEventListener("visibilitychange",l),e.clear()}}}var ge=function(){return ge=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},ge.apply(this,arguments)},ad=function(e,t,n,a){function l(i){return i instanceof n?i:new n(function(v){v(i)})}return new(n||(n=Promise))(function(i,v){function c(w){try{f(a.next(w))}catch(S){v(S)}}function P(w){try{f(a.throw(w))}catch(S){v(S)}}function f(w){w.done?i(w.value):l(w.value).then(c,P)}f((a=a.apply(e,t||[])).next())})},od=function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},a,l,i,v=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return v.next=c(0),v.throw=c(1),v.return=c(2),typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function c(f){return function(w){return P([f,w])}}function P(f){if(a)throw new TypeError("Generator is already executing.");for(;v&&(v=0,f[0]&&(n=0)),n;)try{if(a=1,l&&(i=f[0]&2?l.return:f[0]?l.throw||((i=l.return)&&i.call(l),0):l.next)&&!(i=i.call(l,f[1])).done)return i;switch(l=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,l=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){n.label=f[1];break}if(f[0]===6&&n.label<i[1]){n.label=i[1],i=f;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(f);break}i[2]&&n.ops.pop(),n.trys.pop();continue}f=t.call(e,n)}catch(w){f=[6,w],l=0}finally{a=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},$=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),l,i=[],v;try{for(;(t===void 0||t-- >0)&&!(l=a.next()).done;)i.push(l.value)}catch(c){v={error:c}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(v)throw v.error}}return i},ie=function(e,t,n){if(n||arguments.length===2)for(var a=0,l=t.length,i;a<l;a++)(i||!(a in t))&&(i||(i=Array.prototype.slice.call(t,0,a)),i[a]=t[a]);return e.concat(i||Array.prototype.slice.call(t))},J=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],a=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function Rl(e){if(e!=="standalone"){if(e==="unity-ads-ua-playable")return Ml();if(e==="applovin-growth-playable")return kl();if(e==="ironsource-levelplay-playable")return Sl();if(e==="meta-audience-playable")return Cl();if(e==="google-ads-app-playable")return Pl();if(e==="mintegral-appgrowth-zip")return Tl();if(e==="tiktok-ads-playable")return El();throw Error("E_NATIVE_TARGET")}}function uo(e){var t,n,a,l,i=(t=e.left)!==null&&t!==void 0?t:0,v=(n=e.top)!==null&&n!==void 0?n:0,c=(a=e.right)!==null&&a!==void 0?a:i+e.width,P=(l=e.bottom)!==null&&l!==void 0?l:v+e.height,f=[{id:"sdk-top-left",left:i,top:v,right:Math.min(i+48,c),bottom:Math.min(v+48,P)},{id:"sdk-top-right",left:Math.max(i,c-56),top:v,right:c,bottom:Math.min(v+56,P)},{id:"sdk-bottom-left",left:i,top:Math.max(v,P-28),right:Math.min(i+48,c),bottom:P}];return{left:Math.min(i+48,c),top:Math.min(v+56,P),right:Math.max(i,c-56),bottom:Math.max(v,P-28),zones:f}}function va(e,t){var n,a,l=(a=(n=e.measureText)===null||n===void 0?void 0:n.call(e,t))===null||a===void 0?void 0:a.width,i=/(\d+(?:\.\d+)?)px/.exec(e.font||"");return Number.isFinite(l)?l:ie([],$(t),!1).length*(i?Number(i[1]):16)*.6}function Al(e,t,n,a){var l,i,v,c,P,f,w;e.font=n.fontWeight+" "+a+"px "+n.fontFamily;var S=Math.max(0,n.width-2*((w=n.padding)!==null&&w!==void 0?w:4)),W=[];try{for(var re=J(String(t).split(`
5
+ `)),U=re.next();!U.done;U=re.next()){var G=U.value;if(n.wrap===!1){W.push(G);continue}var oe=G.trim()?G.trim().split(/\s+/):[""],q=void 0;try{for(var ee=(v=void 0,J(oe)),y=ee.next();!y.done;y=ee.next()){var O=y.value,Te=q?q+" "+O:O;if(va(e,Te)<=S){q=Te;continue}if(q&&W.push(q),va(e,O)<=S){q=O;continue}var Se="";try{for(var be=(P=void 0,J(O)),Le=be.next();!Le.done;Le=be.next()){var Z=Le.value;Se&&va(e,Se+Z)>S?(W.push(Se),Se=Z):Se+=Z}}catch(ve){P={error:ve}}finally{try{Le&&!Le.done&&(f=be.return)&&f.call(be)}finally{if(P)throw P.error}}q=Se}}catch(ve){v={error:ve}}finally{try{y&&!y.done&&(c=ee.return)&&c.call(ee)}finally{if(v)throw v.error}}W.push(q)}}catch(ve){l={error:ve}}finally{try{U&&!U.done&&(i=re.return)&&i.call(re)}finally{if(l)throw l.error}}return W}function Vl(e,t,n){var a,l,i=(a=n.padding)!==null&&a!==void 0?a:4,v=Math.max(0,n.width-2*i),c=Math.max(0,n.height-2*i),P=Math.min(n.fontSize,(l=n.minFontSize)!==null&&l!==void 0?l:12),f=n.fontSize,w=Al(e,t,n,f),S,W=function(){var re;e.font=n.fontWeight+" "+f+"px "+n.fontFamily;var U=Math.max.apply(Math,ie([0],$(w.map(function(ee){return va(e,ee)})),!1)),G=f*((re=n.lineHeight)!==null&&re!==void 0?re:1.2),oe=w.length>16;oe&&(w=w.slice(0,16));var q=w.length*G;return{lines:w,fontSize:f,scale:f/n.fontSize,renderedWidth:U,renderedHeight:q,availableWidth:v,availableHeight:c,padding:i,lineHeight:G,overflowsWidth:U>v+.01,overflowsHeight:oe||q>c+.01,unsupportedChars:[]}};if(S=W(),n.autoFit!==!1)for(;(S.overflowsWidth||S.overflowsHeight)&&f>P;)f=Math.max(P,f-1),w=Al(e,t,n,f),S=W();return S}function ld(e,t,n,a){a===void 0&&(a="en");var l=Vl(e,t,n),i=l.padding,v=n.direction==="rtl"||n.direction!=="ltr"&&/^(ar|fa|he|iw|ps|sd|ug|ur|yi)(?:-|$)/.test(a),c=v&&n.direction!=="rtl"?n.align==="left"?"right":n.align==="right"?"left":n.align:n.align;e.fillStyle=n.color,e.font=n.fontWeight+" "+l.fontSize+"px "+n.fontFamily,e.direction=v?"rtl":"ltr",e.textAlign=c,e.textBaseline="middle";var P=c==="left"?i:c==="right"?n.width-i:n.width/2,f=(n.height-l.renderedHeight)/2;return l.lines.forEach(function(w,S){return e.fillText(w,P,f+(S+.5)*l.lineHeight)}),ge(ge({},l),{direction:v?"rtl":"ltr",resolvedAlign:c,clipped:l.overflowsHeight})}function fd(e,t,n){var a,l,i,v,c,P,f=n===void 0?{}:n,w=f.edit,S=w===void 0?!1:w,W=f.sceneId,re=W===void 0?e.base.startScene:W,U=f.onSelect,G=U===void 0?function(){}:U,oe=f.network,q=oe===void 0?"standalone":oe,ee=Rl(q),y=t.getContext("2d"),O=new Map(e.components.map(function(r){return[r.id,r]})),Te=new Map(e.assets.map(function(r){return[r.id,r]})),Se=new Map,be=new Map(e.events.map(function(r){return[r.id,r]})),Le=new Map(e.gameplay.filter(function(r){return r.kind==="responsive-layout"}).map(function(r){return[r.componentId,r.parameters]})),Z=(i=globalThis.matchMedia)===null||i===void 0?void 0:i.call(globalThis,"(prefers-reduced-motion: reduce)"),ve,ae=new Map,me=ae;function R(){var r=Le.size>0&&t.clientWidth>t.clientHeight;return{width:r?Math.max(e.base.width,e.base.height):e.base.width,height:r?Math.min(e.base.width,e.base.height):e.base.height,landscape:r}}function b(){ve!==R().landscape&&(Qt(),tt())}var K=function(r){var o,d=Te.get(r);return((o=d==null?void 0:d.hash)!==null&&o!==void 0?o:r)+":"+r};try{for(var D=J(e.assets),le=D.next();!le.done;le=D.next()){var Q=le.value;if(Q.mime.startsWith("image/")&&!Se.has(K(Q.id))){var fe=new Image;fe.src="data:"+Q.mime+";base64,"+Q.data,Se.set(K(Q.id),fe)}}}catch(r){a={error:r}}finally{try{le&&!le.done&&(l=D.return)&&l.call(D)}finally{if(a)throw a.error}}var _=re,j={},se=[],ye=[],H=[],de=[],ze=new Set,Ae=new Map,ce=0,$e=0,je=0,lr=0,Sr=0,Tr=!1,Lr=0,zr=0,Rt=!1,pt=[],_e,mn,Ge,Gt,it,Lt,ln,Yt,Vt,Zt,Ot=[],mt,st=[],et=[],Wr,sa=0,Vi=!1,li=0,gn=q==="standalone",fi=q==="standalone",Yn=q==="standalone",Vn=!1,Oi=!1,Je=new Map,On=new Map,Ir=new Map,di=new Map,xn=new Set,vo=new Map,so=new Map,Zn=new Set,$n=new Map,Bi=new Map,ca=new Map,ha=new Map,In=new Map,Dt=new Map,ui=0,ya=0,Dr,rt,pa=1,ma,xt=new Map,co=new Map,Bt=new Map,$t=new Map,Bn=new Map,zn=new Map,zi=new Map,Vr=$o(),Kn=Jo(),Wi=new Map,Ni=new Map,Ht=el(Qa(e.projectId)),Qn=new Map,fn=new Map,Wn=new Map,Li=new Set,dn=new Map,Xe,Ol=1,Bl=1,br,bn,vi={x:0,y:0},Yr,Kt=[],wn=[],We=function(r){var o;return(o=Ir.get(r))!==null&&o!==void 0?o:O.get(r)},It=function(r,o){return e.gameplay.find(function(d){return d.kind===r&&d.componentId===o})},si=function(){var r,o;ui++,Zn.clear(),$n.clear(),ca.clear(),ha.clear();try{for(var d=J(xn),u=d.next();!u.done;u=d.next()){var s=u.value;try{s.stop()}catch{}}}catch(p){r={error:p}}finally{try{u&&!u.done&&(o=d.return)&&o.call(d)}finally{if(r)throw r.error}}xn.clear(),Bi.clear()},ho=function(r){var o,d;if(!Xe||r!==void 0&&Xe.pointerId!==r)return!1;var u=Xe.pointerId;Xe.behavior.parameters.powerVariableId&&(j[Xe.behavior.parameters.powerVariableId]=0),Xe=void 0;try{!((o=t.hasPointerCapture)===null||o===void 0)&&o.call(t,u)&&((d=t.releasePointerCapture)===null||d===void 0||d.call(t,u))}catch{}return!0},ga=function(r){var o=r.behavior.parameters;o.axisXVariableId&&(j[o.axisXVariableId]=r.nx),o.axisYVariableId&&(j[o.axisYVariableId]=r.ny),o.magnitudeVariableId&&(j[o.magnitudeVariableId]=r.magnitude),o.angleVariableId&&r.magnitude>0&&(j[o.angleVariableId]=r.angle)},xa=function(r,o){var d,u,s,p;o===void 0&&(o=!1);try{for(var h=J(dn.values()),g=h.next();!g.done;g=h.next()){var x=g.value;if(!(x.pointerId===null||r!==void 0&&x.pointerId!==r)){var k=x.pointerId;x.pointerId=null,x.nx=0,x.ny=0,x.magnitude=0,x.knobX=x.origin.x,x.knobY=x.origin.y,ga(x);try{!((s=t.hasPointerCapture)===null||s===void 0)&&s.call(t,k)&&((p=t.releasePointerCapture)===null||p===void 0||p.call(t,k))}catch{}o&&rr(ot("joystickEnd",x.c))}}}catch(m){d={error:m}}finally{try{g&&!g.done&&(u=h.return)&&u.call(h)}finally{if(d)throw d.error}}},Di=function(r,o){var d,u;if(o===void 0&&(o=!0),!Ge||r!==void 0&&Ge.pointerId!==r)return!1;var s=Ge,p=s.pointerId;if(Ge=void 0,bn=void 0,o){var h=We(s.targetId);h&&s.b.parameters.snapBack&&(Jt(h,s.origin.x,s.origin.y),s.originZone&&Vr.place(h.id,s.originZone))}try{!((d=t.hasPointerCapture)===null||d===void 0)&&d.call(t,p)&&((u=t.releasePointerCapture)===null||u===void 0||u.call(t,p))}catch{}return!0},Ia=function(r){var o,d;(mt==null?void 0:mt.pointerId)===r.pointerId&&(mt=void 0);try{for(var u=J(In.values()),s=u.next();!s.done;s=u.next()){var p=s.value;p.pointerId===r.pointerId&&p.held&&(p.held=!1,p.releasedAt=ce)}}catch(g){o={error:g}}finally{try{s&&!s.done&&(d=u.return)&&d.call(u)}finally{if(o)throw o.error}}var h=Di(r.pointerId);return Lt===r.pointerId?(it=void 0,Lt=void 0,!0):h},Hi=function(r){var o,d,u,s,p,h,g,x;if(r){Ge&&((g=Ir.get(Ge.targetId))===null||g===void 0?void 0:g.instanceId)===r&&Di(void 0,!1),Xe&&((x=Ir.get(Xe.targetId))===null||x===void 0?void 0:x.instanceId)===r&&ho();var k=[];Vr.release(r),Kn.cancel(r),Qn.delete(r),Wn.delete(r),Ht.remove(r),se=se.filter(function(F){return F.id!==r});try{for(var m=J(Ir),C=m.next();!C.done;C=m.next()){var M=$(C.value,2),T=M[0],I=M[1];if(I.instanceId===r){k.push(T),Vr.release(T),Kn.cancel(T),Ir.delete(T),Je.delete(T),di.delete(T),Bt.delete(T),Bn.delete(T),zn.delete(T);try{for(var E=(u=void 0,J($t.values())),A=E.next();!A.done;A=E.next()){var z=A.value;z.removeAgent(T)}}catch(F){u={error:F}}finally{try{A&&!A.done&&(s=E.return)&&s.call(E)}finally{if(u)throw u.error}}try{for(var N=(p=void 0,J(On.keys())),L=N.next();!L.done;L=N.next()){var B=L.value;B.endsWith(":"+T)&&On.delete(B)}}catch(F){p={error:F}}finally{try{L&&!L.done&&(h=N.return)&&h.call(N)}finally{if(p)throw p.error}}}}}catch(F){o={error:F}}finally{try{C&&!C.done&&(d=m.return)&&d.call(m)}finally{if(o)throw o.error}}H=H.filter(function(F){return!k.includes(F.targetId)})}},Jn=function(r){for(;r;){if(r.prototype)return r.id;r=We(r.parentId)}},zl=function(){var r,o,d;return{viewport:R(),components:Object.fromEntries(ie([],$(Je),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,ge(ge({},h),{parameters:ge({},h.parameters)})]})),mode:S?"edit":"play",scene:_,variables:ge({},j),time:ce,instances:se.map(function(u){return ge({id:u.id,prototypeId:u.prototypeId,x:u.transform[4],y:u.transform[5]},Ht.snapshot(u.id))}),particles:ye.length,animations:H.length,contacts:ze.size,spriteFrames:Object.fromEntries(ie([],$(di),!1).map(function(u){var s,p=$(u,2),h=p[0],g=p[1];return[h,(s=g.frame)!==null&&s!==void 0?s:0]})),input:{dragging:!!Ge,pointerId:(o=(r=Ge==null?void 0:Ge.pointerId)!==null&&r!==void 0?r:br==null?void 0:br.pointerId)!==null&&o!==void 0?o:null,pressed:it!=null?it:null,holding:!!(br!=null&&br.holds.length),occupancy:Vr.snapshot(),joysticks:Object.fromEntries(ie([],$(dn),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,{active:h.pointerId!==null,x:h.nx,y:h.ny,magnitude:h.magnitude,angle:h.angle}]}))},feedback:{presses:In.size,floatingTexts:st.length,flashes:et.length,shaking:!!Wr,tutorialHands:li},match:{boards:Object.fromEntries(ie([],$(xt),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,h.snapshot()]})),selected:Dr!=null?Dr:null,cells:ie([],$(Dt),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return ge({id:p},h)})},physics:Ul(),paths:Object.fromEntries(ie([],$($t),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,h.snapshot()]})),canvas:{masks:Object.fromEntries(ie([],$(Qn),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,{progress:h.progress}]})),strokes:Object.fromEntries(ie([],$(fn),!1).map(function(u){var s=$(u,2),p=s[0],h=s[1];return[p,h.strokes.length]})),walls:Kt.length,joints:wn.filter(function(u){return!u.broken}).length},audio:{state:(d=_e==null?void 0:_e.state)!==null&&d!==void 0?d:"locked",voices:xn.size,blocked:ya},network:{target:q,ready:fi,visible:Yn,started:gn,closed:Vn,hostVolume:pa},diagnostics:ie([],$(pt),!1)}},qn=function(){return!S&&!Tr&&!document.hidden&&fi&&Yn&&gn&&!Vn},Qt=function(){var r,o,d,u;mt=void 0,ho(),xa(),Di(),br=void 0,bn=void 0,Yr=void 0;try{for(var s=J(fn.values()),p=s.next();!p.done;p=s.next()){var h=p.value;h.cancel()}}catch(m){r={error:m}}finally{try{p&&!p.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}Kn.clear(),rt=void 0;try{for(var g=J(xt.values()),x=g.next();!x.done;x=g.next()){var k=x.value;k.cancelSelection()}}catch(m){d={error:m}}finally{try{x&&!x.done&&(u=g.return)&&u.call(g)}finally{if(d)throw d.error}}xt.size&&(Dr=void 0),it=void 0,Lt=void 0,In.clear()},at=function(r){Rt=!0,pt.push(r),pt=pt.slice(-16),de=[]},Wl=function(r){var o,d,u;return ge(ge(ge({},r.parameters),r.prototypeId?(o=Je.get(r.prototypeId))===null||o===void 0?void 0:o.parameters:{}),(u=Je.get((d=r.runtimeId)!==null&&d!==void 0?d:r.id))===null||u===void 0?void 0:u.parameters)};function He(r){var o=Wl(r);return o}function ba(r,o){var d,u=In.get(r.id);if(!u||Z!=null&&Z.matches)return o;var s=ie([],$(o),!1),p=u.held?0:ce-((d=u.releasedAt)!==null&&d!==void 0?d:ce),h=u.held?0:Math.min(1,p/u.behavior.springBackSeconds),g=u.held?u.behavior.scaleDown:u.behavior.scaleDown+(1-u.behavior.scaleDown)*(1-Math.pow(1-h,3)),x=He(r);s[4]+=(1-g)*(s[0]*x.width+s[2]*x.height)/2,s[5]+=(1-g)*(s[1]*x.width+s[3]*x.height)/2;for(var k=0;k<4;k++)s[k]*=g;return s}function Fi(r){return{left:0,top:0,right:r.width,bottom:r.height,width:r.width,height:r.height}}function bt(r){var o,d,u,s,p,h,g,x=r.transform,k=(u=(d=Je.get((o=r.runtimeId)!==null&&o!==void 0?o:r.id))===null||d===void 0?void 0:d.transform)!==null&&u!==void 0?u:x,m=Le.get((s=r.prototypeId)!==null&&s!==void 0?s:r.id);if(!m)return ba(r,k);var C=R(),M=ie([],$(k),!1);C.landscape&&(M[4]+=m.x-x[4],M[5]+=m.y-x[5],M[0]*=m.scaleX,M[1]*=m.scaleX,M[2]*=m.scaleY,M[3]*=m.scaleY);var T=(p=m.anchor)!==null&&p!==void 0?p:"none";if(T==="none"&&!m.respectSafeArea)return ba(r,M);var I=Fi(C),E=m.respectSafeArea?uo(I):I,A=He(r),z=(h=m.marginX)!==null&&h!==void 0?h:0,N=(g=m.marginY)!==null&&g!==void 0?g:0,L=Math.abs(M[0])*A.width+Math.abs(M[2])*A.height,B=Math.abs(M[1])*A.width+Math.abs(M[3])*A.height;return T!=="none"?(M[4]=T.endsWith("left")?E.left+z:T.endsWith("right")?E.right-L-z:(E.left+E.right-L)/2,M[5]=T.startsWith("top")?E.top+N:T.startsWith("bottom")?E.bottom-B-N:(E.top+E.bottom-B)/2):(M[4]=Math.max(E.left+z,Math.min(E.right-L-z,M[4])),M[5]=Math.max(E.top+N,Math.min(E.bottom-B-N,M[5]))),ba(r,M)}var Xi=function(r){return(Ir.has(r)?ie([],$(Ir.values()),!1):ie(ie([],$(e.components),!1),$(se),!1)).filter(function(o){return o.parentId===r&&!o.prototype}).sort(function(o,d){return o.order-d.order||(o.id<d.id?-1:o.id>d.id?1:0)})},yo=function(){return e.components.filter(function(r){return r.sceneId===_&&!r.parentId&&!r.prototype}).sort(function(r,o){return r.order-o.order||(r.id<o.id?-1:r.id>o.id?1:0)})},rr=function(r){var o,d;if(r.kind==="sceneEnter"&&((o=e.scenes.find(function(u){return u.id===r.sceneId}))===null||o===void 0?void 0:o.role)==="end-card"&&ma!==r.sceneId&&(ma=r.sceneId,(d=ee==null?void 0:ee.notifyGameEnd)===null||d===void 0||d.call(ee)),de.length>=256){at("Event queue budget exhausted");return}de.push(r)},ot=function(r,o,d,u){var s,p,h,g;return u===void 0&&(u={}),ge(ge({kind:r,componentId:(s=o.prototypeId)!==null&&s!==void 0?s:o.id,selfInstanceId:(p=o.instanceId)!==null&&p!==void 0?p:o.id,instanceId:o.instanceId},d?{otherId:(h=d.prototypeId)!==null&&h!==void 0?h:d.id,otherInstanceId:(g=d.instanceId)!==null&&g!==void 0?g:d.id}:{}),u)};function wa(r){for(var o,d=r;d;d=We(d.parentId)){var u=Ht.states.get((o=d.instanceId)!==null&&o!==void 0?o:d.id);if(u)return u}}function po(r){var o,d,u=It("instance-state",(o=r.prototypeId)!==null&&o!==void 0?o:r.id);return u?Ht.initialize((d=r.instanceId)!==null&&d!==void 0?d:r.id,u.parameters):void 0}function Nl(){var r,o,d,u;try{for(var s=J(e.gameplay.filter(function(m){return m.kind==="instance-state"})),p=s.next();!p.done;p=s.next()){var h=p.value;try{for(var g=(d=void 0,J(Hr(O.get(h.componentId)))),x=g.next();!x.done;x=g.next()){var k=x.value;po(k)}}catch(m){d={error:m}}finally{try{x&&!x.done&&(u=g.return)&&u.call(g)}finally{if(d)throw d.error}}}}catch(m){r={error:m}}finally{try{p&&!p.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}}function Ll(r,o,d,u){var s=wa(r);if(s){var p=s.hp;if(o==="tag")s.tag=d==="set"?String(u):s.tag;else{var h=Number(u);if(s[o]=d==="add"?s[o]+h:d==="sub"?s[o]-h:h,!Number.isFinite(s[o])){at("Instance state range exceeded");return}o==="hp"&&(s.hp=Math.max(0,Math.min(s.maxHp,s.hp)))}p>0&&s.hp<=0&&rr(ot("instanceDepleted",r))}}function Ui(r,o){var d,u,s;if(!r)return!0;if(r.all)return r.all.every(function(k){return Ui(k,o)});if(r.any)return r.any.some(function(k){return Ui(k,o)});var p=r.instanceTarget==="other"?o==null?void 0:o.otherInstanceId:(d=o==null?void 0:o.selfInstanceId)!==null&&d!==void 0?d:o==null?void 0:o.instanceId,h=r.instanceField?(u=We(p))!==null&&u!==void 0?u:ie([],$(Ir.values()),!1).find(function(k){return k.instanceId===p}):void 0,g=r.instanceField?(s=wa(h))===null||s===void 0?void 0:s[r.instanceField]:j[r.variableId],x=r.compareVariableId?j[r.compareVariableId]:r.value;return{eq:function(){return g===x},ne:function(){return g!==x},lt:function(){return g<x},lte:function(){return g<=x},gt:function(){return g>x},gte:function(){return g>=x}}[r.op]()}function mo(r){var o,d,u;Dr=void 0,rt=void 0,r||Dt.clear();try{for(var s=J(e.gameplay),p=s.next();!p.done;p=s.next()){var h=p.value;if(h.kind==="match-tile"){var g=O.get(h.componentId);if(r&&g.id!==r&&!wt(g,r))continue;Je.delete(g.id),Dt.set(g.id,{row:h.parameters.row,column:h.parameters.column,group:h.parameters.group,sceneId:g.sceneId,boardId:(u=g.parentId)!==null&&u!==void 0?u:g.sceneId})}}}catch(x){o={error:x}}finally{try{p&&!p.done&&(d=s.return)&&d.call(s)}finally{if(o)throw o.error}}}function Dl(){var r,o,d=function(h){var g,x;if(xt.has(h.componentId))return"continue";var k=h.componentId,m=h.parameters,C=e.gameplay.filter(function(B){return B.kind==="match-tile"&&O.get(B.componentId).parentId===k}).sort(function(B,F){return B.parameters.row-F.parameters.row||B.parameters.column-F.parameters.column}).map(function(B){return ge({id:B.componentId},B.parameters)}),M=new Map;try{for(var T=(g=void 0,J(C)),I=T.next();!I.done;I=T.next()){var E=I.value;if(!M.has(E.group)){var A=O.get(E.id);M.set(E.group,{fill:A.parameters.fill,children:Xi(E.id).filter(function(B){return["native.image.v1","native.text.v1"].includes(B.contract)})})}}}catch(B){g={error:B}}finally{try{I&&!I.done&&(x=T.return)&&x.call(T)}finally{if(g)throw g.error}}co.set(k,M);var z=O.get(C[m.columns].id).transform[5]-O.get(C[0].id).transform[5],N=function(B,F,Y){var X,te=Y.from,ue=te===void 0?B:te,ne=Y.progress,xe=ne===void 0?0:ne,Re=Y.offsetRows,Ne=Re===void 0?0:Re,Fe=Y.scale,pe=Fe===void 0?1:Fe,Ce=Y.opacity,we=Ce===void 0?1:Ce,Me=C[B],Ve=O.get(Me.id),he=O.get(C[ue].id),mr=M.get(F),Ee=ie([],$(Ve.transform),!1);Ee[4]+=(he.transform[4]-Ve.transform[4])*xe,Ee[5]+=(he.transform[5]-Ve.transform[5]+Ne*z)*xe,Ee[4]+=(1-pe)*(Ee[0]*Ve.parameters.width+Ee[2]*Ve.parameters.height)/2,Ee[5]+=(1-pe)*(Ee[1]*Ve.parameters.width+Ee[3]*Ve.parameters.height)/2;for(var fr=0;fr<4;fr++)Ee[fr]*=pe;Je.set(Me.id,ge(ge({},Je.get(Me.id)),{transform:Ee,parameters:ge(ge({},(X=Je.get(Me.id))===null||X===void 0?void 0:X.parameters),{fill:mr.fill,opacity:we})})),Dt.get(Me.id).group=F;var Pe=Xi(Me.id).filter(function(ar){return["native.image.v1","native.text.v1"].includes(ar.contract)});Pe.forEach(function(ar,Ue){var er,Cr,ur=mr.children[Ue];if(!(!ur||ur.contract!==ar.contract)){var Ke=(er=Je.get(ar.id))!==null&&er!==void 0?er:{transform:ie([],$(ar.transform),!1),parameters:{}};ar.contract==="native.image.v1"?Ke.assetId=(Cr=ur.assetSlots[0])===null||Cr===void 0?void 0:Cr.assetId:Ke.parameters.text=ur.parameters.text,Je.set(ar.id,Ke)}})},L=Go(ge(ge({},m),{slots:C,paint:N,onEvent:function(B){Dr=void 0,rr({kind:B,componentId:k})}}));xt.set(k,L)};try{for(var u=J(e.gameplay.filter(function(h){return h.kind==="match-board"})),s=u.next();!s.done;s=u.next()){var p=s.value;d(p)}}catch(h){r={error:h}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}function go(r){var o,d;Dl();try{for(var u=J(xt),s=u.next();!s.done;s=u.next()){var p=$(s.value,2),h=p[0],g=p[1];(!r||r===h||wt(O.get(h),r))&&g.reset()}}catch(x){o={error:x}}finally{try{s&&!s.done&&(d=u.return)&&d.call(u)}finally{if(o)throw o.error}}}function Hr(r){return Jn(r)?ie([],$(Ir.values()),!1).filter(function(o){return o.prototypeId===r.id}):[r]}function Or(r){var o=He(r);return cr(yr(r),o.width/2,o.height/2)}function Nn(r,o,d){var u;d===void 0&&(d="self");var s=O.get(r),p=d==="other"?o.otherInstanceId:(u=o.selfInstanceId)!==null&&u!==void 0?u:o.instanceId,h=!!(s&&Jn(s));if(p!==void 0){if(r){var g=ie([],$(Ir.values()),!1).find(function(x){return x.prototypeId===r&&(x.instanceId===p||x.id===p)});if(g)return g}if(d==="other"||!r)return We(p);if(h&&typeof p=="string"&&p.startsWith("instance."))return}return s?h?Hr(s)[0]:We(r):void 0}function Jt(r,o,d){var u,s=He(r),p=(u=Je.get(r.id))!==null&&u!==void 0?u:{transform:ie([],$(r.transform),!1),parameters:{}},h=ie([],$(p.transform),!1),g=r.parentId?yr(We(r.parentId)):nn(),x=cr(Ut(g),o,d);h[4]=x.x-(h[0]*s.width+h[2]*s.height)/2,h[5]=x.y-(h[1]*s.width+h[3]*s.height)/2,Je.set(r.id,ge(ge({},p),{transform:h})),r.prototypeId&&(r.transform=ie([],$(h),!1))}function jn(r,o,d){var u,s,p,h;d===void 0&&(d=!1);var g=(u=Je.get(r.id))!==null&&u!==void 0?u:{transform:ie([],$(r.transform),!1),parameters:{}},x=(h=(p=O.get((s=r.prototypeId)!==null&&s!==void 0?s:r.id))===null||p===void 0?void 0:p.transform)!==null&&h!==void 0?h:r.transform,k=Math.hypot(x[0],x[1])*(d?-1:1),m=Math.hypot(x[2],x[3]),C=o+(d?0:Math.atan2(x[1],x[0])),M=Math.cos(C),T=Math.sin(C),I=ie([],$(g.transform),!1);I[0]=M*k,I[1]=T*k,I[2]=-T*m,I[3]=M*m,Je.set(r.id,ge(ge({},g),{transform:I}))}function Ln(r,o){var d=Bt.get(r.id);if(d)return d;var u=yr(r),s=He(r),p=cr(u,s.width/2,s.height/2);return d=ge({id:r.id,sourceId:o.componentId,instanceId:r.instanceId,x:p.x,y:p.y,vx:0,vy:0,width:Math.hypot(u[0],u[1])*s.width,height:Math.hypot(u[2],u[3])*s.height,angle:Math.atan2(u[1],u[0]),restElapsed:0,atRest:!0},o.parameters),Bt.set(r.id,d),d}function ci(r,o){var d,u=Qn.get(r.id);if(u)return u;var s=He(r),p=o.parameters;return u=rl(p,{width:s.width,height:s.height,source:r.contract==="native.image.v1"?Se.get(K((d=r.assetSlots[0])===null||d===void 0?void 0:d.assetId)):void 0,onProgress:function(h){p.progressVariableId&&(j[p.progressVariableId]=h),rr(ot("maskProgress",r))},onComplete:function(){return rr(ot("maskComplete",r))}}),Qn.set(r.id,u),u}function Hl(r){var o=fn.get(r.componentId);return o||(o=il(r.parameters),fn.set(r.componentId,o)),o}function xo(){var r,o,d,u,s,p,h,g,x,k,m,C,M=new Set,T=[];try{for(var I=J(e.gameplay.filter(function(Ee){return Ee.kind==="physics-body"})),E=I.next();!E.done;E=I.next()){var A=E.value,z=O.get(A.componentId);if(z.sceneId===_)try{for(var N=(d=void 0,J(Hr(z))),L=N.next();!L.done;L=N.next()){var B=L.value;if(Er(B)){if(T.length>=64){at("Physics body budget exhausted");break}var F=Ln(B,A),Y=yr(B),X=He(B),te=cr(Y,X.width/2,X.height/2);if(M.add(B.id),F.width=Math.hypot(Y[0],Y[1])*X.width,F.height=Math.hypot(Y[2],Y[3])*X.height,F.mode!=="dynamic"){var ue=Bn.get(B.id),ne=B.parentId?yr(We(B.parentId)):nn(),xe=(m=ue==null?void 0:ue.vx)!==null&&m!==void 0?m:0,Re=(C=ue==null?void 0:ue.vy)!==null&&C!==void 0?C:0;F.x=te.x,F.y=te.y,F.angle=Math.atan2(Y[1],Y[0]),F.vx=ne[0]*xe+ne[2]*Re,F.vy=ne[1]*xe+ne[3]*Re}else F.atRest&&(F.x=te.x,F.y=te.y);T.push(F)}}}catch(Ee){d={error:Ee}}finally{try{L&&!L.done&&(u=N.return)&&u.call(N)}finally{if(d)throw d.error}}}}catch(Ee){r={error:Ee}}finally{try{E&&!E.done&&(o=I.return)&&o.call(I)}finally{if(r)throw r.error}}try{for(var Ne=J(Bt.keys()),Fe=Ne.next();!Fe.done;Fe=Ne.next()){var pe=Fe.value;!M.has(pe)&&!Ir.has(pe)&&Bt.delete(pe)}}catch(Ee){s={error:Ee}}finally{try{Fe&&!Fe.done&&(p=Ne.return)&&p.call(Ne)}finally{if(s)throw s.error}}var Ce=[];try{for(var we=J(e.gameplay.filter(function(Ee){return Ee.kind==="capture-zone"})),Me=we.next();!Me.done;Me=we.next()){var A=Me.value,z=O.get(A.componentId);if(z.sceneId===_)try{for(var Ve=(x=void 0,J(Hr(z))),he=Ve.next();!he.done;he=Ve.next()){var B=he.value;if(Er(B)){var Y=yr(B),X=He(B),te=cr(Y,X.width/2,X.height/2),mr=Math.max(.1,Math.min(Math.hypot(Y[0],Y[1]),Math.hypot(Y[2],Y[3])));Ce.push(ge(ge({id:B.id,sourceId:z.id,instanceId:B.instanceId,x:te.x,y:te.y},A.parameters),{radius:A.parameters.radius*mr}))}}}catch(Pe){x={error:Pe}}finally{try{he&&!he.done&&(k=Ve.return)&&k.call(Ve)}finally{if(x)throw x.error}}}}catch(Ee){h={error:Ee}}finally{try{Me&&!Me.done&&(g=we.return)&&g.call(we)}finally{if(h)throw h.error}}return{bodies:ie(ie([],$(T),!1),$(Kt),!1),zones:Ce}}function Fl(r){var o,d,u,s,p,h,g,x=xo(),k=x.bodies,m=x.zones,C=R();wn=[];try{for(var M=J(e.gameplay.filter(function(ne){return ne.kind==="physics-joint"})),T=M.next();!T.done;T=M.next()){var I=T.value,E=O.get(I.componentId);if(E.sceneId===_){var A=We(I.parameters.anchorComponentId),z=It("physics-body",E.id);if(!(!A||!z))try{for(var N=(u=void 0,J(Hr(E))),L=N.next();!L.done;L=N.next()){var B=L.value;Ln(B,z);var F=Or(A),Y=I.id+":"+B.id;wn.push(ge(ge({},I.parameters),{id:I.id,key:Y,componentId:E.id,bodyId:B.id,anchorId:A.id,x:F.x,y:F.y,broken:Li.has(Y)}))}}catch(ne){u={error:ne}}finally{try{L&&!L.done&&(s=N.return)&&s.call(N)}finally{if(u)throw u.error}}}}}catch(ne){o={error:ne}}finally{try{T&&!T.done&&(d=M.return)&&d.call(M)}finally{if(o)throw o.error}}ja({bodies:k,zones:m,joints:wn,bounds:{left:0,top:0,right:C.width,bottom:C.height},dt:r,onEvent:function(ne,xe,Re){var Ne,Fe,pe,Ce;if(!(ne==="bodyBounce"&&Re&&xe.sourceId===Re.sourceId&&xe.id>Re.id)){var we=(Ne=xe.instanceId)!==null&&Ne!==void 0?Ne:xe.id,Me=Re?(Fe=Re.instanceId)!==null&&Fe!==void 0?Fe:Re.id:void 0,Ve=ge(ge({kind:ne,componentId:xe.sourceId,selfInstanceId:we},Me?{otherInstanceId:Me}:{}),{instanceId:(pe=xe.instanceId)!==null&&pe!==void 0?pe:Re==null?void 0:Re.instanceId});if(Re&&(Ve.otherId=Re.sourceId),rr(Ve),ne==="zoneCapture"){var he=We(xe.id),mr=O.get(Re.sourceId);if(Re.hideCaptured&&he){var Ee=(Ce=Je.get(he.id))!==null&&Ce!==void 0?Ce:{transform:ie([],$(he.transform),!1),parameters:{}};Ee.parameters.visible=!1,Je.set(he.id,Ee)}Re.stopBody&&mr&&he&&Jt(he,Re.x,Re.y)}}}});try{for(var X=J(k),te=X.next();!te.done;te=X.next()){var ue=te.value,B=We(ue.id);!B||ue.mode!=="dynamic"||(ue.spinToRotation&&jn(B,(g=ue.angle)!==null&&g!==void 0?g:0),Jt(B,ue.x,ue.y))}}catch(ne){p={error:ne}}finally{try{te&&!te.done&&(h=X.return)&&h.call(X)}finally{if(p)throw p.error}}}function Xl(){var r,o,d,u,s;try{for(var p=J(e.gameplay.filter(function(L){return L.kind==="oscillate"})),h=p.next();!h.done;h=p.next()){var g=h.value,x=O.get(g.componentId);if(x.sceneId===_)try{for(var k=(d=void 0,J(Hr(x))),m=k.next();!m.done;m=k.next()){var C=m.value,M=Bn.get(C.id);M||(M={base:ie([],$(bt(C)),!1),vx:0,vy:0},Bn.set(C.id,M));var T=g.parameters,I=(ce/T.periodSeconds+T.phase)*Math.PI*2,E=Math.sin(I)*T.amplitude,A=Math.cos(I)*T.amplitude*Math.PI*2/T.periodSeconds,z=(s=Je.get(C.id))!==null&&s!==void 0?s:{parameters:{}},N=ie([],$(M.base),!1);T.axis==="x"?(N[4]+=E,M.vx=A,M.vy=0):(N[5]+=E,M.vy=A,M.vx=0),Je.set(C.id,ge(ge({},z),{transform:N})),Bn.set(C.id,M)}}catch(L){d={error:L}}finally{try{m&&!m.done&&(u=k.return)&&u.call(k)}finally{if(d)throw d.error}}}}catch(L){r={error:L}}finally{try{h&&!h.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}}function Io(){var r,o;$t.clear();var d=function(h){var g=e.gameplay.filter(function(k){return k.kind==="path-gate"&&k.parameters.networkBehaviorId===h.id}),x=hl({id:h.id,nodes:h.parameters.nodes,edges:h.parameters.edges,gates:g,onEvent:function(k,m){var C,M=We(m.componentId),T=(C=M==null?void 0:M.prototypeId)!==null&&C!==void 0?C:m.componentId;rr(ge({kind:k,componentId:T,instanceId:M==null?void 0:M.instanceId},m.nodeId?{nodeId:m.nodeId}:{}))}});$t.set(h.id,x)};try{for(var u=J(e.gameplay.filter(function(h){return h.kind==="path-network"})),s=u.next();!s.done;s=u.next()){var p=s.value;d(p)}}catch(h){r={error:h}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}function Gi(r,o){var d,u,s,p,h,g,x,k,m,C,M,T,I;o===void 0&&(o=!0);var E=0;try{for(var A=J(e.gameplay.filter(function(Ee){return Ee.kind==="path-agent"})),z=A.next();!z.done;z=A.next()){var N=z.value,L=O.get(N.componentId),B=$t.get(N.parameters.networkBehaviorId);if(!(L.sceneId!==_||!B))try{for(var F=(s=void 0,J(Hr(L))),Y=F.next();!Y.done;Y=F.next()){var X=Y.value;if(++E>64){at("Path agent budget exhausted");break}var te=B.getAgent(X.id);te||(te=B.addAgent(ge(ge({},N.parameters),{id:X.id,startNode:(M=X.pathStartNode)!==null&&M!==void 0?M:N.parameters.startNode,targetNode:(T=X.pathTargetNode)!==null&&T!==void 0?T:N.parameters.targetNode}))),te.speedMultiplier=Math.max(0,Number(N.parameters.speedMultiplierVariableId?j[N.parameters.speedMultiplierVariableId]:1))}}catch(Ee){s={error:Ee}}finally{try{Y&&!Y.done&&(p=F.return)&&p.call(F)}finally{if(s)throw s.error}}}}catch(Ee){d={error:Ee}}finally{try{z&&!z.done&&(u=A.return)&&u.call(A)}finally{if(d)throw d.error}}if(o){var ue=function(Ee,fr){var Pe=e.gameplay.find(function(ar){return ar.id===Ee});O.get(Pe.componentId).sceneId===_&&fr.tick(r)};try{for(var ne=J($t),xe=ne.next();!xe.done;xe=ne.next()){var Re=$(xe.value,2),Ne=Re[0],Fe=Re[1];ue(Ne,Fe)}}catch(Ee){h={error:Ee}}finally{try{xe&&!xe.done&&(g=ne.return)&&g.call(ne)}finally{if(h)throw h.error}}}try{for(var pe=J(e.gameplay.filter(function(Ee){return Ee.kind==="path-agent"})),Ce=pe.next();!Ce.done;Ce=pe.next()){var N=Ce.value,L=O.get(N.componentId),we=$t.get(N.parameters.networkBehaviorId);if(!(L.sceneId!==_||!we))try{for(var Me=(m=void 0,J(Hr(L))),Ve=Me.next();!Ve.done;Ve=Me.next()){var X=Ve.value,te=we.getAgent(X.id);if(te){if(te.orientToPath==="rotate")jn(X,te.heading);else if(te.orientToPath==="flip-x")jn(X,0,te.flipX);else if(te.orientToPath==="iso-4"){var he=(I=Je.get(X.id))!==null&&I!==void 0?I:{transform:ie([],$(X.transform),!1),parameters:{}};he.pathFrame=te.frame,Je.set(X.id,he)}var mr=X.parentId?cr(yr(We(X.parentId)),te.x,te.y):te;Jt(X,mr.x,mr.y)}}}catch(Pe){m={error:Pe}}finally{try{Ve&&!Ve.done&&(C=Me.return)&&C.call(Me)}finally{if(m)throw m.error}}}}catch(Ee){x={error:Ee}}finally{try{Ce&&!Ce.done&&(k=pe.return)&&k.call(pe)}finally{if(x)throw x.error}}}function Ma(r){var o,d,u,s,p,h,g,x,k,m,C=new Set;try{for(var M=J(e.gameplay.filter(function(Ke){return Ke.kind==="value-meter"})),T=M.next();!T.done;T=M.next()){var I=T.value,E=O.get(I.componentId);if(E.sceneId===_)try{for(var A=(u=void 0,J(Hr(E))),z=A.next();!z.done;z=A.next()){var N=z.value,L=I.parameters,B=L.instanceField?wa(N):void 0,F=L.instanceField==="hp"&&B?B.hp/B.maxHp*(L.max-L.min)+L.min:L.instanceField==="value"&&B?B.value:Number(j[L.variableId]),Y=zn.get(N.id);Y||(Y={base:ie([],$(bt(N)),!1),value:Number.isFinite(F)?Math.max(L.min,Math.min(L.max,F)):L.min},zn.set(N.id,Y)),C.add(N.id);var X=Math.max(L.min,Math.min(L.max,F)),te=L.smoothingSeconds?1-Math.exp(-r/L.smoothingSeconds):1;Y.value+=((Number.isFinite(X)?X:L.min)-Y.value)*te;var ue=Math.max(0,Math.min(1,(Y.value-L.min)/(L.max-L.min))),ne=ie([],$(Y.base),!1),xe=(k=Je.get(N.id))!==null&&k!==void 0?k:{parameters:{}},Re=L.axis==="x"?He(N).width:He(N).height;if(L.axis==="x"?(ne[0]*=ue,ne[1]*=ue):(ne[2]*=ue,ne[3]*=ue),L.direction==="negative"){var Ne=Re*(1-ue);L.axis==="x"?(ne[4]+=Y.base[0]*Ne,ne[5]+=Y.base[1]*Ne):(ne[4]+=Y.base[2]*Ne,ne[5]+=Y.base[3]*Ne)}Je.set(N.id,ge(ge({},xe),{transform:ne}))}}catch(Ke){u={error:Ke}}finally{try{z&&!z.done&&(s=A.return)&&s.call(A)}finally{if(u)throw u.error}}}}catch(Ke){o={error:Ke}}finally{try{T&&!T.done&&(d=M.return)&&d.call(M)}finally{if(o)throw o.error}}try{for(var Fe=J(zn.keys()),pe=Fe.next();!pe.done;pe=Fe.next()){var Ce=pe.value;C.has(Ce)||zn.delete(Ce)}}catch(Ke){p={error:Ke}}finally{try{pe&&!pe.done&&(h=Fe.return)&&h.call(Fe)}finally{if(p)throw p.error}}try{for(var we=J(e.gameplay.filter(function(Ke){return Ke.kind==="camera-follow"})),Me=we.next();!Me.done;Me=we.next()){var I=Me.value,Ve=O.get(I.componentId),X=We(I.parameters.targetId);if(!(Ve.sceneId!==_||!X)){var he=zi.get(Ve.id);he||(he={base:ie([],$(Ve.transform),!1),x:I.parameters.minX,y:I.parameters.minY},zi.set(Ve.id,he));var mr=function(Ar,Jr){for(var qr=[],Xr=Ar;Xr&&Xr.id!==Jr.id;Xr=We(Xr.parentId))qr.unshift(Xr);return qr.reduce(function(Zr,vr){return ii(Zr,bt(vr))},nn())},ne=wt(X,Ve.id)?mr(X,Ve):yr(X),L=He(X),Ee=cr(ne,L.width/2,L.height/2),fr=R(),Pe=I.parameters,ar=Math.max(Pe.minX,Pe.maxX-fr.width/Pe.zoom),Ue=Math.max(Pe.minY,Pe.maxY-fr.height/Pe.zoom),er=Math.max(Pe.minX,Math.min(ar,Ee.x-fr.width/(2*Pe.zoom))),Cr=Math.max(Pe.minY,Math.min(Ue,Ee.y-fr.height/(2*Pe.zoom))),te=1-Math.exp(-Pe.smoothing*r);he.x+=(er-he.x)*te,he.y+=(Cr-he.y)*te;var xe=(m=Je.get(Ve.id))!==null&&m!==void 0?m:{parameters:{}},ur=ie([],$(he.base),!1);ur[0]*=Pe.zoom,ur[1]*=Pe.zoom,ur[2]*=Pe.zoom,ur[3]*=Pe.zoom,ur[4]-=he.x*Pe.zoom,ur[5]-=he.y*Pe.zoom,Je.set(Ve.id,ge(ge({},xe),{transform:ur}))}}}catch(Ke){g={error:Ke}}finally{try{Me&&!Me.done&&(x=we.return)&&x.call(we)}finally{if(g)throw g.error}}}function Ul(){return{bodies:ie([],$(Bt.values()),!1).map(function(r){return{id:r.id,sourceId:r.sourceId,x:r.x,y:r.y,vx:r.vx,vy:r.vy,atRest:!!r.atRest,captured:!!r.captured}}),aiming:Xe?{componentId:Xe.sourceId,pointerId:Xe.pointerId,power:Xe.power}:null}}function ka(){Vt=void 0,ma=void 0,Qt(),dn.clear(),Vr.clear(),Wi.clear(),Ni.clear(),Ht.reset(),Qn.clear(),fn.clear(),Kt=[],wn=[],Wn.clear(),Li.clear(),ae.clear(),st=[],et=[],Wr=void 0,sa=0,Vi=!1,li=0,j=Object.fromEntries(e.variables.map(function(r){return[r.id,r.initial]})),si(),ya=0,Ir.clear(),di.clear(),Bt.clear(),Bn.clear(),zn.clear(),zi.clear(),Xe=void 0,se=[],ye=[],H=[],Je.clear(),mo(),On.clear(),ze.clear(),Ae.clear(),de=[],ce=0,$e=0,je=0,Rt=!1,lr=0,_=e.base.startScene,it=void 0,Lt=void 0,Gt=void 0,Yt=void 0,S||(Nl(),go(),Io(),Gi(0,!1),Ta(),Ma(0),rr({kind:"sceneEnter",sceneId:_}))}function Sa(){var r,o;if(!(!_e||_e.state!=="running"||!$n.size)){var d=ie([],$($n.values()),!1);$n.clear();try{for(var u=J(d),s=u.next();!s.done;s=u.next()){var p=s.value;wo(p)}}catch(h){r={error:h}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}function hi(r){if(r===void 0&&(r=!1),!_e)return Promise.resolve(void 0);if(_e.state==="running")return Promise.resolve().then(Sa),Promise.resolve(_e);if(!mn||r){var o=_e,d=Promise.resolve().then(function(){return o.resume()}).then(function(){if(o.state==="running")return Sa(),o}).catch(function(){}).finally(function(){mn===d&&(mn=void 0)});mn=d}return mn}function Ca(){var r,o,d=ie([],$(Bi.values()),!1),u=d.some(function(m){return m.bus==="voice"}),s=d.some(function(m){return m.bus==="stinger"}),p=s?.2:u?.25:1;try{for(var h=J(d),g=h.next();!g.done;g=h.next()){var x=g.value,k=x.volume*pa*(x.bus==="music"?p:1);x.gain.gain.setTargetAtTime?x.gain.gain.setTargetAtTime(k,_e.currentTime,.04):x.gain.gain.value=k}}catch(m){r={error:m}}finally{try{g&&!g.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}}function Gl(r,o){if(!o||typeof r.createBuffer!="function"||typeof o.getChannelData!="function"||!o.numberOfChannels)return o;var d=o.sampleRate||44100,u=o.length;if(u<Math.round(d*.2))return o;for(var s=o.numberOfChannels,p=.002,h=u,g=0,x=0;x<s;x++){for(var k=o.getChannelData(x),m=0;m<h;m++)if(Math.abs(k[m])>p){h=m;break}for(var m=u-1;m>g;m--)if(Math.abs(k[m])>p){g=m;break}}if(h>=g)return o;var C=g-h+1;if(C<Math.round(d*.15))return o;var M=Math.min(Math.round(d*.06),Math.floor(C*.1)),T=C-M;if(M<8||T<Math.round(d*.1))return o;for(var I=r.createBuffer(s,T,d),x=0;x<s;x++){for(var E=o.getChannelData(x),A=I.getChannelData(x),m=0;m<M;m++){var z=m/M;A[m]=E[h+m]*Math.sin(z*Math.PI*.5)+E[h+T+m]*Math.cos(z*Math.PI*.5)}for(var m=M;m<T;m++)A[m]=E[h+m]}return I}function bo(r,o,d){var u,s=(u=d.parameters.bus)!==null&&u!==void 0?u:"sfx";r.connect(o),o.connect(_e.destination),xn.add(r),Bi.set(r,{gain:o,bus:s,volume:d.parameters.volume}),r.onended=function(){xn.delete(r),Bi.delete(r),d.parameters.loop&&Zn.delete(d.id),Ca()},Ca()}function wo(r){return ad(this,void 0,void 0,function(){var o,d,u,s,p,h,g,x,k,m,C,M,T,I,E,A,z,N,L,B,F,Y,X,te,ue,ne,xe,Re,Ne,Fe,pe,Ce;return od(this,function(we){switch(we.label){case 0:return xn.size>=32?[2]:(o=!!r.parameters.loop,_e?(d=_e,u=ui,s=(ne=r.parameters.cooldownMs)!==null&&ne!==void 0?ne:45,p=d.currentTime,s>0&&p-((xe=ca.get(r.id))!==null&&xe!==void 0?xe:-1/0)<s/1e3?[2]:o&&Zn.has(r.id)?[2]:(h=O.get(r.componentId),g=Te.get((Re=h==null?void 0:h.assetSlots[0])===null||Re===void 0?void 0:Re.assetId),x=(g==null?void 0:g.mime)==="audio/wav"||(g==null?void 0:g.mime)==="audio/mpeg",!x&&r.parameters.allowSynthFallback===!1?(ya++,[2]):(ca.set(r.id,p),k=d.state!=="running",k?[4,hi()]:[3,2]))):(o&&$n.set(r.id,r),[2]));case 1:k=!we.sent(),we.label=2;case 2:if(k)return o&&$n.set(r.id,r),[2];if(_e!==d||d.state!=="running"||u!==ui||xn.size>=32)return[2];if(m=(Ne=ha.get(r.id))!==null&&Ne!==void 0?Ne:0,C=[0,-.5,.5,-1,1],M=((Fe=r.parameters.pitchJitter)!==null&&Fe!==void 0?Fe:0)*C[m%C.length],T=Number((pe=j[r.parameters.pitchVariableId])!==null&&pe!==void 0?pe:0),I=Math.max(-12,Math.min(12,M+T*((Ce=r.parameters.pitchStep)!==null&&Ce!==void 0?Ce:0))),E=Math.pow(2,I/12),ha.set(r.id,m+1),!x)return[3,8];o&&Zn.add(r.id),we.label=3;case 3:if(we.trys.push([3,6,,7]),A=vo.get(g.hash),A)return[3,5];for(z=atob(g.data),N=new Uint8Array(z.length),L=0;L<z.length;L++)N[L]=z.charCodeAt(L);return[4,new Promise(function(Me,Ve){var he=d.decodeAudioData(N.buffer,Me,Ve);he&&typeof he.then=="function"&&he.then(Me,Ve)})];case 4:A=we.sent(),vo.set(g.hash,A),we.label=5;case 5:return _e!==d||d.state!=="running"||u!==ui||xn.size>=32?(o&&u===ui&&Zn.delete(r.id),[2]):(B=A,o&&(B=so.get(g.hash),B||(B=Gl(d,A),so.set(g.hash,B))),F=d.createBufferSource(),Y=d.createGain(),F.buffer=B,F.loop=o,F.playbackRate&&(F.playbackRate.value=E),o&&Y.gain.setValueAtTime&&Y.gain.linearRampToValueAtTime?(Y.gain.setValueAtTime(1e-4,d.currentTime),Y.gain.linearRampToValueAtTime(r.parameters.volume,d.currentTime+.025)):Y.gain.value=r.parameters.volume,bo(F,Y,r),F.start(),[3,7]);case 6:return X=we.sent(),Zn.delete(r.id),at("Audio decode failed"),[3,7];case 7:return[2];case 8:return te=d.createOscillator(),ue=d.createGain(),te.frequency.value=r.parameters.frequency*E,te.type="sine",ue.gain.setValueAtTime(r.parameters.volume,d.currentTime),ue.gain.exponentialRampToValueAtTime(.001,d.currentTime+r.parameters.seconds),bo(te,ue,r),te.start(),te.stop(d.currentTime+r.parameters.seconds),[2]}})})}function Yl(r,o){for(var d=ie([],$(Dt.values()),!1).filter(function(m){return m.boardId===r}),u=function(m,C){var M;return(M=d.find(function(T){return T.row===m&&T.column===C}))===null||M===void 0?void 0:M.group},s=function(m){for(var C=function(I){var E=u(m,I);if(E&&E===u(m,I+1)&&E===u(m,I+2)&&o.some(function(A){return A.row===m&&A.column>=I&&A.column<=I+2}))return{value:!0}},M=0;M<14;M++){var T=C(M);if(typeof T=="object")return T}},p=0;p<16;p++){var h=s(p);if(typeof h=="object")return h.value}for(var g=function(m){for(var C=function(I){var E=u(I,m);if(E&&E===u(I+1,m)&&E===u(I+2,m)&&o.some(function(A){return A.column===m&&A.row>=I&&A.row<=I+2}))return{value:!0}},M=0;M<14;M++){var T=C(M);if(typeof T=="object")return T}},x=0;x<16;x++){var k=g(x);if(typeof k=="object")return k.value}return!1}function Zl(r){var o,d,u,s=Dt.get(r.id);if(!(!s||s.sceneId!==_||!He(r).enabled||!Er(r))){var p=xt.get(r.parentId);if(p){Dr=p.select(r.id);return}if(Dr===r.id){Dr=void 0;return}var h=Dt.get(Dr);if(!h||h.sceneId!==_||h.boardId!==s.boardId){Dr=r.id;return}var g=O.get(Dr);if(Math.abs(h.row-s.row)+Math.abs(h.column-s.column)!==1){Dr=r.id;return}if(h.group===s.group){Dr=void 0,rr({kind:"invalidMatch",componentId:(o=r.parentId)!==null&&o!==void 0?o:r.id});return}var x=h.row,k=h.column,m=s.row,C=s.column,M=ie([],$(bt(g)),!1),T=ie([],$(bt(r)),!1);if(h.row=m,h.column=C,s.row=x,s.column=k,Yl(s.boardId,[h,s])){var I=function(E,A){var z,N=(z=Je.get(E.id))!==null&&z!==void 0?z:{transform:ie([],$(bt(E)),!1),parameters:{}};N.transform=ie([],$(N.transform),!1),N.transform[4]=A[4],N.transform[5]=A[5],Je.set(E.id,N)};I(g,T),I(r,M),Dr=void 0,rr({kind:"validMatch",componentId:(d=r.parentId)!==null&&d!==void 0?d:r.id})}else h.row=x,h.column=k,s.row=m,s.column=C,Dr=void 0,rr({kind:"invalidMatch",componentId:(u=r.parentId)!==null&&u!==void 0?u:r.id})}}function Pa(r){var o,d,u,s,p=[],h=lt(r,yr(r)),g=Or(r),x=It("drag",(u=r.prototypeId)!==null&&u!==void 0?u:r.id),k=function(T){var I,E,A=O.get(T.componentId),z=T.parameters;if(A.sceneId!==_)return"continue";var N=function(Y){if(Y.id===r.id||wt(Y,r.id)||!Er(Y))return"continue";var X=lt(Y,yr(Y)),te=Or(Y),ue=Math.hypot(te.x-g.x,te.y-g.y),ne=z.radiusPx>0?ue<=z.radiusPx:h.left<X.right&&h.right>X.left&&h.top<X.bottom&&h.bottom>X.top;if(!ne)return"continue";p.push(ge({id:Y.id,c:Y,sourceId:A.id,paintOrder:Ot.findIndex(function(xe){return xe.c.id===Y.id}),distance:ue,itemTarget:e.gameplay.some(function(xe){return xe.kind==="drag"&&xe.componentId===A.id})},z))};try{for(var L=(I=void 0,J(Hr(A))),B=L.next();!B.done;B=L.next()){var F=B.value;N(F)}}catch(Y){I={error:Y}}finally{try{B&&!B.done&&(E=L.return)&&E.call(L)}finally{if(I)throw I.error}}};try{for(var m=J(e.gameplay.filter(function(T){return T.kind==="drop-zone"})),C=m.next();!C.done;C=m.next()){var M=C.value;k(M)}}catch(T){o={error:T}}finally{try{C&&!C.done&&(d=m.return)&&d.call(m)}finally{if(o)throw o.error}}return{zones:p,tag:(s=x==null?void 0:x.parameters.tag)!==null&&s!==void 0?s:""}}function Ta(r){var o,d,u=r?[r]:e.gameplay.filter(function(C){return C.kind==="drag"}).flatMap(function(C){return Hr(O.get(C.componentId))});try{for(var s=J(u),p=s.next();!p.done;p=s.next()){var h=p.value;if(!(!h||!Er(h)||Vr.zoneOf(h.id))){var g=Pa(h),x=g.zones,k=g.tag,m=ia({itemId:h.id,tag:k,zones:x.filter(function(C){return!C.itemTarget}),occupancy:Vr});(m==null?void 0:m.kind)==="accept"&&Vr.place(h.id,m.zone.id)}}}catch(C){o={error:C}}finally{try{p&&!p.done&&(d=s.return)&&d.call(s)}finally{if(o)throw o.error}}}function Dn(r,o,d){d===void 0&&(d=.18),r&&Kn.to(r.id,Or(r),o,d)}function Ea(r,o,d,u){var s,p,h=u!=null?u:d==null?void 0:d.c;rr(ge(ge({},ot(r,o,h,ge({},d?{otherId:d.sourceId}:{}))),{instanceId:(s=o.instanceId)!==null&&s!==void 0?s:(p=d==null?void 0:d.c)===null||p===void 0?void 0:p.instanceId}))}function $l(r){var o,d,u,s,p,h,g;if(!Ge||Ge.pointerId!==r.pointerId)return!1;var x=Ge,k=We(x.targetId),m=x.b.parameters;Ge=void 0,bn=void 0;try{!((o=t.hasPointerCapture)===null||o===void 0)&&o.call(t,r.pointerId)&&((d=t.releasePointerCapture)===null||d===void 0||d.call(t,r.pointerId))}catch{}if(!k)return!0;var C=Pa(k),M=C.zones,T=C.tag,I=ia({itemId:k.id,tag:T,zones:M,occupancy:Vr}),E=x.origin,A=x.originZone;if(!I)return Ea("dragReject",k,void 0,void 0),m.snapBack&&(A&&Vr.place(k.id,A),Dn(k,E,(u=m.snapBackSeconds)!==null&&u!==void 0?u:.18)),!0;var z=I.zone,N=I.occupantId?We(I.occupantId):void 0;return I.kind==="reject"?(Ea("dragReject",k,z,N),m.snapBack&&(A&&Vr.place(k.id,A),Dn(k,E,(s=m.snapBackSeconds)!==null&&s!==void 0?s:.18)),!0):(I.kind==="accept"?(Vr.place(k.id,z.id),z.snapMode==="center"&&Dn(k,Or(z.c),(p=m.snapBackSeconds)!==null&&p!==void 0?p:.18)):I.kind==="swap"&&N&&(Vr.place(k.id,z.id),A?Vr.place(N.id,A):Vr.release(N.id),Dn(k,Or(z.c),(h=m.snapBackSeconds)!==null&&h!==void 0?h:.18),Dn(N,E,(g=m.snapBackSeconds)!==null&&g!==void 0?g:.18)),Ea("dragDrop",k,z,I.kind==="accept"?z.c:N),!0)}function Kl(r){var o,d,u,s,p;Kn.tick(r,function(I,E){var A=We(I);A&&Jt(A,E.x,E.y)});try{for(var h=J(ie([],$(Vr.itemZone.keys()),!1)),g=h.next();!g.done;g=h.next()){var x=g.value,k=We(x);(!k||!Er(k))&&Vr.release(x)}}catch(I){o={error:I}}finally{try{g&&!g.done&&(d=h.return)&&d.call(h)}finally{if(o)throw o.error}}if(br)try{for(var m=J(br.holds),C=m.next();!C.done;C=m.next()){var M=C.value,T=M.charge.tick(r);T!==j[M.behavior.parameters.variableId]&&(j[M.behavior.parameters.variableId]=T,rr({kind:"variableChange",variableId:M.behavior.parameters.variableId,instanceId:M.c.instanceId,selfInstanceId:(p=M.c.instanceId)!==null&&p!==void 0?p:M.c.id}))}}catch(I){u={error:I}}finally{try{C&&!C.done&&(s=m.return)&&s.call(m)}finally{if(u)throw u.error}}}function Mo(r,o){var d,u,s,p,h=o.targetMode;if(h==="pointer")return ge({},vi);if(h==="component"){var g=We(o.targetComponentId);return g?Or(g):void 0}if(h==="nearest-team"){var x=Or(r),k=[],m=o.team,C=(s=o.maxRangePx)!==null&&s!==void 0?s:0;try{for(var M=J(Ht.states),T=M.next();!T.done;T=M.next()){var I=$(T.value,2),E=I[0],A=I[1],g=We(E);g&&Er(g)&&k.push(ge(ge({id:E},Or(g)),{team:A.team}))}}catch(z){d={error:z}}finally{try{T&&!T.done&&(u=M.return)&&u.call(M)}finally{if(d)throw d.error}}return jo(x,k,m,C,(p=r.instanceId)!==null&&p!==void 0?p:r.id)}}function Ql(r){var o,d,u,s,p;try{for(var h=J(e.gameplay.filter(function(F){return F.kind==="steer"})),g=h.next();!g.done;g=h.next()){var x=g.value,k=O.get(x.componentId),m=x.parameters;if(k.sceneId===_)try{for(var C=(u=void 0,J(Hr(k))),M=C.next();!M.done;M=C.next()){var T=M.value;if(Er(T)){var I=Mo(T,m);if(I){var E=Or(T),A=I.x-E.x,z=I.y-E.y;if(!(m.maxRangePx>0&&Math.hypot(A,z)>m.maxRangePx)){var N=Math.atan2(z,A);m.mode==="flee"?N+=Math.PI:m.mode==="orbit"&&(N+=Math.PI/2);var L=(p=Ht.headings.get(T.id))!==null&&p!==void 0?p:N,B=_o(L,N,m.turnRateDegPerSec*Math.PI/180*r);Ht.headings.set(T.id,B),Jt(T,E.x+Math.cos(B)*m.speed*r,E.y+Math.sin(B)*m.speed*r),m.orientToVelocity!==!1&&jn(T,B)}}}}}catch(F){u={error:F}}finally{try{M&&!M.done&&(s=C.return)&&s.call(C)}finally{if(u)throw u.error}}}}catch(F){o={error:F}}finally{try{g&&!g.done&&(d=h.return)&&d.call(h)}finally{if(o)throw o.error}}}function Aa(r,o,d,u){var s;if(se.length>=128){at("Instance budget exhausted");return}var p=O.get(r),h=function(m){return 1+e.components.filter(function(C){return C.parentId===m}).reduce(function(C,M){return C+h(M.id)},0)};if(Ir.size+h(p.id)>4096){at("Runtime node budget exhausted");return}var g="instance."+ ++je;function x(m,C){var M,T,I=m.id===p.id?g:g+":"+m.id,E=ge(ge({},m),{id:I,runtimeId:I,instanceId:g,prototypeId:m.id,prototype:!1,parentId:C,transform:ie([],$(m.transform),!1),spawnTime:ce});Ir.set(I,E);try{for(var A=J(e.components.filter(function(L){return L.parentId===m.id})),z=A.next();!z.done;z=A.next()){var N=z.value;x(N,I)}}catch(L){M={error:L}}finally{try{z&&!z.done&&(T=A.return)&&T.call(A)}finally{if(M)throw M.error}}return E}var k=x(p,void 0);return k.transform[4]=o,k.transform[5]=d,u&&(k.pathStartNode=u.startNode,k.pathTargetNode=u.targetNode,k.parentId=(s=e.gameplay.find(function(m){return m.id===u.networkBehaviorId}))===null||s===void 0?void 0:s.componentId),se.push(k),po(k),Ta(k),u&&Gi(0,!1),k}function Jl(r,o,d){var u,s,p,h,g,x,k,m,C,M,T,I,E,A,z,N,L,B,F,Y,X,te,ue,ne,xe,Re,Ne,Fe,pe,Ce,we;if(++zr>1024){at("Action budget exhausted");return}if(r.kind==="add"||r.kind==="set"){var Me=j[r.variableId],Ve=r.kind==="add"?Me+r.value:r.value;if(typeof Ve=="number"&&(!Number.isFinite(Ve)||Math.abs(Ve)>1e12)){at("Variable range exceeded");return}j[r.variableId]=Ve,Me!==Ve&&rr({kind:"variableChange",variableId:r.variableId,instanceId:o.instanceId})}else if(r.kind==="setComponent"||r.kind==="setAsset"){var he=We(r.componentId);if(!he)return;var mr=(C=Je.get(he.id))!==null&&C!==void 0?C:{transform:ie([],$(he.transform),!1),parameters:{}};r.kind==="setComponent"?mr.parameters[r.key]=r.valueVariableId?j[r.valueVariableId]:r.value:mr.assetId=r.assetId,Je.set(he.id,mr),r.kind==="setComponent"&&r.key==="visible"&&r.value===!1&&(Vr.release(he.id),Kn.cancel(he.id))}else if(r.kind==="resetMatch")mo(r.componentId),go(r.componentId);else if(r.kind==="clearStrokes")(M=fn.get(r.componentId))===null||M===void 0||M.clear(),Kt=Kt.filter(function(gr){return gr.owner!==r.componentId});else if(r.kind==="resetMask"){var he=We(r.componentId),Ee=It("erase-mask",r.componentId);he&&Ee&&ci(he,Ee).reset()}else if(r.kind==="copyMatchAsset"){var fr=(T=xt.get(r.boardId))===null||T===void 0?void 0:T.snapshot().lastMatch,Pe=O.get(r.componentId),ar=fr&&((E=(I=co.get(r.boardId))===null||I===void 0?void 0:I.get(fr.group))===null||E===void 0?void 0:E.children.find(function(gr){return gr.contract==="native.image.v1"}));if(fr&&ar){var Ue=O.get(fr.from),er=cr(yr(Ue),Ue.parameters.width/2,Ue.parameters.height/2),Cr=Pe.parentId?yr(O.get(Pe.parentId)):nn(),ur=cr(Ut(Cr),er.x,er.y),Ke=(A=Je.get(Pe.id))!==null&&A!==void 0?A:{transform:ie([],$(Pe.transform),!1),parameters:{}};Ke.transform=ie([],$(Ke.transform),!1),Ke.transform[4]=ur.x-Pe.parameters.width/2,Ke.transform[5]=ur.y-Pe.parameters.height/2,Ke.assetId=(z=ar.assetSlots[0])===null||z===void 0?void 0:z.assetId,Je.set(Pe.id,Ke)}}else if(r.kind==="hintMatch")Dr=void 0,(N=xt.get(r.componentId))===null||N===void 0||N.showHint();else if(r.kind==="spawn")Aa(r.prototypeId,r.x,r.y);else if(r.kind==="spawnAt"){var Fr=(r.at==="self"||r.at==="midpoint")&&(o.selfInstanceId!==void 0||o.instanceId!==void 0)?We((L=o.selfInstanceId)!==null&&L!==void 0?L:o.instanceId):Nn(r.targetComponentId,o,"self"),zt=(r.at==="other"||r.at==="midpoint")&&o.otherInstanceId!==void 0?We(o.otherInstanceId):void 0,Pe=r.at==="other"?zt:Fr;if(r.at==="pointer"||(r.at==="midpoint"?Fr&&zt:Pe))for(var Mt=Fr?Or(Fr):void 0,kt=zt?Or(zt):void 0,er=r.at==="pointer"?vi:r.at==="midpoint"?{x:(Mt.x+kt.x)/2,y:(Mt.y+kt.y)/2}:Or(Pe),Qr=O.get(r.prototypeId),Ar=Math.max(0,Math.min(16,Math.floor(r.countVariableId?Number(j[r.countVariableId]):(B=r.count)!==null&&B!==void 0?B:1))),Jr=0;Jr<Ar;Jr++){var qr=r.jitterX?(Ht.rng.next()*2-1)*r.jitterX:0,Xr=r.jitterY?(Ht.rng.next()*2-1)*r.jitterY:0;Aa(r.prototypeId,er.x+r.offsetX+qr-Qr.parameters.width/2,er.y+r.offsetY+Xr-Qr.parameters.height/2)}}else if(r.kind==="random"){var Me=j[r.variableId],Ve=Ht.rng.between(r.min,r.max,r.integer===!0);j[r.variableId]=Ve,Me!==Ve&&rr({kind:"variableChange",variableId:r.variableId,instanceId:o.instanceId})}else if(r.kind==="modifyInstanceState"){var he=r.target==="component"?We(r.componentId):Nn(r.componentId,o,r.target);he&&Ll(he,r.field,r.op,r.variableId?j[r.variableId]:r.value)}else if(r.kind==="launchToward"){var Ue=O.get(r.componentId),Zr=Hr(Ue),vr=(F=o.selfInstanceId)!==null&&F!==void 0?F:o.instanceId,he=Ue.prototype?(Y=Zr.find(function(wr){return wr.instanceId===vr||wr.id===vr}))!==null&&Y!==void 0?Y:Zr[Zr.length-1]:(X=Nn(r.componentId,o,"self"))!==null&&X!==void 0?X:We(r.componentId),Ee=It("physics-body",r.componentId),tr=he&&Ln(he,Ee);if(!tr)return;var jr=void 0;if(r.targetMode==="angle-variable")jr=Number(j[r.angleVariableId])*Math.PI/180;else{var Pe=Mo(he,r);if(!Pe)return;var er=Or(he);jr=Math.atan2(Pe.y-er.y,Pe.x-er.x)}var nt=Number(r.speedVariableId?j[r.speedVariableId]:r.speed);if(!Number.isFinite(nt)){at("Launch speed invalid");return}tr.vx=Math.cos(jr)*nt,tr.vy=Math.sin(jr)*nt,tr.atRest=!1,tr.restElapsed=0,tr.captured=!1,tr.exited=!1,r.orientToVelocity!==!1&&jn(he,jr),rr(ot("launch",he))}else if(r.kind==="moveToComponent"){var De=O.get(r.targetComponentId),he=Nn(r.componentId,o,(te=r.target)!==null&&te!==void 0?te:"self"),Pe=De&&Jn(De)?(ue=Nn(r.targetComponentId,o,r.target==="other"?"self":"other"))!==null&&ue!==void 0?ue:Hr(De)[0]:We(r.targetComponentId);he&&Pe&&Dn(he,Or(Pe),r.seconds)}else if(r.kind==="returnToOrigin"){var he=Nn(r.componentId,o,"self"),nr=he&&Wi.get(he.id);he&&nr&&Dn(he,nr,r.seconds)}else if(r.kind==="spawnOnPath")Aa(r.prototypeId,0,0,{startNode:r.startNode,targetNode:r.targetNode,networkBehaviorId:r.networkBehaviorId});else if(["setVelocity","applyImpulse","stopBody"].includes(r.kind)){var ke=O.get(r.componentId),Br=o.instanceId?ie([],$(Ir.values()),!1).filter(function(sr){return sr.instanceId===o.instanceId&&sr.prototypeId===ke.id}):Hr(ke),Ee=It("physics-body",ke.id);try{for(var ft=J(Br),gt=ft.next();!gt.done;gt=ft.next()){var he=gt.value,tr=Ln(he,Ee);r.kind==="setVelocity"?(tr.vx=r.vxVariableId?j[r.vxVariableId]:r.vx,tr.vy=r.vyVariableId?j[r.vyVariableId]:r.vy):r.kind==="applyImpulse"?(tr.vx+=r.vxVariableId?j[r.vxVariableId]:r.ix,tr.vy+=r.vyVariableId?j[r.vyVariableId]:r.iy):(tr.vx=0,tr.vy=0,tr.atRest=!0),tr.captured=!1,tr.exited=!1,tr.restElapsed=0,r.kind!=="stopBody"&&(tr.atRest=!1)}}catch(sr){u={error:sr}}finally{try{gt&&!gt.done&&(s=ft.return)&&s.call(ft)}finally{if(u)throw u.error}}}else if(r.kind==="setPosition"){var or=O.get(r.componentId),Br=o.instanceId?ie([],$(Ir.values()),!1).filter(function(Kr){return Kr.instanceId===o.instanceId&&Kr.prototypeId===or.id}):Hr(or),Ee=It("physics-body",or.id);try{for(var dt=J(Br),St=dt.next();!St.done;St=dt.next()){var he=St.value,tr=Ln(he,Ee);tr.x=r.xVariableId?j[r.xVariableId]:r.x,tr.y=r.yVariableId?j[r.yVariableId]:r.y,tr.vx=0,tr.vy=0,tr.captured=!1,tr.exited=!1,tr.atRest=!0,Jt(he,tr.x,tr.y)}}catch(Kr){p={error:Kr}}finally{try{St&&!St.done&&(h=dt.return)&&h.call(dt)}finally{if(p)throw p.error}}}else if(r.kind==="setPathEdge")(ne=$t.get(r.behaviorId))===null||ne===void 0||ne.setEdge(r.edgeId,r.enabled,r.cost);else if(r.kind==="setPathGate")(Re=$t.get((xe=e.gameplay.find(function(gr){return gr.id===r.behaviorId}))===null||xe===void 0?void 0:xe.parameters.networkBehaviorId))===null||Re===void 0||Re.setGate(r.behaviorId,r.mode,r.holdSeconds);else if(r.kind==="setPathTarget"){var kn=O.get(r.componentId),Ee=It("path-agent",kn.id),vn=$t.get(Ee.parameters.networkBehaviorId);try{for(var Ct=J(o.instanceId?ie([],$(Ir.values()),!1).filter(function(sr){return sr.instanceId===o.instanceId&&sr.prototypeId===kn.id}):Hr(kn)),ut=Ct.next();!ut.done;ut=Ct.next()){var he=ut.value;he.pathTargetNode=r.targetNode,vn==null||vn.setTarget(he.id,r.targetNode)}}catch(sr){g={error:sr}}finally{try{ut&&!ut.done&&(x=Ct.return)&&x.call(Ct)}finally{if(g)throw g.error}}}else if(r.kind==="compute"){var Nr=Number(j[r.variableId]),Ur=r.operandVariableId!==void 0?Number(j[r.operandVariableId]):r.value;if(["div","mod"].includes(r.op)&&Ur===0){at("Division by zero");return}var Ve={add:function(){return Nr+Ur},sub:function(){return Nr-Ur},mul:function(){return Nr*Ur},div:function(){return Ur===0?Nr:Nr/Ur},mod:function(){return Ur===0?Nr:Nr%Ur},min:function(){return Math.min(Nr,Ur)},max:function(){return Math.max(Nr,Ur)},set:function(){return Ur},floor:function(){return Math.floor(Nr)},ceil:function(){return Math.ceil(Nr)},abs:function(){return Math.abs(Nr)},clamp:function(){return Math.max(r.min,Math.min(r.max,Nr))}}[r.op]();if(r.round&&(Ve=Math.round(Ve)),!Number.isFinite(Ve)||Math.abs(Ve)>1e12){at("Variable range exceeded");return}var Me=j[r.variableId];j[r.variableId]=Ve,Me!==Ve&&rr({kind:"variableChange",variableId:r.variableId,instanceId:o.instanceId})}else if(r.kind==="despawn"){var Fr=(Ne=o.selfInstanceId)!==null&&Ne!==void 0?Ne:o.instanceId;r.target==="other"?Hi(o.otherInstanceId):r.target==="both"?(Hi(Fr),Hi(o.otherInstanceId)):Hi(Fr)}else if(r.kind==="changeScene")r.delaySeconds>0?r.sceneId!==_&&(Vt!=null||(Vt={sceneId:r.sceneId,at:ce+r.delaySeconds})):Yt=r.sceneId;else if(r.kind==="restart")(Fe=ee==null?void 0:ee.notifyGameRetry)===null||Fe===void 0||Fe.call(ee),Yt="__restart";else if(r.kind==="cameraShake")Z!=null&&Z.matches||(Wr={intensity:r.intensity,seconds:r.seconds,elapsed:0});else if(r.kind==="screenFlash")et.push({color:r.color,opacity:r.opacity,seconds:r.seconds,elapsed:0}),et.length>8&&et.shift();else if(r.kind==="floatingText"){var sn=O.get(r.componentId),Ue=o.instanceId?(pe=ie([],$(Ir.values()),!1).find(function(Kr){return Kr.instanceId===o.instanceId&&Kr.prototypeId===r.componentId}))!==null&&pe!==void 0?pe:sn:(Ce=We(r.componentId))!==null&&Ce!==void 0?Ce:sn,Pe=(Ue==null?void 0:Ue.sceneId)===_?Ue:sn;if(Pe){var er=void 0;if(!er){var $r=He(Pe);er=cr(yr(Pe),$r.width/2,$r.height/2)}st.push({x:er.x,y:er.y,text:r.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(wr,ct){var Mr;return String((Mr=j[ct])!==null&&Mr!==void 0?Mr:"")}),color:r.color,fontSize:r.fontSize,risePx:r.risePx,seconds:r.seconds,elapsed:0}),st.length>32&&st.shift()}}else if(r.kind==="store")o.kind==="click"&&o.pointerId!==void 0&&!mt&&(mt={pointerId:o.pointerId,targetId:o.targetId,condition:d},(we=t.setPointerCapture)===null||we===void 0||we.call(t,o.pointerId));else if(r.behaviorId){var _r=e.gameplay.find(function(gr){return gr.id===r.behaviorId});if(r.kind==="playAudio")wo(_r);else if(r.kind==="animate"){var vt=O.get(_r.componentId),Br=Jn(vt)?ie([],$(Ir.values()),!1).filter(function(sr){return sr.prototypeId===vt.id&&(!o.instanceId||sr.instanceId===o.instanceId)}):[vt],Sn=function(sr){var Kr=_r.id+":"+sr.id;H=H.filter(function(ct){return ct.id!==Kr});var wr=ge({},_r.parameters);wr.fromCurrent&&(wr.from=wr.property==="opacity"?He(sr).opacity:bt(sr)[wr.property==="x"?4:5]),H.push(ge(ge({},_r),{parameters:wr,id:Kr,behaviorId:_r.id,targetId:sr.id,elapsed:0,baseTransform:ie([],$(sr.transform),!1)}))};try{for(var Pt=J(Br),Ye=Pt.next();!Ye.done;Ye=Pt.next()){var Pe=Ye.value;Sn(Pe)}}catch(sr){k={error:sr}}finally{try{Ye&&!Ye.done&&(m=Pt.return)&&m.call(Pt)}finally{if(k)throw k.error}}}else r.kind==="stopAnimation"?H=H.filter(function(gr){return gr.behaviorId!==_r.id}):r.kind==="emit"&&ql(_r,o)}}function ql(r,o){var d,u,s,p,h,g=r.parameters,x=g.shape==="pixel-confetti",k=g.shape==="confetti",m=x||k;if(!(m&&(Z!=null&&Z.matches))){if(ye.length+g.count>256){at("Particle budget exhausted");return}if(x&&g.coverage==="screen"){ye.push.apply(ye,ie([],$(ml(g)),!1));return}if(k&&g.coverage==="screen"){ye.push.apply(ye,ie([],$(xl(g)),!1));return}for(var C=O.get(r.componentId),M=o.instanceId&&(d=ie([],$(Ir.values()),!1).find(function(Y){return Y.instanceId===o.instanceId&&Y.prototypeId===C.id}))!==null&&d!==void 0?d:C,T=bt(M),I,E=We(M.parentId);E;E=We(E.parentId)){if(m&&E.contract==="native.group.v1"&&He(E).clip){I=E.id;break}T=ii(bt(E),T)}var A=He(M),z=g.origin==="anchor"?cr(T,0,0):m||g.origin==="center"?cr(T,A.width/2,A.height/2):{x:T[4]+M.parameters.width/2,y:T[5]+M.parameters.height/2};if(x){ye.push.apply(ye,ie([],$(to(g,z,I)),!1));return}if(k){ye.push.apply(ye,ie([],$(no(g,z,I)),!1));return}for(var N=Ja(Qa(M.id+":"+ce.toFixed(3))),L=0;L<g.count;L++){var B=-Math.PI/2+((L+N.next())/g.count-.5)*((u=g.spread)!==null&&u!==void 0?u:360)*Math.PI/180,F=g.speed*N.between(.5,.95);ye.push(ge(ge({},z),{vx:Math.cos(B)*F,vy:Math.sin(B)*F,life:(s=g.lifetime)!==null&&s!==void 0?s:.7,gravity:(p=g.gravity)!==null&&p!==void 0?p:250,color:g.color,shape:(h=g.shape)!==null&&h!==void 0?h:"circle"}))}}}function ko(r){var o,d;if(r==="__restart"){ka();return}if(r!==_){Vt=void 0;var u=_;si(),_=r,dn.clear(),Vr.clear(),Wi.clear(),Ni.clear(),Qn.clear(),fn.clear(),Kt=[],wn=[],Wn.clear(),Li.clear(),Dr=void 0,se=[],ye=[],st=[],et=[],Wr=void 0,Vi=!1,li=0,Ir.clear(),Bt.clear(),Bn.clear(),zn.clear(),zi.clear(),Xe=void 0,Io(),de=de.filter(function(g){return g.kind==="variableChange"}),Je.clear(),rt=void 0;try{for(var s=J(xt.values()),p=s.next();!p.done;p=s.next()){var h=p.value;h.reset()}}catch(g){o={error:g}}finally{try{p&&!p.done&&(d=s.return)&&d.call(s)}finally{if(o)throw o.error}}ze.clear(),Ae.clear(),On.clear(),H=[],Qt(),ae.clear(),it=void 0,Lt=void 0,Gi(0,!1),Ta(),Ma(0),rr({kind:"sceneExit",sceneId:u}),rr({kind:"sceneEnter",sceneId:_})}}function un(){for(var r=function(){var o,d,u,s,p=de.shift();Lr++;var h=function(I){return I===void 0||!!We(I)||ie([],$(Ir.values()),!1).some(function(E){return E.instanceId===I})};if(!h(p.selfInstanceId)||!h(p.otherInstanceId)||["contactBegin","boundaryExit"].includes(p.kind)&&p.instanceId&&!Ir.has(p.instanceId))return"continue";try{for(var g=(o=void 0,J(e.eventBindings)),x=g.next();!x.done;x=g.next()){var k=x.value;if(Object.entries(be.get(k.eventId)).every(function(I){var E=$(I,2),A=E[0],z=E[1];return A==="id"||p[A]===z})&&Ui(k.condition,p)){try{for(var m=(u=void 0,J(k.actions)),C=m.next();!C.done;C=m.next()){var M=C.value;if(zr>=1024||Rt)break;Jl(M,p,k.condition)}}catch(I){u={error:I}}finally{try{C&&!C.done&&(s=m.return)&&s.call(m)}finally{if(u)throw u.error}}if(Yt)break}}}catch(I){o={error:I}}finally{try{x&&!x.done&&(d=g.return)&&d.call(g)}finally{if(o)throw o.error}}if(Yt){var T=Yt;Yt=void 0,ko(T)}};de.length&&!Rt&&Lr<256&&zr<1024;)r();de.length&&at("Event/action budget exhausted")}function yr(r){return ii(r.parentId?yr(We(r.parentId)):nn(),bt(r))}var cr=function(r,o,d){return{x:r[0]*o+r[2]*d+r[4],y:r[1]*o+r[3]*d+r[5]}};function lt(r,o){var d=He(r),u=[[0,0],[d.width,0],[d.width,d.height],[0,d.height]].map(function(s){var p=$(s,2),h=p[0],g=p[1];return cr(o,h,g)});return{left:Math.min.apply(Math,ie([],$(u.map(function(s){return s.x})),!1)),right:Math.max.apply(Math,ie([],$(u.map(function(s){return s.x})),!1)),top:Math.min.apply(Math,ie([],$(u.map(function(s){return s.y})),!1)),bottom:Math.max.apply(Math,ie([],$(u.map(function(s){return s.y})),!1))}}function Er(r){return He(r).visible&&He(r).opacity>0&&(!r.parentId||Er(We(r.parentId)))}function So(r,o){for(var d=He(r),u=yr(r),s=Math.min(d.width,d.height)/2,p=o==="circle"?Array.from({length:32},function(x,k){return cr(u,d.width/2+Math.cos(k*Math.PI/16)*s,d.height/2+Math.sin(k*Math.PI/16)*s)}):[[0,0],[d.width,0],[d.width,d.height],[0,d.height]].map(function(x){var k=$(x,2),m=k[0],C=k[1];return cr(u,m,C)}),h=r.parentId?We(r.parentId):void 0,g=function(){var x=He(h);if(h.contract==="native.group.v1"&&x.clip){for(var k=yr(h),m=[[0,0],[x.width,0],[x.width,x.height],[0,x.height]].map(function(E){var A=$(E,2),z=A[0],N=A[1];return cr(k,z,N)}),C=0,M=0;M<4;M++)C+=m[M].x*m[(M+1)%4].y-m[(M+1)%4].x*m[M].y;for(var T=C>=0?1:-1,I=function(E){var A,z,N=m[E],L=m[(E+1)%4],B=function(Ne){return T*((L.x-N.x)*(Ne.y-N.y)-(L.y-N.y)*(Ne.x-N.x))},F=p;p=[];var Y=F[F.length-1],X=B(Y);try{for(var te=(A=void 0,J(F)),ue=te.next();!ue.done;ue=te.next()){var ne=ue.value,xe=B(ne);if(xe>=0!=X>=0){var Re=X/(X-xe);p.push({x:Y.x+(ne.x-Y.x)*Re,y:Y.y+(ne.y-Y.y)*Re})}xe>=0&&p.push(ne),Y=ne,X=xe}}catch(Ne){A={error:Ne}}finally{try{ue&&!ue.done&&(z=te.return)&&z.call(te)}finally{if(A)throw A.error}}},M=0;M<4&&p.length;M++)I(M)}h=h.parentId?We(h.parentId):void 0};h;)g();return p}function jl(r,o){var d,u,s,p,h,g;if(r.length<3||o.length<3)return!1;try{for(var x=J([r,o]),k=x.next();!k.done;k=x.next())for(var m=k.value,C=0;C<m.length;C++){var M=m[C],T=m[(C+1)%m.length],I=M.y-T.y,E=T.x-M.x,A=1/0,z=-1/0,N=1/0,L=-1/0;try{for(var B=(s=void 0,J(r)),F=B.next();!F.done;F=B.next()){var Y=F.value,X=Y.x*I+Y.y*E;A=Math.min(A,X),z=Math.max(z,X)}}catch(ne){s={error:ne}}finally{try{F&&!F.done&&(p=B.return)&&p.call(B)}finally{if(s)throw s.error}}try{for(var te=(h=void 0,J(o)),ue=te.next();!ue.done;ue=te.next()){var Y=ue.value,X=Y.x*I+Y.y*E;N=Math.min(N,X),L=Math.max(L,X)}}catch(ne){h={error:ne}}finally{try{ue&&!ue.done&&(g=te.return)&&g.call(te)}finally{if(h)throw h.error}}if(z<N||L<A)return!1}}catch(ne){d={error:ne}}finally{try{k&&!k.done&&(u=x.return)&&u.call(x)}finally{if(d)throw d.error}}return!0}function _l(r){var o,d,u,s,p=R();try{for(var h=J(dn.values()),g=h.next();!g.done;g=h.next()){var x=g.value,k=x.behavior.parameters;if(!(!k.moveComponentId||x.magnitude<=0)){var m=We(k.moveComponentId);if(!(!m||!Er(m))){var C=(u=k.moveSpeed)!==null&&u!==void 0?u:220,M=It("physics-body",(s=m.prototypeId)!==null&&s!==void 0?s:m.id);if(M&&M.parameters.mode==="dynamic"){var T=Ln(m,M);T.vx=x.nx*C,T.vy=x.ny*C,T.atRest=!1,T.restElapsed=0}else{var I=Or(m),E=He(m),A=I.x+x.nx*C*r,z=I.y+x.ny*C*r;Co(m)||(A=Math.max(E.width/2,Math.min(p.width-E.width/2,A)),z=Math.max(E.height/2,Math.min(p.height-E.height/2,z))),Jt(m,A,z)}k.orientToMove&&jn(m,Math.atan2(x.ny,x.nx))}}}}catch(N){o={error:N}}finally{try{g&&!g.done&&(d=h.return)&&d.call(h)}finally{if(o)throw o.error}}}function ef(r){var o,d,u,s,p,h,g,x,k,m,C,M,T,I,E,A,z,N,L,B,F,Y,X,te,ue,ne,xe,Re,Ne,Fe,pe,Ce,we=R();ce+=r,Vt&&ce>=Vt.at&&ko(Vt.sceneId),yf(r),Kl(r),_l(r),Ql(r),Xl();try{for(var Me=J(In),Ve=Me.next();!Ve.done;Ve=Me.next()){var he=$(Ve.value,2),mr=he[0],Ee=he[1];!Ee.held&&ce-((X=Ee.releasedAt)!==null&&X!==void 0?X:ce)>=Ee.behavior.springBackSeconds&&In.delete(mr)}}catch(Be){o={error:Be}}finally{try{Ve&&!Ve.done&&(d=Me.return)&&d.call(Me)}finally{if(o)throw o.error}}Wr&&(Wr.elapsed+=r,Wr.elapsed>=Wr.seconds&&(Wr=void 0));try{for(var fr=J(et),Pe=fr.next();!Pe.done;Pe=fr.next()){var ar=Pe.value;ar.elapsed+=r}}catch(Be){u={error:Be}}finally{try{Pe&&!Pe.done&&(s=fr.return)&&s.call(fr)}finally{if(u)throw u.error}}et=et.filter(function(Be){return Be.elapsed<Be.seconds});try{for(var Ue=J(st),er=Ue.next();!er.done;er=Ue.next()){var Cr=er.value;Cr.elapsed+=r}}catch(Be){p={error:Be}}finally{try{er&&!er.done&&(h=Ue.return)&&h.call(Ue)}finally{if(p)throw p.error}}st=st.filter(function(Be){return Be.elapsed<Be.seconds});try{for(var ur=J(xt),Ke=ur.next();!Ke.done;Ke=ur.next()){var Fr=$(Ke.value,2),mr=Fr[0],zt=Fr[1];O.get(mr).sceneId===_&&Er(O.get(mr))&&zt.tick(r)}}catch(Be){g={error:Be}}finally{try{Ke&&!Ke.done&&(x=ur.return)&&x.call(ur)}finally{if(g)throw g.error}}var Mt=function(Be){var dr,Gr,Rr=O.get(Be.componentId);if(Rr.sceneId!==_)return"continue";var Tt=Jn(Rr)?ie([],$(Ir.values()),!1).filter(function(ti){return ti.prototypeId===Rr.id}):[Rr];try{for(var xr=(dr=void 0,J(Tt)),yt=xr.next();!yt.done;yt=xr.next()){var ir=yt.value,jt=Be.id+":"+ir.id;if(Be.kind==="motion"){var Et=(te=Je.get(ir.id))!==null&&te!==void 0?te:{transform:ie([],$(ir.transform),!1),parameters:{}},_t=(ue=Et.velocity)!==null&&ue!==void 0?ue:{x:Be.parameters.vx,y:Be.parameters.vy};_t.y+=Be.parameters.gravity*r,Et.transform[4]+=_t.x*r,Et.transform[5]+=_t.y*r,Et.velocity=_t,Je.set(ir.id,Et),ir.prototypeId&&(ir.transform=Et.transform);var Xt=yr(ir);(Xt[5]>we.height||Xt[4]<-300||Xt[4]>we.width+300)&&(Et.exited||(Et.exited=!0,rr({kind:"boundaryExit",componentId:Rr.id,instanceId:ir.instanceId})))}else if(Be.kind==="timer"){var en=((ne=On.get(jt))!==null&&ne!==void 0?ne:0)+r;On.set(jt,en),en>=Be.parameters.seconds&&en-r<Be.parameters.seconds&&(rr(ge({kind:"timer",behaviorId:Be.id,componentId:Rr.id},ir.instanceId?{instanceId:ir.instanceId,selfInstanceId:ir.instanceId}:{})),Be.parameters.repeat&&On.set(jt,en-Be.parameters.seconds))}}}catch(ti){dr={error:ti}}finally{try{yt&&!yt.done&&(Gr=xr.return)&&Gr.call(xr)}finally{if(dr)throw dr.error}}};try{for(var kt=J(e.gameplay),Qr=kt.next();!Qr.done;Qr=kt.next()){var Ar=Qr.value;Mt(Ar)}}catch(Be){k={error:Be}}finally{try{Qr&&!Qr.done&&(m=kt.return)&&m.call(kt)}finally{if(k)throw k.error}}Fl(r),Gi(r),Ma(r);var Jr=[],qr=function(Be){var dr,Gr,Rr=O.get(Be.componentId);if(Rr.sceneId!==_)return"continue";try{for(var Tt=(dr=void 0,J(Jn(Rr)?ie([],$(Ir.values()),!1).filter(function(ir){return ir.prototypeId===Rr.id}):[Rr])),xr=Tt.next();!xr.done;xr=Tt.next()){var yt=xr.value;if(Er(yt)){if(Jr.length>=256){at("Collider budget exhausted");break}Jr.push({b:Be,c:yt,box:lt(yt,yr(yt)),polygon:So(yt,Be.parameters.shape)})}}}catch(ir){dr={error:ir}}finally{try{xr&&!xr.done&&(Gr=Tt.return)&&Gr.call(Tt)}finally{if(dr)throw dr.error}}};try{for(var Xr=J(e.gameplay.filter(function(Be){return Be.kind==="collider"})),Zr=Xr.next();!Zr.done;Zr=Xr.next()){var Ar=Zr.value;qr(Ar)}}catch(Be){C={error:Be}}finally{try{Zr&&!Zr.done&&(M=Xr.return)&&M.call(Xr)}finally{if(C)throw C.error}}var vr=new Set,tr=new Map,jr=function(Be,dr,Gr){var Rr,Tt,xr;((Rr=dr.c.prototypeId)!==null&&Rr!==void 0?Rr:dr.c.id)===((Tt=Gr.c.prototypeId)!==null&&Tt!==void 0?Tt:Gr.c.id)&&dr.c.id>Gr.c.id||rr(ge(ge({},ot(Be,dr.c,Gr.c)),{instanceId:(xr=dr.c.instanceId)!==null&&xr!==void 0?xr:Gr.c.instanceId}))},nt=0;e:for(var De=0;De<Jr.length;De++)for(var Ar=De+1;Ar<Jr.length;Ar++){var nr=Jr[De],ke=Jr[Ar];if(!(nr.c.instanceId&&nr.c.instanceId===ke.c.instanceId)){var Br=nr.box,ft=ke.box,gt=Br.left<ft.right&&Br.right>ft.left&&Br.top<ft.bottom&&Br.bottom>ft.top;if(gt){if(++nt>4096){at("Collision budget exhausted");break e}gt=jl(nr.polygon,ke.polygon)}if(gt){var or=[nr.c.id,ke.c.id].sort().join("|");if(vr.add(or),tr.set(or,[nr,ke]),!ze.has(or))try{for(var dt=(T=void 0,J([[nr,ke],[ke,nr]])),St=dt.next();!St.done;St=dt.next()){var kn=$(St.value,2),vn=kn[0],Ct=kn[1];jr("contactBegin",vn,Ct)}}catch(dr){T={error:dr}}finally{try{St&&!St.done&&(I=dt.return)&&I.call(dt)}finally{if(T)throw T.error}}}}}try{for(var ut=J(Ae),Nr=ut.next();!Nr.done;Nr=ut.next()){var Ur=$(Nr.value,2),or=Ur[0],sn=$(Ur[1],2),nr=sn[0],ke=sn[1];if(!vr.has(or))try{for(var $r=(z=void 0,J([[nr,ke],[ke,nr]])),_r=$r.next();!_r.done;_r=$r.next()){var vt=$(_r.value,2),vn=vt[0],Ct=vt[1];jr("contactEnd",vn,Ct)}}catch(Rr){z={error:Rr}}finally{try{_r&&!_r.done&&(N=$r.return)&&N.call($r)}finally{if(z)throw z.error}}}}catch(Be){E={error:Be}}finally{try{Nr&&!Nr.done&&(A=ut.return)&&A.call(ut)}finally{if(E)throw E.error}}ze=vr,Ae=tr;try{for(var Sn=J(H),Pt=Sn.next();!Pt.done;Pt=Sn.next()){var De=Pt.value;De.elapsed+=r;var Ye=De.parameters,gr=(xe=Ye.delay)!==null&&xe!==void 0?xe:0,sr=De.elapsed-gr;if(!(sr<0)){var Kr=sr/Ye.seconds,wr=Ye.loop?Kr%1:Math.min(1,Kr),ct=(Re=Ye.easing)!==null&&Re!==void 0?Re:"ease-out",Mr=wr;Ye.loop&&ct==="ease-in-out"?Mr=.5-.5*Math.cos(wr*Math.PI*2):ct==="ease-out"?Mr=1-Math.pow(1-wr,3):ct==="ease-in"?Mr=Math.pow(wr,3):ct==="ease-in-out"?Mr=wr<.5?4*Math.pow(wr,3):1-Math.pow(-2*wr+2,3)/2:ct==="back-out"&&(Mr=1+2.70158*Math.pow(wr-1,3)+1.70158*Math.pow(wr-1,2));var ht=Ye.from+(Ye.to-Ye.from)*Mr,qe=We((Ne=De.targetId)!==null&&Ne!==void 0?Ne:De.componentId);if(qe){var Ze=(Fe=Je.get(qe.id))!==null&&Fe!==void 0?Fe:{transform:ie([],$(qe.transform),!1),parameters:{}},Ft=(pe=De.baseTransform)!==null&&pe!==void 0?pe:qe.transform;if(Ye.property==="opacity")Ze.parameters.opacity=Math.max(0,Math.min(1,ht));else if(["scale","scaleX","scaleY","rotation"].includes(Ye.property)){(Ce=Ze.animationAxes)!==null&&Ce!==void 0||(Ze.animationAxes={scale:1,scaleX:1,scaleY:1,rotation:0}),Ze.animationAxes[Ye.property]=ht;var Cn=Ze.animationAxes,Pn=Cn.rotation*Math.PI/180,qt=Math.cos(Pn),ei=Math.sin(Pn),mi=Cn.scale*Cn.scaleX,ri=Cn.scale*Cn.scaleY;Ze.transform[0]=(Ft[0]*qt+Ft[2]*ei)*mi,Ze.transform[1]=(Ft[1]*qt+Ft[3]*ei)*mi,Ze.transform[2]=(-Ft[0]*ei+Ft[2]*qt)*ri,Ze.transform[3]=(-Ft[1]*ei+Ft[3]*qt)*ri}else Ze.transform[Ye.property==="x"?4:5]=ht;Je.set(qe.id,Ze),Ye.loop&&sr>=Ye.seconds&&(De.elapsed=gr+sr%Ye.seconds)}}}}catch(Be){L={error:Be}}finally{try{Pt&&!Pt.done&&(B=Sn.return)&&B.call(Sn)}finally{if(L)throw L.error}}H=H.filter(function(Be){var dr,Gr;return We((dr=Be.targetId)!==null&&dr!==void 0?dr:Be.componentId)&&(Be.elapsed<Be.parameters.seconds+((Gr=Be.parameters.delay)!==null&&Gr!==void 0?Gr:0)||Be.parameters.loop)});try{for(var Tn=J(ye),En=Tn.next();!En.done;En=Tn.next()){var Ye=En.value;if(Ye.age!==void 0){Ye.age+=r;continue}Ye.life-=r,Ye.x+=Ye.vx*r,Ye.y+=Ye.vy*r,Ye.vy+=Ye.gravity*r}}catch(Be){F={error:Be}}finally{try{En&&!En.done&&(Y=Tn.return)&&Y.call(Tn)}finally{if(F)throw F.error}}ye=ye.filter(function(Be){var dr;return Be.life>((dr=Be.age)!==null&&dr!==void 0?dr:0)}),un()}function Yi(r,o){var d,u,s;if(y.beginPath(),r.contract==="native.ellipse.v1")y.ellipse(o.width/2,o.height/2,o.width/2,o.height/2,0,0,Math.PI*2);else if(r.contract==="native.path.v1"){var p=function(M,T){({M:function(){return y.moveTo.apply(y,ie([],$(T),!1))},L:function(){return y.lineTo.apply(y,ie([],$(T),!1))},C:function(){return y.bezierCurveTo.apply(y,ie([],$(T),!1))},Q:function(){return y.quadraticCurveTo.apply(y,ie([],$(T),!1))},Z:function(){return y.closePath()}})[M]()};try{for(var h=J(o.commands),g=h.next();!g.done;g=h.next()){var x=$(g.value),k=x[0],m=x.slice(1);p(k,m)}}catch(M){d={error:M}}finally{try{g&&!g.done&&(u=h.return)&&u.call(h)}finally{if(d)throw d.error}}}else{var C=Math.min((s=o.radius)!==null&&s!==void 0?s:0,o.width/2,o.height/2);typeof y.roundRect=="function"?y.roundRect(0,0,o.width,o.height,C):(y.moveTo(C,0),y.arcTo(o.width,0,o.width,o.height,C),y.arcTo(o.width,o.height,0,o.height,C),y.arcTo(0,o.height,0,0,C),y.arcTo(0,0,o.width,0,C),y.closePath())}}function rf(r,o,d){var u,s,p,h=(u=Je.get(r.id))===null||u===void 0?void 0:u.pathFrame;if(h!==void 0)return Math.min(o.frameCount-1,h);if(S||!o.frameRate)return 0;if(r.contract!=="native.walk-sprite.v1")return Math.floor(Math.max(0,ce-((s=r.spawnTime)!==null&&s!==void 0?s:0))*o.frameRate)%o.frameCount;var g=(p=r.runtimeId)!==null&&p!==void 0?p:r.id,x=di.get(g);if(!x)return di.set(g,{x:d[4],y:d[5],phase:0,lastMove:-1/0,frame:0}),0;var k=Math.hypot(d[4]-x.x,d[5]-x.y)>.3;if(k){var m=ce-x.lastMove;x.phase=Number.isFinite(m)&&m<.25?x.phase+Math.min(m,.12)*o.frameRate:0,x.lastMove=ce}return x.x=d[4],x.y=d[5],ce-x.lastMove>.11&&(x.phase=0),x.frame=Math.floor(x.phase)%o.frameCount,x.frame}var yi=!1,_n={width:390,height:700};function Ra(r){var o,d;r!==yi&&(r?(y.save(),y.beginPath(),y.rect((o=_n.left)!==null&&o!==void 0?o:0,(d=_n.top)!==null&&d!==void 0?d:0,_n.width,_n.height),y.clip(),yi=!0):(y.restore(),yi=!1))}function pi(r,o,d,u,s){var p,h,g,x,k,m,C,M,T;if(o===void 0&&(o=nn()),d===void 0&&(d=[]),s===void 0&&(s=!1),r.contract!=="native.mesh3d.v1"){var I=He(r),E=It("erase-mask",(g=r.prototypeId)!==null&&g!==void 0?g:r.id);if(!(!I.visible||I.opacity<=0)){var A=ii(o,bt(r));yi||Ra(!0),y.save(),y.transform.apply(y,ie([],$(s?A:bt(r)),!1)),y.globalAlpha*=I.opacity;var z=In.get(r.id);z!=null&&z.behavior.liftShadow&&(y.shadowColor="#00000055",y.shadowBlur=8,y.shadowOffsetY=4);var N=d;r.contract==="native.group.v1"&&I.clip&&(y.beginPath(),y.rect(0,0,I.width,I.height),y.clip(),N=ie(ie([],$(d),!1),[{matrix:A,width:I.width,height:I.height}],!1));var L=!1;if(!["native.group.v1","native.text.v1","native.image.v1","native.sprite.v1","native.walk-sprite.v1","native.stage3d.v1","native.mesh3d.v1"].includes(r.contract)){var B=r.contract==="native.button.v1",F=it===r.id,Y=B?I.enabled?F?I.pressedFill:Gt===r.id?I.hoverFill:I.fill:I.disabledFill:I.fill;if(B&&(I.presentation==="pixel-cta"||I.presentation==="shiny-cta")){var X=(x=me.get(r.id))!==null&&x!==void 0?x:$e;ae.set(r.id,X);var te=!S&&!(Z!=null&&Z.matches)?$e-X:-1;I.presentation==="shiny-cta"?wl(y,I,Y,F,te):bl(y,I,Y,F,te)}else I.pixelFrame&&(y.save(),y.translate(3,4),Yi(r,I),y.fillStyle="#3c293366",y.fill(),y.restore()),Yi(r,I),E?(y.save(),y.clip(),ci(r,E).render(y),y.restore(),L=!0,Yi(r,I)):(y.fillStyle=Y,y.fill()),I.pixelFrame&&!(I.radius>0)&&(y.fillStyle="#ffffff22",y.fillRect(2,2,Math.max(0,I.width-4),2),y.fillRect(2,2,2,Math.max(0,I.height-4))),I.strokeWidth&&(y.strokeStyle=I.stroke,y.lineWidth=I.strokeWidth,y.stroke());Dr===r.id&&(Yi(r,I),y.strokeStyle="#ffffff",y.lineWidth=5,y.stroke())}var ue,ne;if(r.contract==="native.text.v1"){var xe=ne=I.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Cr,ur){var Ke;return String((Ke=j[ur])!==null&&Ke!==void 0?Ke:"")});I.pixelPanel&&(y.fillStyle="#3c293366",y.fillRect(3,4,I.width,I.height),y.fillStyle=I.panelFill,y.fillRect(0,0,I.width,I.height),y.strokeStyle=(k=I.panelStroke)!==null&&k!==void 0?k:I.color,y.lineWidth=2,y.strokeRect(1,1,I.width-2,I.height-2),y.fillStyle="#ffffff22",y.fillRect(3,3,Math.max(0,I.width-6),2));var Re=I.fontFamily==="pixel"?_a(xe,I):void 0;Re&&!Re.unsupportedChars.length?ue=pl(y,xe,I):ue=ld(y,xe,Re?ge(ge({},I),{fontFamily:"sans-serif",fontWeight:"700"}):I,e.creativeBrief.language)}if(["native.image.v1","native.sprite.v1","native.walk-sprite.v1"].includes(r.contract)&&!E){var Ne=Se.get(K((C=(m=Je.get(r.id))===null||m===void 0?void 0:m.assetId)!==null&&C!==void 0?C:(M=r.assetSlots[0])===null||M===void 0?void 0:M.assetId));if(Ne!=null&&Ne.complete&&Ne.naturalWidth){y.save(),y.beginPath(),y.rect(0,0,I.width,I.height),y.clip();var Fe=r.contract!=="native.image.v1",pe=Fe?Math.min(I.frameColumns,I.frameCount):1,Ce=Fe?Math.ceil(I.frameCount/pe):1,we=Ne.width/pe,Me=Ne.height/Ce,Ve=Fe?rf(r,I,A):0,he=Ve%pe*we,mr=Math.floor(Ve/pe)*Me,Ee=I.fit==="cover"?Math.max(I.width/we,I.height/Me):Math.min(I.width/we,I.height/Me),fr=I.fit==="stretch"?I.width:we*Ee,Pe=I.fit==="stretch"?I.height:Me*Ee;y.imageSmoothingEnabled=(T=I.smoothing)!==null&&T!==void 0?T:!0,y.drawImage(Ne,he,mr,we,Me,(I.width-fr)/2,(I.height-Pe)/2,fr,Pe),y.restore()}}E&&!L&&ci(r,E).render(y),Ot.push({c:r,m:A,clips:N,instance:u!=null?u:r.prototypeId,textMetrics:ue,textContent:ne});try{for(var ar=J(Xi(r.id)),Ue=ar.next();!Ue.done;Ue=ar.next()){var er=Ue.value;pi(er,A,N,u!=null?u:r.prototypeId)}}catch(Cr){p={error:Cr}}finally{try{Ue&&!Ue.done&&(h=ar.return)&&h.call(ar)}finally{if(p)throw p.error}}I.clip&&r.contract==="native.group.v1"&&Va(r.id),y.restore()}}}function Va(r,o){var d,u;if(!(Z!=null&&Z.matches))try{for(var s=J(ye),p=s.next();!p.done;p=s.next()){var h=p.value;h.shape!=="pixel-confetti"&&h.shape!=="confetti"||h.clipId!==r||!!h.screen!=!!o||(y.save(),h.shape==="confetti"?Il(y,h,o):gl(y,h,o),y.restore())}}catch(g){d={error:g}}finally{try{p&&!p.done&&(u=s.return)&&u.call(s)}finally{if(d)throw d.error}}}function tf(r,o,d,u){y.save(),y.translate(r,o),y.globalAlpha=.92,y.lineWidth=2,y.lineJoin="round",d==="tap"&&(y.strokeStyle="#fff0bd",y.globalAlpha=.7*(1-u),y.beginPath(),y.arc(0,0,12+u*12,0,Math.PI*2),y.stroke(),y.globalAlpha=.92),y.fillStyle="#fff0bd",y.strokeStyle="#193b46",y.beginPath(),y.moveTo(-7,10),y.lineTo(-9,-1),y.quadraticCurveTo(-9,-5,-5,-5),y.lineTo(-3,-3),y.lineTo(-3,-17),y.quadraticCurveTo(-3,-22,1,-22),y.quadraticCurveTo(5,-22,5,-17),y.lineTo(5,-6),y.quadraticCurveTo(9,-9,11,-5),y.quadraticCurveTo(15,-7,16,-2),y.lineTo(14,9),y.quadraticCurveTo(12,18,3,18),y.lineTo(-1,18),y.quadraticCurveTo(-5,17,-7,10),y.closePath(),y.fill(),y.stroke(),y.restore()}function nf(){var r,o,d,u,s,p,h,g,x,k,m,C,M,T,I,E,A,z,N;if(li=0,!S)try{for(var L=J(e.gameplay.filter(function(or){return or.kind==="tutorial-hand"})),B=L.next();!B.done;B=L.next()){var F=B.value,Y=O.get(F.componentId),X=We(F.parameters.targetId);if(!(!Y||Y.sceneId!==_||!X||X.sceneId!==_||!Er(X))&&!(F.parameters.hideOnFirstInput&&Vi)){var te=gn?ce:$e;if(!(te-sa<F.parameters.idleDelaySeconds)){li++;var ue=F.parameters.destinationId?We(F.parameters.destinationId):void 0,ne=He(X),xe=void 0;xe||(xe=cr(yr(X),ne.width/2,ne.height/2));var Re=te%1.2/1.2,Ne=Z!=null&&Z.matches?0:Re*Re*(3-2*Re),Fe=xe.x,pe=xe.y;if(F.parameters.mode!=="tap"){var Ce=ue?cr(yr(ue),He(ue).width/2,He(ue).height/2):{x:xe.x-36,y:xe.y+48};Fe=xe.x+(Ce.x-xe.x)*Ne,pe=xe.y+(Ce.y-xe.y)*Ne}tf(Fe+8,pe+22,F.parameters.mode,Ne)}}}}catch(or){r={error:or}}finally{try{B&&!B.done&&(o=L.return)&&o.call(L)}finally{if(r)throw r.error}}try{for(var we=J(fn),Me=we.next();!Me.done;Me=we.next()){var Ve=$(Me.value,2),he=Ve[0],mr=Ve[1],Ee=It("draw-stroke",he).parameters;try{for(var fr=(s=void 0,J(mr.strokes)),Pe=fr.next();!Pe.done;Pe=fr.next()){var ar=Pe.value;if(!(ar.points.length<2)){y.save(),y.globalAlpha=Ee.mode==="slice-blade"?Math.max(0,1-ar.age/.18):1,y.strokeStyle=Ee.color,y.lineWidth=Ee.strokeWidth,y.lineCap="round",y.lineJoin="round",y.beginPath(),y.moveTo(ar.points[0].x,ar.points[0].y);try{for(var Ue=(h=void 0,J(ar.points.slice(1))),er=Ue.next();!er.done;er=Ue.next()){var Cr=er.value;y.lineTo(Cr.x,Cr.y)}}catch(or){h={error:or}}finally{try{er&&!er.done&&(g=Ue.return)&&g.call(Ue)}finally{if(h)throw h.error}}y.stroke(),y.restore()}}}catch(or){s={error:or}}finally{try{Pe&&!Pe.done&&(p=fr.return)&&p.call(fr)}finally{if(s)throw s.error}}}}catch(or){d={error:or}}finally{try{Me&&!Me.done&&(u=we.return)&&u.call(we)}finally{if(d)throw d.error}}try{for(var ur=J(wn),Ke=ur.next();!Ke.done;Ke=ur.next()){var Fr=Ke.value;if(!(Fr.broken||!Fr.drawRope)){var zt=Bt.get(Fr.bodyId),Mt=We(Fr.anchorId);if(!(!zt||!Mt)){var kt=Or(Mt);y.save(),y.strokeStyle=Fr.ropeColor,y.lineWidth=Fr.ropeWidth,y.beginPath(),y.moveTo(kt.x,kt.y),y.lineTo(zt.x,zt.y),y.stroke(),y.restore()}}}}catch(or){x={error:or}}finally{try{Ke&&!Ke.done&&(k=ur.return)&&k.call(ur)}finally{if(x)throw x.error}}try{for(var Qr=J(e.gameplay.filter(function(or){var dt;return or.kind==="virtual-joystick"&&((dt=O.get(or.componentId))===null||dt===void 0?void 0:dt.sceneId)===_})),Ar=Qr.next();!Ar.done;Ar=Qr.next()){var F=Ar.value,Jr=We(F.componentId),ne=F.parameters;if(!(!Jr||!Er(Jr)||ne.drawControl===!1)){var qr=dn.get(F.id),Xr=qr&&qr.pointerId!==null?qr.origin:Or(Jr),Zr=qr&&qr.pointerId!==null?qr.knobX:Xr.x,vr=qr&&qr.pointerId!==null?qr.knobY:Xr.y,tr=(A=ne.radiusPx)!==null&&A!==void 0?A:56;y.save(),y.fillStyle=(z=ne.baseColor)!==null&&z!==void 0?z:"#ffffff44",y.strokeStyle="#ffffffaa",y.lineWidth=2.5,y.beginPath(),y.arc(Xr.x,Xr.y,tr,0,Math.PI*2),y.fill(),y.stroke(),y.fillStyle=(N=ne.knobColor)!==null&&N!==void 0?N:"#fff0bdee",y.strokeStyle="#193b46aa",y.lineWidth=2,y.beginPath(),y.arc(Zr,vr,tr*.42,0,Math.PI*2),y.fill(),y.stroke(),y.restore()}}}catch(or){m={error:or}}finally{try{Ar&&!Ar.done&&(C=Qr.return)&&C.call(Qr)}finally{if(m)throw m.error}}try{for(var jr=J(st),nt=jr.next();!nt.done;nt=jr.next()){var De=nt.value,nr=Math.min(1,De.elapsed/De.seconds);y.save(),y.globalAlpha=1-nr,y.fillStyle=De.color,y.strokeStyle="#193b46",y.lineWidth=3,y.font="900 "+De.fontSize+"px sans-serif",y.textAlign="center",y.textBaseline="middle";var pe=De.y-(Z!=null&&Z.matches?0:De.risePx*nr);y.strokeText(De.text,De.x,pe),y.fillText(De.text,De.x,pe),y.restore()}}catch(or){M={error:or}}finally{try{nt&&!nt.done&&(T=jr.return)&&T.call(jr)}finally{if(M)throw M.error}}try{for(var ke=J(et),Br=ke.next();!Br.done;Br=ke.next()){var ft=Br.value,nr=Math.min(1,ft.elapsed/ft.seconds),gt=R();y.save(),y.globalAlpha=ft.opacity*(1-nr),y.fillStyle=ft.color,y.fillRect(0,0,gt.width,gt.height),y.restore()}}catch(or){I={error:or}}finally{try{Br&&!Br.done&&(E=ke.return)&&E.call(ke)}finally{if(I)throw I.error}}}function af(){if(Xe){var r=Bt.get(Xe.targetId),o=Xe.behavior.parameters;if(r){var d=Xe.current.x-Xe.start.x,u=Xe.current.y-Xe.start.y,s=Math.hypot(d,u),p=Math.min(o.maxPullPx,s),h=s>.001?p/s:0;y.save(),y.lineCap="round";var g=Math.max(12,Math.min(r.width,r.height)*.62);if(y.strokeStyle="#173a2f66",y.lineWidth=3.5,y.beginPath(),y.arc(r.x,r.y,g,0,Math.PI*2),y.stroke(),y.strokeStyle=o.trajectoryColor,y.lineWidth=2,y.beginPath(),y.arc(r.x,r.y,g,0,Math.PI*2),y.stroke(),o.showTrajectory&&s>=o.minPullPx){var x=Ba(),k=xo(),m=k.bodies,C=k.zones,M=R(),T=sl({body:ge(ge({},r),{vx:x.vx,vy:x.vy,atRest:!1}),bodies:m,zones:C,bounds:{left:0,top:0,right:M.width,bottom:M.height},dots:o.trajectoryDots,bounces:o.trajectoryBounces});T.forEach(function(A,z){var N=.96-.52*(z/Math.max(1,T.length)),L=Math.max(2.2,4.5-z*.22);y.globalAlpha=N,y.fillStyle="#173a2f88",y.beginPath(),y.arc(A.x,A.y,L+1.3,0,Math.PI*2),y.fill(),y.fillStyle=o.trajectoryColor,y.beginPath(),y.arc(A.x,A.y,L,0,Math.PI*2),y.fill()})}if(s>=4){var I=r.x+d*h,E=r.y+u*h;y.globalAlpha=.9,y.strokeStyle="#173a2f66",y.lineWidth=5,y.beginPath(),y.moveTo(r.x,r.y),y.lineTo(I,E),y.stroke(),y.strokeStyle=o.trajectoryColor,y.lineWidth=2.6,y.beginPath(),y.moveTo(r.x,r.y),y.lineTo(I,E),y.stroke(),y.fillStyle="#173a2f88",y.beginPath(),y.arc(I,E,5.2,0,Math.PI*2),y.fill(),y.fillStyle=o.trajectoryColor,y.beginPath(),y.arc(I,E,3.6,0,Math.PI*2),y.fill()}y.restore()}}}function of(r){var o,d,u,s;try{for(var p=J(yo()),h=p.next();!h.done;h=p.next()){var g=h.value,x=g.contract==="native.group.v1"?Xi(g.id):[g];try{for(var k=(u=void 0,J(x)),m=k.next();!m.done;m=k.next()){var C=m.value;if(C.contract==="native.stage3d.v1"&&Er(C)&&He(C).skyColor)return He(C).skyColor;if(!(C.contract!=="native.rectangle.v1"||!Er(C))){var M=He(C);if(!(M.opacity<.95||!M.fill||M.fill==="transparent")&&(/(?:^|\.)(background|backdrop|bg)(?:\.fill)?$/.test(C.id)||M.width>=r.width*.9&&M.height>=r.height*.9))return M.fill}}}catch(T){u={error:T}}finally{try{m&&!m.done&&(s=k.return)&&s.call(k)}finally{if(u)throw u.error}}}}catch(T){o={error:T}}finally{try{h&&!h.done&&(d=p.return)&&d.call(p)}finally{if(o)throw o.error}}return"#102a34"}function lf(){var r;if(bn&&Er(bn.c)){var o=bn.c,d=He(o);y.save(),y.transform.apply(y,ie([],$(yr(o)),!1)),y.strokeStyle=(r=bn.highlightColor)!==null&&r!==void 0?r:"#ffffff",y.lineWidth=4,y.globalAlpha=.85,y.strokeRect(-4,-4,d.width+8,d.height+8),y.restore()}if(Ge!=null&&Ge.b.parameters.bringToFront){var o=We(Ge.targetId);o&&pi(o,o.parentId?yr(We(o.parentId)):nn(),[],o.prototypeId)}}function tt(){var r,o,d,u,s,p;me=ae,ae=new Map;var h=R();ve!==void 0&&ve!==h.landscape&&Qt(),ve=h.landscape;var g=Math.min(devicePixelRatio||1,2),x=t.clientWidth,k=t.clientHeight;(t.width!==Math.round(x*g)||t.height!==Math.round(k*g))&&(t.width=Math.round(x*g),t.height=Math.round(k*g)),y.setTransform(g,0,0,g,0,0),y.fillStyle=of(h),y.fillRect(0,0,x,k);var m=Math.min(x/h.width,k/h.height),C=(x-h.width*m)/2,M=(k-h.height*m)/2;if(Ol=m||1,Bl=g,y.translate(C,M),y.scale(m,m),Wr){var T=Math.min(1,Wr.elapsed/Wr.seconds),I=Wr.intensity*(1-T);y.translate(Math.sin(Wr.elapsed*95)*I,Math.cos(Wr.elapsed*113)*I)}_n=h,yi=!1,_n=Fi(h),Ot=[];try{for(var E=J(yo()),A=E.next();!A.done;A=E.next()){var z=A.value;pi(z)}}catch(pe){r={error:pe}}finally{try{A&&!A.done&&(o=E.return)&&o.call(E)}finally{if(r)throw r.error}}Ra(!0);try{for(var N=J(se),L=N.next();!L.done;L=N.next()){var z=L.value;z.parentId||pi(z,nn(),[],z.prototypeId)}}catch(pe){d={error:pe}}finally{try{L&&!L.done&&(u=N.return)&&u.call(N)}finally{if(d)throw d.error}}if(lf(),af(),S&&Zt){for(var B=O.get(Zt);B!=null&&B.parentId;)B=O.get(B.parentId);B!=null&&B.prototype&&pi(B)}Va(),y.save();try{for(var F=J(ye),Y=F.next();!Y.done;Y=F.next()){var X=Y.value;if(X.age===void 0){var te=Math.min(1,X.life*2),ue=1.5+2.5*te;if(y.globalAlpha=te,y.globalCompositeOperation=X.shape==="square"?"source-over":"lighter",y.fillStyle=X.color,X.shape==="square"){var ne=Math.max(2,Math.round(ue*1.6));y.fillRect(Math.round(X.x-ne/2),Math.round(X.y-ne/2),ne,ne);continue}y.globalCompositeOperation="lighter",y.shadowColor=X.color,y.shadowBlur=ye.length<=16?6:0,y.strokeStyle=X.color,y.lineWidth=1.5+te,y.beginPath(),y.moveTo(X.x-X.vx*.025,X.y-X.vy*.025),y.lineTo(X.x,X.y),y.stroke(),y.beginPath(),y.arc(X.x,X.y,ue,0,Math.PI*2),y.fill()}}}catch(pe){s={error:pe}}finally{try{Y&&!Y.done&&(p=F.return)&&p.call(F)}finally{if(s)throw s.error}}if(y.restore(),nf(),S&&Zt){var xe=Ot.filter(function(pe){return pe.c.contract!=="native.group.v1"&&(pe.c.id===Zt||wt(pe.c,Zt))});if(xe.length){var Re=xe.map(function(pe){return lt(pe.c,pe.m)}),Ne=Math.min.apply(Math,ie([],$(Re.map(function(pe){return pe.left})),!1)),Fe=Math.min.apply(Math,ie([],$(Re.map(function(pe){return pe.top})),!1));y.strokeStyle="#55e6ef",y.lineWidth=2/m,y.strokeRect(Ne,Fe,Math.max.apply(Math,ie([],$(Re.map(function(pe){return pe.right})),!1))-Ne,Math.max.apply(Math,ie([],$(Re.map(function(pe){return pe.bottom})),!1))-Fe)}}Ra(!1),m>0&&Va(void 0,{x:-C/m,y:-M/m,width:x/m,height:k/m})}function ff(r){var o,d,u,s,p=Array.isArray(r)?ie([],$(new Set(r)),!1):void 0;tt();var h=R(),g=Fi(h),x=new Set,k=[];try{for(var m=J(Ot),C=m.next();!C.done;C=m.next()){var M=C.value,T=(u=M.c.prototypeId)!==null&&u!==void 0?u:M.c.id;if(!(M.c.contract==="native.group.v1"||p&&!p.includes(T))){x.add(T);var I=lt(M.c,M.m),E=((s=He(M.c).strokeWidth)!==null&&s!==void 0?s:0)/2;I.left-=E,I.right+=E,I.top-=E,I.bottom+=E;var A={left:Math.max(0,g.left-I.left),right:Math.max(0,I.right-g.right),top:Math.max(0,g.top-I.top),bottom:Math.max(0,I.bottom-g.bottom)};Object.values(A).some(function(N){return N>.01})&&k.push({id:T,contract:M.c.contract,bounds:I,overflow:A})}}}catch(N){o={error:N}}finally{try{C&&!C.done&&(d=m.return)&&d.call(m)}finally{if(o)throw o.error}}var z=p?p.filter(function(N){return!x.has(N)}):[];return{ok:k.length===0&&z.length===0,viewport:ge(ge({},h),{canvasWidth:t.clientWidth,canvasHeight:t.clientHeight}),issues:k,missing:z}}function df(r){var o,d,u,s,p,h,g,x,k,m,C,M,T,I,E,A,z,N,L,B,F,Y,X,te,ue,ne,xe,Re,Ne,Fe,pe,Ce,we,Me=r===void 0?{}:r,Ve=Me.ids,he=Me.interactiveIds,mr=Me.network,Ee=mr===void 0?"standalone":mr,fr=Me.minTouchPx,Pe=fr===void 0?44:fr,ar=Array.isArray(Ve)?ie([],$(new Set(Ve)),!1):void 0;tt();var Ue=R(),er=Fi(Ue),Cr=Math.min(t.clientWidth/Ue.width,t.clientHeight/Ue.height),ur=uo(er,Ee),Ke=[],Fr=new Set,zt=function(V){var Ie;return!ar||ar.includes((Ie=V.c.prototypeId)!==null&&Ie!==void 0?Ie:V.c.id)},Mt=Ot.filter(zt),kt=new Set(e.events.filter(function(V){return V.kind==="click"}).map(function(V){return V.componentId}));try{for(var Qr=J(e.gameplay),Ar=Qr.next();!Ar.done;Ar=Qr.next()){var Jr=Ar.value;["drag","match-tile","aim-launch","aim-launch-3d","swipe-input","hold-charge","virtual-joystick","draw-stroke","erase-mask"].includes(Jr.kind)&&kt.add(Jr.componentId)}}catch(V){o={error:V}}finally{try{Ar&&!Ar.done&&(d=Qr.return)&&d.call(Qr)}finally{if(o)throw o.error}}var qr=new Set(he!=null?he:kt),Xr=new Set(ie(ie([],$(e.gameplay.filter(function(V){return["aim-launch","aim-launch-3d","swipe-input","hold-charge","draw-stroke","virtual-joystick"].includes(V.kind)&&(V.parameters.dragMode==="anywhere"||V.kind==="draw-stroke"||V.kind==="virtual-joystick"&&V.parameters.mode==="floating")}).map(function(V){return V.componentId})),!1),$(e.components.filter(function(V){return V.contract==="native.stage3d.v1"}).map(function(V){return V.id})),!1)),Zr=function(V){var Ie;return qr.has((Ie=V.c.prototypeId)!==null&&Ie!==void 0?Ie:V.c.id)},vr=function(V,Ie,Oe,Qe,kr,pr){return Ke.push(ge(ge({kind:V,severity:Ie,id:Oe},pr?{otherId:pr}:{}),{detail:Qe,metrics:kr}))},tr=function(V){var Ie=[[0,0],[V.width,0],[V.width,V.height],[0,V.height]].map(function(Oe){var Qe=$(Oe,2),kr=Qe[0],pr=Qe[1];return cr(V.matrix,kr,pr)});return{left:Math.min.apply(Math,ie([],$(Ie.map(function(Oe){return Oe.x})),!1)),right:Math.max.apply(Math,ie([],$(Ie.map(function(Oe){return Oe.x})),!1)),top:Math.min.apply(Math,ie([],$(Ie.map(function(Oe){return Oe.y})),!1)),bottom:Math.max.apply(Math,ie([],$(Ie.map(function(Oe){return Oe.y})),!1))}};try{for(var jr=J(Mt),nt=jr.next();!nt.done;nt=jr.next()){var De=nt.value,nr=(X=De.c.prototypeId)!==null&&X!==void 0?X:De.c.id;Fr.add(nr);var ke=lt(De.c,De.m),Br=((te=He(De.c).strokeWidth)!==null&&te!==void 0?te:0)/2;ke.left-=Br,ke.right+=Br,ke.top-=Br,ke.bottom+=Br;var ft=De.c.contract==="native.group.v1"&&!He(De.c).clip,gt=De.c.contract==="native.image.v1"&&De.clips.length===0&&He(De.c).fit==="cover"&&ke.left<=0&&ke.top<=0&&ke.right>=Ue.width&&ke.bottom>=Ue.height||De.c.contract==="native.stage3d.v1"&&ke.left<=0&&ke.top<=0&&ke.right>=Ue.width&&ke.bottom>=Ue.height,or=De.c.contract==="native.rectangle.v1"&&Br===0&&ke.left<=0&&ke.top<=0&&ke.right>=Ue.width&&ke.bottom>=Ue.height||gt;if(!ft){var dt={left:Math.max(0,er.left-ke.left),right:Math.max(0,ke.right-er.right),top:Math.max(0,er.top-ke.top),bottom:Math.max(0,ke.bottom-er.bottom)};if(!or&&!Co(De.c)&&Object.values(dt).some(function(V){return V>.01})&&vr("stage-overflow","blocker",nr,"Component extends beyond the active stage.",{bounds:ke,overflow:dt}),De.c.contract==="native.image.v1"&&De.clips.length===0){var St=ke.right-ke.left,kn=ke.bottom-ke.top,vn=/(?:^|\.)(backdrop|background|bg)$/.test(nr)||He(De.c).fit==="cover"&&!De.c.parentId&&ke.left<=1&&ke.top<=1&&(St>=Ue.width*.4||kn>=Ue.height*.4);vn&&(ke.left>.5||ke.top>.5||ke.right<Ue.width-.5||ke.bottom<Ue.height-.5)&&vr("backdrop-incomplete","blocker",nr,"Backdrop image does not cover the full active stage, leaving a visible seam.",{bounds:ke,stage:{width:Ue.width,height:Ue.height}})}try{for(var Ct=(p=void 0,J(De.clips)),ut=Ct.next();!ut.done;ut=Ct.next()){var Nr=ut.value,Ur=tr(Nr),sn={left:Math.max(0,Ur.left-ke.left),right:Math.max(0,ke.right-Ur.right),top:Math.max(0,Ur.top-ke.top),bottom:Math.max(0,ke.bottom-Ur.bottom)};Object.values(sn).some(function(V){return V>.01})&&vr("parent-clip-crop","blocker",nr,"Component is cropped by an ancestor clipping group.",{bounds:ke,clip:Ur,crop:sn})}}catch(V){p={error:V}}finally{try{ut&&!ut.done&&(h=Ct.return)&&h.call(Ct)}finally{if(p)throw p.error}}}if(De.textMetrics){var $r=De.textMetrics;$r.overflowsWidth&&vr("text-overflow","blocker",nr,"Text exceeds its component width after wrapping and auto-fit.",$r),$r.overflowsHeight&&vr("text-clipped","blocker",nr,"Text is vertically clipped by its component after wrapping and auto-fit.",$r);var _r=(ue=$r.fontSize)!==null&&ue!==void 0?ue:$r.scale*8;_r<12&&vr("text-illegible",_r<8?"blocker":"warning",nr,"Rendered text is below the recommended legible size.",ge({renderedFontSize:_r},$r));var vt=He(De.c),Sn=vt.direction==="rtl"||vt.direction!=="ltr"&&/^(ar|fa|he|iw|ps|sd|ug|ur|yi)(?:-|$)/.test(e.creativeBrief.language);if(Sn&&$r.resolvedAlign==="left"&&vr("rtl-alignment","blocker",nr,"Right-to-left copy must resolve to right or center alignment.",{direction:"rtl",align:vt.align,resolvedAlign:$r.resolvedAlign}),vt.pixelPanel&&vt.align!=="center"){var Pt=Math.max(0,vt.width-2*(vt.padding===void 0?8:vt.padding));Pt-((ne=$r.renderedWidth)!==null&&ne!==void 0?ne:0)>12&&vr("panel-off-center","blocker",nr,"Text inside a framed pixel panel is not horizontally centered.",{align:vt.align,innerWidth:Pt,renderedWidth:(xe=$r.renderedWidth)!==null&&xe!==void 0?xe:0})}}if(Zr(De)&&!Xr.has(nr)&&(De.c.contract!=="native.group.v1"||ke.right>ke.left&&ke.bottom>ke.top)){var Ye=(ke.right-ke.left)*Cr,gr=(ke.bottom-ke.top)*Cr;(Ye<Pe-.01||gr<Pe-.01)&&vr("touch-target-small","blocker",nr,"Interactive target is smaller than the required physical touch size.",{width:Ye,height:gr,minTouchPx:Pe,scale:Cr})}if(Zr(De)&&!Xr.has(nr)||De.c.contract==="native.text.v1")try{for(var sr=(g=void 0,J(ur.zones)),Kr=sr.next();!Kr.done;Kr=sr.next()){var wr=Kr.value,Ye=Math.min(ke.right,wr.right)-Math.max(ke.left,wr.left),gr=Math.min(ke.bottom,wr.bottom)-Math.max(ke.top,wr.top);Ye>.01&&gr>.01&&vr("sdk-safe-area-collision","blocker",nr,"Component intersects a reserved ad-SDK overlay zone.",{bounds:ke,zone:wr,intersection:{width:Ye,height:gr},network:Ee})}}catch(V){g={error:V}}finally{try{Kr&&!Kr.done&&(x=sr.return)&&x.call(sr)}finally{if(g)throw g.error}}}}catch(V){u={error:V}}finally{try{nt&&!nt.done&&(s=jr.return)&&s.call(jr)}finally{if(u)throw u.error}}for(var ct=Mt.filter(function(V){return Zr(V)&&V.c.contract!=="native.group.v1"&&V.c.contract!=="native.stage3d.v1"}),Mr=0;Mr<ct.length;Mr++)for(var ht=Mr+1;ht<ct.length;ht++){var qe=ct[Mr],Ze=ct[ht],Ft=(Re=qe.c.prototypeId)!==null&&Re!==void 0?Re:qe.c.id,Cn=(Ne=Ze.c.prototypeId)!==null&&Ne!==void 0?Ne:Ze.c.id;if(!(Ft===Cn||wt(qe.c,Ze.c.id)||wt(Ze.c,qe.c.id))){var Pn=lt(qe.c,qe.m),qt=lt(Ze.c,Ze.m),Ye=Math.min(Pn.right,qt.right)-Math.max(Pn.left,qt.left),gr=Math.min(Pn.bottom,qt.bottom)-Math.max(Pn.top,qt.top);Ye>1&&gr>1&&vr("interactive-overlap","blocker",Ft,"Interactive targets overlap.",{intersection:{width:Ye,height:gr},first:Pn,second:qt},Cn)}}var ei=function(V){if(!V||V==="transparent")return!1;var Ie=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(V);if(Ie)return Ie[1].length===4?Ie[1][3].toLowerCase()==="f":Ie[1].slice(6).toLowerCase()==="ff";var Oe=/^rgba\([^,]+,[^,]+,[^,]+,\s*([0-9.]+)\s*\)$/i.exec(V);return Oe?Number(Oe[1])>=.95:!0},mi=[];Mt.forEach(function(V,Ie){var Oe,Qe;V.c.contract==="native.rectangle.v1"&&!Zr(V)&&((Oe=He(V.c).opacity)!==null&&Oe!==void 0?Oe:1)>=.95&&ei(He(V.c).fill)&&mi.push({rowIndex:Ie,row:V,order:(Qe=V.c.order)!==null&&Qe!==void 0?Qe:0,bounds:lt(V.c,V.m)})});var ri=Mt.filter(function(V,Ie){var Oe,Qe=lt(V.c,V.m),kr=(Oe=V.c.order)!==null&&Oe!==void 0?Oe:0;return!mi.some(function(pr){return pr.rowIndex>Ie&&pr.order>kr&&pr.row.c.id!==V.c.id&&!wt(pr.row.c,V.c.id)&&!wt(V.c,pr.row.c.id)&&pr.bounds.left<=Qe.left+1&&pr.bounds.right>=Qe.right-1&&pr.bounds.top<=Qe.top+1&&pr.bounds.bottom>=Qe.bottom-1})}),Tn=ri.map(function(V,Ie){return{row:V,rowIndex:Ie}}).filter(function(V){var Ie,Oe=V.row;if(Oe.c.contract!=="native.rectangle.v1")return!1;var Qe=lt(Oe.c,Oe.m),kr=Qe.right-Qe.left,pr=Qe.bottom-Qe.top,At=((Ie=He(Oe.c).strokeWidth)!==null&&Ie!==void 0?Ie:0)===0&&Qe.left<=0&&Qe.right>=Ue.width;return!At&&kr>=180&&pr>=140&&!Zr(Oe)}).map(function(V){var Ie,Oe=V.row,Qe=V.rowIndex;return{id:(Ie=Oe.c.prototypeId)!==null&&Ie!==void 0?Ie:Oe.c.id,row:Oe,rowIndex:Qe,bounds:lt(Oe.c,Oe.m)}}),En=function(V,Ie,Oe,Qe){var kr,pr;Qe===void 0&&(Qe=!1);var At=(kr=V.c.prototypeId)!==null&&kr!==void 0?kr:V.c.id,ki=(Oe.left+Oe.right)/2,cn=(Oe.top+Oe.bottom)/2,Xa=(pr=V.c.order)!==null&&pr!==void 0?pr:0;return Tn.filter(function(hr){var hn;return hr.id!==At&&(!Qe||hr.rowIndex<Ie||((hn=hr.row.c.order)!==null&&hn!==void 0?hn:0)===Xa)&&Oe.right-Oe.left<=hr.bounds.right-hr.bounds.left+4&&Oe.bottom-Oe.top<=hr.bounds.bottom-hr.bounds.top+4&&ki>=hr.bounds.left&&ki<=hr.bounds.right&&cn>=hr.bounds.top&&cn<=hr.bounds.bottom}).sort(function(hr,hn){return(hr.bounds.right-hr.bounds.left)*(hr.bounds.bottom-hr.bounds.top)-(hn.bounds.right-hn.bounds.left)*(hn.bounds.bottom-hn.bounds.top)||hn.rowIndex-hr.rowIndex})[0]},Be=new Map,dr=new Map;if(Tn.length){ri.forEach(function(V,Ie){var Oe,Qe=(Oe=V.c.prototypeId)!==null&&Oe!==void 0?Oe:V.c.id,kr=lt(V.c,V.m),pr=(kr.left+kr.right)/2,At=(kr.top+kr.bottom)/2,ki=V.c.contract==="native.button.v1"&&!Dt.has(V.c.id),cn=V.c.parentId?We(V.c.parentId):void 0,Xa=V.c.contract==="native.text.v1"&&He(V.c).align==="center"&&(cn==null?void 0:cn.contract)!=="native.button.v1";if(ki||Xa){var hr=En(V,Ie,kr,!1);hr&&(Be.has(hr.id)||Be.set(hr.id,{panel:hr,items:[]}),Be.get(hr.id).items.push({id:Qe,bounds:kr,cx:pr,cy:At,isBtn:ki}))}if(["native.text.v1","native.image.v1","native.button.v1"].includes(V.c.contract)&&(cn==null?void 0:cn.contract)!=="native.button.v1"){var hr=En(V,Ie,kr,!0);hr&&(dr.has(hr.id)||dr.set(hr.id,{panel:hr,content:[]}),dr.get(hr.id).content.push({row:V,id:Qe,bounds:kr}))}});try{for(var Gr=J(Be.values()),Rr=Gr.next();!Rr.done;Rr=Gr.next()){var Tt=Rr.value,xr=Tt.panel,yt=Tt.items;if(yt.some(function(V){return V.isBtn})){var ir=xr.bounds,jt=(ir.left+ir.right)/2;try{for(var Et=(C=void 0,J(yt)),_t=Et.next();!_t.done;_t=Et.next()){var Xt=_t.value,en={left:Xt.bounds.left-ir.left,right:ir.right-Xt.bounds.right,top:Xt.bounds.top-ir.top,bottom:ir.bottom-Xt.bounds.bottom},ti=Math.min(en.left,en.right,en.top,en.bottom);(ti<10||ti*Cr<8)&&vr("panel-edge-cramped","blocker",Xt.id,"Element sits too close to its enclosing panel edge.",{panelId:xr.id,margins:en,scale:Cr,minStagePx:10,minCssPx:8},xr.id)}}catch(V){C={error:V}}finally{try{_t&&!_t.done&&(M=Et.return)&&M.call(Et)}finally{if(C)throw C.error}}var Da=[],xf=function(V){var Ie=Da.find(function(Oe){return Math.abs(Oe.cy-V.cy)<=16&&Oe.isBtn===V.isBtn});Ie?Ie.items.push(V):Da.push({cy:V.cy,isBtn:V.isBtn,items:[V]})};try{for(var Qi=(T=void 0,J(yt)),gi=Qi.next();!gi.done;gi=Qi.next()){var Xt=gi.value;xf(Xt)}}catch(V){T={error:V}}finally{try{gi&&!gi.done&&(I=Qi.return)&&I.call(Qi)}finally{if(T)throw T.error}}try{for(var Ji=(E=void 0,J(Da)),xi=Ji.next();!xi.done;xi=Ji.next()){var Ha=xi.value,If=Math.min.apply(Math,ie([],$(Ha.items.map(function(V){return V.bounds.left})),!1)),bf=Math.max.apply(Math,ie([],$(Ha.items.map(function(V){return V.bounds.right})),!1)),Wo=(If+bf)/2,No=Wo-jt;Math.abs(No)>3&&vr("panel-off-center","blocker",Ha.items[0].id,"Element is not horizontally centered inside its enclosing panel.",{panelId:xr.id,offsetX:No,groupCenterX:Wo,panelCenterX:jt,scale:Cr},xr.id)}}catch(V){E={error:V}}finally{try{xi&&!xi.done&&(A=Ji.return)&&A.call(Ji)}finally{if(E)throw E.error}}}}}catch(V){k={error:V}}finally{try{Rr&&!Rr.done&&(m=Gr.return)&&m.call(Gr)}finally{if(k)throw k.error}}try{for(var qi=J(dr.values()),Ii=qi.next();!Ii.done;Ii=qi.next())for(var Lo=Ii.value,xr=Lo.panel,ji=Lo.content,wf=Be.has(xr.id),Mr=0;Mr<ji.length;Mr++)for(var ht=Mr+1;ht<ji.length;ht++){var qe=ji[Mr],Ze=ji[ht];if(!(qe.id===Ze.id||wt(qe.row.c,Ze.row.c.id)||wt(Ze.row.c,qe.row.c.id))){var Mf=qe.row.c.contract==="native.image.v1"&&Ze.row.c.contract==="native.image.v1";if(!(Mf&&(!wf||qe.row.c.parentId&&qe.row.c.parentId===Ze.row.c.parentId))){var Ye=Math.min(qe.bounds.right,Ze.bounds.right)-Math.max(qe.bounds.left,Ze.bounds.left),gr=Math.min(qe.bounds.bottom,Ze.bounds.bottom)-Math.max(qe.bounds.top,Ze.bounds.top);Ye>2&&gr>2&&vr("panel-content-overlap","blocker",qe.id,"Panel elements overlap each other.",{panelId:xr.id,intersection:{width:Ye,height:gr},first:qe.bounds,second:Ze.bounds},Ze.id)}}}}catch(V){z={error:V}}finally{try{Ii&&!Ii.done&&(N=qi.return)&&N.call(qi)}finally{if(z)throw z.error}}}var ni=ri.filter(function(V){if(V.c.contract!=="native.text.v1")return!1;var Ie=V.c.parentId?We(V.c.parentId):void 0;return(Ie==null?void 0:Ie.contract)!=="native.button.v1"}).map(function(V){var Ie,Oe,Qe=String((Ie=He(V.c).text)!==null&&Ie!==void 0?Ie:"").replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(kr,pr){var At;return String((At=j[pr])!==null&&At!==void 0?At:"")}).trim();return{row:V,id:(Oe=V.c.prototypeId)!==null&&Oe!==void 0?Oe:V.c.id,bounds:lt(V.c,V.m),raw:Qe,norm:Qe.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}}).filter(function(V){return V.raw.length>0}),kf=Tn.filter(function(V){var Ie,Oe;return((Ie=Be.get(V.id))===null||Ie===void 0?void 0:Ie.items.some(function(Qe){return Qe.isBtn}))||((Oe=dr.get(V.id))===null||Oe===void 0?void 0:Oe.content.some(function(Qe){return Qe.row.c.contract==="native.button.v1"}))});try{for(var _i=J(kf),bi=_i.next();!bi.done;bi=_i.next()){var xr=bi.value,ir=xr.bounds,jt=(ir.left+ir.right)/2,Sf=ir.right-ir.left;try{for(var ea=(F=void 0,J(ni)),wi=ea.next();!wi.done;wi=ea.next()){var rn=wi.value;if(He(rn.row.c).align==="center"&&!(rn.bounds.bottom>ir.top+6||ir.top-rn.bounds.bottom>48)){var Do=rn.bounds.right-rn.bounds.left,Mi=(rn.bounds.left+rn.bounds.right)/2,Cf=Math.min(rn.bounds.right,ir.right)-Math.max(rn.bounds.left,ir.left);(Mi>=ir.left&&Mi<=ir.right||Cf>=Do*.6)&&Do<=Sf+60&&Math.abs(Mi-jt)>4&&vr("header-off-center","blocker",rn.id,"Centered text above a panel is not horizontally aligned with the panel below it.",{panelId:xr.id,offsetX:Mi-jt,textCenterX:Mi,panelCenterX:jt,scale:Cr},xr.id)}}}catch(Qe){F={error:Qe}}finally{try{wi&&!wi.done&&(Y=ea.return)&&Y.call(ea)}finally{if(F)throw F.error}}}}catch(V){L={error:V}}finally{try{bi&&!bi.done&&(B=_i.return)&&B.call(_i)}finally{if(L)throw L.error}}for(var Mr=0;Mr<ni.length;Mr++)for(var ht=Mr+1;ht<ni.length;ht++){var qe=ni[Mr],Ze=ni[ht];if(!(qe.id===Ze.id||wt(qe.row.c,Ze.row.c.id)||wt(Ze.row.c,qe.row.c.id))){var Ye=Math.min(qe.bounds.right,Ze.bounds.right)-Math.max(qe.bounds.left,Ze.bounds.left),gr=Math.min(qe.bounds.bottom,Ze.bounds.bottom)-Math.max(qe.bounds.top,Ze.bounds.top);if(Ye>2&&gr>2&&vr("panel-content-overlap","blocker",qe.id,"Visible text elements overlap.",{intersection:{width:Ye,height:gr},first:qe.bounds,second:Ze.bounds},Ze.id),qe.norm&&Ze.norm){var Ho=$(qe.norm.length<=Ze.norm.length?[qe.norm,Ze.norm]:[Ze.norm,qe.norm],2),ra=Ho[0],Fo=Ho[1];(ra===Fo&&ra.length>=6||ra.length>=12&&Fo.includes(ra))&&vr("duplicate-visible-copy","blocker",qe.id,"Duplicate visible copy appears in multiple text elements simultaneously.",{first:qe.raw,second:Ze.raw},Ze.id)}}}var tn=ni.filter(function(V){return!/^[\d\s/.,:%+\-x]+$/i.test(V.raw)}),ta=tn.reduce(function(V,Ie){return V+(Ie.norm?Ie.norm.split(" ").filter(Boolean).length:0)},0),Fa=tn.reduce(function(V,Ie){return V+Ie.raw.replace(/\s+/g," ").length},0);ta>20||Fa>130||tn.length>5?vr("text-clutter-heavy","blocker",(pe=(Fe=tn[0])===null||Fe===void 0?void 0:Fe.id)!==null&&pe!==void 0?pe:null,"Too much visible copy on one screen; keep playable ads visual and concise.",{blocks:tn.length,wordCount:ta,charCount:Fa,texts:tn.map(function(V){return V.raw})}):(ta>12||tn.length>4)&&vr("text-clutter-heavy","warning",(we=(Ce=tn[0])===null||Ce===void 0?void 0:Ce.id)!==null&&we!==void 0?we:null,"Screen copy is getting dense; consider trimming narration so gameplay carries the experience.",{blocks:tn.length,wordCount:ta,charCount:Fa,texts:tn.map(function(V){return V.raw})});var Xo=ar?ar.filter(function(V){if(Fr.has(V))return!1;var Ie=We(V);return(Ie==null?void 0:Ie.contract)==="native.mesh3d.v1"?!1:!Ie||Er(Ie)}):[];return{ok:!Ke.some(function(V){return V.severity==="blocker"})&&Xo.length===0,viewport:ge(ge({},Ue),{canvasWidth:t.clientWidth,canvasHeight:t.clientHeight,scale:Cr}),defects:Ke,missing:Xo,interactive:ct.map(function(V){var Ie;return{id:(Ie=V.c.prototypeId)!==null&&Ie!==void 0?Ie:V.c.id,bounds:lt(V.c,V.m)}}),texts:Mt.filter(function(V){return V.c.contract==="native.text.v1"}).map(function(V){var Ie,Oe,Qe,kr,pr,At;return{id:(Ie=V.c.prototypeId)!==null&&Ie!==void 0?Ie:V.c.id,text:(Oe=V.textContent)!==null&&Oe!==void 0?Oe:"",direction:(kr=(Qe=V.textMetrics)===null||Qe===void 0?void 0:Qe.direction)!==null&&kr!==void 0?kr:"ltr",align:(At=(pr=V.textMetrics)===null||pr===void 0?void 0:pr.resolvedAlign)!==null&&At!==void 0?At:He(V.c).align}}),safeArea:ur}}function wt(r,o){for(;r.parentId;){if(r.parentId===o)return!0;r=We(r.parentId)}return!1}function Co(r){for(var o=function(s){if(e.gameplay.some(function(p){var h;return p.kind==="camera-follow"&&p.componentId===((h=s.prototypeId)!==null&&h!==void 0?h:s.id)}))return{value:!0}},d=r;d;d=d.parentId?We(d.parentId):void 0){var u=o(d);if(typeof u=="object")return u.value}return!1}function Oa(r){var o=R(),d=t.getBoundingClientRect(),u=Math.min(d.width/o.width,d.height/o.height);return{x:(r.clientX-d.left-(d.width-o.width*u)/2)/u,y:(r.clientY-d.top-(d.height-o.height*u)/2)/u}}function uf(r,o){var d,u,s,p;try{try{for(var h=J(r.clips),g=h.next();!g.done;g=h.next()){var x=g.value,k=cr(Ut(x.matrix),o.x,o.y);if(k.x<0||k.y<0||k.x>x.width||k.y>x.height)return!1}}catch(B){d={error:B}}finally{try{g&&!g.done&&(u=h.return)&&u.call(h)}finally{if(d)throw d.error}}var m=cr(Ut(r.m),o.x,o.y),C=He(r.c);if(r.c.contract==="native.path.v1"){var M=new Path2D,T=function(B,F){({M:function(){return M.moveTo.apply(M,ie([],$(F),!1))},L:function(){return M.lineTo.apply(M,ie([],$(F),!1))},C:function(){return M.bezierCurveTo.apply(M,ie([],$(F),!1))},Q:function(){return M.quadraticCurveTo.apply(M,ie([],$(F),!1))},Z:function(){return M.closePath()}})[B]()};try{for(var I=J(C.commands),E=I.next();!E.done;E=I.next()){var A=$(E.value),z=A[0],N=A.slice(1);T(z,N)}}catch(B){s={error:B}}finally{try{E&&!E.done&&(p=I.return)&&p.call(I)}finally{if(s)throw s.error}}y.save(),y.setTransform(1,0,0,1,0,0),y.lineWidth=C.strokeWidth;var L=y.isPointInPath(M,m.x,m.y)||C.strokeWidth>0&&y.isPointInStroke(M,m.x,m.y);return y.restore(),L}return r.c.contract==="native.ellipse.v1"?Math.pow((m.x-C.width/2)/(C.width/2),2)+Math.pow((m.y-C.height/2)/(C.height/2),2)<=1:m.x>=0&&m.y>=0&&m.x<=C.width&&m.y<=C.height}catch{return!1}}function Zi(r){return ie([],$(Ot),!1).reverse().find(function(o){return o.c.contract!=="native.group.v1"&&o.c.sceneId===_&&We(o.c.id)&&Er(o.c)&&uf(o,r)})}function $i(r){for(var o=[];r;)o.push(r),r=We(r.parentId);return o}function Ba(){if(!Xe)return{vx:0,vy:0,power:0,pull:0};var r=Xe.behavior.parameters,o=Xe.current.x-Xe.start.x,d=Xe.current.y-Xe.start.y,u=Math.hypot(o,d),s=Math.max(0,Math.min(1,(u-r.minPullPx)/Math.max(1,r.maxPullPx-r.minPullPx))),p=r.minSpeed+(r.maxSpeed-r.minSpeed)*s,h=r.invert?-1:1;return{vx:u?o/u*p*h:0,vy:u?d/u*p*h:0,power:s,pull:u}}function Po(r){if(Xe){Xe.current=r;var o=Ba();Xe.power=o.power,Xe.behavior.parameters.powerVariableId&&(j[Xe.behavior.parameters.powerVariableId]=o.power)}}function To(r){var o,d;r===void 0&&(r=!1);try{var u=(o=globalThis.AudioContext)!==null&&o!==void 0?o:globalThis.webkitAudioContext;u&&!_e&&(_e=new u,(d=_e.addEventListener)===null||d===void 0||d.call(_e,"statechange",function(){(_e==null?void 0:_e.state)==="running"&&Sa()})),hi(r)}catch{}}function vf(r,o,d){var u,s,p,h,g,x,k=function(F){var Y=d.find(function(ue){var ne;return((ne=ue.prototypeId)!==null&&ne!==void 0?ne:ue.id)===F.componentId});if(!Y)return"continue";var X=cr(Ut(yr(Y)),o.x,o.y),te=ci(Y,F);return te.stampSegment(X,X),Yr={kind:"mask",pointerId:r.pointerId,c:Y,behavior:F,last:X},(g=t.setPointerCapture)===null||g===void 0||g.call(t,r.pointerId),{value:!0}};try{for(var m=J(e.gameplay.filter(function(F){var Y;return F.kind==="erase-mask"&&((Y=O.get(F.componentId))===null||Y===void 0?void 0:Y.sceneId)===_})),C=m.next();!C.done;C=m.next()){var M=C.value,T=k(M);if(typeof T=="object")return T.value}}catch(F){u={error:F}}finally{try{C&&!C.done&&(s=m.return)&&s.call(m)}finally{if(u)throw u.error}}if(d.some(function(F){return F.contract==="native.button.v1"||e.events.some(function(Y){var X;return Y.kind==="click"&&Y.componentId===((X=F.prototypeId)!==null&&X!==void 0?X:F.id)})}))return!1;try{for(var I=J(e.gameplay.filter(function(F){var Y;return F.kind==="draw-stroke"&&((Y=O.get(F.componentId))===null||Y===void 0?void 0:Y.sceneId)===_})),E=I.next();!E.done;E=I.next()){var M=E.value,A=O.get(M.componentId),z=Ut(yr(A)),N=cr(z,o.x,o.y),L=He(A);if(!(N.x<0||N.y<0||N.x>L.width||N.y>L.height)){var B=Hl(M);return B.begin(o),Yr={kind:"stroke",pointerId:r.pointerId,c:A,behavior:M,store:B,last:o},rr({kind:"strokeStart",componentId:A.id}),(x=t.setPointerCapture)===null||x===void 0||x.call(t,r.pointerId),!0}}}catch(F){p={error:F}}finally{try{E&&!E.done&&(h=I.return)&&h.call(I)}finally{if(p)throw p.error}}return!1}function sf(r,o,d){var u,s,p,h,g,x,k,m=d.store.active;if(m){try{for(var C=J(e.gameplay.filter(function(te){var ue;return te.kind==="collider"&&((ue=O.get(te.componentId))===null||ue===void 0?void 0:ue.sceneId)===_})),M=C.next();!M.done;M=C.next()){var T=M.value,I=O.get(T.componentId);try{for(var E=(p=void 0,J(Hr(I))),A=E.next();!A.done;A=E.next()){var z=A.value;!Er(z)||m.hitIds.has(z.id)||nl(r,o,So(z,T.parameters.shape))&&(m.hitIds.add(z.id),rr(ot("sliceHit",z)))}}catch(te){p={error:te}}finally{try{A&&!A.done&&(h=E.return)&&h.call(E)}finally{if(p)throw p.error}}}}catch(te){u={error:te}}finally{try{M&&!M.done&&(s=C.return)&&s.call(C)}finally{if(u)throw u.error}}try{for(var N=J(wn),L=N.next();!L.done;L=N.next()){var B=L.value;if(!(B.broken||!B.breakable||m.hitIds.has(B.key))){var F=Bt.get(B.bodyId),Y=We(B.anchorId);if(!(!F||!Y)){var X=Or(Y);qa(r,o,{x:X.x,y:X.y},{x:F.x,y:F.y})&&(m.hitIds.add(B.key),B.broken=!0,Li.add(B.key),rr({kind:"jointBreak",behaviorId:B.id,componentId:B.componentId,selfInstanceId:B.bodyId,instanceId:(k=We(B.bodyId))===null||k===void 0?void 0:k.instanceId}))}}}}catch(te){g={error:te}}finally{try{L&&!L.done&&(x=N.return)&&x.call(N)}finally{if(g)throw g.error}}}}function cf(r,o){var d,u=o.last,s=o.behavior.parameters;if(s.inkVariableId){var p=s.inkVariableId,h=Math.hypot(r.x-u.x,r.y-u.y);if(((d=j[p])!==null&&d!==void 0?d:0)<h)return;j[p]-=h}o.store.add(r)&&(s.mode==="slice-blade"&&sf(u,r,o),o.last=r)}function hf(r){var o,d;if(!(!Yr||Yr.pointerId!==r.pointerId)){var u=Yr;Yr=void 0;try{!((o=t.hasPointerCapture)===null||o===void 0)&&o.call(t,r.pointerId)&&((d=t.releasePointerCapture)===null||d===void 0||d.call(t,r.pointerId))}catch{}if(u.kind==="stroke"){var s=u.store.end(),p=u.behavior.parameters;if(s){if(p.mode==="physics-wall"){var h=new Set(u.store.strokes.map(function(x){return x.id}));Kt=Kt.filter(function(x){return x.owner!==u.c.id||h.has(x.strokeId)}),Kt.push.apply(Kt,ie([],$(al(s,p.strokeWidth).map(function(x){return ge(ge({},x),{owner:u.c.id})})),!1))}else if(p.mode==="path-trace"){var g=We(p.followComponentId);g&&s.points.length>1&&Wn.set(g.id,{points:s.points,index:1,speed:p.followSpeed})}}rr({kind:"strokeEnd",componentId:u.c.id})}}}function yf(r){var o,d,u,s;try{for(var p=J(fn.values()),h=p.next();!h.done;h=p.next()){var g=h.value;g.tick(r)}}catch(B){o={error:B}}finally{try{h&&!h.done&&(d=p.return)&&d.call(p)}finally{if(o)throw o.error}}try{for(var x=J(Wn),k=x.next();!k.done;k=x.next()){var m=$(k.value,2),C=m[0],M=m[1],T=We(C);if(!T){Wn.delete(C);continue}var I=M.points[M.index];if(!I){Wn.delete(C),rr(ot("pathArrive",T));continue}var E=Or(T),A=I.x-E.x,z=I.y-E.y,N=Math.hypot(A,z),L=M.speed*r;N<=L?(Jt(T,I.x,I.y),M.index++):N>.001&&Jt(T,E.x+A/N*L,E.y+z/N*L)}}catch(B){u={error:B}}finally{try{k&&!k.done&&(s=x.return)&&s.call(x)}finally{if(u)throw u.error}}}function pf(r,o,d){var u,s,p=[],h=[],g=function(C){var M=O.get(C.componentId),T=C.parameters.dragMode==="anywhere"?Hr(M).find(function(A){return Er(A)}):d.find(function(A){var z;return((z=A.prototypeId)!==null&&z!==void 0?z:A.id)===M.id});if(!T)return"continue";if(C.kind==="swipe-input")h.push({behavior:C,c:T});else{var I=C.parameters,E=Math.max(I.min,Math.min(I.max,Number(j[I.variableId])));j[I.variableId]=E,p.push({behavior:C,c:T,charge:Qo(I,E)}),rr(ot("holdStart",T))}};try{for(var x=J(e.gameplay.filter(function(C){var M;return["swipe-input","hold-charge"].includes(C.kind)&&((M=O.get(C.componentId))===null||M===void 0?void 0:M.sceneId)===_})),k=x.next();!k.done;k=x.next()){var m=k.value;g(m)}}catch(C){u={error:C}}finally{try{k&&!k.done&&(s=x.return)&&s.call(x)}finally{if(u)throw u.error}}(p.length||h.length)&&(br={pointerId:r.pointerId,start:o,current:o,holds:p,swipes:h})}function mf(r,o){var d,u,s,p,h,g,x,k;if(!(!br||br.pointerId!==r.pointerId)){var m=br,C=new Set;br=void 0;try{for(var M=J(ie(ie([],$(m.holds),!1),$(m.swipes),!1)),T=M.next();!T.done;T=M.next()){var I=T.value,E=I.behavior,A=I.c;C.has(E.componentId)||(C.add(E.componentId),rr(ot("pointerUp",A,void 0,{targetId:A.id,pointerId:r.pointerId})))}}catch(ne){d={error:ne}}finally{try{T&&!T.done&&(u=M.return)&&u.call(M)}finally{if(d)throw d.error}}try{for(var z=J(m.holds),N=z.next();!N.done;N=z.next()){var L=N.value,B=L.behavior.parameters;if(rr(ot("holdRelease",L.c)),B.resetOnRelease!==!1){var F=j[B.variableId];j[B.variableId]=B.min,F!==B.min&&rr({kind:"variableChange",variableId:B.variableId,selfInstanceId:(x=L.c.instanceId)!==null&&x!==void 0?x:L.c.id,instanceId:L.c.instanceId})}}}catch(ne){s={error:ne}}finally{try{N&&!N.done&&(p=z.return)&&p.call(z)}finally{if(s)throw s.error}}try{for(var Y=J(m.swipes),X=Y.next();!X.done;X=Y.next()){var te=X.value,ue=Ko(m.start,o,te.behavior.parameters.minDistancePx,(k=Ni.get(te.behavior.id))!==null&&k!==void 0?k:-1/0,ce*1e3,te.behavior.parameters.cooldownMs);ue&&(Ni.set(te.behavior.id,ce*1e3),rr(ot("swipe",te.c,void 0,{direction:ue})))}}catch(ne){h={error:ne}}finally{try{X&&!X.done&&(g=Y.return)&&g.call(Y)}finally{if(h)throw h.error}}return C}}function gf(r,o,d){var u,s,p;if(d.some(function(E){return E.contract==="native.button.v1"&&He(E).enabled}))return!1;try{for(var h=J(e.gameplay.filter(function(E){var A;return E.kind==="virtual-joystick"&&((A=O.get(E.componentId))===null||A===void 0?void 0:A.sceneId)===_})),g=h.next();!g.done;g=h.next()){var x=g.value,k=O.get(x.componentId);if(Er(k)){var m=dn.get(x.id);if(!(m&&m.pointerId!==null)){var C=cr(Ut(yr(k)),o.x,o.y),M=He(k);if(!(C.x<0||C.y<0||C.x>M.width||C.y>M.height)){var T=x.parameters.mode==="floating"?ge({},o):Or(k),I=$a(T,o,x.parameters.radiusPx,x.parameters.deadZone);return m=ge({behavior:x,c:k,pointerId:r.pointerId,origin:T,current:o},I),dn.set(x.id,m),ga(m),rr(ot("joystickStart",k)),(p=t.setPointerCapture)===null||p===void 0||p.call(t,r.pointerId),!0}}}}}catch(E){u={error:E}}finally{try{g&&!g.done&&(s=h.return)&&s.call(h)}finally{if(u)throw u.error}}return!1}var Eo=function(r){var o,d,u,s,p,h,g,x,k,m,C;b();var M=Oa(r),T=Zi(M);if(vi=M,!(!T&&S)){if(S){T&&(Zt=T.c.id,G((p=T.c.prototypeId)!==null&&p!==void 0?p:T.c.id));return}var I=e.gameplay.some(function(Ce){return Ce.kind==="virtual-joystick"||Ce.kind==="fps-controller-3d"});if(!(!r.isTrusted||r.button!==void 0&&r.button!==0||!I&&r.isPrimary===!1||Tr||Vn||!I&&(Ge&&Ge.pointerId!==r.pointerId||br&&br.pointerId!==r.pointerId||Xe&&Xe.pointerId!==r.pointerId)||ee&&(!fi||!Yn))){var E=!gn;sa=ce,Vi=!0,gn=!0,To(!0),E&&!Rt&&(Lr=zr=0,un());var A=T?$i(T.c):[];if(gf(r,M,A)){Lr=zr=0,Rt=!1,un(),tt();return}if(vf(r,M,A)){un(),tt();return}pf(r,M,A);var z=e.gameplay.find(function(Ce){return Ce.kind==="aim-launch"&&O.get(Ce.componentId).sceneId===_&&(Ce.parameters.dragMode==="anywhere"&&!A.some(function(we){return we.contract==="native.button.v1"})||A.some(function(we){var Me;return((Me=we.prototypeId)!==null&&Me!==void 0?Me:we.id)===Ce.componentId}))});if(z){var N=O.get(z.componentId),L=(h=A.find(function(Ce){var we;return((we=Ce.prototypeId)!==null&&we!==void 0?we:Ce.id)===N.id}))!==null&&h!==void 0?h:Hr(N).find(function(Ce){return Er(Ce)}),B=L&&Ln(L,It("physics-body",N.id));if(B&&(!z.parameters.onlyWhenAtRest||B.atRest)){Xe={behavior:z,targetId:L.id,sourceId:N.id,pointerId:r.pointerId,start:M,current:M,power:0},Po(M),(g=t.setPointerCapture)===null||g===void 0||g.call(t,r.pointerId),tt();return}}try{for(var F=J(A),Y=F.next();!Y.done;Y=F.next()){var X=Y.value,te=It("press-feedback",(x=X.prototypeId)!==null&&x!==void 0?x:X.id);te&&(X.contract!=="native.button.v1"||He(X).enabled)&&In.set(X.id,{behavior:te.parameters,pointerId:r.pointerId,held:!0})}}catch(Ce){o={error:Ce}}finally{try{Y&&!Y.done&&(d=F.return)&&d.call(F)}finally{if(o)throw o.error}}var ue=A.find(function(Ce){var we;return((we=Dt.get(Ce.id))===null||we===void 0?void 0:we.sceneId)===_});if(ue){var ne=xt.get(ue.parentId);if(ne!=null&&ne.snapshot().busy)return;Zl(ue),ne&&!ne.snapshot().busy&&(rt={pointerId:r.pointerId,boardId:ue.parentId,tileId:ue.id,start:M},(k=t.setPointerCapture)===null||k===void 0||k.call(t,r.pointerId))}it=(m=A.find(function(Ce){return Ce.contract==="native.button.v1"&&He(Ce).enabled}))===null||m===void 0?void 0:m.id,Lt=it?r.pointerId:void 0;var xe=e.gameplay.find(function(Ce){return Ce.kind==="drag"&&A.some(function(we){var Me;return((Me=we.prototypeId)!==null&&Me!==void 0?Me:we.id)===Ce.componentId})});if(xe){var X=A.find(function(we){var Me;return((Me=we.prototypeId)!==null&&Me!==void 0?Me:we.id)===xe.componentId}),Re=Or(X),Ne=Vr.zoneOf(X.id);Wi.set(X.id,Re),Vr.release(X.id),Ge={b:xe,targetId:X.id,start:M,current:M,origin:Re,originZone:Ne,m:ie([],$(bt(X)),!1),pointerId:r.pointerId},rr(ot("dragStart",X)),t.setPointerCapture(r.pointerId)}Lr=zr=0,Rt=!1;try{for(var Fe=J(A),pe=Fe.next();!pe.done;pe=Fe.next()){var X=pe.value;(X.contract!=="native.button.v1"||He(X).enabled)&&rr({kind:"click",componentId:(C=X.prototypeId)!==null&&C!==void 0?C:X.id,instanceId:X.instanceId,targetId:X.id,pointerId:r.pointerId})}}catch(Ce){u={error:Ce}}finally{try{pe&&!pe.done&&(s=Fe.return)&&s.call(Fe)}finally{if(u)throw u.error}}un(),tt()}}};function Ao(r,o){if(!rt||rt.pointerId!==r.pointerId)return!1;if(!r.isTrusted||!qn())return!0;var d=rt,u=xt.get(d.boardId);if(u.snapshot().busy)return rt=void 0,!0;var s=Ut(yr(O.get(d.boardId))),p=cr(s,d.start.x,d.start.y),h=cr(s,o.x,o.y),g=h.x-p.x,x=h.y-p.y,k=O.get(d.tileId);if(Math.max(Math.abs(g),Math.abs(x))<Math.min(k.parameters.width,k.parameters.height)*.35)return!0;var m=Dt.get(k.id),C=Math.abs(g)>Math.abs(x),M=m.row+(C?0:Math.sign(x)),T=m.column+(C?Math.sign(g):0),I=ie([],$(Dt),!1).find(function(E){var A=$(E,2),z=A[1];return z.boardId===d.boardId&&z.row===M&&z.column===T});return I&&u.swap(k.id,I[0])&&(Dr=void 0,tt()),rt=void 0,!0}var Ro=function(r){var o,d,u,s;if(!Tr){b();var p=R(),h=Oa(r);vi=h,(br==null?void 0:br.pointerId)===r.pointerId&&(br.current=h);try{for(var g=J(dn.values()),x=g.next();!x.done;x=g.next()){var k=x.value;if(k.pointerId===r.pointerId){var m=h.x-k.current.x,C=h.y-k.current.y;Object.assign(k,{current:h},$a(k.origin,h,k.behavior.parameters.radiusPx,k.behavior.parameters.deadZone)),ga(k),tt();return}}}catch(we){o={error:we}}finally{try{x&&!x.done&&(d=g.return)&&d.call(g)}finally{if(o)throw o.error}}if((Yr==null?void 0:Yr.pointerId)===r.pointerId){if(Yr.kind==="mask"){var M=Yr,T=cr(Ut(yr(M.c)),h.x,h.y);ci(M.c,M.behavior).stampSegment(M.last,T),M.last=T}else cf(h,Yr);un(),tt();return}if((Xe==null?void 0:Xe.pointerId)===r.pointerId){r.isTrusted&&qn()&&Po(h),tt();return}var I=Zi(h);if(Gt=I?(u=$i(I.c).find(function(we){return we.contract==="native.button.v1"}))===null||u===void 0?void 0:u.id:void 0,!Ao(r,h)&&!(!Ge||Ge.pointerId!==r.pointerId)){var E=We(Ge.targetId);if(!E){Di();return}var A=E.parentId?yr(We(E.parentId)):nn(),z=Ut(A),N=cr(z,Ge.start.x,Ge.start.y),L=cr(z,h.x,h.y),B=ie([],$(Ge.m),!1),F=Ge.b.parameters.axis;if(F!=="y"){var Y=Ge.m[4]+L.x-N.x;Number.isFinite(Ge.b.parameters.minX)&&(Y=Math.max(Ge.b.parameters.minX,Y)),Number.isFinite(Ge.b.parameters.maxX)&&(Y=Math.min(Ge.b.parameters.maxX,Y)),B[4]=Y}if(F!=="x"){var X=Ge.m[5]+L.y-N.y;Number.isFinite(Ge.b.parameters.minY)&&(X=Math.max(Ge.b.parameters.minY,X)),Number.isFinite(Ge.b.parameters.maxY)&&(X=Math.min(Ge.b.parameters.maxY,X)),B[5]=X}if(!E.parentId)F!=="y"&&(B[4]=Math.max(0,Math.min(p.width-E.parameters.width,B[4])));else{var te=lt(E,ii(A,B)),ue=0;te.left<0||te.right-te.left>p.width?ue=-te.left:te.right>p.width&&(ue=p.width-te.right);var ne=F==="y"?0:A[0],xe=F==="x"?0:A[2];Math.abs(ne)>=Math.abs(xe)&&Math.abs(ne)>1e-8?B[4]+=ue/ne:Math.abs(xe)>1e-8&&(B[5]+=ue/xe)}var Re=(s=Je.get(E.id))!==null&&s!==void 0?s:{parameters:{}};Je.set(E.id,ge(ge({},Re),{transform:B})),Ge.current=h;var Ne=Pa(E),Fe=Ne.zones,pe=Ne.tag,Ce=ia({itemId:E.id,tag:pe,zones:Fe,occupancy:Vr});bn=Ce&&Ce.kind!=="reject"?Ce.zone:void 0}}},Vo=function(r){var o,d,u,s;b();var p=Oa(r),h=mt;vi=p,xa(r.pointerId,!0),hf(r);var g=(u=mf(r,p))!==null&&u!==void 0?u:new Set;if($l(r),r.isTrusted&&qn()){var x=Zi(p);try{for(var k=J(x?$i(x.c):[]),m=k.next();!m.done;m=k.next()){var C=m.value;!g.has((s=C.prototypeId)!==null&&s!==void 0?s:C.id)&&(C.contract!=="native.button.v1"||He(C).enabled)&&rr(ot("pointerUp",C,void 0,{targetId:C.id,pointerId:r.pointerId}))}}catch(A){o={error:A}}finally{try{m&&!m.done&&(d=k.return)&&d.call(k)}finally{if(o)throw o.error}}}if(un(),tt(),(Xe==null?void 0:Xe.pointerId)===r.pointerId){var M=Xe,T=Ba(),I=Bt.get(M.targetId);Xe=void 0,M.behavior.parameters.powerVariableId&&(j[M.behavior.parameters.powerVariableId]=0),I&&r.isTrusted&&qn()&&T.pull>=M.behavior.parameters.minPullPx&&(I.vx=T.vx,I.vy=T.vy,I.atRest=!1,I.restElapsed=0,I.captured=!1,I.exited=!1,rr({kind:"launch",componentId:M.sourceId,instanceId:I.instanceId})),Ia(r),un(),tt();return}if(Ao(r,p),(rt==null?void 0:rt.pointerId)===r.pointerId&&(rt=void 0),Ia(r),!((h==null?void 0:h.pointerId)!==r.pointerId||!r.isTrusted||!qn()||navigator.userActivation&&navigator.userActivation.isActive!==!0||!Ui(h.condition))){var E=Zi(p);!E||!$i(E.c).some(function(A){return A.id===h.targetId&&(A.contract!=="native.button.v1"||He(A).enabled)})||(ee?ee.openStore(e.base.storeUrl):window.open(e.base.storeUrl,"_blank","noopener"))}},Ki=function(r){var o,d;if(xa(r.pointerId,!0),(Xe==null?void 0:Xe.pointerId)===r.pointerId&&(Xe.behavior.parameters.powerVariableId&&(j[Xe.behavior.parameters.powerVariableId]=0),Xe=void 0),(rt==null?void 0:rt.pointerId)===r.pointerId&&(rt=void 0),(Yr==null?void 0:Yr.pointerId)===r.pointerId&&(Yr.kind==="stroke"&&Yr.store.cancel(),Yr=void 0),(br==null?void 0:br.pointerId)===r.pointerId){try{for(var u=J(br.holds),s=u.next();!s.done;s=u.next()){var p=s.value;p.behavior.parameters.resetOnRelease!==!1&&(j[p.behavior.parameters.variableId]=p.behavior.parameters.min)}}catch(h){o={error:h}}finally{try{s&&!s.done&&(d=u.return)&&d.call(u)}finally{if(o)throw o.error}}br=void 0}Ia(r)},Oo=function(r){r!=null&&r.isTrusted&&!S&&!Tr&&!Vn&&To(!0)},za=function(){Oi||tt()},Mn=typeof globalThis.ResizeObserver=="function"?new globalThis.ResizeObserver(za):void 0;try{(v=Mn==null?void 0:Mn.observe)===null||v===void 0||v.call(Mn,t)}catch{}var Bo=function(){lr=0,Sr=0,document.hidden&&Qt(),_e&&(document.hidden?_e.suspend().catch(function(){}):!Tr&&gn&&hi())};document.addEventListener("visibilitychange",Bo),(c=globalThis.addEventListener)===null||c===void 0||c.call(globalThis,"resize",za),t.addEventListener("pointerdown",Eo),t.addEventListener("pointermove",Ro),t.addEventListener("pointerup",Vo),t.addEventListener("pointercancel",Ki),t.addEventListener("lostpointercapture",Ki),t.addEventListener("click",Oo);var Wa=ee==null?void 0:ee.onVisibilityChanged(function(r){Yn=r,lr=0,Sr=0,r||Qt(),_e&&(r?!Tr&&gn&&hi():_e.suspend().catch(function(){}))}),Na=ee==null?void 0:ee.onClosed(function(){Vn=!0,lr=0,Sr=0,Qt(),si()}),La=(P=ee==null?void 0:ee.onVolumeChanged)===null||P===void 0?void 0:P.call(ee,function(r){typeof r=="number"&&Number.isFinite(r)&&r>=0&&(pa=Math.min(1,r>1?r/100:r),Ca())});function zo(r){var o=!S&&!Tr&&!document.hidden&&fi&&Yn&&!Vn;if(o&&Sr&&($e+=Math.min((r-Sr)/1e3,5/60)),qn()){Lr=zr=0,Rt=!1,Sr&&(lr+=Math.min((r-Sr)/1e3,5/60));for(var d=0;d<5&&lr>=1/60;d++)ef(1/60),lr-=1/60;un()}else lr=0;Sr=r,tt(),ln=requestAnimationFrame(zo)}return ka(),S&&(_=re),tt(),ln=requestAnimationFrame(zo),ee&&ee.init().then(function(){Oi||(fi=!0,Yn=ee.isVisible(),lr=0,Sr=0)}).catch(function(){Oi||(Vn=!0,Qt(),si())}),{state:zl,auditViewport:ff,auditSceneLayout:df,restart:function(){var r;(r=ee==null?void 0:ee.notifyGameRetry)===null||r===void 0||r.call(ee),ka(),tt()},select:function(r){Zt=r},inspectScene:function(r){S&&e.scenes.some(function(o){return o.id===r})&&(_=r,Zt=void 0)},pause:function(r){Tr=r,lr=0,Sr=0,r&&Qt(),_e&&(r?_e.suspend().catch(function(){}):gn&&hi())},destroy:function(){var r,o;Oi=!0,cancelAnimationFrame(ln),Qt(),si(),Wa==null||Wa(),Na==null||Na(),La==null||La(),ee==null||ee.destroy(),(r=Mn==null?void 0:Mn.disconnect)===null||r===void 0||r.call(Mn),document.removeEventListener("visibilitychange",Bo),(o=globalThis.removeEventListener)===null||o===void 0||o.call(globalThis,"resize",za),t.removeEventListener("pointerdown",Eo),t.removeEventListener("pointermove",Ro),t.removeEventListener("pointerup",Vo),t.removeEventListener("pointercancel",Ki),t.removeEventListener("lostpointercapture",Ki),t.removeEventListener("click",Oo),_e==null||_e.close().catch(function(){})}}}return Vf(dd);})();