@tora-editor/tora 0.1.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 (131) hide show
  1. package/README.md +107 -58
  2. package/assets/free-audio/arcade-pop/audio/loss.wav +0 -0
  3. package/assets/free-audio/arcade-pop/audio/reward.wav +0 -0
  4. package/assets/free-audio/arcade-pop/audio/win.wav +0 -0
  5. package/assets/free-audio/arcade-pop/source/INFO.txt +11 -11
  6. package/assets/kenney-food-starter/License.txt +28 -0
  7. package/assets/kenney-food-starter/burger.glb +0 -0
  8. package/assets/kenney-food-starter/frying-pan.glb +0 -0
  9. package/assets/kenney-food-starter/plan.json +61 -0
  10. package/assets/kenney-food-starter/plate.glb +0 -0
  11. package/assets/kenney-food-starter/pot.glb +0 -0
  12. package/assets/kenney-harvest/audio/victory.wav +0 -0
  13. package/assets/kenney-harvest/source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg +0 -0
  14. package/assets/kenney-harvest/source/music-jingles/OGG/jingles_PIZZA/jingles_PIZZA03.ogg +0 -0
  15. package/assets/kenney-harvest/source/music-jingles/license.txt +14 -0
  16. package/bin/tora.mjs +322 -28
  17. package/crates/packer/trusted/native-3d-meta.json +4 -3
  18. package/crates/packer/trusted/native-3d.js +181 -181
  19. package/crates/packer/trusted/native-meta.json +3 -3
  20. package/crates/packer/trusted/native.js +5 -5
  21. package/crates/packer/trusted/release-manifest.json +17 -17
  22. package/crates/packer/trusted/review-runtime-meta.json +4 -3
  23. package/crates/packer/trusted/review-runtime.js +182 -182
  24. package/docs/MIGRATION_0_3.md +39 -0
  25. package/docs/NATIVE_AGENT_TOOLS.md +12 -363
  26. package/docs/TORA_AGENT_SETUP.md +24 -95
  27. package/docs/TORA_CREATION_API.md +63 -348
  28. package/docs/reference/CORE_AUTHORING.md +10 -3
  29. package/docs/reference/PLAYABLE_STARTERS.md +20 -0
  30. package/docs/reference/packs/3d.md +11 -3
  31. package/network-rules/mintegral-appgrowth-single-html.json +10 -10
  32. package/package.json +6 -6
  33. package/packages/creative-project/project-v21.schema.json +372 -9
  34. package/scripts/lean/editor/entry.js +11 -6
  35. package/scripts/lean/editor/project-launcher.js +116 -0
  36. package/scripts/lean/editor/quick-edit-panel.js +479 -0
  37. package/scripts/lean/editor/review-editor.css +256 -68
  38. package/scripts/lean/editor/review-editor.js +1834 -1086
  39. package/scripts/lean/editor-state.mjs +6 -0
  40. package/scripts/lean/editor.mjs +6 -3
  41. package/scripts/lean/matrix.mjs +5 -0
  42. package/scripts/lean/native/agent-tools.mjs +39 -62
  43. package/scripts/lean/native/api.mjs +161 -136
  44. package/scripts/lean/native/asset-catalog.mjs +7 -6
  45. package/scripts/lean/native/asset-lineage.mjs +54 -0
  46. package/scripts/lean/native/asset-prep.mjs +173 -40
  47. package/scripts/lean/native/assets.mjs +107 -11
  48. package/scripts/lean/native/audio-assets.mjs +30 -0
  49. package/scripts/lean/native/browser-pool.mjs +34 -0
  50. package/scripts/lean/native/build-cache.mjs +38 -7
  51. package/scripts/lean/native/cc0-inputs.mjs +24 -0
  52. package/scripts/lean/native/cc0-staging.mjs +28 -8
  53. package/scripts/lean/native/compiler.mjs +9 -3
  54. package/scripts/lean/native/contracts.mjs +16 -11
  55. package/scripts/lean/native/creative-qa.mjs +365 -128
  56. package/scripts/lean/native/demos.mjs +53 -18
  57. package/scripts/lean/native/document.mjs +50 -12
  58. package/scripts/lean/native/export-budget.mjs +75 -0
  59. package/scripts/lean/native/local-bundle.mjs +7 -3
  60. package/scripts/lean/native/mcp-server.mjs +42 -74
  61. package/scripts/lean/native/media-validate.mjs +124 -0
  62. package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
  63. package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
  64. package/scripts/lean/native/modules/star-salvage.mjs +3 -368
  65. package/scripts/lean/native/native-bin.mjs +3 -3
  66. package/scripts/lean/native/outcome-playthrough.mjs +97 -0
  67. package/scripts/lean/native/project-bundle.mjs +6 -5
  68. package/scripts/lean/native/project-index.mjs +0 -2
  69. package/scripts/lean/native/qa-adapters.mjs +10 -0
  70. package/scripts/lean/native/quick-edit.mjs +328 -0
  71. package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
  72. package/scripts/lean/native/review.mjs +205 -571
  73. package/scripts/lean/native/schema-vocabulary.mjs +10 -0
  74. package/scripts/lean/native/schema.mjs +7 -5
  75. package/scripts/lean/native/scope.mjs +45 -0
  76. package/scripts/lean/native/service.mjs +378 -79
  77. package/scripts/lean/native/starters.mjs +563 -0
  78. package/scripts/lean/native/variant-adapters.mjs +8 -0
  79. package/scripts/lean/native/variants-core.mjs +186 -0
  80. package/scripts/lean/native/variants.mjs +63 -0
  81. package/scripts/lean/native/win-cues.mjs +96 -0
  82. package/skills/tora-playables/SKILL.md +1 -1
  83. package/scripts/lean/editor/review-intake.js +0 -837
  84. package/scripts/lean/model-client.mjs +0 -119
  85. package/scripts/lean/native/author-expansion-proofs.mjs +0 -240
  86. package/scripts/lean/native/author-games.mjs +0 -160
  87. package/scripts/lean/native/author-harvest.mjs +0 -74
  88. package/scripts/lean/native/author-primitive-proofs.mjs +0 -874
  89. package/scripts/lean/native/author-salvage.mjs +0 -71
  90. package/scripts/lean/native/chat-compose.mjs +0 -287
  91. package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -191
  92. package/scripts/lean/native/check-salvage.mjs +0 -197
  93. package/scripts/lean/native/compatibility.mjs +0 -34
  94. package/scripts/lean/native/concept.mjs +0 -633
  95. package/scripts/lean/native/draw-stroke.mjs +0 -26
  96. package/scripts/lean/native/erase-mask.mjs +0 -18
  97. package/scripts/lean/native/harvest-recipe.mjs +0 -21
  98. package/scripts/lean/native/instance-steering.mjs +0 -24
  99. package/scripts/lean/native/intake-creator-agent.mjs +0 -98
  100. package/scripts/lean/native/intake-creator-tools.mjs +0 -165
  101. package/scripts/lean/native/interaction-gestures.mjs +0 -45
  102. package/scripts/lean/native/match-board.mjs +0 -138
  103. package/scripts/lean/native/modules/index.mjs +0 -54
  104. package/scripts/lean/native/modules/tap-collect.mjs +0 -54
  105. package/scripts/lean/native/path-network.mjs +0 -132
  106. package/scripts/lean/native/physics-2d.mjs +0 -154
  107. package/scripts/lean/native/physics-3d.mjs +0 -259
  108. package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
  109. package/scripts/lean/native/prepare-game-audio.mjs +0 -372
  110. package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
  111. package/scripts/lean/native/prepare-golf-assets.py +0 -211
  112. package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
  113. package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
  114. package/scripts/lean/native/prepare-primitive-images.py +0 -25
  115. package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
  116. package/scripts/lean/native/prepare-traffic-assets.py +0 -329
  117. package/scripts/lean/native/presentation.mjs +0 -335
  118. package/scripts/lean/native/review-agent-tools.mjs +0 -561
  119. package/scripts/lean/native/review-connection.mjs +0 -303
  120. package/scripts/lean/native/review-fields.mjs +0 -24
  121. package/scripts/lean/native/review-intake.mjs +0 -385
  122. package/scripts/lean/native/review-intents.mjs +0 -217
  123. package/scripts/lean/native/review-provider.mjs +0 -580
  124. package/scripts/lean/native/review-receipts.mjs +0 -76
  125. package/scripts/lean/native/review-resolver.mjs +0 -429
  126. package/scripts/lean/native/review-targets.mjs +0 -35
  127. package/scripts/lean/native/runtime.mjs +0 -1623
  128. package/scripts/lean/native/salvage-recipe.mjs +0 -20
  129. package/scripts/lean/native/stage-3d.mjs +0 -818
  130. package/scripts/lean/native/verify.mjs +0 -4
  131. package/scripts/lean/scene-document.mjs +0 -48
@@ -1,10 +1,10 @@
1
- var ToraNative=(()=>{var af=Object.defineProperty;var mg=Object.getOwnPropertyDescriptor;var vg=Object.getOwnPropertyNames;var gg=Object.prototype.hasOwnProperty;var yg=(n,e)=>{for(var t in e)af(n,t,{get:e[t],enumerable:!0})},xg=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of vg(e))!gg.call(n,r)&&r!==t&&af(n,r,{get:()=>e[r],enumerable:!(i=mg(e,r))||i.enumerable});return n};var _g=n=>xg(af({},"__esModule",{value:!0}),n);var ew={};yg(ew,{computeSafeArea:()=>np,createNetworkBridge:()=>wv,layoutStandardText:()=>Tv,mountNative:()=>jb});var Pp=function(n,e){if(!n)throw Error(e)},ga=function(){return[1,0,0,1,0,0]};function sf(n){return Pp(Array.isArray(n)&&n.length===6&&n.every(Number.isFinite),"E_SCENE_MATRIX"),n}function qs(n,e){return sf(n),sf(e),[n[0]*e[0]+n[2]*e[1],n[1]*e[0]+n[3]*e[1],n[0]*e[2]+n[2]*e[3],n[1]*e[2]+n[3]*e[3],n[0]*e[4]+n[2]*e[5]+n[4],n[1]*e[4]+n[3]*e[5]+n[5]]}function wr(n){sf(n);var e=n[0]*n[3]-n[1]*n[2];return Pp(Math.abs(e)>1e-12,"E_SCENE_SINGULAR_TRANSFORM"),[n[3]/e,-n[1]/e,-n[2]/e,n[0]/e,(n[2]*n[5]-n[3]*n[4])/e,(n[1]*n[4]-n[0]*n[5])/e]}var lf=function(){return lf=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},lf.apply(this,arguments)},ya=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Ts=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},of=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Lp(n){var e=n.rows,t=n.columns,i=n.seed,r=n.slots,a=n.paint,s=n.onEvent,o=r.map(function(fe){return fe.group}),u=Ts([],ya(new Set(o)),!1),l=Ts([],ya(o),!1),d=i,f="idle",h=0,v,y,T=[],g=[],m=0,L=0,F=0,_,p,S=function(fe,pe){return fe*t+pe},B=function(fe){return Math.floor(fe/t)},b=function(fe){return fe%t},I=function(){return d=Math.imul(d,1664525)+1013904223>>>0,d/4294967296};function z(fe){for(var pe=new Set,Fe=0;Fe<e;Fe++)for(var ae=0;ae<t;ae++){var de=S(Fe,ae),_e=fe[de];if(ae+2<t&&_e===fe[de+1]&&_e===fe[de+2])for(var Ge=0;Ge<3;Ge++)pe.add(de+Ge);if(Fe+2<e&&_e===fe[de+t]&&_e===fe[de+t*2])for(var Ge=0;Ge<3;Ge++)pe.add(de+t*Ge)}return Ts([],ya(pe),!1)}function U(fe,pe){var Fe;if(l[fe]===l[pe])return!1;var ae=Ts([],ya(l),!1);return Fe=ya([ae[pe],ae[fe]],2),ae[fe]=Fe[0],ae[pe]=Fe[1],z(ae).some(function(de){return de===fe||de===pe})}function Y(){for(var fe=[],pe=0;pe<l.length;pe++)b(pe)+1<t&&U(pe,pe+1)&&fe.push({from:r[pe].id,to:r[pe+1].id}),B(pe)+1<e&&U(pe,pe+t)&&fe.push({from:r[pe].id,to:r[pe+t].id});return fe}function E(){for(var fe=0;fe<64;fe++){l=[];for(var pe=function(ae){var de=u.filter(function(_e){return!(b(ae)>=2&&l[ae-1]===_e&&l[ae-2]===_e)&&!(B(ae)>=2&&l[ae-t]===_e&&l[ae-t*2]===_e)});l.push(de[Math.floor(I()*de.length)])},Fe=0;Fe<r.length;Fe++)pe(Fe);if(Y().length)return}l=r.map(function(ae,de){return u[(B(de)*2+b(de))%3]}),l[0]=u[0],l[1]=u[1],l[2]=u[0],l[t+1]=u[0]}function M(){for(var fe=0;fe<r.length;fe++)a(fe,l[fe],{})}function O(){d=i,l=Ts([],ya(o),!1),f="idle",h=0,v=void 0,y=void 0,T=[],g=[],m=0,L=0,F=0,_=void 0,p=void 0,(z(l).length||!Y().length)&&E(),M()}function H(fe,pe){if(f!=="idle")return!1;var Fe=r.findIndex(function(de){return de.id===fe}),ae=r.findIndex(function(de){return de.id===pe});return Fe<0||ae<0||Math.abs(B(Fe)-B(ae))+Math.abs(b(Fe)-b(ae))!==1?!1:(v=void 0,_=void 0,M(),y=[Fe,ae],f="swap",h=0,!0)}function ee(fe){if(f==="idle"){if(v===fe){v=void 0;return}if(!(v&&H(v,fe)))return v=fe,v}}function j(){T=z(l),F+=T.length,p={group:l[T[0]],from:r[T[0]].id,count:T.length},s("matchClear"),f="clear",h=0}function K(){var fe=new Set(T),pe=Ts([],ya(l),!1);g=[];for(var Fe=0;Fe<t;Fe++){for(var ae=[],de=e-1;de>=0;de--)fe.has(S(de,Fe))||ae.push(S(de,Fe));for(var _e=0,de=e-1;de>=0;de--){var Ge=S(de,Fe),$e=ae[e-1-de];$e!==void 0?(pe[Ge]=l[$e],g.push({cell:Ge,from:$e,offsetRows:0})):(pe[Ge]=u[Math.floor(I()*u.length)],g.push({cell:Ge,from:Ge,offsetRows:-(de+1+_e++)}))}}l=pe,f="fall",h=0}function re(){if(z(l).length&&m<3){m++,j();return}(z(l).length||!Y().length)&&E(),M(),f="idle",h=0,y=void 0,T=[],g=[],L++,s("validMatch")}function J(fe){var pe,Fe,ae,de,_e,Ge,$e;if(f==="idle"){if(_){_.elapsed+=fe;var ut=1+.065*Math.sin(Math.min(1,_.elapsed/.8)*Math.PI*4),zt=function(ze){a(r.findIndex(function(Ye){return Ye.id===ze}),l[r.findIndex(function(Ye){return Ye.id===ze})],{scale:ut})};try{for(var ct=of(_.ids),Tt=ct.next();!Tt.done;Tt=ct.next()){var Zt=Tt.value;zt(Zt)}}catch(ze){pe={error:ze}}finally{try{Tt&&!Tt.done&&(Fe=ct.return)&&Fe.call(ct)}finally{if(pe)throw pe.error}}_.elapsed>=.8&&(_=void 0,M())}return}if(h+=fe,f==="swap"||f==="reverse"){var wt=Math.min(1,h/.14),bt=wt*wt*(3-2*wt),_t=ya(y,2),ln=_t[0],rt=_t[1];if(a(ln,l[ln],{from:rt,progress:f==="swap"?bt:1-bt}),a(rt,l[rt],{from:ln,progress:f==="swap"?bt:1-bt}),wt<1)return;if(f==="reverse"){M(),f="idle",y=void 0,s("invalidMatch");return}if(!U(ln,rt)){f="reverse",h=0;return}ae=ya([l[rt],l[ln]],2),l[ln]=ae[0],l[rt]=ae[1],M(),j();return}if(f==="clear"){var an=Math.min(1,h/.18),ut=an<.22?1+an*.45:Math.max(.05,1.1*(1-an)/.78);try{for(var se=of(T),mn=se.next();!mn.done;mn=se.next()){var nn=mn.value;a(nn,l[nn],{scale:ut,opacity:1-an})}}catch(Ye){de={error:Ye}}finally{try{mn&&!mn.done&&(_e=se.return)&&_e.call(se)}finally{if(de)throw de.error}}an===1&&K();return}var W=Math.min(1,h/.25),w=1-Math.pow(1-W,3);try{for(var ue=of(g),ye=ue.next();!ye.done;ye=ue.next()){var we=ye.value;a(we.cell,l[we.cell],{from:we.from,offsetRows:we.offsetRows,progress:1-w})}}catch(ze){Ge={error:ze}}finally{try{ye&&!ye.done&&($e=ue.return)&&$e.call(ue)}finally{if(Ge)throw Ge.error}}W===1&&re()}function ne(){if(f==="idle"){v=void 0;var fe=Y()[0];fe&&(_={ids:[fe.from,fe.to],elapsed:0})}}function Te(){var fe;return{phase:f,busy:f!=="idle",selected:v??null,moves:L,cleared:F,groups:Ts([],ya(l),!1),legalMoves:f==="idle"?Y():[],hint:(fe=_?.ids)!==null&&fe!==void 0?fe:[],lastMatch:p?lf({},p):null}}return{reset:O,select:ee,swap:H,tick:J,showHint:ne,snapshot:Te,cancelSelection:function(){v=void 0,_&&(_=void 0,M())}}}var bc=function(){return bc=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},bc.apply(this,arguments)},Dp=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Mg=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Np=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Up(){var n=new Map,e=new Map,t=function(r){var a,s,o=e.get(r);o!==void 0&&((a=n.get(o))===null||a===void 0||a.delete(r),((s=n.get(o))===null||s===void 0?void 0:s.size)===0&&n.delete(o)),e.delete(r)},i=function(r,a){t(r),a!=null&&(n.has(a)||n.set(a,new Set),n.get(a).add(r),e.set(r,a))};return{occupants:n,itemZone:e,release:t,place:i,clear:function(){n.clear(),e.clear()},items:function(r){var a;return Mg([],Dp((a=n.get(r))!==null&&a!==void 0?a:[]),!1).sort()},zoneOf:function(r){return e.get(r)},snapshot:function(){return{itemZone:Object.fromEntries(e)}}}}function wc(n){var e,t,i=n.itemId,r=n.tag,a=r===void 0?"":r,s=n.zones,o=n.occupancy,u=s.filter(function(y){var T,g,m;return y.id!==i&&(((g=(T=y.acceptTags)===null||T===void 0?void 0:T.length)!==null&&g!==void 0?g:0)===0||((m=y.acceptTags)===null||m===void 0?void 0:m.includes(a)))});u.sort(function(y,T){return Number(T.itemTarget)-Number(y.itemTarget)||T.paintOrder-y.paintOrder||y.distance-T.distance||y.id.localeCompare(T.id)});try{for(var l=Np(u),d=l.next();!d.done;d=l.next()){var f=d.value,h=o.items(f.id).filter(function(y){return y!==i}),v=f.capacity>0&&h.length>=f.capacity;return f.snapMode==="reject"?{kind:"reject",zone:f,occupantId:h[0]}:v?f.onOccupied==="emit"?{kind:"emit",zone:f,occupantId:h[0]}:f.onOccupied==="swap"&&h.length?{kind:"swap",zone:f,occupantId:h[0]}:{kind:"reject",zone:f,occupantId:h[0]}:{kind:"accept",zone:f}}}catch(y){e={error:y}}finally{try{d&&!d.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}return null}function Fp(n,e,t,i,r,a){if(t===void 0&&(t=28),i===void 0&&(i=-1/0),r===void 0&&(r=0),a===void 0&&(a=80),r-i<a)return null;var s=e.x-n.x,o=e.y-n.y;return Math.max(Math.abs(s),Math.abs(o))<t?null:Math.abs(s)>Math.abs(o)?s<0?"left":"right":o<0?"up":"down"}function Op(n,e){var t=e,i=1;return{tick:function(r){return n.pingPong?(t+=i*n.ratePerSecond*r,t>=n.max?(t=n.max,i=-1):t<=n.min&&(t=n.min,i=1)):t=Math.max(n.min,Math.min(n.max,t+n.ratePerSecond*r)),t}}}function Bp(){var n=new Map;return{to:function(e,t,i,r,a){r===void 0&&(r=.18),n.set(e,{from:bc({},t),to:bc({},i),seconds:Math.max(.02,r),elapsed:0,onDone:a})},cancel:function(e){n.delete(e)},clear:function(){n.clear()},tick:function(e,t){var i,r,a;try{for(var s=Np(n),o=s.next();!o.done;o=s.next()){var u=Dp(o.value,2),l=u[0],d=u[1];d.elapsed+=e;var f=Math.min(1,d.elapsed/d.seconds),h=1-Math.pow(1-f,3);t(l,{x:d.from.x+(d.to.x-d.from.x)*h,y:d.from.y+(d.to.y-d.from.y)*h}),f===1&&(n.delete(l),(a=d.onDone)===null||a===void 0||a.call(d))}}catch(v){i={error:v}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}}}}function cf(n,e,t,i){t===void 0&&(t=56),i===void 0&&(i=.12);var r=Math.max(1,t),a=e.x-n.x,s=e.y-n.y,o=Math.hypot(a,s),u=Math.min(o,r),l=u/r,d=o>1e-6?a/o:0,f=o>1e-6?s/o:0,h=n.x+d*u,v=n.y+f*u;if(l<=i)return{nx:0,ny:0,magnitude:0,angle:0,knobX:h,knobY:v};var y=(l-i)/Math.max(1e-6,1-i);return{nx:d*y,ny:f*y,magnitude:y,angle:Math.atan2(f,d)*180/Math.PI,knobX:h,knobY:v}}var uf=function(){return uf=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},uf.apply(this,arguments)},kp=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function zp(n){var e,t,i=2166136261;try{for(var r=kp(String(n)),a=r.next();!a.done;a=r.next()){var s=a.value;i^=s.codePointAt(0),i=Math.imul(i,16777619)}}catch(o){e={error:o}}finally{try{a&&!a.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return i>>>0||1}function Sg(n){var e=n>>>0||1,t=e;return{next:function(){return t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296},between:function(i,r,a){if(a===void 0&&(a=!1),a){var s=Math.ceil(i),o=Math.floor(r);return o<s?s:Math.min(o,s+Math.floor((o-s+1)*this.next()))}return i+(r-i)*this.next()},reset:function(){t=e}}}function Vp(n,e,t,i,r){var a,s;i===void 0&&(i=0);var o=null,u=1/0;try{for(var l=kp(e),d=l.next();!d.done;d=l.next()){var f=d.value;if(!(f.id===r||f.team!==t)){var h=Math.hypot(f.x-n.x,f.y-n.y);i>0&&h>i||(h<u||h===u&&f.id<o?.id)&&(o=f,u=h)}}}catch(v){a={error:v}}finally{try{d&&!d.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}return o}function Gp(n,e,t){var i=((e-n+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return n+Math.max(-t,Math.min(t,i))}function Hp(n){var e=Sg(n),t=new Map,i=new Map;return{rng:e,states:t,headings:i,reset:function(){e.reset(),t.clear(),i.clear()},initialize:function(r,a){var s;return t.has(r)||t.set(r,{hp:a.hp,maxHp:a.maxHp,value:a.value,tag:(s=a.tag)!==null&&s!==void 0?s:"",team:a.team}),t.get(r)},remove:function(r){t.delete(r),i.delete(r)},snapshot:function(r){var a=t.get(r);return a?uf({},a):void 0}}}function Wp(n,e){var t,i,r,a,s=e===void 0?{}:e,o=s.width,u=s.height,l=s.onProgress,d=l===void 0?function(){}:l,f=s.onComplete,h=f===void 0?function(){}:f,v=s.canvasFactory,y=s.source,T=n,g=T.gridSize,m=new Uint8Array(g*g),L=0,F=!1,_=-1,p=!1,S=Math.max(1,o),B=Math.max(1,u),b=Math.min(1,512/Math.max(S,B)),I=(t=v?.())!==null&&t!==void 0?t:!((i=globalThis.document)===null||i===void 0)&&i.createElement?globalThis.document.createElement("canvas"):void 0;I&&(I.width=Math.max(1,Math.round(S*b)),I.height=Math.max(1,Math.round(B*b)));var z=(r=I?.getContext)===null||r===void 0?void 0:r.call(I,"2d"),U=(a=T.maskColor)!==null&&a!==void 0?a:"#dceeff",Y=function(){return!!(y&&y.complete&&y.naturalWidth>0)},E=function(){z&&(z.globalCompositeOperation="source-over",z.clearRect(0,0,I.width,I.height),T.mode==="erase"&&(Y()?(z.drawImage(y,0,0,I.width,I.height),p=!0):(z.fillStyle=U,z.fillRect(0,0,I.width,I.height),p=!1)))};E();var M=function(){if(!F){var H=Math.round(L/m.length*100),ee=Math.min(100,H);ee!==_&&(_=ee,d(ee)),ee>=T.targetPercent&&(F=!0,h(ee))}},O=function(H,ee){for(var j=Math.max(0,Math.min(g-1,Math.floor(H/S*g))),K=Math.max(0,Math.min(g-1,Math.floor(ee/B*g))),re=Math.max(0,Math.ceil(T.brushRadiusPx/S*g)),J=Math.max(0,Math.ceil(T.brushRadiusPx/B*g)),ne=Math.max(0,K-J);ne<=Math.min(g-1,K+J);ne++)for(var Te=Math.max(0,j-re);Te<=Math.min(g-1,j+re);Te++)if(!(Math.hypot((Te+.5)/g*S-H,(ne+.5)/g*B-ee)>T.brushRadiusPx)){var fe=ne*g+Te;m[fe]||(m[fe]=1,L++)}z&&(z.save(),z.scale(b,b),z.globalCompositeOperation=T.mode==="erase"?"destination-out":"source-over",z.fillStyle=U,z.beginPath(),z.arc(H,ee,T.brushRadiusPx,0,Math.PI*2),z.fill(),T.mode==="reveal"&&y&&(z.globalCompositeOperation="source-in",z.drawImage(y,0,0,S,B)),z.restore()),M()};return{canvas:I,stampSegment:function(H,ee){for(var j=Math.hypot(ee.x-H.x,ee.y-H.y),K=Math.max(1,Math.ceil(j/Math.max(1,T.brushRadiusPx*.45))),re=0;re<=K;re++)O(H.x+(ee.x-H.x)*re/K,H.y+(ee.y-H.y)*re/K)},reset:function(){m.fill(0),L=0,F=!1,_=-1,E(),M()},get progress(){return Math.round(L/m.length*100)},render:function(H){T.mode==="erase"&&L===0&&!p&&Y()&&E(),I?H.drawImage(I,0,0,I.width,I.height,0,0,o,u):T.mode==="erase"&&this.progress<100&&(H.save(),H.globalAlpha=1-this.progress/100,H.fillStyle=U,H.fillRect(0,0,o,u),H.restore())}}}var Es=function(){return Es=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Es.apply(this,arguments)},bg=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function df(n,e,t,i){var r=function(d,f,h){return(f.x-d.x)*(h.y-d.y)-(f.y-d.y)*(h.x-d.x)},a=r(n,e,t),s=r(n,e,i),o=r(t,i,n),u=r(t,i,e),l=1e-8;return Math.abs(a)<l&&Math.abs(s)<l&&Math.abs(o)<l&&Math.abs(u)<l?Math.max(Math.min(n.x,e.x),Math.min(t.x,i.x))<=Math.min(Math.max(n.x,e.x),Math.max(t.x,i.x))+l&&Math.max(Math.min(n.y,e.y),Math.min(t.y,i.y))<=Math.min(Math.max(n.y,e.y),Math.max(t.y,i.y))+l:a>0!=s>0&&o>0!=u>0}function Xp(n,e){for(var t=!1,i=0,r=e.length-1;i<e.length;r=i++){var a=e[i],s=e[r];a.y>n.y!=s.y>n.y&&n.x<(s.x-a.x)*(n.y-a.y)/(s.y-a.y)+a.x&&(t=!t)}return t}function Yp(n,e,t){if(t.length>=3&&(Xp(n,t)||Xp(e,t)))return!0;for(var i=0;i<t.length;i++)if(df(n,e,t[i],t[(i+1)%t.length]))return!0;return!1}function qp(n){var e=n,t=[],i=null,r=0,a=function(s){return Es(Es({},s),{points:s.points.map(function(o){return Es({},o)})})};return{begin:function(s){var o={id:++r,points:[Es({},s)],age:0,hitIds:new Set};return i=o,t.push(o),t.length>e.maxStrokes&&t.shift(),o},add:function(s){if(!i||i.points.length>=e.maxPoints)return!1;var o=i.points[i.points.length-1];return Math.hypot(s.x-o.x,s.y-o.y)<e.minSegmentPx?!1:(i.points.push(Es({},s)),!0)},end:function(){var s=i;return i=null,s?a(s):void 0},cancel:function(){i&&(t=t.filter(function(s){return s!==i})),i=null},clear:function(){i=null,t=[]},tick:function(s){var o,u;try{for(var l=bg(t),d=l.next();!d.done;d=l.next()){var f=d.value;f.age+=s}}catch(h){o={error:h}}finally{try{d&&!d.done&&(u=l.return)&&u.call(l)}finally{if(o)throw o.error}}t=t.filter(function(h){return h===i||h.age<.18||e.mode!=="slice-blade"})},get active(){return i},get strokes(){return t}}}function Zp(n,e){for(var t=[],i=1;i<n.points.length;i++){var r=n.points[i-1],a=n.points[i],s=Math.hypot(a.x-r.x,a.y-r.y);s<.001||t.push({id:"stroke-".concat(n.id,"-").concat(i),strokeId:n.id,mode:"static",shape:"box",x:(r.x+a.x)/2,y:(r.y+a.y)/2,width:s,height:Math.max(2,e),angle:Math.atan2(a.y-r.y,a.x-r.x),restitution:.8})}return t}var jo=function(){return jo=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},jo.apply(this,arguments)},em=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},ts=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},wg=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Ba=function(n,e){return Math.hypot(n,e)},Jp=function(n,e,t){return Math.max(e,Math.min(t,n))},As=function(n){return Math.max(1,Math.min(n.width,n.height)/2)};function $p(n){var e,t,i=Math.cos((e=n.angle)!==null&&e!==void 0?e:0),r=Math.sin((t=n.angle)!==null&&t!==void 0?t:0),a=n.width/2,s=n.height/2;return[[-a,-s],[a,-s],[a,s],[-a,s]].map(function(o){var u=em(o,2),l=u[0],d=u[1];return{x:n.x+l*i-d*r,y:n.y+l*r+d*i}})}function Tg(n,e){var t,i,r,a,s,o,u,l,d,f,h=$p(n),v=$p(e),y=[(u=n.angle)!==null&&u!==void 0?u:0,((l=n.angle)!==null&&l!==void 0?l:0)+Math.PI/2,(d=e.angle)!==null&&d!==void 0?d:0,((f=e.angle)!==null&&f!==void 0?f:0)+Math.PI/2],T=1/0,g=1,m=0;try{for(var L=ts(y),F=L.next();!F.done;F=L.next()){var _=F.value,p=Math.cos(_),S=Math.sin(_),B=1/0,b=-1/0,I=1/0,z=-1/0;try{for(var U=(r=void 0,ts(h)),Y=U.next();!Y.done;Y=U.next()){var E=Y.value,M=E.x*p+E.y*S;M<B&&(B=M),M>b&&(b=M)}}catch(j){r={error:j}}finally{try{Y&&!Y.done&&(a=U.return)&&a.call(U)}finally{if(r)throw r.error}}try{for(var O=(s=void 0,ts(v)),H=O.next();!H.done;H=O.next()){var E=H.value,M=E.x*p+E.y*S;M<I&&(I=M),M>z&&(z=M)}}catch(j){s={error:j}}finally{try{H&&!H.done&&(o=O.return)&&o.call(O)}finally{if(s)throw s.error}}var ee=Math.min(b,z)-Math.max(B,I);if(ee<=0)return null;ee<T&&(T=ee,g=p,m=S)}}catch(j){t={error:j}}finally{try{F&&!F.done&&(i=L.return)&&i.call(L)}finally{if(t)throw t.error}}return(n.x-e.x)*g+(n.y-e.y)*m<0&&(g=-g,m=-m),{nx:g,ny:m,penetration:T}}function Kp(n,e){var t,i,r,a=As(n),s=-((t=e.angle)!==null&&t!==void 0?t:0),o=Math.cos(s),u=Math.sin(s),l=n.x-e.x,d=n.y-e.y,f=l*o-d*u,h=l*u+d*o,v=e.width/2,y=e.height/2,T=Jp(f,-v,v),g=Jp(h,-y,y),m=f-T,L=h-g,F=Ba(m,L),_;if(F>=a)return null;if(F<1e-4){var p=[{d:v-Math.abs(f),x:f>=0?1:-1,y:0},{d:y-Math.abs(h),x:0,y:h>=0?1:-1}].sort(function(b,I){return b.d-I.d});m=p[0].x,L=p[0].y,_=a+p[0].d}else m/=F,L/=F,_=a-F;var S=Math.cos((i=e.angle)!==null&&i!==void 0?i:0),B=Math.sin((r=e.angle)!==null&&r!==void 0?r:0);return{nx:m*S-L*B,ny:m*B+L*S,penetration:_}}function Qp(n,e){var t;return!!(n.ignoreGroup&&n.ignoreGroup!=="none"&&(n.ignoreGroup==="all"||n.ignoreGroup===((t=e.collisionGroup)!==null&&t!==void 0?t:"all")))}function jp(n,e,t){var i,r,a,s,o,u;if(!(n.captured||e.captured||Qp(n,e)||Qp(e,n))){var l=n.x-e.x,d=n.y-e.y,f;if(n.shape==="circle"&&e.shape==="circle"){var h=Ba(l,d),v=As(n)+As(e)-h;if(v<=0)return;f=v,h>1e-4?(l/=h,d/=h):(l=1,d=0)}else if(n.shape==="circle"&&e.shape==="box"){var y=Kp(n,e);if(!y)return;l=y.nx,d=y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="circle"){var y=Kp(e,n);if(!y)return;l=-y.nx,d=-y.ny,f=y.penetration}else if(n.shape==="box"&&e.shape==="box"){var y=Tg(n,e);if(!y)return;l=y.nx,d=y.ny,f=y.penetration}else return;var T=n.mode==="dynamic"?1/((i=n.mass)!==null&&i!==void 0?i:1):0,g=e.mode==="dynamic"?1/((r=e.mass)!==null&&r!==void 0?r:1):0,m=T+g;if(m){n.x+=l*f*T/m,n.y+=d*f*T/m,e.mode==="dynamic"&&(e.x-=l*f*g/m,e.y-=d*f*g/m);var L=n.vx-((a=e.vx)!==null&&a!==void 0?a:0),F=n.vy-((s=e.vy)!==null&&s!==void 0?s:0),_=L*l+F*d;if(!(_>=0)){var p=Math.max((o=n.restitution)!==null&&o!==void 0?o:0,(u=e.restitution)!==null&&u!==void 0?u:0),S=-(1+p)*_/m;n.vx+=l*S*T,n.vy+=d*S*T,e.mode==="dynamic"&&(e.vx-=l*S*g,e.vy-=d*S*g),n.atRest=!1,n.restElapsed=0,e.mode==="dynamic"&&(e.atRest=!1,e.restElapsed=0),Math.abs(_)>4&&(t("bodyBounce",n,e,{speed:Math.abs(_)}),e.mode==="dynamic"&&t("bodyBounce",e,n,{speed:Math.abs(_)}))}}}}function Eg(n,e,t,i){var r,a;if(!(n.mode!=="dynamic"||n.captured))try{for(var s=ts(e),o=s.next();!o.done;o=s.next()){var u=o.value,l=u.x-n.x,d=u.y-n.y,f=Ba(l,d);if(!(f>=u.radius*2.5)){if(f>u.radius&&f>.001&&u.pullStrength>0){var h=u.pullStrength*(1-f/(u.radius*2.5));n.vx+=l/f*h*t,n.vy+=d/f*h*t}if(f<u.radius&&Ba(n.vx,n.vy)<=u.maxCaptureSpeed){n.captured=!0,n.atRest=!0,n.vx=u.stopBody?0:n.vx,n.vy=u.stopBody?0:n.vy,u.stopBody&&(n.x=u.x,n.y=u.y),i("zoneCapture",n,u,{});return}}}}catch(v){r={error:v}}finally{try{o&&!o.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}}function Ag(n,e){var t,i,r,a,s,o,u=function(h){if(h.broken)return"continue";var v=e.find(function(B){return B.id===h.bodyId}),y=e.find(function(B){return B.id===h.anchorId});if(!v||v.mode!=="dynamic")return"continue";var T=(a=(r=y?.x)!==null&&r!==void 0?r:h.x)!==null&&a!==void 0?a:0,g=(o=(s=y?.y)!==null&&s!==void 0?s:h.y)!==null&&o!==void 0?o:0,m=v.x-T,L=v.y-g,F=Ba(m,L);if(F<=h.lengthPx||F<1e-4)return"continue";var _=m/F,p=L/F;v.x=T+_*h.lengthPx,v.y=g+p*h.lengthPx;var S=v.vx*_+v.vy*p;S>0&&(v.vx-=_*S,v.vy-=p*S)};try{for(var l=ts(n),d=l.next();!d.done;d=l.next()){var f=d.value;u(f)}}catch(h){t={error:h}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(t)throw t.error}}}function ff(n){for(var e,t,i,r,a,s,o,u,l,d,f,h=n.bodies,v=n.zones,y=v===void 0?[]:v,T=n.joints,g=T===void 0?[]:T,m=n.bounds,L=n.dt,F=n.onEvent,_=F===void 0?function(){}:F,p=h.filter(function(ae){return ae.mode==="dynamic"&&!ae.captured}),S=p.reduce(function(ae,de){return Math.max(ae,Ba(de.vx,de.vy))},0),B=p.reduce(function(ae,de){return Math.min(ae,As(de))},24),b=Math.min(16,Math.max(1,Math.ceil(S*L/(B*.45)))),I=L/b,z=0;z<b;z++){try{for(var U=(e=void 0,ts(p)),Y=U.next();!Y.done;Y=U.next()){var E=Y.value;E.vy+=((o=E.gravity)!==null&&o!==void 0?o:0)*I;var M=Ba(E.vx,E.vy);if(M>E.maxSpeed){var O=E.maxSpeed/M;E.vx*=O,E.vy*=O,M=E.maxSpeed}E.x+=E.vx*I,E.y+=E.vy*I;var H=Math.max(0,M-((u=E.friction)!==null&&u!==void 0?u:0)*I),ee=Math.exp(-((l=E.linearDamping)!==null&&l!==void 0?l:0)*I);if(M>1e-4){var j=H/M*ee;E.vx*=j,E.vy*=j}E.spinToRotation&&(E.angle=((d=E.angle)!==null&&d!==void 0?d:0)+Ba(E.vx,E.vy)*I/As(E)*(E.vx<0?-1:1))}}catch(ae){e={error:ae}}finally{try{Y&&!Y.done&&(t=U.return)&&t.call(U)}finally{if(e)throw e.error}}for(var K=0;K<p.length;K++){var E=p[K];try{for(var re=(i=void 0,ts(h)),J=re.next();!J.done;J=re.next()){var ne=J.value;ne.id!==E.id&&ne.mode!=="dynamic"&&jp(E,ne,_)}}catch(de){i={error:de}}finally{try{J&&!J.done&&(r=re.return)&&r.call(re)}finally{if(i)throw i.error}}for(var ne=K+1;ne<p.length;ne++)jp(p[ne],E,_);var Te=E.shape==="box"?E.width/2:As(E),fe=E.shape==="box"?E.height/2:As(E);E.wallBounce?(E.x-Te<m.left&&(E.x=m.left+Te,E.vx<0&&(_("bodyBounce",E,null,{speed:Math.abs(E.vx)}),E.vx=-E.vx*E.restitution)),E.x+Te>m.right&&(E.x=m.right-Te,E.vx>0&&(_("bodyBounce",E,null,{speed:Math.abs(E.vx)}),E.vx=-E.vx*E.restitution)),E.y-fe<m.top&&(E.y=m.top+fe,E.vy<0&&(_("bodyBounce",E,null,{speed:Math.abs(E.vy)}),E.vy=-E.vy*E.restitution)),E.y+fe>m.bottom&&(E.y=m.bottom-fe,E.vy>0&&(_("bodyBounce",E,null,{speed:Math.abs(E.vy)}),E.vy=-E.vy*E.restitution))):!E.exited&&(E.x+Te<m.left||E.x-Te>m.right||E.y+fe<m.top||E.y-fe>m.bottom)&&(E.exited=!0,_("boundaryExit",E,null,{})),Eg(E,y,I,_)}Ag(g,h)}try{for(var pe=ts(p),Fe=pe.next();!Fe.done;Fe=pe.next()){var E=Fe.value,M=Ba(E.vx,E.vy);M<E.restSpeed&&!E.captured?(E.restElapsed=((f=E.restElapsed)!==null&&f!==void 0?f:0)+L,E.restElapsed>=E.restDelaySeconds&&!E.atRest&&(E.atRest=!0,E.vx=0,E.vy=0,_("bodyRest",E,null,{}))):M>=E.restSpeed&&(E.restElapsed=0,E.atRest=!1)}}catch(ae){a={error:ae}}finally{try{Fe&&!Fe.done&&(s=pe.return)&&s.call(pe)}finally{if(a)throw a.error}}}function tm(n){for(var e=n.body,t=n.bodies,i=n.zones,r=i===void 0?[]:i,a=n.bounds,s=n.dots,o=s===void 0?8:s,u=n.bounces,l=u===void 0?1:u,d=function(F){return jo({},F)},f=d(e),h=t.filter(function(F){return F.id!==e.id}).map(d),v=wg([f],em(h),!1),y=[],T=0,g=!1,m=function(F,_,p,S){F==="bodyBounce"&&S.sourceId===e.id&&T++,F==="zoneCapture"&&S.sourceId===e.id&&(g=!0)},L=0;L<90&&y.length<o&&!g&&T<=l;L++)ff({bodies:v,zones:r,bounds:a,dt:1/60,onEvent:function(F,_,p,S){return m(F,_,p,jo(jo({},S),{sourceId:_.id}))}}),L%Math.max(1,Math.floor(90/o))===0&&y.push({x:f.x,y:f.y});return y}var Zs=function(){return Zs=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Zs.apply(this,arguments)},el=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},im=.008333333333333333;function Js(n,e,t){var i,r,a,s=(i=n.boundsX)!==null&&i!==void 0?i:3,o=(r=n.boundsZ)!==null&&r!==void 0?r:7;if(Math.abs(e)>s||Math.abs(t)>o)return null;if(!n.ramp)return 0;var u=(a=n.rampHeight)!==null&&a!==void 0?a:1.1;return t>=1?0:t<=-1?u:(1-t)*(u*.5)}function nm(n,e,t,i){var r,a,s,o=n.radius,u=Math.cos(e.angle),l=Math.sin(e.angle),d=n.x-e.x,f=n.z-e.z,h=u*d+l*f,v=-l*d+u*f,y=Math.max(-e.hx,Math.min(e.hx,h)),T=Math.max(-e.hz,Math.min(e.hz,v)),g=h-y,m=v-T,L=Math.hypot(g,m),F=Js(n,n.x,n.z);if(!(L>=o||F!==null&&n.y>F+.55)){L<1e-8?e.hx-Math.abs(h)<e.hz-Math.abs(v)?(g=h<0?-1:1,m=0,L=0):(g=0,m=v<0?-1:1,L=0):(g/=L,m/=L);var _=u*g-l*m,p=l*g+u*m;n.x+=_*(o-L+1e-5),n.z+=p*(o-L+1e-5);var S=(r=e.vx)!==null&&r!==void 0?r:0,B=(a=e.vz)!==null&&a!==void 0?a:0,b=(n.vx-S)*_+(n.vz-B)*p;if(b<0){var I=1+((s=n.restitution)!==null&&s!==void 0?s:.72);n.vx-=I*b*_,n.vz-=I*b*p,Math.abs(b)>.3&&t>0&&i&&i("bodyBounce",n,e.sourceId?e:void 0)}}}function rm(n,e){n.vx=0,n.vy=0,n.vz=0,n.airborne=!1,n.atRest=!0,n.restElapsed=0,n.movingTime=0,e&&e("bodyRest",n)}function hf(n,e){n.x=n.lastSafe.x,n.y=n.lastSafe.y,n.z=n.lastSafe.z,rm(n,e)}function pf(n){var e,t,i,r,a,s,o,u,l,d,f,h,v,y,T,g,m,L,F=n.bodies,_=n.walls,p=n.zones,S=n.dt,B=n.onEvent;if(!(!Number.isFinite(S)||S<=0))for(var b=Math.max(1,Math.round(S/im)),I=S/b,z=0;z<b;z++)try{for(var U=(e=void 0,el(F)),Y=U.next();!Y.done;Y=U.next()){var E=Y.value;if(!(E.mode!=="dynamic"||E.captured)&&!E.atRest){var M=(l=E.boundsX)!==null&&l!==void 0?l:3,O=(d=E.boundsZ)!==null&&d!==void 0?d:7;if(E.y<-3||Math.abs(E.x)>M+2||Math.abs(E.z)>O+2){hf(E,B);continue}E.movingTime=((f=E.movingTime)!==null&&f!==void 0?f:0)+I;var H=E.radius,ee=Math.hypot(E.vx,E.vy,E.vz),j=Math.max(1,Math.min(16,Math.ceil(ee*I/(H*.45)))),K=I/j;(!E._perimeter||E._pbx!==M||E._pbz!==O)&&(E._pbx=M,E._pbz=O,E._perimeter=[{x:-(M+.1),z:0,hx:.1,hz:O+.1,angle:0,vx:0,vz:0},{x:M+.1,z:0,hx:.1,hz:O+.1,angle:0,vx:0,vz:0},{x:0,z:-(O+.1),hx:M+.1,hz:.1,angle:0,vx:0,vz:0},{x:0,z:O+.1,hx:M+.1,hz:.1,angle:0,vx:0,vz:0}]);for(var re=E._perimeter,J=!1,ne=0;ne<j;ne++){var Te=Js(E,E.x,E.z),fe=Te!==null&&E.y<=Te+H+.012&&E.vy<=.1,pe=Te;if(fe){E.y=Te+H,E.vy=0;var Fe=Math.hypot(E.vx,E.vz),ae=Math.max(0,Fe-((h=E.friction)!==null&&h!==void 0?h:1.05)*K);if(Fe>0&&(E.vx*=ae/Fe,E.vz*=ae/Fe),E.ramp&&E.z<1&&E.z>-1){var de=((v=E.rampHeight)!==null&&v!==void 0?v:1.1)*.5;E.vz+=9.81*de/(1+de*de)*K}}else E.vy-=9.81*K,E.airborne||(E.airborne=!0,B&&B("bodyJump",E));E.x+=E.vx*K,E.z+=E.vz*K,E.y+=E.vy*K;var _e=Js(E,E.x,E.z);if(_e!==null){if(fe&&pe!==null){var de=((y=E.rampHeight)!==null&&y!==void 0?y:1.1)*.5;E.ramp&&E.z<=-1&&E.z-E.vz*K>-1.5&&E.vz<-.8?(E.vy=-E.vz*de,E.airborne=!0,B&&B("bodyJump",E)):E.y=_e+H}E.y<_e+H&&(E.y=_e+H,E.vy=0,E.airborne=!1)}if(E.y<2){try{for(var Ge=(i=void 0,el(_)),$e=Ge.next();!$e.done;$e=Ge.next()){var ut=$e.value;nm(E,ut,K,B)}}catch(rt){i={error:rt}}finally{try{$e&&!$e.done&&(r=Ge.return)&&r.call(Ge)}finally{if(i)throw i.error}}try{for(var zt=(a=void 0,el(re)),ct=zt.next();!ct.done;ct=zt.next()){var ut=ct.value;nm(E,ut,K,B)}}catch(rt){a={error:rt}}finally{try{ct&&!ct.done&&(s=zt.return)&&s.call(zt)}finally{if(a)throw a.error}}}E.spin=((T=E.spin)!==null&&T!==void 0?T:0)+Math.hypot(E.vx,E.vz)*K/H;var Tt=Math.hypot(E.vx,E.vz);try{for(var Zt=(o=void 0,el(p)),wt=Zt.next();!wt.done;wt=Zt.next()){var bt=wt.value,_t=Math.hypot(E.x-bt.x,E.z-bt.z);if(_t<bt.radius&&Math.abs(E.y-(bt.y+H))<bt.heightTolerance&&Tt<bt.maxCaptureSpeed){E.captured=!0,E.captureElapsed=0,E.captureTarget={x:bt.x,y:bt.y,z:bt.z},E.vx=0,E.vy=0,E.vz=0,E.atRest=!0,B&&B("zoneCapture",E,bt),J=!0;break}}}catch(rt){o={error:rt}}finally{try{wt&&!wt.done&&(u=Zt.return)&&u.call(Zt)}finally{if(o)throw o.error}}if(J)break;if(E.y<-3||Math.abs(E.x)>M+2||Math.abs(E.z)>O+2){hf(E,B),J=!0;break}}if(!J){var ln=Math.hypot(E.vx,E.vy,E.vz);ln<((g=E.restSpeed)!==null&&g!==void 0?g:.07)?(E.restElapsed=((m=E.restElapsed)!==null&&m!==void 0?m:0)+I,E.restElapsed>((L=E.restDelaySeconds)!==null&&L!==void 0?L:.25)&&rm(E,B)):E.restElapsed=0,E.movingTime>18&&hf(E,B)}}}}catch(rt){e={error:rt}}finally{try{Y&&!Y.done&&(t=U.return)&&t.call(U)}finally{if(e)throw e.error}}}function am(n){var e,t=n.body,i=n.walls,r=n.zones,a=n.vx,s=n.vz,o=n.dots,u=o===void 0?15:o,l=Math.hypot(a,s);if(!Number.isFinite(l)||l<.35)return[];for(var d=Math.min(1,((e=t.maxSpeed)!==null&&e!==void 0?e:9)/l),f=Zs(Zs({},t),{vx:a*d,vy:0,vz:s*d,atRest:!1,captured:!1,airborne:!1,restElapsed:0,movingTime:0,lastSafe:{x:t.x,y:t.y,z:t.z}}),h=i.map(function(L){return Zs(Zs({},L),{vx:0,vz:0})}),v=[f],y={bodies:v,walls:h,zones:r,dt:im},T=[],g=Math.max(18,u*6),m=0;m<g&&(pf(y),m%6===0&&T.push({x:f.x,y:f.y,z:f.z}),!(f.atRest||f.captured));m++);return T}function mf(n,e,t,i,r,a){var s,o,u,l;i===void 0&&(i=[]),r===void 0&&(r=12),a===void 0&&(a=12);for(var d=n,f=e,h=Math.max(.05,t??.45),v=0;v<2;v++){try{for(var y=(s=void 0,el(i)),T=y.next();!T.done;T=y.next()){var g=T.value,m=Math.cos((u=g.angle)!==null&&u!==void 0?u:0),L=Math.sin((l=g.angle)!==null&&l!==void 0?l:0),F=d-g.x,_=f-g.z,p=m*F+L*_,S=-L*F+m*_,B=Math.max(-g.hx,Math.min(g.hx,p)),b=Math.max(-g.hz,Math.min(g.hz,S)),I=p-B,z=S-b,U=Math.hypot(I,z);if(!(U>=h)){U<1e-8?g.hx-Math.abs(p)<g.hz-Math.abs(S)?(I=p<0?-1:1,z=0):(I=0,z=S<0?-1:1):(I/=U,z/=U);var Y=m*I-L*z,E=L*I+m*z;d+=Y*(h-U+1e-4),f+=E*(h-U+1e-4)}}}catch(H){s={error:H}}finally{try{T&&!T.done&&(o=y.return)&&o.call(y)}finally{if(s)throw s.error}}var M=Math.max(0,(r??12)-h),O=Math.max(0,(a??12)-h);d=Math.max(-M,Math.min(M,d)),f=Math.max(-O,Math.min(O,f))}return{x:d,z:f}}var Bm=0,jf=1,km=2;var kl=1,Du=2,Eo=3,ms=0,pr=1,Ir=2,Aa=0,Ao=1,eh=2,th=3,nh=4,zm=5;var Fs=100,Vm=101,Gm=102,Hm=103,Wm=104,Xm=200,Ym=201,qm=202,Zm=203,ih=204,rh=205,Jm=206,$m=207,Km=208,Qm=209,jm=210,e0=211,t0=212,n0=213,i0=214,Jc=0,$c=1,Kc=2,ho=3,Qc=4,jc=5,eu=6,tu=7,Nu=0,r0=1,a0=2,aa=0,ah=1,sh=2,oh=3,lh=4,ch=5,uh=6,dh=7;var fh=300,vs=301,Os=302,Uu=303,Fu=304,zl=306,nu=1e3,_a=1001,iu=1002,Bi=1003,s0=1004;var Vl=1005;var Hi=1006,Ou=1007;var gs=1008;var Cr=1009,hh=1010,ph=1011,Io=1012,Bu=1013,sa=1014,Yr=1015,oa=1016,ku=1017,zu=1018,Co=1020,mh=35902,vh=35899,gh=1021,yh=1022,qr=1023,Ma=1026,ys=1027,Vu=1028,Gu=1029,xs=1030,Hu=1031;var Wu=1033,Gl=33776,Hl=33777,Wl=33778,Xl=33779,Xu=35840,Yu=35841,qu=35842,Zu=35843,Ju=36196,$u=37492,Ku=37496,Qu=37488,ju=37489,Yl=37490,ed=37491,td=37808,nd=37809,id=37810,rd=37811,ad=37812,sd=37813,od=37814,ld=37815,cd=37816,ud=37817,dd=37818,fd=37819,hd=37820,pd=37821,md=36492,vd=36494,gd=36495,yd=36283,xd=36284,ql=36285,_d=36286;var dl=2300,ru=2301,qc=2302,Gf=2303,Hf=2400,Wf=2401,Xf=2402;var o0=3200;var Md=0,l0=1,Ya="",hr="srgb",fl="srgb-linear",hl="linear",Jn="srgb";var Zc=7680;var c0=519,u0=512,d0=513,f0=514,Sd=515,h0=516,p0=517,bd=518,m0=519,v0=35044;var xh="300 es",ra=2e3,po=2001;function Ig(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Cg(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function pl(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function g0(){let n=pl("canvas");return n.style.display="block",n}var sm={},mo=null;function _h(...n){let e="THREE."+n.shift();mo?mo("log",e,...n):console.log(e,...n)}function y0(n){let e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function rn(...n){n=y0(n);let e="THREE."+n.shift();if(mo)mo("warn",e,...n);else{let t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function sn(...n){n=y0(n);let e="THREE."+n.shift();if(mo)mo("error",e,...n);else{let t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Ls(...n){let e=n.join(" ");e in sm||(sm[e]=!0,rn(...n))}function x0(n,e,t){return new Promise(function(i,r){function a(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(a,t);break;default:i()}}setTimeout(a,t)})}var _0={[Jc]:$c,[Kc]:eu,[Qc]:tu,[ho]:jc,[$c]:Jc,[eu]:Kc,[tu]:Qc,[jc]:ho},Sa=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){let i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){let i=this._listeners;if(i===void 0)return;let r=i[e];if(r!==void 0){let a=r.indexOf(t);a!==-1&&r.splice(a,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let i=t[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let a=0,s=r.length;a<s;a++)r[a].call(this,e);e.target=null}}},Qi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];var vf=Math.PI/180,au=180/Math.PI;function Ro(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Qi[n&255]+Qi[n>>8&255]+Qi[n>>16&255]+Qi[n>>24&255]+"-"+Qi[e&255]+Qi[e>>8&255]+"-"+Qi[e>>16&15|64]+Qi[e>>24&255]+"-"+Qi[t&63|128]+Qi[t>>8&255]+"-"+Qi[t>>16&255]+Qi[t>>24&255]+Qi[i&255]+Qi[i>>8&255]+Qi[i>>16&255]+Qi[i>>24&255]).toLowerCase()}function Tn(n,e,t){return Math.max(e,Math.min(t,n))}function Rg(n,e){return(n%e+e)%e}function gf(n,e,t){return(1-t)*n+t*e}function tl(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:case Uint8ClampedArray:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Tr(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var Eh=class Eh{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Tn(this.x,e.x,t.x),this.y=Tn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Tn(this.x,e,t),this.y=Tn(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Tn(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Tn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Eh.prototype.isVector2=!0;var kt=Eh,ba=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,a,s,o){let u=i[r+0],l=i[r+1],d=i[r+2],f=i[r+3],h=a[s+0],v=a[s+1],y=a[s+2],T=a[s+3];if(f!==T||u!==h||l!==v||d!==y){let g=u*h+l*v+d*y+f*T;g<0&&(h=-h,v=-v,y=-y,T=-T,g=-g);let m=1-o;if(g<.9995){let L=Math.acos(g),F=Math.sin(L);m=Math.sin(m*L)/F,o=Math.sin(o*L)/F,u=u*m+h*o,l=l*m+v*o,d=d*m+y*o,f=f*m+T*o}else{u=u*m+h*o,l=l*m+v*o,d=d*m+y*o,f=f*m+T*o;let L=1/Math.sqrt(u*u+l*l+d*d+f*f);u*=L,l*=L,d*=L,f*=L}}e[t]=u,e[t+1]=l,e[t+2]=d,e[t+3]=f}static multiplyQuaternionsFlat(e,t,i,r,a,s){let o=i[r],u=i[r+1],l=i[r+2],d=i[r+3],f=a[s],h=a[s+1],v=a[s+2],y=a[s+3];return e[t]=o*y+d*f+u*v-l*h,e[t+1]=u*y+d*h+l*f-o*v,e[t+2]=l*y+d*v+o*h-u*f,e[t+3]=d*y-o*f-u*h-l*v,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,a=e._z,s=e._order,o=Math.cos,u=Math.sin,l=o(i/2),d=o(r/2),f=o(a/2),h=u(i/2),v=u(r/2),y=u(a/2);switch(s){case"XYZ":this._x=h*d*f+l*v*y,this._y=l*v*f-h*d*y,this._z=l*d*y+h*v*f,this._w=l*d*f-h*v*y;break;case"YXZ":this._x=h*d*f+l*v*y,this._y=l*v*f-h*d*y,this._z=l*d*y-h*v*f,this._w=l*d*f+h*v*y;break;case"ZXY":this._x=h*d*f-l*v*y,this._y=l*v*f+h*d*y,this._z=l*d*y+h*v*f,this._w=l*d*f-h*v*y;break;case"ZYX":this._x=h*d*f-l*v*y,this._y=l*v*f+h*d*y,this._z=l*d*y-h*v*f,this._w=l*d*f+h*v*y;break;case"YZX":this._x=h*d*f+l*v*y,this._y=l*v*f+h*d*y,this._z=l*d*y-h*v*f,this._w=l*d*f-h*v*y;break;case"XZY":this._x=h*d*f-l*v*y,this._y=l*v*f-h*d*y,this._z=l*d*y+h*v*f,this._w=l*d*f+h*v*y;break;default:rn("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],a=t[8],s=t[1],o=t[5],u=t[9],l=t[2],d=t[6],f=t[10],h=i+o+f;if(h>0){let v=.5/Math.sqrt(h+1);this._w=.25/v,this._x=(d-u)*v,this._y=(a-l)*v,this._z=(s-r)*v}else if(i>o&&i>f){let v=2*Math.sqrt(1+i-o-f);this._w=(d-u)/v,this._x=.25*v,this._y=(r+s)/v,this._z=(a+l)/v}else if(o>f){let v=2*Math.sqrt(1+o-i-f);this._w=(a-l)/v,this._x=(r+s)/v,this._y=.25*v,this._z=(u+d)/v}else{let v=2*Math.sqrt(1+f-i-o);this._w=(s-r)/v,this._x=(a+l)/v,this._y=(u+d)/v,this._z=.25*v}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Tn(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,a=e._z,s=e._w,o=t._x,u=t._y,l=t._z,d=t._w;return this._x=i*d+s*o+r*l-a*u,this._y=r*d+s*u+a*o-i*l,this._z=a*d+s*l+i*u-r*o,this._w=s*d-i*o-r*u-a*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,a=-a,s=-s,o=-o);let u=1-t;if(o<.9995){let l=Math.acos(o),d=Math.sin(l);u=Math.sin(u*l)/d,t=Math.sin(t*l)/d,this._x=this._x*u+i*t,this._y=this._y*u+r*t,this._z=this._z*u+a*t,this._w=this._w*u+s*t,this._onChangeCallback()}else this._x=this._x*u+i*t,this._y=this._y*u+r*t,this._z=this._z*u+a*t,this._w=this._w*u+s*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),a=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),a*Math.sin(t),a*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Ah=class Ah{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(om.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(om.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6]*r,this.y=a[1]*t+a[4]*i+a[7]*r,this.z=a[2]*t+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*t+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*t+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*t+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*t+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,a=e.x,s=e.y,o=e.z,u=e.w,l=2*(s*r-o*i),d=2*(o*t-a*r),f=2*(a*i-s*t);return this.x=t+u*l+s*f-o*d,this.y=i+u*d+o*l-a*f,this.z=r+u*f+a*d-s*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r,this.y=a[1]*t+a[5]*i+a[9]*r,this.z=a[2]*t+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Tn(this.x,e.x,t.x),this.y=Tn(this.y,e.y,t.y),this.z=Tn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Tn(this.x,e,t),this.y=Tn(this.y,e,t),this.z=Tn(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Tn(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,a=e.z,s=t.x,o=t.y,u=t.z;return this.x=r*u-a*o,this.y=a*s-i*u,this.z=i*o-r*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return yf.copy(this).projectOnVector(e),this.sub(yf)}reflect(e){return this.sub(yf.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(Tn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Ah.prototype.isVector3=!0;var ge=Ah,yf=new ge,om=new ba,Ih=class Ih{constructor(e,t,i,r,a,s,o,u,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,u,l)}set(e,t,i,r,a,s,o,u,l){let d=this.elements;return d[0]=e,d[1]=r,d[2]=o,d[3]=t,d[4]=a,d[5]=u,d[6]=i,d[7]=s,d[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[3],u=i[6],l=i[1],d=i[4],f=i[7],h=i[2],v=i[5],y=i[8],T=r[0],g=r[3],m=r[6],L=r[1],F=r[4],_=r[7],p=r[2],S=r[5],B=r[8];return a[0]=s*T+o*L+u*p,a[3]=s*g+o*F+u*S,a[6]=s*m+o*_+u*B,a[1]=l*T+d*L+f*p,a[4]=l*g+d*F+f*S,a[7]=l*m+d*_+f*B,a[2]=h*T+v*L+y*p,a[5]=h*g+v*F+y*S,a[8]=h*m+v*_+y*B,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8];return t*s*d-t*o*l-i*a*d+i*o*u+r*a*l-r*s*u}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8],f=d*s-o*l,h=o*u-d*a,v=l*a-s*u,y=t*f+i*h+r*v;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);let T=1/y;return e[0]=f*T,e[1]=(r*l-d*i)*T,e[2]=(o*i-r*s)*T,e[3]=h*T,e[4]=(d*t-r*u)*T,e[5]=(r*a-o*t)*T,e[6]=v*T,e[7]=(i*u-l*t)*T,e[8]=(s*t-i*a)*T,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,a,s,o){let u=Math.cos(a),l=Math.sin(a);return this.set(i*u,i*l,-i*(u*s+l*o)+s+e,-r*l,r*u,-r*(-l*s+u*o)+o+t,0,0,1),this}scale(e,t){return Ls("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(xf.makeScale(e,t)),this}rotate(e){return Ls("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(xf.makeRotation(-e)),this}translate(e,t){return Ls("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(xf.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Ih.prototype.isMatrix3=!0;var un=Ih,xf=new un,lm=new un().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),cm=new un().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Pg(){let n={enabled:!0,workingColorSpace:fl,spaces:{},convert:function(r,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Jn&&(r.r=Wa(r.r),r.g=Wa(r.g),r.b=Wa(r.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(r.applyMatrix3(this.spaces[a].toXYZ),r.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===Jn&&(r.r=uo(r.r),r.g=uo(r.g),r.b=uo(r.b))),r},workingToColorSpace:function(r,a){return this.convert(r,this.workingColorSpace,a)},colorSpaceToWorking:function(r,a){return this.convert(r,a,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Ya?hl:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,a=this.workingColorSpace){return r.fromArray(this.spaces[a].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,a,s){return r.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,a){return Ls("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return Ls("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,a)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[fl]:{primaries:e,whitePoint:i,transfer:hl,toXYZ:lm,fromXYZ:cm,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:hr},outputColorSpaceConfig:{drawingBufferColorSpace:hr}},[hr]:{primaries:e,whitePoint:i,transfer:Jn,toXYZ:lm,fromXYZ:cm,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:hr}}}),n}var Ln=Pg();function Wa(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function uo(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var $s,su=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{$s===void 0&&($s=pl("canvas")),$s.width=e.width,$s.height=e.height;let r=$s.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=$s}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=pl("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let s=0;s<a.length;s++)a[s]=Wa(a[s]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Wa(t[i]/255)*255):t[i]=Wa(t[i]);return{data:t,width:e.width,height:e.height}}else return rn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Lg=0,vo=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Lg++}),this.uuid=Ro(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let a;if(Array.isArray(r)){a=[];for(let s=0,o=r.length;s<o;s++)r[s].isDataTexture?a.push(_f(r[s].image)):a.push(_f(r[s]))}else a=_f(r);i.url=a}return t||(e.images[this.uuid]=i),i}};function _f(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?su.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(rn("Texture: Unable to serialize Texture."),{})}var Dg=0,Mf=new ge,tr=class n extends Sa{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=_a,r=_a,a=Hi,s=gs,o=qr,u=Cr,l=n.DEFAULT_ANISOTROPY,d=Ya){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Dg++}),this.uuid=Ro(),this.name="",this.source=new vo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=a,this.minFilter=s,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=u,this.offset=new kt(0,0),this.repeat=new kt(1,1),this.center=new kt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new un,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Mf).x}get height(){return this.source.getSize(Mf).y}get depth(){return this.source.getSize(Mf).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let i=e[t];if(i===void 0){rn(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){rn(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==fh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case nu:e.x=e.x-Math.floor(e.x);break;case _a:e.x=e.x<0?0:1;break;case iu:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case nu:e.y=e.y-Math.floor(e.y);break;case _a:e.y=e.y<0?0:1;break;case iu:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};tr.DEFAULT_IMAGE=null;tr.DEFAULT_MAPPING=fh;tr.DEFAULT_ANISOTROPY=1;var Ch=class Ch{constructor(e=0,t=0,i=0,r=1){this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*t+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*t+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*t+s[7]*i+s[11]*r+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,a,u=e.elements,l=u[0],d=u[4],f=u[8],h=u[1],v=u[5],y=u[9],T=u[2],g=u[6],m=u[10];if(Math.abs(d-h)<.01&&Math.abs(f-T)<.01&&Math.abs(y-g)<.01){if(Math.abs(d+h)<.1&&Math.abs(f+T)<.1&&Math.abs(y+g)<.1&&Math.abs(l+v+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let F=(l+1)/2,_=(v+1)/2,p=(m+1)/2,S=(d+h)/4,B=(f+T)/4,b=(y+g)/4;return F>_&&F>p?F<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(F),r=S/i,a=B/i):_>p?_<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(_),i=S/r,a=b/r):p<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(p),i=B/a,r=b/a),this.set(i,r,a,t),this}let L=Math.sqrt((g-y)*(g-y)+(f-T)*(f-T)+(h-d)*(h-d));return Math.abs(L)<.001&&(L=1),this.x=(g-y)/L,this.y=(f-T)/L,this.z=(h-d)/L,this.w=Math.acos((l+v+m-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Tn(this.x,e.x,t.x),this.y=Tn(this.y,e.y,t.y),this.z=Tn(this.z,e.z,t.z),this.w=Tn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Tn(this.x,e,t),this.y=Tn(this.y,e,t),this.z=Tn(this.z,e,t),this.w=Tn(this.w,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Tn(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Ch.prototype.isVector4=!0;var fi=Ch,ou=class extends Sa{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Hi,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new fi(0,0,e,t),this.scissorTest=!1,this.viewport=new fi(0,0,e,t),this.textures=[];let r={width:e,height:t,depth:i.depth},a=new tr(r),s=i.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveColorBuffer=i.resolveColorBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.storeMultisampledColorBuffer=i.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=i.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=i.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:Hi,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,a=this.textures.length;r<a;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let r=Object.assign({},e.textures[t].image);this.textures[t].source=new vo(r)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ar=class extends ou{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},ml=class extends tr{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Bi,this.minFilter=Bi,this.wrapR=_a,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var lu=class extends tr{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=Bi,this.minFilter=Bi,this.wrapR=_a,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var Lu=class Lu{constructor(e,t,i,r,a,s,o,u,l,d,f,h,v,y,T,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,u,l,d,f,h,v,y,T,g)}set(e,t,i,r,a,s,o,u,l,d,f,h,v,y,T,g){let m=this.elements;return m[0]=e,m[4]=t,m[8]=i,m[12]=r,m[1]=a,m[5]=s,m[9]=o,m[13]=u,m[2]=l,m[6]=d,m[10]=f,m[14]=h,m[3]=v,m[7]=y,m[11]=T,m[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Lu().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,i=e.elements,r=1/Ks.setFromMatrixColumn(e,0).length(),a=1/Ks.setFromMatrixColumn(e,1).length(),s=1/Ks.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*a,t[5]=i[5]*a,t[6]=i[6]*a,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),o=Math.sin(i),u=Math.cos(r),l=Math.sin(r),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){let h=s*d,v=s*f,y=o*d,T=o*f;t[0]=u*d,t[4]=-u*f,t[8]=l,t[1]=v+y*l,t[5]=h-T*l,t[9]=-o*u,t[2]=T-h*l,t[6]=y+v*l,t[10]=s*u}else if(e.order==="YXZ"){let h=u*d,v=u*f,y=l*d,T=l*f;t[0]=h+T*o,t[4]=y*o-v,t[8]=s*l,t[1]=s*f,t[5]=s*d,t[9]=-o,t[2]=v*o-y,t[6]=T+h*o,t[10]=s*u}else if(e.order==="ZXY"){let h=u*d,v=u*f,y=l*d,T=l*f;t[0]=h-T*o,t[4]=-s*f,t[8]=y+v*o,t[1]=v+y*o,t[5]=s*d,t[9]=T-h*o,t[2]=-s*l,t[6]=o,t[10]=s*u}else if(e.order==="ZYX"){let h=s*d,v=s*f,y=o*d,T=o*f;t[0]=u*d,t[4]=y*l-v,t[8]=h*l+T,t[1]=u*f,t[5]=T*l+h,t[9]=v*l-y,t[2]=-l,t[6]=o*u,t[10]=s*u}else if(e.order==="YZX"){let h=s*u,v=s*l,y=o*u,T=o*l;t[0]=u*d,t[4]=T-h*f,t[8]=y*f+v,t[1]=f,t[5]=s*d,t[9]=-o*d,t[2]=-l*d,t[6]=v*f+y,t[10]=h-T*f}else if(e.order==="XZY"){let h=s*u,v=s*l,y=o*u,T=o*l;t[0]=u*d,t[4]=-f,t[8]=l*d,t[1]=h*f+T,t[5]=s*d,t[9]=v*f-y,t[2]=y*f-v,t[6]=o*d,t[10]=T*f+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ng,e,Ug)}lookAt(e,t,i){let r=this.elements;return Dr.subVectors(e,t),Dr.lengthSq()===0&&(Dr.z=1),Dr.normalize(),ns.crossVectors(i,Dr),ns.lengthSq()===0&&(Math.abs(i.z)===1?Dr.x+=1e-4:Dr.z+=1e-4,Dr.normalize(),ns.crossVectors(i,Dr)),ns.normalize(),Tc.crossVectors(Dr,ns),r[0]=ns.x,r[4]=Tc.x,r[8]=Dr.x,r[1]=ns.y,r[5]=Tc.y,r[9]=Dr.y,r[2]=ns.z,r[6]=Tc.z,r[10]=Dr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[4],u=i[8],l=i[12],d=i[1],f=i[5],h=i[9],v=i[13],y=i[2],T=i[6],g=i[10],m=i[14],L=i[3],F=i[7],_=i[11],p=i[15],S=r[0],B=r[4],b=r[8],I=r[12],z=r[1],U=r[5],Y=r[9],E=r[13],M=r[2],O=r[6],H=r[10],ee=r[14],j=r[3],K=r[7],re=r[11],J=r[15];return a[0]=s*S+o*z+u*M+l*j,a[4]=s*B+o*U+u*O+l*K,a[8]=s*b+o*Y+u*H+l*re,a[12]=s*I+o*E+u*ee+l*J,a[1]=d*S+f*z+h*M+v*j,a[5]=d*B+f*U+h*O+v*K,a[9]=d*b+f*Y+h*H+v*re,a[13]=d*I+f*E+h*ee+v*J,a[2]=y*S+T*z+g*M+m*j,a[6]=y*B+T*U+g*O+m*K,a[10]=y*b+T*Y+g*H+m*re,a[14]=y*I+T*E+g*ee+m*J,a[3]=L*S+F*z+_*M+p*j,a[7]=L*B+F*U+_*O+p*K,a[11]=L*b+F*Y+_*H+p*re,a[15]=L*I+F*E+_*ee+p*J,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],a=e[12],s=e[1],o=e[5],u=e[9],l=e[13],d=e[2],f=e[6],h=e[10],v=e[14],y=e[3],T=e[7],g=e[11],m=e[15],L=u*v-l*h,F=o*v-l*f,_=o*h-u*f,p=s*v-l*d,S=s*h-u*d,B=s*f-o*d;return t*(T*L-g*F+m*_)-i*(y*L-g*p+m*S)+r*(y*F-T*p+m*B)-a*(y*_-T*S+g*B)}determinantAffine(){let e=this.elements,t=e[0],i=e[4],r=e[8],a=e[1],s=e[5],o=e[9],u=e[2],l=e[6],d=e[10];return t*(s*d-o*l)-i*(a*d-o*u)+r*(a*l-s*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8],f=e[9],h=e[10],v=e[11],y=e[12],T=e[13],g=e[14],m=e[15],L=t*o-i*s,F=t*u-r*s,_=t*l-a*s,p=i*u-r*o,S=i*l-a*o,B=r*l-a*u,b=d*T-f*y,I=d*g-h*y,z=d*m-v*y,U=f*g-h*T,Y=f*m-v*T,E=h*m-v*g,M=L*E-F*Y+_*U+p*z-S*I+B*b;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let O=1/M;return e[0]=(o*E-u*Y+l*U)*O,e[1]=(r*Y-i*E-a*U)*O,e[2]=(T*B-g*S+m*p)*O,e[3]=(h*S-f*B-v*p)*O,e[4]=(u*z-s*E-l*I)*O,e[5]=(t*E-r*z+a*I)*O,e[6]=(g*_-y*B-m*F)*O,e[7]=(d*B-h*_+v*F)*O,e[8]=(s*Y-o*z+l*b)*O,e[9]=(i*z-t*Y-a*b)*O,e[10]=(y*S-T*_+m*L)*O,e[11]=(f*_-d*S-v*L)*O,e[12]=(o*I-s*U-u*b)*O,e[13]=(t*U-i*I+r*b)*O,e[14]=(T*F-y*p-g*L)*O,e[15]=(d*p-f*F+h*L)*O,this}scale(e){let t=this.elements,i=e.x,r=e.y,a=e.z;return t[0]*=i,t[4]*=r,t[8]*=a,t[1]*=i,t[5]*=r,t[9]*=a,t[2]*=i,t[6]*=r,t[10]*=a,t[3]*=i,t[7]*=r,t[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),a=1-i,s=e.x,o=e.y,u=e.z,l=a*s,d=a*o;return this.set(l*s+i,l*o-r*u,l*u+r*o,0,l*o+r*u,d*o+i,d*u-r*s,0,l*u-r*o,d*u+r*s,a*u*u+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,a=t._x,s=t._y,o=t._z,u=t._w,l=a+a,d=s+s,f=o+o,h=a*l,v=a*d,y=a*f,T=s*d,g=s*f,m=o*f,L=u*l,F=u*d,_=u*f,p=i.x,S=i.y,B=i.z;return r[0]=(1-(T+m))*p,r[1]=(v+_)*p,r[2]=(y-F)*p,r[3]=0,r[4]=(v-_)*S,r[5]=(1-(h+m))*S,r[6]=(g+L)*S,r[7]=0,r[8]=(y+F)*B,r[9]=(g-L)*B,r[10]=(1-(h+T))*B,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let a=this.determinantAffine();if(a===0)return i.set(1,1,1),t.identity(),this;let s=Ks.set(r[0],r[1],r[2]).length(),o=Ks.set(r[4],r[5],r[6]).length(),u=Ks.set(r[8],r[9],r[10]).length();a<0&&(s=-s),ta.copy(this);let l=1/s,d=1/o,f=1/u;return ta.elements[0]*=l,ta.elements[1]*=l,ta.elements[2]*=l,ta.elements[4]*=d,ta.elements[5]*=d,ta.elements[6]*=d,ta.elements[8]*=f,ta.elements[9]*=f,ta.elements[10]*=f,t.setFromRotationMatrix(ta),i.x=s,i.y=o,i.z=u,this}makePerspective(e,t,i,r,a,s,o=ra,u=!1){let l=this.elements,d=2*a/(t-e),f=2*a/(i-r),h=(t+e)/(t-e),v=(i+r)/(i-r),y,T;if(u)y=a/(s-a),T=s*a/(s-a);else if(o===ra)y=-(s+a)/(s-a),T=-2*s*a/(s-a);else if(o===po)y=-s/(s-a),T=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=d,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=f,l[9]=v,l[13]=0,l[2]=0,l[6]=0,l[10]=y,l[14]=T,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,a,s,o=ra,u=!1){let l=this.elements,d=2/(t-e),f=2/(i-r),h=-(t+e)/(t-e),v=-(i+r)/(i-r),y,T;if(u)y=1/(s-a),T=s/(s-a);else if(o===ra)y=-2/(s-a),T=-(s+a)/(s-a);else if(o===po)y=-1/(s-a),T=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=d,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=f,l[9]=0,l[13]=v,l[2]=0,l[6]=0,l[10]=y,l[14]=T,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};Lu.prototype.isMatrix4=!0;var $n=Lu,Ks=new ge,ta=new $n,Ng=new ge(0,0,0),Ug=new ge(1,1,1),ns=new ge,Tc=new ge,Dr=new ge,um=new $n,dm=new ba,Xa=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,a=r[0],s=r[4],o=r[8],u=r[1],l=r[5],d=r[9],f=r[2],h=r[6],v=r[10];switch(t){case"XYZ":this._y=Math.asin(Tn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,v),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Tn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,v),this._z=Math.atan2(u,l)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Tn(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,v),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(u,a));break;case"ZYX":this._y=Math.asin(-Tn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,v),this._z=Math.atan2(u,a)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Tn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-d,l),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,v));break;case"XZY":this._z=Math.asin(-Tn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,v),this._y=0);break;default:rn("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return um.makeRotationFromQuaternion(e),this.setFromRotationMatrix(um,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return dm.setFromEuler(this),this.setFromQuaternion(dm,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Xa.DEFAULT_ORDER="XYZ";var go=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},Fg=0,fm=new ge,Qs=new ba,ka=new $n,Ec=new ge,nl=new ge,Og=new ge,Bg=new ba,hm=new ge(1,0,0),pm=new ge(0,1,0),mm=new ge(0,0,1),vm={type:"added"},kg={type:"removed"},js={type:"childadded",child:null},Sf={type:"childremoved",child:null},nr=class n extends Sa{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Fg++}),this.uuid=Ro(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new ge,t=new Xa,i=new ba,r=new ge(1,1,1);function a(){i.setFromEuler(t,!1)}function s(){t.setFromQuaternion(i,void 0,!1)}t._onChange(a),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new $n},normalMatrix:{value:new un}}),this.matrix=new $n,this.matrixWorld=new $n,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new go,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Qs.setFromAxisAngle(e,t),this.quaternion.multiply(Qs),this}rotateOnWorldAxis(e,t){return Qs.setFromAxisAngle(e,t),this.quaternion.premultiply(Qs),this}rotateX(e){return this.rotateOnAxis(hm,e)}rotateY(e){return this.rotateOnAxis(pm,e)}rotateZ(e){return this.rotateOnAxis(mm,e)}translateOnAxis(e,t){return fm.copy(e).applyQuaternion(this.quaternion),this.position.add(fm.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(hm,e)}translateY(e){return this.translateOnAxis(pm,e)}translateZ(e){return this.translateOnAxis(mm,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ka.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Ec.copy(e):Ec.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),nl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ka.lookAt(nl,Ec,this.up):ka.lookAt(Ec,nl,this.up),this.quaternion.setFromRotationMatrix(ka),r&&(ka.extractRotation(r.matrixWorld),Qs.setFromRotationMatrix(ka),this.quaternion.premultiply(Qs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(sn("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(vm),js.child=e,this.dispatchEvent(js),js.child=null):sn("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(kg),Sf.child=e,this.dispatchEvent(Sf),Sf.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ka.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ka.multiply(e.parent.matrixWorld)),e.applyMatrix4(ka),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(vm),js.child=e,this.dispatchEvent(js),js.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nl,e,Og),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nl,Bg,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,i=e.y,r=e.z,a=this.matrix.elements;a[12]+=t-a[0]*t-a[4]*i-a[8]*r,a[13]+=i-a[1]*t-a[5]*i-a[9]*r,a[14]+=r-a[2]*t-a[6]*i-a[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),t===!0){let a=this.children;for(let s=0,o=a.length;s<o;s++)a[s].updateWorldMatrix(!1,!0,i)}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function a(o,u){return o[u.uuid]===void 0&&(o[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let u=o.shapes;if(Array.isArray(u))for(let l=0,d=u.length;l<d;l++){let f=u[l];a(e.shapes,f)}else a(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let u=0,l=this.material.length;u<l;u++)o.push(a(e.materials,this.material[u]));r.material=o}else r.material=a(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){let u=this.animations[o];r.animations.push(a(e.animations,u))}}if(t){let o=s(e.geometries),u=s(e.materials),l=s(e.textures),d=s(e.images),f=s(e.shapes),h=s(e.skeletons),v=s(e.animations),y=s(e.nodes);o.length>0&&(i.geometries=o),u.length>0&&(i.materials=u),l.length>0&&(i.textures=l),d.length>0&&(i.images=d),f.length>0&&(i.shapes=f),h.length>0&&(i.skeletons=h),v.length>0&&(i.animations=v),y.length>0&&(i.nodes=y)}return i.object=r,i;function s(o){let u=[];for(let l in o){let d=o[l];delete d.metadata,u.push(d)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};nr.DEFAULT_UP=new ge(0,1,0);nr.DEFAULT_MATRIX_AUTO_UPDATE=!0;nr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Er=class extends nr{constructor(){super(),this.isGroup=!0,this.type="Group"}},zg={type:"move"},yo=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Er,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Er,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ge,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ge),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Er,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ge,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ge,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,a=null,s=null,o=this._targetRay,u=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){s=!0;for(let T of e.hand.values()){let g=t.getJointPose(T,i),m=this._getHandJoint(l,T);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}let d=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],h=d.position.distanceTo(f.position),v=.02,y=.005;l.inputState.pinching&&h>v+y?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=v-y&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,i),a!==null&&(u.matrix.fromArray(a.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,a.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(a.linearVelocity)):u.hasLinearVelocity=!1,a.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(a.angularVelocity)):u.hasAngularVelocity=!1,u.eventsEnabled&&u.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(zg)))}return o!==null&&(o.visible=r!==null),u!==null&&(u.visible=a!==null),l!==null&&(l.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Er;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},M0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},is={h:0,s:0,l:0},Ac={h:0,s:0,l:0};function bf(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}var vn=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=hr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ln.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=Ln.workingColorSpace){return this.r=e,this.g=t,this.b=i,Ln.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=Ln.workingColorSpace){if(e=Rg(e,1),t=Tn(t,0,1),i=Tn(i,0,1),t===0)this.r=this.g=this.b=i;else{let a=i<=.5?i*(1+t):i+t-i*t,s=2*i-a;this.r=bf(s,a,e+1/3),this.g=bf(s,a,e),this.b=bf(s,a,e-1/3)}return Ln.colorSpaceToWorking(this,r),this}setStyle(e,t=hr){function i(a){a!==void 0&&parseFloat(a)<1&&rn("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let a,s=r[1],o=r[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:rn("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let a=r[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(s===6)return this.setHex(parseInt(a,16),t);rn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=hr){let i=M0[e.toLowerCase()];return i!==void 0?this.setHex(i,t):rn("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Wa(e.r),this.g=Wa(e.g),this.b=Wa(e.b),this}copyLinearToSRGB(e){return this.r=uo(e.r),this.g=uo(e.g),this.b=uo(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=hr){return Ln.workingToColorSpace(ji.copy(this),e),Math.round(Tn(ji.r*255,0,255))*65536+Math.round(Tn(ji.g*255,0,255))*256+Math.round(Tn(ji.b*255,0,255))}getHexString(e=hr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ln.workingColorSpace){Ln.workingToColorSpace(ji.copy(this),t);let i=ji.r,r=ji.g,a=ji.b,s=Math.max(i,r,a),o=Math.min(i,r,a),u,l,d=(o+s)/2;if(o===s)u=0,l=0;else{let f=s-o;switch(l=d<=.5?f/(s+o):f/(2-s-o),s){case i:u=(r-a)/f+(r<a?6:0);break;case r:u=(a-i)/f+2;break;case a:u=(i-r)/f+4;break}u/=6}return e.h=u,e.s=l,e.l=d,e}getRGB(e,t=Ln.workingColorSpace){return Ln.workingToColorSpace(ji.copy(this),t),e.r=ji.r,e.g=ji.g,e.b=ji.b,e}getStyle(e=hr){Ln.workingToColorSpace(ji.copy(this),e);let t=ji.r,i=ji.g,r=ji.b;return e!==hr?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(is),this.setHSL(is.h+e,is.s+t,is.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(is),e.getHSL(Ac);let i=gf(is.h,Ac.h,t),r=gf(is.s,Ac.s,t),a=gf(is.l,Ac.l,t);return this.setHSL(i,r,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,a=e.elements;return this.r=a[0]*t+a[3]*i+a[6]*r,this.g=a[1]*t+a[4]*i+a[7]*r,this.b=a[2]*t+a[5]*i+a[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},ji=new vn;vn.NAMES=M0;var vl=class extends nr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Xa,this.environmentIntensity=1,this.environmentRotation=new Xa,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},na=new ge,za=new ge,wf=new ge,Va=new ge,eo=new ge,to=new ge,gm=new ge,Tf=new ge,Ef=new ge,Af=new ge,If=new fi,Cf=new fi,Rf=new fi,os=class n{constructor(e=new ge,t=new ge,i=new ge){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),na.subVectors(e,t),r.cross(na);let a=r.lengthSq();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,t,i,r,a){na.subVectors(r,t),za.subVectors(i,t),wf.subVectors(e,t);let s=na.dot(na),o=na.dot(za),u=na.dot(wf),l=za.dot(za),d=za.dot(wf),f=s*l-o*o;if(f===0)return a.set(0,0,0),null;let h=1/f,v=(l*u-o*d)*h,y=(s*d-o*u)*h;return a.set(1-v-y,y,v)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Va)===null?!1:Va.x>=0&&Va.y>=0&&Va.x+Va.y<=1}static getInterpolation(e,t,i,r,a,s,o,u){return this.getBarycoord(e,t,i,r,Va)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(a,Va.x),u.addScaledVector(s,Va.y),u.addScaledVector(o,Va.z),u)}static getInterpolatedAttribute(e,t,i,r,a,s){return If.setScalar(0),Cf.setScalar(0),Rf.setScalar(0),If.fromBufferAttribute(e,t),Cf.fromBufferAttribute(e,i),Rf.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(If,a.x),s.addScaledVector(Cf,a.y),s.addScaledVector(Rf,a.z),s}static isFrontFacing(e,t,i,r){return na.subVectors(i,t),za.subVectors(e,t),na.cross(za).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return na.subVectors(this.c,this.b),za.subVectors(this.a,this.b),na.cross(za).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,a){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,a=this.c,s,o;eo.subVectors(r,i),to.subVectors(a,i),Tf.subVectors(e,i);let u=eo.dot(Tf),l=to.dot(Tf);if(u<=0&&l<=0)return t.copy(i);Ef.subVectors(e,r);let d=eo.dot(Ef),f=to.dot(Ef);if(d>=0&&f<=d)return t.copy(r);let h=u*f-d*l;if(h<=0&&u>=0&&d<=0)return s=u/(u-d),t.copy(i).addScaledVector(eo,s);Af.subVectors(e,a);let v=eo.dot(Af),y=to.dot(Af);if(y>=0&&v<=y)return t.copy(a);let T=v*l-u*y;if(T<=0&&l>=0&&y<=0)return o=l/(l-y),t.copy(i).addScaledVector(to,o);let g=d*y-v*f;if(g<=0&&f-d>=0&&v-y>=0)return gm.subVectors(a,r),o=(f-d)/(f-d+(v-y)),t.copy(r).addScaledVector(gm,o);let m=1/(g+T+h);return s=T*m,o=h*m,t.copy(i).addScaledVector(eo,s).addScaledVector(to,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},wa=class{constructor(e=new ge(1/0,1/0,1/0),t=new ge(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(ia.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(ia.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=ia.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let a=i.getAttribute("position");if(t===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,ia):ia.fromBufferAttribute(a,s),ia.applyMatrix4(e.matrixWorld),this.expandByPoint(ia);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ic.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ic.copy(i.boundingBox)),Ic.applyMatrix4(e.matrixWorld),this.union(Ic)}let r=e.children;for(let a=0,s=r.length;a<s;a++)this.expandByObject(r[a],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ia),ia.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(il),Cc.subVectors(this.max,il),no.subVectors(e.a,il),io.subVectors(e.b,il),ro.subVectors(e.c,il),rs.subVectors(io,no),as.subVectors(ro,io),Is.subVectors(no,ro);let t=[0,-rs.z,rs.y,0,-as.z,as.y,0,-Is.z,Is.y,rs.z,0,-rs.x,as.z,0,-as.x,Is.z,0,-Is.x,-rs.y,rs.x,0,-as.y,as.x,0,-Is.y,Is.x,0];return!Pf(t,no,io,ro,Cc)||(t=[1,0,0,0,1,0,0,0,1],!Pf(t,no,io,ro,Cc))?!1:(Rc.crossVectors(rs,as),t=[Rc.x,Rc.y,Rc.z],Pf(t,no,io,ro,Cc))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ia).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ia).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Ga[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ga[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ga[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ga[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ga[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ga[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ga[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ga[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ga),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Ga=[new ge,new ge,new ge,new ge,new ge,new ge,new ge,new ge],ia=new ge,Ic=new wa,no=new ge,io=new ge,ro=new ge,rs=new ge,as=new ge,Is=new ge,il=new ge,Cc=new ge,Rc=new ge,Cs=new ge;function Pf(n,e,t,i,r){for(let a=0,s=n.length-3;a<=s;a+=3){Cs.fromArray(n,a);let o=r.x*Math.abs(Cs.x)+r.y*Math.abs(Cs.y)+r.z*Math.abs(Cs.z),u=e.dot(Cs),l=t.dot(Cs),d=i.dot(Cs);if(Math.max(-Math.max(u,l,d),Math.min(u,l,d))>o)return!1}return!0}var Ci=new ge,Pc=new kt,Vg=0,Fr=class extends Sa{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Vg++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=v0,this.updateRanges=[],this.gpuType=Yr,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,a=this.itemSize;r<a;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Pc.fromBufferAttribute(this,t),Pc.applyMatrix3(e),this.setXY(t,Pc.x,Pc.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.applyMatrix3(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.applyMatrix4(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.applyNormalMatrix(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ci.fromBufferAttribute(this,t),Ci.transformDirection(e),this.setXYZ(t,Ci.x,Ci.y,Ci.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=tl(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Tr(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=tl(t,this.array)),t}setX(e,t){return this.normalized&&(t=Tr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=tl(t,this.array)),t}setY(e,t){return this.normalized&&(t=Tr(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=tl(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Tr(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=tl(t,this.array)),t}setW(e,t){return this.normalized&&(t=Tr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Tr(t,this.array),i=Tr(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Tr(t,this.array),i=Tr(i,this.array),r=Tr(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e*=this.itemSize,this.normalized&&(t=Tr(t,this.array),i=Tr(i,this.array),r=Tr(r,this.array),a=Tr(a,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}};var gl=class extends Fr{constructor(e,t,i){super(new Uint16Array(e),t,i)}};var yl=class extends Fr{constructor(e,t,i){super(new Uint32Array(e),t,i)}};var Xn=class extends Fr{constructor(e,t,i){super(new Float32Array(e),t,i)}},Gg=new wa,rl=new ge,Lf=new ge,ls=class{constructor(e=new ge,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):Gg.setFromPoints(e).getCenter(i);let r=0;for(let a=0,s=e.length;a<s;a++)r=Math.max(r,i.distanceToSquared(e[a]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;rl.subVectors(e,this.center);let t=rl.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(rl,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Lf.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(rl.copy(e.center).add(Lf)),this.expandByPoint(rl.copy(e.center).sub(Lf))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Hg=0,Xr=new $n,Df=new nr,ao=new ge,Nr=new wa,al=new wa,Oi=new ge,Wi=class n extends Sa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Hg++}),this.uuid=Ro(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Ig(e)?yl:gl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let a=new un().getNormalMatrix(e);i.applyNormalMatrix(a),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Xr.makeRotationFromQuaternion(e),this.applyMatrix4(Xr),this}rotateX(e){return Xr.makeRotationX(e),this.applyMatrix4(Xr),this}rotateY(e){return Xr.makeRotationY(e),this.applyMatrix4(Xr),this}rotateZ(e){return Xr.makeRotationZ(e),this.applyMatrix4(Xr),this}translate(e,t,i){return Xr.makeTranslation(e,t,i),this.applyMatrix4(Xr),this}scale(e,t,i){return Xr.makeScale(e,t,i),this.applyMatrix4(Xr),this}lookAt(e){return Df.lookAt(e),Df.updateMatrix(),this.applyMatrix4(Df.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ao).negate(),this.translate(ao.x,ao.y,ao.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let i=[];for(let r=0,a=e.length;r<a;r++){let s=e[r];i.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Xn(i,3))}else{let i=Math.min(e.length,t.count);for(let r=0;r<i;r++){let a=e[r];t.setXYZ(r,a.x,a.y,a.z||0)}e.length>t.count&&rn("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wa);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){sn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ge(-1/0,-1/0,-1/0),new ge(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let a=t[i];Nr.setFromBufferAttribute(a),this.morphTargetsRelative?(Oi.addVectors(this.boundingBox.min,Nr.min),this.boundingBox.expandByPoint(Oi),Oi.addVectors(this.boundingBox.max,Nr.max),this.boundingBox.expandByPoint(Oi)):(this.boundingBox.expandByPoint(Nr.min),this.boundingBox.expandByPoint(Nr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&sn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ls);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){sn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ge,1/0);return}if(e){let i=this.boundingSphere.center;if(Nr.setFromBufferAttribute(e),t)for(let a=0,s=t.length;a<s;a++){let o=t[a];al.setFromBufferAttribute(o),this.morphTargetsRelative?(Oi.addVectors(Nr.min,al.min),Nr.expandByPoint(Oi),Oi.addVectors(Nr.max,al.max),Nr.expandByPoint(Oi)):(Nr.expandByPoint(al.min),Nr.expandByPoint(al.max))}Nr.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)Oi.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(Oi));if(t)for(let a=0,s=t.length;a<s;a++){let o=t[a],u=this.morphTargetsRelative;for(let l=0,d=o.count;l<d;l++)Oi.fromBufferAttribute(o,l),u&&(ao.fromBufferAttribute(e,l),Oi.add(ao)),r=Math.max(r,i.distanceToSquared(Oi))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&sn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){sn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,a=t.uv,s=this.getAttribute("tangent");(s===void 0||s.count!==i.count)&&(s=new Fr(new Float32Array(4*i.count),4),this.setAttribute("tangent",s));let o=[],u=[];for(let b=0;b<i.count;b++)o[b]=new ge,u[b]=new ge;let l=new ge,d=new ge,f=new ge,h=new kt,v=new kt,y=new kt,T=new ge,g=new ge;function m(b,I,z){l.fromBufferAttribute(i,b),d.fromBufferAttribute(i,I),f.fromBufferAttribute(i,z),h.fromBufferAttribute(a,b),v.fromBufferAttribute(a,I),y.fromBufferAttribute(a,z),d.sub(l),f.sub(l),v.sub(h),y.sub(h);let U=1/(v.x*y.y-y.x*v.y);isFinite(U)&&(T.copy(d).multiplyScalar(y.y).addScaledVector(f,-v.y).multiplyScalar(U),g.copy(f).multiplyScalar(v.x).addScaledVector(d,-y.x).multiplyScalar(U),o[b].add(T),o[I].add(T),o[z].add(T),u[b].add(g),u[I].add(g),u[z].add(g))}let L=this.groups;L.length===0&&(L=[{start:0,count:e.count}]);for(let b=0,I=L.length;b<I;++b){let z=L[b],U=z.start,Y=z.count;for(let E=U,M=U+Y;E<M;E+=3)m(e.getX(E+0),e.getX(E+1),e.getX(E+2))}let F=new ge,_=new ge,p=new ge,S=new ge;function B(b){p.fromBufferAttribute(r,b),S.copy(p);let I=o[b];F.copy(I),F.sub(p.multiplyScalar(p.dot(I))).normalize(),_.crossVectors(S,I);let U=_.dot(u[b])<0?-1:1;s.setXYZW(b,F.x,F.y,F.z,U)}for(let b=0,I=L.length;b<I;++b){let z=L[b],U=z.start,Y=z.count;for(let E=U,M=U+Y;E<M;E+=3)B(e.getX(E+0)),B(e.getX(E+1)),B(e.getX(E+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==t.count)i=new Fr(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,v=i.count;h<v;h++)i.setXYZ(h,0,0,0);let r=new ge,a=new ge,s=new ge,o=new ge,u=new ge,l=new ge,d=new ge,f=new ge;if(e)for(let h=0,v=e.count;h<v;h+=3){let y=e.getX(h+0),T=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,y),a.fromBufferAttribute(t,T),s.fromBufferAttribute(t,g),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),o.fromBufferAttribute(i,y),u.fromBufferAttribute(i,T),l.fromBufferAttribute(i,g),o.add(d),u.add(d),l.add(d),i.setXYZ(y,o.x,o.y,o.z),i.setXYZ(T,u.x,u.y,u.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let h=0,v=t.count;h<v;h+=3)r.fromBufferAttribute(t,h+0),a.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),i.setXYZ(h+0,d.x,d.y,d.z),i.setXYZ(h+1,d.x,d.y,d.z),i.setXYZ(h+2,d.x,d.y,d.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Oi.fromBufferAttribute(e,t),Oi.normalize(),e.setXYZ(t,Oi.x,Oi.y,Oi.z)}toNonIndexed(){function e(o,u){let l=o.array,d=o.itemSize,f=o.normalized,h=new l.constructor(u.length*d),v=0,y=0;for(let T=0,g=u.length;T<g;T++){o.isInterleavedBufferAttribute?v=u[T]*o.data.stride+o.offset:v=u[T]*d;for(let m=0;m<d;m++)h[y++]=l[v++]}return new Fr(h,d,f)}if(this.index===null)return rn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let o in r){let u=r[o],l=e(u,i);t.setAttribute(o,l)}let a=this.morphAttributes;for(let o in a){let u=[],l=a[o];for(let d=0,f=l.length;d<f;d++){let h=l[d],v=e(h,i);u.push(v)}t.morphAttributes[o]=u}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,u=s.length;o<u;o++){let l=s[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let u=this.parameters;for(let l in u)u[l]!==void 0&&(e[l]=u[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let u in i){let l=i[u];e.data.attributes[u]=l.toJSON(e.data)}let r={},a=!1;for(let u in this.morphAttributes){let l=this.morphAttributes[u],d=[];for(let f=0,h=l.length;f<h;f++){let v=l[f];d.push(v.toJSON(e.data))}d.length>0&&(r[u]=d,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone());let r=e.attributes;for(let l in r){let d=r[l];this.setAttribute(l,d.clone(t))}let a=e.morphAttributes;for(let l in a){let d=[],f=a[l];for(let h=0,v=f.length;h<v;h++)d.push(f[h].clone(t));this.morphAttributes[l]=d}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let l=0,d=s.length;l<d;l++){let f=s[l];this.addGroup(f.start,f.count,f.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};var Nf=new ge,Wg=new ge,Xg=new un,Ur=class{constructor(e=new ge(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=Nf.subVectors(i,t).cross(Wg.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){let r=e.delta(Nf),a=this.normal.dot(r);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/a;return i===!0&&(s<0||s>1)?null:t.copy(e.start).addScaledVector(r,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||Xg.getNormalMatrix(e),r=this.coplanarPoint(Nf).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},Yg=0,cs=class extends Sa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Yg++}),this.uuid=Ro(),this.name="",this.type="Material",this.blending=Ao,this.side=ms,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ih,this.blendDst=rh,this.blendEquation=Fs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new vn(0,0,0),this.blendAlpha=0,this.depthFunc=ho,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=c0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Zc,this.stencilZFail=Zc,this.stencilZPass=Zc,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){rn(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){rn(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector2&&i&&i.isVector2||r&&r.isEuler&&i&&i.isEuler||r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,i.blending=this.blending,i.side=this.side,i.shadowSide=this.shadowSide,i.vertexColors=this.vertexColors,i.opacity=this.opacity,i.transparent=this.transparent,i.blendSrc=this.blendSrc,i.blendDst=this.blendDst,i.blendEquation=this.blendEquation,i.blendSrcAlpha=this.blendSrcAlpha,i.blendDstAlpha=this.blendDstAlpha,i.blendEquationAlpha=this.blendEquationAlpha,i.blendColor=this.blendColor.getHex(),i.blendAlpha=this.blendAlpha,i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.clipIntersection=this.clipIntersection,i.clipShadows=this.clipShadows,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,i.stencilWrite=this.stencilWrite,i.polygonOffset=this.polygonOffset,i.polygonOffsetFactor=this.polygonOffsetFactor,i.polygonOffsetUnits=this.polygonOffsetUnits,i.dithering=this.dithering,i.alphaTest=this.alphaTest,i.alphaHash=this.alphaHash,i.alphaToCoverage=this.alphaToCoverage,i.premultipliedAlpha=this.premultipliedAlpha,i.forceSinglePass=this.forceSinglePass,i.allowOverride=this.allowOverride,i.visible=this.visible,i.toneMapped=this.toneMapped,i.name=this.name,this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(i.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(i.clippingPlanes=this.clippingPlanes.map(a=>a.toJSON())),this.rotation!==void 0&&(i.rotation=this.rotation),this.depthPacking!==void 0&&(i.depthPacking=this.depthPacking),this.linewidth!==void 0&&(i.linewidth=this.linewidth),this.linecap!==void 0&&(i.linecap=this.linecap),this.linejoin!==void 0&&(i.linejoin=this.linejoin),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.wireframe!==void 0&&(i.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(i.flatShading=this.flatShading),this.fog!==void 0&&(i.fog=this.fog),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(a){let s=[];for(let o in a){let u=a[o];delete u.metadata,s.push(u)}return s}if(t){let a=r(e.textures),s=r(e.images);a.length>0&&(i.textures=a),s.length>0&&(i.images=s)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new vn().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(i=>new Ur().fromJSON(i))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new kt().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new kt().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let a=0;a!==r;++a)i[a]=t[a].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};var Ha=new ge,Uf=new ge,Lc=new ge,Dc=new ge,xl=class{constructor(e=new ge,t=new ge(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ha)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Ha.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ha.copy(this.origin).addScaledVector(this.direction,t),Ha.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Uf.copy(e).add(t).multiplyScalar(.5),Lc.copy(t).sub(e).normalize(),Dc.copy(this.origin).sub(Uf);let a=e.distanceTo(t)*.5,s=-this.direction.dot(Lc),o=Dc.dot(this.direction),u=-Dc.dot(Lc),l=Dc.lengthSq(),d=Math.abs(1-s*s),f,h,v,y;if(d>0)if(f=s*u-o,h=s*o-u,y=a*d,f>=0)if(h>=-y)if(h<=y){let T=1/d;f*=T,h*=T,v=f*(f+s*h+2*o)+h*(s*f+h+2*u)+l}else h=a,f=Math.max(0,-(s*h+o)),v=-f*f+h*(h+2*u)+l;else h=-a,f=Math.max(0,-(s*h+o)),v=-f*f+h*(h+2*u)+l;else h<=-y?(f=Math.max(0,-(-s*a+o)),h=f>0?-a:Math.min(Math.max(-a,-u),a),v=-f*f+h*(h+2*u)+l):h<=y?(f=0,h=Math.min(Math.max(-a,-u),a),v=h*(h+2*u)+l):(f=Math.max(0,-(s*a+o)),h=f>0?a:Math.min(Math.max(-a,-u),a),v=-f*f+h*(h+2*u)+l);else h=s>0?-a:a,f=Math.max(0,-(s*h+o)),v=-f*f+h*(h+2*u)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(Uf).addScaledVector(Lc,h),v}intersectSphere(e,t){if(e.radius<0)return null;Ha.subVectors(e.center,this.origin);let i=Ha.dot(this.direction),r=Ha.dot(Ha)-i*i,a=e.radius*e.radius;if(r>a)return null;let s=Math.sqrt(a-r),o=i-s,u=i+s;return u<0?null:o<0?this.at(u,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,a,s,o,u,l=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),d>=0?(a=(e.min.y-h.y)*d,s=(e.max.y-h.y)*d):(a=(e.max.y-h.y)*d,s=(e.min.y-h.y)*d),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),f>=0?(o=(e.min.z-h.z)*f,u=(e.max.z-h.z)*f):(o=(e.max.z-h.z)*f,u=(e.min.z-h.z)*f),i>u||o>r)||((o>i||i!==i)&&(i=o),(u<r||r!==r)&&(r=u),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Ha)!==null}intersectTriangle(e,t,i,r,a){let s=this.origin,o=this.direction,u=o.x,l=o.y,d=o.z,f=e.x-s.x,h=e.y-s.y,v=e.z-s.z,y=t.x-s.x,T=t.y-s.y,g=t.z-s.z,m=i.x-s.x,L=i.y-s.y,F=i.z-s.z,_=Math.abs(u),p=Math.abs(l),S=Math.abs(d),B,b,I,z,U,Y,E,M,O,H,ee,j;if(_>=p&&_>=S?(I=u,Y=f,O=y,j=m,u>=0?(B=l,b=d,z=h,U=v,E=T,M=g,H=L,ee=F):(B=d,b=l,z=v,U=h,E=g,M=T,H=F,ee=L)):p>=S?(I=l,Y=h,O=T,j=L,l>=0?(B=d,b=u,z=v,U=f,E=g,M=y,H=F,ee=m):(B=u,b=d,z=f,U=v,E=y,M=g,H=m,ee=F)):(I=d,Y=v,O=g,j=F,d>=0?(B=u,b=l,z=f,U=h,E=y,M=T,H=m,ee=L):(B=l,b=u,z=h,U=f,E=T,M=y,H=L,ee=m)),I===0)return null;let K=B/I,re=b/I,J=1/I,ne=z-K*Y,Te=U-re*Y,fe=E-K*O,pe=M-re*O,Fe=H-K*j,ae=ee-re*j,de=Fe*pe-ae*fe,_e=ne*ae-Te*Fe,Ge=fe*Te-pe*ne;if(r){if(de<0||_e<0||Ge<0)return null}else if((de<0||_e<0||Ge<0)&&(de>0||_e>0||Ge>0))return null;let $e=de+_e+Ge;if($e===0)return null;let ut=J*(de*Y+_e*O+Ge*j);return($e>0?ut<0:ut>0)?null:this.at(ut/$e,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ta=class extends cs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new vn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xa,this.combine=Nu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},ym=new $n,Rs=new xl,Nc=new ls,xm=new ge,Uc=new ge,Fc=new ge,Oc=new ge,Ff=new ge,Bc=new ge,_m=new ge,kc=new ge,jn=class extends nr{constructor(e=new Wi,t=new Ta){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){let o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,a=i.morphAttributes.position,s=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(a&&o){Bc.set(0,0,0);for(let u=0,l=a.length;u<l;u++){let d=o[u],f=a[u];d!==0&&(Ff.fromBufferAttribute(f,e),s?Bc.addScaledVector(Ff,d):Bc.addScaledVector(Ff.sub(t),d))}t.add(Bc)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Nc.copy(i.boundingSphere),Nc.applyMatrix4(a),Rs.copy(e.ray).recast(e.near),!(Nc.containsPoint(Rs.origin)===!1&&(Rs.intersectSphere(Nc,xm)===null||Rs.origin.distanceToSquared(xm)>(e.far-e.near)**2))&&(ym.copy(a).invert(),Rs.copy(e.ray).applyMatrix4(ym),!(i.boundingBox!==null&&Rs.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Rs)))}_computeIntersections(e,t,i){let r,a=this.geometry,s=this.material,o=a.index,u=a.attributes.position,l=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,h=a.groups,v=a.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,T=h.length;y<T;y++){let g=h[y],m=s[g.materialIndex],L=Math.max(g.start,v.start),F=Math.min(o.count,Math.min(g.start+g.count,v.start+v.count));for(let _=L,p=F;_<p;_+=3){let S=o.getX(_),B=o.getX(_+1),b=o.getX(_+2);r=zc(this,m,e,i,l,d,f,S,B,b),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let y=Math.max(0,v.start),T=Math.min(o.count,v.start+v.count);for(let g=y,m=T;g<m;g+=3){let L=o.getX(g),F=o.getX(g+1),_=o.getX(g+2);r=zc(this,s,e,i,l,d,f,L,F,_),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(s))for(let y=0,T=h.length;y<T;y++){let g=h[y],m=s[g.materialIndex],L=Math.max(g.start,v.start),F=Math.min(u.count,Math.min(g.start+g.count,v.start+v.count));for(let _=L,p=F;_<p;_+=3){let S=_,B=_+1,b=_+2;r=zc(this,m,e,i,l,d,f,S,B,b),r&&(r.faceIndex=Math.floor(_/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let y=Math.max(0,v.start),T=Math.min(u.count,v.start+v.count);for(let g=y,m=T;g<m;g+=3){let L=g,F=g+1,_=g+2;r=zc(this,s,e,i,l,d,f,L,F,_),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};function qg(n,e,t,i,r,a,s,o){let u;if(e.side===pr?u=i.intersectTriangle(s,a,r,!0,o):u=i.intersectTriangle(r,a,s,e.side===ms,o),u===null)return null;kc.copy(o),kc.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(kc);return l<t.near||l>t.far?null:{distance:l,point:kc.clone(),object:n}}function zc(n,e,t,i,r,a,s,o,u,l){n.getVertexPosition(o,Uc),n.getVertexPosition(u,Fc),n.getVertexPosition(l,Oc);let d=qg(n,e,t,i,Uc,Fc,Oc,_m);if(d){let f=new ge;os.getBarycoord(_m,Uc,Fc,Oc,f),r&&(d.uv=os.getInterpolatedAttribute(r,o,u,l,f,new kt)),a&&(d.uv1=os.getInterpolatedAttribute(a,o,u,l,f,new kt)),s&&(d.normal=os.getInterpolatedAttribute(s,o,u,l,f,new ge),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));let h={a:o,b:u,c:l,normal:new ge,materialIndex:0};os.getNormal(Uc,Fc,Oc,h.normal),d.face=h,d.barycoord=f}return d}var _l=class extends tr{constructor(e=null,t=1,i=1,r,a,s,o,u,l=Bi,d=Bi,f,h){super(null,s,o,u,l,d,r,a,f,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Ml=class extends Fr{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},so=new $n,Mm=new $n,Vc=[],Sm=new wa,Zg=new $n,sl=new jn,ol=new ls,Ea=class extends jn{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ml(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,Zg)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new wa),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,so),Sm.copy(e.boundingBox).applyMatrix4(so),this.boundingBox.union(Sm)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ls),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,so),ol.copy(e.boundingSphere).applyMatrix4(so),this.boundingSphere.union(ol)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,a=i.length+1,s=e*a+1;for(let o=0;o<i.length;o++)i[o]=r[s+o]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(sl.geometry=this.geometry,sl.material=this.material,sl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ol.copy(this.boundingSphere),ol.applyMatrix4(i),e.ray.intersectsSphere(ol)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,so),Mm.multiplyMatrices(i,so),sl.matrixWorld=Mm,sl.raycast(e,Vc);for(let s=0,o=Vc.length;s<o;s++){let u=Vc[s];u.instanceId=a,u.object=this,t.push(u)}Vc.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Ml(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new _l(new Float32Array(r*this.count),r,this.count,Vu,Yr));let a=this.morphTexture.source.data.data,s=0;for(let l=0;l<i.length;l++)s+=i[l];let o=this.geometry.morphTargetsRelative?1:1-s,u=r*e;return a[u]=o,a.set(i,u+1),this}updateMorphTargets(){}dispose(){super.dispose(),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},Ps=new ls,Jg=new kt(.5,.5),Gc=new ge,xo=class{constructor(e=new Ur,t=new Ur,i=new Ur,r=new Ur,a=new Ur,s=new Ur){this.planes=[e,t,i,r,a,s]}set(e,t,i,r,a,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(a),o[5].copy(s),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=ra,i=!1){let r=this.planes,a=e.elements,s=a[0],o=a[1],u=a[2],l=a[3],d=a[4],f=a[5],h=a[6],v=a[7],y=a[8],T=a[9],g=a[10],m=a[11],L=a[12],F=a[13],_=a[14],p=a[15];if(r[0].setComponents(l-s,v-d,m-y,p-L).normalize(),r[1].setComponents(l+s,v+d,m+y,p+L).normalize(),r[2].setComponents(l+o,v+f,m+T,p+F).normalize(),r[3].setComponents(l-o,v-f,m-T,p-F).normalize(),i)r[4].setComponents(u,h,g,_).normalize(),r[5].setComponents(l-u,v-h,m-g,p-_).normalize();else if(r[4].setComponents(l-u,v-h,m-g,p-_).normalize(),t===ra)r[5].setComponents(l+u,v+h,m+g,p+_).normalize();else if(t===po)r[5].setComponents(u,h,g,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ps.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ps.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ps)}intersectsSprite(e){Ps.center.set(0,0,0);let t=Jg.distanceTo(e.center);return Ps.radius=.7071067811865476+t,Ps.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ps)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(Gc.x=r.normal.x>0?e.max.x:e.min.x,Gc.y=r.normal.y>0?e.max.y:e.min.y,Gc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Gc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var Sl=class extends tr{constructor(e=[],t=vs,i,r,a,s,o,u,l,d){super(e,t,i,r,a,s,o,u,l,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var us=class extends tr{constructor(e,t,i=sa,r,a,s,o=Bi,u=Bi,l,d=Ma,f=1){if(d!==Ma&&d!==ys)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:f};super(h,r,a,s,o,u,d,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new vo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},cu=class extends us{constructor(e,t=sa,i=vs,r,a,s=Bi,o=Bi,u,l=Ma){let d={width:e,height:e,depth:1},f=[d,d,d,d,d,d];super(e,e,t,i,r,a,s,o,u,l),this.image=f,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},bl=class extends tr{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Or=class n extends Wi{constructor(e=1,t=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};let o=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);let u=[],l=[],d=[],f=[],h=0,v=0;y("z","y","x",-1,-1,i,t,e,s,a,0),y("z","y","x",1,-1,i,t,-e,s,a,1),y("x","z","y",1,1,e,i,t,r,s,2),y("x","z","y",1,-1,e,i,-t,r,s,3),y("x","y","z",1,-1,e,t,i,r,a,4),y("x","y","z",-1,-1,e,t,-i,r,a,5),this.setIndex(u),this.setAttribute("position",new Xn(l,3)),this.setAttribute("normal",new Xn(d,3)),this.setAttribute("uv",new Xn(f,2));function y(T,g,m,L,F,_,p,S,B,b,I){let z=_/B,U=p/b,Y=_/2,E=p/2,M=S/2,O=B+1,H=b+1,ee=0,j=0,K=new ge;for(let re=0;re<H;re++){let J=re*U-E;for(let ne=0;ne<O;ne++){let Te=ne*z-Y;K[T]=Te*L,K[g]=J*F,K[m]=M,l.push(K.x,K.y,K.z),K[T]=0,K[g]=0,K[m]=S>0?1:-1,d.push(K.x,K.y,K.z),f.push(ne/B),f.push(1-re/b),ee+=1}}for(let re=0;re<b;re++)for(let J=0;J<B;J++){let ne=h+J+O*re,Te=h+J+O*(re+1),fe=h+(J+1)+O*(re+1),pe=h+(J+1)+O*re;u.push(ne,Te,pe),u.push(Te,fe,pe),j+=6}o.addGroup(v,j,I),v+=j,h+=ee}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var _o=class n extends Wi{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let a=[],s=[],o=[],u=[],l=new ge,d=new kt;s.push(0,0,0),o.push(0,0,1),u.push(.5,.5);for(let f=0,h=3;f<=t;f++,h+=3){let v=i+f/t*r;l.x=e*Math.cos(v),l.y=e*Math.sin(v),s.push(l.x,l.y,l.z),o.push(0,0,1),d.x=(s[h]/e+1)/2,d.y=(s[h+1]/e+1)/2,u.push(d.x,d.y)}for(let f=1;f<=t;f++)a.push(f,f+1,0);this.setIndex(a),this.setAttribute("position",new Xn(s,3)),this.setAttribute("normal",new Xn(o,3)),this.setAttribute("uv",new Xn(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},Ds=class n extends Wi{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,o=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:o,thetaLength:u};let l=this;r=Math.floor(r),a=Math.floor(a);let d=[],f=[],h=[],v=[],y=0,T=[],g=i/2,m=0;L(),s===!1&&(e>0&&F(!0),t>0&&F(!1)),this.setIndex(d),this.setAttribute("position",new Xn(f,3)),this.setAttribute("normal",new Xn(h,3)),this.setAttribute("uv",new Xn(v,2));function L(){let _=new ge,p=new ge,S=0,B=(t-e)/i;for(let b=0;b<=a;b++){let I=[],z=b/a,U=z*(t-e)+e;for(let Y=0;Y<=r;Y++){let E=Y/r,M=E*u+o,O=Math.sin(M),H=Math.cos(M);p.x=U*O,p.y=-z*i+g,p.z=U*H,f.push(p.x,p.y,p.z),_.set(O,B,H).normalize(),h.push(_.x,_.y,_.z),v.push(E,1-z),I.push(y++)}T.push(I)}for(let b=0;b<r;b++)for(let I=0;I<a;I++){let z=T[I][b],U=T[I+1][b],Y=T[I+1][b+1],E=T[I][b+1];(e>0||I!==0)&&(d.push(z,U,E),S+=3),(t>0||I!==a-1)&&(d.push(U,Y,E),S+=3)}l.addGroup(m,S,0),m+=S}function F(_){let p=y,S=new kt,B=new ge,b=0,I=_===!0?e:t,z=_===!0?1:-1;for(let Y=1;Y<=r;Y++)f.push(0,g*z,0),h.push(0,z,0),v.push(.5,.5),y++;let U=y;for(let Y=0;Y<=r;Y++){let M=Y/r*u+o,O=Math.cos(M),H=Math.sin(M);B.x=I*H,B.y=g*z,B.z=I*O,f.push(B.x,B.y,B.z),h.push(0,z,0),S.x=O*.5+.5,S.y=H*.5*z+.5,v.push(S.x,S.y),y++}for(let Y=0;Y<r;Y++){let E=p+Y,M=U+Y;_===!0?d.push(M,M+1,E):d.push(M+1,M,E),b+=3}l.addGroup(m,b,_===!0?1:2),m+=b}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}};var Br=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){rn("Curve: .getPoint() not implemented.")}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let i=this.getLengths(),r=0,a=i.length,s;t?s=t:s=e*i[a-1];let o=0,u=a-1,l;for(;o<=u;)if(r=Math.floor(o+(u-o)/2),l=i[r]-s,l<0)o=r+1;else if(l>0)u=r-1;else{u=r;break}if(r=u,i[r]===s)return r/(a-1);let d=i[r],h=i[r+1]-d,v=(s-d)/h;return(r+v)/(a-1)}getTangent(e,t){let r=e-1e-4,a=e+1e-4;r<0&&(r=0),a>1&&(a=1);let s=this.getPoint(r),o=this.getPoint(a),u=t||(s.isVector2?new kt:new ge);return u.copy(o).sub(s).normalize(),u}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){let i=new ge,r=[],a=[],s=[],o=new ge,u=new $n;for(let v=0;v<=e;v++){let y=v/e;r[v]=this.getTangentAt(y,new ge)}a[0]=new ge,s[0]=new ge;let l=Number.MAX_VALUE,d=Math.abs(r[0].x),f=Math.abs(r[0].y),h=Math.abs(r[0].z);d<=l&&(l=d,i.set(1,0,0)),f<=l&&(l=f,i.set(0,1,0)),h<=l&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],o),s[0].crossVectors(r[0],a[0]);for(let v=1;v<=e;v++){if(a[v]=a[v-1].clone(),s[v]=s[v-1].clone(),o.crossVectors(r[v-1],r[v]),o.length()>Number.EPSILON){o.normalize();let y=Math.acos(Tn(r[v-1].dot(r[v]),-1,1));a[v].applyMatrix4(u.makeRotationAxis(o,y))}s[v].crossVectors(r[v],a[v])}if(t===!0){let v=Math.acos(Tn(a[0].dot(a[e]),-1,1));v/=e,r[0].dot(o.crossVectors(a[0],a[e]))>0&&(v=-v);for(let y=1;y<=e;y++)a[y].applyMatrix4(u.makeRotationAxis(r[y],v*y)),s[y].crossVectors(r[y],a[y])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Mo=class extends Br{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,o=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=o,this.aRotation=u}getPoint(e,t=new kt){let i=t,r=Math.PI*2,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);let o=this.aStartAngle+e*a,u=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let d=Math.cos(this.aRotation),f=Math.sin(this.aRotation),h=u-this.aX,v=l-this.aY;u=h*d-v*f+this.aX,l=h*f+v*d+this.aY}return i.set(u,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},uu=class extends Mo{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}};function Mh(){let n=0,e=0,t=0,i=0;function r(a,s,o,u){n=a,e=o,t=-3*a+3*s-2*o-u,i=2*a-2*s+o+u}return{initCatmullRom:function(a,s,o,u,l){r(s,o,l*(o-a),l*(u-s))},initNonuniformCatmullRom:function(a,s,o,u,l,d,f){let h=(s-a)/l-(o-a)/(l+d)+(o-s)/d,v=(o-s)/d-(u-s)/(d+f)+(u-o)/f;h*=d,v*=d,r(s,o,h,v)},calc:function(a){let s=a*a,o=s*a;return n+e*a+t*s+i*o}}}var bm=new ge,wm=new ge,Of=new Mh,Bf=new Mh,kf=new Mh,du=class extends Br{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new ge){let i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e,o=Math.floor(s),u=s-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/a)+1)*a:u===0&&o===a-1&&(o=a-2,u=1);let l,d;this.closed||o>0?l=r[(o-1)%a]:(wm.subVectors(r[0],r[1]).add(r[0]),l=wm);let f=r[o%a],h=r[(o+1)%a];if(this.closed||o+2<a?d=r[(o+2)%a]:(bm.subVectors(r[a-1],r[a-2]).add(r[a-1]),d=bm),this.curveType==="centripetal"||this.curveType==="chordal"){let v=this.curveType==="chordal"?.5:.25,y=Math.pow(l.distanceToSquared(f),v),T=Math.pow(f.distanceToSquared(h),v),g=Math.pow(h.distanceToSquared(d),v);T<1e-4&&(T=1),y<1e-4&&(y=T),g<1e-4&&(g=T),Of.initNonuniformCatmullRom(l.x,f.x,h.x,d.x,y,T,g),Bf.initNonuniformCatmullRom(l.y,f.y,h.y,d.y,y,T,g),kf.initNonuniformCatmullRom(l.z,f.z,h.z,d.z,y,T,g)}else this.curveType==="catmullrom"&&(Of.initCatmullRom(l.x,f.x,h.x,d.x,this.tension),Bf.initCatmullRom(l.y,f.y,h.y,d.y,this.tension),kf.initCatmullRom(l.z,f.z,h.z,d.z,this.tension));return i.set(Of.calc(u),Bf.calc(u),kf.calc(u)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new ge().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Tm(n,e,t,i,r){let a=(i-e)*.5,s=(r-t)*.5,o=n*n,u=n*o;return(2*t-2*i+a+s)*u+(-3*t+3*i-2*a-s)*o+a*n+t}function $g(n,e){let t=1-n;return t*t*e}function Kg(n,e){return 2*(1-n)*n*e}function Qg(n,e){return n*n*e}function cl(n,e,t,i){return $g(n,e)+Kg(n,t)+Qg(n,i)}function jg(n,e){let t=1-n;return t*t*t*e}function ey(n,e){let t=1-n;return 3*t*t*n*e}function ty(n,e){return 3*(1-n)*n*n*e}function ny(n,e){return n*n*n*e}function ul(n,e,t,i,r){return jg(n,e)+ey(n,t)+ty(n,i)+ny(n,r)}var wl=class extends Br{constructor(e=new kt,t=new kt,i=new kt,r=new kt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new kt){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(ul(e,r.x,a.x,s.x,o.x),ul(e,r.y,a.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},fu=class extends Br{constructor(e=new ge,t=new ge,i=new ge,r=new ge){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ge){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(ul(e,r.x,a.x,s.x,o.x),ul(e,r.y,a.y,s.y,o.y),ul(e,r.z,a.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Tl=class extends Br{constructor(e=new kt,t=new kt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new kt){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new kt){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},hu=class extends Br{constructor(e=new ge,t=new ge){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new ge){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ge){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},El=class extends Br{constructor(e=new kt,t=new kt,i=new kt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new kt){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(cl(e,r.x,a.x,s.x),cl(e,r.y,a.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},pu=class extends Br{constructor(e=new ge,t=new ge,i=new ge){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ge){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(cl(e,r.x,a.x,s.x),cl(e,r.y,a.y,s.y),cl(e,r.z,a.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Al=class extends Br{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new kt){let i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),o=a-s,u=r[s===0?s:s-1],l=r[s],d=r[s>r.length-2?r.length-1:s+1],f=r[s>r.length-3?r.length-1:s+2];return i.set(Tm(o,u.x,l.x,d.x,f.x),Tm(o,u.y,l.y,d.y,f.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new kt().fromArray(r))}return this}},Em=Object.freeze({__proto__:null,ArcCurve:uu,CatmullRomCurve3:du,CubicBezierCurve:wl,CubicBezierCurve3:fu,EllipseCurve:Mo,LineCurve:Tl,LineCurve3:hu,QuadraticBezierCurve:El,QuadraticBezierCurve3:pu,SplineCurve:Al}),mu=class extends Br{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Em[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),a=0;for(;a<r.length;){if(r[a]>=i){let s=r[a]-i,o=this.curves[a],u=o.getLength(),l=u===0?0:1-s/u;return o.getPointAt(l,t)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,a=this.curves;r<a.length;r++){let s=a[r],o=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,u=s.getPoints(o);for(let l=0;l<u.length;l++){let d=u[l];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new Em[r.type]().fromJSON(r))}return this}},Ns=class extends mu{constructor(e){super(),this.type="Path",this.currentPoint=new kt,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new Tl(this.currentPoint.clone(),new kt(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new El(this.currentPoint.clone(),new kt(e,t),new kt(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let o=new wl(this.currentPoint.clone(),new kt(e,t),new kt(i,r),new kt(a,s));return this.curves.push(o),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Al(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){let o=this.currentPoint.x,u=this.currentPoint.y;return this.absarc(e+o,t+u,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,o,u){let l=this.currentPoint.x,d=this.currentPoint.y;return this.absellipse(e+l,t+d,i,r,a,s,o,u),this}absellipse(e,t,i,r,a,s,o,u){let l=new Mo(e,t,i,r,a,s,o,u);if(this.curves.length>0){let f=l.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(l);let d=l.getPoint(1);return this.currentPoint.copy(d),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},So=class extends Ns{constructor(e){super(e),this.uuid=Ro(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Ns().fromJSON(r))}return this}};function iy(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,a=S0(n,0,r,t,!0),s=[];if(!a||a.next===a.prev)return s;let o,u,l;if(i&&(a=ly(n,e,a,t)),n.length>80*t){o=n[0],u=n[1];let d=o,f=u;for(let h=t;h<r;h+=t){let v=n[h],y=n[h+1];v<o&&(o=v),y<u&&(u=y),v>d&&(d=v),y>f&&(f=y)}l=Math.max(d-o,f-u),l=l!==0?32767/l:0}return Il(a,s,t,o,u,l,0),s}function S0(n,e,t,i,r){let a;if(r===xy(n,e,t,i)>0)for(let s=e;s<t;s+=i)a=Am(s/i|0,n[s],n[s+1],a);else for(let s=t-i;s>=e;s-=i)a=Am(s/i|0,n[s],n[s+1],a);return a&&bo(a,a.next)&&(Rl(a),a=a.next),a}function Us(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(bo(t,t.next)||mi(t.prev,t,t.next)===0)){if(Rl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Il(n,e,t,i,r,a,s){if(!n)return;!s&&a&&hy(n,i,r,a);let o=n;for(;n.prev!==n.next;){let u=n.prev,l=n.next;if(a?ay(n,i,r,a):ry(n)){e.push(u.i,n.i,l.i),Rl(n),n=l.next,o=l.next;continue}if(n=l,n===o){s?s===1?(n=sy(Us(n),e),Il(n,e,t,i,r,a,2)):s===2&&oy(n,e,t,i,r,a):Il(Us(n),e,t,i,r,a,1);break}}}function ry(n){let e=n.prev,t=n,i=n.next;if(mi(e,t,i)>=0)return!1;let r=e.x,a=t.x,s=i.x,o=e.y,u=t.y,l=i.y,d=Math.min(r,a,s),f=Math.min(o,u,l),h=Math.max(r,a,s),v=Math.max(o,u,l),y=i.next;for(;y!==e;){if(y.x>=d&&y.x<=h&&y.y>=f&&y.y<=v&&ll(r,o,a,u,s,l,y.x,y.y)&&mi(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function ay(n,e,t,i){let r=n.prev,a=n,s=n.next;if(mi(r,a,s)>=0)return!1;let o=r.x,u=a.x,l=s.x,d=r.y,f=a.y,h=s.y,v=Math.min(o,u,l),y=Math.min(d,f,h),T=Math.max(o,u,l),g=Math.max(d,f,h),m=Yf(v,y,e,t,i),L=Yf(T,g,e,t,i),F=n.prevZ,_=n.nextZ;for(;F&&F.z>=m&&_&&_.z<=L;){if(F.x>=v&&F.x<=T&&F.y>=y&&F.y<=g&&F!==r&&F!==s&&ll(o,d,u,f,l,h,F.x,F.y)&&mi(F.prev,F,F.next)>=0||(F=F.prevZ,_.x>=v&&_.x<=T&&_.y>=y&&_.y<=g&&_!==r&&_!==s&&ll(o,d,u,f,l,h,_.x,_.y)&&mi(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;F&&F.z>=m;){if(F.x>=v&&F.x<=T&&F.y>=y&&F.y<=g&&F!==r&&F!==s&&ll(o,d,u,f,l,h,F.x,F.y)&&mi(F.prev,F,F.next)>=0)return!1;F=F.prevZ}for(;_&&_.z<=L;){if(_.x>=v&&_.x<=T&&_.y>=y&&_.y<=g&&_!==r&&_!==s&&ll(o,d,u,f,l,h,_.x,_.y)&&mi(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function sy(n,e){let t=n;do{let i=t.prev,r=t.next.next;!bo(i,r)&&w0(i,t,t.next,r)&&Cl(i,r)&&Cl(r,i)&&(e.push(i.i,t.i,r.i),Rl(t),Rl(t.next),t=n=r),t=t.next}while(t!==n);return Us(t)}function oy(n,e,t,i,r,a){let s=n;do{let o=s.next.next;for(;o!==s.prev;){if(s.i!==o.i&&vy(s,o)){let u=T0(s,o);s=Us(s,s.next),u=Us(u,u.next),Il(s,e,t,i,r,a,0),Il(u,e,t,i,r,a,0);return}o=o.next}s=s.next}while(s!==n)}function ly(n,e,t,i){let r=[];for(let a=0,s=e.length;a<s;a++){let o=e[a]*i,u=a<s-1?e[a+1]*i:n.length,l=S0(n,o,u,i,!1);l===l.next&&(l.steiner=!0),r.push(my(l))}r.sort(cy);for(let a=0;a<r.length;a++)t=uy(r[a],t);return t}function cy(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){let i=(n.next.y-n.y)/(n.next.x-n.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=i-r}return t}function uy(n,e){let t=dy(n,e);if(!t)return e;let i=T0(t,n);return Us(i,i.next),Us(t,t.next)}function dy(n,e){let t=e,i=n.x,r=n.y,a=-1/0,s;if(bo(n,t))return t;do{if(bo(n,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){let f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=i&&f>a&&(a=f,s=t.x<t.next.x?t:t.next,f===i))return s}t=t.next}while(t!==e);if(!s)return null;let o=s,u=s.x,l=s.y,d=1/0;t=s;do{if(i>=t.x&&t.x>=u&&i!==t.x&&b0(r<l?i:a,r,u,l,r<l?a:i,r,t.x,t.y)){let f=Math.abs(r-t.y)/(i-t.x);Cl(t,n)&&(f<d||f===d&&(t.x>s.x||t.x===s.x&&fy(s,t)))&&(s=t,d=f)}t=t.next}while(t!==o);return s}function fy(n,e){return mi(n.prev,n,e.prev)<0&&mi(e.next,n,n.next)<0}function hy(n,e,t,i){let r=n;do r.z===0&&(r.z=Yf(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,py(r)}function py(n){let e,t=1;do{let i=n,r;n=null;let a=null;for(e=0;i;){e++;let s=i,o=0;for(let l=0;l<t&&(o++,s=s.nextZ,!!s);l++);let u=t;for(;o>0||u>0&&s;)o!==0&&(u===0||!s||i.z<=s.z)?(r=i,i=i.nextZ,o--):(r=s,s=s.nextZ,u--),a?a.nextZ=r:n=r,r.prevZ=a,a=r;i=s}a.nextZ=null,t*=2}while(e>1);return n}function Yf(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function my(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function b0(n,e,t,i,r,a,s,o){return(r-s)*(e-o)>=(n-s)*(a-o)&&(n-s)*(i-o)>=(t-s)*(e-o)&&(t-s)*(a-o)>=(r-s)*(i-o)}function ll(n,e,t,i,r,a,s,o){return!(n===s&&e===o)&&b0(n,e,t,i,r,a,s,o)}function vy(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!gy(n,e)&&(Cl(n,e)&&Cl(e,n)&&yy(n,e)&&(mi(n.prev,n,e.prev)||mi(n,e.prev,e))||bo(n,e)&&mi(n.prev,n,n.next)>0&&mi(e.prev,e,e.next)>0)}function mi(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function bo(n,e){return n.x===e.x&&n.y===e.y}function w0(n,e,t,i){let r=Wc(mi(n,e,t)),a=Wc(mi(n,e,i)),s=Wc(mi(t,i,n)),o=Wc(mi(t,i,e));return!!(r!==a&&s!==o||r===0&&Hc(n,t,e)||a===0&&Hc(n,i,e)||s===0&&Hc(t,n,i)||o===0&&Hc(t,e,i))}function Hc(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Wc(n){return n>0?1:n<0?-1:0}function gy(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&w0(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Cl(n,e){return mi(n.prev,n,n.next)<0?mi(n,e,n.next)>=0&&mi(n,n.prev,e)>=0:mi(n,e,n.prev)<0||mi(n,n.next,e)<0}function yy(n,e){let t=n,i=!1,r=(n.x+e.x)/2,a=(n.y+e.y)/2;do t.y>a!=t.next.y>a&&t.next.y!==t.y&&r<(t.next.x-t.x)*(a-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function T0(n,e){let t=qf(n.i,n.x,n.y),i=qf(e.i,e.x,e.y),r=n.next,a=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,a.next=i,i.prev=a,i}function Am(n,e,t,i){let r=qf(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Rl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function qf(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function xy(n,e,t,i){let r=0;for(let a=e,s=t-i;a<t;a+=i)r+=(n[s]-n[a])*(n[a+1]+n[s+1]),s=a;return r}var Zf=class{static triangulate(e,t,i=2){return iy(e,t,i)}},fo=class n{static area(e){let t=e.length,i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],a=[];Im(e),Cm(i,e);let s=e.length;t.forEach(Im);for(let u=0;u<t.length;u++)r.push(s),s+=t[u].length,Cm(i,t[u]);let o=Zf.triangulate(i,r);for(let u=0;u<o.length;u+=3)a.push(o.slice(u,u+3));return a}};function Im(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Cm(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}var Pl=class n extends Wi{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let a=e/2,s=t/2,o=Math.floor(i),u=Math.floor(r),l=o+1,d=u+1,f=e/o,h=t/u,v=[],y=[],T=[],g=[];for(let m=0;m<d;m++){let L=m*h-s;for(let F=0;F<l;F++){let _=F*f-a;y.push(_,-L,0),T.push(0,0,1),g.push(F/o),g.push(1-m/u)}}for(let m=0;m<u;m++)for(let L=0;L<o;L++){let F=L+l*m,_=L+l*(m+1),p=L+1+l*(m+1),S=L+1+l*m;v.push(F,_,S),v.push(_,p,S)}this.setIndex(v),this.setAttribute("position",new Xn(y,3)),this.setAttribute("normal",new Xn(T,3)),this.setAttribute("uv",new Xn(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},wo=class n extends Wi{constructor(e=.5,t=1,i=32,r=1,a=0,s=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:a,thetaLength:s},i=Math.max(3,i),r=Math.max(1,r);let o=[],u=[],l=[],d=[],f=e,h=(t-e)/r,v=new ge,y=new kt;for(let T=0;T<=r;T++){for(let g=0;g<=i;g++){let m=a+g/i*s;v.x=f*Math.cos(m),v.y=f*Math.sin(m),u.push(v.x,v.y,v.z),l.push(0,0,1),y.x=(v.x/t+1)/2,y.y=(v.y/t+1)/2,d.push(y.x,y.y)}f+=h}for(let T=0;T<r;T++){let g=T*(i+1);for(let m=0;m<i;m++){let L=m+g,F=L,_=L+i+1,p=L+i+2,S=L+1;o.push(F,_,S),o.push(_,p,S)}}this.setIndex(o),this.setAttribute("position",new Xn(u,3)),this.setAttribute("normal",new Xn(l,3)),this.setAttribute("uv",new Xn(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},Ll=class n extends Wi{constructor(e=new So([new kt(0,.5),new kt(-.5,-.5),new kt(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],a=[],s=[],o=0,u=0;if(Array.isArray(e)===!1)l(e);else for(let d=0;d<e.length;d++)l(e[d]),this.addGroup(o,u,d),o+=u,u=0;this.setIndex(i),this.setAttribute("position",new Xn(r,3)),this.setAttribute("normal",new Xn(a,3)),this.setAttribute("uv",new Xn(s,2));function l(d){let f=r.length/3,h=d.extractPoints(t),v=h.shape,y=h.holes;fo.isClockWise(v)===!1&&(v=v.reverse());for(let g=0,m=y.length;g<m;g++){let L=y[g];fo.isClockWise(L)===!0&&(y[g]=L.reverse())}let T=fo.triangulateShape(v,y);for(let g=0,m=y.length;g<m;g++){let L=y[g];v=v.concat(L)}for(let g=0,m=v.length;g<m;g++){let L=v[g];r.push(L.x,L.y,0),a.push(0,0,1),s.push(L.x,L.y)}for(let g=0,m=T.length;g<m;g++){let L=T[g],F=L[0]+f,_=L[1]+f,p=L[2]+f;i.push(F,_,p),u+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return _y(t,e)}static fromJSON(e,t){let i=[];for(let r=0,a=e.shapes.length;r<a;r++){let s=t[e.shapes[r]];i.push(s)}return new n(i,e.curveSegments)}};function _y(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}var ds=class n extends Wi{constructor(e=1,t=32,i=16,r=0,a=Math.PI*2,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:s,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let u=Math.min(s+o,Math.PI),l=0,d=[],f=new ge,h=new ge,v=[],y=[],T=[],g=[];for(let m=0;m<=i;m++){let L=[],F=m/i,_=s+F*o,p=e*Math.cos(_),S=Math.sqrt(e*e-p*p),B=0;m===0&&s===0?B=.5/t:m===i&&u===Math.PI&&(B=-.5/t);for(let b=0;b<=t;b++){let I=b/t,z=r+I*a;f.x=-S*Math.cos(z),f.y=p,f.z=S*Math.sin(z),y.push(f.x,f.y,f.z),h.copy(f).normalize(),T.push(h.x,h.y,h.z),g.push(I+B,1-F),L.push(l++)}d.push(L)}for(let m=0;m<i;m++)for(let L=0;L<t;L++){let F=d[m][L+1],_=d[m][L],p=d[m+1][L],S=d[m+1][L+1];(m!==0||s>0)&&v.push(F,_,S),(m!==i-1||u<Math.PI)&&v.push(_,p,S)}this.setIndex(v),this.setAttribute("position",new Xn(y,3)),this.setAttribute("normal",new Xn(T,3)),this.setAttribute("uv",new Xn(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};function Bs(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];if(Rm(r))r.isRenderTargetTexture?(rn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone();else if(Array.isArray(r))if(Rm(r[0])){let a=[];for(let s=0,o=r.length;s<o;s++)a[s]=r[s].clone();e[t][i]=a}else e[t][i]=r.slice();else e[t][i]=r}}return e}function ir(n){let e={};for(let t=0;t<n.length;t++){let i=Bs(n[t]);for(let r in i)e[r]=i[r]}return e}function Rm(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}function My(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Sh(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ln.workingColorSpace}var E0={clone:Bs,merge:ir},Sy=`void main() {
1
+ var ToraNative=(()=>{var ah=Object.defineProperty;var Ny=Object.getOwnPropertyDescriptor;var Uy=Object.getOwnPropertyNames;var Fy=Object.prototype.hasOwnProperty;var Oy=(n,e)=>{for(var t in e)ah(n,t,{get:e[t],enumerable:!0})},By=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Uy(e))!Fy.call(n,r)&&r!==t&&ah(n,r,{get:()=>e[r],enumerable:!(i=Ny(e,r))||i.enumerable});return n};var ky=n=>By(ah({},"__esModule",{value:!0}),n);var A1={};Oy(A1,{computeSafeArea:()=>am,createNetworkBridge:()=>Hg,layoutStandardText:()=>Wg,mountNative:()=>E1});var Um=function(n,e){if(!n)throw Error(e)},Na=function(){return[1,0,0,1,0,0]};function sh(n){return Um(Array.isArray(n)&&n.length===6&&n.every(Number.isFinite),"E_SCENE_MATRIX"),n}function Uo(n,e){return sh(n),sh(e),[n[0]*e[0]+n[2]*e[1],n[1]*e[0]+n[3]*e[1],n[0]*e[2]+n[2]*e[3],n[1]*e[2]+n[3]*e[3],n[0]*e[4]+n[2]*e[5]+n[4],n[1]*e[4]+n[3]*e[5]+n[5]]}function Or(n){sh(n);var e=n[0]*n[3]-n[1]*n[2];return Um(Math.abs(e)>1e-12,"E_SCENE_SINGULAR_TRANSFORM"),[n[3]/e,-n[1]/e,-n[2]/e,n[0]/e,(n[2]*n[5]-n[3]*n[4])/e,(n[1]*n[4]-n[0]*n[5])/e]}var lh=function(){return lh=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},lh.apply(this,arguments)},Ja=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},ao=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},oh=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Fm(n){var e=n.rows,t=n.columns,i=n.seed,r=n.slots,a=n.paint,s=n.onEvent,o=r.map(function($){return $.group}),u=ao([],Ja(new Set(o)),!1),l=ao([],Ja(o),!1),d=i,f="idle",h=0,m,x,_=[],g=[],v=0,F=0,P=0,S,N,p=function($,Te){return $*t+Te},L=function($){return Math.floor($/t)},E=function($){return $%t},D=function(){return d=Math.imul(d,1664525)+1013904223>>>0,d/4294967296};function X($){for(var Te=new Set,Le=0;Le<e;Le++)for(var se=0;se<t;se++){var re=p(Le,se),Ie=$[re];if(se+2<t&&Ie===$[re+1]&&Ie===$[re+2])for(var ke=0;ke<3;ke++)Te.add(re+ke);if(Le+2<e&&Ie===$[re+t]&&Ie===$[re+t*2])for(var ke=0;ke<3;ke++)Te.add(re+t*ke)}return ao([],Ja(Te),!1)}function Y($,Te){var Le;if(l[$]===l[Te])return!1;var se=ao([],Ja(l),!1);return Le=Ja([se[Te],se[$]],2),se[$]=Le[0],se[Te]=Le[1],X(se).some(function(re){return re===$||re===Te})}function W(){for(var $=[],Te=0;Te<l.length;Te++)E(Te)+1<t&&Y(Te,Te+1)&&$.push({from:r[Te].id,to:r[Te+1].id}),L(Te)+1<e&&Y(Te,Te+t)&&$.push({from:r[Te].id,to:r[Te+t].id});return $}function C(){for(var $=0;$<64;$++){l=[];for(var Te=function(se){var re=u.filter(function(Ie){return!(E(se)>=2&&l[se-1]===Ie&&l[se-2]===Ie)&&!(L(se)>=2&&l[se-t]===Ie&&l[se-t*2]===Ie)});l.push(re[Math.floor(D()*re.length)])},Le=0;Le<r.length;Le++)Te(Le);if(W().length)return}l=r.map(function(se,re){return u[(L(re)*2+E(re))%3]}),l[0]=u[0],l[1]=u[1],l[2]=u[0],l[t+1]=u[0]}function M(){for(var $=0;$<r.length;$++)a($,l[$],{})}function J(){d=i,l=ao([],Ja(o),!1),f="idle",h=0,m=void 0,x=void 0,_=[],g=[],v=0,F=0,P=0,S=void 0,N=void 0,(X(l).length||!W().length)&&C(),M()}function q($,Te){if(f!=="idle")return!1;var Le=r.findIndex(function(re){return re.id===$}),se=r.findIndex(function(re){return re.id===Te});return Le<0||se<0||Math.abs(L(Le)-L(se))+Math.abs(E(Le)-E(se))!==1?!1:(m=void 0,S=void 0,M(),x=[Le,se],f="swap",h=0,!0)}function ce($){if(f==="idle"){if(m===$){m=void 0;return}if(!(m&&q(m,$)))return m=$,m}}function k(){_=X(l),P+=_.length,N={group:l[_[0]],from:r[_[0]].id,count:_.length},s("matchClear"),f="clear",h=0}function G(){var $=new Set(_),Te=ao([],Ja(l),!1);g=[];for(var Le=0;Le<t;Le++){for(var se=[],re=e-1;re>=0;re--)$.has(p(re,Le))||se.push(p(re,Le));for(var Ie=0,re=e-1;re>=0;re--){var ke=p(re,Le),xe=se[e-1-re];xe!==void 0?(Te[ke]=l[xe],g.push({cell:ke,from:xe,offsetRows:0})):(Te[ke]=u[Math.floor(D()*u.length)],g.push({cell:ke,from:ke,offsetRows:-(re+1+Ie++)}))}}l=Te,f="fall",h=0}function te(){if(X(l).length&&v<3){v++,k();return}(X(l).length||!W().length)&&C(),M(),f="idle",h=0,x=void 0,_=[],g=[],F++,s("validMatch")}function le($){var Te,Le,se,re,Ie,ke,xe;if(f==="idle"){if(S){S.elapsed+=$;var Ye=1+.065*Math.sin(Math.min(1,S.elapsed/.8)*Math.PI*4),mt=function(Je){a(r.findIndex(function(je){return je.id===Je}),l[r.findIndex(function(je){return je.id===Je})],{scale:Ye})};try{for(var He=oh(S.ids),qe=He.next();!qe.done;qe=He.next()){var pt=qe.value;mt(pt)}}catch(Je){Te={error:Je}}finally{try{qe&&!qe.done&&(Le=He.return)&&Le.call(He)}finally{if(Te)throw Te.error}}S.elapsed>=.8&&(S=void 0,M())}return}if(h+=$,f==="swap"||f==="reverse"){var at=Math.min(1,h/.14),ot=at*at*(3-2*at),Vt=Ja(x,2),cn=Vt[0],Ze=Vt[1];if(a(cn,l[cn],{from:Ze,progress:f==="swap"?ot:1-ot}),a(Ze,l[Ze],{from:cn,progress:f==="swap"?ot:1-ot}),at<1)return;if(f==="reverse"){M(),f="idle",x=void 0,s("invalidMatch");return}if(!Y(cn,Ze)){f="reverse",h=0;return}se=Ja([l[Ze],l[cn]],2),l[cn]=se[0],l[Ze]=se[1],M(),k();return}if(f==="clear"){var pn=Math.min(1,h/.18),Ye=pn<.22?1+pn*.45:Math.max(.05,1.1*(1-pn)/.78);try{for(var ne=oh(_),Tn=ne.next();!Tn.done;Tn=ne.next()){var gn=Tn.value;a(gn,l[gn],{scale:Ye,opacity:1-pn})}}catch(je){re={error:je}}finally{try{Tn&&!Tn.done&&(Ie=ne.return)&&Ie.call(ne)}finally{if(re)throw re.error}}pn===1&&G();return}var Q=Math.min(1,h/.25),I=1-Math.pow(1-Q,3);try{for(var ie=oh(g),be=ie.next();!be.done;be=ie.next()){var De=be.value;a(De.cell,l[De.cell],{from:De.from,offsetRows:De.offsetRows,progress:1-I})}}catch(Je){ke={error:Je}}finally{try{be&&!be.done&&(xe=ie.return)&&xe.call(ie)}finally{if(ke)throw ke.error}}Q===1&&te()}function ge(){if(f==="idle"){m=void 0;var $=W()[0];$&&(S={ids:[$.from,$.to],elapsed:0})}}function oe(){var $;return{phase:f,busy:f!=="idle",selected:m??null,moves:F,cleared:P,groups:ao([],Ja(l),!1),legalMoves:f==="idle"?W():[],hint:($=S?.ids)!==null&&$!==void 0?$:[],lastMatch:N?lh({},N):null}}return{reset:J,select:ce,swap:q,tick:le,showHint:ge,snapshot:oe,cancelSelection:function(){m=void 0,S&&(S=void 0,M())}}}var yu=function(){return yu=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},yu.apply(this,arguments)},Om=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},zy=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Bm=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function km(){var n=new Map,e=new Map,t=function(r){var a,s,o=e.get(r);o!==void 0&&((a=n.get(o))===null||a===void 0||a.delete(r),((s=n.get(o))===null||s===void 0?void 0:s.size)===0&&n.delete(o)),e.delete(r)},i=function(r,a){t(r),a!=null&&(n.has(a)||n.set(a,new Set),n.get(a).add(r),e.set(r,a))};return{occupants:n,itemZone:e,release:t,place:i,clear:function(){n.clear(),e.clear()},items:function(r){var a;return zy([],Om((a=n.get(r))!==null&&a!==void 0?a:[]),!1).sort()},zoneOf:function(r){return e.get(r)},snapshot:function(){return{itemZone:Object.fromEntries(e)}}}}function xu(n){var e,t,i=n.itemId,r=n.tag,a=r===void 0?"":r,s=n.zones,o=n.occupancy,u=s.filter(function(x){var _,g,v;return x.id!==i&&(((g=(_=x.acceptTags)===null||_===void 0?void 0:_.length)!==null&&g!==void 0?g:0)===0||((v=x.acceptTags)===null||v===void 0?void 0:v.includes(a)))});u.sort(function(x,_){return Number(_.itemTarget)-Number(x.itemTarget)||_.paintOrder-x.paintOrder||x.distance-_.distance||x.id.localeCompare(_.id)});try{for(var l=Bm(u),d=l.next();!d.done;d=l.next()){var f=d.value,h=o.items(f.id).filter(function(x){return x!==i}),m=f.capacity>0&&h.length>=f.capacity;return f.snapMode==="reject"?{kind:"reject",zone:f,occupantId:h[0]}:m?f.onOccupied==="emit"?{kind:"emit",zone:f,occupantId:h[0]}:f.onOccupied==="swap"&&h.length?{kind:"swap",zone:f,occupantId:h[0]}:{kind:"reject",zone:f,occupantId:h[0]}:{kind:"accept",zone:f}}}catch(x){e={error:x}}finally{try{d&&!d.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}return null}function zm(n,e,t,i,r,a){if(t===void 0&&(t=28),i===void 0&&(i=-1/0),r===void 0&&(r=0),a===void 0&&(a=80),r-i<a)return null;var s=e.x-n.x,o=e.y-n.y;return Math.max(Math.abs(s),Math.abs(o))<t?null:Math.abs(s)>Math.abs(o)?s<0?"left":"right":o<0?"up":"down"}function Vm(n,e){var t=e,i=1;return{tick:function(r){return n.pingPong?(t+=i*n.ratePerSecond*r,t>=n.max?(t=n.max,i=-1):t<=n.min&&(t=n.min,i=1)):t=Math.max(n.min,Math.min(n.max,t+n.ratePerSecond*r)),t}}}function Gm(){var n=new Map;return{to:function(e,t,i,r,a){r===void 0&&(r=.18),n.set(e,{from:yu({},t),to:yu({},i),seconds:Math.max(.02,r),elapsed:0,onDone:a})},cancel:function(e){n.delete(e)},clear:function(){n.clear()},tick:function(e,t){var i,r,a;try{for(var s=Bm(n),o=s.next();!o.done;o=s.next()){var u=Om(o.value,2),l=u[0],d=u[1];d.elapsed+=e;var f=Math.min(1,d.elapsed/d.seconds),h=1-Math.pow(1-f,3);t(l,{x:d.from.x+(d.to.x-d.from.x)*h,y:d.from.y+(d.to.y-d.from.y)*h}),f===1&&(n.delete(l),(a=d.onDone)===null||a===void 0||a.call(d))}}catch(m){i={error:m}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}}}}function ch(n,e,t,i){t===void 0&&(t=56),i===void 0&&(i=.12);var r=Math.max(1,t),a=e.x-n.x,s=e.y-n.y,o=Math.hypot(a,s),u=Math.min(o,r),l=u/r,d=o>1e-6?a/o:0,f=o>1e-6?s/o:0,h=n.x+d*u,m=n.y+f*u;if(l<=i)return{nx:0,ny:0,magnitude:0,angle:0,knobX:h,knobY:m};var x=(l-i)/Math.max(1e-6,1-i);return{nx:d*x,ny:f*x,magnitude:x,angle:Math.atan2(f,d)*180/Math.PI,knobX:h,knobY:m}}var uh=function(){return uh=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},uh.apply(this,arguments)},Hm=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function _u(n){var e,t,i=2166136261;try{for(var r=Hm(String(n)),a=r.next();!a.done;a=r.next()){var s=a.value;i^=s.codePointAt(0),i=Math.imul(i,16777619)}}catch(o){e={error:o}}finally{try{a&&!a.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return i>>>0||1}function Mu(n){var e=n>>>0||1,t=e;return{next:function(){return t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296},between:function(i,r,a){if(a===void 0&&(a=!1),a){var s=Math.ceil(i),o=Math.floor(r);return o<s?s:Math.min(o,s+Math.floor((o-s+1)*this.next()))}return i+(r-i)*this.next()},reset:function(){t=e}}}function Wm(n,e,t,i,r){var a,s;i===void 0&&(i=0);var o=null,u=1/0;try{for(var l=Hm(e),d=l.next();!d.done;d=l.next()){var f=d.value;if(!(f.id===r||f.team!==t)){var h=Math.hypot(f.x-n.x,f.y-n.y);i>0&&h>i||(h<u||h===u&&f.id<o?.id)&&(o=f,u=h)}}}catch(m){a={error:m}}finally{try{d&&!d.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}return o}function Xm(n,e,t){var i=((e-n+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return n+Math.max(-t,Math.min(t,i))}function Ym(n){var e=Mu(n),t=new Map,i=new Map;return{rng:e,states:t,headings:i,reset:function(){e.reset(),t.clear(),i.clear()},initialize:function(r,a){var s;return t.has(r)||t.set(r,{hp:a.hp,maxHp:a.maxHp,value:a.value,tag:(s=a.tag)!==null&&s!==void 0?s:"",team:a.team}),t.get(r)},remove:function(r){t.delete(r),i.delete(r)},snapshot:function(r){var a=t.get(r);return a?uh({},a):void 0}}}function qm(n,e){var t,i,r,a,s=e===void 0?{}:e,o=s.width,u=s.height,l=s.onProgress,d=l===void 0?function(){}:l,f=s.onComplete,h=f===void 0?function(){}:f,m=s.canvasFactory,x=s.source,_=n,g=_.gridSize,v=new Uint8Array(g*g),F=0,P=!1,S=-1,N=!1,p=Math.max(1,o),L=Math.max(1,u),E=Math.min(1,512/Math.max(p,L)),D=(t=m?.())!==null&&t!==void 0?t:!((i=globalThis.document)===null||i===void 0)&&i.createElement?globalThis.document.createElement("canvas"):void 0;D&&(D.width=Math.max(1,Math.round(p*E)),D.height=Math.max(1,Math.round(L*E)));var X=(r=D?.getContext)===null||r===void 0?void 0:r.call(D,"2d"),Y=(a=_.maskColor)!==null&&a!==void 0?a:"#dceeff",W=function(){return!!(x&&x.complete&&x.naturalWidth>0)},C=function(){X&&(X.globalCompositeOperation="source-over",X.clearRect(0,0,D.width,D.height),_.mode==="erase"&&(W()?(X.drawImage(x,0,0,D.width,D.height),N=!0):(X.fillStyle=Y,X.fillRect(0,0,D.width,D.height),N=!1)))};C();var M=function(){if(!P){var q=Math.round(F/v.length*100),ce=Math.min(100,q);ce!==S&&(S=ce,d(ce)),ce>=_.targetPercent&&(P=!0,h(ce))}},J=function(q,ce){for(var k=Math.max(0,Math.min(g-1,Math.floor(q/p*g))),G=Math.max(0,Math.min(g-1,Math.floor(ce/L*g))),te=Math.max(0,Math.ceil(_.brushRadiusPx/p*g)),le=Math.max(0,Math.ceil(_.brushRadiusPx/L*g)),ge=Math.max(0,G-le);ge<=Math.min(g-1,G+le);ge++)for(var oe=Math.max(0,k-te);oe<=Math.min(g-1,k+te);oe++)if(!(Math.hypot((oe+.5)/g*p-q,(ge+.5)/g*L-ce)>_.brushRadiusPx)){var $=ge*g+oe;v[$]||(v[$]=1,F++)}X&&(X.save(),X.scale(E,E),X.globalCompositeOperation=_.mode==="erase"?"destination-out":"source-over",X.fillStyle=Y,X.beginPath(),X.arc(q,ce,_.brushRadiusPx,0,Math.PI*2),X.fill(),_.mode==="reveal"&&x&&(X.globalCompositeOperation="source-in",X.drawImage(x,0,0,p,L)),X.restore()),M()};return{canvas:D,stampSegment:function(q,ce){for(var k=Math.hypot(ce.x-q.x,ce.y-q.y),G=Math.max(1,Math.ceil(k/Math.max(1,_.brushRadiusPx*.45))),te=0;te<=G;te++)J(q.x+(ce.x-q.x)*te/G,q.y+(ce.y-q.y)*te/G)},reset:function(){v.fill(0),F=0,P=!1,S=-1,C(),M()},get progress(){return Math.round(F/v.length*100)},render:function(q){_.mode==="erase"&&F===0&&!N&&W()&&C(),D?q.drawImage(D,0,0,D.width,D.height,0,0,o,u):_.mode==="erase"&&this.progress<100&&(q.save(),q.globalAlpha=1-this.progress/100,q.fillStyle=Y,q.fillRect(0,0,o,u),q.restore())}}}var so=function(){return so=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},so.apply(this,arguments)},Vy=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function dh(n,e,t,i){var r=function(d,f,h){return(f.x-d.x)*(h.y-d.y)-(f.y-d.y)*(h.x-d.x)},a=r(n,e,t),s=r(n,e,i),o=r(t,i,n),u=r(t,i,e),l=1e-8;return Math.abs(a)<l&&Math.abs(s)<l&&Math.abs(o)<l&&Math.abs(u)<l?Math.max(Math.min(n.x,e.x),Math.min(t.x,i.x))<=Math.min(Math.max(n.x,e.x),Math.max(t.x,i.x))+l&&Math.max(Math.min(n.y,e.y),Math.min(t.y,i.y))<=Math.min(Math.max(n.y,e.y),Math.max(t.y,i.y))+l:a>0!=s>0&&o>0!=u>0}function Zm(n,e){for(var t=!1,i=0,r=e.length-1;i<e.length;r=i++){var a=e[i],s=e[r];a.y>n.y!=s.y>n.y&&n.x<(s.x-a.x)*(n.y-a.y)/(s.y-a.y)+a.x&&(t=!t)}return t}function Jm(n,e,t){if(t.length>=3&&(Zm(n,t)||Zm(e,t)))return!0;for(var i=0;i<t.length;i++)if(dh(n,e,t[i],t[(i+1)%t.length]))return!0;return!1}function $m(n){var e=n,t=[],i=null,r=0,a=function(s){return so(so({},s),{points:s.points.map(function(o){return so({},o)})})};return{begin:function(s){var o={id:++r,points:[so({},s)],age:0,hitIds:new Set};return i=o,t.push(o),t.length>e.maxStrokes&&t.shift(),o},add:function(s){if(!i||i.points.length>=e.maxPoints)return!1;var o=i.points[i.points.length-1];return Math.hypot(s.x-o.x,s.y-o.y)<e.minSegmentPx?!1:(i.points.push(so({},s)),!0)},end:function(){var s=i;return i=null,s?a(s):void 0},cancel:function(){i&&(t=t.filter(function(s){return s!==i})),i=null},clear:function(){i=null,t=[]},tick:function(s){var o,u;try{for(var l=Vy(t),d=l.next();!d.done;d=l.next()){var f=d.value;f.age+=s}}catch(h){o={error:h}}finally{try{d&&!d.done&&(u=l.return)&&u.call(l)}finally{if(o)throw o.error}}t=t.filter(function(h){return h===i||h.age<.18||e.mode!=="slice-blade"})},get active(){return i},get strokes(){return t}}}function Km(n,e){for(var t=[],i=1;i<n.points.length;i++){var r=n.points[i-1],a=n.points[i],s=Math.hypot(a.x-r.x,a.y-r.y);s<.001||t.push({id:"stroke-".concat(n.id,"-").concat(i),strokeId:n.id,mode:"static",shape:"box",x:(r.x+a.x)/2,y:(r.y+a.y)/2,width:s,height:Math.max(2,e),angle:Math.atan2(a.y-r.y,a.x-r.x),restitution:.8})}return t}var Zl=function(){return Zl=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Zl.apply(this,arguments)},iv=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Ds=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Gy=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},ps=function(n,e){return Math.hypot(n,e)},Qm=function(n,e,t){return Math.max(e,Math.min(t,n))},oo=function(n){return Math.max(1,Math.min(n.width,n.height)/2)};function jm(n){var e,t,i=Math.cos((e=n.angle)!==null&&e!==void 0?e:0),r=Math.sin((t=n.angle)!==null&&t!==void 0?t:0),a=n.width/2,s=n.height/2;return[[-a,-s],[a,-s],[a,s],[-a,s]].map(function(o){var u=iv(o,2),l=u[0],d=u[1];return{x:n.x+l*i-d*r,y:n.y+l*r+d*i}})}function Hy(n,e){var t,i,r,a,s,o,u,l,d,f,h=jm(n),m=jm(e),x=[(u=n.angle)!==null&&u!==void 0?u:0,((l=n.angle)!==null&&l!==void 0?l:0)+Math.PI/2,(d=e.angle)!==null&&d!==void 0?d:0,((f=e.angle)!==null&&f!==void 0?f:0)+Math.PI/2],_=1/0,g=1,v=0;try{for(var F=Ds(x),P=F.next();!P.done;P=F.next()){var S=P.value,N=Math.cos(S),p=Math.sin(S),L=1/0,E=-1/0,D=1/0,X=-1/0;try{for(var Y=(r=void 0,Ds(h)),W=Y.next();!W.done;W=Y.next()){var C=W.value,M=C.x*N+C.y*p;M<L&&(L=M),M>E&&(E=M)}}catch(k){r={error:k}}finally{try{W&&!W.done&&(a=Y.return)&&a.call(Y)}finally{if(r)throw r.error}}try{for(var J=(s=void 0,Ds(m)),q=J.next();!q.done;q=J.next()){var C=q.value,M=C.x*N+C.y*p;M<D&&(D=M),M>X&&(X=M)}}catch(k){s={error:k}}finally{try{q&&!q.done&&(o=J.return)&&o.call(J)}finally{if(s)throw s.error}}var ce=Math.min(E,X)-Math.max(L,D);if(ce<=0)return null;ce<_&&(_=ce,g=N,v=p)}}catch(k){t={error:k}}finally{try{P&&!P.done&&(i=F.return)&&i.call(F)}finally{if(t)throw t.error}}return(n.x-e.x)*g+(n.y-e.y)*v<0&&(g=-g,v=-v),{nx:g,ny:v,penetration:_}}function ev(n,e){var t,i,r,a=oo(n),s=-((t=e.angle)!==null&&t!==void 0?t:0),o=Math.cos(s),u=Math.sin(s),l=n.x-e.x,d=n.y-e.y,f=l*o-d*u,h=l*u+d*o,m=e.width/2,x=e.height/2,_=Qm(f,-m,m),g=Qm(h,-x,x),v=f-_,F=h-g,P=ps(v,F),S;if(P>=a)return null;if(P<1e-4){var N=[{d:m-Math.abs(f),x:f>=0?1:-1,y:0},{d:x-Math.abs(h),x:0,y:h>=0?1:-1}].sort(function(E,D){return E.d-D.d});v=N[0].x,F=N[0].y,S=a+N[0].d}else v/=P,F/=P,S=a-P;var p=Math.cos((i=e.angle)!==null&&i!==void 0?i:0),L=Math.sin((r=e.angle)!==null&&r!==void 0?r:0);return{nx:v*p-F*L,ny:v*L+F*p,penetration:S}}function tv(n,e){var t;return!!(n.ignoreGroup&&n.ignoreGroup!=="none"&&(n.ignoreGroup==="all"||n.ignoreGroup===((t=e.collisionGroup)!==null&&t!==void 0?t:"all")))}function nv(n,e,t){var i,r,a,s,o,u;if(!(n.captured||e.captured||tv(n,e)||tv(e,n))){var l=n.x-e.x,d=n.y-e.y,f;if(n.shape==="circle"&&e.shape==="circle"){var h=ps(l,d),m=oo(n)+oo(e)-h;if(m<=0)return;f=m,h>1e-4?(l/=h,d/=h):(l=1,d=0)}else if(n.shape==="circle"&&e.shape==="box"){var x=ev(n,e);if(!x)return;l=x.nx,d=x.ny,f=x.penetration}else if(n.shape==="box"&&e.shape==="circle"){var x=ev(e,n);if(!x)return;l=-x.nx,d=-x.ny,f=x.penetration}else if(n.shape==="box"&&e.shape==="box"){var x=Hy(n,e);if(!x)return;l=x.nx,d=x.ny,f=x.penetration}else return;var _=n.mode==="dynamic"?1/((i=n.mass)!==null&&i!==void 0?i:1):0,g=e.mode==="dynamic"?1/((r=e.mass)!==null&&r!==void 0?r:1):0,v=_+g;if(v){n.x+=l*f*_/v,n.y+=d*f*_/v,e.mode==="dynamic"&&(e.x-=l*f*g/v,e.y-=d*f*g/v);var F=n.vx-((a=e.vx)!==null&&a!==void 0?a:0),P=n.vy-((s=e.vy)!==null&&s!==void 0?s:0),S=F*l+P*d;if(!(S>=0)){var N=Math.max((o=n.restitution)!==null&&o!==void 0?o:0,(u=e.restitution)!==null&&u!==void 0?u:0),p=-(1+N)*S/v;n.vx+=l*p*_,n.vy+=d*p*_,e.mode==="dynamic"&&(e.vx-=l*p*g,e.vy-=d*p*g),n.atRest=!1,n.restElapsed=0,e.mode==="dynamic"&&(e.atRest=!1,e.restElapsed=0),Math.abs(S)>4&&(t("bodyBounce",n,e,{speed:Math.abs(S)}),e.mode==="dynamic"&&t("bodyBounce",e,n,{speed:Math.abs(S)}))}}}}function Wy(n,e,t,i){var r,a;if(!(n.mode!=="dynamic"||n.captured))try{for(var s=Ds(e),o=s.next();!o.done;o=s.next()){var u=o.value,l=u.x-n.x,d=u.y-n.y,f=ps(l,d);if(!(f>=u.radius*2.5)){if(f>u.radius&&f>.001&&u.pullStrength>0){var h=u.pullStrength*(1-f/(u.radius*2.5));n.vx+=l/f*h*t,n.vy+=d/f*h*t}if(f<u.radius&&ps(n.vx,n.vy)<=u.maxCaptureSpeed){n.captured=!0,n.atRest=!0,n.vx=u.stopBody?0:n.vx,n.vy=u.stopBody?0:n.vy,u.stopBody&&(n.x=u.x,n.y=u.y),i("zoneCapture",n,u,{});return}}}}catch(m){r={error:m}}finally{try{o&&!o.done&&(a=s.return)&&a.call(s)}finally{if(r)throw r.error}}}function Xy(n,e){var t,i,r,a,s,o,u=function(h){if(h.broken)return"continue";var m=e.find(function(L){return L.id===h.bodyId}),x=e.find(function(L){return L.id===h.anchorId});if(!m||m.mode!=="dynamic")return"continue";var _=(a=(r=x?.x)!==null&&r!==void 0?r:h.x)!==null&&a!==void 0?a:0,g=(o=(s=x?.y)!==null&&s!==void 0?s:h.y)!==null&&o!==void 0?o:0,v=m.x-_,F=m.y-g,P=ps(v,F);if(P<=h.lengthPx||P<1e-4)return"continue";var S=v/P,N=F/P;m.x=_+S*h.lengthPx,m.y=g+N*h.lengthPx;var p=m.vx*S+m.vy*N;p>0&&(m.vx-=S*p,m.vy-=N*p)};try{for(var l=Ds(n),d=l.next();!d.done;d=l.next()){var f=d.value;u(f)}}catch(h){t={error:h}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(t)throw t.error}}}function fh(n){for(var e,t,i,r,a,s,o,u,l,d,f,h=n.bodies,m=n.zones,x=m===void 0?[]:m,_=n.joints,g=_===void 0?[]:_,v=n.bounds,F=n.dt,P=n.onEvent,S=P===void 0?function(){}:P,N=h.filter(function(se){return se.mode==="dynamic"&&!se.captured}),p=N.reduce(function(se,re){return Math.max(se,ps(re.vx,re.vy))},0),L=N.reduce(function(se,re){return Math.min(se,oo(re))},24),E=Math.min(16,Math.max(1,Math.ceil(p*F/(L*.45)))),D=F/E,X=0;X<E;X++){try{for(var Y=(e=void 0,Ds(N)),W=Y.next();!W.done;W=Y.next()){var C=W.value;C.vy+=((o=C.gravity)!==null&&o!==void 0?o:0)*D;var M=ps(C.vx,C.vy);if(M>C.maxSpeed){var J=C.maxSpeed/M;C.vx*=J,C.vy*=J,M=C.maxSpeed}C.x+=C.vx*D,C.y+=C.vy*D;var q=Math.max(0,M-((u=C.friction)!==null&&u!==void 0?u:0)*D),ce=Math.exp(-((l=C.linearDamping)!==null&&l!==void 0?l:0)*D);if(M>1e-4){var k=q/M*ce;C.vx*=k,C.vy*=k}C.spinToRotation&&(C.angle=((d=C.angle)!==null&&d!==void 0?d:0)+ps(C.vx,C.vy)*D/oo(C)*(C.vx<0?-1:1))}}catch(se){e={error:se}}finally{try{W&&!W.done&&(t=Y.return)&&t.call(Y)}finally{if(e)throw e.error}}for(var G=0;G<N.length;G++){var C=N[G];try{for(var te=(i=void 0,Ds(h)),le=te.next();!le.done;le=te.next()){var ge=le.value;ge.id!==C.id&&ge.mode!=="dynamic"&&nv(C,ge,S)}}catch(re){i={error:re}}finally{try{le&&!le.done&&(r=te.return)&&r.call(te)}finally{if(i)throw i.error}}for(var ge=G+1;ge<N.length;ge++)nv(N[ge],C,S);var oe=C.shape==="box"?C.width/2:oo(C),$=C.shape==="box"?C.height/2:oo(C);C.wallBounce?(C.x-oe<v.left&&(C.x=v.left+oe,C.vx<0&&(S("bodyBounce",C,null,{speed:Math.abs(C.vx)}),C.vx=-C.vx*C.restitution)),C.x+oe>v.right&&(C.x=v.right-oe,C.vx>0&&(S("bodyBounce",C,null,{speed:Math.abs(C.vx)}),C.vx=-C.vx*C.restitution)),C.y-$<v.top&&(C.y=v.top+$,C.vy<0&&(S("bodyBounce",C,null,{speed:Math.abs(C.vy)}),C.vy=-C.vy*C.restitution)),C.y+$>v.bottom&&(C.y=v.bottom-$,C.vy>0&&(S("bodyBounce",C,null,{speed:Math.abs(C.vy)}),C.vy=-C.vy*C.restitution))):!C.exited&&(C.x+oe<v.left||C.x-oe>v.right||C.y+$<v.top||C.y-$>v.bottom)&&(C.exited=!0,S("boundaryExit",C,null,{})),Wy(C,x,D,S)}Xy(g,h)}try{for(var Te=Ds(N),Le=Te.next();!Le.done;Le=Te.next()){var C=Le.value,M=ps(C.vx,C.vy);M<C.restSpeed&&!C.captured?(C.restElapsed=((f=C.restElapsed)!==null&&f!==void 0?f:0)+F,C.restElapsed>=C.restDelaySeconds&&!C.atRest&&(C.atRest=!0,C.vx=0,C.vy=0,S("bodyRest",C,null,{}))):M>=C.restSpeed&&(C.restElapsed=0,C.atRest=!1)}}catch(se){a={error:se}}finally{try{Le&&!Le.done&&(s=Te.return)&&s.call(Te)}finally{if(a)throw a.error}}}function rv(n){for(var e=n.body,t=n.bodies,i=n.zones,r=i===void 0?[]:i,a=n.bounds,s=n.dots,o=s===void 0?8:s,u=n.bounces,l=u===void 0?1:u,d=function(P){return Zl({},P)},f=d(e),h=t.filter(function(P){return P.id!==e.id}).map(d),m=Gy([f],iv(h),!1),x=[],_=0,g=!1,v=function(P,S,N,p){P==="bodyBounce"&&p.sourceId===e.id&&_++,P==="zoneCapture"&&p.sourceId===e.id&&(g=!0)},F=0;F<90&&x.length<o&&!g&&_<=l;F++)fh({bodies:m,zones:r,bounds:a,dt:1/60,onEvent:function(P,S,N,p){return v(P,S,N,Zl(Zl({},p),{sourceId:S.id}))}}),F%Math.max(1,Math.floor(90/o))===0&&x.push({x:f.x,y:f.y});return x}var Fo=function(){return Fo=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Fo.apply(this,arguments)},Jl=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},sv=.008333333333333333;function Ns(n,e,t){var i,r,a,s=(i=n.boundsX)!==null&&i!==void 0?i:3,o=(r=n.boundsZ)!==null&&r!==void 0?r:7;if(Math.abs(e)>s||Math.abs(t)>o)return null;if(!n.ramp)return 0;var u=(a=n.rampHeight)!==null&&a!==void 0?a:1.1;return t>=1?0:t<=-1?u:(1-t)*(u*.5)}function av(n,e,t,i){var r,a,s,o=n.radius,u=Math.cos(e.angle),l=Math.sin(e.angle),d=n.x-e.x,f=n.z-e.z,h=u*d+l*f,m=-l*d+u*f,x=Math.max(-e.hx,Math.min(e.hx,h)),_=Math.max(-e.hz,Math.min(e.hz,m)),g=h-x,v=m-_,F=Math.hypot(g,v),P=Ns(n,n.x,n.z);if(!(F>=o||P!==null&&n.y>P+.55)){F<1e-8?e.hx-Math.abs(h)<e.hz-Math.abs(m)?(g=h<0?-1:1,v=0,F=0):(g=0,v=m<0?-1:1,F=0):(g/=F,v/=F);var S=u*g-l*v,N=l*g+u*v;n.x+=S*(o-F+1e-5),n.z+=N*(o-F+1e-5);var p=(r=e.vx)!==null&&r!==void 0?r:0,L=(a=e.vz)!==null&&a!==void 0?a:0,E=(n.vx-p)*S+(n.vz-L)*N;if(E<0){var D=1+((s=n.restitution)!==null&&s!==void 0?s:.72);n.vx-=D*E*S,n.vz-=D*E*N,Math.abs(E)>.3&&t>0&&i&&i("bodyBounce",n,e.sourceId?e:void 0)}}}function ov(n,e){n.vx=0,n.vy=0,n.vz=0,n.airborne=!1,n.atRest=!0,n.restElapsed=0,n.movingTime=0,e&&e("bodyRest",n)}function hh(n,e){n.x=n.lastSafe.x,n.y=n.lastSafe.y,n.z=n.lastSafe.z,ov(n,e)}function ph(n){var e,t,i,r,a,s,o,u,l,d,f,h,m,x,_,g,v,F,P=n.bodies,S=n.walls,N=n.zones,p=n.dt,L=n.onEvent;if(!(!Number.isFinite(p)||p<=0))for(var E=Math.max(1,Math.round(p/sv)),D=p/E,X=0;X<E;X++)try{for(var Y=(e=void 0,Jl(P)),W=Y.next();!W.done;W=Y.next()){var C=W.value;if(!(C.mode!=="dynamic"||C.captured)&&!C.atRest){var M=(l=C.boundsX)!==null&&l!==void 0?l:3,J=(d=C.boundsZ)!==null&&d!==void 0?d:7;if(C.y<-3||Math.abs(C.x)>M+2||Math.abs(C.z)>J+2){hh(C,L);continue}C.movingTime=((f=C.movingTime)!==null&&f!==void 0?f:0)+D;var q=C.radius,ce=Math.hypot(C.vx,C.vy,C.vz),k=Math.max(1,Math.min(16,Math.ceil(ce*D/(q*.45)))),G=D/k;(!C._perimeter||C._pbx!==M||C._pbz!==J)&&(C._pbx=M,C._pbz=J,C._perimeter=[{x:-(M+.1),z:0,hx:.1,hz:J+.1,angle:0,vx:0,vz:0},{x:M+.1,z:0,hx:.1,hz:J+.1,angle:0,vx:0,vz:0},{x:0,z:-(J+.1),hx:M+.1,hz:.1,angle:0,vx:0,vz:0},{x:0,z:J+.1,hx:M+.1,hz:.1,angle:0,vx:0,vz:0}]);for(var te=C._perimeter,le=!1,ge=0;ge<k;ge++){var oe=Ns(C,C.x,C.z),$=oe!==null&&C.y<=oe+q+.012&&C.vy<=.1,Te=oe;if($){C.y=oe+q,C.vy=0;var Le=Math.hypot(C.vx,C.vz),se=Math.max(0,Le-((h=C.friction)!==null&&h!==void 0?h:1.05)*G);if(Le>0&&(C.vx*=se/Le,C.vz*=se/Le),C.ramp&&C.z<1&&C.z>-1){var re=((m=C.rampHeight)!==null&&m!==void 0?m:1.1)*.5;C.vz+=9.81*re/(1+re*re)*G}}else C.vy-=9.81*G,C.airborne||(C.airborne=!0,L&&L("bodyJump",C));C.x+=C.vx*G,C.z+=C.vz*G,C.y+=C.vy*G;var Ie=Ns(C,C.x,C.z);if(Ie!==null){if($&&Te!==null){var re=((x=C.rampHeight)!==null&&x!==void 0?x:1.1)*.5;C.ramp&&C.z<=-1&&C.z-C.vz*G>-1.5&&C.vz<-.8?(C.vy=-C.vz*re,C.airborne=!0,L&&L("bodyJump",C)):C.y=Ie+q}C.y<Ie+q&&(C.y=Ie+q,C.vy=0,C.airborne=!1)}if(C.y<2){try{for(var ke=(i=void 0,Jl(S)),xe=ke.next();!xe.done;xe=ke.next()){var Ye=xe.value;av(C,Ye,G,L)}}catch(Ze){i={error:Ze}}finally{try{xe&&!xe.done&&(r=ke.return)&&r.call(ke)}finally{if(i)throw i.error}}try{for(var mt=(a=void 0,Jl(te)),He=mt.next();!He.done;He=mt.next()){var Ye=He.value;av(C,Ye,G,L)}}catch(Ze){a={error:Ze}}finally{try{He&&!He.done&&(s=mt.return)&&s.call(mt)}finally{if(a)throw a.error}}}C.spin=((_=C.spin)!==null&&_!==void 0?_:0)+Math.hypot(C.vx,C.vz)*G/q;var qe=Math.hypot(C.vx,C.vz);try{for(var pt=(o=void 0,Jl(N)),at=pt.next();!at.done;at=pt.next()){var ot=at.value,Vt=Math.hypot(C.x-ot.x,C.z-ot.z);if(Vt<ot.radius&&Math.abs(C.y-(ot.y+q))<ot.heightTolerance&&qe<ot.maxCaptureSpeed){C.captured=!0,C.captureElapsed=0,C.captureTarget={x:ot.x,y:ot.y,z:ot.z},C.vx=0,C.vy=0,C.vz=0,C.atRest=!0,L&&L("zoneCapture",C,ot),le=!0;break}}}catch(Ze){o={error:Ze}}finally{try{at&&!at.done&&(u=pt.return)&&u.call(pt)}finally{if(o)throw o.error}}if(le)break;if(C.y<-3||Math.abs(C.x)>M+2||Math.abs(C.z)>J+2){hh(C,L),le=!0;break}}if(!le){var cn=Math.hypot(C.vx,C.vy,C.vz);cn<((g=C.restSpeed)!==null&&g!==void 0?g:.07)?(C.restElapsed=((v=C.restElapsed)!==null&&v!==void 0?v:0)+D,C.restElapsed>((F=C.restDelaySeconds)!==null&&F!==void 0?F:.25)&&ov(C,L)):C.restElapsed=0,C.movingTime>18&&hh(C,L)}}}}catch(Ze){e={error:Ze}}finally{try{W&&!W.done&&(t=Y.return)&&t.call(Y)}finally{if(e)throw e.error}}}function lv(n){var e,t=n.body,i=n.walls,r=n.zones,a=n.vx,s=n.vz,o=n.dots,u=o===void 0?15:o,l=Math.hypot(a,s);if(!Number.isFinite(l)||l<.35)return[];for(var d=Math.min(1,((e=t.maxSpeed)!==null&&e!==void 0?e:9)/l),f=Fo(Fo({},t),{vx:a*d,vy:0,vz:s*d,atRest:!1,captured:!1,airborne:!1,restElapsed:0,movingTime:0,lastSafe:{x:t.x,y:t.y,z:t.z}}),h=i.map(function(F){return Fo(Fo({},F),{vx:0,vz:0})}),m=[f],x={bodies:m,walls:h,zones:r,dt:sv},_=[],g=Math.max(18,u*6),v=0;v<g&&(ph(x),v%6===0&&_.push({x:f.x,y:f.y,z:f.z}),!(f.atRest||f.captured));v++);return _}function mh(n,e,t,i,r,a){var s,o,u,l;i===void 0&&(i=[]),r===void 0&&(r=12),a===void 0&&(a=12);for(var d=n,f=e,h=Math.max(.05,t??.45),m=0;m<2;m++){try{for(var x=(s=void 0,Jl(i)),_=x.next();!_.done;_=x.next()){var g=_.value,v=Math.cos((u=g.angle)!==null&&u!==void 0?u:0),F=Math.sin((l=g.angle)!==null&&l!==void 0?l:0),P=d-g.x,S=f-g.z,N=v*P+F*S,p=-F*P+v*S,L=Math.max(-g.hx,Math.min(g.hx,N)),E=Math.max(-g.hz,Math.min(g.hz,p)),D=N-L,X=p-E,Y=Math.hypot(D,X);if(!(Y>=h)){Y<1e-8?g.hx-Math.abs(N)<g.hz-Math.abs(p)?(D=N<0?-1:1,X=0):(D=0,X=p<0?-1:1):(D/=Y,X/=Y);var W=v*D-F*X,C=F*D+v*X;d+=W*(h-Y+1e-4),f+=C*(h-Y+1e-4)}}}catch(q){s={error:q}}finally{try{_&&!_.done&&(o=x.return)&&o.call(x)}finally{if(s)throw s.error}}var M=Math.max(0,(r??12)-h),J=Math.max(0,(a??12)-h);d=Math.max(-M,Math.min(M,d)),f=Math.max(-J,Math.min(J,f))}return{x:d,z:f}}var Yv=0,np=1,qv=2;var Nc=1,Cd=2,gl=3,es=0,ea=1,Gr=2,ts=0,yl=1,ip=2,rp=3,ap=4,Zv=5;var go=100,Jv=101,$v=102,Kv=103,Qv=104,jv=200,e0=201,t0=202,n0=203,sp=204,op=205,i0=206,r0=207,a0=208,s0=209,o0=210,l0=211,c0=212,u0=213,d0=214,qu=0,Zu=1,Ju=2,jo=3,$u=4,Ku=5,Qu=6,ju=7,Rd=0,f0=1,h0=2,la=0,lp=1,cp=2,up=3,Uc=4,dp=5,fp=6,Fc=7,Wh="attached",p0="detached",hp=300,qs=301,yo=302,xl=303,Pd=304,Oc=306,Vs=1e3,Ta=1001,el=1002,ar=1003,Ld=1004;var xo=1005;var fr=1006,_l=1007;var ns=1008;var ca=1009,pp=1010,mp=1011,Ml=1012,Dd=1013,za=1014,va=1015,Va=1016,Nd=1017,Ud=1018,Sl=1020,vp=35902,gp=35899,yp=1021,xp=1022,ga=1023,Ka=1026,Zs=1027,Fd=1028,Od=1029,Js=1030,Bd=1031;var kd=1033,Bc=33776,kc=33777,zc=33778,Vc=33779,zd=35840,Vd=35841,Gd=35842,Hd=35843,Wd=36196,Xd=37492,Yd=37496,qd=37488,Zd=37489,Gc=37490,Jd=37491,$d=37808,Kd=37809,Qd=37810,jd=37811,ef=37812,tf=37813,nf=37814,rf=37815,af=37816,sf=37817,of=37818,lf=37819,cf=37820,uf=37821,df=36492,ff=36494,hf=36495,pf=36283,mf=36284,Hc=36285,vf=36286;var oc=2300,ed=2301,Xu=2302,Xh=2303,Yh=2400,qh=2401,Zh=2402;var m0=3200;var Wc=0,v0=1,ta="",Ir="srgb",lc="srgb-linear",cc="linear",Di="srgb";var Yu=7680;var g0=519,y0=512,x0=513,_0=514,gf=515,M0=516,S0=517,yf=518,b0=519,w0=35044;var _p="300 es",Ba=2e3,tl=2001;function Yy(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function qy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function uc(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function T0(){let n=uc("canvas");return n.style.display="block",n}var cv={},nl=null;function Mp(...n){let e="THREE."+n.shift();nl?nl("log",e,...n):console.log(e,...n)}function E0(n){let e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Rn(...n){n=E0(n);let e="THREE."+n.shift();if(nl)nl("warn",e,...n);else{let t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function On(...n){n=E0(n);let e="THREE."+n.shift();if(nl)nl("error",e,...n);else{let t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function ho(...n){let e=n.join(" ");e in cv||(cv[e]=!0,Rn(...n))}function A0(n,e,t){return new Promise(function(i,r){function a(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(a,t);break;default:i()}}setTimeout(a,t)})}var I0={[qu]:Zu,[Ju]:Qu,[$u]:ju,[jo]:Ku,[Zu]:qu,[Qu]:Ju,[ju]:$u,[Ku]:jo},Qa=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){let i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){let i=this._listeners;if(i===void 0)return;let r=i[e];if(r!==void 0){let a=r.indexOf(t);a!==-1&&r.splice(a,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let i=t[e.type];if(i!==void 0){e.target=this;let r=i.slice(0);for(let a=0,s=r.length;a<s;a++)r[a].call(this,e);e.target=null}}},Br=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];var vh=Math.PI/180,td=180/Math.PI;function _o(){let n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Br[n&255]+Br[n>>8&255]+Br[n>>16&255]+Br[n>>24&255]+"-"+Br[e&255]+Br[e>>8&255]+"-"+Br[e>>16&15|64]+Br[e>>24&255]+"-"+Br[t&63|128]+Br[t>>8&255]+"-"+Br[t>>16&255]+Br[t>>24&255]+Br[i&255]+Br[i>>8&255]+Br[i>>16&255]+Br[i>>24&255]).toLowerCase()}function pi(n,e,t){return Math.max(e,Math.min(t,n))}function Zy(n,e){return(n%e+e)%e}function gh(n,e,t){return(1-t)*n+t*e}function $l(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:case Uint8ClampedArray:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ra(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var Ap=class Ap{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=pi(this.x,e.x,t.x),this.y=pi(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=pi(this.x,e,t),this.y=pi(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(pi(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(pi(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Ap.prototype.isVector2=!0;var ln=Ap,aa=class{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,a,s,o){let u=i[r+0],l=i[r+1],d=i[r+2],f=i[r+3],h=a[s+0],m=a[s+1],x=a[s+2],_=a[s+3];if(f!==_||u!==h||l!==m||d!==x){let g=u*h+l*m+d*x+f*_;g<0&&(h=-h,m=-m,x=-x,_=-_,g=-g);let v=1-o;if(g<.9995){let F=Math.acos(g),P=Math.sin(F);v=Math.sin(v*F)/P,o=Math.sin(o*F)/P,u=u*v+h*o,l=l*v+m*o,d=d*v+x*o,f=f*v+_*o}else{u=u*v+h*o,l=l*v+m*o,d=d*v+x*o,f=f*v+_*o;let F=1/Math.sqrt(u*u+l*l+d*d+f*f);u*=F,l*=F,d*=F,f*=F}}e[t]=u,e[t+1]=l,e[t+2]=d,e[t+3]=f}static multiplyQuaternionsFlat(e,t,i,r,a,s){let o=i[r],u=i[r+1],l=i[r+2],d=i[r+3],f=a[s],h=a[s+1],m=a[s+2],x=a[s+3];return e[t]=o*x+d*f+u*m-l*h,e[t+1]=u*x+d*h+l*f-o*m,e[t+2]=l*x+d*m+o*h-u*f,e[t+3]=d*x-o*f-u*h-l*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let i=e._x,r=e._y,a=e._z,s=e._order,o=Math.cos,u=Math.sin,l=o(i/2),d=o(r/2),f=o(a/2),h=u(i/2),m=u(r/2),x=u(a/2);switch(s){case"XYZ":this._x=h*d*f+l*m*x,this._y=l*m*f-h*d*x,this._z=l*d*x+h*m*f,this._w=l*d*f-h*m*x;break;case"YXZ":this._x=h*d*f+l*m*x,this._y=l*m*f-h*d*x,this._z=l*d*x-h*m*f,this._w=l*d*f+h*m*x;break;case"ZXY":this._x=h*d*f-l*m*x,this._y=l*m*f+h*d*x,this._z=l*d*x+h*m*f,this._w=l*d*f-h*m*x;break;case"ZYX":this._x=h*d*f-l*m*x,this._y=l*m*f+h*d*x,this._z=l*d*x-h*m*f,this._w=l*d*f+h*m*x;break;case"YZX":this._x=h*d*f+l*m*x,this._y=l*m*f+h*d*x,this._z=l*d*x-h*m*f,this._w=l*d*f-h*m*x;break;case"XZY":this._x=h*d*f-l*m*x,this._y=l*m*f-h*d*x,this._z=l*d*x+h*m*f,this._w=l*d*f+h*m*x;break;default:Rn("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],a=t[8],s=t[1],o=t[5],u=t[9],l=t[2],d=t[6],f=t[10],h=i+o+f;if(h>0){let m=.5/Math.sqrt(h+1);this._w=.25/m,this._x=(d-u)*m,this._y=(a-l)*m,this._z=(s-r)*m}else if(i>o&&i>f){let m=2*Math.sqrt(1+i-o-f);this._w=(d-u)/m,this._x=.25*m,this._y=(r+s)/m,this._z=(a+l)/m}else if(o>f){let m=2*Math.sqrt(1+o-i-f);this._w=(a-l)/m,this._x=(r+s)/m,this._y=.25*m,this._z=(u+d)/m}else{let m=2*Math.sqrt(1+f-i-o);this._w=(s-r)/m,this._x=(a+l)/m,this._y=(u+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(pi(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let r=Math.min(1,t/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,a=e._z,s=e._w,o=t._x,u=t._y,l=t._z,d=t._w;return this._x=i*d+s*o+r*l-a*u,this._y=r*d+s*u+a*o-i*l,this._z=a*d+s*l+i*u-r*o,this._w=s*d-i*o-r*u-a*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,r=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,a=-a,s=-s,o=-o);let u=1-t;if(o<.9995){let l=Math.acos(o),d=Math.sin(l);u=Math.sin(u*l)/d,t=Math.sin(t*l)/d,this._x=this._x*u+i*t,this._y=this._y*u+r*t,this._z=this._z*u+a*t,this._w=this._w*u+s*t,this._onChangeCallback()}else this._x=this._x*u+i*t,this._y=this._y*u+r*t,this._z=this._z*u+a*t,this._w=this._w*u+s*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),a=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),a*Math.sin(t),a*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Ip=class Ip{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(uv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(uv.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6]*r,this.y=a[1]*t+a[4]*i+a[7]*r,this.z=a[2]*t+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*t+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*t+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*t+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*t+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,a=e.x,s=e.y,o=e.z,u=e.w,l=2*(s*r-o*i),d=2*(o*t-a*r),f=2*(a*i-s*t);return this.x=t+u*l+s*f-o*d,this.y=i+u*d+o*l-a*f,this.z=r+u*f+a*d-s*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r,this.y=a[1]*t+a[5]*i+a[9]*r,this.z=a[2]*t+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=pi(this.x,e.x,t.x),this.y=pi(this.y,e.y,t.y),this.z=pi(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=pi(this.x,e,t),this.y=pi(this.y,e,t),this.z=pi(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(pi(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,a=e.z,s=t.x,o=t.y,u=t.z;return this.x=r*u-a*o,this.y=a*s-i*u,this.z=i*o-r*s,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return yh.copy(this).projectOnVector(e),this.sub(yh)}reflect(e){return this.sub(yh.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(pi(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Ip.prototype.isVector3=!0;var Se=Ip,yh=new Se,uv=new aa,Cp=class Cp{constructor(e,t,i,r,a,s,o,u,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,u,l)}set(e,t,i,r,a,s,o,u,l){let d=this.elements;return d[0]=e,d[1]=r,d[2]=o,d[3]=t,d[4]=a,d[5]=u,d[6]=i,d[7]=s,d[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[3],u=i[6],l=i[1],d=i[4],f=i[7],h=i[2],m=i[5],x=i[8],_=r[0],g=r[3],v=r[6],F=r[1],P=r[4],S=r[7],N=r[2],p=r[5],L=r[8];return a[0]=s*_+o*F+u*N,a[3]=s*g+o*P+u*p,a[6]=s*v+o*S+u*L,a[1]=l*_+d*F+f*N,a[4]=l*g+d*P+f*p,a[7]=l*v+d*S+f*L,a[2]=h*_+m*F+x*N,a[5]=h*g+m*P+x*p,a[8]=h*v+m*S+x*L,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8];return t*s*d-t*o*l-i*a*d+i*o*u+r*a*l-r*s*u}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8],f=d*s-o*l,h=o*u-d*a,m=l*a-s*u,x=t*f+i*h+r*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/x;return e[0]=f*_,e[1]=(r*l-d*i)*_,e[2]=(o*i-r*s)*_,e[3]=h*_,e[4]=(d*t-r*u)*_,e[5]=(r*a-o*t)*_,e[6]=m*_,e[7]=(i*u-l*t)*_,e[8]=(s*t-i*a)*_,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,a,s,o){let u=Math.cos(a),l=Math.sin(a);return this.set(i*u,i*l,-i*(u*s+l*o)+s+e,-r*l,r*u,-r*(-l*s+u*o)+o+t,0,0,1),this}scale(e,t){return ho("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(xh.makeScale(e,t)),this}rotate(e){return ho("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(xh.makeRotation(-e)),this}translate(e,t){return ho("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(xh.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Cp.prototype.isMatrix3=!0;var qn=Cp,xh=new qn,dv=new qn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),fv=new qn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Jy(){let n={enabled:!0,workingColorSpace:lc,spaces:{},convert:function(r,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Di&&(r.r=_s(r.r),r.g=_s(r.g),r.b=_s(r.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(r.applyMatrix3(this.spaces[a].toXYZ),r.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===Di&&(r.r=Ko(r.r),r.g=Ko(r.g),r.b=Ko(r.b))),r},workingToColorSpace:function(r,a){return this.convert(r,this.workingColorSpace,a)},colorSpaceToWorking:function(r,a){return this.convert(r,a,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===ta?cc:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,a=this.workingColorSpace){return r.fromArray(this.spaces[a].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,a,s){return r.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,a){return ho("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return ho("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,a)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[lc]:{primaries:e,whitePoint:i,transfer:cc,toXYZ:dv,fromXYZ:fv,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ir},outputColorSpaceConfig:{drawingBufferColorSpace:Ir}},[Ir]:{primaries:e,whitePoint:i,transfer:Di,toXYZ:dv,fromXYZ:fv,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ir}}}),n}var vi=Jy();function _s(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Ko(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var Oo,nd=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{Oo===void 0&&(Oo=uc("canvas")),Oo.width=e.width,Oo.height=e.height;let r=Oo.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Oo}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=uc("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let s=0;s<a.length;s++)a[s]=_s(a[s]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(_s(t[i]/255)*255):t[i]=_s(t[i]);return{data:t,width:e.width,height:e.height}}else return Rn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},$y=0,il=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:$y++}),this.uuid=_o(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let a;if(Array.isArray(r)){a=[];for(let s=0,o=r.length;s<o;s++)r[s].isDataTexture?a.push(_h(r[s].image)):a.push(_h(r[s]))}else a=_h(r);i.url=a}return t||(e.images[this.uuid]=i),i}};function _h(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?nd.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(Rn("Texture: Unable to serialize Texture."),{})}var Ky=0,Mh=new Se,Cr=class n extends Qa{constructor(e=n.DEFAULT_IMAGE,t=n.DEFAULT_MAPPING,i=Ta,r=Ta,a=fr,s=ns,o=ga,u=ca,l=n.DEFAULT_ANISOTROPY,d=ta){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ky++}),this.uuid=_o(),this.name="",this.source=new il(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=a,this.minFilter=s,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=u,this.offset=new ln(0,0),this.repeat=new ln(1,1),this.center=new ln(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new qn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Mh).x}get height(){return this.source.getSize(Mh).y}get depth(){return this.source.getSize(Mh).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let i=e[t];if(i===void 0){Rn(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Rn(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==hp)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Vs:e.x=e.x-Math.floor(e.x);break;case Ta:e.x=e.x<0?0:1;break;case el:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Vs:e.y=e.y-Math.floor(e.y);break;case Ta:e.y=e.y<0?0:1;break;case el:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Cr.DEFAULT_IMAGE=null;Cr.DEFAULT_MAPPING=hp;Cr.DEFAULT_ANISOTROPY=1;var Rp=class Rp{constructor(e=0,t=0,i=0,r=1){this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*t+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*t+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*t+s[7]*i+s[11]*r+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,a,u=e.elements,l=u[0],d=u[4],f=u[8],h=u[1],m=u[5],x=u[9],_=u[2],g=u[6],v=u[10];if(Math.abs(d-h)<.01&&Math.abs(f-_)<.01&&Math.abs(x-g)<.01){if(Math.abs(d+h)<.1&&Math.abs(f+_)<.1&&Math.abs(x+g)<.1&&Math.abs(l+m+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let P=(l+1)/2,S=(m+1)/2,N=(v+1)/2,p=(d+h)/4,L=(f+_)/4,E=(x+g)/4;return P>S&&P>N?P<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(P),r=p/i,a=L/i):S>N?S<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(S),i=p/r,a=E/r):N<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(N),i=L/a,r=E/a),this.set(i,r,a,t),this}let F=Math.sqrt((g-x)*(g-x)+(f-_)*(f-_)+(h-d)*(h-d));return Math.abs(F)<.001&&(F=1),this.x=(g-x)/F,this.y=(f-_)/F,this.z=(h-d)/F,this.w=Math.acos((l+m+v-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=pi(this.x,e.x,t.x),this.y=pi(this.y,e.y,t.y),this.z=pi(this.z,e.z,t.z),this.w=pi(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=pi(this.x,e,t),this.y=pi(this.y,e,t),this.z=pi(this.z,e,t),this.w=pi(this.w,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(pi(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Rp.prototype.isVector4=!0;var Fi=Rp,id=class extends Qa{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:fr,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new Fi(0,0,e,t),this.scissorTest=!1,this.viewport=new Fi(0,0,e,t),this.textures=[];let r={width:e,height:t,depth:i.depth},a=new Cr(r),s=i.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveColorBuffer=i.resolveColorBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this.storeMultisampledColorBuffer=i.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=i.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=i.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:fr,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,a=this.textures.length;r<a;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t<i;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let r=Object.assign({},e.textures[t].image);this.textures[t].source=new il(r)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},sa=class extends id{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},dc=class extends Cr{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=ar,this.minFilter=ar,this.wrapR=Ta,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var rd=class extends Cr{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=ar,this.minFilter=ar,this.wrapR=Ta,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var Id=class Id{constructor(e,t,i,r,a,s,o,u,l,d,f,h,m,x,_,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,o,u,l,d,f,h,m,x,_,g)}set(e,t,i,r,a,s,o,u,l,d,f,h,m,x,_,g){let v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=r,v[1]=a,v[5]=s,v[9]=o,v[13]=u,v[2]=l,v[6]=d,v[10]=f,v[14]=h,v[3]=m,v[7]=x,v[11]=_,v[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Id().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,i=e.elements,r=1/Bo.setFromMatrixColumn(e,0).length(),a=1/Bo.setFromMatrixColumn(e,1).length(),s=1/Bo.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*a,t[5]=i[5]*a,t[6]=i[6]*a,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),o=Math.sin(i),u=Math.cos(r),l=Math.sin(r),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){let h=s*d,m=s*f,x=o*d,_=o*f;t[0]=u*d,t[4]=-u*f,t[8]=l,t[1]=m+x*l,t[5]=h-_*l,t[9]=-o*u,t[2]=_-h*l,t[6]=x+m*l,t[10]=s*u}else if(e.order==="YXZ"){let h=u*d,m=u*f,x=l*d,_=l*f;t[0]=h+_*o,t[4]=x*o-m,t[8]=s*l,t[1]=s*f,t[5]=s*d,t[9]=-o,t[2]=m*o-x,t[6]=_+h*o,t[10]=s*u}else if(e.order==="ZXY"){let h=u*d,m=u*f,x=l*d,_=l*f;t[0]=h-_*o,t[4]=-s*f,t[8]=x+m*o,t[1]=m+x*o,t[5]=s*d,t[9]=_-h*o,t[2]=-s*l,t[6]=o,t[10]=s*u}else if(e.order==="ZYX"){let h=s*d,m=s*f,x=o*d,_=o*f;t[0]=u*d,t[4]=x*l-m,t[8]=h*l+_,t[1]=u*f,t[5]=_*l+h,t[9]=m*l-x,t[2]=-l,t[6]=o*u,t[10]=s*u}else if(e.order==="YZX"){let h=s*u,m=s*l,x=o*u,_=o*l;t[0]=u*d,t[4]=_-h*f,t[8]=x*f+m,t[1]=f,t[5]=s*d,t[9]=-o*d,t[2]=-l*d,t[6]=m*f+x,t[10]=h-_*f}else if(e.order==="XZY"){let h=s*u,m=s*l,x=o*u,_=o*l;t[0]=u*d,t[4]=-f,t[8]=l*d,t[1]=h*f+_,t[5]=s*d,t[9]=m*f-x,t[2]=x*f-m,t[6]=o*d,t[10]=_*f+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Qy,e,jy)}lookAt(e,t,i){let r=this.elements;return ua.subVectors(e,t),ua.lengthSq()===0&&(ua.z=1),ua.normalize(),Us.crossVectors(i,ua),Us.lengthSq()===0&&(Math.abs(i.z)===1?ua.x+=1e-4:ua.z+=1e-4,ua.normalize(),Us.crossVectors(i,ua)),Us.normalize(),Su.crossVectors(ua,Us),r[0]=Us.x,r[4]=Su.x,r[8]=ua.x,r[1]=Us.y,r[5]=Su.y,r[9]=ua.y,r[2]=Us.z,r[6]=Su.z,r[10]=ua.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,s=i[0],o=i[4],u=i[8],l=i[12],d=i[1],f=i[5],h=i[9],m=i[13],x=i[2],_=i[6],g=i[10],v=i[14],F=i[3],P=i[7],S=i[11],N=i[15],p=r[0],L=r[4],E=r[8],D=r[12],X=r[1],Y=r[5],W=r[9],C=r[13],M=r[2],J=r[6],q=r[10],ce=r[14],k=r[3],G=r[7],te=r[11],le=r[15];return a[0]=s*p+o*X+u*M+l*k,a[4]=s*L+o*Y+u*J+l*G,a[8]=s*E+o*W+u*q+l*te,a[12]=s*D+o*C+u*ce+l*le,a[1]=d*p+f*X+h*M+m*k,a[5]=d*L+f*Y+h*J+m*G,a[9]=d*E+f*W+h*q+m*te,a[13]=d*D+f*C+h*ce+m*le,a[2]=x*p+_*X+g*M+v*k,a[6]=x*L+_*Y+g*J+v*G,a[10]=x*E+_*W+g*q+v*te,a[14]=x*D+_*C+g*ce+v*le,a[3]=F*p+P*X+S*M+N*k,a[7]=F*L+P*Y+S*J+N*G,a[11]=F*E+P*W+S*q+N*te,a[15]=F*D+P*C+S*ce+N*le,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],a=e[12],s=e[1],o=e[5],u=e[9],l=e[13],d=e[2],f=e[6],h=e[10],m=e[14],x=e[3],_=e[7],g=e[11],v=e[15],F=u*m-l*h,P=o*m-l*f,S=o*h-u*f,N=s*m-l*d,p=s*h-u*d,L=s*f-o*d;return t*(_*F-g*P+v*S)-i*(x*F-g*N+v*p)+r*(x*P-_*N+v*L)-a*(x*S-_*p+g*L)}determinantAffine(){let e=this.elements,t=e[0],i=e[4],r=e[8],a=e[1],s=e[5],o=e[9],u=e[2],l=e[6],d=e[10];return t*(s*d-o*l)-i*(a*d-o*u)+r*(a*l-s*u)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],u=e[6],l=e[7],d=e[8],f=e[9],h=e[10],m=e[11],x=e[12],_=e[13],g=e[14],v=e[15],F=t*o-i*s,P=t*u-r*s,S=t*l-a*s,N=i*u-r*o,p=i*l-a*o,L=r*l-a*u,E=d*_-f*x,D=d*g-h*x,X=d*v-m*x,Y=f*g-h*_,W=f*v-m*_,C=h*v-m*g,M=F*C-P*W+S*Y+N*X-p*D+L*E;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let J=1/M;return e[0]=(o*C-u*W+l*Y)*J,e[1]=(r*W-i*C-a*Y)*J,e[2]=(_*L-g*p+v*N)*J,e[3]=(h*p-f*L-m*N)*J,e[4]=(u*X-s*C-l*D)*J,e[5]=(t*C-r*X+a*D)*J,e[6]=(g*S-x*L-v*P)*J,e[7]=(d*L-h*S+m*P)*J,e[8]=(s*W-o*X+l*E)*J,e[9]=(i*X-t*W-a*E)*J,e[10]=(x*p-_*S+v*F)*J,e[11]=(f*S-d*p-m*F)*J,e[12]=(o*D-s*Y-u*E)*J,e[13]=(t*Y-i*D+r*E)*J,e[14]=(_*P-x*N-g*F)*J,e[15]=(d*N-f*P+h*F)*J,this}scale(e){let t=this.elements,i=e.x,r=e.y,a=e.z;return t[0]*=i,t[4]*=r,t[8]*=a,t[1]*=i,t[5]*=r,t[9]*=a,t[2]*=i,t[6]*=r,t[10]*=a,t[3]*=i,t[7]*=r,t[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),a=1-i,s=e.x,o=e.y,u=e.z,l=a*s,d=a*o;return this.set(l*s+i,l*o-r*u,l*u+r*o,0,l*o+r*u,d*o+i,d*u-r*s,0,l*u-r*o,d*u+r*s,a*u*u+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,a=t._x,s=t._y,o=t._z,u=t._w,l=a+a,d=s+s,f=o+o,h=a*l,m=a*d,x=a*f,_=s*d,g=s*f,v=o*f,F=u*l,P=u*d,S=u*f,N=i.x,p=i.y,L=i.z;return r[0]=(1-(_+v))*N,r[1]=(m+S)*N,r[2]=(x-P)*N,r[3]=0,r[4]=(m-S)*p,r[5]=(1-(h+v))*p,r[6]=(g+F)*p,r[7]=0,r[8]=(x+P)*L,r[9]=(g-F)*L,r[10]=(1-(h+_))*L,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let a=this.determinantAffine();if(a===0)return i.set(1,1,1),t.identity(),this;let s=Bo.set(r[0],r[1],r[2]).length(),o=Bo.set(r[4],r[5],r[6]).length(),u=Bo.set(r[8],r[9],r[10]).length();a<0&&(s=-s),Ua.copy(this);let l=1/s,d=1/o,f=1/u;return Ua.elements[0]*=l,Ua.elements[1]*=l,Ua.elements[2]*=l,Ua.elements[4]*=d,Ua.elements[5]*=d,Ua.elements[6]*=d,Ua.elements[8]*=f,Ua.elements[9]*=f,Ua.elements[10]*=f,t.setFromRotationMatrix(Ua),i.x=s,i.y=o,i.z=u,this}makePerspective(e,t,i,r,a,s,o=Ba,u=!1){let l=this.elements,d=2*a/(t-e),f=2*a/(i-r),h=(t+e)/(t-e),m=(i+r)/(i-r),x,_;if(u)x=a/(s-a),_=s*a/(s-a);else if(o===Ba)x=-(s+a)/(s-a),_=-2*s*a/(s-a);else if(o===tl)x=-s/(s-a),_=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=d,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=f,l[9]=m,l[13]=0,l[2]=0,l[6]=0,l[10]=x,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,r,a,s,o=Ba,u=!1){let l=this.elements,d=2/(t-e),f=2/(i-r),h=-(t+e)/(t-e),m=-(i+r)/(i-r),x,_;if(u)x=1/(s-a),_=s/(s-a);else if(o===Ba)x=-2/(s-a),_=-(s+a)/(s-a);else if(o===tl)x=-1/(s-a),_=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=d,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=f,l[9]=0,l[13]=m,l[2]=0,l[6]=0,l[10]=x,l[14]=_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};Id.prototype.isMatrix4=!0;var Jn=Id,Bo=new Se,Ua=new Jn,Qy=new Se(0,0,0),jy=new Se(1,1,1),Us=new Se,Su=new Se,ua=new Se,hv=new Jn,pv=new aa,Ea=class n{constructor(e=0,t=0,i=0,r=n.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,a=r[0],s=r[4],o=r[8],u=r[1],l=r[5],d=r[9],f=r[2],h=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(pi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-pi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(u,l)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(pi(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(u,a));break;case"ZYX":this._y=Math.asin(-pi(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,m),this._z=Math.atan2(u,a)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(pi(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-d,l),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-pi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:Rn("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return hv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(hv,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return pv.setFromEuler(this),this.setFromQuaternion(pv,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Ea.DEFAULT_ORDER="XYZ";var rl=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},ex=0,mv=new Se,ko=new aa,ms=new Jn,bu=new Se,Kl=new Se,tx=new Se,nx=new aa,vv=new Se(1,0,0),gv=new Se(0,1,0),yv=new Se(0,0,1),xv={type:"added"},ix={type:"removed"},zo={type:"childadded",child:null},Sh={type:"childremoved",child:null},hr=class n extends Qa{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ex++}),this.uuid=_o(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.DEFAULT_UP.clone();let e=new Se,t=new Ea,i=new aa,r=new Se(1,1,1);function a(){i.setFromEuler(t,!1)}function s(){t.setFromQuaternion(i,void 0,!1)}t._onChange(a),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Jn},normalMatrix:{value:new qn}}),this.matrix=new Jn,this.matrixWorld=new Jn,this.matrixAutoUpdate=n.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=n.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new rl,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ko.setFromAxisAngle(e,t),this.quaternion.multiply(ko),this}rotateOnWorldAxis(e,t){return ko.setFromAxisAngle(e,t),this.quaternion.premultiply(ko),this}rotateX(e){return this.rotateOnAxis(vv,e)}rotateY(e){return this.rotateOnAxis(gv,e)}rotateZ(e){return this.rotateOnAxis(yv,e)}translateOnAxis(e,t){return mv.copy(e).applyQuaternion(this.quaternion),this.position.add(mv.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(vv,e)}translateY(e){return this.translateOnAxis(gv,e)}translateZ(e){return this.translateOnAxis(yv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ms.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?bu.copy(e):bu.set(e,t,i);let r=this.parent;this.updateWorldMatrix(!0,!1),Kl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ms.lookAt(Kl,bu,this.up):ms.lookAt(bu,Kl,this.up),this.quaternion.setFromRotationMatrix(ms),r&&(ms.extractRotation(r.matrixWorld),ko.setFromRotationMatrix(ms),this.quaternion.premultiply(ko.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(On("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(xv),zo.child=e,this.dispatchEvent(zo),zo.child=null):On("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(ix),Sh.child=e,this.dispatchEvent(Sh),Sh.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ms.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ms.multiply(e.parent.matrixWorld)),e.applyMatrix4(ms),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(xv),zo.child=e,this.dispatchEvent(zo),zo.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,r=this.children.length;i<r;i++){let s=this.children[i].getObjectByProperty(e,t);if(s!==void 0)return s}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);let r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kl,e,tx),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Kl,nx,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,i=e.y,r=e.z,a=this.matrix.elements;a[12]+=t-a[0]*t-a[4]*i-a[8]*r,a[13]+=i-a[1]*t-a[5]*i-a[9]*r,a[14]+=r-a[2]*t-a[6]*i-a[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t,i=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),t===!0){let a=this.children;for(let s=0,o=a.length;s<o;s++)a[s].updateWorldMatrix(!1,!0,i)}}toJSON(e){let t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function a(o,u){return o[u.uuid]===void 0&&(o[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let u=o.shapes;if(Array.isArray(u))for(let l=0,d=u.length;l<d;l++){let f=u[l];a(e.shapes,f)}else a(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let u=0,l=this.material.length;u<l;u++)o.push(a(e.materials,this.material[u]));r.material=o}else r.material=a(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){let u=this.animations[o];r.animations.push(a(e.animations,u))}}if(t){let o=s(e.geometries),u=s(e.materials),l=s(e.textures),d=s(e.images),f=s(e.shapes),h=s(e.skeletons),m=s(e.animations),x=s(e.nodes);o.length>0&&(i.geometries=o),u.length>0&&(i.materials=u),l.length>0&&(i.textures=l),d.length>0&&(i.images=d),f.length>0&&(i.shapes=f),h.length>0&&(i.skeletons=h),m.length>0&&(i.animations=m),x.length>0&&(i.nodes=x)}return i.object=r,i;function s(o){let u=[];for(let l in o){let d=o[l];delete d.metadata,u.push(d)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){let r=e.children[i];this.add(r.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};hr.DEFAULT_UP=new Se(0,1,0);hr.DEFAULT_MATRIX_AUTO_UPDATE=!0;hr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var dr=class extends hr{constructor(){super(),this.isGroup=!0,this.type="Group"}},rx={type:"move"},al=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new dr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new dr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Se,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Se),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new dr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Se,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Se,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,a=null,s=null,o=this._targetRay,u=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){s=!0;for(let _ of e.hand.values()){let g=t.getJointPose(_,i),v=this._getHandJoint(l,_);g!==null&&(v.matrix.fromArray(g.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=g.radius),v.visible=g!==null}let d=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],h=d.position.distanceTo(f.position),m=.02,x=.005;l.inputState.pinching&&h>m+x?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=m-x&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,i),a!==null&&(u.matrix.fromArray(a.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,a.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(a.linearVelocity)):u.hasLinearVelocity=!1,a.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(a.angularVelocity)):u.hasAngularVelocity=!1,u.eventsEnabled&&u.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(rx)))}return o!==null&&(o.visible=r!==null),u!==null&&(u.visible=a!==null),l!==null&&(l.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new dr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},C0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Fs={h:0,s:0,l:0},wu={h:0,s:0,l:0};function bh(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}var Wn=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ir){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,vi.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=vi.workingColorSpace){return this.r=e,this.g=t,this.b=i,vi.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=vi.workingColorSpace){if(e=Zy(e,1),t=pi(t,0,1),i=pi(i,0,1),t===0)this.r=this.g=this.b=i;else{let a=i<=.5?i*(1+t):i+t-i*t,s=2*i-a;this.r=bh(s,a,e+1/3),this.g=bh(s,a,e),this.b=bh(s,a,e-1/3)}return vi.colorSpaceToWorking(this,r),this}setStyle(e,t=Ir){function i(a){a!==void 0&&parseFloat(a)<1&&Rn("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let a,s=r[1],o=r[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:Rn("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let a=r[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(s===6)return this.setHex(parseInt(a,16),t);Rn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ir){let i=C0[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Rn("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=_s(e.r),this.g=_s(e.g),this.b=_s(e.b),this}copyLinearToSRGB(e){return this.r=Ko(e.r),this.g=Ko(e.g),this.b=Ko(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ir){return vi.workingToColorSpace(kr.copy(this),e),Math.round(pi(kr.r*255,0,255))*65536+Math.round(pi(kr.g*255,0,255))*256+Math.round(pi(kr.b*255,0,255))}getHexString(e=Ir){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=vi.workingColorSpace){vi.workingToColorSpace(kr.copy(this),t);let i=kr.r,r=kr.g,a=kr.b,s=Math.max(i,r,a),o=Math.min(i,r,a),u,l,d=(o+s)/2;if(o===s)u=0,l=0;else{let f=s-o;switch(l=d<=.5?f/(s+o):f/(2-s-o),s){case i:u=(r-a)/f+(r<a?6:0);break;case r:u=(a-i)/f+2;break;case a:u=(i-r)/f+4;break}u/=6}return e.h=u,e.s=l,e.l=d,e}getRGB(e,t=vi.workingColorSpace){return vi.workingToColorSpace(kr.copy(this),t),e.r=kr.r,e.g=kr.g,e.b=kr.b,e}getStyle(e=Ir){vi.workingToColorSpace(kr.copy(this),e);let t=kr.r,i=kr.g,r=kr.b;return e!==Ir?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(Fs),this.setHSL(Fs.h+e,Fs.s+t,Fs.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Fs),e.getHSL(wu);let i=gh(Fs.h,wu.h,t),r=gh(Fs.s,wu.s,t),a=gh(Fs.l,wu.l,t);return this.setHSL(i,r,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,r=this.b,a=e.elements;return this.r=a[0]*t+a[3]*i+a[6]*r,this.g=a[1]*t+a[4]*i+a[7]*r,this.b=a[2]*t+a[5]*i+a[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},kr=new Wn;Wn.NAMES=C0;var fc=class extends hr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ea,this.environmentIntensity=1,this.environmentRotation=new Ea,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},Fa=new Se,vs=new Se,wh=new Se,gs=new Se,Vo=new Se,Go=new Se,_v=new Se,Th=new Se,Eh=new Se,Ah=new Se,Ih=new Fi,Ch=new Fi,Rh=new Fi,zs=class n{constructor(e=new Se,t=new Se,i=new Se){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),Fa.subVectors(e,t),r.cross(Fa);let a=r.lengthSq();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,t,i,r,a){Fa.subVectors(r,t),vs.subVectors(i,t),wh.subVectors(e,t);let s=Fa.dot(Fa),o=Fa.dot(vs),u=Fa.dot(wh),l=vs.dot(vs),d=vs.dot(wh),f=s*l-o*o;if(f===0)return a.set(0,0,0),null;let h=1/f,m=(l*u-o*d)*h,x=(s*d-o*u)*h;return a.set(1-m-x,x,m)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,gs)===null?!1:gs.x>=0&&gs.y>=0&&gs.x+gs.y<=1}static getInterpolation(e,t,i,r,a,s,o,u){return this.getBarycoord(e,t,i,r,gs)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(a,gs.x),u.addScaledVector(s,gs.y),u.addScaledVector(o,gs.z),u)}static getInterpolatedAttribute(e,t,i,r,a,s){return Ih.setScalar(0),Ch.setScalar(0),Rh.setScalar(0),Ih.fromBufferAttribute(e,t),Ch.fromBufferAttribute(e,i),Rh.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(Ih,a.x),s.addScaledVector(Ch,a.y),s.addScaledVector(Rh,a.z),s}static isFrontFacing(e,t,i,r){return Fa.subVectors(i,t),vs.subVectors(e,t),Fa.cross(vs).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Fa.subVectors(this.c,this.b),vs.subVectors(this.a,this.b),Fa.cross(vs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return n.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,a){return n.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}containsPoint(e){return n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i=this.a,r=this.b,a=this.c,s,o;Vo.subVectors(r,i),Go.subVectors(a,i),Th.subVectors(e,i);let u=Vo.dot(Th),l=Go.dot(Th);if(u<=0&&l<=0)return t.copy(i);Eh.subVectors(e,r);let d=Vo.dot(Eh),f=Go.dot(Eh);if(d>=0&&f<=d)return t.copy(r);let h=u*f-d*l;if(h<=0&&u>=0&&d<=0)return s=u/(u-d),t.copy(i).addScaledVector(Vo,s);Ah.subVectors(e,a);let m=Vo.dot(Ah),x=Go.dot(Ah);if(x>=0&&m<=x)return t.copy(a);let _=m*l-u*x;if(_<=0&&l>=0&&x<=0)return o=l/(l-x),t.copy(i).addScaledVector(Go,o);let g=d*x-m*f;if(g<=0&&f-d>=0&&m-x>=0)return _v.subVectors(a,r),o=(f-d)/(f-d+(m-x)),t.copy(r).addScaledVector(_v,o);let v=1/(g+_+h);return s=_*v,o=h*v,t.copy(i).addScaledVector(Vo,s).addScaledVector(Go,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Qr=class{constructor(e=new Se(1/0,1/0,1/0),t=new Se(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Oa.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Oa.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Oa.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let i=e.geometry;if(i!==void 0){let a=i.getAttribute("position");if(t===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,Oa):Oa.fromBufferAttribute(a,s),Oa.applyMatrix4(e.matrixWorld),this.expandByPoint(Oa);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Tu.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Tu.copy(i.boundingBox)),Tu.applyMatrix4(e.matrixWorld),this.union(Tu)}let r=e.children;for(let a=0,s=r.length;a<s;a++)this.expandByObject(r[a],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Oa),Oa.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ql),Eu.subVectors(this.max,Ql),Ho.subVectors(e.a,Ql),Wo.subVectors(e.b,Ql),Xo.subVectors(e.c,Ql),Os.subVectors(Wo,Ho),Bs.subVectors(Xo,Wo),lo.subVectors(Ho,Xo);let t=[0,-Os.z,Os.y,0,-Bs.z,Bs.y,0,-lo.z,lo.y,Os.z,0,-Os.x,Bs.z,0,-Bs.x,lo.z,0,-lo.x,-Os.y,Os.x,0,-Bs.y,Bs.x,0,-lo.y,lo.x,0];return!Ph(t,Ho,Wo,Xo,Eu)||(t=[1,0,0,0,1,0,0,0,1],!Ph(t,Ho,Wo,Xo,Eu))?!1:(Au.crossVectors(Os,Bs),t=[Au.x,Au.y,Au.z],Ph(t,Ho,Wo,Xo,Eu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Oa).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Oa).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ys[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ys[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ys[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ys[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ys[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ys[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ys[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ys[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ys),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},ys=[new Se,new Se,new Se,new Se,new Se,new Se,new Se,new Se],Oa=new Se,Tu=new Qr,Ho=new Se,Wo=new Se,Xo=new Se,Os=new Se,Bs=new Se,lo=new Se,Ql=new Se,Eu=new Se,Au=new Se,co=new Se;function Ph(n,e,t,i,r){for(let a=0,s=n.length-3;a<=s;a+=3){co.fromArray(n,a);let o=r.x*Math.abs(co.x)+r.y*Math.abs(co.y)+r.z*Math.abs(co.z),u=e.dot(co),l=t.dot(co),d=i.dot(co);if(Math.max(-Math.max(u,l,d),Math.min(u,l,d))>o)return!1}return!0}var rr=new Se,Iu=new ln,ax=0,Vr=class extends Qa{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:ax++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=w0,this.updateRanges=[],this.gpuType=va,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,a=this.itemSize;r<a;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Iu.fromBufferAttribute(this,t),Iu.applyMatrix3(e),this.setXY(t,Iu.x,Iu.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)rr.fromBufferAttribute(this,t),rr.applyMatrix3(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)rr.fromBufferAttribute(this,t),rr.applyMatrix4(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)rr.fromBufferAttribute(this,t),rr.applyNormalMatrix(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)rr.fromBufferAttribute(this,t),rr.transformDirection(e),this.setXYZ(t,rr.x,rr.y,rr.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=$l(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=ra(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=$l(t,this.array)),t}setX(e,t){return this.normalized&&(t=ra(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=$l(t,this.array)),t}setY(e,t){return this.normalized&&(t=ra(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=$l(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ra(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=$l(t,this.array)),t}setW(e,t){return this.normalized&&(t=ra(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=ra(t,this.array),i=ra(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=ra(t,this.array),i=ra(i,this.array),r=ra(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e*=this.itemSize,this.normalized&&(t=ra(t,this.array),i=ra(i,this.array),r=ra(r,this.array),a=ra(a,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}};var hc=class extends Vr{constructor(e,t,i){super(new Uint16Array(e),t,i)}};var pc=class extends Vr{constructor(e,t,i){super(new Uint32Array(e),t,i)}};var Ci=class extends Vr{constructor(e,t,i){super(new Float32Array(e),t,i)}},sx=new Qr,jl=new Se,Lh=new Se,ja=class{constructor(e=new Se,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;t!==void 0?i.copy(t):sx.setFromPoints(e).getCenter(i);let r=0;for(let a=0,s=e.length;a<s;a++)r=Math.max(r,i.distanceToSquared(e[a]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;jl.subVectors(e,this.center);let t=jl.lengthSq();if(t>this.radius*this.radius){let i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(jl,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Lh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(jl.copy(e.center).add(Lh)),this.expandByPoint(jl.copy(e.center).sub(Lh))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},ox=0,wa=new Jn,Dh=new hr,Yo=new Se,da=new Qr,ec=new Qr,Ar=new Se,pr=class n extends Qa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ox++}),this.uuid=_o(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Yy(e)?pc:hc)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let i=this.attributes.normal;if(i!==void 0){let a=new qn().getNormalMatrix(e);i.applyNormalMatrix(a),i.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return wa.makeRotationFromQuaternion(e),this.applyMatrix4(wa),this}rotateX(e){return wa.makeRotationX(e),this.applyMatrix4(wa),this}rotateY(e){return wa.makeRotationY(e),this.applyMatrix4(wa),this}rotateZ(e){return wa.makeRotationZ(e),this.applyMatrix4(wa),this}translate(e,t,i){return wa.makeTranslation(e,t,i),this.applyMatrix4(wa),this}scale(e,t,i){return wa.makeScale(e,t,i),this.applyMatrix4(wa),this}lookAt(e){return Dh.lookAt(e),Dh.updateMatrix(),this.applyMatrix4(Dh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Yo).negate(),this.translate(Yo.x,Yo.y,Yo.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let i=[];for(let r=0,a=e.length;r<a;r++){let s=e[r];i.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Ci(i,3))}else{let i=Math.min(e.length,t.count);for(let r=0;r<i;r++){let a=e[r];t.setXYZ(r,a.x,a.y,a.z||0)}e.length>t.count&&Rn("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Qr);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){On("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Se(-1/0,-1/0,-1/0),new Se(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){let a=t[i];da.setFromBufferAttribute(a),this.morphTargetsRelative?(Ar.addVectors(this.boundingBox.min,da.min),this.boundingBox.expandByPoint(Ar),Ar.addVectors(this.boundingBox.max,da.max),this.boundingBox.expandByPoint(Ar)):(this.boundingBox.expandByPoint(da.min),this.boundingBox.expandByPoint(da.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&On('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ja);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){On("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Se,1/0);return}if(e){let i=this.boundingSphere.center;if(da.setFromBufferAttribute(e),t)for(let a=0,s=t.length;a<s;a++){let o=t[a];ec.setFromBufferAttribute(o),this.morphTargetsRelative?(Ar.addVectors(da.min,ec.min),da.expandByPoint(Ar),Ar.addVectors(da.max,ec.max),da.expandByPoint(Ar)):(da.expandByPoint(ec.min),da.expandByPoint(ec.max))}da.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)Ar.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(Ar));if(t)for(let a=0,s=t.length;a<s;a++){let o=t[a],u=this.morphTargetsRelative;for(let l=0,d=o.count;l<d;l++)Ar.fromBufferAttribute(o,l),u&&(Yo.fromBufferAttribute(e,l),Ar.add(Yo)),r=Math.max(r,i.distanceToSquared(Ar))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&On('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){On("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let i=t.position,r=t.normal,a=t.uv,s=this.getAttribute("tangent");(s===void 0||s.count!==i.count)&&(s=new Vr(new Float32Array(4*i.count),4),this.setAttribute("tangent",s));let o=[],u=[];for(let E=0;E<i.count;E++)o[E]=new Se,u[E]=new Se;let l=new Se,d=new Se,f=new Se,h=new ln,m=new ln,x=new ln,_=new Se,g=new Se;function v(E,D,X){l.fromBufferAttribute(i,E),d.fromBufferAttribute(i,D),f.fromBufferAttribute(i,X),h.fromBufferAttribute(a,E),m.fromBufferAttribute(a,D),x.fromBufferAttribute(a,X),d.sub(l),f.sub(l),m.sub(h),x.sub(h);let Y=1/(m.x*x.y-x.x*m.y);isFinite(Y)&&(_.copy(d).multiplyScalar(x.y).addScaledVector(f,-m.y).multiplyScalar(Y),g.copy(f).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(Y),o[E].add(_),o[D].add(_),o[X].add(_),u[E].add(g),u[D].add(g),u[X].add(g))}let F=this.groups;F.length===0&&(F=[{start:0,count:e.count}]);for(let E=0,D=F.length;E<D;++E){let X=F[E],Y=X.start,W=X.count;for(let C=Y,M=Y+W;C<M;C+=3)v(e.getX(C+0),e.getX(C+1),e.getX(C+2))}let P=new Se,S=new Se,N=new Se,p=new Se;function L(E){N.fromBufferAttribute(r,E),p.copy(N);let D=o[E];P.copy(D),P.sub(N.multiplyScalar(N.dot(D))).normalize(),S.crossVectors(p,D);let Y=S.dot(u[E])<0?-1:1;s.setXYZW(E,P.x,P.y,P.z,Y)}for(let E=0,D=F.length;E<D;++E){let X=F[E],Y=X.start,W=X.count;for(let C=Y,M=Y+W;C<M;C+=3)L(e.getX(C+0)),L(e.getX(C+1)),L(e.getX(C+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==t.count)i=new Vr(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let h=0,m=i.count;h<m;h++)i.setXYZ(h,0,0,0);let r=new Se,a=new Se,s=new Se,o=new Se,u=new Se,l=new Se,d=new Se,f=new Se;if(e)for(let h=0,m=e.count;h<m;h+=3){let x=e.getX(h+0),_=e.getX(h+1),g=e.getX(h+2);r.fromBufferAttribute(t,x),a.fromBufferAttribute(t,_),s.fromBufferAttribute(t,g),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),o.fromBufferAttribute(i,x),u.fromBufferAttribute(i,_),l.fromBufferAttribute(i,g),o.add(d),u.add(d),l.add(d),i.setXYZ(x,o.x,o.y,o.z),i.setXYZ(_,u.x,u.y,u.z),i.setXYZ(g,l.x,l.y,l.z)}else for(let h=0,m=t.count;h<m;h+=3)r.fromBufferAttribute(t,h+0),a.fromBufferAttribute(t,h+1),s.fromBufferAttribute(t,h+2),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),i.setXYZ(h+0,d.x,d.y,d.z),i.setXYZ(h+1,d.x,d.y,d.z),i.setXYZ(h+2,d.x,d.y,d.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Ar.fromBufferAttribute(e,t),Ar.normalize(),e.setXYZ(t,Ar.x,Ar.y,Ar.z)}toNonIndexed(){function e(o,u){let l=o.array,d=o.itemSize,f=o.normalized,h=new l.constructor(u.length*d),m=0,x=0;for(let _=0,g=u.length;_<g;_++){o.isInterleavedBufferAttribute?m=u[_]*o.data.stride+o.offset:m=u[_]*d;for(let v=0;v<d;v++)h[x++]=l[m++]}return new Vr(h,d,f)}if(this.index===null)return Rn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new n,i=this.index.array,r=this.attributes;for(let o in r){let u=r[o],l=e(u,i);t.setAttribute(o,l)}let a=this.morphAttributes;for(let o in a){let u=[],l=a[o];for(let d=0,f=l.length;d<f;d++){let h=l[d],m=e(h,i);u.push(m)}t.morphAttributes[o]=u}t.morphTargetsRelative=this.morphTargetsRelative;let s=this.groups;for(let o=0,u=s.length;o<u;o++){let l=s[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let u=this.parameters;for(let l in u)u[l]!==void 0&&(e[l]=u[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let u in i){let l=i[u];e.data.attributes[u]=l.toJSON(e.data)}let r={},a=!1;for(let u in this.morphAttributes){let l=this.morphAttributes[u],d=[];for(let f=0,h=l.length;f<h;f++){let m=l[f];d.push(m.toJSON(e.data))}d.length>0&&(r[u]=d,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;i!==null&&this.setIndex(i.clone());let r=e.attributes;for(let l in r){let d=r[l];this.setAttribute(l,d.clone(t))}let a=e.morphAttributes;for(let l in a){let d=[],f=a[l];for(let h=0,m=f.length;h<m;h++)d.push(f[h].clone(t));this.morphAttributes[l]=d}this.morphTargetsRelative=e.morphTargetsRelative;let s=e.groups;for(let l=0,d=s.length;l<d;l++){let f=s[l];this.addGroup(f.start,f.count,f.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}};var Nh=new Se,lx=new Se,cx=new qn,fa=class{constructor(e=new Se(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=Nh.subVectors(i,t).cross(lx.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){let r=e.delta(Nh),a=this.normal.dot(r);if(a===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/a;return i===!0&&(s<0||s>1)?null:t.copy(e.start).addScaledVector(r,s)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||cx.getNormalMatrix(e),r=this.coplanarPoint(Nh).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},ux=0,Ms=class extends Qa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ux++}),this.uuid=_o(),this.name="",this.type="Material",this.blending=yl,this.side=es,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=sp,this.blendDst=op,this.blendEquation=go,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Wn(0,0,0),this.blendAlpha=0,this.depthFunc=jo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=g0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yu,this.stencilZFail=Yu,this.stencilZPass=Yu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let i=e[t];if(i===void 0){Rn(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Rn(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector2&&i&&i.isVector2||r&&r.isEuler&&i&&i.isEuler||r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,i.blending=this.blending,i.side=this.side,i.shadowSide=this.shadowSide,i.vertexColors=this.vertexColors,i.opacity=this.opacity,i.transparent=this.transparent,i.blendSrc=this.blendSrc,i.blendDst=this.blendDst,i.blendEquation=this.blendEquation,i.blendSrcAlpha=this.blendSrcAlpha,i.blendDstAlpha=this.blendDstAlpha,i.blendEquationAlpha=this.blendEquationAlpha,i.blendColor=this.blendColor.getHex(),i.blendAlpha=this.blendAlpha,i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.clipIntersection=this.clipIntersection,i.clipShadows=this.clipShadows,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,i.stencilWrite=this.stencilWrite,i.polygonOffset=this.polygonOffset,i.polygonOffsetFactor=this.polygonOffsetFactor,i.polygonOffsetUnits=this.polygonOffsetUnits,i.dithering=this.dithering,i.alphaTest=this.alphaTest,i.alphaHash=this.alphaHash,i.alphaToCoverage=this.alphaToCoverage,i.premultipliedAlpha=this.premultipliedAlpha,i.forceSinglePass=this.forceSinglePass,i.allowOverride=this.allowOverride,i.visible=this.visible,i.toneMapped=this.toneMapped,i.name=this.name,this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(i.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(i.clippingPlanes=this.clippingPlanes.map(a=>a.toJSON())),this.rotation!==void 0&&(i.rotation=this.rotation),this.depthPacking!==void 0&&(i.depthPacking=this.depthPacking),this.linewidth!==void 0&&(i.linewidth=this.linewidth),this.linecap!==void 0&&(i.linecap=this.linecap),this.linejoin!==void 0&&(i.linejoin=this.linejoin),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.wireframe!==void 0&&(i.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(i.flatShading=this.flatShading),this.fog!==void 0&&(i.fog=this.fog),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(a){let s=[];for(let o in a){let u=a[o];delete u.metadata,s.push(u)}return s}if(t){let a=r(e.textures),s=r(e.images);a.length>0&&(i.textures=a),s.length>0&&(i.images=s)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Wn().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(i=>new fa().fromJSON(i))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new ln().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new ln().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(t!==null){let r=t.length;i=new Array(r);for(let a=0;a!==r;++a)i[a]=t[a].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};var xs=new Se,Uh=new Se,Cu=new Se,Ru=new Se,sl=class{constructor(e=new Se,t=new Se(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,xs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=xs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(xs.copy(this.origin).addScaledVector(this.direction,t),xs.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Uh.copy(e).add(t).multiplyScalar(.5),Cu.copy(t).sub(e).normalize(),Ru.copy(this.origin).sub(Uh);let a=e.distanceTo(t)*.5,s=-this.direction.dot(Cu),o=Ru.dot(this.direction),u=-Ru.dot(Cu),l=Ru.lengthSq(),d=Math.abs(1-s*s),f,h,m,x;if(d>0)if(f=s*u-o,h=s*o-u,x=a*d,f>=0)if(h>=-x)if(h<=x){let _=1/d;f*=_,h*=_,m=f*(f+s*h+2*o)+h*(s*f+h+2*u)+l}else h=a,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*u)+l;else h=-a,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*u)+l;else h<=-x?(f=Math.max(0,-(-s*a+o)),h=f>0?-a:Math.min(Math.max(-a,-u),a),m=-f*f+h*(h+2*u)+l):h<=x?(f=0,h=Math.min(Math.max(-a,-u),a),m=h*(h+2*u)+l):(f=Math.max(0,-(s*a+o)),h=f>0?a:Math.min(Math.max(-a,-u),a),m=-f*f+h*(h+2*u)+l);else h=s>0?-a:a,f=Math.max(0,-(s*h+o)),m=-f*f+h*(h+2*u)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(Uh).addScaledVector(Cu,h),m}intersectSphere(e,t){if(e.radius<0)return null;xs.subVectors(e.center,this.origin);let i=xs.dot(this.direction),r=xs.dot(xs)-i*i,a=e.radius*e.radius;if(r>a)return null;let s=Math.sqrt(a-r),o=i-s,u=i+s;return u<0?null:o<0?this.at(u,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,a,s,o,u,l=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,h=this.origin;return l>=0?(i=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(i=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),d>=0?(a=(e.min.y-h.y)*d,s=(e.max.y-h.y)*d):(a=(e.max.y-h.y)*d,s=(e.min.y-h.y)*d),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),f>=0?(o=(e.min.z-h.z)*f,u=(e.max.z-h.z)*f):(o=(e.max.z-h.z)*f,u=(e.min.z-h.z)*f),i>u||o>r)||((o>i||i!==i)&&(i=o),(u<r||r!==r)&&(r=u),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,xs)!==null}intersectTriangle(e,t,i,r,a){let s=this.origin,o=this.direction,u=o.x,l=o.y,d=o.z,f=e.x-s.x,h=e.y-s.y,m=e.z-s.z,x=t.x-s.x,_=t.y-s.y,g=t.z-s.z,v=i.x-s.x,F=i.y-s.y,P=i.z-s.z,S=Math.abs(u),N=Math.abs(l),p=Math.abs(d),L,E,D,X,Y,W,C,M,J,q,ce,k;if(S>=N&&S>=p?(D=u,W=f,J=x,k=v,u>=0?(L=l,E=d,X=h,Y=m,C=_,M=g,q=F,ce=P):(L=d,E=l,X=m,Y=h,C=g,M=_,q=P,ce=F)):N>=p?(D=l,W=h,J=_,k=F,l>=0?(L=d,E=u,X=m,Y=f,C=g,M=x,q=P,ce=v):(L=u,E=d,X=f,Y=m,C=x,M=g,q=v,ce=P)):(D=d,W=m,J=g,k=P,d>=0?(L=u,E=l,X=f,Y=h,C=x,M=_,q=v,ce=F):(L=l,E=u,X=h,Y=f,C=_,M=x,q=F,ce=v)),D===0)return null;let G=L/D,te=E/D,le=1/D,ge=X-G*W,oe=Y-te*W,$=C-G*J,Te=M-te*J,Le=q-G*k,se=ce-te*k,re=Le*Te-se*$,Ie=ge*se-oe*Le,ke=$*oe-Te*ge;if(r){if(re<0||Ie<0||ke<0)return null}else if((re<0||Ie<0||ke<0)&&(re>0||Ie>0||ke>0))return null;let xe=re+Ie+ke;if(xe===0)return null;let Ye=le*(re*W+Ie*J+ke*k);return(xe>0?Ye<0:Ye>0)?null:this.at(Ye/xe,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},oa=class extends Ms{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Wn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ea,this.combine=Rd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Mv=new Jn,uo=new sl,Pu=new ja,Sv=new Se,Lu=new Se,Du=new Se,Nu=new Se,Fh=new Se,Uu=new Se,bv=new Se,Fu=new Se,bi=class extends hr{constructor(e=new pr,t=new oa){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){let r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){let o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,t){let i=this.geometry,r=i.attributes.position,a=i.morphAttributes.position,s=i.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(a&&o){Uu.set(0,0,0);for(let u=0,l=a.length;u<l;u++){let d=o[u],f=a[u];d!==0&&(Fh.fromBufferAttribute(f,e),s?Uu.addScaledVector(Fh,d):Uu.addScaledVector(Fh.sub(t),d))}t.add(Uu)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Pu.copy(i.boundingSphere),Pu.applyMatrix4(a),uo.copy(e.ray).recast(e.near),!(Pu.containsPoint(uo.origin)===!1&&(uo.intersectSphere(Pu,Sv)===null||uo.origin.distanceToSquared(Sv)>(e.far-e.near)**2))&&(Mv.copy(a).invert(),uo.copy(e.ray).applyMatrix4(Mv),!(i.boundingBox!==null&&uo.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,uo)))}_computeIntersections(e,t,i){let r,a=this.geometry,s=this.material,o=a.index,u=a.attributes.position,l=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,h=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let x=0,_=h.length;x<_;x++){let g=h[x],v=s[g.materialIndex],F=Math.max(g.start,m.start),P=Math.min(o.count,Math.min(g.start+g.count,m.start+m.count));for(let S=F,N=P;S<N;S+=3){let p=o.getX(S),L=o.getX(S+1),E=o.getX(S+2);r=Ou(this,v,e,i,l,d,f,p,L,E),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let x=Math.max(0,m.start),_=Math.min(o.count,m.start+m.count);for(let g=x,v=_;g<v;g+=3){let F=o.getX(g),P=o.getX(g+1),S=o.getX(g+2);r=Ou(this,s,e,i,l,d,f,F,P,S),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(s))for(let x=0,_=h.length;x<_;x++){let g=h[x],v=s[g.materialIndex],F=Math.max(g.start,m.start),P=Math.min(u.count,Math.min(g.start+g.count,m.start+m.count));for(let S=F,N=P;S<N;S+=3){let p=S,L=S+1,E=S+2;r=Ou(this,v,e,i,l,d,f,p,L,E),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=g.materialIndex,t.push(r))}}else{let x=Math.max(0,m.start),_=Math.min(u.count,m.start+m.count);for(let g=x,v=_;g<v;g+=3){let F=g,P=g+1,S=g+2;r=Ou(this,s,e,i,l,d,f,F,P,S),r&&(r.faceIndex=Math.floor(g/3),t.push(r))}}}};function dx(n,e,t,i,r,a,s,o){let u;if(e.side===ea?u=i.intersectTriangle(s,a,r,!0,o):u=i.intersectTriangle(r,a,s,e.side===es,o),u===null)return null;Fu.copy(o),Fu.applyMatrix4(n.matrixWorld);let l=t.ray.origin.distanceTo(Fu);return l<t.near||l>t.far?null:{distance:l,point:Fu.clone(),object:n}}function Ou(n,e,t,i,r,a,s,o,u,l){n.getVertexPosition(o,Lu),n.getVertexPosition(u,Du),n.getVertexPosition(l,Nu);let d=dx(n,e,t,i,Lu,Du,Nu,bv);if(d){let f=new Se;zs.getBarycoord(bv,Lu,Du,Nu,f),r&&(d.uv=zs.getInterpolatedAttribute(r,o,u,l,f,new ln)),a&&(d.uv1=zs.getInterpolatedAttribute(a,o,u,l,f,new ln)),s&&(d.normal=zs.getInterpolatedAttribute(s,o,u,l,f,new Se),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));let h={a:o,b:u,c:l,normal:new Se,materialIndex:0};zs.getNormal(Lu,Du,Nu,h.normal),d.face=h,d.barycoord=f}return d}var tc=new Fi,wv=new Fi,Tv=new Fi,fx=new Fi,Ev=new Jn,Bu=new Se,Oh=new ja,Av=new Jn,Bh=new sl,mc=class extends bi{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Wh,this.bindMatrix=new Jn,this.bindMatrixInverse=new Jn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Qr),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Bu),this.boundingBox.expandByPoint(Bu)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ja),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,Bu),this.boundingSphere.expandByPoint(Bu)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Oh.copy(this.boundingSphere),Oh.applyMatrix4(r),e.ray.intersectsSphere(Oh)!==!1&&(Av.copy(r).invert(),Bh.copy(e.ray).applyMatrix4(Av),!(this.boundingBox!==null&&Bh.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Bh)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Fi,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);let a=1/e.manhattanLength();a!==1/0?e.multiplyScalar(a):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Wh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===p0?this.bindMatrixInverse.copy(this.bindMatrix).invert():Rn("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let i=this.skeleton,r=this.geometry;wv.fromBufferAttribute(r.attributes.skinIndex,e),Tv.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4?(tc.copy(t),t.set(0,0,0,0)):(tc.set(...t,1),t.set(0,0,0)),tc.applyMatrix4(this.bindMatrix);for(let a=0;a<4;a++){let s=Tv.getComponent(a);if(s!==0){let o=wv.getComponent(a);Ev.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),t.addScaledVector(fx.copy(tc).applyMatrix4(Ev),s)}}return t.isVector4&&(t.w=tc.w),t.applyMatrix4(this.bindMatrixInverse)}},ol=class extends hr{constructor(){super(),this.isBone=!0,this.type="Bone"}},Gs=class extends Cr{constructor(e=null,t=1,i=1,r,a,s,o,u,l=ar,d=ar,f,h){super(null,s,o,u,l,d,r,a,f,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Iv=new Jn,hx=new Jn,ll=class n{constructor(e=[],t=[]){this.uuid=_o(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Rn("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Jn)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new Jn;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let a=0,s=e.length;a<s;a++){let o=e[a]?e[a].matrixWorld:hx;Iv.multiplyMatrices(o,t[a]),Iv.toArray(i,a*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new n(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Gs(t,e,e,ga,va);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let a=e.bones[i],s=t[a];s===void 0&&(Rn("Skeleton: No bone found with UUID:",a),s=new ol),this.bones.push(s),this.boneInverses.push(new Jn().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,a=t.length;r<a;r++){let s=t[r];e.bones.push(s.uuid);let o=i[r];e.boneInverses.push(o.toArray())}return e}},vc=class extends Vr{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},qo=new Jn,Cv=new Jn,ku=[],Rv=new Qr,px=new Jn,nc=new bi,ic=new ja,ka=class extends bi{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new vc(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,px)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Qr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,qo),Rv.copy(e.boundingBox).applyMatrix4(qo),this.boundingBox.union(Rv)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ja),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,qo),ic.copy(e.boundingSphere).applyMatrix4(qo),this.boundingSphere.union(ic)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let i=t.morphTargetInfluences,r=this.morphTexture.source.data.data,a=i.length+1,s=e*a+1;for(let o=0;o<i.length;o++)i[o]=r[s+o]}raycast(e,t){let i=this.matrixWorld,r=this.count;if(nc.geometry=this.geometry,nc.material=this.material,nc.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ic.copy(this.boundingSphere),ic.applyMatrix4(i),e.ray.intersectsSphere(ic)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,qo),Cv.multiplyMatrices(i,qo),nc.matrixWorld=Cv,nc.raycast(e,ku);for(let s=0,o=ku.length;s<o;s++){let u=ku[s];u.instanceId=a,u.object=this,t.push(u)}ku.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new vc(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let i=t.morphTargetInfluences,r=i.length+1;this.morphTexture===null&&(this.morphTexture=new Gs(new Float32Array(r*this.count),r,this.count,Fd,va));let a=this.morphTexture.source.data.data,s=0;for(let l=0;l<i.length;l++)s+=i[l];let o=this.geometry.morphTargetsRelative?1:1-s,u=r*e;return a[u]=o,a.set(i,u+1),this}updateMorphTargets(){}dispose(){super.dispose(),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},fo=new ja,mx=new ln(.5,.5),zu=new Se,cl=class{constructor(e=new fa,t=new fa,i=new fa,r=new fa,a=new fa,s=new fa){this.planes=[e,t,i,r,a,s]}set(e,t,i,r,a,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(a),o[5].copy(s),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Ba,i=!1){let r=this.planes,a=e.elements,s=a[0],o=a[1],u=a[2],l=a[3],d=a[4],f=a[5],h=a[6],m=a[7],x=a[8],_=a[9],g=a[10],v=a[11],F=a[12],P=a[13],S=a[14],N=a[15];if(r[0].setComponents(l-s,m-d,v-x,N-F).normalize(),r[1].setComponents(l+s,m+d,v+x,N+F).normalize(),r[2].setComponents(l+o,m+f,v+_,N+P).normalize(),r[3].setComponents(l-o,m-f,v-_,N-P).normalize(),i)r[4].setComponents(u,h,g,S).normalize(),r[5].setComponents(l-u,m-h,v-g,N-S).normalize();else if(r[4].setComponents(l-u,m-h,v-g,N-S).normalize(),t===Ba)r[5].setComponents(l+u,m+h,v+g,N+S).normalize();else if(t===tl)r[5].setComponents(u,h,g,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),fo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),fo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(fo)}intersectsSprite(e){fo.center.set(0,0,0);let t=mx.distanceTo(e.center);return fo.radius=.7071067811865476+t,fo.applyMatrix4(e.matrixWorld),this.intersectsSphere(fo)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let r=t[i];if(zu.x=r.normal.x>0?e.max.x:e.min.x,zu.y=r.normal.y>0?e.max.y:e.min.y,zu.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(zu)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var gc=class extends Cr{constructor(e=[],t=qs,i,r,a,s,o,u,l,d){super(e,t,i,r,a,s,o,u,l,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var Hs=class extends Cr{constructor(e,t,i=za,r,a,s,o=ar,u=ar,l,d=Ka,f=1){if(d!==Ka&&d!==Zs)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:f};super(h,r,a,s,o,u,d,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new il(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},ad=class extends Hs{constructor(e,t=za,i=qs,r,a,s=ar,o=ar,u,l=Ka){let d={width:e,height:e,depth:1},f=[d,d,d,d,d,d];super(e,e,t,i,r,a,s,o,u,l),this.image=f,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},yc=class extends Cr{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},jr=class n extends pr{constructor(e=1,t=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};let o=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);let u=[],l=[],d=[],f=[],h=0,m=0;x("z","y","x",-1,-1,i,t,e,s,a,0),x("z","y","x",1,-1,i,t,-e,s,a,1),x("x","z","y",1,1,e,i,t,r,s,2),x("x","z","y",1,-1,e,i,-t,r,s,3),x("x","y","z",1,-1,e,t,i,r,a,4),x("x","y","z",-1,-1,e,t,-i,r,a,5),this.setIndex(u),this.setAttribute("position",new Ci(l,3)),this.setAttribute("normal",new Ci(d,3)),this.setAttribute("uv",new Ci(f,2));function x(_,g,v,F,P,S,N,p,L,E,D){let X=S/L,Y=N/E,W=S/2,C=N/2,M=p/2,J=L+1,q=E+1,ce=0,k=0,G=new Se;for(let te=0;te<q;te++){let le=te*Y-C;for(let ge=0;ge<J;ge++){let oe=ge*X-W;G[_]=oe*F,G[g]=le*P,G[v]=M,l.push(G.x,G.y,G.z),G[_]=0,G[g]=0,G[v]=p>0?1:-1,d.push(G.x,G.y,G.z),f.push(ge/L),f.push(1-te/E),ce+=1}}for(let te=0;te<E;te++)for(let le=0;le<L;le++){let ge=h+le+J*te,oe=h+le+J*(te+1),$=h+(le+1)+J*(te+1),Te=h+(le+1)+J*te;u.push(ge,oe,Te),u.push(oe,$,Te),k+=6}o.addGroup(m,k,D),m+=k,h+=ce}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var ul=class n extends pr{constructor(e=1,t=32,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);let a=[],s=[],o=[],u=[],l=new Se,d=new ln;s.push(0,0,0),o.push(0,0,1),u.push(.5,.5);for(let f=0,h=3;f<=t;f++,h+=3){let m=i+f/t*r;l.x=e*Math.cos(m),l.y=e*Math.sin(m),s.push(l.x,l.y,l.z),o.push(0,0,1),d.x=(s[h]/e+1)/2,d.y=(s[h+1]/e+1)/2,u.push(d.x,d.y)}for(let f=1;f<=t;f++)a.push(f,f+1,0);this.setIndex(a),this.setAttribute("position",new Ci(s,3)),this.setAttribute("normal",new Ci(o,3)),this.setAttribute("uv",new Ci(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.segments,e.thetaStart,e.thetaLength)}},po=class n extends pr{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,o=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:o,thetaLength:u};let l=this;r=Math.floor(r),a=Math.floor(a);let d=[],f=[],h=[],m=[],x=0,_=[],g=i/2,v=0;F(),s===!1&&(e>0&&P(!0),t>0&&P(!1)),this.setIndex(d),this.setAttribute("position",new Ci(f,3)),this.setAttribute("normal",new Ci(h,3)),this.setAttribute("uv",new Ci(m,2));function F(){let S=new Se,N=new Se,p=0,L=(t-e)/i;for(let E=0;E<=a;E++){let D=[],X=E/a,Y=X*(t-e)+e;for(let W=0;W<=r;W++){let C=W/r,M=C*u+o,J=Math.sin(M),q=Math.cos(M);N.x=Y*J,N.y=-X*i+g,N.z=Y*q,f.push(N.x,N.y,N.z),S.set(J,L,q).normalize(),h.push(S.x,S.y,S.z),m.push(C,1-X),D.push(x++)}_.push(D)}for(let E=0;E<r;E++)for(let D=0;D<a;D++){let X=_[D][E],Y=_[D+1][E],W=_[D+1][E+1],C=_[D][E+1];(e>0||D!==0)&&(d.push(X,Y,C),p+=3),(t>0||D!==a-1)&&(d.push(Y,W,C),p+=3)}l.addGroup(v,p,0),v+=p}function P(S){let N=x,p=new ln,L=new Se,E=0,D=S===!0?e:t,X=S===!0?1:-1;for(let W=1;W<=r;W++)f.push(0,g*X,0),h.push(0,X,0),m.push(.5,.5),x++;let Y=x;for(let W=0;W<=r;W++){let M=W/r*u+o,J=Math.cos(M),q=Math.sin(M);L.x=D*q,L.y=g*X,L.z=D*J,f.push(L.x,L.y,L.z),h.push(0,X,0),p.x=J*.5+.5,p.y=q*.5*X+.5,m.push(p.x,p.y),x++}for(let W=0;W<r;W++){let C=N+W,M=Y+W;S===!0?d.push(M,M+1,C):d.push(M+1,M,C),E+=3}l.addGroup(v,E,S===!0?1:2),v+=E}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}};var ha=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Rn("Curve: .getPoint() not implemented.")}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let i=this.getLengths(),r=0,a=i.length,s;t?s=t:s=e*i[a-1];let o=0,u=a-1,l;for(;o<=u;)if(r=Math.floor(o+(u-o)/2),l=i[r]-s,l<0)o=r+1;else if(l>0)u=r-1;else{u=r;break}if(r=u,i[r]===s)return r/(a-1);let d=i[r],h=i[r+1]-d,m=(s-d)/h;return(r+m)/(a-1)}getTangent(e,t){let r=e-1e-4,a=e+1e-4;r<0&&(r=0),a>1&&(a=1);let s=this.getPoint(r),o=this.getPoint(a),u=t||(s.isVector2?new ln:new Se);return u.copy(o).sub(s).normalize(),u}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){let i=new Se,r=[],a=[],s=[],o=new Se,u=new Jn;for(let m=0;m<=e;m++){let x=m/e;r[m]=this.getTangentAt(x,new Se)}a[0]=new Se,s[0]=new Se;let l=Number.MAX_VALUE,d=Math.abs(r[0].x),f=Math.abs(r[0].y),h=Math.abs(r[0].z);d<=l&&(l=d,i.set(1,0,0)),f<=l&&(l=f,i.set(0,1,0)),h<=l&&i.set(0,0,1),o.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],o),s[0].crossVectors(r[0],a[0]);for(let m=1;m<=e;m++){if(a[m]=a[m-1].clone(),s[m]=s[m-1].clone(),o.crossVectors(r[m-1],r[m]),o.length()>Number.EPSILON){o.normalize();let x=Math.acos(pi(r[m-1].dot(r[m]),-1,1));a[m].applyMatrix4(u.makeRotationAxis(o,x))}s[m].crossVectors(r[m],a[m])}if(t===!0){let m=Math.acos(pi(a[0].dot(a[e]),-1,1));m/=e,r[0].dot(o.crossVectors(a[0],a[e]))>0&&(m=-m);for(let x=1;x<=e;x++)a[x].applyMatrix4(u.makeRotationAxis(r[x],m*x)),s[x].crossVectors(r[x],a[x])}return{tangents:r,normals:a,binormals:s}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},dl=class extends ha{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,o=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=o,this.aRotation=u}getPoint(e,t=new ln){let i=t,r=Math.PI*2,a=this.aEndAngle-this.aStartAngle,s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);let o=this.aStartAngle+e*a,u=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let d=Math.cos(this.aRotation),f=Math.sin(this.aRotation),h=u-this.aX,m=l-this.aY;u=h*d-m*f+this.aX,l=h*f+m*d+this.aY}return i.set(u,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},sd=class extends dl{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}};function Sp(){let n=0,e=0,t=0,i=0;function r(a,s,o,u){n=a,e=o,t=-3*a+3*s-2*o-u,i=2*a-2*s+o+u}return{initCatmullRom:function(a,s,o,u,l){r(s,o,l*(o-a),l*(u-s))},initNonuniformCatmullRom:function(a,s,o,u,l,d,f){let h=(s-a)/l-(o-a)/(l+d)+(o-s)/d,m=(o-s)/d-(u-s)/(d+f)+(u-o)/f;h*=d,m*=d,r(s,o,h,m)},calc:function(a){let s=a*a,o=s*a;return n+e*a+t*s+i*o}}}var Pv=new Se,Lv=new Se,kh=new Sp,zh=new Sp,Vh=new Sp,od=class extends ha{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new Se){let i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e,o=Math.floor(s),u=s-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/a)+1)*a:u===0&&o===a-1&&(o=a-2,u=1);let l,d;this.closed||o>0?l=r[(o-1)%a]:(Lv.subVectors(r[0],r[1]).add(r[0]),l=Lv);let f=r[o%a],h=r[(o+1)%a];if(this.closed||o+2<a?d=r[(o+2)%a]:(Pv.subVectors(r[a-1],r[a-2]).add(r[a-1]),d=Pv),this.curveType==="centripetal"||this.curveType==="chordal"){let m=this.curveType==="chordal"?.5:.25,x=Math.pow(l.distanceToSquared(f),m),_=Math.pow(f.distanceToSquared(h),m),g=Math.pow(h.distanceToSquared(d),m);_<1e-4&&(_=1),x<1e-4&&(x=_),g<1e-4&&(g=_),kh.initNonuniformCatmullRom(l.x,f.x,h.x,d.x,x,_,g),zh.initNonuniformCatmullRom(l.y,f.y,h.y,d.y,x,_,g),Vh.initNonuniformCatmullRom(l.z,f.z,h.z,d.z,x,_,g)}else this.curveType==="catmullrom"&&(kh.initCatmullRom(l.x,f.x,h.x,d.x,this.tension),zh.initCatmullRom(l.y,f.y,h.y,d.y,this.tension),Vh.initCatmullRom(l.z,f.z,h.z,d.z,this.tension));return i.set(kh.calc(u),zh.calc(u),Vh.calc(u)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new Se().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function Dv(n,e,t,i,r){let a=(i-e)*.5,s=(r-t)*.5,o=n*n,u=n*o;return(2*t-2*i+a+s)*u+(-3*t+3*i-2*a-s)*o+a*n+t}function vx(n,e){let t=1-n;return t*t*e}function gx(n,e){return 2*(1-n)*n*e}function yx(n,e){return n*n*e}function ac(n,e,t,i){return vx(n,e)+gx(n,t)+yx(n,i)}function xx(n,e){let t=1-n;return t*t*t*e}function _x(n,e){let t=1-n;return 3*t*t*n*e}function Mx(n,e){return 3*(1-n)*n*n*e}function Sx(n,e){return n*n*n*e}function sc(n,e,t,i,r){return xx(n,e)+_x(n,t)+Mx(n,i)+Sx(n,r)}var xc=class extends ha{constructor(e=new ln,t=new ln,i=new ln,r=new ln){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new ln){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(sc(e,r.x,a.x,s.x,o.x),sc(e,r.y,a.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ld=class extends ha{constructor(e=new Se,t=new Se,i=new Se,r=new Se){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Se){let i=t,r=this.v0,a=this.v1,s=this.v2,o=this.v3;return i.set(sc(e,r.x,a.x,s.x,o.x),sc(e,r.y,a.y,s.y,o.y),sc(e,r.z,a.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},_c=class extends ha{constructor(e=new ln,t=new ln){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ln){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ln){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},cd=class extends ha{constructor(e=new Se,t=new Se){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new Se){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Se){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Mc=class extends ha{constructor(e=new ln,t=new ln,i=new ln){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new ln){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(ac(e,r.x,a.x,s.x),ac(e,r.y,a.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ud=class extends ha{constructor(e=new Se,t=new Se,i=new Se){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Se){let i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(ac(e,r.x,a.x,s.x),ac(e,r.y,a.y,s.y),ac(e,r.z,a.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Sc=class extends ha{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ln){let i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),o=a-s,u=r[s===0?s:s-1],l=r[s],d=r[s>r.length-2?r.length-1:s+1],f=r[s>r.length-3?r.length-1:s+2];return i.set(Dv(o,u.x,l.x,d.x,f.x),Dv(o,u.y,l.y,d.y,f.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new ln().fromArray(r))}return this}},Nv=Object.freeze({__proto__:null,ArcCurve:sd,CatmullRomCurve3:od,CubicBezierCurve:xc,CubicBezierCurve3:ld,EllipseCurve:dl,LineCurve:_c,LineCurve3:cd,QuadraticBezierCurve:Mc,QuadraticBezierCurve3:ud,SplineCurve:Sc}),dd=class extends ha{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Nv[i](t,e))}return this}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),a=0;for(;a<r.length;){if(r[a]>=i){let s=r[a]-i,o=this.curves[a],u=o.getLength(),l=u===0?0:1-s/u;return o.getPointAt(l,t)}a++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,a=this.curves;r<a.length;r++){let s=a[r],o=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,u=s.getPoints(o);for(let l=0;l<u.length;l++){let d=u[l];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new Nv[r.type]().fromJSON(r))}return this}},mo=class extends dd{constructor(e){super(),this.type="Path",this.currentPoint=new ln,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new _c(this.currentPoint.clone(),new ln(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let a=new Mc(this.currentPoint.clone(),new ln(e,t),new ln(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){let o=new xc(this.currentPoint.clone(),new ln(e,t),new ln(i,r),new ln(a,s));return this.curves.push(o),this.currentPoint.set(a,s),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Sc(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){let o=this.currentPoint.x,u=this.currentPoint.y;return this.absarc(e+o,t+u,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,o,u){let l=this.currentPoint.x,d=this.currentPoint.y;return this.absellipse(e+l,t+d,i,r,a,s,o,u),this}absellipse(e,t,i,r,a,s,o,u){let l=new dl(e,t,i,r,a,s,o,u);if(this.curves.length>0){let f=l.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(l);let d=l.getPoint(1);return this.currentPoint.copy(d),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},fl=class extends mo{constructor(e){super(e),this.uuid=_o(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new mo().fromJSON(r))}return this}};function bx(n,e,t=2){let i=e&&e.length,r=i?e[0]*t:n.length,a=R0(n,0,r,t,!0),s=[];if(!a||a.next===a.prev)return s;let o,u,l;if(i&&(a=Ix(n,e,a,t)),n.length>80*t){o=n[0],u=n[1];let d=o,f=u;for(let h=t;h<r;h+=t){let m=n[h],x=n[h+1];m<o&&(o=m),x<u&&(u=x),m>d&&(d=m),x>f&&(f=x)}l=Math.max(d-o,f-u),l=l!==0?32767/l:0}return bc(a,s,t,o,u,l,0),s}function R0(n,e,t,i,r){let a;if(r===kx(n,e,t,i)>0)for(let s=e;s<t;s+=i)a=Uv(s/i|0,n[s],n[s+1],a);else for(let s=t-i;s>=e;s-=i)a=Uv(s/i|0,n[s],n[s+1],a);return a&&hl(a,a.next)&&(Tc(a),a=a.next),a}function vo(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(hl(t,t.next)||Ki(t.prev,t,t.next)===0)){if(Tc(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function bc(n,e,t,i,r,a,s){if(!n)return;!s&&a&&Dx(n,i,r,a);let o=n;for(;n.prev!==n.next;){let u=n.prev,l=n.next;if(a?Tx(n,i,r,a):wx(n)){e.push(u.i,n.i,l.i),Tc(n),n=l.next,o=l.next;continue}if(n=l,n===o){s?s===1?(n=Ex(vo(n),e),bc(n,e,t,i,r,a,2)):s===2&&Ax(n,e,t,i,r,a):bc(vo(n),e,t,i,r,a,1);break}}}function wx(n){let e=n.prev,t=n,i=n.next;if(Ki(e,t,i)>=0)return!1;let r=e.x,a=t.x,s=i.x,o=e.y,u=t.y,l=i.y,d=Math.min(r,a,s),f=Math.min(o,u,l),h=Math.max(r,a,s),m=Math.max(o,u,l),x=i.next;for(;x!==e;){if(x.x>=d&&x.x<=h&&x.y>=f&&x.y<=m&&rc(r,o,a,u,s,l,x.x,x.y)&&Ki(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function Tx(n,e,t,i){let r=n.prev,a=n,s=n.next;if(Ki(r,a,s)>=0)return!1;let o=r.x,u=a.x,l=s.x,d=r.y,f=a.y,h=s.y,m=Math.min(o,u,l),x=Math.min(d,f,h),_=Math.max(o,u,l),g=Math.max(d,f,h),v=Jh(m,x,e,t,i),F=Jh(_,g,e,t,i),P=n.prevZ,S=n.nextZ;for(;P&&P.z>=v&&S&&S.z<=F;){if(P.x>=m&&P.x<=_&&P.y>=x&&P.y<=g&&P!==r&&P!==s&&rc(o,d,u,f,l,h,P.x,P.y)&&Ki(P.prev,P,P.next)>=0||(P=P.prevZ,S.x>=m&&S.x<=_&&S.y>=x&&S.y<=g&&S!==r&&S!==s&&rc(o,d,u,f,l,h,S.x,S.y)&&Ki(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;P&&P.z>=v;){if(P.x>=m&&P.x<=_&&P.y>=x&&P.y<=g&&P!==r&&P!==s&&rc(o,d,u,f,l,h,P.x,P.y)&&Ki(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;S&&S.z<=F;){if(S.x>=m&&S.x<=_&&S.y>=x&&S.y<=g&&S!==r&&S!==s&&rc(o,d,u,f,l,h,S.x,S.y)&&Ki(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function Ex(n,e){let t=n;do{let i=t.prev,r=t.next.next;!hl(i,r)&&L0(i,t,t.next,r)&&wc(i,r)&&wc(r,i)&&(e.push(i.i,t.i,r.i),Tc(t),Tc(t.next),t=n=r),t=t.next}while(t!==n);return vo(t)}function Ax(n,e,t,i,r,a){let s=n;do{let o=s.next.next;for(;o!==s.prev;){if(s.i!==o.i&&Fx(s,o)){let u=D0(s,o);s=vo(s,s.next),u=vo(u,u.next),bc(s,e,t,i,r,a,0),bc(u,e,t,i,r,a,0);return}o=o.next}s=s.next}while(s!==n)}function Ix(n,e,t,i){let r=[];for(let a=0,s=e.length;a<s;a++){let o=e[a]*i,u=a<s-1?e[a+1]*i:n.length,l=R0(n,o,u,i,!1);l===l.next&&(l.steiner=!0),r.push(Ux(l))}r.sort(Cx);for(let a=0;a<r.length;a++)t=Rx(r[a],t);return t}function Cx(n,e){let t=n.x-e.x;if(t===0&&(t=n.y-e.y,t===0)){let i=(n.next.y-n.y)/(n.next.x-n.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=i-r}return t}function Rx(n,e){let t=Px(n,e);if(!t)return e;let i=D0(t,n);return vo(i,i.next),vo(t,t.next)}function Px(n,e){let t=e,i=n.x,r=n.y,a=-1/0,s;if(hl(n,t))return t;do{if(hl(n,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){let f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=i&&f>a&&(a=f,s=t.x<t.next.x?t:t.next,f===i))return s}t=t.next}while(t!==e);if(!s)return null;let o=s,u=s.x,l=s.y,d=1/0;t=s;do{if(i>=t.x&&t.x>=u&&i!==t.x&&P0(r<l?i:a,r,u,l,r<l?a:i,r,t.x,t.y)){let f=Math.abs(r-t.y)/(i-t.x);wc(t,n)&&(f<d||f===d&&(t.x>s.x||t.x===s.x&&Lx(s,t)))&&(s=t,d=f)}t=t.next}while(t!==o);return s}function Lx(n,e){return Ki(n.prev,n,e.prev)<0&&Ki(e.next,n,n.next)<0}function Dx(n,e,t,i){let r=n;do r.z===0&&(r.z=Jh(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,Nx(r)}function Nx(n){let e,t=1;do{let i=n,r;n=null;let a=null;for(e=0;i;){e++;let s=i,o=0;for(let l=0;l<t&&(o++,s=s.nextZ,!!s);l++);let u=t;for(;o>0||u>0&&s;)o!==0&&(u===0||!s||i.z<=s.z)?(r=i,i=i.nextZ,o--):(r=s,s=s.nextZ,u--),a?a.nextZ=r:n=r,r.prevZ=a,a=r;i=s}a.nextZ=null,t*=2}while(e>1);return n}function Jh(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Ux(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function P0(n,e,t,i,r,a,s,o){return(r-s)*(e-o)>=(n-s)*(a-o)&&(n-s)*(i-o)>=(t-s)*(e-o)&&(t-s)*(a-o)>=(r-s)*(i-o)}function rc(n,e,t,i,r,a,s,o){return!(n===s&&e===o)&&P0(n,e,t,i,r,a,s,o)}function Fx(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Ox(n,e)&&(wc(n,e)&&wc(e,n)&&Bx(n,e)&&(Ki(n.prev,n,e.prev)||Ki(n,e.prev,e))||hl(n,e)&&Ki(n.prev,n,n.next)>0&&Ki(e.prev,e,e.next)>0)}function Ki(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function hl(n,e){return n.x===e.x&&n.y===e.y}function L0(n,e,t,i){let r=Gu(Ki(n,e,t)),a=Gu(Ki(n,e,i)),s=Gu(Ki(t,i,n)),o=Gu(Ki(t,i,e));return!!(r!==a&&s!==o||r===0&&Vu(n,t,e)||a===0&&Vu(n,i,e)||s===0&&Vu(t,n,i)||o===0&&Vu(t,e,i))}function Vu(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Gu(n){return n>0?1:n<0?-1:0}function Ox(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&L0(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function wc(n,e){return Ki(n.prev,n,n.next)<0?Ki(n,e,n.next)>=0&&Ki(n,n.prev,e)>=0:Ki(n,e,n.prev)<0||Ki(n,n.next,e)<0}function Bx(n,e){let t=n,i=!1,r=(n.x+e.x)/2,a=(n.y+e.y)/2;do t.y>a!=t.next.y>a&&t.next.y!==t.y&&r<(t.next.x-t.x)*(a-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function D0(n,e){let t=$h(n.i,n.x,n.y),i=$h(e.i,e.x,e.y),r=n.next,a=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,a.next=i,i.prev=a,i}function Uv(n,e,t,i){let r=$h(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Tc(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function $h(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function kx(n,e,t,i){let r=0;for(let a=e,s=t-i;a<t;a+=i)r+=(n[s]-n[a])*(n[a+1]+n[s+1]),s=a;return r}var Kh=class{static triangulate(e,t,i=2){return bx(e,t,i)}},Qo=class n{static area(e){let t=e.length,i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return n.area(e)<0}static triangulateShape(e,t){let i=[],r=[],a=[];Fv(e),Ov(i,e);let s=e.length;t.forEach(Fv);for(let u=0;u<t.length;u++)r.push(s),s+=t[u].length,Ov(i,t[u]);let o=Kh.triangulate(i,r);for(let u=0;u<o.length;u+=3)a.push(o.slice(u,u+3));return a}};function Fv(n){let e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Ov(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}var Ec=class n extends pr{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};let a=e/2,s=t/2,o=Math.floor(i),u=Math.floor(r),l=o+1,d=u+1,f=e/o,h=t/u,m=[],x=[],_=[],g=[];for(let v=0;v<d;v++){let F=v*h-s;for(let P=0;P<l;P++){let S=P*f-a;x.push(S,-F,0),_.push(0,0,1),g.push(P/o),g.push(1-v/u)}}for(let v=0;v<u;v++)for(let F=0;F<o;F++){let P=F+l*v,S=F+l*(v+1),N=F+1+l*(v+1),p=F+1+l*v;m.push(P,S,p),m.push(S,N,p)}this.setIndex(m),this.setAttribute("position",new Ci(x,3)),this.setAttribute("normal",new Ci(_,3)),this.setAttribute("uv",new Ci(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.widthSegments,e.heightSegments)}},pl=class n extends pr{constructor(e=.5,t=1,i=32,r=1,a=0,s=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:a,thetaLength:s},i=Math.max(3,i),r=Math.max(1,r);let o=[],u=[],l=[],d=[],f=e,h=(t-e)/r,m=new Se,x=new ln;for(let _=0;_<=r;_++){for(let g=0;g<=i;g++){let v=a+g/i*s;m.x=f*Math.cos(v),m.y=f*Math.sin(v),u.push(m.x,m.y,m.z),l.push(0,0,1),x.x=(m.x/t+1)/2,x.y=(m.y/t+1)/2,d.push(x.x,x.y)}f+=h}for(let _=0;_<r;_++){let g=_*(i+1);for(let v=0;v<i;v++){let F=v+g,P=F,S=F+i+1,N=F+i+2,p=F+1;o.push(P,S,p),o.push(S,N,p)}}this.setIndex(o),this.setAttribute("position",new Ci(u,3)),this.setAttribute("normal",new Ci(l,3)),this.setAttribute("uv",new Ci(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},Ac=class n extends pr{constructor(e=new fl([new ln(0,.5),new ln(-.5,-.5),new ln(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],r=[],a=[],s=[],o=0,u=0;if(Array.isArray(e)===!1)l(e);else for(let d=0;d<e.length;d++)l(e[d]),this.addGroup(o,u,d),o+=u,u=0;this.setIndex(i),this.setAttribute("position",new Ci(r,3)),this.setAttribute("normal",new Ci(a,3)),this.setAttribute("uv",new Ci(s,2));function l(d){let f=r.length/3,h=d.extractPoints(t),m=h.shape,x=h.holes;Qo.isClockWise(m)===!1&&(m=m.reverse());for(let g=0,v=x.length;g<v;g++){let F=x[g];Qo.isClockWise(F)===!0&&(x[g]=F.reverse())}let _=Qo.triangulateShape(m,x);for(let g=0,v=x.length;g<v;g++){let F=x[g];m=m.concat(F)}for(let g=0,v=m.length;g<v;g++){let F=m[g];r.push(F.x,F.y,0),a.push(0,0,1),s.push(F.x,F.y)}for(let g=0,v=_.length;g<v;g++){let F=_[g],P=F[0]+f,S=F[1]+f,N=F[2]+f;i.push(P,S,N),u+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return zx(t,e)}static fromJSON(e,t){let i=[];for(let r=0,a=e.shapes.length;r<a;r++){let s=t[e.shapes[r]];i.push(s)}return new n(i,e.curveSegments)}};function zx(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){let r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}var Ss=class n extends pr{constructor(e=1,t=32,i=16,r=0,a=Math.PI*2,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:a,thetaStart:s,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let u=Math.min(s+o,Math.PI),l=0,d=[],f=new Se,h=new Se,m=[],x=[],_=[],g=[];for(let v=0;v<=i;v++){let F=[],P=v/i,S=s+P*o,N=e*Math.cos(S),p=Math.sqrt(e*e-N*N),L=0;v===0&&s===0?L=.5/t:v===i&&u===Math.PI&&(L=-.5/t);for(let E=0;E<=t;E++){let D=E/t,X=r+D*a;f.x=-p*Math.cos(X),f.y=N,f.z=p*Math.sin(X),x.push(f.x,f.y,f.z),h.copy(f).normalize(),_.push(h.x,h.y,h.z),g.push(D+L,1-P),F.push(l++)}d.push(F)}for(let v=0;v<i;v++)for(let F=0;F<t;F++){let P=d[v][F+1],S=d[v][F],N=d[v+1][F],p=d[v+1][F+1];(v!==0||s>0)&&m.push(P,S,p),(v!==i-1||u<Math.PI)&&m.push(S,N,p)}this.setIndex(m),this.setAttribute("position",new Ci(x,3)),this.setAttribute("normal",new Ci(_,3)),this.setAttribute("uv",new Ci(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};function Mo(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let r=n[t][i];if(Bv(r))r.isRenderTargetTexture?(Rn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone();else if(Array.isArray(r))if(Bv(r[0])){let a=[];for(let s=0,o=r.length;s<o;s++)a[s]=r[s].clone();e[t][i]=a}else e[t][i]=r.slice();else e[t][i]=r}}return e}function Hr(n){let e={};for(let t=0;t<n.length;t++){let i=Mo(n[t]);for(let r in i)e[r]=i[r]}return e}function Bv(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}function Vx(n){let e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function bp(n){let e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:vi.workingColorSpace}var N0={clone:Mo,merge:Hr},Gx=`void main() {
2
2
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
- }`,by=`void main() {
3
+ }`,Hx=`void main() {
4
4
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
- }`,kr=class extends cs{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Sy,this.fragmentShader=by,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Bs(e.uniforms),this.uniformsGroups=My(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let i in e.uniforms){let r=e.uniforms[i];switch(this.uniforms[i]={},r.type){case"t":this.uniforms[i].value=t[r.value]||null;break;case"c":this.uniforms[i].value=new vn().setHex(r.value);break;case"v2":this.uniforms[i].value=new kt().fromArray(r.value);break;case"v3":this.uniforms[i].value=new ge().fromArray(r.value);break;case"v4":this.uniforms[i].value=new fi().fromArray(r.value);break;case"m3":this.uniforms[i].value=new un().fromArray(r.value);break;case"m4":this.uniforms[i].value=new $n().fromArray(r.value);break;default:this.uniforms[i].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},vu=class extends kr{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var Xi=class extends cs{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new vn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new vn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Md,this.normalScale=new kt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xa,this.combine=Nu,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},gu=class extends cs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=o0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},yu=class extends cs{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function oo(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function zf(n){return n!==void 0&&n.inTangents!==void 0&&n.outTangents!==void 0}var fs=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;n:{i:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<a)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break n}if(!(e>=a)){let o=t[1];e<o&&(i=2,a=o);for(let u=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===u)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break n}break e}for(;i<s;){let o=i+s>>>1;e<t[o]?s=o:i=o+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},xu=class extends fs{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Hf,endingEnd:Hf}}intervalChanged_(e,t,i){let r=this.parameterPositions,a=e-2,s=e+1,o=r[a],u=r[s];if(o===void 0)switch(this.getSettings_().endingStart){case Wf:a=e,o=2*t-i;break;case Xf:a=r.length-2,o=t+r[a]-r[a+1];break;default:a=e,o=i}if(u===void 0)switch(this.getSettings_().endingEnd){case Wf:s=e,u=2*i-t;break;case Xf:s=1,u=i+r[1]-r[0];break;default:s=e-1,u=t}let l=(i-t)*.5,d=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(u-i),this._offsetPrev=a*d,this._offsetNext=s*d}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=this._offsetPrev,f=this._offsetNext,h=this._weightPrev,v=this._weightNext,y=(i-t)/(r-t),T=y*y,g=T*y,m=-h*g+2*h*T-h*y,L=(1+h)*g+(-1.5-2*h)*T+(-.5+h)*y+1,F=(-1-v)*g+(1.5+v)*T+.5*y,_=v*g-v*T;for(let p=0;p!==o;++p)a[p]=m*s[d+p]+L*s[l+p]+F*s[u+p]+_*s[f+p];return a}},_u=class extends fs{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=(i-t)/(r-t),f=1-d;for(let h=0;h!==o;++h)a[h]=s[l+h]*f+s[u+h]*d;return a}},Mu=class extends fs{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Su=class extends fs{interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=this.inTangents,f=this.outTangents;if(!d||!f){let y=(i-t)/(r-t),T=1-y;for(let g=0;g!==o;++g)a[g]=s[l+g]*T+s[u+g]*y;return a}let h=o*2,v=e-1;for(let y=0;y!==o;++y){let T=s[l+y],g=s[u+y],m=v*h+y*2,L=f[m],F=f[m+1],_=e*h+y*2,p=d[_],S=d[_+1],B=Ty(i,t,L,p,r);a[y]=A0(B,T,F,S,g)}return a}};function A0(n,e,t,i,r){let a=1-n;return a*a*a*e+3*a*a*n*t+3*a*n*n*i+n*n*n*r}function wy(n,e,t,i,r){let a=1-n;return 3*a*a*(t-e)+6*a*n*(i-t)+3*n*n*(r-i)}function Ty(n,e,t,i,r){let a=(n-e)/(r-e);for(let s=0;s<8;s++){let o=A0(a,e,t,i,r)-n;if(Math.abs(o)<1e-10)break;let u=wy(a,e,t,i,r);if(Math.abs(u)<1e-10)break;a=Math.max(0,Math.min(1,a-o/u))}return a}var zr=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=oo(t,this.TimeBufferType),this.values=oo(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:oo(e.times,Array),values:oo(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r),zf(e.settings)&&(i.settings={inTangents:oo(e.settings.inTangents,Array),outTangents:oo(e.settings.outTangents,Array)})}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new Mu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new _u(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new xu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new Su(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case dl:t=this.InterpolantFactoryMethodDiscrete;break;case ru:t=this.InterpolantFactoryMethodLinear;break;case qc:t=this.InterpolantFactoryMethodSmooth;break;case Gf:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return rn("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return dl;case this.InterpolantFactoryMethodLinear:return ru;case this.InterpolantFactoryMethodSmooth:return qc;case this.InterpolantFactoryMethodBezier:return Gf}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e;zf(this.settings)&&(Pm(this.settings.inTangents,e),Pm(this.settings.outTangents,e))}return this}trim(e,t){let i=this.times,r=i.length,a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);let o=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(sn("KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;a===0&&(sn("KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let o=0;o!==a;o++){let u=i[o];if(typeof u=="number"&&isNaN(u)){sn("KeyframeTrack: Time is not a valid number.",this,o,u),e=!1;break}if(s!==null&&s>u){sn("KeyframeTrack: Out of order keys.",this,o,u,s),e=!1;break}s=u}if(r!==void 0&&Cg(r))for(let o=0,u=r.length;o!==u;++o){let l=r[o];if(isNaN(l)){sn("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===qc,a=e.length-1,s=1;for(let o=1;o<a;++o){let u=!1,l=e[o],d=e[o+1];if(l!==d&&(o!==1||l!==e[0]))if(r)u=!0;else{let f=o*i,h=f-i,v=f+i;for(let y=0;y!==i;++y){let T=t[f+y];if(T!==t[h+y]||T!==t[v+y]){u=!0;break}}}if(u){if(o!==s){e[s]=e[o];let f=o*i,h=s*i;for(let v=0;v!==i;++v)t[h+v]=t[f+v]}++s}}if(a>0){e[s]=e[a];for(let o=a*i,u=s*i,l=0;l!==i;++l)t[u+l]=t[o+l];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,zf(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function Pm(n,e){for(let t=0,i=n.length;t!==i;t+=2)n[t]*=e}zr.prototype.ValueTypeName="";zr.prototype.TimeBufferType=Float32Array;zr.prototype.ValueBufferType=Float32Array;zr.prototype.DefaultInterpolation=ru;var hs=class extends zr{constructor(e,t,i){super(e,t,i)}};hs.prototype.ValueTypeName="bool";hs.prototype.ValueBufferType=Array;hs.prototype.DefaultInterpolation=dl;hs.prototype.InterpolantFactoryMethodLinear=void 0;hs.prototype.InterpolantFactoryMethodSmooth=void 0;var bu=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}};bu.prototype.ValueTypeName="color";var wu=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}};wu.prototype.ValueTypeName="number";var Tu=class extends fs{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=(i-t)/(r-t),l=e*o;for(let d=l+o;l!==d;l+=4)ba.slerpFlat(a,0,s,l-o,s,l,u);return a}},Dl=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new Tu(this.times,this.values,this.getValueSize(),e)}};Dl.prototype.ValueTypeName="quaternion";Dl.prototype.InterpolantFactoryMethodSmooth=void 0;var ps=class extends zr{constructor(e,t,i){super(e,t,i)}};ps.prototype.ValueTypeName="string";ps.prototype.ValueBufferType=Array;ps.prototype.DefaultInterpolation=dl;ps.prototype.InterpolantFactoryMethodLinear=void 0;ps.prototype.InterpolantFactoryMethodSmooth=void 0;var Eu=class extends zr{constructor(e,t,i,r){super(e,t,i,r)}};Eu.prototype.ValueTypeName="vector";var Au=class{constructor(e,t,i){let r=this,a=!1,s=0,o=0,u,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(d){o++,a===!1&&r.onStart!==void 0&&r.onStart(d,s,o),a=!0},this.itemEnd=function(d){s++,r.onProgress!==void 0&&r.onProgress(d,s,o),s===o&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return d=d.normalize("NFC"),u?u(d):d},this.setURLModifier=function(d){return u=d,this},this.addHandler=function(d,f){return l.push(d,f),this},this.removeHandler=function(d){let f=l.indexOf(d);return f!==-1&&l.splice(f,2),this},this.getHandler=function(d){for(let f=0,h=l.length;f<h;f+=2){let v=l[f],y=l[f+1];if(v.global&&(v.lastIndex=0),v.test(d))return y}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},I0=new Au,Iu=class{constructor(e){this.manager=e!==void 0?e:I0,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};Iu.DEFAULT_MATERIAL_NAME="__DEFAULT";var Nl=class extends nr{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new vn(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},Ul=class extends Nl{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(nr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new vn(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Vf=new $n,Lm=new ge,Dm=new ge,Cu=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new kt(512,512),this.mapType=Cr,this.map=null,this.mapPass=null,this.matrix=new $n,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new xo,this._frameExtents=new kt(1,1),this._viewportCount=1,this._viewports=[new fi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Lm.setFromMatrixPosition(e.matrixWorld),t.position.copy(Lm),Dm.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Dm),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,i,r){Vf.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),i.setFromProjectionMatrix(Vf,e.coordinateSystem,e.reversedDepth);let a=this._frameExtents,s=r?r.z/a.x:1,o=r?r.w/a.y:1,u=r?r.x/a.x:0,l=r?r.y/a.y:0;e.coordinateSystem===po||e.reversedDepth?t.set(.5*s,0,0,.5*s+u,0,.5*o,0,.5*o+l,0,0,1,0,0,0,0,1):t.set(.5*s,0,0,.5*s+u,0,.5*o,0,.5*o+l,0,0,.5,.5,0,0,0,1),t.multiply(Vf)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Xc=new ge,Yc=new ba,xa=new ge,Fl=class extends nr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new $n,this.projectionMatrix=new $n,this.projectionMatrixInverse=new $n,this.coordinateSystem=ra,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Xc,Yc,xa),xa.x===1&&xa.y===1&&xa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Xc,Yc,xa.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(Xc,Yc,xa),xa.x===1&&xa.y===1&&xa.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Xc,Yc,xa.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},ss=new ge,Nm=new kt,Um=new kt,er=class extends Fl{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=au*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(vf*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return au*2*Math.atan(Math.tan(vf*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){ss.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ss.x,ss.y).multiplyScalar(-e/ss.z),ss.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ss.x,ss.y).multiplyScalar(-e/ss.z)}getViewSize(e,t){return this.getViewBounds(e,Nm,Um),t.subVectors(Um,Nm)}setViewOffset(e,t,i,r,a,s){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(vf*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,a=-.5*r,s=this.view;if(this.view!==null&&this.view.enabled){let u=s.fullWidth,l=s.fullHeight;a+=s.offsetX*r/u,t-=s.offsetY*i/l,r*=s.width/u,i*=s.height/l}let o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};var To=class extends Fl{constructor(e=-1,t=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,a=i-e,s=i+e,o=r+t,u=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=l*this.view.offsetX,s=a+l*this.view.width,o-=d*this.view.offsetY,u=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,u,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Jf=class extends Cu{constructor(){super(new To(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Ol=class extends Nl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(nr.DEFAULT_UP),this.updateMatrix(),this.target=new nr,this.shadow=new Jf}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var lo=-90,co=1,Ru=class extends nr{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new er(lo,co,e,t);r.layers=this.layers,this.add(r);let a=new er(lo,co,e,t);a.layers=this.layers,this.add(a);let s=new er(lo,co,e,t);s.layers=this.layers,this.add(s);let o=new er(lo,co,e,t);o.layers=this.layers,this.add(o);let u=new er(lo,co,e,t);u.layers=this.layers,this.add(u);let l=new er(lo,co,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,a,s,o,u]=t;for(let l of t)this.remove(l);if(e===ra)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===po)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[a,s,o,u,l,d]=this.children,f=e.getRenderTarget(),h=e.getActiveCubeFace(),v=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;let T=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(i,0,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,1,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,2,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(i,4,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=T,e.setRenderTarget(i,5,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(f,h,v),e.xr.enabled=y,i.texture.needsPMREMUpdate=!0}},Pu=class extends er{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var bh="\\[\\]\\.:\\/",Ey=new RegExp("["+bh+"]","g"),wh="[^"+bh+"]",Ay="[^"+bh.replace("\\.","")+"]",Iy=/((?:WC+[\/:])*)/.source.replace("WC",wh),Cy=/(WCOD+)?/.source.replace("WCOD",Ay),Ry=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",wh),Py=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",wh),Ly=new RegExp("^"+Iy+Cy+Ry+Py+"$"),Dy=["material","materials","bones","map"],$f=class{constructor(e,t,i){let r=i||li.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},li=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Ey,"")}static parseTrackName(e){let t=Ly.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let a=i.nodeName.substring(r+1);Dy.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(a){for(let s=0;s<a.length;s++){let o=a[s];if(o.name===t||o.uuid===t)return o;let u=i(o.children);if(u)return u}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,a=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){rn("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){sn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){sn("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){sn("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===l){l=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){sn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){sn("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){sn("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){sn("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let s=e[r];if(s===void 0){let l=t.nodeName;sn("PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(a!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){sn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){sn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}u=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(u=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};li.Composite=$f;li.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};li.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};li.prototype.GetterByBindingType=[li.prototype._getValue_direct,li.prototype._getValue_array,li.prototype._getValue_arrayElement,li.prototype._getValue_toArray];li.prototype.SetterByBindingTypeAndVersioning=[[li.prototype._setValue_direct,li.prototype._setValue_direct_setNeedsUpdate,li.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[li.prototype._setValue_array,li.prototype._setValue_array_setNeedsUpdate,li.prototype._setValue_array_setMatrixWorldNeedsUpdate],[li.prototype._setValue_arrayElement,li.prototype._setValue_arrayElement_setNeedsUpdate,li.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[li.prototype._setValue_fromArray,li.prototype._setValue_fromArray_setNeedsUpdate,li.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var uw=new Float32Array(1);var Fm=new $n,Bl=class{constructor(e,t,i=0,r=1/0){this.ray=new xl(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new go,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):sn("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Fm.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Fm),this}intersectObject(e,t=!0,i=[]){return Kf(e,this,i,t),i.sort(Om),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)Kf(e[r],this,i,t);return i.sort(Om),i}};function Om(n,e){return n.distance-e.distance}function Kf(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){let a=n.children;for(let s=0,o=a.length;s<o;s++)Kf(a[s],e,t,!0)}}var Rh=class Rh{constructor(e,t,i,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){let a=this.elements;return a[0]=e,a[2]=t,a[1]=i,a[3]=r,this}};Rh.prototype.isMatrix2=!0;var Qf=Rh;function Th(n,e,t,i){let r=Ny(i);switch(t){case gh:return n*e;case Vu:return n*e/r.components*r.byteLength;case Gu:return n*e/r.components*r.byteLength;case xs:return n*e*2/r.components*r.byteLength;case Hu:return n*e*2/r.components*r.byteLength;case yh:return n*e*3/r.components*r.byteLength;case qr:return n*e*4/r.components*r.byteLength;case Wu:return n*e*4/r.components*r.byteLength;case Gl:case Hl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Wl:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Yu:case Zu:return Math.max(n,16)*Math.max(e,8)/4;case Xu:case qu:return Math.max(n,8)*Math.max(e,8)/2;case Ju:case $u:case Qu:case ju:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ku:case Yl:case ed:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case td:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case nd:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case id:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case rd:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case ad:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case sd:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case od:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ld:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case cd:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case ud:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case dd:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case fd:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case hd:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case pd:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case md:case vd:case gd:return Math.ceil(n/4)*Math.ceil(e/4)*16;case yd:case xd:return Math.ceil(n/4)*Math.ceil(e/4)*8;case ql:case _d:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Ny(n){switch(n){case Cr:case hh:return{byteLength:1,components:1};case Io:case ph:case oa:return{byteLength:2,components:1};case ku:case zu:return{byteLength:2,components:4};case sa:case Bu:case Yr:return{byteLength:4,components:1};case mh:case vh:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));typeof window<"u"&&(window.__THREE__?rn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="186");function $0(){let n=null,e=!1,t=null,i=null;function r(a,s){i=n.requestAnimationFrame(r),t(a,s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(a){t=a},setContext:function(a){n=a}}}function Fy(n){let e=new WeakMap;function t(o,u){let l=o.array,d=o.usage,f=l.byteLength,h=n.createBuffer();n.bindBuffer(u,h),n.bufferData(u,l,d),o.onUploadCallback();let v;if(l instanceof Float32Array)v=n.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)v=n.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?v=n.HALF_FLOAT:v=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)v=n.SHORT;else if(l instanceof Uint32Array)v=n.UNSIGNED_INT;else if(l instanceof Int32Array)v=n.INT;else if(l instanceof Int8Array)v=n.BYTE;else if(l instanceof Uint8Array)v=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)v=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:v,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:f}}function i(o,u,l){let d=u.array,f=u.updateRanges;if(n.bindBuffer(l,o),f.length===0)n.bufferSubData(l,0,d);else{f.sort((v,y)=>v.start-y.start);let h=0;for(let v=1;v<f.length;v++){let y=f[h],T=f[v];T.start<=y.start+y.count+1?y.count=Math.max(y.count,T.start+T.count-y.start):(++h,f[h]=T)}f.length=h+1;for(let v=0,y=f.length;v<y;v++){let T=f[v];n.bufferSubData(l,T.start*d.BYTES_PER_ELEMENT,d,T.start,T.count)}u.clearUpdateRanges()}u.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);let u=e.get(o);u&&(n.deleteBuffer(u.buffer),e.delete(o))}function s(o,u){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=e.get(o);if(l===void 0)e.set(o,t(o,u));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,o,u),l.version=o.version}}return{get:r,remove:a,update:s}}var Oy=`#ifdef USE_ALPHAHASH
5
+ }`,pa=class extends Ms{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Gx,this.fragmentShader=Hx,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Mo(e.uniforms),this.uniformsGroups=Vx(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let s=this.uniforms[r].value;s&&s.isTexture?t.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[r]={type:"m4",value:s.toArray()}:t.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let i in e.uniforms){let r=e.uniforms[i];switch(this.uniforms[i]={},r.type){case"t":this.uniforms[i].value=t[r.value]||null;break;case"c":this.uniforms[i].value=new Wn().setHex(r.value);break;case"v2":this.uniforms[i].value=new ln().fromArray(r.value);break;case"v3":this.uniforms[i].value=new Se().fromArray(r.value);break;case"v4":this.uniforms[i].value=new Fi().fromArray(r.value);break;case"m3":this.uniforms[i].value=new qn().fromArray(r.value);break;case"m4":this.uniforms[i].value=new Jn().fromArray(r.value);break;default:this.uniforms[i].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},fd=class extends pa{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},ml=class extends Ms{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Wn(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Wn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wc,this.normalScale=new ln(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ea,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}};var mr=class extends Ms{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Wn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Wn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Wc,this.normalScale=new ln(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ea,this.combine=Rd,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},hd=class extends Ms{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=m0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},pd=class extends Ms{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Zo(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Gh(n){return n!==void 0&&n.inTangents!==void 0&&n.outTangents!==void 0}var Ws=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;n:{i:if(!(e<r)){for(let o=i+2;;){if(r===void 0){if(e<a)break i;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break n}if(!(e>=a)){let o=t[1];e<o&&(i=2,a=o);for(let u=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===u)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break n}break e}for(;i<s;){let o=i+s>>>1;e<t[o]?s=o:i=o+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},md=class extends Ws{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Yh,endingEnd:Yh}}intervalChanged_(e,t,i){let r=this.parameterPositions,a=e-2,s=e+1,o=r[a],u=r[s];if(o===void 0)switch(this.getSettings_().endingStart){case qh:a=e,o=2*t-i;break;case Zh:a=r.length-2,o=t+r[a]-r[a+1];break;default:a=e,o=i}if(u===void 0)switch(this.getSettings_().endingEnd){case qh:s=e,u=2*i-t;break;case Zh:s=1,u=i+r[1]-r[0];break;default:s=e-1,u=t}let l=(i-t)*.5,d=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(u-i),this._offsetPrev=a*d,this._offsetNext=s*d}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=this._offsetPrev,f=this._offsetNext,h=this._weightPrev,m=this._weightNext,x=(i-t)/(r-t),_=x*x,g=_*x,v=-h*g+2*h*_-h*x,F=(1+h)*g+(-1.5-2*h)*_+(-.5+h)*x+1,P=(-1-m)*g+(1.5+m)*_+.5*x,S=m*g-m*_;for(let N=0;N!==o;++N)a[N]=v*s[d+N]+F*s[l+N]+P*s[u+N]+S*s[f+N];return a}},vd=class extends Ws{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=(i-t)/(r-t),f=1-d;for(let h=0;h!==o;++h)a[h]=s[l+h]*f+s[u+h]*d;return a}},gd=class extends Ws{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},yd=class extends Ws{interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=e*o,l=u-o,d=this.inTangents,f=this.outTangents;if(!d||!f){let x=(i-t)/(r-t),_=1-x;for(let g=0;g!==o;++g)a[g]=s[l+g]*_+s[u+g]*x;return a}let h=o*2,m=e-1;for(let x=0;x!==o;++x){let _=s[l+x],g=s[u+x],v=m*h+x*2,F=f[v],P=f[v+1],S=e*h+x*2,N=d[S],p=d[S+1],L=Xx(i,t,F,N,r);a[x]=U0(L,_,P,p,g)}return a}};function U0(n,e,t,i,r){let a=1-n;return a*a*a*e+3*a*a*n*t+3*a*n*n*i+n*n*n*r}function Wx(n,e,t,i,r){let a=1-n;return 3*a*a*(t-e)+6*a*n*(i-t)+3*n*n*(r-i)}function Xx(n,e,t,i,r){let a=(n-e)/(r-e);for(let s=0;s<8;s++){let o=U0(a,e,t,i,r)-n;if(Math.abs(o)<1e-10)break;let u=Wx(a,e,t,i,r);if(Math.abs(u)<1e-10)break;a=Math.max(0,Math.min(1,a-o/u))}return a}var ma=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Zo(t,this.TimeBufferType),this.values=Zo(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:Zo(e.times,Array),values:Zo(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r),Gh(e.settings)&&(i.settings={inTangents:Zo(e.settings.inTangents,Array),outTangents:Zo(e.settings.outTangents,Array)})}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new gd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new vd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new md(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new yd(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case oc:t=this.InterpolantFactoryMethodDiscrete;break;case ed:t=this.InterpolantFactoryMethodLinear;break;case Xu:t=this.InterpolantFactoryMethodSmooth;break;case Xh:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return Rn("KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return oc;case this.InterpolantFactoryMethodLinear:return ed;case this.InterpolantFactoryMethodSmooth:return Xu;case this.InterpolantFactoryMethodBezier:return Xh}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e;Gh(this.settings)&&(kv(this.settings.inTangents,e),kv(this.settings.outTangents,e))}return this}trim(e,t){let i=this.times,r=i.length,a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);let o=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*o,s*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(On("KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,a=i.length;a===0&&(On("KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let o=0;o!==a;o++){let u=i[o];if(typeof u=="number"&&isNaN(u)){On("KeyframeTrack: Time is not a valid number.",this,o,u),e=!1;break}if(s!==null&&s>u){On("KeyframeTrack: Out of order keys.",this,o,u,s),e=!1;break}s=u}if(r!==void 0&&qy(r))for(let o=0,u=r.length;o!==u;++o){let l=r[o];if(isNaN(l)){On("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Xu,a=e.length-1,s=1;for(let o=1;o<a;++o){let u=!1,l=e[o],d=e[o+1];if(l!==d&&(o!==1||l!==e[0]))if(r)u=!0;else{let f=o*i,h=f-i,m=f+i;for(let x=0;x!==i;++x){let _=t[f+x];if(_!==t[h+x]||_!==t[m+x]){u=!0;break}}}if(u){if(o!==s){e[s]=e[o];let f=o*i,h=s*i;for(let m=0;m!==i;++m)t[h+m]=t[f+m]}++s}}if(a>0){e[s]=e[a];for(let o=a*i,u=s*i,l=0;l!==i;++l)t[u+l]=t[o+l];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,Gh(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function kv(n,e){for(let t=0,i=n.length;t!==i;t+=2)n[t]*=e}ma.prototype.ValueTypeName="";ma.prototype.TimeBufferType=Float32Array;ma.prototype.ValueBufferType=Float32Array;ma.prototype.DefaultInterpolation=ed;var Xs=class extends ma{constructor(e,t,i){super(e,t,i)}};Xs.prototype.ValueTypeName="bool";Xs.prototype.ValueBufferType=Array;Xs.prototype.DefaultInterpolation=oc;Xs.prototype.InterpolantFactoryMethodLinear=void 0;Xs.prototype.InterpolantFactoryMethodSmooth=void 0;var xd=class extends ma{constructor(e,t,i,r){super(e,t,i,r)}};xd.prototype.ValueTypeName="color";var _d=class extends ma{constructor(e,t,i,r){super(e,t,i,r)}};_d.prototype.ValueTypeName="number";var Md=class extends Ws{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let a=this.resultBuffer,s=this.sampleValues,o=this.valueSize,u=(i-t)/(r-t),l=e*o;for(let d=l+o;l!==d;l+=4)aa.slerpFlat(a,0,s,l-o,s,l,u);return a}},Ic=class extends ma{constructor(e,t,i,r){super(e,t,i,r)}InterpolantFactoryMethodLinear(e){return new Md(this.times,this.values,this.getValueSize(),e)}};Ic.prototype.ValueTypeName="quaternion";Ic.prototype.InterpolantFactoryMethodSmooth=void 0;var Ys=class extends ma{constructor(e,t,i){super(e,t,i)}};Ys.prototype.ValueTypeName="string";Ys.prototype.ValueBufferType=Array;Ys.prototype.DefaultInterpolation=oc;Ys.prototype.InterpolantFactoryMethodLinear=void 0;Ys.prototype.InterpolantFactoryMethodSmooth=void 0;var Sd=class extends ma{constructor(e,t,i,r){super(e,t,i,r)}};Sd.prototype.ValueTypeName="vector";var bd=class{constructor(e,t,i){let r=this,a=!1,s=0,o=0,u,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this._abortController=null,this.itemStart=function(d){o++,a===!1&&r.onStart!==void 0&&r.onStart(d,s,o),a=!0},this.itemEnd=function(d){s++,r.onProgress!==void 0&&r.onProgress(d,s,o),s===o&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return d=d.normalize("NFC"),u?u(d):d},this.setURLModifier=function(d){return u=d,this},this.addHandler=function(d,f){return l.push(d,f),this},this.removeHandler=function(d){let f=l.indexOf(d);return f!==-1&&l.splice(f,2),this},this.getHandler=function(d){for(let f=0,h=l.length;f<h;f+=2){let m=l[f],x=l[f+1];if(m.global&&(m.lastIndex=0),m.test(d))return x}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},F0=new bd,wd=class{constructor(e){this.manager=e!==void 0?e:F0,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};wd.DEFAULT_MATERIAL_NAME="__DEFAULT";var Cc=class extends hr{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Wn(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},Rc=class extends Cc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(hr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Wn(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Hh=new Jn,zv=new Se,Vv=new Se,Td=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ln(512,512),this.mapType=ca,this.map=null,this.mapPass=null,this.matrix=new Jn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new cl,this._frameExtents=new ln(1,1),this._viewportCount=1,this._viewports=[new Fi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;zv.setFromMatrixPosition(e.matrixWorld),t.position.copy(zv),Vv.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Vv),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,i,r){Hh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),i.setFromProjectionMatrix(Hh,e.coordinateSystem,e.reversedDepth);let a=this._frameExtents,s=r?r.z/a.x:1,o=r?r.w/a.y:1,u=r?r.x/a.x:0,l=r?r.y/a.y:0;e.coordinateSystem===tl||e.reversedDepth?t.set(.5*s,0,0,.5*s+u,0,.5*o,0,.5*o+l,0,0,1,0,0,0,0,1):t.set(.5*s,0,0,.5*s+u,0,.5*o,0,.5*o+l,0,0,.5,.5,0,0,0,1),t.multiply(Hh)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Hu=new Se,Wu=new aa,$a=new Se,Pc=class extends hr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Jn,this.projectionMatrix=new Jn,this.projectionMatrixInverse=new Jn,this.coordinateSystem=Ba,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Hu,Wu,$a),$a.x===1&&$a.y===1&&$a.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Hu,Wu,$a.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(Hu,Wu,$a),$a.x===1&&$a.y===1&&$a.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Hu,Wu,$a.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},ks=new Se,Gv=new ln,Hv=new ln,zr=class extends Pc{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=td*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(vh*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return td*2*Math.atan(Math.tan(vh*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){ks.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ks.x,ks.y).multiplyScalar(-e/ks.z),ks.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(ks.x,ks.y).multiplyScalar(-e/ks.z)}getViewSize(e,t){return this.getViewBounds(e,Gv,Hv),t.subVectors(Hv,Gv)}setViewOffset(e,t,i,r,a,s){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(vh*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,a=-.5*r,s=this.view;if(this.view!==null&&this.view.enabled){let u=s.fullWidth,l=s.fullHeight;a+=s.offsetX*r/u,t-=s.offsetY*i/l,r*=s.width/u,i*=s.height/l}let o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};var vl=class extends Pc{constructor(e=-1,t=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,a=i-e,s=i+e,o=r+t,u=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=l*this.view.offsetX,s=a+l*this.view.width,o-=d*this.view.offsetY,u=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,u,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Qh=class extends Td{constructor(){super(new vl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Lc=class extends Cc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(hr.DEFAULT_UP),this.updateMatrix(),this.target=new hr,this.shadow=new Qh}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var Jo=-90,$o=1,Ed=class extends hr{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new zr(Jo,$o,e,t);r.layers=this.layers,this.add(r);let a=new zr(Jo,$o,e,t);a.layers=this.layers,this.add(a);let s=new zr(Jo,$o,e,t);s.layers=this.layers,this.add(s);let o=new zr(Jo,$o,e,t);o.layers=this.layers,this.add(o);let u=new zr(Jo,$o,e,t);u.layers=this.layers,this.add(u);let l=new zr(Jo,$o,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,a,s,o,u]=t;for(let l of t)this.remove(l);if(e===Ba)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===tl)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[a,s,o,u,l,d]=this.children,f=e.getRenderTarget(),h=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;let _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(i,0,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,1,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(i,2,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(i,4,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,r),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,d),e.setRenderTarget(f,h,m),e.xr.enabled=x,i.texture.needsPMREMUpdate=!0}},Ad=class extends zr{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var wp="\\[\\]\\.:\\/",Yx=new RegExp("["+wp+"]","g"),Tp="[^"+wp+"]",qx="[^"+wp.replace("\\.","")+"]",Zx=/((?:WC+[\/:])*)/.source.replace("WC",Tp),Jx=/(WCOD+)?/.source.replace("WCOD",qx),$x=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Tp),Kx=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Tp),Qx=new RegExp("^"+Zx+Jx+$x+Kx+"$"),jx=["material","materials","bones","map"],jh=class{constructor(e,t,i){let r=i||Wi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Wi=class n{constructor(e,t,i){this.path=t,this.parsedPath=i||n.parseTrackName(t),this.node=n.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new n.Composite(e,t,i):new n(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Yx,"")}static parseTrackName(e){let t=Qx.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let a=i.nodeName.substring(r+1);jx.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(a){for(let s=0;s<a.length;s++){let o=a[s];if(o.name===t||o.uuid===t)return o;let u=i(o.children);if(u)return u}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,a=t.propertyIndex;if(e||(e=n.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Rn("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){On("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){On("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){On("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let d=0;d<e.length;d++)if(e[d].name===l){l=d;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){On("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){On("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){On("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){On("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let s=e[r];if(s===void 0){let l=t.nodeName;On("PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(a!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){On("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){On("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[a]!==void 0&&(a=e.morphTargetDictionary[a])}u=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(u=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Wi.Composite=jh;Wi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Wi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Wi.prototype.GetterByBindingType=[Wi.prototype._getValue_direct,Wi.prototype._getValue_array,Wi.prototype._getValue_arrayElement,Wi.prototype._getValue_toArray];Wi.prototype.SetterByBindingTypeAndVersioning=[[Wi.prototype._setValue_direct,Wi.prototype._setValue_direct_setNeedsUpdate,Wi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Wi.prototype._setValue_array,Wi.prototype._setValue_array_setNeedsUpdate,Wi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Wi.prototype._setValue_arrayElement,Wi.prototype._setValue_arrayElement_setNeedsUpdate,Wi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Wi.prototype._setValue_fromArray,Wi.prototype._setValue_fromArray_setNeedsUpdate,Wi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var O1=new Float32Array(1);var Wv=new Jn,Dc=class{constructor(e,t,i=0,r=1/0){this.ray=new sl(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new rl,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):On("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Wv.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Wv),this}intersectObject(e,t=!0,i=[]){return ep(e,this,i,t),i.sort(Xv),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)ep(e[r],this,i,t);return i.sort(Xv),i}};function Xv(n,e){return n.distance-e.distance}function ep(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){let a=n.children;for(let s=0,o=a.length;s<o;s++)ep(a[s],e,t,!0)}}var Pp=class Pp{constructor(e,t,i,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,r){let a=this.elements;return a[0]=e,a[2]=t,a[1]=i,a[3]=r,this}};Pp.prototype.isMatrix2=!0;var tp=Pp;function Ep(n,e,t,i){let r=e_(i);switch(t){case yp:return n*e;case Fd:return n*e/r.components*r.byteLength;case Od:return n*e/r.components*r.byteLength;case Js:return n*e*2/r.components*r.byteLength;case Bd:return n*e*2/r.components*r.byteLength;case xp:return n*e*3/r.components*r.byteLength;case ga:return n*e*4/r.components*r.byteLength;case kd:return n*e*4/r.components*r.byteLength;case Bc:case kc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case zc:case Vc:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Vd:case Hd:return Math.max(n,16)*Math.max(e,8)/4;case zd:case Gd:return Math.max(n,8)*Math.max(e,8)/2;case Wd:case Xd:case qd:case Zd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Yd:case Gc:case Jd:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case $d:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kd:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Qd:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case jd:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case ef:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case tf:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case nf:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case rf:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case af:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case sf:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case of:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case lf:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case cf:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case uf:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case df:case ff:case hf:return Math.ceil(n/4)*Math.ceil(e/4)*16;case pf:case mf:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Hc:case vf:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function e_(n){switch(n){case ca:case pp:return{byteLength:1,components:1};case Ml:case mp:case Va:return{byteLength:2,components:1};case Nd:case Ud:return{byteLength:2,components:4};case za:case Dd:case va:return{byteLength:4,components:1};case vp:case gp:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"186"}}));typeof window<"u"&&(window.__THREE__?Rn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="186");function rg(){let n=null,e=!1,t=null,i=null;function r(a,s){i=n.requestAnimationFrame(r),t(a,s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(a){t=a},setContext:function(a){n=a}}}function n_(n){let e=new WeakMap;function t(o,u){let l=o.array,d=o.usage,f=l.byteLength,h=n.createBuffer();n.bindBuffer(u,h),n.bufferData(u,l,d),o.onUploadCallback();let m;if(l instanceof Float32Array)m=n.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)m=n.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?m=n.HALF_FLOAT:m=n.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=n.SHORT;else if(l instanceof Uint32Array)m=n.UNSIGNED_INT;else if(l instanceof Int32Array)m=n.INT;else if(l instanceof Int8Array)m=n.BYTE;else if(l instanceof Uint8Array)m=n.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:f}}function i(o,u,l){let d=u.array,f=u.updateRanges;if(n.bindBuffer(l,o),f.length===0)n.bufferSubData(l,0,d);else{f.sort((m,x)=>m.start-x.start);let h=0;for(let m=1;m<f.length;m++){let x=f[h],_=f[m];_.start<=x.start+x.count+1?x.count=Math.max(x.count,_.start+_.count-x.start):(++h,f[h]=_)}f.length=h+1;for(let m=0,x=f.length;m<x;m++){let _=f[m];n.bufferSubData(l,_.start*d.BYTES_PER_ELEMENT,d,_.start,_.count)}u.clearUpdateRanges()}u.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);let u=e.get(o);u&&(n.deleteBuffer(u.buffer),e.delete(o))}function s(o,u){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=e.get(o);if(l===void 0)e.set(o,t(o,u));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(l.buffer,o,u),l.version=o.version}}return{get:r,remove:a,update:s}}var i_=`#ifdef USE_ALPHAHASH
6
6
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
7
- #endif`,By=`#ifdef USE_ALPHAHASH
7
+ #endif`,r_=`#ifdef USE_ALPHAHASH
8
8
  const float ALPHA_HASH_SCALE = 0.05;
9
9
  float hash2D( vec2 value ) {
10
10
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -39,20 +39,20 @@ var ToraNative=(()=>{var af=Object.defineProperty;var mg=Object.getOwnPropertyDe
39
39
  : cases.z;
40
40
  return clamp( threshold , 1.0e-6, 1.0 );
41
41
  }
42
- #endif`,ky=`#ifdef USE_ALPHAMAP
42
+ #endif`,a_=`#ifdef USE_ALPHAMAP
43
43
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
44
- #endif`,zy=`#ifdef USE_ALPHAMAP
44
+ #endif`,s_=`#ifdef USE_ALPHAMAP
45
45
  uniform sampler2D alphaMap;
46
- #endif`,Vy=`#ifdef USE_ALPHATEST
46
+ #endif`,o_=`#ifdef USE_ALPHATEST
47
47
  #ifdef ALPHA_TO_COVERAGE
48
48
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
49
49
  if ( diffuseColor.a == 0.0 ) discard;
50
50
  #else
51
51
  if ( diffuseColor.a < alphaTest ) discard;
52
52
  #endif
53
- #endif`,Gy=`#ifdef USE_ALPHATEST
53
+ #endif`,l_=`#ifdef USE_ALPHATEST
54
54
  uniform float alphaTest;
55
- #endif`,Hy=`#ifdef USE_AOMAP
55
+ #endif`,c_=`#ifdef USE_AOMAP
56
56
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
57
57
  reflectedLight.indirectDiffuse *= ambientOcclusion;
58
58
  #if defined( USE_CLEARCOAT )
@@ -65,10 +65,10 @@ var ToraNative=(()=>{var af=Object.defineProperty;var mg=Object.getOwnPropertyDe
65
65
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
66
66
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
67
67
  #endif
68
- #endif`,Wy=`#ifdef USE_AOMAP
68
+ #endif`,u_=`#ifdef USE_AOMAP
69
69
  uniform sampler2D aoMap;
70
70
  uniform float aoMapIntensity;
71
- #endif`,Xy=`#ifdef USE_BATCHING
71
+ #endif`,d_=`#ifdef USE_BATCHING
72
72
  #if ! defined( GL_ANGLE_multi_draw )
73
73
  #define gl_DrawID _gl_DrawID
74
74
  uniform int _gl_DrawID;
@@ -102,15 +102,15 @@ var ToraNative=(()=>{var af=Object.defineProperty;var mg=Object.getOwnPropertyDe
102
102
  int y = j / size;
103
103
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
104
104
  }
105
- #endif`,Yy=`#ifdef USE_BATCHING
105
+ #endif`,f_=`#ifdef USE_BATCHING
106
106
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
107
- #endif`,qy=`vec3 transformed = vec3( position );
107
+ #endif`,h_=`vec3 transformed = vec3( position );
108
108
  #ifdef USE_ALPHAHASH
109
109
  vPosition = vec3( position );
110
- #endif`,Zy=`vec3 objectNormal = vec3( normal );
110
+ #endif`,p_=`vec3 objectNormal = vec3( normal );
111
111
  #ifdef USE_TANGENT
112
112
  vec3 objectTangent = vec3( tangent.xyz );
113
- #endif`,Jy=`float G_BlinnPhong_Implicit( ) {
113
+ #endif`,m_=`float G_BlinnPhong_Implicit( ) {
114
114
  return 0.25;
115
115
  }
116
116
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -124,7 +124,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
124
124
  float G = G_BlinnPhong_Implicit( );
125
125
  float D = D_BlinnPhong( shininess, dotNH );
126
126
  return F * ( G * D );
127
- } // validated`,$y=`#ifdef USE_IRIDESCENCE
127
+ } // validated`,v_=`#ifdef USE_IRIDESCENCE
128
128
  const mat3 XYZ_TO_REC709 = mat3(
129
129
  3.2404542, -0.9692660, 0.0556434,
130
130
  -1.5371385, 1.8760108, -0.2040259,
@@ -187,7 +187,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
187
187
  }
188
188
  return max( I, vec3( 0.0 ) );
189
189
  }
190
- #endif`,Ky=`#ifdef USE_BUMPMAP
190
+ #endif`,g_=`#ifdef USE_BUMPMAP
191
191
  uniform sampler2D bumpMap;
192
192
  uniform float bumpScale;
193
193
  vec2 dHdxy_fwd() {
@@ -208,7 +208,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
208
208
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
209
209
  return normalize( abs( fDet ) * surf_norm - vGrad );
210
210
  }
211
- #endif`,Qy=`#if NUM_CLIPPING_PLANES > 0
211
+ #endif`,y_=`#if NUM_CLIPPING_PLANES > 0
212
212
  vec4 plane;
213
213
  #ifdef ALPHA_TO_COVERAGE
214
214
  float distanceToPlane, distanceGradient;
@@ -254,20 +254,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
254
254
  if ( clipped ) discard;
255
255
  #endif
256
256
  #endif
257
- #endif`,jy=`#if NUM_CLIPPING_PLANES > 0
257
+ #endif`,x_=`#if NUM_CLIPPING_PLANES > 0
258
258
  varying vec3 vClipPosition;
259
259
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
260
- #endif`,ex=`#if NUM_CLIPPING_PLANES > 0
260
+ #endif`,__=`#if NUM_CLIPPING_PLANES > 0
261
261
  varying vec3 vClipPosition;
262
- #endif`,tx=`#if NUM_CLIPPING_PLANES > 0
262
+ #endif`,M_=`#if NUM_CLIPPING_PLANES > 0
263
263
  vClipPosition = - mvPosition.xyz;
264
- #endif`,nx=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
264
+ #endif`,S_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
265
265
  diffuseColor *= vColor;
266
- #endif`,ix=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
266
+ #endif`,b_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
267
267
  varying vec4 vColor;
268
- #endif`,rx=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
268
+ #endif`,w_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
269
269
  varying vec4 vColor;
270
- #endif`,ax=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
270
+ #endif`,T_=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
271
271
  vColor = vec4( 1.0 );
272
272
  #endif
273
273
  #ifdef USE_COLOR_ALPHA
@@ -280,7 +280,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
280
280
  #endif
281
281
  #ifdef USE_BATCHING_COLOR
282
282
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
283
- #endif`,sx=`#define PI 3.141592653589793
283
+ #endif`,E_=`#define PI 3.141592653589793
284
284
  #define PI2 6.283185307179586
285
285
  #define PI_HALF 1.5707963267948966
286
286
  #define RECIPROCAL_PI 0.3183098861837907
@@ -351,7 +351,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
351
351
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
352
352
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
353
353
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
354
- } // validated`,ox=`#ifdef ENVMAP_TYPE_CUBE_UV
354
+ } // validated`,A_=`#ifdef ENVMAP_TYPE_CUBE_UV
355
355
  #define cubeUV_minMipLevel 4.0
356
356
  #define cubeUV_minTileSize 16.0
357
357
  float getFace( vec3 direction ) {
@@ -444,7 +444,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
444
444
  return vec4( mix( color0, color1, mipF ), 1.0 );
445
445
  }
446
446
  }
447
- #endif`,lx=`vec3 transformedNormal = objectNormal;
447
+ #endif`,I_=`vec3 transformedNormal = objectNormal;
448
448
  #ifdef USE_TANGENT
449
449
  vec3 transformedTangent = objectTangent;
450
450
  #endif
@@ -470,21 +470,21 @@ transformedNormal = normalMatrix * transformedNormal;
470
470
  #endif
471
471
  #ifdef USE_TANGENT
472
472
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
473
- #endif`,cx=`#ifdef USE_DISPLACEMENTMAP
473
+ #endif`,C_=`#ifdef USE_DISPLACEMENTMAP
474
474
  uniform sampler2D displacementMap;
475
475
  uniform float displacementScale;
476
476
  uniform float displacementBias;
477
- #endif`,ux=`#ifdef USE_DISPLACEMENTMAP
477
+ #endif`,R_=`#ifdef USE_DISPLACEMENTMAP
478
478
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
479
- #endif`,dx=`#ifdef USE_EMISSIVEMAP
479
+ #endif`,P_=`#ifdef USE_EMISSIVEMAP
480
480
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
481
481
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
482
482
  emissiveColor = sRGBTransferEOTF( emissiveColor );
483
483
  #endif
484
484
  totalEmissiveRadiance *= emissiveColor.rgb;
485
- #endif`,fx=`#ifdef USE_EMISSIVEMAP
485
+ #endif`,L_=`#ifdef USE_EMISSIVEMAP
486
486
  uniform sampler2D emissiveMap;
487
- #endif`,hx="gl_FragColor = linearToOutputTexel( gl_FragColor );",px=`vec4 LinearTransferOETF( in vec4 value ) {
487
+ #endif`,D_="gl_FragColor = linearToOutputTexel( gl_FragColor );",N_=`vec4 LinearTransferOETF( in vec4 value ) {
488
488
  return value;
489
489
  }
490
490
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -492,7 +492,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
492
492
  }
493
493
  vec4 sRGBTransferOETF( in vec4 value ) {
494
494
  return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
495
- }`,mx=`#ifdef USE_ENVMAP
495
+ }`,U_=`#ifdef USE_ENVMAP
496
496
  #ifdef ENV_WORLDPOS
497
497
  vec3 cameraToFrag;
498
498
  if ( isOrthographic ) {
@@ -519,7 +519,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
519
519
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
520
520
  #endif
521
521
  #endif
522
- #endif`,vx=`#ifdef USE_ENVMAP
522
+ #endif`,F_=`#ifdef USE_ENVMAP
523
523
  uniform float envMapIntensity;
524
524
  uniform mat3 envMapRotation;
525
525
  #ifdef ENVMAP_TYPE_CUBE
@@ -527,7 +527,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
527
527
  #else
528
528
  uniform sampler2D envMap;
529
529
  #endif
530
- #endif`,gx=`#ifdef USE_ENVMAP
530
+ #endif`,O_=`#ifdef USE_ENVMAP
531
531
  uniform float reflectivity;
532
532
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
533
533
  #define ENV_WORLDPOS
@@ -538,7 +538,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
538
538
  #else
539
539
  varying vec3 vReflect;
540
540
  #endif
541
- #endif`,yx=`#ifdef USE_ENVMAP
541
+ #endif`,B_=`#ifdef USE_ENVMAP
542
542
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
543
543
  #define ENV_WORLDPOS
544
544
  #endif
@@ -549,7 +549,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
549
549
  varying vec3 vReflect;
550
550
  uniform float refractionRatio;
551
551
  #endif
552
- #endif`,xx=`#ifdef USE_ENVMAP
552
+ #endif`,k_=`#ifdef USE_ENVMAP
553
553
  #ifdef ENV_WORLDPOS
554
554
  vWorldPosition = worldPosition.xyz;
555
555
  #else
@@ -566,18 +566,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
566
566
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
567
567
  #endif
568
568
  #endif
569
- #endif`,_x=`#ifdef USE_FOG
569
+ #endif`,z_=`#ifdef USE_FOG
570
570
  vFogDepth = - mvPosition.z;
571
- #endif`,Mx=`#ifdef USE_FOG
571
+ #endif`,V_=`#ifdef USE_FOG
572
572
  varying float vFogDepth;
573
- #endif`,Sx=`#ifdef USE_FOG
573
+ #endif`,G_=`#ifdef USE_FOG
574
574
  #ifdef FOG_EXP2
575
575
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
576
576
  #else
577
577
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
578
578
  #endif
579
579
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
580
- #endif`,bx=`#ifdef USE_FOG
580
+ #endif`,H_=`#ifdef USE_FOG
581
581
  uniform vec3 fogColor;
582
582
  varying float vFogDepth;
583
583
  #ifdef FOG_EXP2
@@ -586,7 +586,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
586
586
  uniform float fogNear;
587
587
  uniform float fogFar;
588
588
  #endif
589
- #endif`,wx=`#ifdef USE_GRADIENTMAP
589
+ #endif`,W_=`#ifdef USE_GRADIENTMAP
590
590
  uniform sampler2D gradientMap;
591
591
  #endif
592
592
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -598,12 +598,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
598
598
  vec2 fw = fwidth( coord ) * 0.5;
599
599
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
600
600
  #endif
601
- }`,Tx=`#ifdef USE_LIGHTMAP
601
+ }`,X_=`#ifdef USE_LIGHTMAP
602
602
  uniform sampler2D lightMap;
603
603
  uniform float lightMapIntensity;
604
- #endif`,Ex=`LambertMaterial material;
604
+ #endif`,Y_=`LambertMaterial material;
605
605
  material.diffuseColor = diffuseColor.rgb;
606
- material.specularStrength = specularStrength;`,Ax=`varying vec3 vViewPosition;
606
+ material.specularStrength = specularStrength;`,q_=`varying vec3 vViewPosition;
607
607
  struct LambertMaterial {
608
608
  vec3 diffuseColor;
609
609
  float specularStrength;
@@ -617,7 +617,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
617
617
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
618
618
  }
619
619
  #define RE_Direct RE_Direct_Lambert
620
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Ix=`uniform bool receiveShadow;
620
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Z_=`uniform bool receiveShadow;
621
621
  uniform vec3 ambientLightColor;
622
622
  #if defined( USE_LIGHT_PROBES )
623
623
  uniform vec3 lightProbe[ 9 ];
@@ -746,7 +746,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
746
746
  return irradiance;
747
747
  }
748
748
  #endif
749
- #include <lightprobes_pars_fragment>`,Cx=`#ifdef USE_ENVMAP
749
+ #include <lightprobes_pars_fragment>`,J_=`#ifdef USE_ENVMAP
750
750
  vec3 getIBLIrradiance( const in vec3 normal ) {
751
751
  #ifdef ENVMAP_TYPE_CUBE_UV
752
752
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -803,8 +803,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
803
803
  }
804
804
  #endif
805
805
  #endif
806
- #endif`,Rx=`ToonMaterial material;
807
- material.diffuseColor = diffuseColor.rgb;`,Px=`varying vec3 vViewPosition;
806
+ #endif`,$_=`ToonMaterial material;
807
+ material.diffuseColor = diffuseColor.rgb;`,K_=`varying vec3 vViewPosition;
808
808
  struct ToonMaterial {
809
809
  vec3 diffuseColor;
810
810
  };
@@ -816,11 +816,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
816
816
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
817
817
  }
818
818
  #define RE_Direct RE_Direct_Toon
819
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Lx=`BlinnPhongMaterial material;
819
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Q_=`BlinnPhongMaterial material;
820
820
  material.diffuseColor = diffuseColor.rgb;
821
821
  material.specularColor = specular;
822
822
  material.specularShininess = shininess;
823
- material.specularStrength = specularStrength;`,Dx=`varying vec3 vViewPosition;
823
+ material.specularStrength = specularStrength;`,j_=`varying vec3 vViewPosition;
824
824
  struct BlinnPhongMaterial {
825
825
  vec3 diffuseColor;
826
826
  vec3 specularColor;
@@ -837,7 +837,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
837
837
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
838
838
  }
839
839
  #define RE_Direct RE_Direct_BlinnPhong
840
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Nx=`PhysicalMaterial material;
840
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,eM=`PhysicalMaterial material;
841
841
  material.diffuseColor = diffuseColor.rgb;
842
842
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
843
843
  material.metalness = metalnessFactor;
@@ -930,7 +930,7 @@ material.roughness = min( material.roughness, 1.0 );
930
930
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
931
931
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
932
932
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
933
- #endif`,Ux=`uniform sampler2D dfgLUT;
933
+ #endif`,tM=`uniform sampler2D dfgLUT;
934
934
  struct PhysicalMaterial {
935
935
  vec3 diffuseColor;
936
936
  vec3 diffuseContribution;
@@ -1297,7 +1297,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1297
1297
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1298
1298
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1299
1299
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1300
- }`,Fx=`
1300
+ }`,nM=`
1301
1301
  vec3 geometryPosition = - vViewPosition;
1302
1302
  vec3 geometryNormal = normal;
1303
1303
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1445,7 +1445,7 @@ IncidentLight directLight;
1445
1445
  #if defined( RE_IndirectSpecular )
1446
1446
  vec3 radiance = vec3( 0.0 );
1447
1447
  vec3 clearcoatRadiance = vec3( 0.0 );
1448
- #endif`,Ox=`#if defined( RE_IndirectDiffuse )
1448
+ #endif`,iM=`#if defined( RE_IndirectDiffuse )
1449
1449
  #ifdef USE_LIGHTMAP
1450
1450
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1451
1451
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1475,7 +1475,7 @@ IncidentLight directLight;
1475
1475
  #ifdef USE_CLEARCOAT
1476
1476
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1477
1477
  #endif
1478
- #endif`,Bx=`#if defined( RE_IndirectDiffuse )
1478
+ #endif`,rM=`#if defined( RE_IndirectDiffuse )
1479
1479
  #if defined( LAMBERT ) || defined( PHONG )
1480
1480
  irradiance += iblIrradiance;
1481
1481
  #endif
@@ -1483,7 +1483,7 @@ IncidentLight directLight;
1483
1483
  #endif
1484
1484
  #if defined( RE_IndirectSpecular )
1485
1485
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1486
- #endif`,kx=`#ifdef USE_LIGHT_PROBES_GRID
1486
+ #endif`,aM=`#ifdef USE_LIGHT_PROBES_GRID
1487
1487
  uniform highp sampler3D probesSH;
1488
1488
  uniform vec3 probesMin;
1489
1489
  uniform vec3 probesMax;
@@ -1528,27 +1528,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1528
1528
  result += c8 * 0.429043 * ( x * x - y * y );
1529
1529
  return max( result, vec3( 0.0 ) );
1530
1530
  }
1531
- #endif`,zx=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1531
+ #endif`,sM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1532
1532
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1533
- #endif`,Vx=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1533
+ #endif`,oM=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1534
1534
  uniform float logDepthBufFC;
1535
1535
  varying float vFragDepth;
1536
1536
  varying float vIsPerspective;
1537
- #endif`,Gx=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1537
+ #endif`,lM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1538
1538
  varying float vFragDepth;
1539
1539
  varying float vIsPerspective;
1540
- #endif`,Hx=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1540
+ #endif`,cM=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1541
1541
  vFragDepth = 1.0 + gl_Position.w;
1542
1542
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1543
- #endif`,Wx=`#ifdef USE_MAP
1543
+ #endif`,uM=`#ifdef USE_MAP
1544
1544
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1545
1545
  #ifdef DECODE_VIDEO_TEXTURE
1546
1546
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1547
1547
  #endif
1548
1548
  diffuseColor *= sampledDiffuseColor;
1549
- #endif`,Xx=`#ifdef USE_MAP
1549
+ #endif`,dM=`#ifdef USE_MAP
1550
1550
  uniform sampler2D map;
1551
- #endif`,Yx=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1551
+ #endif`,fM=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1552
1552
  #if defined( USE_POINTS_UV )
1553
1553
  vec2 uv = vUv;
1554
1554
  #else
@@ -1560,7 +1560,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1560
1560
  #endif
1561
1561
  #ifdef USE_ALPHAMAP
1562
1562
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1563
- #endif`,qx=`#if defined( USE_POINTS_UV )
1563
+ #endif`,hM=`#if defined( USE_POINTS_UV )
1564
1564
  varying vec2 vUv;
1565
1565
  #else
1566
1566
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1572,19 +1572,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1572
1572
  #endif
1573
1573
  #ifdef USE_ALPHAMAP
1574
1574
  uniform sampler2D alphaMap;
1575
- #endif`,Zx=`float metalnessFactor = metalness;
1575
+ #endif`,pM=`float metalnessFactor = metalness;
1576
1576
  #ifdef USE_METALNESSMAP
1577
1577
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1578
1578
  metalnessFactor *= texelMetalness.b;
1579
- #endif`,Jx=`#ifdef USE_METALNESSMAP
1579
+ #endif`,mM=`#ifdef USE_METALNESSMAP
1580
1580
  uniform sampler2D metalnessMap;
1581
- #endif`,$x=`#ifdef USE_INSTANCING_MORPH
1581
+ #endif`,vM=`#ifdef USE_INSTANCING_MORPH
1582
1582
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1583
1583
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1584
1584
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1585
1585
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1586
1586
  }
1587
- #endif`,Kx=`#if defined( USE_MORPHCOLORS )
1587
+ #endif`,gM=`#if defined( USE_MORPHCOLORS )
1588
1588
  vColor *= morphTargetBaseInfluence;
1589
1589
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1590
1590
  #if defined( USE_COLOR_ALPHA )
@@ -1593,12 +1593,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1593
1593
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1594
1594
  #endif
1595
1595
  }
1596
- #endif`,Qx=`#ifdef USE_MORPHNORMALS
1596
+ #endif`,yM=`#ifdef USE_MORPHNORMALS
1597
1597
  objectNormal *= morphTargetBaseInfluence;
1598
1598
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1599
1599
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1600
1600
  }
1601
- #endif`,jx=`#ifdef USE_MORPHTARGETS
1601
+ #endif`,xM=`#ifdef USE_MORPHTARGETS
1602
1602
  #ifndef USE_INSTANCING_MORPH
1603
1603
  uniform float morphTargetBaseInfluence;
1604
1604
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1612,12 +1612,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1612
1612
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1613
1613
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1614
1614
  }
1615
- #endif`,e_=`#ifdef USE_MORPHTARGETS
1615
+ #endif`,_M=`#ifdef USE_MORPHTARGETS
1616
1616
  transformed *= morphTargetBaseInfluence;
1617
1617
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1618
1618
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1619
1619
  }
1620
- #endif`,t_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1620
+ #endif`,MM=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1621
1621
  #ifdef FLAT_SHADED
1622
1622
  vec3 fdx = dFdx( vViewPosition );
1623
1623
  vec3 fdy = dFdy( vViewPosition );
@@ -1658,7 +1658,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1658
1658
  tbn2[1] *= faceDirection;
1659
1659
  #endif
1660
1660
  #endif
1661
- vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE
1661
+ vec3 nonPerturbedNormal = normal;`,SM=`#ifdef USE_NORMALMAP_OBJECTSPACE
1662
1662
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1663
1663
  #ifdef FLIP_SIDED
1664
1664
  normal = - normal;
@@ -1676,19 +1676,19 @@ vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE
1676
1676
  normal = normalize( tbn * mapN );
1677
1677
  #elif defined( USE_BUMPMAP )
1678
1678
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1679
- #endif`,i_=`#ifndef FLAT_SHADED
1679
+ #endif`,bM=`#ifndef FLAT_SHADED
1680
1680
  varying vec3 vNormal;
1681
1681
  #ifdef USE_TANGENT
1682
1682
  varying vec3 vTangent;
1683
1683
  varying vec3 vBitangent;
1684
1684
  #endif
1685
- #endif`,r_=`#ifndef FLAT_SHADED
1685
+ #endif`,wM=`#ifndef FLAT_SHADED
1686
1686
  varying vec3 vNormal;
1687
1687
  #ifdef USE_TANGENT
1688
1688
  varying vec3 vTangent;
1689
1689
  varying vec3 vBitangent;
1690
1690
  #endif
1691
- #endif`,a_=`#ifndef FLAT_SHADED
1691
+ #endif`,TM=`#ifndef FLAT_SHADED
1692
1692
  vNormal = normalize( transformedNormal );
1693
1693
  #ifdef USE_TANGENT
1694
1694
  vTangent = normalize( transformedTangent );
@@ -1697,7 +1697,7 @@ vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE
1697
1697
  vBitangent = - vBitangent;
1698
1698
  #endif
1699
1699
  #endif
1700
- #endif`,s_=`#ifdef USE_NORMALMAP
1700
+ #endif`,EM=`#ifdef USE_NORMALMAP
1701
1701
  uniform sampler2D normalMap;
1702
1702
  uniform vec2 normalScale;
1703
1703
  #endif
@@ -1719,13 +1719,13 @@ vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE
1719
1719
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1720
1720
  return mat3( T * scale, B * scale, N );
1721
1721
  }
1722
- #endif`,o_=`#ifdef USE_CLEARCOAT
1722
+ #endif`,AM=`#ifdef USE_CLEARCOAT
1723
1723
  vec3 clearcoatNormal = nonPerturbedNormal;
1724
- #endif`,l_=`#ifdef USE_CLEARCOAT_NORMALMAP
1724
+ #endif`,IM=`#ifdef USE_CLEARCOAT_NORMALMAP
1725
1725
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1726
1726
  clearcoatMapN.xy *= clearcoatNormalScale;
1727
1727
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1728
- #endif`,c_=`#ifdef USE_CLEARCOATMAP
1728
+ #endif`,CM=`#ifdef USE_CLEARCOATMAP
1729
1729
  uniform sampler2D clearcoatMap;
1730
1730
  #endif
1731
1731
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1734,18 +1734,18 @@ vec3 nonPerturbedNormal = normal;`,n_=`#ifdef USE_NORMALMAP_OBJECTSPACE
1734
1734
  #endif
1735
1735
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1736
1736
  uniform sampler2D clearcoatRoughnessMap;
1737
- #endif`,u_=`#ifdef USE_IRIDESCENCEMAP
1737
+ #endif`,RM=`#ifdef USE_IRIDESCENCEMAP
1738
1738
  uniform sampler2D iridescenceMap;
1739
1739
  #endif
1740
1740
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1741
1741
  uniform sampler2D iridescenceThicknessMap;
1742
- #endif`,d_=`#ifdef OPAQUE
1742
+ #endif`,PM=`#ifdef OPAQUE
1743
1743
  diffuseColor.a = 1.0;
1744
1744
  #endif
1745
1745
  #ifdef USE_TRANSMISSION
1746
1746
  diffuseColor.a *= material.transmissionAlpha;
1747
1747
  #endif
1748
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,f_=`vec3 packNormalToRGB( const in vec3 normal ) {
1748
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,LM=`vec3 packNormalToRGB( const in vec3 normal ) {
1749
1749
  return normalize( normal ) * 0.5 + 0.5;
1750
1750
  }
1751
1751
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1824,9 +1824,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1824
1824
  #else
1825
1825
  return ( near * far ) / ( ( far - near ) * depth - far );
1826
1826
  #endif
1827
- }`,h_=`#ifdef PREMULTIPLIED_ALPHA
1827
+ }`,DM=`#ifdef PREMULTIPLIED_ALPHA
1828
1828
  gl_FragColor.rgb *= gl_FragColor.a;
1829
- #endif`,p_=`vec4 mvPosition = vec4( transformed, 1.0 );
1829
+ #endif`,NM=`vec4 mvPosition = vec4( transformed, 1.0 );
1830
1830
  #ifdef USE_BATCHING
1831
1831
  mvPosition = batchingMatrix * mvPosition;
1832
1832
  #endif
@@ -1834,22 +1834,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1834
1834
  mvPosition = instanceMatrix * mvPosition;
1835
1835
  #endif
1836
1836
  mvPosition = modelViewMatrix * mvPosition;
1837
- gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING
1837
+ gl_Position = projectionMatrix * mvPosition;`,UM=`#ifdef DITHERING
1838
1838
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1839
- #endif`,v_=`#ifdef DITHERING
1839
+ #endif`,FM=`#ifdef DITHERING
1840
1840
  vec3 dithering( vec3 color ) {
1841
1841
  float grid_position = rand( gl_FragCoord.xy );
1842
1842
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1843
1843
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1844
1844
  return color + dither_shift_RGB;
1845
1845
  }
1846
- #endif`,g_=`float roughnessFactor = roughness;
1846
+ #endif`,OM=`float roughnessFactor = roughness;
1847
1847
  #ifdef USE_ROUGHNESSMAP
1848
1848
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1849
1849
  roughnessFactor *= texelRoughness.g;
1850
- #endif`,y_=`#ifdef USE_ROUGHNESSMAP
1850
+ #endif`,BM=`#ifdef USE_ROUGHNESSMAP
1851
1851
  uniform sampler2D roughnessMap;
1852
- #endif`,x_=`#if NUM_SPOT_LIGHT_COORDS > 0
1852
+ #endif`,kM=`#if NUM_SPOT_LIGHT_COORDS > 0
1853
1853
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1854
1854
  #endif
1855
1855
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2100,7 +2100,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING
2100
2100
  }
2101
2101
  #endif
2102
2102
  #endif
2103
- #endif`,__=`#if NUM_SPOT_LIGHT_COORDS > 0
2103
+ #endif`,zM=`#if NUM_SPOT_LIGHT_COORDS > 0
2104
2104
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2105
2105
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2106
2106
  #endif
@@ -2145,7 +2145,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING
2145
2145
  };
2146
2146
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2147
2147
  #endif
2148
- #endif`,M_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2148
+ #endif`,VM=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2149
2149
  #ifdef HAS_NORMAL
2150
2150
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2151
2151
  #else
@@ -2185,7 +2185,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING
2185
2185
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2186
2186
  }
2187
2187
  #pragma unroll_loop_end
2188
- #endif`,S_=`float getShadowMask() {
2188
+ #endif`,GM=`float getShadowMask() {
2189
2189
  float shadow = 1.0;
2190
2190
  #ifdef USE_SHADOWMAP
2191
2191
  #if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2226,12 +2226,12 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING
2226
2226
  #endif
2227
2227
  #endif
2228
2228
  return shadow;
2229
- }`,b_=`#ifdef USE_SKINNING
2229
+ }`,HM=`#ifdef USE_SKINNING
2230
2230
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2231
2231
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2232
2232
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2233
2233
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2234
- #endif`,w_=`#ifdef USE_SKINNING
2234
+ #endif`,WM=`#ifdef USE_SKINNING
2235
2235
  uniform mat4 bindMatrix;
2236
2236
  uniform mat4 bindMatrixInverse;
2237
2237
  uniform highp sampler2D boneTexture;
@@ -2246,7 +2246,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING
2246
2246
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2247
2247
  return mat4( v1, v2, v3, v4 );
2248
2248
  }
2249
- #endif`,T_=`#ifdef USE_SKINNING
2249
+ #endif`,XM=`#ifdef USE_SKINNING
2250
2250
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2251
2251
  vec4 skinned = vec4( 0.0 );
2252
2252
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2254,7 +2254,7 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING
2254
2254
  skinned += boneMatZ * skinVertex * skinWeight.z;
2255
2255
  skinned += boneMatW * skinVertex * skinWeight.w;
2256
2256
  transformed = ( bindMatrixInverse * skinned ).xyz;
2257
- #endif`,E_=`#ifdef USE_SKINNING
2257
+ #endif`,YM=`#ifdef USE_SKINNING
2258
2258
  mat4 skinMatrix = mat4( 0.0 );
2259
2259
  skinMatrix += skinWeight.x * boneMatX;
2260
2260
  skinMatrix += skinWeight.y * boneMatY;
@@ -2265,17 +2265,17 @@ gl_Position = projectionMatrix * mvPosition;`,m_=`#ifdef DITHERING
2265
2265
  #ifdef USE_TANGENT
2266
2266
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2267
2267
  #endif
2268
- #endif`,A_=`float specularStrength;
2268
+ #endif`,qM=`float specularStrength;
2269
2269
  #ifdef USE_SPECULARMAP
2270
2270
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2271
2271
  specularStrength = texelSpecular.r;
2272
2272
  #else
2273
2273
  specularStrength = 1.0;
2274
- #endif`,I_=`#ifdef USE_SPECULARMAP
2274
+ #endif`,ZM=`#ifdef USE_SPECULARMAP
2275
2275
  uniform sampler2D specularMap;
2276
- #endif`,C_=`#if defined( TONE_MAPPING )
2276
+ #endif`,JM=`#if defined( TONE_MAPPING )
2277
2277
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2278
- #endif`,R_=`#ifndef saturate
2278
+ #endif`,$M=`#ifndef saturate
2279
2279
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2280
2280
  #endif
2281
2281
  uniform float toneMappingExposure;
@@ -2372,7 +2372,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2372
2372
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2373
2373
  return mix( color, vec3( newPeak ), g );
2374
2374
  }
2375
- vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISSION
2375
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,KM=`#ifdef USE_TRANSMISSION
2376
2376
  material.transmission = transmission;
2377
2377
  material.transmissionAlpha = 1.0;
2378
2378
  material.thickness = thickness;
@@ -2393,7 +2393,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS
2393
2393
  material.attenuationColor, material.attenuationDistance );
2394
2394
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2395
2395
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2396
- #endif`,L_=`#ifdef USE_TRANSMISSION
2396
+ #endif`,QM=`#ifdef USE_TRANSMISSION
2397
2397
  uniform float transmission;
2398
2398
  uniform float thickness;
2399
2399
  uniform float attenuationDistance;
@@ -2519,7 +2519,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS
2519
2519
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2520
2520
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2521
2521
  }
2522
- #endif`,D_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2522
+ #endif`,jM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2523
2523
  varying vec2 vUv;
2524
2524
  #endif
2525
2525
  #ifdef USE_MAP
@@ -2589,7 +2589,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS
2589
2589
  #ifdef USE_THICKNESSMAP
2590
2590
  uniform mat3 thicknessMapTransform;
2591
2591
  varying vec2 vThicknessMapUv;
2592
- #endif`,N_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2592
+ #endif`,eS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2593
2593
  varying vec2 vUv;
2594
2594
  #endif
2595
2595
  #ifdef USE_MAP
@@ -2683,7 +2683,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS
2683
2683
  #ifdef USE_THICKNESSMAP
2684
2684
  uniform mat3 thicknessMapTransform;
2685
2685
  varying vec2 vThicknessMapUv;
2686
- #endif`,U_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2686
+ #endif`,tS=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2687
2687
  vUv = vec3( uv, 1 ).xy;
2688
2688
  #endif
2689
2689
  #ifdef USE_MAP
@@ -2754,7 +2754,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS
2754
2754
  #endif
2755
2755
  #ifdef USE_THICKNESSMAP
2756
2756
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2757
- #endif`,F_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2757
+ #endif`,nS=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2758
2758
  vec4 worldPosition = vec4( transformed, 1.0 );
2759
2759
  #ifdef USE_BATCHING
2760
2760
  worldPosition = batchingMatrix * worldPosition;
@@ -2763,12 +2763,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,P_=`#ifdef USE_TRANSMISS
2763
2763
  worldPosition = instanceMatrix * worldPosition;
2764
2764
  #endif
2765
2765
  worldPosition = modelMatrix * worldPosition;
2766
- #endif`,O_=`varying vec2 vUv;
2766
+ #endif`,iS=`varying vec2 vUv;
2767
2767
  uniform mat3 uvTransform;
2768
2768
  void main() {
2769
2769
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2770
2770
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2771
- }`,B_=`uniform sampler2D t2D;
2771
+ }`,rS=`uniform sampler2D t2D;
2772
2772
  uniform float backgroundIntensity;
2773
2773
  varying vec2 vUv;
2774
2774
  void main() {
@@ -2780,14 +2780,14 @@ void main() {
2780
2780
  gl_FragColor = texColor;
2781
2781
  #include <tonemapping_fragment>
2782
2782
  #include <colorspace_fragment>
2783
- }`,k_=`varying vec3 vWorldDirection;
2783
+ }`,aS=`varying vec3 vWorldDirection;
2784
2784
  #include <common>
2785
2785
  void main() {
2786
2786
  vWorldDirection = transformDirection( position, modelMatrix );
2787
2787
  #include <begin_vertex>
2788
2788
  #include <project_vertex>
2789
2789
  gl_Position.z = gl_Position.w;
2790
- }`,z_=`#ifdef ENVMAP_TYPE_CUBE
2790
+ }`,sS=`#ifdef ENVMAP_TYPE_CUBE
2791
2791
  uniform samplerCube envMap;
2792
2792
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2793
2793
  uniform sampler2D envMap;
@@ -2809,14 +2809,14 @@ void main() {
2809
2809
  gl_FragColor = texColor;
2810
2810
  #include <tonemapping_fragment>
2811
2811
  #include <colorspace_fragment>
2812
- }`,V_=`varying vec3 vWorldDirection;
2812
+ }`,oS=`varying vec3 vWorldDirection;
2813
2813
  #include <common>
2814
2814
  void main() {
2815
2815
  vWorldDirection = transformDirection( position, modelMatrix );
2816
2816
  #include <begin_vertex>
2817
2817
  #include <project_vertex>
2818
2818
  gl_Position.z = gl_Position.w;
2819
- }`,G_=`uniform samplerCube tCube;
2819
+ }`,lS=`uniform samplerCube tCube;
2820
2820
  uniform float tFlip;
2821
2821
  uniform float opacity;
2822
2822
  varying vec3 vWorldDirection;
@@ -2826,7 +2826,7 @@ void main() {
2826
2826
  gl_FragColor.a *= opacity;
2827
2827
  #include <tonemapping_fragment>
2828
2828
  #include <colorspace_fragment>
2829
- }`,H_=`#include <common>
2829
+ }`,cS=`#include <common>
2830
2830
  #include <batching_pars_vertex>
2831
2831
  #include <uv_pars_vertex>
2832
2832
  #include <displacementmap_pars_vertex>
@@ -2853,7 +2853,7 @@ void main() {
2853
2853
  #include <logdepthbuf_vertex>
2854
2854
  #include <clipping_planes_vertex>
2855
2855
  vHighPrecisionZW = gl_Position.zw;
2856
- }`,W_=`#if DEPTH_PACKING == 3200
2856
+ }`,uS=`#if DEPTH_PACKING == 3200
2857
2857
  uniform float opacity;
2858
2858
  #endif
2859
2859
  #include <common>
@@ -2891,7 +2891,7 @@ void main() {
2891
2891
  #elif DEPTH_PACKING == 3203
2892
2892
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2893
2893
  #endif
2894
- }`,X_=`#define DISTANCE
2894
+ }`,dS=`#define DISTANCE
2895
2895
  varying vec3 vWorldPosition;
2896
2896
  #include <common>
2897
2897
  #include <batching_pars_vertex>
@@ -2918,7 +2918,7 @@ void main() {
2918
2918
  #include <worldpos_vertex>
2919
2919
  #include <clipping_planes_vertex>
2920
2920
  vWorldPosition = worldPosition.xyz;
2921
- }`,Y_=`#define DISTANCE
2921
+ }`,fS=`#define DISTANCE
2922
2922
  uniform vec3 referencePosition;
2923
2923
  uniform float nearDistance;
2924
2924
  uniform float farDistance;
@@ -2941,13 +2941,13 @@ void main() {
2941
2941
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2942
2942
  dist = saturate( dist );
2943
2943
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
2944
- }`,q_=`varying vec3 vWorldDirection;
2944
+ }`,hS=`varying vec3 vWorldDirection;
2945
2945
  #include <common>
2946
2946
  void main() {
2947
2947
  vWorldDirection = transformDirection( position, modelMatrix );
2948
2948
  #include <begin_vertex>
2949
2949
  #include <project_vertex>
2950
- }`,Z_=`uniform sampler2D tEquirect;
2950
+ }`,pS=`uniform sampler2D tEquirect;
2951
2951
  varying vec3 vWorldDirection;
2952
2952
  #include <common>
2953
2953
  void main() {
@@ -2956,7 +2956,7 @@ void main() {
2956
2956
  gl_FragColor = texture2D( tEquirect, sampleUV );
2957
2957
  #include <tonemapping_fragment>
2958
2958
  #include <colorspace_fragment>
2959
- }`,J_=`uniform float scale;
2959
+ }`,mS=`uniform float scale;
2960
2960
  attribute float lineDistance;
2961
2961
  varying float vLineDistance;
2962
2962
  #include <common>
@@ -2978,7 +2978,7 @@ void main() {
2978
2978
  #include <logdepthbuf_vertex>
2979
2979
  #include <clipping_planes_vertex>
2980
2980
  #include <fog_vertex>
2981
- }`,$_=`uniform vec3 diffuse;
2981
+ }`,vS=`uniform vec3 diffuse;
2982
2982
  uniform float opacity;
2983
2983
  uniform float dashSize;
2984
2984
  uniform float totalSize;
@@ -3006,7 +3006,7 @@ void main() {
3006
3006
  #include <colorspace_fragment>
3007
3007
  #include <fog_fragment>
3008
3008
  #include <premultiplied_alpha_fragment>
3009
- }`,K_=`#include <common>
3009
+ }`,gS=`#include <common>
3010
3010
  #include <batching_pars_vertex>
3011
3011
  #include <uv_pars_vertex>
3012
3012
  #include <envmap_pars_vertex>
@@ -3038,7 +3038,7 @@ void main() {
3038
3038
  #include <worldpos_vertex>
3039
3039
  #include <envmap_vertex>
3040
3040
  #include <fog_vertex>
3041
- }`,Q_=`uniform vec3 diffuse;
3041
+ }`,yS=`uniform vec3 diffuse;
3042
3042
  uniform float opacity;
3043
3043
  #ifndef FLAT_SHADED
3044
3044
  varying vec3 vNormal;
@@ -3086,7 +3086,7 @@ void main() {
3086
3086
  #include <fog_fragment>
3087
3087
  #include <premultiplied_alpha_fragment>
3088
3088
  #include <dithering_fragment>
3089
- }`,j_=`#define LAMBERT
3089
+ }`,xS=`#define LAMBERT
3090
3090
  varying vec3 vViewPosition;
3091
3091
  #include <common>
3092
3092
  #include <batching_pars_vertex>
@@ -3125,7 +3125,7 @@ void main() {
3125
3125
  #include <envmap_vertex>
3126
3126
  #include <shadowmap_vertex>
3127
3127
  #include <fog_vertex>
3128
- }`,eM=`#define LAMBERT
3128
+ }`,_S=`#define LAMBERT
3129
3129
  uniform vec3 diffuse;
3130
3130
  uniform vec3 emissive;
3131
3131
  uniform float opacity;
@@ -3183,7 +3183,7 @@ void main() {
3183
3183
  #include <fog_fragment>
3184
3184
  #include <premultiplied_alpha_fragment>
3185
3185
  #include <dithering_fragment>
3186
- }`,tM=`#define MATCAP
3186
+ }`,MS=`#define MATCAP
3187
3187
  varying vec3 vViewPosition;
3188
3188
  #include <common>
3189
3189
  #include <batching_pars_vertex>
@@ -3217,7 +3217,7 @@ void main() {
3217
3217
  #include <clipping_planes_vertex>
3218
3218
  #include <fog_vertex>
3219
3219
  vViewPosition = - mvPosition.xyz;
3220
- }`,nM=`#define MATCAP
3220
+ }`,SS=`#define MATCAP
3221
3221
  uniform vec3 diffuse;
3222
3222
  uniform float opacity;
3223
3223
  uniform sampler2D matcap;
@@ -3263,7 +3263,7 @@ void main() {
3263
3263
  #include <fog_fragment>
3264
3264
  #include <premultiplied_alpha_fragment>
3265
3265
  #include <dithering_fragment>
3266
- }`,iM=`#define NORMAL
3266
+ }`,bS=`#define NORMAL
3267
3267
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3268
3268
  varying vec3 vViewPosition;
3269
3269
  #endif
@@ -3296,7 +3296,7 @@ void main() {
3296
3296
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3297
3297
  vViewPosition = - mvPosition.xyz;
3298
3298
  #endif
3299
- }`,rM=`#define NORMAL
3299
+ }`,wS=`#define NORMAL
3300
3300
  uniform float opacity;
3301
3301
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3302
3302
  varying vec3 vViewPosition;
@@ -3317,7 +3317,7 @@ void main() {
3317
3317
  #ifdef OPAQUE
3318
3318
  gl_FragColor.a = 1.0;
3319
3319
  #endif
3320
- }`,aM=`#define PHONG
3320
+ }`,TS=`#define PHONG
3321
3321
  varying vec3 vViewPosition;
3322
3322
  #include <common>
3323
3323
  #include <batching_pars_vertex>
@@ -3356,7 +3356,7 @@ void main() {
3356
3356
  #include <envmap_vertex>
3357
3357
  #include <shadowmap_vertex>
3358
3358
  #include <fog_vertex>
3359
- }`,sM=`#define PHONG
3359
+ }`,ES=`#define PHONG
3360
3360
  uniform vec3 diffuse;
3361
3361
  uniform vec3 emissive;
3362
3362
  uniform vec3 specular;
@@ -3416,7 +3416,7 @@ void main() {
3416
3416
  #include <fog_fragment>
3417
3417
  #include <premultiplied_alpha_fragment>
3418
3418
  #include <dithering_fragment>
3419
- }`,oM=`#define STANDARD
3419
+ }`,AS=`#define STANDARD
3420
3420
  varying vec3 vViewPosition;
3421
3421
  #ifdef USE_TRANSMISSION
3422
3422
  varying vec3 vWorldPosition;
@@ -3459,7 +3459,7 @@ void main() {
3459
3459
  #ifdef USE_TRANSMISSION
3460
3460
  vWorldPosition = worldPosition.xyz;
3461
3461
  #endif
3462
- }`,lM=`#define STANDARD
3462
+ }`,IS=`#define STANDARD
3463
3463
  #ifdef PHYSICAL
3464
3464
  #define IOR
3465
3465
  #define USE_SPECULAR
@@ -3587,7 +3587,7 @@ void main() {
3587
3587
  #include <fog_fragment>
3588
3588
  #include <premultiplied_alpha_fragment>
3589
3589
  #include <dithering_fragment>
3590
- }`,cM=`#define TOON
3590
+ }`,CS=`#define TOON
3591
3591
  varying vec3 vViewPosition;
3592
3592
  #include <common>
3593
3593
  #include <batching_pars_vertex>
@@ -3624,7 +3624,7 @@ void main() {
3624
3624
  #include <worldpos_vertex>
3625
3625
  #include <shadowmap_vertex>
3626
3626
  #include <fog_vertex>
3627
- }`,uM=`#define TOON
3627
+ }`,RS=`#define TOON
3628
3628
  uniform vec3 diffuse;
3629
3629
  uniform vec3 emissive;
3630
3630
  uniform float opacity;
@@ -3676,7 +3676,7 @@ void main() {
3676
3676
  #include <fog_fragment>
3677
3677
  #include <premultiplied_alpha_fragment>
3678
3678
  #include <dithering_fragment>
3679
- }`,dM=`uniform float size;
3679
+ }`,PS=`uniform float size;
3680
3680
  uniform float scale;
3681
3681
  #include <common>
3682
3682
  #include <color_pars_vertex>
@@ -3707,7 +3707,7 @@ void main() {
3707
3707
  #include <clipping_planes_vertex>
3708
3708
  #include <worldpos_vertex>
3709
3709
  #include <fog_vertex>
3710
- }`,fM=`uniform vec3 diffuse;
3710
+ }`,LS=`uniform vec3 diffuse;
3711
3711
  uniform float opacity;
3712
3712
  #include <common>
3713
3713
  #include <color_pars_fragment>
@@ -3732,7 +3732,7 @@ void main() {
3732
3732
  #include <colorspace_fragment>
3733
3733
  #include <fog_fragment>
3734
3734
  #include <premultiplied_alpha_fragment>
3735
- }`,hM=`#include <common>
3735
+ }`,DS=`#include <common>
3736
3736
  #include <batching_pars_vertex>
3737
3737
  #include <fog_pars_vertex>
3738
3738
  #include <morphtarget_pars_vertex>
@@ -3755,7 +3755,7 @@ void main() {
3755
3755
  #include <worldpos_vertex>
3756
3756
  #include <shadowmap_vertex>
3757
3757
  #include <fog_vertex>
3758
- }`,pM=`uniform vec3 color;
3758
+ }`,NS=`uniform vec3 color;
3759
3759
  uniform float opacity;
3760
3760
  #include <common>
3761
3761
  #include <fog_pars_fragment>
@@ -3771,7 +3771,7 @@ void main() {
3771
3771
  #include <colorspace_fragment>
3772
3772
  #include <fog_fragment>
3773
3773
  #include <premultiplied_alpha_fragment>
3774
- }`,mM=`uniform float rotation;
3774
+ }`,US=`uniform float rotation;
3775
3775
  uniform vec2 center;
3776
3776
  #include <common>
3777
3777
  #include <uv_pars_vertex>
@@ -3795,7 +3795,7 @@ void main() {
3795
3795
  #include <logdepthbuf_vertex>
3796
3796
  #include <clipping_planes_vertex>
3797
3797
  #include <fog_vertex>
3798
- }`,vM=`uniform vec3 diffuse;
3798
+ }`,FS=`uniform vec3 diffuse;
3799
3799
  uniform float opacity;
3800
3800
  #include <common>
3801
3801
  #include <uv_pars_fragment>
@@ -3820,7 +3820,7 @@ void main() {
3820
3820
  #include <tonemapping_fragment>
3821
3821
  #include <colorspace_fragment>
3822
3822
  #include <fog_fragment>
3823
- }`,gn={alphahash_fragment:Oy,alphahash_pars_fragment:By,alphamap_fragment:ky,alphamap_pars_fragment:zy,alphatest_fragment:Vy,alphatest_pars_fragment:Gy,aomap_fragment:Hy,aomap_pars_fragment:Wy,batching_pars_vertex:Xy,batching_vertex:Yy,begin_vertex:qy,beginnormal_vertex:Zy,bsdfs:Jy,iridescence_fragment:$y,bumpmap_pars_fragment:Ky,clipping_planes_fragment:Qy,clipping_planes_pars_fragment:jy,clipping_planes_pars_vertex:ex,clipping_planes_vertex:tx,color_fragment:nx,color_pars_fragment:ix,color_pars_vertex:rx,color_vertex:ax,common:sx,cube_uv_reflection_fragment:ox,defaultnormal_vertex:lx,displacementmap_pars_vertex:cx,displacementmap_vertex:ux,emissivemap_fragment:dx,emissivemap_pars_fragment:fx,colorspace_fragment:hx,colorspace_pars_fragment:px,envmap_fragment:mx,envmap_common_pars_fragment:vx,envmap_pars_fragment:gx,envmap_pars_vertex:yx,envmap_physical_pars_fragment:Cx,envmap_vertex:xx,fog_vertex:_x,fog_pars_vertex:Mx,fog_fragment:Sx,fog_pars_fragment:bx,gradientmap_pars_fragment:wx,lightmap_pars_fragment:Tx,lights_lambert_fragment:Ex,lights_lambert_pars_fragment:Ax,lights_pars_begin:Ix,lights_toon_fragment:Rx,lights_toon_pars_fragment:Px,lights_phong_fragment:Lx,lights_phong_pars_fragment:Dx,lights_physical_fragment:Nx,lights_physical_pars_fragment:Ux,lights_fragment_begin:Fx,lights_fragment_maps:Ox,lights_fragment_end:Bx,lightprobes_pars_fragment:kx,logdepthbuf_fragment:zx,logdepthbuf_pars_fragment:Vx,logdepthbuf_pars_vertex:Gx,logdepthbuf_vertex:Hx,map_fragment:Wx,map_pars_fragment:Xx,map_particle_fragment:Yx,map_particle_pars_fragment:qx,metalnessmap_fragment:Zx,metalnessmap_pars_fragment:Jx,morphinstance_vertex:$x,morphcolor_vertex:Kx,morphnormal_vertex:Qx,morphtarget_pars_vertex:jx,morphtarget_vertex:e_,normal_fragment_begin:t_,normal_fragment_maps:n_,normal_pars_fragment:i_,normal_pars_vertex:r_,normal_vertex:a_,normalmap_pars_fragment:s_,clearcoat_normal_fragment_begin:o_,clearcoat_normal_fragment_maps:l_,clearcoat_pars_fragment:c_,iridescence_pars_fragment:u_,opaque_fragment:d_,packing:f_,premultiplied_alpha_fragment:h_,project_vertex:p_,dithering_fragment:m_,dithering_pars_fragment:v_,roughnessmap_fragment:g_,roughnessmap_pars_fragment:y_,shadowmap_pars_fragment:x_,shadowmap_pars_vertex:__,shadowmap_vertex:M_,shadowmask_pars_fragment:S_,skinbase_vertex:b_,skinning_pars_vertex:w_,skinning_vertex:T_,skinnormal_vertex:E_,specularmap_fragment:A_,specularmap_pars_fragment:I_,tonemapping_fragment:C_,tonemapping_pars_fragment:R_,transmission_fragment:P_,transmission_pars_fragment:L_,uv_pars_fragment:D_,uv_pars_vertex:N_,uv_vertex:U_,worldpos_vertex:F_,background_vert:O_,background_frag:B_,backgroundCube_vert:k_,backgroundCube_frag:z_,cube_vert:V_,cube_frag:G_,depth_vert:H_,depth_frag:W_,distance_vert:X_,distance_frag:Y_,equirect_vert:q_,equirect_frag:Z_,linedashed_vert:J_,linedashed_frag:$_,meshbasic_vert:K_,meshbasic_frag:Q_,meshlambert_vert:j_,meshlambert_frag:eM,meshmatcap_vert:tM,meshmatcap_frag:nM,meshnormal_vert:iM,meshnormal_frag:rM,meshphong_vert:aM,meshphong_frag:sM,meshphysical_vert:oM,meshphysical_frag:lM,meshtoon_vert:cM,meshtoon_frag:uM,points_vert:dM,points_frag:fM,shadow_vert:hM,shadow_frag:pM,sprite_vert:mM,sprite_frag:vM},At={common:{diffuse:{value:new vn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new un}},envmap:{envMap:{value:null},envMapRotation:{value:new un},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new un}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new un}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new un},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new un},normalScale:{value:new kt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new un},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new un}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new un}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new un}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new vn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new ge},probesMax:{value:new ge},probesResolution:{value:new ge}},points:{diffuse:{value:new vn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0},uvTransform:{value:new un}},sprite:{diffuse:{value:new vn(16777215)},opacity:{value:1},center:{value:new kt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}}},Ca={basic:{uniforms:ir([At.common,At.specularmap,At.envmap,At.aomap,At.lightmap,At.fog]),vertexShader:gn.meshbasic_vert,fragmentShader:gn.meshbasic_frag},lambert:{uniforms:ir([At.common,At.specularmap,At.envmap,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.fog,At.lights,{emissive:{value:new vn(0)},envMapIntensity:{value:1}}]),vertexShader:gn.meshlambert_vert,fragmentShader:gn.meshlambert_frag},phong:{uniforms:ir([At.common,At.specularmap,At.envmap,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.fog,At.lights,{emissive:{value:new vn(0)},specular:{value:new vn(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:gn.meshphong_vert,fragmentShader:gn.meshphong_frag},standard:{uniforms:ir([At.common,At.envmap,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.roughnessmap,At.metalnessmap,At.fog,At.lights,{emissive:{value:new vn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag},toon:{uniforms:ir([At.common,At.aomap,At.lightmap,At.emissivemap,At.bumpmap,At.normalmap,At.displacementmap,At.gradientmap,At.fog,At.lights,{emissive:{value:new vn(0)}}]),vertexShader:gn.meshtoon_vert,fragmentShader:gn.meshtoon_frag},matcap:{uniforms:ir([At.common,At.bumpmap,At.normalmap,At.displacementmap,At.fog,{matcap:{value:null}}]),vertexShader:gn.meshmatcap_vert,fragmentShader:gn.meshmatcap_frag},points:{uniforms:ir([At.points,At.fog]),vertexShader:gn.points_vert,fragmentShader:gn.points_frag},dashed:{uniforms:ir([At.common,At.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:gn.linedashed_vert,fragmentShader:gn.linedashed_frag},depth:{uniforms:ir([At.common,At.displacementmap]),vertexShader:gn.depth_vert,fragmentShader:gn.depth_frag},normal:{uniforms:ir([At.common,At.bumpmap,At.normalmap,At.displacementmap,{opacity:{value:1}}]),vertexShader:gn.meshnormal_vert,fragmentShader:gn.meshnormal_frag},sprite:{uniforms:ir([At.sprite,At.fog]),vertexShader:gn.sprite_vert,fragmentShader:gn.sprite_frag},background:{uniforms:{uvTransform:{value:new un},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:gn.background_vert,fragmentShader:gn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new un}},vertexShader:gn.backgroundCube_vert,fragmentShader:gn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:gn.cube_vert,fragmentShader:gn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:gn.equirect_vert,fragmentShader:gn.equirect_frag},distance:{uniforms:ir([At.common,At.displacementmap,{referencePosition:{value:new ge},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:gn.distance_vert,fragmentShader:gn.distance_frag},shadow:{uniforms:ir([At.lights,At.fog,{color:{value:new vn(0)},opacity:{value:1}}]),vertexShader:gn.shadow_vert,fragmentShader:gn.shadow_frag}};Ca.physical={uniforms:ir([Ca.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new un},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new un},clearcoatNormalScale:{value:new kt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new un},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new un},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new un},sheen:{value:0},sheenColor:{value:new vn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new un},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new un},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new un},transmissionSamplerSize:{value:new kt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new un},attenuationDistance:{value:0},attenuationColor:{value:new vn(0)},specularColor:{value:new vn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new un},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new un},anisotropyVector:{value:new kt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new un}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag};var wd={r:0,b:0,g:0},gM=new $n,K0=new un;K0.set(-1,0,0,0,1,0,0,0,1);function yM(n,e,t,i,r,a){let s=new vn(0),o=r===!0?0:1,u,l,d=null,f=0,h=null;function v(L){let F=L.isScene===!0?L.background:null;if(F&&F.isTexture){let _=L.backgroundBlurriness>0;F=e.get(F,_)}return F}function y(L){let F=!1,_=v(L);_===null?g(s,o):_&&_.isColor&&(g(_,1),F=!0);let p=n.xr.getEnvironmentBlendMode();p==="additive"?t.buffers.color.setClear(0,0,0,1,a):p==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,a),(n.autoClear||F)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function T(L,F){let _=v(F);_&&(_.isCubeTexture||_.mapping===zl)?(l===void 0&&(l=new jn(new Or(1,1,1),new kr({name:"BackgroundCubeMaterial",uniforms:Bs(Ca.backgroundCube.uniforms),vertexShader:Ca.backgroundCube.vertexShader,fragmentShader:Ca.backgroundCube.fragmentShader,side:pr,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(p,S,B){this.matrixWorld.copyPosition(B.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=_,l.material.uniforms.backgroundBlurriness.value=F.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=F.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(gM.makeRotationFromEuler(F.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(K0),l.material.toneMapped=Ln.getTransfer(_.colorSpace)!==Jn,(d!==_||f!==_.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,d=_,f=_.version,h=n.toneMapping),l.layers.enableAll(),L.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(u===void 0&&(u=new jn(new Pl(2,2),new kr({name:"BackgroundMaterial",uniforms:Bs(Ca.background.uniforms),vertexShader:Ca.background.vertexShader,fragmentShader:Ca.background.fragmentShader,side:ms,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=_,u.material.uniforms.backgroundIntensity.value=F.backgroundIntensity,u.material.toneMapped=Ln.getTransfer(_.colorSpace)!==Jn,_.matrixAutoUpdate===!0&&_.updateMatrix(),u.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||f!==_.version||h!==n.toneMapping)&&(u.material.needsUpdate=!0,d=_,f=_.version,h=n.toneMapping),u.layers.enableAll(),L.unshift(u,u.geometry,u.material,0,0,null))}function g(L,F){L.getRGB(wd,Sh(n)),t.buffers.color.setClear(wd.r,wd.g,wd.b,F,a)}function m(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return s},setClearColor:function(L,F=1){s.set(L),o=F,g(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(L){o=L,g(s,o)},render:y,addToRenderList:T,dispose:m}}function xM(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),a=r,s=!1;function o(U,Y,E,M,O){let H=!1,ee=f(U,M,E,Y);a!==ee&&(a=ee,l(a.object)),H=v(U,M,E,O),H&&y(U,M,E,O),O!==null&&e.update(O,n.ELEMENT_ARRAY_BUFFER),(H||s)&&(s=!1,_(U,Y,E,M),O!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function u(){return n.createVertexArray()}function l(U){return n.bindVertexArray(U)}function d(U){return n.deleteVertexArray(U)}function f(U,Y,E,M){let O=M.wireframe===!0,H=i[Y.id];H===void 0&&(H={},i[Y.id]=H);let ee=U.isInstancedMesh===!0?U.id:0,j=H[ee];j===void 0&&(j={},H[ee]=j);let K=j[E.id];K===void 0&&(K={},j[E.id]=K);let re=K[O];return re===void 0&&(re=h(u()),K[O]=re),re}function h(U){let Y=[],E=[],M=[];for(let O=0;O<t;O++)Y[O]=0,E[O]=0,M[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:Y,enabledAttributes:E,attributeDivisors:M,object:U,attributes:{},index:null}}function v(U,Y,E,M){let O=a.attributes,H=Y.attributes,ee=0,j=E.getAttributes();for(let K in j)if(j[K].location>=0){let J=O[K],ne=H[K];if(ne===void 0&&(K==="instanceMatrix"&&U.instanceMatrix&&(ne=U.instanceMatrix),K==="instanceColor"&&U.instanceColor&&(ne=U.instanceColor)),J===void 0||J.attribute!==ne||ne&&J.data!==ne.data)return!0;ee++}return a.attributesNum!==ee||a.index!==M}function y(U,Y,E,M){let O={},H=Y.attributes,ee=0,j=E.getAttributes();for(let K in j)if(j[K].location>=0){let J=H[K];J===void 0&&(K==="instanceMatrix"&&U.instanceMatrix&&(J=U.instanceMatrix),K==="instanceColor"&&U.instanceColor&&(J=U.instanceColor));let ne={};ne.attribute=J,J&&J.data&&(ne.data=J.data),O[K]=ne,ee++}a.attributes=O,a.attributesNum=ee,a.index=M}function T(){let U=a.newAttributes;for(let Y=0,E=U.length;Y<E;Y++)U[Y]=0}function g(U){m(U,0)}function m(U,Y){let E=a.newAttributes,M=a.enabledAttributes,O=a.attributeDivisors;E[U]=1,M[U]===0&&(n.enableVertexAttribArray(U),M[U]=1),O[U]!==Y&&(n.vertexAttribDivisor(U,Y),O[U]=Y)}function L(){let U=a.newAttributes,Y=a.enabledAttributes;for(let E=0,M=Y.length;E<M;E++)Y[E]!==U[E]&&(n.disableVertexAttribArray(E),Y[E]=0)}function F(U,Y,E,M,O,H,ee){ee===!0?n.vertexAttribIPointer(U,Y,E,O,H):n.vertexAttribPointer(U,Y,E,M,O,H)}function _(U,Y,E,M){T();let O=M.attributes,H=E.getAttributes(),ee=Y.defaultAttributeValues;for(let j in H){let K=H[j];if(K.location>=0){let re=O[j];if(re===void 0&&(j==="instanceMatrix"&&U.instanceMatrix&&(re=U.instanceMatrix),j==="instanceColor"&&U.instanceColor&&(re=U.instanceColor)),re!==void 0){let J=re.normalized,ne=re.itemSize,Te=e.get(re);if(Te===void 0)continue;let fe=Te.buffer,pe=Te.type,Fe=Te.bytesPerElement,ae=pe===n.INT||pe===n.UNSIGNED_INT||re.gpuType===Bu;if(re.isInterleavedBufferAttribute){let de=re.data,_e=de.stride,Ge=re.offset;if(de.isInstancedInterleavedBuffer){for(let $e=0;$e<K.locationSize;$e++)m(K.location+$e,de.meshPerAttribute);U.isInstancedMesh!==!0&&M._maxInstanceCount===void 0&&(M._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let $e=0;$e<K.locationSize;$e++)g(K.location+$e);n.bindBuffer(n.ARRAY_BUFFER,fe);for(let $e=0;$e<K.locationSize;$e++)F(K.location+$e,ne/K.locationSize,pe,J,_e*Fe,(Ge+ne/K.locationSize*$e)*Fe,ae)}else{if(re.isInstancedBufferAttribute){for(let de=0;de<K.locationSize;de++)m(K.location+de,re.meshPerAttribute);U.isInstancedMesh!==!0&&M._maxInstanceCount===void 0&&(M._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let de=0;de<K.locationSize;de++)g(K.location+de);n.bindBuffer(n.ARRAY_BUFFER,fe);for(let de=0;de<K.locationSize;de++)F(K.location+de,ne/K.locationSize,pe,J,ne*Fe,ne/K.locationSize*de*Fe,ae)}}else if(ee!==void 0){let J=ee[j];if(J!==void 0)switch(J.length){case 2:n.vertexAttrib2fv(K.location,J);break;case 3:n.vertexAttrib3fv(K.location,J);break;case 4:n.vertexAttrib4fv(K.location,J);break;default:n.vertexAttrib1fv(K.location,J)}}}}L()}function p(){I();for(let U in i){let Y=i[U];for(let E in Y){let M=Y[E];for(let O in M){let H=M[O];for(let ee in H)d(H[ee].object),delete H[ee];delete M[O]}}delete i[U]}}function S(U){if(i[U.id]===void 0)return;let Y=i[U.id];for(let E in Y){let M=Y[E];for(let O in M){let H=M[O];for(let ee in H)d(H[ee].object),delete H[ee];delete M[O]}}delete i[U.id]}function B(U){for(let Y in i){let E=i[Y];for(let M in E){let O=E[M];if(O[U.id]===void 0)continue;let H=O[U.id];for(let ee in H)d(H[ee].object),delete H[ee];delete O[U.id]}}}function b(U){for(let Y in i){let E=i[Y],M=U.isInstancedMesh===!0?U.id:0,O=E[M];if(O!==void 0){for(let H in O){let ee=O[H];for(let j in ee)d(ee[j].object),delete ee[j];delete O[H]}delete E[M],Object.keys(E).length===0&&delete i[Y]}}}function I(){z(),s=!0,a!==r&&(a=r,l(a.object))}function z(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:I,resetDefaultState:z,dispose:p,releaseStatesOfGeometry:S,releaseStatesOfObject:b,releaseStatesOfProgram:B,initAttributes:T,enableAttribute:g,disableUnusedAttributes:L}}function _M(n,e,t){let i;function r(u){i=u}function a(u,l){n.drawArrays(i,u,l),t.update(l,i,1)}function s(u,l,d){d!==0&&(n.drawArraysInstanced(i,u,l,d),t.update(l,i,d))}function o(u,l,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,u,0,l,0,d);let h=0;for(let v=0;v<d;v++)h+=l[v];t.update(h,i,1)}this.setMode=r,this.render=a,this.renderInstances=s,this.renderMultiDraw=o}function MM(n,e,t,i){let r;function a(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let B=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(B.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(B){return!(B!==qr&&i.convert(B)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(B){let b=B===oa&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(B!==Cr&&B!==Yr&&!b&&i.convert(B)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE))}function u(B){if(B==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";B="mediump"}return B==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",d=u(l);d!==l&&(rn("WebGLRenderer:",l,"not supported, using",d,"instead."),l=d);let f=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&rn("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let v=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),y=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),T=n.getParameter(n.MAX_TEXTURE_SIZE),g=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),m=n.getParameter(n.MAX_VERTEX_ATTRIBS),L=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),F=n.getParameter(n.MAX_VARYING_VECTORS),_=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),p=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:u,textureFormatReadable:s,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:v,maxVertexTextures:y,maxTextureSize:T,maxCubemapSize:g,maxAttributes:m,maxVertexUniforms:L,maxVaryings:F,maxFragmentUniforms:_,maxSamples:p,samples:S}}function SM(n){let e=this,t=null,i=0,r=!1,a=!1,s=new Ur,o=new un,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let v=f.length!==0||h||i!==0||r;return r=h,i=f.length,v},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,h){t=d(f,h,0)},this.setState=function(f,h,v){let y=f.clippingPlanes,T=f.clipIntersection,g=f.clipShadows,m=n.get(f);if(!r||y===null||y.length===0||a&&!g)a?d(null):l();else{let L=a?0:i,F=L*4,_=m.clippingState||null;u.value=_,_=d(y,h,F,v);for(let p=0;p!==F;++p)_[p]=t[p];m.clippingState=_,this.numIntersection=T?this.numPlanes:0,this.numPlanes+=L}};function l(){u.value!==t&&(u.value=t,u.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(f,h,v,y){let T=f!==null?f.length:0,g=null;if(T!==0){if(g=u.value,y!==!0||g===null){let m=v+T*4,L=h.matrixWorldInverse;o.getNormalMatrix(L),(g===null||g.length<m)&&(g=new Float32Array(m));for(let F=0,_=v;F!==T;++F,_+=4)s.copy(f[F]).applyMatrix4(L,o),s.normal.toArray(g,_),g[_+3]=s.constant}u.value=g,u.needsUpdate=!0}return e.numPlanes=T,e.numIntersection=0,g}}var Lo=4,bM=6,wM=20,TM=256,Zl=new To,C0=new vn,Ph=null,Lh=0,Dh=0,Nh=!1,EM=new ge,ks=new ge,Ed=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,a={}){let{size:s=256,position:o=EM}=a;Ph=this._renderer.getRenderTarget(),Lh=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Nh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let u=this._allocateTargets();return u.depthBuffer=!0,this._sceneToCubeUV(e,i,r,u,o),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=L0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=P0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ph,Lh,Dh),this._renderer.xr.enabled=Nh,e.scissorTest=!1,Po(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===vs||e.mapping===Os?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ph=this._renderer.getRenderTarget(),Lh=this._renderer.getActiveCubeFace(),Dh=this._renderer.getActiveMipmapLevel(),Nh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Hi,minFilter:Hi,generateMipmaps:!1,type:oa,format:qr,colorSpace:fl,depthBuffer:!1},r=R0(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=R0(e,t,i);let{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=AM(a)),this._blurMaterial=CM(a,e,t),this._ggxMaterial=IM(a,e,t)}return r}_compileMaterial(e){let t=new jn(new Wi,e);this._renderer.compile(t,Zl)}_sceneToCubeUV(e,t,i,r,a){let u=new er(90,1,t,i),l=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,h=f.autoClear,v=f.toneMapping;f.getClearColor(C0),f.toneMapping=aa,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new jn(new Or,new Ta({name:"PMREM.Background",side:pr,depthWrite:!1,depthTest:!1})));let T=this._backgroundBox,g=T.material,m=!1,L=e.background;L?L.isColor&&(g.color.copy(L),e.background=null,m=!0):(g.color.copy(C0),m=!0);for(let F=0;F<6;F++){let _=F%3;_===0?(u.up.set(0,l[F],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x+d[F],a.y,a.z)):_===1?(u.up.set(0,0,l[F]),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y+d[F],a.z)):(u.up.set(0,l[F],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y,a.z+d[F]));let p=this._cubeSize;Po(r,_*p,F>2?p:0,p,p),f.setRenderTarget(r),m&&f.render(T,u),f.render(e,u)}f.toneMapping=v,f.autoClear=h,e.background=L}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===vs||e.mapping===Os;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=L0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=P0());let a=r?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;let o=a.uniforms;o.envMap.value=e;let u=this._cubeSize;Po(t,0,0,3*u,2*u),i.setRenderTarget(t),i.render(s,Zl)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let a=1;a<r;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=i}_applyGGXFilter(e,t,i){let r=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[i];o.material=s;let u=s.uniforms,l=i/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),f=Math.sqrt(l*l-d*d),h=l*1.25,v=f*h,{_lodMax:y}=this,T=this._sizeLods[i],g=3*T*(i>y-Lo?i-y+Lo:0),m=4*(this._cubeSize-T);u.envMap.value=e.texture,u.roughness.value=v,u.mipInt.value=y-t,Po(a,g,m,3*T,2*T),r.setRenderTarget(a),r.render(o,Zl),u.envMap.value=a.texture,u.roughness.value=0,u.mipInt.value=y-i,Po(e,g,m,3*T,2*T),r.setRenderTarget(e),r.render(o,Zl)}_blur(e,t,i,r){let a=this._pingPongRenderTarget,s=Math.min(r,Math.PI)/Math.SQRT2;this._blurPass(e,a,t,i,s),this._blurPass(a,e,i,i,s)}_blurPass(e,t,i,r,a){let s=this._renderer,o=this._blurMaterial,u=this._lodMeshes[r];u.material=o;let l=o.uniforms;l.envMap.value=e.texture,l.sigma.value=a,l.mipInt.value=this._lodMax-i;let d=this._sizeLods[r],f=3*d*(r>this._lodMax-Lo?r-this._lodMax+Lo:0),h=4*(this._cubeSize-d);Po(t,f,h,3*d,2*d),s.setRenderTarget(t),s.render(u,Zl)}};function AM(n){let e=[],t=[],i=n,r=n-Lo+1+bM;for(let a=0;a<r;a++){let s=Math.pow(2,i);e.push(s);let o=1/(s-2),u=-o,l=1+o,d=[u,u,l,u,l,l,u,u,l,l,u,l],f=6,h=6,v=3,y=new Float32Array(v*h*f),T=new Float32Array(v*h*f);for(let m=0;m<f;m++){let L=m%3*2/3-1,F=m>2?0:-1,_=[L,F,0,L+2/3,F,0,L+2/3,F+1,0,L,F,0,L+2/3,F+1,0,L,F+1,0];y.set(_,v*h*m);for(let p=0;p<h;p++){let S=d[p*2]*2-1,B=d[p*2+1]*2-1;m===0?ks.set(1,B,S):m===1?ks.set(-S,1,-B):m===2?ks.set(-S,B,1):m===3?ks.set(-1,B,-S):m===4?ks.set(-S,-1,B):ks.set(S,B,-1),ks.toArray(T,(m*h+p)*v)}}let g=new Wi;g.setAttribute("position",new Fr(y,v)),g.setAttribute("outputDirection",new Fr(T,v)),t.push(new jn(g,null)),i>Lo&&i--}return{lodMeshes:t,sizeLods:e}}function R0(n,e,t){let i=new Ar(n,e,t);return i.texture.mapping=zl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Po(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function IM(n,e,t){return new kr({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:TM,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Cd(),fragmentShader:`
3823
+ }`,ai={alphahash_fragment:i_,alphahash_pars_fragment:r_,alphamap_fragment:a_,alphamap_pars_fragment:s_,alphatest_fragment:o_,alphatest_pars_fragment:l_,aomap_fragment:c_,aomap_pars_fragment:u_,batching_pars_vertex:d_,batching_vertex:f_,begin_vertex:h_,beginnormal_vertex:p_,bsdfs:m_,iridescence_fragment:v_,bumpmap_pars_fragment:g_,clipping_planes_fragment:y_,clipping_planes_pars_fragment:x_,clipping_planes_pars_vertex:__,clipping_planes_vertex:M_,color_fragment:S_,color_pars_fragment:b_,color_pars_vertex:w_,color_vertex:T_,common:E_,cube_uv_reflection_fragment:A_,defaultnormal_vertex:I_,displacementmap_pars_vertex:C_,displacementmap_vertex:R_,emissivemap_fragment:P_,emissivemap_pars_fragment:L_,colorspace_fragment:D_,colorspace_pars_fragment:N_,envmap_fragment:U_,envmap_common_pars_fragment:F_,envmap_pars_fragment:O_,envmap_pars_vertex:B_,envmap_physical_pars_fragment:J_,envmap_vertex:k_,fog_vertex:z_,fog_pars_vertex:V_,fog_fragment:G_,fog_pars_fragment:H_,gradientmap_pars_fragment:W_,lightmap_pars_fragment:X_,lights_lambert_fragment:Y_,lights_lambert_pars_fragment:q_,lights_pars_begin:Z_,lights_toon_fragment:$_,lights_toon_pars_fragment:K_,lights_phong_fragment:Q_,lights_phong_pars_fragment:j_,lights_physical_fragment:eM,lights_physical_pars_fragment:tM,lights_fragment_begin:nM,lights_fragment_maps:iM,lights_fragment_end:rM,lightprobes_pars_fragment:aM,logdepthbuf_fragment:sM,logdepthbuf_pars_fragment:oM,logdepthbuf_pars_vertex:lM,logdepthbuf_vertex:cM,map_fragment:uM,map_pars_fragment:dM,map_particle_fragment:fM,map_particle_pars_fragment:hM,metalnessmap_fragment:pM,metalnessmap_pars_fragment:mM,morphinstance_vertex:vM,morphcolor_vertex:gM,morphnormal_vertex:yM,morphtarget_pars_vertex:xM,morphtarget_vertex:_M,normal_fragment_begin:MM,normal_fragment_maps:SM,normal_pars_fragment:bM,normal_pars_vertex:wM,normal_vertex:TM,normalmap_pars_fragment:EM,clearcoat_normal_fragment_begin:AM,clearcoat_normal_fragment_maps:IM,clearcoat_pars_fragment:CM,iridescence_pars_fragment:RM,opaque_fragment:PM,packing:LM,premultiplied_alpha_fragment:DM,project_vertex:NM,dithering_fragment:UM,dithering_pars_fragment:FM,roughnessmap_fragment:OM,roughnessmap_pars_fragment:BM,shadowmap_pars_fragment:kM,shadowmap_pars_vertex:zM,shadowmap_vertex:VM,shadowmask_pars_fragment:GM,skinbase_vertex:HM,skinning_pars_vertex:WM,skinning_vertex:XM,skinnormal_vertex:YM,specularmap_fragment:qM,specularmap_pars_fragment:ZM,tonemapping_fragment:JM,tonemapping_pars_fragment:$M,transmission_fragment:KM,transmission_pars_fragment:QM,uv_pars_fragment:jM,uv_pars_vertex:eS,uv_vertex:tS,worldpos_vertex:nS,background_vert:iS,background_frag:rS,backgroundCube_vert:aS,backgroundCube_frag:sS,cube_vert:oS,cube_frag:lS,depth_vert:cS,depth_frag:uS,distance_vert:dS,distance_frag:fS,equirect_vert:hS,equirect_frag:pS,linedashed_vert:mS,linedashed_frag:vS,meshbasic_vert:gS,meshbasic_frag:yS,meshlambert_vert:xS,meshlambert_frag:_S,meshmatcap_vert:MS,meshmatcap_frag:SS,meshnormal_vert:bS,meshnormal_frag:wS,meshphong_vert:TS,meshphong_frag:ES,meshphysical_vert:AS,meshphysical_frag:IS,meshtoon_vert:CS,meshtoon_frag:RS,points_vert:PS,points_frag:LS,shadow_vert:DS,shadow_frag:NS,sprite_vert:US,sprite_frag:FS},$t={common:{diffuse:{value:new Wn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qn},alphaMap:{value:null},alphaMapTransform:{value:new qn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qn}},envmap:{envMap:{value:null},envMapRotation:{value:new qn},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qn},normalScale:{value:new ln(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Wn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new Se},probesMax:{value:new Se},probesResolution:{value:new Se}},points:{diffuse:{value:new Wn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qn},alphaTest:{value:0},uvTransform:{value:new qn}},sprite:{diffuse:{value:new Wn(16777215)},opacity:{value:1},center:{value:new ln(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qn},alphaMap:{value:null},alphaMapTransform:{value:new qn},alphaTest:{value:0}}},rs={basic:{uniforms:Hr([$t.common,$t.specularmap,$t.envmap,$t.aomap,$t.lightmap,$t.fog]),vertexShader:ai.meshbasic_vert,fragmentShader:ai.meshbasic_frag},lambert:{uniforms:Hr([$t.common,$t.specularmap,$t.envmap,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.fog,$t.lights,{emissive:{value:new Wn(0)},envMapIntensity:{value:1}}]),vertexShader:ai.meshlambert_vert,fragmentShader:ai.meshlambert_frag},phong:{uniforms:Hr([$t.common,$t.specularmap,$t.envmap,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.fog,$t.lights,{emissive:{value:new Wn(0)},specular:{value:new Wn(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ai.meshphong_vert,fragmentShader:ai.meshphong_frag},standard:{uniforms:Hr([$t.common,$t.envmap,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.roughnessmap,$t.metalnessmap,$t.fog,$t.lights,{emissive:{value:new Wn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ai.meshphysical_vert,fragmentShader:ai.meshphysical_frag},toon:{uniforms:Hr([$t.common,$t.aomap,$t.lightmap,$t.emissivemap,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.gradientmap,$t.fog,$t.lights,{emissive:{value:new Wn(0)}}]),vertexShader:ai.meshtoon_vert,fragmentShader:ai.meshtoon_frag},matcap:{uniforms:Hr([$t.common,$t.bumpmap,$t.normalmap,$t.displacementmap,$t.fog,{matcap:{value:null}}]),vertexShader:ai.meshmatcap_vert,fragmentShader:ai.meshmatcap_frag},points:{uniforms:Hr([$t.points,$t.fog]),vertexShader:ai.points_vert,fragmentShader:ai.points_frag},dashed:{uniforms:Hr([$t.common,$t.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ai.linedashed_vert,fragmentShader:ai.linedashed_frag},depth:{uniforms:Hr([$t.common,$t.displacementmap]),vertexShader:ai.depth_vert,fragmentShader:ai.depth_frag},normal:{uniforms:Hr([$t.common,$t.bumpmap,$t.normalmap,$t.displacementmap,{opacity:{value:1}}]),vertexShader:ai.meshnormal_vert,fragmentShader:ai.meshnormal_frag},sprite:{uniforms:Hr([$t.sprite,$t.fog]),vertexShader:ai.sprite_vert,fragmentShader:ai.sprite_frag},background:{uniforms:{uvTransform:{value:new qn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ai.background_vert,fragmentShader:ai.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qn}},vertexShader:ai.backgroundCube_vert,fragmentShader:ai.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ai.cube_vert,fragmentShader:ai.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ai.equirect_vert,fragmentShader:ai.equirect_frag},distance:{uniforms:Hr([$t.common,$t.displacementmap,{referencePosition:{value:new Se},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ai.distance_vert,fragmentShader:ai.distance_frag},shadow:{uniforms:Hr([$t.lights,$t.fog,{color:{value:new Wn(0)},opacity:{value:1}}]),vertexShader:ai.shadow_vert,fragmentShader:ai.shadow_frag}};rs.physical={uniforms:Hr([rs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qn},clearcoatNormalScale:{value:new ln(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qn},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qn},sheen:{value:0},sheenColor:{value:new Wn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qn},transmissionSamplerSize:{value:new ln},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qn},attenuationDistance:{value:0},attenuationColor:{value:new Wn(0)},specularColor:{value:new Wn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qn},anisotropyVector:{value:new ln},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qn}}]),vertexShader:ai.meshphysical_vert,fragmentShader:ai.meshphysical_frag};var xf={r:0,b:0,g:0},OS=new Jn,ag=new qn;ag.set(-1,0,0,0,1,0,0,0,1);function BS(n,e,t,i,r,a){let s=new Wn(0),o=r===!0?0:1,u,l,d=null,f=0,h=null;function m(F){let P=F.isScene===!0?F.background:null;if(P&&P.isTexture){let S=F.backgroundBlurriness>0;P=e.get(P,S)}return P}function x(F){let P=!1,S=m(F);S===null?g(s,o):S&&S.isColor&&(g(S,1),P=!0);let N=n.xr.getEnvironmentBlendMode();N==="additive"?t.buffers.color.setClear(0,0,0,1,a):N==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,a),(n.autoClear||P)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(F,P){let S=m(P);S&&(S.isCubeTexture||S.mapping===Oc)?(l===void 0&&(l=new bi(new jr(1,1,1),new pa({name:"BackgroundCubeMaterial",uniforms:Mo(rs.backgroundCube.uniforms),vertexShader:rs.backgroundCube.vertexShader,fragmentShader:rs.backgroundCube.fragmentShader,side:ea,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(N,p,L){this.matrixWorld.copyPosition(L.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=P.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=P.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(OS.makeRotationFromEuler(P.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(ag),l.material.toneMapped=vi.getTransfer(S.colorSpace)!==Di,(d!==S||f!==S.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,d=S,f=S.version,h=n.toneMapping),l.layers.enableAll(),F.unshift(l,l.geometry,l.material,0,0,null)):S&&S.isTexture&&(u===void 0&&(u=new bi(new Ec(2,2),new pa({name:"BackgroundMaterial",uniforms:Mo(rs.background.uniforms),vertexShader:rs.background.vertexShader,fragmentShader:rs.background.fragmentShader,side:es,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=S,u.material.uniforms.backgroundIntensity.value=P.backgroundIntensity,u.material.toneMapped=vi.getTransfer(S.colorSpace)!==Di,S.matrixAutoUpdate===!0&&S.updateMatrix(),u.material.uniforms.uvTransform.value.copy(S.matrix),(d!==S||f!==S.version||h!==n.toneMapping)&&(u.material.needsUpdate=!0,d=S,f=S.version,h=n.toneMapping),u.layers.enableAll(),F.unshift(u,u.geometry,u.material,0,0,null))}function g(F,P){F.getRGB(xf,bp(n)),t.buffers.color.setClear(xf.r,xf.g,xf.b,P,a)}function v(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return s},setClearColor:function(F,P=1){s.set(F),o=P,g(s,o)},getClearAlpha:function(){return o},setClearAlpha:function(F){o=F,g(s,o)},render:x,addToRenderList:_,dispose:v}}function kS(n,e){let t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=h(null),a=r,s=!1;function o(Y,W,C,M,J){let q=!1,ce=f(Y,M,C,W);a!==ce&&(a=ce,l(a.object)),q=m(Y,M,C,J),q&&x(Y,M,C,J),J!==null&&e.update(J,n.ELEMENT_ARRAY_BUFFER),(q||s)&&(s=!1,S(Y,W,C,M),J!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(J).buffer))}function u(){return n.createVertexArray()}function l(Y){return n.bindVertexArray(Y)}function d(Y){return n.deleteVertexArray(Y)}function f(Y,W,C,M){let J=M.wireframe===!0,q=i[W.id];q===void 0&&(q={},i[W.id]=q);let ce=Y.isInstancedMesh===!0?Y.id:0,k=q[ce];k===void 0&&(k={},q[ce]=k);let G=k[C.id];G===void 0&&(G={},k[C.id]=G);let te=G[J];return te===void 0&&(te=h(u()),G[J]=te),te}function h(Y){let W=[],C=[],M=[];for(let J=0;J<t;J++)W[J]=0,C[J]=0,M[J]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:C,attributeDivisors:M,object:Y,attributes:{},index:null}}function m(Y,W,C,M){let J=a.attributes,q=W.attributes,ce=0,k=C.getAttributes();for(let G in k)if(k[G].location>=0){let le=J[G],ge=q[G];if(ge===void 0&&(G==="instanceMatrix"&&Y.instanceMatrix&&(ge=Y.instanceMatrix),G==="instanceColor"&&Y.instanceColor&&(ge=Y.instanceColor)),le===void 0||le.attribute!==ge||ge&&le.data!==ge.data)return!0;ce++}return a.attributesNum!==ce||a.index!==M}function x(Y,W,C,M){let J={},q=W.attributes,ce=0,k=C.getAttributes();for(let G in k)if(k[G].location>=0){let le=q[G];le===void 0&&(G==="instanceMatrix"&&Y.instanceMatrix&&(le=Y.instanceMatrix),G==="instanceColor"&&Y.instanceColor&&(le=Y.instanceColor));let ge={};ge.attribute=le,le&&le.data&&(ge.data=le.data),J[G]=ge,ce++}a.attributes=J,a.attributesNum=ce,a.index=M}function _(){let Y=a.newAttributes;for(let W=0,C=Y.length;W<C;W++)Y[W]=0}function g(Y){v(Y,0)}function v(Y,W){let C=a.newAttributes,M=a.enabledAttributes,J=a.attributeDivisors;C[Y]=1,M[Y]===0&&(n.enableVertexAttribArray(Y),M[Y]=1),J[Y]!==W&&(n.vertexAttribDivisor(Y,W),J[Y]=W)}function F(){let Y=a.newAttributes,W=a.enabledAttributes;for(let C=0,M=W.length;C<M;C++)W[C]!==Y[C]&&(n.disableVertexAttribArray(C),W[C]=0)}function P(Y,W,C,M,J,q,ce){ce===!0?n.vertexAttribIPointer(Y,W,C,J,q):n.vertexAttribPointer(Y,W,C,M,J,q)}function S(Y,W,C,M){_();let J=M.attributes,q=C.getAttributes(),ce=W.defaultAttributeValues;for(let k in q){let G=q[k];if(G.location>=0){let te=J[k];if(te===void 0&&(k==="instanceMatrix"&&Y.instanceMatrix&&(te=Y.instanceMatrix),k==="instanceColor"&&Y.instanceColor&&(te=Y.instanceColor)),te!==void 0){let le=te.normalized,ge=te.itemSize,oe=e.get(te);if(oe===void 0)continue;let $=oe.buffer,Te=oe.type,Le=oe.bytesPerElement,se=Te===n.INT||Te===n.UNSIGNED_INT||te.gpuType===Dd;if(te.isInterleavedBufferAttribute){let re=te.data,Ie=re.stride,ke=te.offset;if(re.isInstancedInterleavedBuffer){for(let xe=0;xe<G.locationSize;xe++)v(G.location+xe,re.meshPerAttribute);Y.isInstancedMesh!==!0&&M._maxInstanceCount===void 0&&(M._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let xe=0;xe<G.locationSize;xe++)g(G.location+xe);n.bindBuffer(n.ARRAY_BUFFER,$);for(let xe=0;xe<G.locationSize;xe++)P(G.location+xe,ge/G.locationSize,Te,le,Ie*Le,(ke+ge/G.locationSize*xe)*Le,se)}else{if(te.isInstancedBufferAttribute){for(let re=0;re<G.locationSize;re++)v(G.location+re,te.meshPerAttribute);Y.isInstancedMesh!==!0&&M._maxInstanceCount===void 0&&(M._maxInstanceCount=te.meshPerAttribute*te.count)}else for(let re=0;re<G.locationSize;re++)g(G.location+re);n.bindBuffer(n.ARRAY_BUFFER,$);for(let re=0;re<G.locationSize;re++)P(G.location+re,ge/G.locationSize,Te,le,ge*Le,ge/G.locationSize*re*Le,se)}}else if(ce!==void 0){let le=ce[k];if(le!==void 0)switch(le.length){case 2:n.vertexAttrib2fv(G.location,le);break;case 3:n.vertexAttrib3fv(G.location,le);break;case 4:n.vertexAttrib4fv(G.location,le);break;default:n.vertexAttrib1fv(G.location,le)}}}}F()}function N(){D();for(let Y in i){let W=i[Y];for(let C in W){let M=W[C];for(let J in M){let q=M[J];for(let ce in q)d(q[ce].object),delete q[ce];delete M[J]}}delete i[Y]}}function p(Y){if(i[Y.id]===void 0)return;let W=i[Y.id];for(let C in W){let M=W[C];for(let J in M){let q=M[J];for(let ce in q)d(q[ce].object),delete q[ce];delete M[J]}}delete i[Y.id]}function L(Y){for(let W in i){let C=i[W];for(let M in C){let J=C[M];if(J[Y.id]===void 0)continue;let q=J[Y.id];for(let ce in q)d(q[ce].object),delete q[ce];delete J[Y.id]}}}function E(Y){for(let W in i){let C=i[W],M=Y.isInstancedMesh===!0?Y.id:0,J=C[M];if(J!==void 0){for(let q in J){let ce=J[q];for(let k in ce)d(ce[k].object),delete ce[k];delete J[q]}delete C[M],Object.keys(C).length===0&&delete i[W]}}}function D(){X(),s=!0,a!==r&&(a=r,l(a.object))}function X(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:D,resetDefaultState:X,dispose:N,releaseStatesOfGeometry:p,releaseStatesOfObject:E,releaseStatesOfProgram:L,initAttributes:_,enableAttribute:g,disableUnusedAttributes:F}}function zS(n,e,t){let i;function r(u){i=u}function a(u,l){n.drawArrays(i,u,l),t.update(l,i,1)}function s(u,l,d){d!==0&&(n.drawArraysInstanced(i,u,l,d),t.update(l,i,d))}function o(u,l,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,u,0,l,0,d);let h=0;for(let m=0;m<d;m++)h+=l[m];t.update(h,i,1)}this.setMode=r,this.render=a,this.renderInstances=s,this.renderMultiDraw=o}function VS(n,e,t,i){let r;function a(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let L=e.get("EXT_texture_filter_anisotropic");r=n.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(L){return!(L!==ga&&i.convert(L)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(L){let E=L===Va&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(L!==ca&&L!==va&&!E&&i.convert(L)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE))}function u(L){if(L==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";L="mediump"}return L==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",d=u(l);d!==l&&(Rn("WebGLRenderer:",l,"not supported, using",d,"instead."),l=d);let f=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Rn("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let m=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),x=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),g=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),v=n.getParameter(n.MAX_VERTEX_ATTRIBS),F=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),P=n.getParameter(n.MAX_VARYING_VECTORS),S=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),N=n.getParameter(n.MAX_SAMPLES),p=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:u,textureFormatReadable:s,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:m,maxVertexTextures:x,maxTextureSize:_,maxCubemapSize:g,maxAttributes:v,maxVertexUniforms:F,maxVaryings:P,maxFragmentUniforms:S,maxSamples:N,samples:p}}function GS(n){let e=this,t=null,i=0,r=!1,a=!1,s=new fa,o=new qn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(f,h){let m=f.length!==0||h||i!==0||r;return r=h,i=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,h){t=d(f,h,0)},this.setState=function(f,h,m){let x=f.clippingPlanes,_=f.clipIntersection,g=f.clipShadows,v=n.get(f);if(!r||x===null||x.length===0||a&&!g)a?d(null):l();else{let F=a?0:i,P=F*4,S=v.clippingState||null;u.value=S,S=d(x,h,P,m);for(let N=0;N!==P;++N)S[N]=t[N];v.clippingState=S,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=F}};function l(){u.value!==t&&(u.value=t,u.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(f,h,m,x){let _=f!==null?f.length:0,g=null;if(_!==0){if(g=u.value,x!==!0||g===null){let v=m+_*4,F=h.matrixWorldInverse;o.getNormalMatrix(F),(g===null||g.length<v)&&(g=new Float32Array(v));for(let P=0,S=m;P!==_;++P,S+=4)s.copy(f[P]).applyMatrix4(F,o),s.normal.toArray(g,S),g[S+3]=s.constant}u.value=g,u.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,g}}var wl=4,HS=6,WS=20,XS=256,Xc=new vl,O0=new Wn,Lp=null,Dp=0,Np=0,Up=!1,YS=new Se,So=new Se,El=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,r=100,a={}){let{size:s=256,position:o=YS}=a;Lp=this._renderer.getRenderTarget(),Dp=this._renderer.getActiveCubeFace(),Np=this._renderer.getActiveMipmapLevel(),Up=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);let u=this._allocateTargets();return u.depthBuffer=!0,this._sceneToCubeUV(e,i,r,u,o),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=z0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=k0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Lp,Dp,Np),this._renderer.xr.enabled=Up,e.scissorTest=!1,bl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===qs||e.mapping===yo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Lp=this._renderer.getRenderTarget(),Dp=this._renderer.getActiveCubeFace(),Np=this._renderer.getActiveMipmapLevel(),Up=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:fr,minFilter:fr,generateMipmaps:!1,type:Va,format:ga,colorSpace:lc,depthBuffer:!1},r=B0(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=B0(e,t,i);let{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods}=qS(a)),this._blurMaterial=JS(a,e,t),this._ggxMaterial=ZS(a,e,t)}return r}_compileMaterial(e){let t=new bi(new pr,e);this._renderer.compile(t,Xc)}_sceneToCubeUV(e,t,i,r,a){let u=new zr(90,1,t,i),l=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,h=f.autoClear,m=f.toneMapping;f.getClearColor(O0),f.toneMapping=la,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new bi(new jr,new oa({name:"PMREM.Background",side:ea,depthWrite:!1,depthTest:!1})));let _=this._backgroundBox,g=_.material,v=!1,F=e.background;F?F.isColor&&(g.color.copy(F),e.background=null,v=!0):(g.color.copy(O0),v=!0);for(let P=0;P<6;P++){let S=P%3;S===0?(u.up.set(0,l[P],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x+d[P],a.y,a.z)):S===1?(u.up.set(0,0,l[P]),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y+d[P],a.z)):(u.up.set(0,l[P],0),u.position.set(a.x,a.y,a.z),u.lookAt(a.x,a.y,a.z+d[P]));let N=this._cubeSize;bl(r,S*N,P>2?N:0,N,N),f.setRenderTarget(r),v&&f.render(_,u),f.render(e,u)}f.toneMapping=m,f.autoClear=h,e.background=F}_textureToCubeUV(e,t){let i=this._renderer,r=e.mapping===qs||e.mapping===yo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=z0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=k0());let a=r?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;let o=a.uniforms;o.envMap.value=e;let u=this._cubeSize;bl(t,0,0,3*u,2*u),i.setRenderTarget(t),i.render(s,Xc)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let a=1;a<r;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=i}_applyGGXFilter(e,t,i){let r=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[i];o.material=s;let u=s.uniforms,l=i/(this._lodMeshes.length-1),d=t/(this._lodMeshes.length-1),f=Math.sqrt(l*l-d*d),h=l*1.25,m=f*h,{_lodMax:x}=this,_=this._sizeLods[i],g=3*_*(i>x-wl?i-x+wl:0),v=4*(this._cubeSize-_);u.envMap.value=e.texture,u.roughness.value=m,u.mipInt.value=x-t,bl(a,g,v,3*_,2*_),r.setRenderTarget(a),r.render(o,Xc),u.envMap.value=a.texture,u.roughness.value=0,u.mipInt.value=x-i,bl(e,g,v,3*_,2*_),r.setRenderTarget(e),r.render(o,Xc)}_blur(e,t,i,r){let a=this._pingPongRenderTarget,s=Math.min(r,Math.PI)/Math.SQRT2;this._blurPass(e,a,t,i,s),this._blurPass(a,e,i,i,s)}_blurPass(e,t,i,r,a){let s=this._renderer,o=this._blurMaterial,u=this._lodMeshes[r];u.material=o;let l=o.uniforms;l.envMap.value=e.texture,l.sigma.value=a,l.mipInt.value=this._lodMax-i;let d=this._sizeLods[r],f=3*d*(r>this._lodMax-wl?r-this._lodMax+wl:0),h=4*(this._cubeSize-d);bl(t,f,h,3*d,2*d),s.setRenderTarget(t),s.render(u,Xc)}};function qS(n){let e=[],t=[],i=n,r=n-wl+1+HS;for(let a=0;a<r;a++){let s=Math.pow(2,i);e.push(s);let o=1/(s-2),u=-o,l=1+o,d=[u,u,l,u,l,l,u,u,l,l,u,l],f=6,h=6,m=3,x=new Float32Array(m*h*f),_=new Float32Array(m*h*f);for(let v=0;v<f;v++){let F=v%3*2/3-1,P=v>2?0:-1,S=[F,P,0,F+2/3,P,0,F+2/3,P+1,0,F,P,0,F+2/3,P+1,0,F,P+1,0];x.set(S,m*h*v);for(let N=0;N<h;N++){let p=d[N*2]*2-1,L=d[N*2+1]*2-1;v===0?So.set(1,L,p):v===1?So.set(-p,1,-L):v===2?So.set(-p,L,1):v===3?So.set(-1,L,-p):v===4?So.set(-p,-1,L):So.set(p,L,-1),So.toArray(_,(v*h+N)*m)}}let g=new pr;g.setAttribute("position",new Vr(x,m)),g.setAttribute("outputDirection",new Vr(_,m)),t.push(new bi(g,null)),i>wl&&i--}return{lodMeshes:t,sizeLods:e}}function B0(n,e,t){let i=new sa(n,e,t);return i.texture.mapping=Oc,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function bl(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function ZS(n,e,t){return new pa({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:XS,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:bf(),fragmentShader:`
3824
3824
 
3825
3825
  precision highp float;
3826
3826
  precision highp int;
@@ -3924,7 +3924,7 @@ void main() {
3924
3924
 
3925
3925
  gl_FragColor = vec4(prefilteredColor, 1.0);
3926
3926
  }
3927
- `,blending:Aa,depthTest:!1,depthWrite:!1})}function CM(n,e,t){return new kr({name:"SphericalGaussianBlur",defines:{SAMPLES:wM,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Cd(),fragmentShader:`
3927
+ `,blending:ts,depthTest:!1,depthWrite:!1})}function JS(n,e,t){return new pa({name:"SphericalGaussianBlur",defines:{SAMPLES:WS,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:bf(),fragmentShader:`
3928
3928
 
3929
3929
  precision highp float;
3930
3930
  precision highp int;
@@ -3984,7 +3984,7 @@ void main() {
3984
3984
  gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
3985
3985
 
3986
3986
  }
3987
- `,blending:Aa,depthTest:!1,depthWrite:!1})}function P0(){return new kr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Cd(),fragmentShader:`
3987
+ `,blending:ts,depthTest:!1,depthWrite:!1})}function k0(){return new pa({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:bf(),fragmentShader:`
3988
3988
 
3989
3989
  precision mediump float;
3990
3990
  precision mediump int;
@@ -4003,7 +4003,7 @@ void main() {
4003
4003
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
4004
4004
 
4005
4005
  }
4006
- `,blending:Aa,depthTest:!1,depthWrite:!1})}function L0(){return new kr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Cd(),fragmentShader:`
4006
+ `,blending:ts,depthTest:!1,depthWrite:!1})}function z0(){return new pa({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:bf(),fragmentShader:`
4007
4007
 
4008
4008
  precision mediump float;
4009
4009
  precision mediump int;
@@ -4019,7 +4019,7 @@ void main() {
4019
4019
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
4020
4020
 
4021
4021
  }
4022
- `,blending:Aa,depthTest:!1,depthWrite:!1})}function Cd(){return`
4022
+ `,blending:ts,depthTest:!1,depthWrite:!1})}function bf(){return`
4023
4023
 
4024
4024
  precision mediump float;
4025
4025
  precision mediump int;
@@ -4034,7 +4034,7 @@ void main() {
4034
4034
  gl_Position = vec4( position, 1.0 );
4035
4035
 
4036
4036
  }
4037
- `}var Ad=class extends Ar{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Sl(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
4037
+ `}var Mf=class extends sa{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new gc(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`
4038
4038
 
4039
4039
  varying vec3 vWorldDirection;
4040
4040
 
@@ -4069,7 +4069,7 @@ void main() {
4069
4069
  gl_FragColor = texture2D( tEquirect, sampleUV );
4070
4070
 
4071
4071
  }
4072
- `},r=new Or(5,5,5),a=new kr({name:"CubemapFromEquirect",uniforms:Bs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:pr,blending:Aa});a.uniforms.tEquirect.value=t;let s=new jn(r,a),o=t.minFilter;return t.minFilter===gs&&(t.minFilter=Hi),new Ru(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){let a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,r);e.setRenderTarget(a)}};function RM(n){let e=new WeakMap,t=new WeakMap,i=null;function r(h,v=!1){return h==null?null:v?s(h):a(h)}function a(h){if(h&&h.isTexture){let v=h.mapping;if(v===Uu||v===Fu)if(e.has(h)){let y=e.get(h).texture;return o(y,h.mapping)}else{let y=h.image;if(y&&y.height>0){let T=new Ad(y.height);return T.fromEquirectangularTexture(n,h),e.set(h,T),h.addEventListener("dispose",l),o(T.texture,h.mapping)}else return null}}return h}function s(h){if(h&&h.isTexture){let v=h.mapping,y=v===Uu||v===Fu,T=v===vs||v===Os;if(y||T){let g=t.get(h),m=g!==void 0?g.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==m)return i===null&&(i=new Ed(n)),g=y?i.fromEquirectangular(h,g):i.fromCubemap(h,g),g.texture.pmremVersion=h.pmremVersion,t.set(h,g),g.texture;if(g!==void 0)return g.texture;{let L=h.image;return y&&L&&L.height>0||T&&L&&u(L)?(i===null&&(i=new Ed(n)),g=y?i.fromEquirectangular(h):i.fromCubemap(h),g.texture.pmremVersion=h.pmremVersion,t.set(h,g),h.addEventListener("dispose",d),g.texture):null}}}return h}function o(h,v){return v===Uu?h.mapping=vs:v===Fu&&(h.mapping=Os),h}function u(h){let v=0,y=6;for(let T=0;T<y;T++)h[T]!==void 0&&v++;return v===y}function l(h){let v=h.target;v.removeEventListener("dispose",l);let y=e.get(v);y!==void 0&&(e.delete(v),y.dispose())}function d(h){let v=h.target;v.removeEventListener("dispose",d);let y=t.get(v);y!==void 0&&(t.delete(v),y.dispose())}function f(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:r,dispose:f}}function PM(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r=n.getExtension(i);return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let r=t(i);return r===null&&Ls("WebGLRenderer: "+i+" extension not supported."),r}}}function LM(n,e,t,i){let r={},a=new WeakMap;function s(f){let h=f.target;h.index!==null&&e.remove(h.index);for(let y in h.attributes)e.remove(h.attributes[y]);h.removeEventListener("dispose",s),delete r[h.id];let v=a.get(h);v&&(e.remove(v),a.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function o(f,h){return r[h.id]===!0||(h.addEventListener("dispose",s),r[h.id]=!0,t.memory.geometries++),h}function u(f){let h=f.attributes;for(let v in h)e.update(h[v],n.ARRAY_BUFFER)}function l(f){let h=[],v=f.index,y=f.attributes.position,T=0;if(y===void 0)return;if(v!==null){let L=v.array;T=v.version;for(let F=0,_=L.length;F<_;F+=3){let p=L[F+0],S=L[F+1],B=L[F+2];h.push(p,S,S,B,B,p)}}else{let L=y.array;T=y.version;for(let F=0,_=L.length/3-1;F<_;F+=3){let p=F+0,S=F+1,B=F+2;h.push(p,S,S,B,B,p)}}let g=new(y.count>=65535?yl:gl)(h,1);g.version=T;let m=a.get(f);m&&e.remove(m),a.set(f,g)}function d(f){let h=a.get(f);if(h){let v=f.index;v!==null&&h.version<v.version&&l(f)}else l(f);return a.get(f)}return{get:o,update:u,getWireframeAttribute:d}}function DM(n,e,t){let i;function r(f){i=f}let a,s;function o(f){a=f.type,s=f.bytesPerElement}function u(f,h){n.drawElements(i,h,a,f*s),t.update(h,i,1)}function l(f,h,v){v!==0&&(n.drawElementsInstanced(i,h,a,f*s,v),t.update(h,i,v))}function d(f,h,v){if(v===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,a,f,0,v);let T=0;for(let g=0;g<v;g++)T+=h[g];t.update(T,i,1)}this.setMode=r,this.setIndex=o,this.render=u,this.renderInstances=l,this.renderMultiDraw=d}function NM(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(a,s,o){switch(t.calls++,s){case n.TRIANGLES:t.triangles+=o*(a/3);break;case n.LINES:t.lines+=o*(a/2);break;case n.LINE_STRIP:t.lines+=o*(a-1);break;case n.LINE_LOOP:t.lines+=o*a;break;case n.POINTS:t.points+=o*a;break;default:sn("WebGLInfo: Unknown draw mode:",s);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function UM(n,e,t){let i=new WeakMap,r=new fi;function a(s,o,u){let l=s.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=d!==void 0?d.length:0,h=i.get(o);if(h===void 0||h.count!==f){let I=function(){B.dispose(),i.delete(o),o.removeEventListener("dispose",I)};h!==void 0&&h.texture.dispose();let v=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,T=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],m=o.morphAttributes.normal||[],L=o.morphAttributes.color||[],F=0;v===!0&&(F=1),y===!0&&(F=2),T===!0&&(F=3);let _=o.attributes.position.count*F,p=1;_>e.maxTextureSize&&(p=Math.ceil(_/e.maxTextureSize),_=e.maxTextureSize);let S=new Float32Array(_*p*4*f),B=new ml(S,_,p,f);B.type=Yr,B.needsUpdate=!0;let b=F*4;for(let z=0;z<f;z++){let U=g[z],Y=m[z],E=L[z],M=_*p*4*z;for(let O=0;O<U.count;O++){let H=O*b;v===!0&&(r.fromBufferAttribute(U,O),S[M+H+0]=r.x,S[M+H+1]=r.y,S[M+H+2]=r.z,S[M+H+3]=0),y===!0&&(r.fromBufferAttribute(Y,O),S[M+H+4]=r.x,S[M+H+5]=r.y,S[M+H+6]=r.z,S[M+H+7]=0),T===!0&&(r.fromBufferAttribute(E,O),S[M+H+8]=r.x,S[M+H+9]=r.y,S[M+H+10]=r.z,S[M+H+11]=E.itemSize===4?r.w:1)}}h={count:f,texture:B,size:new kt(_,p)},i.set(o,h),o.addEventListener("dispose",I)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)u.getUniforms().setValue(n,"morphTexture",s.morphTexture,t);else{let v=0;for(let T=0;T<l.length;T++)v+=l[T];let y=o.morphTargetsRelative?1:1-v;u.getUniforms().setValue(n,"morphTargetBaseInfluence",y),u.getUniforms().setValue(n,"morphTargetInfluences",l)}u.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),u.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:a}}function FM(n,e,t,i,r){let a=new WeakMap;function s(l){let d=r.render.frame,f=l.geometry,h=e.get(l,f);if(a.get(h)!==d&&(e.update(h),a.set(h,d)),l.isInstancedMesh&&(l.hasEventListener("dispose",u)===!1&&l.addEventListener("dispose",u),a.get(l)!==d&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),a.set(l,d))),l.isSkinnedMesh){let v=l.skeleton;a.get(v)!==d&&(v.update(),a.set(v,d))}return h}function o(){a=new WeakMap}function u(l){let d=l.target;d.removeEventListener("dispose",u),i.releaseStatesOfObject(d),t.remove(d.instanceMatrix),d.instanceColor!==null&&t.remove(d.instanceColor)}return{update:s,dispose:o}}var OM={[ah]:"LINEAR_TONE_MAPPING",[sh]:"REINHARD_TONE_MAPPING",[oh]:"CINEON_TONE_MAPPING",[lh]:"ACES_FILMIC_TONE_MAPPING",[uh]:"AGX_TONE_MAPPING",[dh]:"NEUTRAL_TONE_MAPPING",[ch]:"CUSTOM_TONE_MAPPING"};function BM(n,e,t,i,r,a){let s=new Ar(e,t,{type:n,depthBuffer:r,stencilBuffer:a,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,u=null,l=new Wi;l.setAttribute("position",new Xn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Xn([0,2,0,0,2,0],2));let d=new vu({uniforms:{tDiffuse:{value:null}},vertexShader:`
4072
+ `},r=new jr(5,5,5),a=new pa({name:"CubemapFromEquirect",uniforms:Mo(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:ea,blending:ts});a.uniforms.tEquirect.value=t;let s=new bi(r,a),o=t.minFilter;return t.minFilter===ns&&(t.minFilter=fr),new Ed(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){let a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,r);e.setRenderTarget(a)}};function $S(n){let e=new WeakMap,t=new WeakMap,i=null;function r(h,m=!1){return h==null?null:m?s(h):a(h)}function a(h){if(h&&h.isTexture){let m=h.mapping;if(m===xl||m===Pd)if(e.has(h)){let x=e.get(h).texture;return o(x,h.mapping)}else{let x=h.image;if(x&&x.height>0){let _=new Mf(x.height);return _.fromEquirectangularTexture(n,h),e.set(h,_),h.addEventListener("dispose",l),o(_.texture,h.mapping)}else return null}}return h}function s(h){if(h&&h.isTexture){let m=h.mapping,x=m===xl||m===Pd,_=m===qs||m===yo;if(x||_){let g=t.get(h),v=g!==void 0?g.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==v)return i===null&&(i=new El(n)),g=x?i.fromEquirectangular(h,g):i.fromCubemap(h,g),g.texture.pmremVersion=h.pmremVersion,t.set(h,g),g.texture;if(g!==void 0)return g.texture;{let F=h.image;return x&&F&&F.height>0||_&&F&&u(F)?(i===null&&(i=new El(n)),g=x?i.fromEquirectangular(h):i.fromCubemap(h),g.texture.pmremVersion=h.pmremVersion,t.set(h,g),h.addEventListener("dispose",d),g.texture):null}}}return h}function o(h,m){return m===xl?h.mapping=qs:m===Pd&&(h.mapping=yo),h}function u(h){let m=0,x=6;for(let _=0;_<x;_++)h[_]!==void 0&&m++;return m===x}function l(h){let m=h.target;m.removeEventListener("dispose",l);let x=e.get(m);x!==void 0&&(e.delete(m),x.dispose())}function d(h){let m=h.target;m.removeEventListener("dispose",d);let x=t.get(m);x!==void 0&&(t.delete(m),x.dispose())}function f(){e=new WeakMap,t=new WeakMap,i!==null&&(i.dispose(),i=null)}return{get:r,dispose:f}}function KS(n){let e={};function t(i){if(e[i]!==void 0)return e[i];let r=n.getExtension(i);return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){let r=t(i);return r===null&&ho("WebGLRenderer: "+i+" extension not supported."),r}}}function QS(n,e,t,i){let r={},a=new WeakMap;function s(f){let h=f.target;h.index!==null&&e.remove(h.index);for(let x in h.attributes)e.remove(h.attributes[x]);h.removeEventListener("dispose",s),delete r[h.id];let m=a.get(h);m&&(e.remove(m),a.delete(h)),i.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function o(f,h){return r[h.id]===!0||(h.addEventListener("dispose",s),r[h.id]=!0,t.memory.geometries++),h}function u(f){let h=f.attributes;for(let m in h)e.update(h[m],n.ARRAY_BUFFER)}function l(f){let h=[],m=f.index,x=f.attributes.position,_=0;if(x===void 0)return;if(m!==null){let F=m.array;_=m.version;for(let P=0,S=F.length;P<S;P+=3){let N=F[P+0],p=F[P+1],L=F[P+2];h.push(N,p,p,L,L,N)}}else{let F=x.array;_=x.version;for(let P=0,S=F.length/3-1;P<S;P+=3){let N=P+0,p=P+1,L=P+2;h.push(N,p,p,L,L,N)}}let g=new(x.count>=65535?pc:hc)(h,1);g.version=_;let v=a.get(f);v&&e.remove(v),a.set(f,g)}function d(f){let h=a.get(f);if(h){let m=f.index;m!==null&&h.version<m.version&&l(f)}else l(f);return a.get(f)}return{get:o,update:u,getWireframeAttribute:d}}function jS(n,e,t){let i;function r(f){i=f}let a,s;function o(f){a=f.type,s=f.bytesPerElement}function u(f,h){n.drawElements(i,h,a,f*s),t.update(h,i,1)}function l(f,h,m){m!==0&&(n.drawElementsInstanced(i,h,a,f*s,m),t.update(h,i,m))}function d(f,h,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,h,0,a,f,0,m);let _=0;for(let g=0;g<m;g++)_+=h[g];t.update(_,i,1)}this.setMode=r,this.setIndex=o,this.render=u,this.renderInstances=l,this.renderMultiDraw=d}function eb(n){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(a,s,o){switch(t.calls++,s){case n.TRIANGLES:t.triangles+=o*(a/3);break;case n.LINES:t.lines+=o*(a/2);break;case n.LINE_STRIP:t.lines+=o*(a-1);break;case n.LINE_LOOP:t.lines+=o*a;break;case n.POINTS:t.points+=o*a;break;default:On("WebGLInfo: Unknown draw mode:",s);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function tb(n,e,t){let i=new WeakMap,r=new Fi;function a(s,o,u){let l=s.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=d!==void 0?d.length:0,h=i.get(o);if(h===void 0||h.count!==f){let D=function(){L.dispose(),i.delete(o),o.removeEventListener("dispose",D)};h!==void 0&&h.texture.dispose();let m=o.morphAttributes.position!==void 0,x=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,g=o.morphAttributes.position||[],v=o.morphAttributes.normal||[],F=o.morphAttributes.color||[],P=0;m===!0&&(P=1),x===!0&&(P=2),_===!0&&(P=3);let S=o.attributes.position.count*P,N=1;S>e.maxTextureSize&&(N=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);let p=new Float32Array(S*N*4*f),L=new dc(p,S,N,f);L.type=va,L.needsUpdate=!0;let E=P*4;for(let X=0;X<f;X++){let Y=g[X],W=v[X],C=F[X],M=S*N*4*X;for(let J=0;J<Y.count;J++){let q=J*E;m===!0&&(r.fromBufferAttribute(Y,J),p[M+q+0]=r.x,p[M+q+1]=r.y,p[M+q+2]=r.z,p[M+q+3]=0),x===!0&&(r.fromBufferAttribute(W,J),p[M+q+4]=r.x,p[M+q+5]=r.y,p[M+q+6]=r.z,p[M+q+7]=0),_===!0&&(r.fromBufferAttribute(C,J),p[M+q+8]=r.x,p[M+q+9]=r.y,p[M+q+10]=r.z,p[M+q+11]=C.itemSize===4?r.w:1)}}h={count:f,texture:L,size:new ln(S,N)},i.set(o,h),o.addEventListener("dispose",D)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)u.getUniforms().setValue(n,"morphTexture",s.morphTexture,t);else{let m=0;for(let _=0;_<l.length;_++)m+=l[_];let x=o.morphTargetsRelative?1:1-m;u.getUniforms().setValue(n,"morphTargetBaseInfluence",x),u.getUniforms().setValue(n,"morphTargetInfluences",l)}u.getUniforms().setValue(n,"morphTargetsTexture",h.texture,t),u.getUniforms().setValue(n,"morphTargetsTextureSize",h.size)}return{update:a}}function nb(n,e,t,i,r){let a=new WeakMap;function s(l){let d=r.render.frame,f=l.geometry,h=e.get(l,f);if(a.get(h)!==d&&(e.update(h),a.set(h,d)),l.isInstancedMesh&&(l.hasEventListener("dispose",u)===!1&&l.addEventListener("dispose",u),a.get(l)!==d&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),a.set(l,d))),l.isSkinnedMesh){let m=l.skeleton;a.get(m)!==d&&(m.update(),a.set(m,d))}return h}function o(){a=new WeakMap}function u(l){let d=l.target;d.removeEventListener("dispose",u),i.releaseStatesOfObject(d),t.remove(d.instanceMatrix),d.instanceColor!==null&&t.remove(d.instanceColor)}return{update:s,dispose:o}}var ib={[lp]:"LINEAR_TONE_MAPPING",[cp]:"REINHARD_TONE_MAPPING",[up]:"CINEON_TONE_MAPPING",[Uc]:"ACES_FILMIC_TONE_MAPPING",[fp]:"AGX_TONE_MAPPING",[Fc]:"NEUTRAL_TONE_MAPPING",[dp]:"CUSTOM_TONE_MAPPING"};function rb(n,e,t,i,r,a){let s=new sa(e,t,{type:n,depthBuffer:r,stencilBuffer:a,samples:i?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,u=null,l=new pr;l.setAttribute("position",new Ci([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Ci([0,2,0,0,2,0],2));let d=new fd({uniforms:{tDiffuse:{value:null}},vertexShader:`
4073
4073
  precision highp float;
4074
4074
 
4075
4075
  uniform mat4 modelViewMatrix;
@@ -4115,17 +4115,17 @@ void main() {
4115
4115
  #ifdef SRGB_TRANSFER
4116
4116
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4117
4117
  #endif
4118
- }`,depthTest:!1,depthWrite:!1}),f=new jn(l,d),h=new To(-1,1,1,-1,0,1),v=null,y=null,T=!1,g,m=null,L=[],F=!1;this.setSize=function(_,p){s.setSize(_,p),o!==null&&o.setSize(_,p),u!==null&&u.setSize(_,p);for(let S=0;S<L.length;S++){let B=L[S];B.setSize&&B.setSize(_,p)}},this.setEffects=function(_){L=_,F=L.length>0&&L[0].isRenderPass===!0;let p=s.width,S=s.height;L.length>0&&o===null&&(o=new Ar(p,S,{type:oa,depthBuffer:!1,stencilBuffer:!1}),u=new Ar(p,S,{type:oa,depthBuffer:!1,stencilBuffer:!1}));for(let B=0;B<L.length;B++){let b=L[B];b.setSize&&b.setSize(p,S)}},this.begin=function(_,p){if(T||_.toneMapping===aa&&L.length===0)return!1;if(m=p,p!==null){let S=p.width,B=p.height;(s.width!==S||s.height!==B)&&this.setSize(S,B)}return F===!1&&_.setRenderTarget(s),g=_.toneMapping,_.toneMapping=aa,!0},this.hasRenderPass=function(){return F},this.end=function(_,p){_.toneMapping=g,T=!0;let S=s,B=o;for(let b=0;b<L.length;b++){let I=L[b];I.enabled!==!1&&(I.render(_,B,S,p),I.needsSwap!==!1&&(S=B,B=B===o?u:o))}if(v!==_.outputColorSpace||y!==_.toneMapping){v=_.outputColorSpace,y=_.toneMapping,d.defines={},Ln.getTransfer(v)===Jn&&(d.defines.SRGB_TRANSFER="");let b=OM[y];b&&(d.defines[b]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=S.texture,_.setRenderTarget(m),_.render(f,h),m=null,T=!1},this.isCompositing=function(){return T},this.dispose=function(){s.dispose(),o!==null&&o.dispose(),u!==null&&u.dispose(),l.dispose(),d.dispose()}}var Q0=new tr,Oh=new us(1,1),j0=new ml,ev=new lu,tv=new Sl,D0=[],N0=[],U0=new Float32Array(16),F0=new Float32Array(9),O0=new Float32Array(4);function No(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,a=D0[r];if(a===void 0&&(a=new Float32Array(r),D0[r]=a),e!==0){i.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=t,n[s].toArray(a,o)}return a}function Ri(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Pi(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Rd(n,e){let t=N0[e];t===void 0&&(t=new Int32Array(e),N0[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function kM(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function zM(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ri(t,e))return;n.uniform2fv(this.addr,e),Pi(t,e)}}function VM(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ri(t,e))return;n.uniform3fv(this.addr,e),Pi(t,e)}}function GM(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ri(t,e))return;n.uniform4fv(this.addr,e),Pi(t,e)}}function HM(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Ri(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Pi(t,e)}else{if(Ri(t,i))return;O0.set(i),n.uniformMatrix2fv(this.addr,!1,O0),Pi(t,i)}}function WM(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Ri(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Pi(t,e)}else{if(Ri(t,i))return;F0.set(i),n.uniformMatrix3fv(this.addr,!1,F0),Pi(t,i)}}function XM(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(Ri(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Pi(t,e)}else{if(Ri(t,i))return;U0.set(i),n.uniformMatrix4fv(this.addr,!1,U0),Pi(t,i)}}function YM(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function qM(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ri(t,e))return;n.uniform2iv(this.addr,e),Pi(t,e)}}function ZM(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ri(t,e))return;n.uniform3iv(this.addr,e),Pi(t,e)}}function JM(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ri(t,e))return;n.uniform4iv(this.addr,e),Pi(t,e)}}function $M(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function KM(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ri(t,e))return;n.uniform2uiv(this.addr,e),Pi(t,e)}}function QM(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ri(t,e))return;n.uniform3uiv(this.addr,e),Pi(t,e)}}function jM(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ri(t,e))return;n.uniform4uiv(this.addr,e),Pi(t,e)}}function eS(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let a;this.type===n.SAMPLER_2D_SHADOW?(Oh.compareFunction=t.isReversedDepthBuffer()?bd:Sd,a=Oh):a=Q0,t.setTexture2D(e||a,r)}function tS(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||ev,r)}function nS(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||tv,r)}function iS(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||j0,r)}function rS(n){switch(n){case 5126:return kM;case 35664:return zM;case 35665:return VM;case 35666:return GM;case 35674:return HM;case 35675:return WM;case 35676:return XM;case 5124:case 35670:return YM;case 35667:case 35671:return qM;case 35668:case 35672:return ZM;case 35669:case 35673:return JM;case 5125:return $M;case 36294:return KM;case 36295:return QM;case 36296:return jM;case 35678:case 36198:case 36298:case 36306:case 35682:return eS;case 35679:case 36299:case 36307:return tS;case 35680:case 36300:case 36308:case 36293:return nS;case 36289:case 36303:case 36311:case 36292:return iS}}function aS(n,e){n.uniform1fv(this.addr,e)}function sS(n,e){let t=No(e,this.size,2);n.uniform2fv(this.addr,t)}function oS(n,e){let t=No(e,this.size,3);n.uniform3fv(this.addr,t)}function lS(n,e){let t=No(e,this.size,4);n.uniform4fv(this.addr,t)}function cS(n,e){let t=No(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function uS(n,e){let t=No(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function dS(n,e){let t=No(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function fS(n,e){n.uniform1iv(this.addr,e)}function hS(n,e){n.uniform2iv(this.addr,e)}function pS(n,e){n.uniform3iv(this.addr,e)}function mS(n,e){n.uniform4iv(this.addr,e)}function vS(n,e){n.uniform1uiv(this.addr,e)}function gS(n,e){n.uniform2uiv(this.addr,e)}function yS(n,e){n.uniform3uiv(this.addr,e)}function xS(n,e){n.uniform4uiv(this.addr,e)}function _S(n,e,t){let i=this.cache,r=e.length,a=Rd(t,r);Ri(i,a)||(n.uniform1iv(this.addr,a),Pi(i,a));let s;this.type===n.SAMPLER_2D_SHADOW?s=Oh:s=Q0;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||s,a[o])}function MS(n,e,t){let i=this.cache,r=e.length,a=Rd(t,r);Ri(i,a)||(n.uniform1iv(this.addr,a),Pi(i,a));for(let s=0;s!==r;++s)t.setTexture3D(e[s]||ev,a[s])}function SS(n,e,t){let i=this.cache,r=e.length,a=Rd(t,r);Ri(i,a)||(n.uniform1iv(this.addr,a),Pi(i,a));for(let s=0;s!==r;++s)t.setTextureCube(e[s]||tv,a[s])}function bS(n,e,t){let i=this.cache,r=e.length,a=Rd(t,r);Ri(i,a)||(n.uniform1iv(this.addr,a),Pi(i,a));for(let s=0;s!==r;++s)t.setTexture2DArray(e[s]||j0,a[s])}function wS(n){switch(n){case 5126:return aS;case 35664:return sS;case 35665:return oS;case 35666:return lS;case 35674:return cS;case 35675:return uS;case 35676:return dS;case 5124:case 35670:return fS;case 35667:case 35671:return hS;case 35668:case 35672:return pS;case 35669:case 35673:return mS;case 5125:return vS;case 36294:return gS;case 36295:return yS;case 36296:return xS;case 35678:case 36198:case 36298:case 36306:case 35682:return _S;case 35679:case 36299:case 36307:return MS;case 35680:case 36300:case 36308:case 36293:return SS;case 36289:case 36303:case 36311:case 36292:return bS}}var Bh=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=rS(t.type)}},kh=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=wS(t.type)}},zh=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let a=0,s=r.length;a!==s;++a){let o=r[a];o.setValue(e,t[o.id],i)}}},Uh=/(\w+)(\])?(\[|\.)?/g;function B0(n,e){n.seq.push(e),n.map[e.id]=e}function TS(n,e,t){let i=n.name,r=i.length;for(Uh.lastIndex=0;;){let a=Uh.exec(i),s=Uh.lastIndex,o=a[1],u=a[2]==="]",l=a[3];if(u&&(o=o|0),l===void 0||l==="["&&s+2===r){B0(t,l===void 0?new Bh(o,n,e):new kh(o,n,e));break}else{let f=t.map[o];f===void 0&&(f=new zh(o),B0(t,f)),t=f}}}var Do=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<i;++s){let o=e.getActiveUniform(t,s),u=e.getUniformLocation(t,o.name);TS(o,u,this)}let r=[],a=[];for(let s of this.seq)s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(s):a.push(s);r.length>0&&(this.seq=r.concat(a))}setValue(e,t,i,r){let a=this.map[t];a!==void 0&&a.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let a=0,s=t.length;a!==s;++a){let o=t[a],u=i[o.id];u.needsUpdate!==!1&&o.setValue(e,u.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,a=e.length;r!==a;++r){let s=e[r];s.id in t&&i.push(s)}return i}};function k0(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}var ES=37297,AS=0;function IS(n,e){let t=n.split(`
4118
+ }`,depthTest:!1,depthWrite:!1}),f=new bi(l,d),h=new vl(-1,1,1,-1,0,1),m=null,x=null,_=!1,g,v=null,F=[],P=!1;this.setSize=function(S,N){s.setSize(S,N),o!==null&&o.setSize(S,N),u!==null&&u.setSize(S,N);for(let p=0;p<F.length;p++){let L=F[p];L.setSize&&L.setSize(S,N)}},this.setEffects=function(S){F=S,P=F.length>0&&F[0].isRenderPass===!0;let N=s.width,p=s.height;F.length>0&&o===null&&(o=new sa(N,p,{type:Va,depthBuffer:!1,stencilBuffer:!1}),u=new sa(N,p,{type:Va,depthBuffer:!1,stencilBuffer:!1}));for(let L=0;L<F.length;L++){let E=F[L];E.setSize&&E.setSize(N,p)}},this.begin=function(S,N){if(_||S.toneMapping===la&&F.length===0)return!1;if(v=N,N!==null){let p=N.width,L=N.height;(s.width!==p||s.height!==L)&&this.setSize(p,L)}return P===!1&&S.setRenderTarget(s),g=S.toneMapping,S.toneMapping=la,!0},this.hasRenderPass=function(){return P},this.end=function(S,N){S.toneMapping=g,_=!0;let p=s,L=o;for(let E=0;E<F.length;E++){let D=F[E];D.enabled!==!1&&(D.render(S,L,p,N),D.needsSwap!==!1&&(p=L,L=L===o?u:o))}if(m!==S.outputColorSpace||x!==S.toneMapping){m=S.outputColorSpace,x=S.toneMapping,d.defines={},vi.getTransfer(m)===Di&&(d.defines.SRGB_TRANSFER="");let E=ib[x];E&&(d.defines[E]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=p.texture,S.setRenderTarget(v),S.render(f,h),v=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){s.dispose(),o!==null&&o.dispose(),u!==null&&u.dispose(),l.dispose(),d.dispose()}}var sg=new Cr,Bp=new Hs(1,1),og=new dc,lg=new rd,cg=new gc,V0=[],G0=[],H0=new Float32Array(16),W0=new Float32Array(9),X0=new Float32Array(4);function Al(n,e,t){let i=n[0];if(i<=0||i>0)return n;let r=e*t,a=V0[r];if(a===void 0&&(a=new Float32Array(r),V0[r]=a),e!==0){i.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=t,n[s].toArray(a,o)}return a}function vr(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function gr(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function wf(n,e){let t=G0[e];t===void 0&&(t=new Int32Array(e),G0[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function ab(n,e){let t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function sb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vr(t,e))return;n.uniform2fv(this.addr,e),gr(t,e)}}function ob(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(vr(t,e))return;n.uniform3fv(this.addr,e),gr(t,e)}}function lb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(vr(t,e))return;n.uniform4fv(this.addr,e),gr(t,e)}}function cb(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(vr(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),gr(t,e)}else{if(vr(t,i))return;X0.set(i),n.uniformMatrix2fv(this.addr,!1,X0),gr(t,i)}}function ub(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(vr(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),gr(t,e)}else{if(vr(t,i))return;W0.set(i),n.uniformMatrix3fv(this.addr,!1,W0),gr(t,i)}}function db(n,e){let t=this.cache,i=e.elements;if(i===void 0){if(vr(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),gr(t,e)}else{if(vr(t,i))return;H0.set(i),n.uniformMatrix4fv(this.addr,!1,H0),gr(t,i)}}function fb(n,e){let t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function hb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vr(t,e))return;n.uniform2iv(this.addr,e),gr(t,e)}}function pb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(vr(t,e))return;n.uniform3iv(this.addr,e),gr(t,e)}}function mb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(vr(t,e))return;n.uniform4iv(this.addr,e),gr(t,e)}}function vb(n,e){let t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function gb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vr(t,e))return;n.uniform2uiv(this.addr,e),gr(t,e)}}function yb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(vr(t,e))return;n.uniform3uiv(this.addr,e),gr(t,e)}}function xb(n,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(vr(t,e))return;n.uniform4uiv(this.addr,e),gr(t,e)}}function _b(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let a;this.type===n.SAMPLER_2D_SHADOW?(Bp.compareFunction=t.isReversedDepthBuffer()?yf:gf,a=Bp):a=sg,t.setTexture2D(e||a,r)}function Mb(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||lg,r)}function Sb(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||cg,r)}function bb(n,e,t){let i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||og,r)}function wb(n){switch(n){case 5126:return ab;case 35664:return sb;case 35665:return ob;case 35666:return lb;case 35674:return cb;case 35675:return ub;case 35676:return db;case 5124:case 35670:return fb;case 35667:case 35671:return hb;case 35668:case 35672:return pb;case 35669:case 35673:return mb;case 5125:return vb;case 36294:return gb;case 36295:return yb;case 36296:return xb;case 35678:case 36198:case 36298:case 36306:case 35682:return _b;case 35679:case 36299:case 36307:return Mb;case 35680:case 36300:case 36308:case 36293:return Sb;case 36289:case 36303:case 36311:case 36292:return bb}}function Tb(n,e){n.uniform1fv(this.addr,e)}function Eb(n,e){let t=Al(e,this.size,2);n.uniform2fv(this.addr,t)}function Ab(n,e){let t=Al(e,this.size,3);n.uniform3fv(this.addr,t)}function Ib(n,e){let t=Al(e,this.size,4);n.uniform4fv(this.addr,t)}function Cb(n,e){let t=Al(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function Rb(n,e){let t=Al(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function Pb(n,e){let t=Al(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function Lb(n,e){n.uniform1iv(this.addr,e)}function Db(n,e){n.uniform2iv(this.addr,e)}function Nb(n,e){n.uniform3iv(this.addr,e)}function Ub(n,e){n.uniform4iv(this.addr,e)}function Fb(n,e){n.uniform1uiv(this.addr,e)}function Ob(n,e){n.uniform2uiv(this.addr,e)}function Bb(n,e){n.uniform3uiv(this.addr,e)}function kb(n,e){n.uniform4uiv(this.addr,e)}function zb(n,e,t){let i=this.cache,r=e.length,a=wf(t,r);vr(i,a)||(n.uniform1iv(this.addr,a),gr(i,a));let s;this.type===n.SAMPLER_2D_SHADOW?s=Bp:s=sg;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||s,a[o])}function Vb(n,e,t){let i=this.cache,r=e.length,a=wf(t,r);vr(i,a)||(n.uniform1iv(this.addr,a),gr(i,a));for(let s=0;s!==r;++s)t.setTexture3D(e[s]||lg,a[s])}function Gb(n,e,t){let i=this.cache,r=e.length,a=wf(t,r);vr(i,a)||(n.uniform1iv(this.addr,a),gr(i,a));for(let s=0;s!==r;++s)t.setTextureCube(e[s]||cg,a[s])}function Hb(n,e,t){let i=this.cache,r=e.length,a=wf(t,r);vr(i,a)||(n.uniform1iv(this.addr,a),gr(i,a));for(let s=0;s!==r;++s)t.setTexture2DArray(e[s]||og,a[s])}function Wb(n){switch(n){case 5126:return Tb;case 35664:return Eb;case 35665:return Ab;case 35666:return Ib;case 35674:return Cb;case 35675:return Rb;case 35676:return Pb;case 5124:case 35670:return Lb;case 35667:case 35671:return Db;case 35668:case 35672:return Nb;case 35669:case 35673:return Ub;case 5125:return Fb;case 36294:return Ob;case 36295:return Bb;case 36296:return kb;case 35678:case 36198:case 36298:case 36306:case 35682:return zb;case 35679:case 36299:case 36307:return Vb;case 35680:case 36300:case 36308:case 36293:return Gb;case 36289:case 36303:case 36311:case 36292:return Hb}}var kp=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=wb(t.type)}},zp=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Wb(t.type)}},Vp=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let r=this.seq;for(let a=0,s=r.length;a!==s;++a){let o=r[a];o.setValue(e,t[o.id],i)}}},Fp=/(\w+)(\])?(\[|\.)?/g;function Y0(n,e){n.seq.push(e),n.map[e.id]=e}function Xb(n,e,t){let i=n.name,r=i.length;for(Fp.lastIndex=0;;){let a=Fp.exec(i),s=Fp.lastIndex,o=a[1],u=a[2]==="]",l=a[3];if(u&&(o=o|0),l===void 0||l==="["&&s+2===r){Y0(t,l===void 0?new kp(o,n,e):new zp(o,n,e));break}else{let f=t.map[o];f===void 0&&(f=new Vp(o),Y0(t,f)),t=f}}}var Tl=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<i;++s){let o=e.getActiveUniform(t,s),u=e.getUniformLocation(t,o.name);Xb(o,u,this)}let r=[],a=[];for(let s of this.seq)s.type===e.SAMPLER_2D_SHADOW||s.type===e.SAMPLER_CUBE_SHADOW||s.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(s):a.push(s);r.length>0&&(this.seq=r.concat(a))}setValue(e,t,i,r){let a=this.map[t];a!==void 0&&a.setValue(e,i,r)}setOptional(e,t,i){let r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let a=0,s=t.length;a!==s;++a){let o=t[a],u=i[o.id];u.needsUpdate!==!1&&o.setValue(e,u.value,r)}}static seqWithValue(e,t){let i=[];for(let r=0,a=e.length;r!==a;++r){let s=e[r];s.id in t&&i.push(s)}return i}};function q0(n,e,t){let i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}var Yb=37297,qb=0;function Zb(n,e){let t=n.split(`
4119
4119
  `),i=[],r=Math.max(e-6,0),a=Math.min(e+6,t.length);for(let s=r;s<a;s++){let o=s+1;i.push(`${o===e?">":" "} ${o}: ${t[s]}`)}return i.join(`
4120
- `)}var z0=new un;function CS(n){Ln._getMatrix(z0,Ln.workingColorSpace,n);let e=`mat3( ${z0.elements.map(t=>t.toFixed(4))} )`;switch(Ln.getTransfer(n)){case hl:return[e,"LinearTransferOETF"];case Jn:return[e,"sRGBTransferOETF"];default:return rn("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function V0(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),a=(n.getShaderInfoLog(e)||"").trim();if(i&&a==="")return"";let s=/ERROR: 0:(\d+)/.exec(a);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
4120
+ `)}var Z0=new qn;function Jb(n){vi._getMatrix(Z0,vi.workingColorSpace,n);let e=`mat3( ${Z0.elements.map(t=>t.toFixed(4))} )`;switch(vi.getTransfer(n)){case cc:return[e,"LinearTransferOETF"];case Di:return[e,"sRGBTransferOETF"];default:return Rn("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function J0(n,e,t){let i=n.getShaderParameter(e,n.COMPILE_STATUS),a=(n.getShaderInfoLog(e)||"").trim();if(i&&a==="")return"";let s=/ERROR: 0:(\d+)/.exec(a);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
4121
4121
 
4122
4122
  `+a+`
4123
4123
 
4124
- `+IS(n.getShaderSource(e),o)}else return a}function RS(n,e){let t=CS(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
4125
- `)}var PS={[ah]:"Linear",[sh]:"Reinhard",[oh]:"Cineon",[lh]:"ACESFilmic",[uh]:"AgX",[dh]:"Neutral",[ch]:"Custom"};function LS(n,e){let t=PS[e];return t===void 0?(rn("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var Td=new ge;function DS(){Ln.getLuminanceCoefficients(Td);let n=Td.x.toFixed(4),e=Td.y.toFixed(4),t=Td.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4126
- `)}function NS(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter($l).join(`
4127
- `)}function US(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
4128
- `)}function FS(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let a=n.getActiveAttrib(e,r),s=a.name,o=1;a.type===n.FLOAT_MAT2&&(o=2),a.type===n.FLOAT_MAT3&&(o=3),a.type===n.FLOAT_MAT4&&(o=4),t[s]={type:a.type,location:n.getAttribLocation(e,s),locationSize:o}}return t}function $l(n){return n!==""}function G0(n,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function H0(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var OS=/^[ \t]*#include +<([\w\d./]+)>/gm;function Vh(n){return n.replace(OS,kS)}var BS=new Map;function kS(n,e){let t=gn[e];if(t===void 0){let i=BS.get(e);if(i!==void 0)t=gn[i],rn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Vh(t)}var zS=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function W0(n){return n.replace(zS,VS)}function VS(n,e,t,i){let r="";for(let a=parseInt(e);a<parseInt(t);a++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function X0(n){let e=`precision ${n.precision} float;
4124
+ `+Zb(n.getShaderSource(e),o)}else return a}function $b(n,e){let t=Jb(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
4125
+ `)}var Kb={[lp]:"Linear",[cp]:"Reinhard",[up]:"Cineon",[Uc]:"ACESFilmic",[fp]:"AgX",[Fc]:"Neutral",[dp]:"Custom"};function Qb(n,e){let t=Kb[e];return t===void 0?(Rn("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var _f=new Se;function jb(){vi.getLuminanceCoefficients(_f);let n=_f.x.toFixed(4),e=_f.y.toFixed(4),t=_f.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4126
+ `)}function ew(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(qc).join(`
4127
+ `)}function tw(n){let e=[];for(let t in n){let i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
4128
+ `)}function nw(n,e){let t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){let a=n.getActiveAttrib(e,r),s=a.name,o=1;a.type===n.FLOAT_MAT2&&(o=2),a.type===n.FLOAT_MAT3&&(o=3),a.type===n.FLOAT_MAT4&&(o=4),t[s]={type:a.type,location:n.getAttribLocation(e,s),locationSize:o}}return t}function qc(n){return n!==""}function $0(n,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function K0(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var iw=/^[ \t]*#include +<([\w\d./]+)>/gm;function Gp(n){return n.replace(iw,aw)}var rw=new Map;function aw(n,e){let t=ai[e];if(t===void 0){let i=rw.get(e);if(i!==void 0)t=ai[i],Rn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Gp(t)}var sw=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Q0(n){return n.replace(sw,ow)}function ow(n,e,t,i){let r="";for(let a=parseInt(e);a<parseInt(t);a++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function j0(n){let e=`precision ${n.precision} float;
4129
4129
  precision ${n.precision} int;
4130
4130
  precision ${n.precision} sampler2D;
4131
4131
  precision ${n.precision} samplerCube;
@@ -4145,30 +4145,30 @@ void main() {
4145
4145
  `;return n.precision==="highp"?e+=`
4146
4146
  #define HIGH_PRECISION`:n.precision==="mediump"?e+=`
4147
4147
  #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
4148
- #define LOW_PRECISION`),e}var GS={[kl]:"SHADOWMAP_TYPE_PCF",[Eo]:"SHADOWMAP_TYPE_VSM"};function HS(n){return GS[n.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var WS={[vs]:"ENVMAP_TYPE_CUBE",[Os]:"ENVMAP_TYPE_CUBE",[zl]:"ENVMAP_TYPE_CUBE_UV"};function XS(n){return n.envMap===!1?"ENVMAP_TYPE_CUBE":WS[n.envMapMode]||"ENVMAP_TYPE_CUBE"}var YS={[Os]:"ENVMAP_MODE_REFRACTION"};function qS(n){return n.envMap===!1?"ENVMAP_MODE_REFLECTION":YS[n.envMapMode]||"ENVMAP_MODE_REFLECTION"}var ZS={[Nu]:"ENVMAP_BLENDING_MULTIPLY",[r0]:"ENVMAP_BLENDING_MIX",[a0]:"ENVMAP_BLENDING_ADD"};function JS(n){return n.envMap===!1?"ENVMAP_BLENDING_NONE":ZS[n.combine]||"ENVMAP_BLENDING_NONE"}function $S(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function KS(n,e,t,i){let r=n.getContext(),a=t.defines,s=t.vertexShader,o=t.fragmentShader,u=HS(t),l=XS(t),d=qS(t),f=JS(t),h=$S(t),v=NS(t),y=US(a),T=r.createProgram(),g,m,L=t.glslVersion?"#version "+t.glslVersion+`
4149
- `:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter($l).join(`
4148
+ #define LOW_PRECISION`),e}var lw={[Nc]:"SHADOWMAP_TYPE_PCF",[gl]:"SHADOWMAP_TYPE_VSM"};function cw(n){return lw[n.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var uw={[qs]:"ENVMAP_TYPE_CUBE",[yo]:"ENVMAP_TYPE_CUBE",[Oc]:"ENVMAP_TYPE_CUBE_UV"};function dw(n){return n.envMap===!1?"ENVMAP_TYPE_CUBE":uw[n.envMapMode]||"ENVMAP_TYPE_CUBE"}var fw={[yo]:"ENVMAP_MODE_REFRACTION"};function hw(n){return n.envMap===!1?"ENVMAP_MODE_REFLECTION":fw[n.envMapMode]||"ENVMAP_MODE_REFLECTION"}var pw={[Rd]:"ENVMAP_BLENDING_MULTIPLY",[f0]:"ENVMAP_BLENDING_MIX",[h0]:"ENVMAP_BLENDING_ADD"};function mw(n){return n.envMap===!1?"ENVMAP_BLENDING_NONE":pw[n.combine]||"ENVMAP_BLENDING_NONE"}function vw(n){let e=n.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function gw(n,e,t,i){let r=n.getContext(),a=t.defines,s=t.vertexShader,o=t.fragmentShader,u=cw(t),l=dw(t),d=hw(t),f=mw(t),h=vw(t),m=ew(t),x=tw(a),_=r.createProgram(),g,v,F=t.glslVersion?"#version "+t.glslVersion+`
4149
+ `:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(qc).join(`
4150
4150
  `),g.length>0&&(g+=`
4151
- `),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y].filter($l).join(`
4152
- `),m.length>0&&(m+=`
4153
- `)):(g=[X0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4154
- `].filter($l).join(`
4155
- `),m=[X0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,y,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+d:"",t.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==aa?"#define TONE_MAPPING":"",t.toneMapping!==aa?gn.tonemapping_pars_fragment:"",t.toneMapping!==aa?LS("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",gn.colorspace_pars_fragment,RS("linearToOutputTexel",t.outputColorSpace),DS(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4156
- `].filter($l).join(`
4157
- `)),s=Vh(s),s=G0(s,t),s=H0(s,t),o=Vh(o),o=G0(o,t),o=H0(o,t),s=W0(s),o=W0(o),t.isRawShaderMaterial!==!0&&(L=`#version 300 es
4158
- `,g=[v,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4151
+ `),v=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(qc).join(`
4152
+ `),v.length>0&&(v+=`
4153
+ `)):(g=[j0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+d:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4154
+ `].filter(qc).join(`
4155
+ `),v=[j0(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+d:"",t.envMap?"#define "+f:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+u:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==la?"#define TONE_MAPPING":"",t.toneMapping!==la?ai.tonemapping_pars_fragment:"",t.toneMapping!==la?Qb("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ai.colorspace_pars_fragment,$b("linearToOutputTexel",t.outputColorSpace),jb(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4156
+ `].filter(qc).join(`
4157
+ `)),s=Gp(s),s=$0(s,t),s=K0(s,t),o=Gp(o),o=$0(o,t),o=K0(o,t),s=Q0(s),o=Q0(o),t.isRawShaderMaterial!==!0&&(F=`#version 300 es
4158
+ `,g=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4159
4159
  `)+`
4160
- `+g,m=["#define varying in",t.glslVersion===xh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===xh?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
4160
+ `+g,v=["#define varying in",t.glslVersion===_p?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===_p?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
4161
4161
  `)+`
4162
- `+m);let F=L+g+s,_=L+m+o,p=k0(r,r.VERTEX_SHADER,F),S=k0(r,r.FRAGMENT_SHADER,_);r.attachShader(T,p),r.attachShader(T,S),t.index0AttributeName!==void 0?r.bindAttribLocation(T,0,t.index0AttributeName):t.hasPositionAttribute===!0&&r.bindAttribLocation(T,0,"position"),r.linkProgram(T);function B(U){if(n.debug.checkShaderErrors){let Y=r.getProgramInfoLog(T)||"",E=r.getShaderInfoLog(p)||"",M=r.getShaderInfoLog(S)||"",O=Y.trim(),H=E.trim(),ee=M.trim(),j=!0,K=!0;if(r.getProgramParameter(T,r.LINK_STATUS)===!1)if(j=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,T,p,S);else{let re=V0(r,p,"vertex"),J=V0(r,S,"fragment");sn("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(T,r.VALIDATE_STATUS)+`
4162
+ `+v);let P=F+g+s,S=F+v+o,N=q0(r,r.VERTEX_SHADER,P),p=q0(r,r.FRAGMENT_SHADER,S);r.attachShader(_,N),r.attachShader(_,p),t.index0AttributeName!==void 0?r.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&r.bindAttribLocation(_,0,"position"),r.linkProgram(_);function L(Y){if(n.debug.checkShaderErrors){let W=r.getProgramInfoLog(_)||"",C=r.getShaderInfoLog(N)||"",M=r.getShaderInfoLog(p)||"",J=W.trim(),q=C.trim(),ce=M.trim(),k=!0,G=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(k=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,_,N,p);else{let te=J0(r,N,"vertex"),le=J0(r,p,"fragment");On("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
4163
4163
 
4164
- Material Name: `+U.name+`
4165
- Material Type: `+U.type+`
4164
+ Material Name: `+Y.name+`
4165
+ Material Type: `+Y.type+`
4166
4166
 
4167
- Program Info Log: `+O+`
4168
- `+re+`
4169
- `+J)}else O!==""?rn("WebGLProgram: Program Info Log:",O):(H===""||ee==="")&&(K=!1);K&&(U.diagnostics={runnable:j,programLog:O,vertexShader:{log:H,prefix:g},fragmentShader:{log:ee,prefix:m}})}r.deleteShader(p),r.deleteShader(S),b=new Do(r,T),I=FS(r,T)}let b;this.getUniforms=function(){return b===void 0&&B(this),b};let I;this.getAttributes=function(){return I===void 0&&B(this),I};let z=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return z===!1&&(z=r.getProgramParameter(T,ES)),z},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(T),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=AS++,this.cacheKey=e,this.usedTimes=1,this.program=T,this.vertexShader=p,this.fragmentShader=S,this}var QS=0,Gh=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(i)===!1&&(r.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new Hh(e),t.set(e,i)),i}},Hh=class{constructor(e){this.id=QS++,this.code=e,this.usedTimes=0}};function jS(n){return n===xs||n===Yl||n===ql}function eb(n,e,t,i,r,a){let s=new go,o=new Gh,u=new Set,l=[],d=new Map,f=i.logarithmicDepthBuffer,h=i.precision,v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(b){return u.add(b),b===0?"uv":`uv${b}`}function T(b,I,z,U,Y,E){let M=U.fog,O=Y.geometry,H=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?U.environment:null,ee=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap,j=e.get(b.envMap||H,ee),K=j&&j.mapping===zl?j.image.height:null,re=v[b.type];b.precision!==null&&(h=i.getMaxPrecision(b.precision),h!==b.precision&&rn("WebGLProgram.getParameters:",b.precision,"not supported, using",h,"instead."));let J=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ne=J!==void 0?J.length:0,Te=0;O.morphAttributes.position!==void 0&&(Te=1),O.morphAttributes.normal!==void 0&&(Te=2),O.morphAttributes.color!==void 0&&(Te=3);let fe,pe,Fe,ae;if(re){let cn=Ca[re];fe=cn.vertexShader,pe=cn.fragmentShader}else{fe=b.vertexShader,pe=b.fragmentShader;let cn=o.getVertexShaderStage(b),dn=o.getFragmentShaderStage(b);o.update(b,cn,dn),Fe=cn.id,ae=dn.id}let de=n.getRenderTarget(),_e=n.state.buffers.depth.getReversed(),Ge=Y.isInstancedMesh===!0,$e=Y.isBatchedMesh===!0,ut=!!b.map,zt=!!b.matcap,ct=!!j,Tt=!!b.aoMap,Zt=!!b.lightMap,wt=!!b.bumpMap&&b.wireframe===!1,bt=!!b.normalMap,_t=!!b.displacementMap,ln=!!b.emissiveMap,rt=!!b.metalnessMap,an=!!b.roughnessMap,se=b.anisotropy>0,mn=b.clearcoat>0,nn=b.dispersion>0,W=b.retroreflectivity>0,w=b.iridescence>0,ue=b.sheen>0,ye=b.transmission>0,we=se&&!!b.anisotropyMap,ze=mn&&!!b.clearcoatMap,Ye=mn&&!!b.clearcoatNormalMap,Re=mn&&!!b.clearcoatRoughnessMap,Ae=w&&!!b.iridescenceMap,Ne=w&&!!b.iridescenceThicknessMap,je=ue&&!!b.sheenColorMap,Ve=ue&&!!b.sheenRoughnessMap,qe=!!b.specularMap,ot=!!b.specularColorMap,pt=!!b.specularIntensityMap,He=ye&&!!b.transmissionMap,ie=ye&&!!b.thicknessMap,Oe=!!b.gradientMap,Pe=!!b.alphaMap,nt=b.alphaTest>0,dt=!!b.alphaHash,Be=!!b.extensions,Rt=aa;b.toneMapped&&(de===null||de.isXRRenderTarget===!0)&&(Rt=n.toneMapping);let vt={shaderID:re,shaderType:b.type,shaderName:b.name,vertexShader:fe,fragmentShader:pe,defines:b.defines,customVertexShaderID:Fe,customFragmentShaderID:ae,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:h,batching:$e,batchingColor:$e&&Y._colorsTexture!==null,instancing:Ge,instancingColor:Ge&&Y.instanceColor!==null,instancingMorph:Ge&&Y.morphTexture!==null,outputColorSpace:de===null?n.outputColorSpace:de.isXRRenderTarget===!0?de.texture.colorSpace:Ln.workingColorSpace,alphaToCoverage:!!b.alphaToCoverage,map:ut,matcap:zt,envMap:ct,envMapMode:ct&&j.mapping,envMapCubeUVHeight:K,aoMap:Tt,lightMap:Zt,bumpMap:wt,normalMap:bt,displacementMap:_t,emissiveMap:ln,normalMapObjectSpace:bt&&b.normalMapType===l0,normalMapTangentSpace:bt&&b.normalMapType===Md,packedNormalMap:bt&&b.normalMapType===Md&&jS(b.normalMap.format),metalnessMap:rt,roughnessMap:an,anisotropy:se,anisotropyMap:we,clearcoat:mn,clearcoatMap:ze,clearcoatNormalMap:Ye,clearcoatRoughnessMap:Re,dispersion:nn,retroreflection:W,iridescence:w,iridescenceMap:Ae,iridescenceThicknessMap:Ne,sheen:ue,sheenColorMap:je,sheenRoughnessMap:Ve,specularMap:qe,specularColorMap:ot,specularIntensityMap:pt,transmission:ye,transmissionMap:He,thicknessMap:ie,gradientMap:Oe,opaque:b.transparent===!1&&b.blending===Ao&&b.alphaToCoverage===!1,alphaMap:Pe,alphaTest:nt,alphaHash:dt,combine:b.combine,mapUv:ut&&y(b.map.channel),aoMapUv:Tt&&y(b.aoMap.channel),lightMapUv:Zt&&y(b.lightMap.channel),bumpMapUv:wt&&y(b.bumpMap.channel),normalMapUv:bt&&y(b.normalMap.channel),displacementMapUv:_t&&y(b.displacementMap.channel),emissiveMapUv:ln&&y(b.emissiveMap.channel),metalnessMapUv:rt&&y(b.metalnessMap.channel),roughnessMapUv:an&&y(b.roughnessMap.channel),anisotropyMapUv:we&&y(b.anisotropyMap.channel),clearcoatMapUv:ze&&y(b.clearcoatMap.channel),clearcoatNormalMapUv:Ye&&y(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Re&&y(b.clearcoatRoughnessMap.channel),iridescenceMapUv:Ae&&y(b.iridescenceMap.channel),iridescenceThicknessMapUv:Ne&&y(b.iridescenceThicknessMap.channel),sheenColorMapUv:je&&y(b.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&y(b.sheenRoughnessMap.channel),specularMapUv:qe&&y(b.specularMap.channel),specularColorMapUv:ot&&y(b.specularColorMap.channel),specularIntensityMapUv:pt&&y(b.specularIntensityMap.channel),transmissionMapUv:He&&y(b.transmissionMap.channel),thicknessMapUv:ie&&y(b.thicknessMap.channel),alphaMapUv:Pe&&y(b.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(bt||se),vertexNormals:!!O.attributes.normal,vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:Y.isPoints===!0&&!!O.attributes.uv&&(ut||Pe),fog:!!M,useFog:b.fog===!0,fogExp2:!!M&&M.isFogExp2,flatShading:b.wireframe===!1&&(b.flatShading===!0||O.attributes.normal===void 0&&bt===!1&&(b.isMeshLambertMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isMeshPhysicalMaterial)),sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:_e,skinning:Y.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:ne,morphTextureStride:Te,numSunLights:I.sun.length,numDirLights:I.directional.length,numPointLights:I.point.length,numSpotLights:I.spot.length,numSpotLightMaps:I.spotLightMap.length,numRectAreaLights:I.rectArea.length,numHemiLights:I.hemi.length,numSunLightShadows:I.sunShadowMap.length,numDirLightShadows:I.directionalShadowMap.length,numPointLightShadows:I.pointShadowMap.length,numSpotLightShadows:I.spotShadowMap.length,numSpotLightShadowsWithMaps:I.numSpotLightShadowsWithMaps,numLightProbes:I.numLightProbes,numLightProbeGrids:E.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:b.dithering,shadowMapEnabled:n.shadowMap.enabled&&z.length>0,shadowMapType:n.shadowMap.type,toneMapping:Rt,decodeVideoTexture:ut&&b.map.isVideoTexture===!0&&Ln.getTransfer(b.map.colorSpace)===Jn,decodeVideoTextureEmissive:ln&&b.emissiveMap.isVideoTexture===!0&&Ln.getTransfer(b.emissiveMap.colorSpace)===Jn,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===Ir,flipSided:b.side===pr,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:Be&&b.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Be&&b.extensions.multiDraw===!0||$e)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return vt.vertexUv1s=u.has(1),vt.vertexUv2s=u.has(2),vt.vertexUv3s=u.has(3),u.clear(),vt}function g(b){let I=[];if(b.shaderID?I.push(b.shaderID):(I.push(b.customVertexShaderID),I.push(b.customFragmentShaderID)),b.defines!==void 0)for(let z in b.defines)I.push(z),I.push(b.defines[z]);return b.isRawShaderMaterial===!1&&(m(I,b),L(I,b),I.push(n.outputColorSpace)),I.push(b.customProgramCacheKey),I.join()}function m(b,I){b.push(I.precision),b.push(I.outputColorSpace),b.push(I.envMapMode),b.push(I.envMapCubeUVHeight),b.push(I.mapUv),b.push(I.alphaMapUv),b.push(I.lightMapUv),b.push(I.aoMapUv),b.push(I.bumpMapUv),b.push(I.normalMapUv),b.push(I.displacementMapUv),b.push(I.emissiveMapUv),b.push(I.metalnessMapUv),b.push(I.roughnessMapUv),b.push(I.anisotropyMapUv),b.push(I.clearcoatMapUv),b.push(I.clearcoatNormalMapUv),b.push(I.clearcoatRoughnessMapUv),b.push(I.iridescenceMapUv),b.push(I.iridescenceThicknessMapUv),b.push(I.sheenColorMapUv),b.push(I.sheenRoughnessMapUv),b.push(I.specularMapUv),b.push(I.specularColorMapUv),b.push(I.specularIntensityMapUv),b.push(I.transmissionMapUv),b.push(I.thicknessMapUv),b.push(I.combine),b.push(I.fogExp2),b.push(I.sizeAttenuation),b.push(I.morphTargetsCount),b.push(I.morphAttributeCount),b.push(I.numSunLights),b.push(I.numDirLights),b.push(I.numPointLights),b.push(I.numSpotLights),b.push(I.numSpotLightMaps),b.push(I.numHemiLights),b.push(I.numRectAreaLights),b.push(I.numSunLightShadows),b.push(I.numDirLightShadows),b.push(I.numPointLightShadows),b.push(I.numSpotLightShadows),b.push(I.numSpotLightShadowsWithMaps),b.push(I.numLightProbes),b.push(I.shadowMapType),b.push(I.toneMapping),b.push(I.numClippingPlanes),b.push(I.numClipIntersection),b.push(I.depthPacking)}function L(b,I){s.disableAll(),I.instancing&&s.enable(0),I.instancingColor&&s.enable(1),I.instancingMorph&&s.enable(2),I.matcap&&s.enable(3),I.envMap&&s.enable(4),I.normalMapObjectSpace&&s.enable(5),I.normalMapTangentSpace&&s.enable(6),I.clearcoat&&s.enable(7),I.iridescence&&s.enable(8),I.alphaTest&&s.enable(9),I.vertexColors&&s.enable(10),I.vertexAlphas&&s.enable(11),I.vertexUv1s&&s.enable(12),I.vertexUv2s&&s.enable(13),I.vertexUv3s&&s.enable(14),I.vertexTangents&&s.enable(15),I.anisotropy&&s.enable(16),I.alphaHash&&s.enable(17),I.batching&&s.enable(18),I.dispersion&&s.enable(19),I.retroreflection&&s.enable(24),I.batchingColor&&s.enable(20),I.gradientMap&&s.enable(21),I.packedNormalMap&&s.enable(22),I.vertexNormals&&s.enable(23),b.push(s.mask),s.disableAll(),I.fog&&s.enable(0),I.useFog&&s.enable(1),I.flatShading&&s.enable(2),I.logarithmicDepthBuffer&&s.enable(3),I.reversedDepthBuffer&&s.enable(4),I.skinning&&s.enable(5),I.morphTargets&&s.enable(6),I.morphNormals&&s.enable(7),I.morphColors&&s.enable(8),I.premultipliedAlpha&&s.enable(9),I.shadowMapEnabled&&s.enable(10),I.doubleSided&&s.enable(11),I.flipSided&&s.enable(12),I.useDepthPacking&&s.enable(13),I.dithering&&s.enable(14),I.transmission&&s.enable(15),I.sheen&&s.enable(16),I.opaque&&s.enable(17),I.pointsUvs&&s.enable(18),I.decodeVideoTexture&&s.enable(19),I.decodeVideoTextureEmissive&&s.enable(20),I.alphaToCoverage&&s.enable(21),I.numLightProbeGrids>0&&s.enable(22),I.hasPositionAttribute&&s.enable(23),b.push(s.mask)}function F(b){let I=v[b.type],z;if(I){let U=Ca[I];z=E0.clone(U.uniforms)}else z=b.uniforms;return z}function _(b,I){let z=d.get(I);return z!==void 0?++z.usedTimes:(z=new KS(n,I,b,r),l.push(z),d.set(I,z)),z}function p(b){if(--b.usedTimes===0){let I=l.indexOf(b);l[I]=l[l.length-1],l.pop(),d.delete(b.cacheKey),b.destroy()}}function S(b){o.remove(b)}function B(){o.dispose()}return{getParameters:T,getProgramCacheKey:g,getUniforms:F,acquireProgram:_,releaseProgram:p,releaseShaderCache:S,programs:l,dispose:B}}function tb(){let n=new WeakMap;function e(s){return n.has(s)}function t(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function i(s){n.delete(s)}function r(s,o,u){n.get(s)[o]=u}function a(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:a}}function nb(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Y0(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function q0(){let n=[],e=0,t=[],i=[],r=[];function a(){e=0,t.length=0,i.length=0,r.length=0}function s(h){let v=0;return h.isInstancedMesh&&(v+=2),h.isSkinnedMesh&&(v+=1),v}function o(h,v,y,T,g,m){let L=n[e];return L===void 0?(L={id:h.id,object:h,geometry:v,material:y,materialVariant:s(h),groupOrder:T,renderOrder:h.renderOrder,z:g,group:m},n[e]=L):(L.id=h.id,L.object=h,L.geometry=v,L.material=y,L.materialVariant=s(h),L.groupOrder=T,L.renderOrder=h.renderOrder,L.z=g,L.group=m),e++,L}function u(h,v,y,T,g,m,L){L.reversedDepth===!0&&(g=-g);let F=o(h,v,y,T,g,m);y.transmission>0?i.push(F):y.transparent===!0?r.push(F):t.push(F)}function l(h,v,y,T,g,m){let L=o(h,v,y,T,g,m);y.transmission>0?i.unshift(L):y.transparent===!0?r.unshift(L):t.unshift(L)}function d(h,v){t.length>1&&t.sort(h||nb),i.length>1&&i.sort(v||Y0),r.length>1&&r.sort(v||Y0)}function f(){for(let h=e,v=n.length;h<v;h++){let y=n[h];if(y.id===null)break;y.id=null,y.object=null,y.geometry=null,y.material=null,y.group=null}}return{opaque:t,transmissive:i,transparent:r,init:a,push:u,unshift:l,finish:f,sort:d}}function ib(){let n=new WeakMap;function e(i,r){let a=n.get(i),s;return a===void 0?(s=new q0,n.set(i,[s])):r>=a.length?(s=new q0,a.push(s)):s=a[r],s}function t(){n=new WeakMap}return{get:e,dispose:t}}function rb(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new ge,color:new vn};break;case"SpotLight":t={position:new ge,direction:new ge,color:new vn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new ge,color:new vn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new ge,skyColor:new vn,groundColor:new vn};break;case"RectAreaLight":t={color:new vn,position:new ge,halfWidth:new ge,halfHeight:new ge};break}return n[e.id]=t,t}}}function ab(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new kt};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new kt};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new kt,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var sb=0;function ob(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function lb(n){let e=new rb,t=ab(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new ge);let r=new ge,a=new $n,s=new $n;function o(l){let d=0,f=0,h=0;for(let Y=0;Y<9;Y++)i.probe[Y].set(0,0,0);let v=0,y=0,T=0,g=0,m=0,L=0,F=0,_=0,p=0,S=0,B=0,b=0,I=0,z=0;l.sort(ob);for(let Y=0,E=l.length;Y<E;Y++){let M=l[Y],O=M.color,H=M.intensity,ee=M.distance,j=null;if(M.shadow&&M.shadow.map&&(M.shadow.map.texture.format===xs?j=M.shadow.map.texture:j=M.shadow.map.depthTexture||M.shadow.map.texture),M.isAmbientLight)d+=O.r*H,f+=O.g*H,h+=O.b*H;else if(M.isLightProbe){for(let K=0;K<9;K++)i.probe[K].addScaledVector(M.sh.coefficients[K],H);z++}else if(M.isSunLight){let K=e.get(M);if(K.color.copy(M.color).multiplyScalar(M.intensity),M.castShadow){let re=M.shadow,J=t.get(M);J.shadowIntensity=re.intensity,J.shadowBias=re.bias,J.shadowNormalBias=re.normalBias,J.shadowRadius=re.radius,J.shadowMapSize.copy(re.mapSize).multiply(re.getFrameExtents()),i.sunShadow[y]=J,i.sunShadowMap[y]=j;let ne=re.getViewportCount();for(let Te=0;Te<ne;Te++)i.sunShadowMatrix[T+Te]=re.getMatrix(Te),i.sunShadowCascade[T+Te]=re._cascadeData[Te];T+=ne,y++}i.sun[v]=K,v++}else if(M.isDirectionalLight){let K=e.get(M);if(K.color.copy(M.color).multiplyScalar(M.intensity),M.castShadow){let re=M.shadow,J=t.get(M);J.shadowIntensity=re.intensity,J.shadowBias=re.bias,J.shadowNormalBias=re.normalBias,J.shadowRadius=re.radius,J.shadowMapSize=re.mapSize,i.directionalShadow[g]=J,i.directionalShadowMap[g]=j,i.directionalShadowMatrix[g]=M.shadow.matrix,p++}i.directional[g]=K,g++}else if(M.isSpotLight){let K=e.get(M);K.position.setFromMatrixPosition(M.matrixWorld),K.color.copy(O).multiplyScalar(H),K.distance=ee,K.coneCos=Math.cos(M.angle),K.penumbraCos=Math.cos(M.angle*(1-M.penumbra)),K.decay=M.decay,i.spot[L]=K;let re=M.shadow;if(M.map&&(i.spotLightMap[b]=M.map,b++,re.updateMatrices(M),M.castShadow&&I++),i.spotLightMatrix[L]=re.matrix,M.castShadow){let J=t.get(M);J.shadowIntensity=re.intensity,J.shadowBias=re.bias,J.shadowNormalBias=re.normalBias,J.shadowRadius=re.radius,J.shadowMapSize=re.mapSize,i.spotShadow[L]=J,i.spotShadowMap[L]=j,B++}L++}else if(M.isRectAreaLight){let K=e.get(M);K.color.copy(O).multiplyScalar(H),K.halfWidth.set(M.width*.5,0,0),K.halfHeight.set(0,M.height*.5,0),i.rectArea[F]=K,F++}else if(M.isPointLight){let K=e.get(M);if(K.color.copy(M.color).multiplyScalar(M.intensity),K.distance=M.distance,K.decay=M.decay,M.castShadow){let re=M.shadow,J=t.get(M);J.shadowIntensity=re.intensity,J.shadowBias=re.bias,J.shadowNormalBias=re.normalBias,J.shadowRadius=re.radius,J.shadowMapSize=re.mapSize,J.shadowCameraNear=re.camera.near,J.shadowCameraFar=re.camera.far,i.pointShadow[m]=J,i.pointShadowMap[m]=j,i.pointShadowMatrix[m]=M.shadow.matrix,S++}i.point[m]=K,m++}else if(M.isHemisphereLight){let K=e.get(M);K.skyColor.copy(M.color).multiplyScalar(H),K.groundColor.copy(M.groundColor).multiplyScalar(H),i.hemi[_]=K,_++}}F>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=At.LTC_FLOAT_1,i.rectAreaLTC2=At.LTC_FLOAT_2):(i.rectAreaLTC1=At.LTC_HALF_1,i.rectAreaLTC2=At.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=h;let U=i.hash;(U.sunLength!==v||U.directionalLength!==g||U.pointLength!==m||U.spotLength!==L||U.rectAreaLength!==F||U.hemiLength!==_||U.numSunShadows!==y||U.numDirectionalShadows!==p||U.numPointShadows!==S||U.numSpotShadows!==B||U.numSpotMaps!==b||U.numLightProbes!==z)&&(i.sun.length=v,i.directional.length=g,i.spot.length=L,i.rectArea.length=F,i.point.length=m,i.hemi.length=_,i.sunShadow.length=y,i.sunShadowMap.length=y,i.sunShadowMatrix.length=T,i.sunShadowCascade.length=T,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.directionalShadowMatrix.length=p,i.pointShadow.length=S,i.pointShadowMap.length=S,i.pointShadowMatrix.length=S,i.spotShadow.length=B,i.spotShadowMap.length=B,i.spotLightMatrix.length=B+b-I,i.spotLightMap.length=b,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=z,U.sunLength=v,U.directionalLength=g,U.pointLength=m,U.spotLength=L,U.rectAreaLength=F,U.hemiLength=_,U.numSunShadows=y,U.numDirectionalShadows=p,U.numPointShadows=S,U.numSpotShadows=B,U.numSpotMaps=b,U.numLightProbes=z,i.version=sb++)}function u(l,d){let f=0,h=0,v=0,y=0,T=0,g=0,m=d.matrixWorldInverse;for(let L=0,F=l.length;L<F;L++){let _=l[L];if(_.isSunLight){let p=i.sun[f];p.direction.setFromMatrixPosition(_.matrixWorld),p.direction.transformDirection(m),f++}else if(_.isDirectionalLight){let p=i.directional[h];p.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),p.direction.sub(r),p.direction.transformDirection(m),h++}else if(_.isSpotLight){let p=i.spot[y];p.position.setFromMatrixPosition(_.matrixWorld),p.position.applyMatrix4(m),p.direction.setFromMatrixPosition(_.matrixWorld),r.setFromMatrixPosition(_.target.matrixWorld),p.direction.sub(r),p.direction.transformDirection(m),y++}else if(_.isRectAreaLight){let p=i.rectArea[T];p.position.setFromMatrixPosition(_.matrixWorld),p.position.applyMatrix4(m),s.identity(),a.copy(_.matrixWorld),a.premultiply(m),s.extractRotation(a),p.halfWidth.set(_.width*.5,0,0),p.halfHeight.set(0,_.height*.5,0),p.halfWidth.applyMatrix4(s),p.halfHeight.applyMatrix4(s),T++}else if(_.isPointLight){let p=i.point[v];p.position.setFromMatrixPosition(_.matrixWorld),p.position.applyMatrix4(m),v++}else if(_.isHemisphereLight){let p=i.hemi[g];p.direction.setFromMatrixPosition(_.matrixWorld),p.direction.transformDirection(m),g++}}}return{setup:o,setupView:u,state:i}}function Z0(n){let e=new lb(n),t=[],i=[],r=[];function a(h){f.camera=h,t.length=0,i.length=0,r.length=0}function s(h){t.push(h)}function o(h){i.push(h)}function u(h){r.push(h)}function l(){e.setup(t)}function d(h){e.setupView(t,h)}let f={lightsArray:t,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:f,setupLights:l,setupLightsView:d,pushLight:s,pushShadow:o,pushLightProbeGrid:u}}function cb(n){let e=new WeakMap;function t(r,a=0){let s=e.get(r),o;return s===void 0?(o=new Z0(n),e.set(r,[o])):a>=s.length?(o=new Z0(n),s.push(o)):o=s[a],o}function i(){e=new WeakMap}return{get:t,dispose:i}}var ub=`void main() {
4167
+ Program Info Log: `+J+`
4168
+ `+te+`
4169
+ `+le)}else J!==""?Rn("WebGLProgram: Program Info Log:",J):(q===""||ce==="")&&(G=!1);G&&(Y.diagnostics={runnable:k,programLog:J,vertexShader:{log:q,prefix:g},fragmentShader:{log:ce,prefix:v}})}r.deleteShader(N),r.deleteShader(p),E=new Tl(r,_),D=nw(r,_)}let E;this.getUniforms=function(){return E===void 0&&L(this),E};let D;this.getAttributes=function(){return D===void 0&&L(this),D};let X=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return X===!1&&(X=r.getProgramParameter(_,Yb)),X},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=qb++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=N,this.fragmentShader=p,this}var yw=0,Hp=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(i)===!1&&(r.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return i===void 0&&(i=new Wp(e),t.set(e,i)),i}},Wp=class{constructor(e){this.id=yw++,this.code=e,this.usedTimes=0}};function xw(n){return n===Js||n===Gc||n===Hc}function _w(n,e,t,i,r,a){let s=new rl,o=new Hp,u=new Set,l=[],d=new Map,f=i.logarithmicDepthBuffer,h=i.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(E){return u.add(E),E===0?"uv":`uv${E}`}function _(E,D,X,Y,W,C){let M=Y.fog,J=W.geometry,q=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?Y.environment:null,ce=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap,k=e.get(E.envMap||q,ce),G=k&&k.mapping===Oc?k.image.height:null,te=m[E.type];E.precision!==null&&(h=i.getMaxPrecision(E.precision),h!==E.precision&&Rn("WebGLProgram.getParameters:",E.precision,"not supported, using",h,"instead."));let le=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,ge=le!==void 0?le.length:0,oe=0;J.morphAttributes.position!==void 0&&(oe=1),J.morphAttributes.normal!==void 0&&(oe=2),J.morphAttributes.color!==void 0&&(oe=3);let $,Te,Le,se;if(te){let yt=rs[te];$=yt.vertexShader,Te=yt.fragmentShader}else{$=E.vertexShader,Te=E.fragmentShader;let yt=o.getVertexShaderStage(E),Et=o.getFragmentShaderStage(E);o.update(E,yt,Et),Le=yt.id,se=Et.id}let re=n.getRenderTarget(),Ie=n.state.buffers.depth.getReversed(),ke=W.isInstancedMesh===!0,xe=W.isBatchedMesh===!0,Ye=!!E.map,mt=!!E.matcap,He=!!k,qe=!!E.aoMap,pt=!!E.lightMap,at=!!E.bumpMap&&E.wireframe===!1,ot=!!E.normalMap,Vt=!!E.displacementMap,cn=!!E.emissiveMap,Ze=!!E.metalnessMap,pn=!!E.roughnessMap,ne=E.anisotropy>0,Tn=E.clearcoat>0,gn=E.dispersion>0,Q=E.retroreflectivity>0,I=E.iridescence>0,ie=E.sheen>0,be=E.transmission>0,De=ne&&!!E.anisotropyMap,Je=Tn&&!!E.clearcoatMap,je=Tn&&!!E.clearcoatNormalMap,Ne=Tn&&!!E.clearcoatRoughnessMap,Pe=I&&!!E.iridescenceMap,it=I&&!!E.iridescenceThicknessMap,Rt=ie&&!!E.sheenColorMap,Mt=ie&&!!E.sheenRoughnessMap,ct=!!E.specularMap,Gt=!!E.specularColorMap,Kt=!!E.specularIntensityMap,nn=be&&!!E.transmissionMap,he=be&&!!E.thicknessMap,dt=!!E.gradientMap,Ee=!!E.alphaMap,gt=E.alphaTest>0,Ke=!!E.alphaHash,We=!!E.extensions,Wt=la;E.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(Wt=n.toneMapping);let Lt={shaderID:te,shaderType:E.type,shaderName:E.name,vertexShader:$,fragmentShader:Te,defines:E.defines,customVertexShaderID:Le,customFragmentShaderID:se,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:h,batching:xe,batchingColor:xe&&W._colorsTexture!==null,instancing:ke,instancingColor:ke&&W.instanceColor!==null,instancingMorph:ke&&W.morphTexture!==null,outputColorSpace:re===null?n.outputColorSpace:re.isXRRenderTarget===!0?re.texture.colorSpace:vi.workingColorSpace,alphaToCoverage:!!E.alphaToCoverage,map:Ye,matcap:mt,envMap:He,envMapMode:He&&k.mapping,envMapCubeUVHeight:G,aoMap:qe,lightMap:pt,bumpMap:at,normalMap:ot,displacementMap:Vt,emissiveMap:cn,normalMapObjectSpace:ot&&E.normalMapType===v0,normalMapTangentSpace:ot&&E.normalMapType===Wc,packedNormalMap:ot&&E.normalMapType===Wc&&xw(E.normalMap.format),metalnessMap:Ze,roughnessMap:pn,anisotropy:ne,anisotropyMap:De,clearcoat:Tn,clearcoatMap:Je,clearcoatNormalMap:je,clearcoatRoughnessMap:Ne,dispersion:gn,retroreflection:Q,iridescence:I,iridescenceMap:Pe,iridescenceThicknessMap:it,sheen:ie,sheenColorMap:Rt,sheenRoughnessMap:Mt,specularMap:ct,specularColorMap:Gt,specularIntensityMap:Kt,transmission:be,transmissionMap:nn,thicknessMap:he,gradientMap:dt,opaque:E.transparent===!1&&E.blending===yl&&E.alphaToCoverage===!1,alphaMap:Ee,alphaTest:gt,alphaHash:Ke,combine:E.combine,mapUv:Ye&&x(E.map.channel),aoMapUv:qe&&x(E.aoMap.channel),lightMapUv:pt&&x(E.lightMap.channel),bumpMapUv:at&&x(E.bumpMap.channel),normalMapUv:ot&&x(E.normalMap.channel),displacementMapUv:Vt&&x(E.displacementMap.channel),emissiveMapUv:cn&&x(E.emissiveMap.channel),metalnessMapUv:Ze&&x(E.metalnessMap.channel),roughnessMapUv:pn&&x(E.roughnessMap.channel),anisotropyMapUv:De&&x(E.anisotropyMap.channel),clearcoatMapUv:Je&&x(E.clearcoatMap.channel),clearcoatNormalMapUv:je&&x(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ne&&x(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Pe&&x(E.iridescenceMap.channel),iridescenceThicknessMapUv:it&&x(E.iridescenceThicknessMap.channel),sheenColorMapUv:Rt&&x(E.sheenColorMap.channel),sheenRoughnessMapUv:Mt&&x(E.sheenRoughnessMap.channel),specularMapUv:ct&&x(E.specularMap.channel),specularColorMapUv:Gt&&x(E.specularColorMap.channel),specularIntensityMapUv:Kt&&x(E.specularIntensityMap.channel),transmissionMapUv:nn&&x(E.transmissionMap.channel),thicknessMapUv:he&&x(E.thicknessMap.channel),alphaMapUv:Ee&&x(E.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(ot||ne),vertexNormals:!!J.attributes.normal,vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:W.isPoints===!0&&!!J.attributes.uv&&(Ye||Ee),fog:!!M,useFog:E.fog===!0,fogExp2:!!M&&M.isFogExp2,flatShading:E.wireframe===!1&&(E.flatShading===!0||J.attributes.normal===void 0&&ot===!1&&(E.isMeshLambertMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isMeshPhysicalMaterial)),sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ie,skinning:W.isSkinnedMesh===!0,hasPositionAttribute:J.attributes.position!==void 0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:ge,morphTextureStride:oe,numSunLights:D.sun.length,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numSunLightShadows:D.sunShadowMap.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numLightProbeGrids:C.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:E.dithering,shadowMapEnabled:n.shadowMap.enabled&&X.length>0,shadowMapType:n.shadowMap.type,toneMapping:Wt,decodeVideoTexture:Ye&&E.map.isVideoTexture===!0&&vi.getTransfer(E.map.colorSpace)===Di,decodeVideoTextureEmissive:cn&&E.emissiveMap.isVideoTexture===!0&&vi.getTransfer(E.emissiveMap.colorSpace)===Di,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Gr,flipSided:E.side===ea,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:We&&E.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(We&&E.extensions.multiDraw===!0||xe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return Lt.vertexUv1s=u.has(1),Lt.vertexUv2s=u.has(2),Lt.vertexUv3s=u.has(3),u.clear(),Lt}function g(E){let D=[];if(E.shaderID?D.push(E.shaderID):(D.push(E.customVertexShaderID),D.push(E.customFragmentShaderID)),E.defines!==void 0)for(let X in E.defines)D.push(X),D.push(E.defines[X]);return E.isRawShaderMaterial===!1&&(v(D,E),F(D,E),D.push(n.outputColorSpace)),D.push(E.customProgramCacheKey),D.join()}function v(E,D){E.push(D.precision),E.push(D.outputColorSpace),E.push(D.envMapMode),E.push(D.envMapCubeUVHeight),E.push(D.mapUv),E.push(D.alphaMapUv),E.push(D.lightMapUv),E.push(D.aoMapUv),E.push(D.bumpMapUv),E.push(D.normalMapUv),E.push(D.displacementMapUv),E.push(D.emissiveMapUv),E.push(D.metalnessMapUv),E.push(D.roughnessMapUv),E.push(D.anisotropyMapUv),E.push(D.clearcoatMapUv),E.push(D.clearcoatNormalMapUv),E.push(D.clearcoatRoughnessMapUv),E.push(D.iridescenceMapUv),E.push(D.iridescenceThicknessMapUv),E.push(D.sheenColorMapUv),E.push(D.sheenRoughnessMapUv),E.push(D.specularMapUv),E.push(D.specularColorMapUv),E.push(D.specularIntensityMapUv),E.push(D.transmissionMapUv),E.push(D.thicknessMapUv),E.push(D.combine),E.push(D.fogExp2),E.push(D.sizeAttenuation),E.push(D.morphTargetsCount),E.push(D.morphAttributeCount),E.push(D.numSunLights),E.push(D.numDirLights),E.push(D.numPointLights),E.push(D.numSpotLights),E.push(D.numSpotLightMaps),E.push(D.numHemiLights),E.push(D.numRectAreaLights),E.push(D.numSunLightShadows),E.push(D.numDirLightShadows),E.push(D.numPointLightShadows),E.push(D.numSpotLightShadows),E.push(D.numSpotLightShadowsWithMaps),E.push(D.numLightProbes),E.push(D.shadowMapType),E.push(D.toneMapping),E.push(D.numClippingPlanes),E.push(D.numClipIntersection),E.push(D.depthPacking)}function F(E,D){s.disableAll(),D.instancing&&s.enable(0),D.instancingColor&&s.enable(1),D.instancingMorph&&s.enable(2),D.matcap&&s.enable(3),D.envMap&&s.enable(4),D.normalMapObjectSpace&&s.enable(5),D.normalMapTangentSpace&&s.enable(6),D.clearcoat&&s.enable(7),D.iridescence&&s.enable(8),D.alphaTest&&s.enable(9),D.vertexColors&&s.enable(10),D.vertexAlphas&&s.enable(11),D.vertexUv1s&&s.enable(12),D.vertexUv2s&&s.enable(13),D.vertexUv3s&&s.enable(14),D.vertexTangents&&s.enable(15),D.anisotropy&&s.enable(16),D.alphaHash&&s.enable(17),D.batching&&s.enable(18),D.dispersion&&s.enable(19),D.retroreflection&&s.enable(24),D.batchingColor&&s.enable(20),D.gradientMap&&s.enable(21),D.packedNormalMap&&s.enable(22),D.vertexNormals&&s.enable(23),E.push(s.mask),s.disableAll(),D.fog&&s.enable(0),D.useFog&&s.enable(1),D.flatShading&&s.enable(2),D.logarithmicDepthBuffer&&s.enable(3),D.reversedDepthBuffer&&s.enable(4),D.skinning&&s.enable(5),D.morphTargets&&s.enable(6),D.morphNormals&&s.enable(7),D.morphColors&&s.enable(8),D.premultipliedAlpha&&s.enable(9),D.shadowMapEnabled&&s.enable(10),D.doubleSided&&s.enable(11),D.flipSided&&s.enable(12),D.useDepthPacking&&s.enable(13),D.dithering&&s.enable(14),D.transmission&&s.enable(15),D.sheen&&s.enable(16),D.opaque&&s.enable(17),D.pointsUvs&&s.enable(18),D.decodeVideoTexture&&s.enable(19),D.decodeVideoTextureEmissive&&s.enable(20),D.alphaToCoverage&&s.enable(21),D.numLightProbeGrids>0&&s.enable(22),D.hasPositionAttribute&&s.enable(23),E.push(s.mask)}function P(E){let D=m[E.type],X;if(D){let Y=rs[D];X=N0.clone(Y.uniforms)}else X=E.uniforms;return X}function S(E,D){let X=d.get(D);return X!==void 0?++X.usedTimes:(X=new gw(n,D,E,r),l.push(X),d.set(D,X)),X}function N(E){if(--E.usedTimes===0){let D=l.indexOf(E);l[D]=l[l.length-1],l.pop(),d.delete(E.cacheKey),E.destroy()}}function p(E){o.remove(E)}function L(){o.dispose()}return{getParameters:_,getProgramCacheKey:g,getUniforms:P,acquireProgram:S,releaseProgram:N,releaseShaderCache:p,programs:l,dispose:L}}function Mw(){let n=new WeakMap;function e(s){return n.has(s)}function t(s){let o=n.get(s);return o===void 0&&(o={},n.set(s,o)),o}function i(s){n.delete(s)}function r(s,o,u){n.get(s)[o]=u}function a(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:a}}function Sw(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function eg(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function tg(){let n=[],e=0,t=[],i=[],r=[];function a(){e=0,t.length=0,i.length=0,r.length=0}function s(h){let m=0;return h.isInstancedMesh&&(m+=2),h.isSkinnedMesh&&(m+=1),m}function o(h,m,x,_,g,v){let F=n[e];return F===void 0?(F={id:h.id,object:h,geometry:m,material:x,materialVariant:s(h),groupOrder:_,renderOrder:h.renderOrder,z:g,group:v},n[e]=F):(F.id=h.id,F.object=h,F.geometry=m,F.material=x,F.materialVariant=s(h),F.groupOrder=_,F.renderOrder=h.renderOrder,F.z=g,F.group=v),e++,F}function u(h,m,x,_,g,v,F){F.reversedDepth===!0&&(g=-g);let P=o(h,m,x,_,g,v);x.transmission>0?i.push(P):x.transparent===!0?r.push(P):t.push(P)}function l(h,m,x,_,g,v){let F=o(h,m,x,_,g,v);x.transmission>0?i.unshift(F):x.transparent===!0?r.unshift(F):t.unshift(F)}function d(h,m){t.length>1&&t.sort(h||Sw),i.length>1&&i.sort(m||eg),r.length>1&&r.sort(m||eg)}function f(){for(let h=e,m=n.length;h<m;h++){let x=n[h];if(x.id===null)break;x.id=null,x.object=null,x.geometry=null,x.material=null,x.group=null}}return{opaque:t,transmissive:i,transparent:r,init:a,push:u,unshift:l,finish:f,sort:d}}function bw(){let n=new WeakMap;function e(i,r){let a=n.get(i),s;return a===void 0?(s=new tg,n.set(i,[s])):r>=a.length?(s=new tg,a.push(s)):s=a[r],s}function t(){n=new WeakMap}return{get:e,dispose:t}}function ww(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new Se,color:new Wn};break;case"SpotLight":t={position:new Se,direction:new Se,color:new Wn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Se,color:new Wn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Se,skyColor:new Wn,groundColor:new Wn};break;case"RectAreaLight":t={color:new Wn,position:new Se,halfWidth:new Se,halfHeight:new Se};break}return n[e.id]=t,t}}}function Tw(){let n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ln};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ln};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ln,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}var Ew=0;function Aw(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Iw(n){let e=new ww,t=Tw(),i={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new Se);let r=new Se,a=new Jn,s=new Jn;function o(l){let d=0,f=0,h=0;for(let W=0;W<9;W++)i.probe[W].set(0,0,0);let m=0,x=0,_=0,g=0,v=0,F=0,P=0,S=0,N=0,p=0,L=0,E=0,D=0,X=0;l.sort(Aw);for(let W=0,C=l.length;W<C;W++){let M=l[W],J=M.color,q=M.intensity,ce=M.distance,k=null;if(M.shadow&&M.shadow.map&&(M.shadow.map.texture.format===Js?k=M.shadow.map.texture:k=M.shadow.map.depthTexture||M.shadow.map.texture),M.isAmbientLight)d+=J.r*q,f+=J.g*q,h+=J.b*q;else if(M.isLightProbe){for(let G=0;G<9;G++)i.probe[G].addScaledVector(M.sh.coefficients[G],q);X++}else if(M.isSunLight){let G=e.get(M);if(G.color.copy(M.color).multiplyScalar(M.intensity),M.castShadow){let te=M.shadow,le=t.get(M);le.shadowIntensity=te.intensity,le.shadowBias=te.bias,le.shadowNormalBias=te.normalBias,le.shadowRadius=te.radius,le.shadowMapSize.copy(te.mapSize).multiply(te.getFrameExtents()),i.sunShadow[x]=le,i.sunShadowMap[x]=k;let ge=te.getViewportCount();for(let oe=0;oe<ge;oe++)i.sunShadowMatrix[_+oe]=te.getMatrix(oe),i.sunShadowCascade[_+oe]=te._cascadeData[oe];_+=ge,x++}i.sun[m]=G,m++}else if(M.isDirectionalLight){let G=e.get(M);if(G.color.copy(M.color).multiplyScalar(M.intensity),M.castShadow){let te=M.shadow,le=t.get(M);le.shadowIntensity=te.intensity,le.shadowBias=te.bias,le.shadowNormalBias=te.normalBias,le.shadowRadius=te.radius,le.shadowMapSize=te.mapSize,i.directionalShadow[g]=le,i.directionalShadowMap[g]=k,i.directionalShadowMatrix[g]=M.shadow.matrix,N++}i.directional[g]=G,g++}else if(M.isSpotLight){let G=e.get(M);G.position.setFromMatrixPosition(M.matrixWorld),G.color.copy(J).multiplyScalar(q),G.distance=ce,G.coneCos=Math.cos(M.angle),G.penumbraCos=Math.cos(M.angle*(1-M.penumbra)),G.decay=M.decay,i.spot[F]=G;let te=M.shadow;if(M.map&&(i.spotLightMap[E]=M.map,E++,te.updateMatrices(M),M.castShadow&&D++),i.spotLightMatrix[F]=te.matrix,M.castShadow){let le=t.get(M);le.shadowIntensity=te.intensity,le.shadowBias=te.bias,le.shadowNormalBias=te.normalBias,le.shadowRadius=te.radius,le.shadowMapSize=te.mapSize,i.spotShadow[F]=le,i.spotShadowMap[F]=k,L++}F++}else if(M.isRectAreaLight){let G=e.get(M);G.color.copy(J).multiplyScalar(q),G.halfWidth.set(M.width*.5,0,0),G.halfHeight.set(0,M.height*.5,0),i.rectArea[P]=G,P++}else if(M.isPointLight){let G=e.get(M);if(G.color.copy(M.color).multiplyScalar(M.intensity),G.distance=M.distance,G.decay=M.decay,M.castShadow){let te=M.shadow,le=t.get(M);le.shadowIntensity=te.intensity,le.shadowBias=te.bias,le.shadowNormalBias=te.normalBias,le.shadowRadius=te.radius,le.shadowMapSize=te.mapSize,le.shadowCameraNear=te.camera.near,le.shadowCameraFar=te.camera.far,i.pointShadow[v]=le,i.pointShadowMap[v]=k,i.pointShadowMatrix[v]=M.shadow.matrix,p++}i.point[v]=G,v++}else if(M.isHemisphereLight){let G=e.get(M);G.skyColor.copy(M.color).multiplyScalar(q),G.groundColor.copy(M.groundColor).multiplyScalar(q),i.hemi[S]=G,S++}}P>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=$t.LTC_FLOAT_1,i.rectAreaLTC2=$t.LTC_FLOAT_2):(i.rectAreaLTC1=$t.LTC_HALF_1,i.rectAreaLTC2=$t.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=h;let Y=i.hash;(Y.sunLength!==m||Y.directionalLength!==g||Y.pointLength!==v||Y.spotLength!==F||Y.rectAreaLength!==P||Y.hemiLength!==S||Y.numSunShadows!==x||Y.numDirectionalShadows!==N||Y.numPointShadows!==p||Y.numSpotShadows!==L||Y.numSpotMaps!==E||Y.numLightProbes!==X)&&(i.sun.length=m,i.directional.length=g,i.spot.length=F,i.rectArea.length=P,i.point.length=v,i.hemi.length=S,i.sunShadow.length=x,i.sunShadowMap.length=x,i.sunShadowMatrix.length=_,i.sunShadowCascade.length=_,i.directionalShadow.length=N,i.directionalShadowMap.length=N,i.directionalShadowMatrix.length=N,i.pointShadow.length=p,i.pointShadowMap.length=p,i.pointShadowMatrix.length=p,i.spotShadow.length=L,i.spotShadowMap.length=L,i.spotLightMatrix.length=L+E-D,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=X,Y.sunLength=m,Y.directionalLength=g,Y.pointLength=v,Y.spotLength=F,Y.rectAreaLength=P,Y.hemiLength=S,Y.numSunShadows=x,Y.numDirectionalShadows=N,Y.numPointShadows=p,Y.numSpotShadows=L,Y.numSpotMaps=E,Y.numLightProbes=X,i.version=Ew++)}function u(l,d){let f=0,h=0,m=0,x=0,_=0,g=0,v=d.matrixWorldInverse;for(let F=0,P=l.length;F<P;F++){let S=l[F];if(S.isSunLight){let N=i.sun[f];N.direction.setFromMatrixPosition(S.matrixWorld),N.direction.transformDirection(v),f++}else if(S.isDirectionalLight){let N=i.directional[h];N.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),N.direction.sub(r),N.direction.transformDirection(v),h++}else if(S.isSpotLight){let N=i.spot[x];N.position.setFromMatrixPosition(S.matrixWorld),N.position.applyMatrix4(v),N.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),N.direction.sub(r),N.direction.transformDirection(v),x++}else if(S.isRectAreaLight){let N=i.rectArea[_];N.position.setFromMatrixPosition(S.matrixWorld),N.position.applyMatrix4(v),s.identity(),a.copy(S.matrixWorld),a.premultiply(v),s.extractRotation(a),N.halfWidth.set(S.width*.5,0,0),N.halfHeight.set(0,S.height*.5,0),N.halfWidth.applyMatrix4(s),N.halfHeight.applyMatrix4(s),_++}else if(S.isPointLight){let N=i.point[m];N.position.setFromMatrixPosition(S.matrixWorld),N.position.applyMatrix4(v),m++}else if(S.isHemisphereLight){let N=i.hemi[g];N.direction.setFromMatrixPosition(S.matrixWorld),N.direction.transformDirection(v),g++}}}return{setup:o,setupView:u,state:i}}function ng(n){let e=new Iw(n),t=[],i=[],r=[];function a(h){f.camera=h,t.length=0,i.length=0,r.length=0}function s(h){t.push(h)}function o(h){i.push(h)}function u(h){r.push(h)}function l(){e.setup(t)}function d(h){e.setupView(t,h)}let f={lightsArray:t,shadowsArray:i,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:f,setupLights:l,setupLightsView:d,pushLight:s,pushShadow:o,pushLightProbeGrid:u}}function Cw(n){let e=new WeakMap;function t(r,a=0){let s=e.get(r),o;return s===void 0?(o=new ng(n),e.set(r,[o])):a>=s.length?(o=new ng(n),s.push(o)):o=s[a],o}function i(){e=new WeakMap}return{get:t,dispose:i}}var Rw=`void main() {
4170
4170
  gl_Position = vec4( position, 1.0 );
4171
- }`,db=`uniform sampler2D shadow_pass;
4171
+ }`,Pw=`uniform sampler2D shadow_pass;
4172
4172
  uniform vec2 resolution;
4173
4173
  uniform float radius;
4174
4174
  void main() {
@@ -4193,12 +4193,12 @@ void main() {
4193
4193
  squared_mean = squared_mean / samples;
4194
4194
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4195
4195
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4196
- }`,fb=[new ge(1,0,0),new ge(-1,0,0),new ge(0,1,0),new ge(0,-1,0),new ge(0,0,1),new ge(0,0,-1)],hb=[new ge(0,-1,0),new ge(0,-1,0),new ge(0,0,1),new ge(0,0,-1),new ge(0,-1,0),new ge(0,-1,0)],J0=new $n,Jl=new ge,Fh=new ge;function pb(n,e,t){let i=new xo,r=new kt,a=new kt,s=new fi,o=new gu,u=new yu,l={},d=t.maxTextureSize,f={[ms]:pr,[pr]:ms,[Ir]:Ir},h=new kr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new kt},radius:{value:4}},vertexShader:ub,fragmentShader:db}),v=h.clone();v.defines.HORIZONTAL_PASS=1;let y=new Wi;y.setAttribute("position",new Fr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let T=new jn(y,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=kl;let m=this.type;this.render=function(S,B,b){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||S.length===0)return;this.type===Du&&(rn("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=kl);let I=n.getRenderTarget(),z=n.getActiveCubeFace(),U=n.getActiveMipmapLevel(),Y=n.state;Y.setBlending(Aa),Y.buffers.depth.getReversed()===!0?Y.buffers.color.setClear(0,0,0,0):Y.buffers.color.setClear(1,1,1,1),Y.buffers.depth.setTest(!0),Y.setScissorTest(!1);let E=m!==this.type;E&&B.traverse(function(M){M.material&&(Array.isArray(M.material)?M.material.forEach(O=>O.needsUpdate=!0):M.material.needsUpdate=!0)});for(let M=0,O=S.length;M<O;M++){let H=S[M],ee=H.shadow;if(ee===void 0){rn("WebGLShadowMap:",H,"has no shadow.");continue}if(ee.autoUpdate===!1&&ee.needsUpdate===!1)continue;r.copy(ee.mapSize);let j=ee.getFrameExtents();r.multiply(j),a.copy(ee.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(a.x=Math.floor(d/j.x),r.x=a.x*j.x,ee.mapSize.x=a.x),r.y>d&&(a.y=Math.floor(d/j.y),r.y=a.y*j.y,ee.mapSize.y=a.y));let K=n.state.buffers.depth.getReversed();if(ee.camera._reversedDepth=K,ee.map===null||E===!0){if(ee.map!==null&&(ee.map.depthTexture!==null&&(ee.map.depthTexture.dispose(),ee.map.depthTexture=null),ee.map.dispose()),this.type===Eo){if(H.isPointLight){rn("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}ee.map=new Ar(r.x,r.y,{format:xs,type:oa,minFilter:Hi,magFilter:Hi,generateMipmaps:!1}),ee.map.texture.name=H.name+".shadowMap",ee.map.depthTexture=new us(r.x,r.y,Yr),ee.map.depthTexture.name=H.name+".shadowMapDepth",ee.map.depthTexture.format=Ma,ee.map.depthTexture.compareFunction=null,ee.map.depthTexture.minFilter=Bi,ee.map.depthTexture.magFilter=Bi}else H.isPointLight?(ee.map=new Ad(r.x),ee.map.depthTexture=new cu(r.x,sa)):(ee.map=new Ar(r.x,r.y),ee.map.depthTexture=new us(r.x,r.y,sa)),ee.map.depthTexture.name=H.name+".shadowMap",ee.map.depthTexture.format=Ma,this.type===kl?(ee.map.depthTexture.compareFunction=K?bd:Sd,ee.map.depthTexture.minFilter=Hi,ee.map.depthTexture.magFilter=Hi):(ee.map.depthTexture.compareFunction=null,ee.map.depthTexture.minFilter=Bi,ee.map.depthTexture.magFilter=Bi);ee.camera.updateProjectionMatrix()}ee.map.isWebGLCubeRenderTarget!==!0&&(ee.map.width!==r.x||ee.map.height!==r.y)&&ee.map.setSize(r.x,r.y);let re=ee.map.isWebGLCubeRenderTarget?6:ee.getViewportCount();H.isPointLight!==!0&&ee.updateMatrices(H,b);for(let J=0;J<re;J++){let ne=ee.getCamera(J);if(H.isPointLight){let Te=ee.camera,fe=ee.matrix,pe=H.distance||Te.far;pe!==Te.far&&(Te.far=pe,Te.updateProjectionMatrix()),Jl.setFromMatrixPosition(H.matrixWorld),Te.position.copy(Jl),Fh.copy(Te.position),Fh.add(fb[J]),Te.up.copy(hb[J]),Te.lookAt(Fh),Te.updateMatrixWorld(),fe.makeTranslation(-Jl.x,-Jl.y,-Jl.z),J0.multiplyMatrices(Te.projectionMatrix,Te.matrixWorldInverse),ee._frustum.setFromProjectionMatrix(J0,Te.coordinateSystem,Te.reversedDepth)}if(ee.map.isWebGLCubeRenderTarget)n.setRenderTarget(ee.map,J),n.clear();else{J===0&&(n.setRenderTarget(ee.map),n.clear());let Te=ee.getViewport(J);s.set(a.x*Te.x,a.y*Te.y,a.x*Te.z,a.y*Te.w),Y.viewport(s)}i=ee.getFrustum(J),_(B,b,ne,H,this.type)}ee.isPointLightShadow!==!0&&this.type===Eo&&L(ee,b),ee.needsUpdate=!1}m=this.type,g.needsUpdate=!1,n.setRenderTarget(I,z,U)};function L(S,B){let b=e.update(T);h.defines.VSM_SAMPLES!==S.blurSamples&&(h.defines.VSM_SAMPLES=S.blurSamples,v.defines.VSM_SAMPLES=S.blurSamples,h.needsUpdate=!0,v.needsUpdate=!0),S.mapPass===null?S.mapPass=new Ar(r.x,r.y,{format:xs,type:oa}):(S.mapPass.width!==S.map.width||S.mapPass.height!==S.map.height)&&S.mapPass.setSize(S.map.width,S.map.height),h.uniforms.shadow_pass.value=S.map.depthTexture,h.uniforms.resolution.value.set(S.map.width,S.map.height),h.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(B,null,b,h,T,null),v.uniforms.shadow_pass.value=S.mapPass.texture,v.uniforms.resolution.value.set(S.map.width,S.map.height),v.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(B,null,b,v,T,null)}function F(S,B,b,I){let z=null,U=b.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(U!==void 0)z=U;else if(z=b.isPointLight===!0?u:o,n.localClippingEnabled&&B.clipShadows===!0&&Array.isArray(B.clippingPlanes)&&B.clippingPlanes.length!==0||B.displacementMap&&B.displacementScale!==0||B.alphaMap&&B.alphaTest>0||B.map&&B.alphaTest>0||B.alphaToCoverage===!0){let Y=z.uuid,E=B.uuid,M=l[Y];M===void 0&&(M={},l[Y]=M);let O=M[E];O===void 0&&(O=z.clone(),M[E]=O,B.addEventListener("dispose",p)),z=O}if(z.visible=B.visible,z.wireframe=B.wireframe,I===Eo?z.side=B.shadowSide!==null?B.shadowSide:B.side:z.side=B.shadowSide!==null?B.shadowSide:f[B.side],z.alphaMap=B.alphaMap,z.alphaTest=B.alphaToCoverage===!0?.5:B.alphaTest,z.map=B.map,z.clipShadows=B.clipShadows,z.clippingPlanes=B.clippingPlanes,z.clipIntersection=B.clipIntersection,z.displacementMap=B.displacementMap,z.displacementScale=B.displacementScale,z.displacementBias=B.displacementBias,z.wireframeLinewidth=B.wireframeLinewidth,z.linewidth=B.linewidth,b.isPointLight===!0&&z.isMeshDistanceMaterial===!0){let Y=n.properties.get(z);Y.light=b}return z}function _(S,B,b,I,z){if(S.visible===!1)return;if(S.layers.test(B.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&z===Eo)&&(!S.frustumCulled||S.intersectsFrustum(i))){S.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,S.matrixWorld);let E=e.update(S),M=S.material;if(Array.isArray(M)){let O=E.groups;for(let H=0,ee=O.length;H<ee;H++){let j=O[H],K=M[j.materialIndex];if(K&&K.visible){let re=F(S,K,I,z);S.onBeforeShadow(n,S,B,b,E,re,j),n.renderBufferDirect(b,null,E,re,S,j),S.onAfterShadow(n,S,B,b,E,re,j)}}}else if(M.visible){let O=F(S,M,I,z);S.onBeforeShadow(n,S,B,b,E,O,null),n.renderBufferDirect(b,null,E,O,S,null),S.onAfterShadow(n,S,B,b,E,O,null)}}let Y=S.children;for(let E=0,M=Y.length;E<M;E++)_(Y[E],B,b,I,z)}function p(S){S.target.removeEventListener("dispose",p);for(let b in l){let I=l[b],z=S.target.uuid;z in I&&(I[z].dispose(),delete I[z])}}}function mb(n,e){function t(){let ie=!1,Oe=new fi,Pe=null,nt=new fi(0,0,0,0);return{setMask:function(dt){Pe!==dt&&!ie&&(n.colorMask(dt,dt,dt,dt),Pe=dt)},setLocked:function(dt){ie=dt},setClear:function(dt,Be,Rt,vt,cn){cn===!0&&(dt*=vt,Be*=vt,Rt*=vt),Oe.set(dt,Be,Rt,vt),nt.equals(Oe)===!1&&(n.clearColor(dt,Be,Rt,vt),nt.copy(Oe))},reset:function(){ie=!1,Pe=null,nt.set(-1,0,0,0)}}}function i(){let ie=!1,Oe=!1,Pe=null,nt=null,dt=null;return{setReversed:function(Be){if(Oe!==Be){let Rt=e.get("EXT_clip_control");Be?Rt.clipControlEXT(Rt.LOWER_LEFT_EXT,Rt.ZERO_TO_ONE_EXT):Rt.clipControlEXT(Rt.LOWER_LEFT_EXT,Rt.NEGATIVE_ONE_TO_ONE_EXT),Oe=Be;let vt=dt;dt=null,this.setClear(vt)}},getReversed:function(){return Oe},setTest:function(Be){Be?de(n.DEPTH_TEST):_e(n.DEPTH_TEST)},setMask:function(Be){Pe!==Be&&!ie&&(n.depthMask(Be),Pe=Be)},setFunc:function(Be){if(Oe&&(Be=_0[Be]),nt!==Be){switch(Be){case Jc:n.depthFunc(n.NEVER);break;case $c:n.depthFunc(n.ALWAYS);break;case Kc:n.depthFunc(n.LESS);break;case ho:n.depthFunc(n.LEQUAL);break;case Qc:n.depthFunc(n.EQUAL);break;case jc:n.depthFunc(n.GEQUAL);break;case eu:n.depthFunc(n.GREATER);break;case tu:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}nt=Be}},setLocked:function(Be){ie=Be},setClear:function(Be){dt!==Be&&(dt=Be,Oe&&(Be=1-Be),n.clearDepth(Be))},reset:function(){ie=!1,Pe=null,nt=null,dt=null,Oe=!1}}}function r(){let ie=!1,Oe=null,Pe=null,nt=null,dt=null,Be=null,Rt=null,vt=null,cn=null;return{setTest:function(dn){ie||(dn?de(n.STENCIL_TEST):_e(n.STENCIL_TEST))},setMask:function(dn){Oe!==dn&&!ie&&(n.stencilMask(dn),Oe=dn)},setFunc:function(dn,Fn,Dn){(Pe!==dn||nt!==Fn||dt!==Dn)&&(n.stencilFunc(dn,Fn,Dn),Pe=dn,nt=Fn,dt=Dn)},setOp:function(dn,Fn,Dn){(Be!==dn||Rt!==Fn||vt!==Dn)&&(n.stencilOp(dn,Fn,Dn),Be=dn,Rt=Fn,vt=Dn)},setLocked:function(dn){ie=dn},setClear:function(dn){cn!==dn&&(n.clearStencil(dn),cn=dn)},reset:function(){ie=!1,Oe=null,Pe=null,nt=null,dt=null,Be=null,Rt=null,vt=null,cn=null}}}let a=new t,s=new i,o=new r,u=new WeakMap,l=new WeakMap,d={},f={},h={},v=new WeakMap,y=[],T=null,g=!1,m=null,L=null,F=null,_=null,p=null,S=null,B=null,b=new vn(0,0,0),I=0,z=!1,U=null,Y=null,E=null,M=null,O=null,H=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),ee=!1,j=0,K=n.getParameter(n.VERSION);K.indexOf("WebGL")!==-1?(j=parseFloat(/^WebGL (\d)/.exec(K)[1]),ee=j>=1):K.indexOf("OpenGL ES")!==-1&&(j=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),ee=j>=2);let re=null,J={},ne=n.getParameter(n.SCISSOR_BOX),Te=n.getParameter(n.VIEWPORT),fe=new fi().fromArray(ne),pe=new fi().fromArray(Te);function Fe(ie,Oe,Pe,nt){let dt=new Uint8Array(4),Be=n.createTexture();n.bindTexture(ie,Be),n.texParameteri(ie,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(ie,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Rt=0;Rt<Pe;Rt++)ie===n.TEXTURE_3D||ie===n.TEXTURE_2D_ARRAY?n.texImage3D(Oe,0,n.RGBA,1,1,nt,0,n.RGBA,n.UNSIGNED_BYTE,dt):n.texImage2D(Oe+Rt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,dt);return Be}let ae={};ae[n.TEXTURE_2D]=Fe(n.TEXTURE_2D,n.TEXTURE_2D,1),ae[n.TEXTURE_CUBE_MAP]=Fe(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),ae[n.TEXTURE_2D_ARRAY]=Fe(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),ae[n.TEXTURE_3D]=Fe(n.TEXTURE_3D,n.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),de(n.DEPTH_TEST),s.setFunc(ho),wt(!1),bt(jf),de(n.CULL_FACE),Tt(Aa);function de(ie){d[ie]!==!0&&(n.enable(ie),d[ie]=!0)}function _e(ie){d[ie]!==!1&&(n.disable(ie),d[ie]=!1)}function Ge(ie,Oe){return h[ie]!==Oe?(n.bindFramebuffer(ie,Oe),h[ie]=Oe,ie===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=Oe),ie===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=Oe),!0):!1}function $e(ie,Oe){let Pe=y,nt=!1;if(ie){Pe=v.get(Oe),Pe===void 0&&(Pe=[],v.set(Oe,Pe));let dt=ie.textures;if(Pe.length!==dt.length||Pe[0]!==n.COLOR_ATTACHMENT0){for(let Be=0,Rt=dt.length;Be<Rt;Be++)Pe[Be]=n.COLOR_ATTACHMENT0+Be;Pe.length=dt.length,nt=!0}}else Pe[0]!==n.BACK&&(Pe[0]=n.BACK,nt=!0);nt&&n.drawBuffers(Pe)}function ut(ie){return T!==ie?(n.useProgram(ie),T=ie,!0):!1}let zt={[Fs]:n.FUNC_ADD,[Vm]:n.FUNC_SUBTRACT,[Gm]:n.FUNC_REVERSE_SUBTRACT};zt[Hm]=n.MIN,zt[Wm]=n.MAX;let ct={[Xm]:n.ZERO,[Ym]:n.ONE,[qm]:n.SRC_COLOR,[ih]:n.SRC_ALPHA,[jm]:n.SRC_ALPHA_SATURATE,[Km]:n.DST_COLOR,[Jm]:n.DST_ALPHA,[Zm]:n.ONE_MINUS_SRC_COLOR,[rh]:n.ONE_MINUS_SRC_ALPHA,[Qm]:n.ONE_MINUS_DST_COLOR,[$m]:n.ONE_MINUS_DST_ALPHA,[e0]:n.CONSTANT_COLOR,[t0]:n.ONE_MINUS_CONSTANT_COLOR,[n0]:n.CONSTANT_ALPHA,[i0]:n.ONE_MINUS_CONSTANT_ALPHA};function Tt(ie,Oe,Pe,nt,dt,Be,Rt,vt,cn,dn){if(ie===Aa){g===!0&&(_e(n.BLEND),g=!1);return}if(g===!1&&(de(n.BLEND),g=!0),ie!==zm){if(ie!==m||dn!==z){if((L!==Fs||p!==Fs)&&(n.blendEquation(n.FUNC_ADD),L=Fs,p=Fs),dn)switch(ie){case Ao:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case eh:n.blendFunc(n.ONE,n.ONE);break;case th:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case nh:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:sn("WebGLState: Invalid blending: ",ie);break}else switch(ie){case Ao:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case eh:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case th:sn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case nh:sn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:sn("WebGLState: Invalid blending: ",ie);break}F=null,_=null,S=null,B=null,b.set(0,0,0),I=0,m=ie,z=dn}return}dt=dt||Oe,Be=Be||Pe,Rt=Rt||nt,(Oe!==L||dt!==p)&&(n.blendEquationSeparate(zt[Oe],zt[dt]),L=Oe,p=dt),(Pe!==F||nt!==_||Be!==S||Rt!==B)&&(n.blendFuncSeparate(ct[Pe],ct[nt],ct[Be],ct[Rt]),F=Pe,_=nt,S=Be,B=Rt),(vt.equals(b)===!1||cn!==I)&&(n.blendColor(vt.r,vt.g,vt.b,cn),b.copy(vt),I=cn),m=ie,z=!1}function Zt(ie,Oe){ie.side===Ir?_e(n.CULL_FACE):de(n.CULL_FACE);let Pe=ie.side===pr;Oe&&(Pe=!Pe),wt(Pe),ie.blending===Ao&&ie.transparent===!1?Tt(Aa):Tt(ie.blending,ie.blendEquation,ie.blendSrc,ie.blendDst,ie.blendEquationAlpha,ie.blendSrcAlpha,ie.blendDstAlpha,ie.blendColor,ie.blendAlpha,ie.premultipliedAlpha),s.setFunc(ie.depthFunc),s.setTest(ie.depthTest),s.setMask(ie.depthWrite),a.setMask(ie.colorWrite);let nt=ie.stencilWrite;o.setTest(nt),nt&&(o.setMask(ie.stencilWriteMask),o.setFunc(ie.stencilFunc,ie.stencilRef,ie.stencilFuncMask),o.setOp(ie.stencilFail,ie.stencilZFail,ie.stencilZPass)),ln(ie.polygonOffset,ie.polygonOffsetFactor,ie.polygonOffsetUnits),ie.alphaToCoverage===!0?de(n.SAMPLE_ALPHA_TO_COVERAGE):_e(n.SAMPLE_ALPHA_TO_COVERAGE)}function wt(ie){U!==ie&&(ie?n.frontFace(n.CW):n.frontFace(n.CCW),U=ie)}function bt(ie){ie!==Bm?(de(n.CULL_FACE),ie!==Y&&(ie===jf?n.cullFace(n.BACK):ie===km?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):_e(n.CULL_FACE),Y=ie}function _t(ie){ie!==E&&(ee&&n.lineWidth(ie),E=ie)}function ln(ie,Oe,Pe){ie?(de(n.POLYGON_OFFSET_FILL),(M!==Oe||O!==Pe)&&(M=Oe,O=Pe,s.getReversed()&&(Oe=-Oe),n.polygonOffset(Oe,Pe))):_e(n.POLYGON_OFFSET_FILL)}function rt(ie){ie?de(n.SCISSOR_TEST):_e(n.SCISSOR_TEST)}function an(ie){ie===void 0&&(ie=n.TEXTURE0+H-1),re!==ie&&(n.activeTexture(ie),re=ie)}function se(ie,Oe,Pe){Pe===void 0&&(re===null?Pe=n.TEXTURE0+H-1:Pe=re);let nt=J[Pe];nt===void 0&&(nt={type:void 0,texture:void 0},J[Pe]=nt),(nt.type!==ie||nt.texture!==Oe)&&(re!==Pe&&(n.activeTexture(Pe),re=Pe),n.bindTexture(ie,Oe||ae[ie]),nt.type=ie,nt.texture=Oe)}function mn(){let ie=J[re];ie!==void 0&&ie.type!==void 0&&(n.bindTexture(ie.type,null),ie.type=void 0,ie.texture=void 0)}function nn(){try{n.compressedTexImage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function W(){try{n.compressedTexImage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function w(){try{n.texSubImage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function ue(){try{n.texSubImage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function ye(){try{n.compressedTexSubImage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function we(){try{n.compressedTexSubImage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function ze(){try{n.texStorage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function Ye(){try{n.texStorage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function Re(){try{n.texImage2D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function Ae(){try{n.texImage3D(...arguments)}catch(ie){sn("WebGLState:",ie)}}function Ne(ie){return f[ie]!==void 0?f[ie]:n.getParameter(ie)}function je(ie,Oe){f[ie]!==Oe&&(n.pixelStorei(ie,Oe),f[ie]=Oe)}function Ve(ie){fe.equals(ie)===!1&&(n.scissor(ie.x,ie.y,ie.z,ie.w),fe.copy(ie))}function qe(ie){pe.equals(ie)===!1&&(n.viewport(ie.x,ie.y,ie.z,ie.w),pe.copy(ie))}function ot(ie,Oe){let Pe=l.get(Oe);Pe===void 0&&(Pe=new WeakMap,l.set(Oe,Pe));let nt=Pe.get(ie);nt===void 0&&(nt=n.getUniformBlockIndex(Oe,ie.name),Pe.set(ie,nt))}function pt(ie,Oe){let nt=l.get(Oe).get(ie);u.get(Oe)!==nt&&(n.uniformBlockBinding(Oe,nt,ie.__bindingPointIndex),u.set(Oe,nt))}function He(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),s.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),n.pixelStorei(n.PACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.BROWSER_DEFAULT_WEBGL),n.pixelStorei(n.PACK_ROW_LENGTH,0),n.pixelStorei(n.PACK_SKIP_PIXELS,0),n.pixelStorei(n.PACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_ROW_LENGTH,0),n.pixelStorei(n.UNPACK_IMAGE_HEIGHT,0),n.pixelStorei(n.UNPACK_SKIP_PIXELS,0),n.pixelStorei(n.UNPACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_SKIP_IMAGES,0),d={},f={},re=null,J={},h={},v=new WeakMap,y=[],T=null,g=!1,m=null,L=null,F=null,_=null,p=null,S=null,B=null,b=new vn(0,0,0),I=0,z=!1,U=null,Y=null,E=null,M=null,O=null,fe.set(0,0,n.canvas.width,n.canvas.height),pe.set(0,0,n.canvas.width,n.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:de,disable:_e,bindFramebuffer:Ge,drawBuffers:$e,useProgram:ut,setBlending:Tt,setMaterial:Zt,setFlipSided:wt,setCullFace:bt,setLineWidth:_t,setPolygonOffset:ln,setScissorTest:rt,activeTexture:an,bindTexture:se,unbindTexture:mn,compressedTexImage2D:nn,compressedTexImage3D:W,texImage2D:Re,texImage3D:Ae,pixelStorei:je,getParameter:Ne,updateUBOMapping:ot,uniformBlockBinding:pt,texStorage2D:ze,texStorage3D:Ye,texSubImage2D:w,texSubImage3D:ue,compressedTexSubImage2D:ye,compressedTexSubImage3D:we,scissor:Ve,viewport:qe,reset:He}}function vb(n,e,t,i,r,a,s){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,u=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new kt,d=new WeakMap,f=new Set,h,v=new WeakMap,y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function T(W,w){return y?new OffscreenCanvas(W,w):pl("canvas")}function g(W,w,ue){let ye=1,we=nn(W);if((we.width>ue||we.height>ue)&&(ye=ue/Math.max(we.width,we.height)),ye<1)if(typeof HTMLImageElement<"u"&&W instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&W instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&W instanceof ImageBitmap||typeof VideoFrame<"u"&&W instanceof VideoFrame){let ze=Math.floor(ye*we.width),Ye=Math.floor(ye*we.height);h===void 0&&(h=T(ze,Ye));let Re=w?T(ze,Ye):h;return Re.width=ze,Re.height=Ye,Re.getContext("2d").drawImage(W,0,0,ze,Ye),rn("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+ze+"x"+Ye+")."),Re}else return"data"in W&&rn("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.height+")."),W;return W}function m(W){return W.generateMipmaps}function L(W){n.generateMipmap(W)}function F(W){return W.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:W.isWebGL3DRenderTarget?n.TEXTURE_3D:W.isWebGLArrayRenderTarget||W.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function _(W,w,ue,ye,we,ze=!1){if(W!==null){if(n[W]!==void 0)return n[W];rn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+W+"'")}let Ye;ye&&(Ye=e.get("EXT_texture_norm16"),Ye||rn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Re=w;if(w===n.RED&&(ue===n.FLOAT&&(Re=n.R32F),ue===n.HALF_FLOAT&&(Re=n.R16F),ue===n.UNSIGNED_BYTE&&(Re=n.R8),ue===n.UNSIGNED_SHORT&&Ye&&(Re=Ye.R16_EXT),ue===n.SHORT&&Ye&&(Re=Ye.R16_SNORM_EXT)),w===n.RED_INTEGER&&(ue===n.UNSIGNED_BYTE&&(Re=n.R8UI),ue===n.UNSIGNED_SHORT&&(Re=n.R16UI),ue===n.UNSIGNED_INT&&(Re=n.R32UI),ue===n.BYTE&&(Re=n.R8I),ue===n.SHORT&&(Re=n.R16I),ue===n.INT&&(Re=n.R32I)),w===n.RG&&(ue===n.FLOAT&&(Re=n.RG32F),ue===n.HALF_FLOAT&&(Re=n.RG16F),ue===n.UNSIGNED_BYTE&&(Re=n.RG8),ue===n.UNSIGNED_SHORT&&Ye&&(Re=Ye.RG16_EXT),ue===n.SHORT&&Ye&&(Re=Ye.RG16_SNORM_EXT)),w===n.RG_INTEGER&&(ue===n.UNSIGNED_BYTE&&(Re=n.RG8UI),ue===n.UNSIGNED_SHORT&&(Re=n.RG16UI),ue===n.UNSIGNED_INT&&(Re=n.RG32UI),ue===n.BYTE&&(Re=n.RG8I),ue===n.SHORT&&(Re=n.RG16I),ue===n.INT&&(Re=n.RG32I)),w===n.RGB_INTEGER&&(ue===n.UNSIGNED_BYTE&&(Re=n.RGB8UI),ue===n.UNSIGNED_SHORT&&(Re=n.RGB16UI),ue===n.UNSIGNED_INT&&(Re=n.RGB32UI),ue===n.BYTE&&(Re=n.RGB8I),ue===n.SHORT&&(Re=n.RGB16I),ue===n.INT&&(Re=n.RGB32I)),w===n.RGBA_INTEGER&&(ue===n.UNSIGNED_BYTE&&(Re=n.RGBA8UI),ue===n.UNSIGNED_SHORT&&(Re=n.RGBA16UI),ue===n.UNSIGNED_INT&&(Re=n.RGBA32UI),ue===n.BYTE&&(Re=n.RGBA8I),ue===n.SHORT&&(Re=n.RGBA16I),ue===n.INT&&(Re=n.RGBA32I)),w===n.RGB&&(ue===n.UNSIGNED_SHORT&&Ye&&(Re=Ye.RGB16_EXT),ue===n.SHORT&&Ye&&(Re=Ye.RGB16_SNORM_EXT),ue===n.UNSIGNED_INT_5_9_9_9_REV&&(Re=n.RGB9_E5),ue===n.UNSIGNED_INT_10F_11F_11F_REV&&(Re=n.R11F_G11F_B10F)),w===n.RGBA){let Ae=ze?hl:Ln.getTransfer(we);ue===n.FLOAT&&(Re=n.RGBA32F),ue===n.HALF_FLOAT&&(Re=n.RGBA16F),ue===n.UNSIGNED_BYTE&&(Re=Ae===Jn?n.SRGB8_ALPHA8:n.RGBA8),ue===n.UNSIGNED_SHORT&&Ye&&(Re=Ye.RGBA16_EXT),ue===n.SHORT&&Ye&&(Re=Ye.RGBA16_SNORM_EXT),ue===n.UNSIGNED_SHORT_4_4_4_4&&(Re=n.RGBA4),ue===n.UNSIGNED_SHORT_5_5_5_1&&(Re=n.RGB5_A1)}return(Re===n.R16F||Re===n.R32F||Re===n.RG16F||Re===n.RG32F||Re===n.RGBA16F||Re===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Re}function p(W,w){let ue;return W?w===null||w===sa||w===Co?ue=n.DEPTH24_STENCIL8:w===Yr?ue=n.DEPTH32F_STENCIL8:w===Io&&(ue=n.DEPTH24_STENCIL8,rn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):w===null||w===sa||w===Co?ue=n.DEPTH_COMPONENT24:w===Yr?ue=n.DEPTH_COMPONENT32F:w===Io&&(ue=n.DEPTH_COMPONENT16),ue}function S(W,w){return m(W)===!0||W.isFramebufferTexture&&W.minFilter!==Bi&&W.minFilter!==Hi?Math.log2(Math.max(w.width,w.height))+1:W.mipmaps!==void 0&&W.mipmaps.length>0?W.mipmaps.length:W.isCompressedTexture&&Array.isArray(W.image)?w.mipmaps.length:1}function B(W){let w=W.target;w.removeEventListener("dispose",B),I(w),w.isVideoTexture&&d.delete(w),w.isHTMLTexture&&f.delete(w)}function b(W){let w=W.target;w.removeEventListener("dispose",b),U(w)}function I(W){let w=i.get(W);if(w.__webglInit===void 0)return;let ue=W.source,ye=v.get(ue);if(ye){let we=ye[w.__cacheKey];we.usedTimes--,we.usedTimes===0&&z(W),Object.keys(ye).length===0&&v.delete(ue)}i.remove(W)}function z(W){let w=i.get(W);n.deleteTexture(w.__webglTexture);let ue=W.source,ye=v.get(ue);delete ye[w.__cacheKey],s.memory.textures--}function U(W){let w=i.get(W);if(W.depthTexture&&(W.depthTexture.dispose(),i.remove(W.depthTexture)),W.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(w.__webglFramebuffer[ye]))for(let we=0;we<w.__webglFramebuffer[ye].length;we++)n.deleteFramebuffer(w.__webglFramebuffer[ye][we]);else n.deleteFramebuffer(w.__webglFramebuffer[ye]);w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer[ye])}else{if(Array.isArray(w.__webglFramebuffer))for(let ye=0;ye<w.__webglFramebuffer.length;ye++)n.deleteFramebuffer(w.__webglFramebuffer[ye]);else n.deleteFramebuffer(w.__webglFramebuffer);if(w.__webglDepthbuffer&&n.deleteRenderbuffer(w.__webglDepthbuffer),w.__webglMultisampledFramebuffer&&n.deleteFramebuffer(w.__webglMultisampledFramebuffer),w.__webglColorRenderbuffer)for(let ye=0;ye<w.__webglColorRenderbuffer.length;ye++)w.__webglColorRenderbuffer[ye]&&n.deleteRenderbuffer(w.__webglColorRenderbuffer[ye]);w.__webglDepthRenderbuffer&&n.deleteRenderbuffer(w.__webglDepthRenderbuffer)}let ue=W.textures;for(let ye=0,we=ue.length;ye<we;ye++){let ze=i.get(ue[ye]);ze.__webglTexture&&(n.deleteTexture(ze.__webglTexture),s.memory.textures--),i.remove(ue[ye])}i.remove(W)}let Y=0;function E(){Y=0}function M(){return Y}function O(W){Y=W}function H(){let W=Y;return W>=r.maxTextures&&rn("WebGLTextures: Trying to use "+(W+1)+" texture units while this GPU supports only "+r.maxTextures),Y+=1,W}function ee(W){let w=[];return w.push(W.wrapS),w.push(W.wrapT),w.push(W.wrapR||0),w.push(W.magFilter),w.push(W.minFilter),w.push(W.anisotropy),w.push(W.internalFormat),w.push(W.format),w.push(W.type),w.push(W.generateMipmaps),w.push(W.premultiplyAlpha),w.push(W.flipY),w.push(W.unpackAlignment),w.push(W.colorSpace),w.join()}function j(W,w){let ue=i.get(W);if(W.isVideoTexture&&se(W),W.isRenderTargetTexture===!1&&W.isExternalTexture!==!0&&W.version>0&&ue.__version!==W.version){let ye=W.image;if(ye===null)rn("WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)rn("WebGLRenderer: Texture marked for update but image is incomplete");else{_e(ue,W,w);return}}else W.isExternalTexture&&(ue.__webglTexture=W.sourceTexture?W.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ue.__webglTexture,n.TEXTURE0+w)}function K(W,w){let ue=i.get(W);if(W.isRenderTargetTexture===!1&&W.version>0&&ue.__version!==W.version){_e(ue,W,w);return}else W.isExternalTexture&&(ue.__webglTexture=W.sourceTexture?W.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ue.__webglTexture,n.TEXTURE0+w)}function re(W,w){let ue=i.get(W);if(W.isRenderTargetTexture===!1&&W.version>0&&ue.__version!==W.version){_e(ue,W,w);return}t.bindTexture(n.TEXTURE_3D,ue.__webglTexture,n.TEXTURE0+w)}function J(W,w){let ue=i.get(W);if(W.isCubeDepthTexture!==!0&&W.version>0&&ue.__version!==W.version){Ge(ue,W,w);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ue.__webglTexture,n.TEXTURE0+w)}let ne={[nu]:n.REPEAT,[_a]:n.CLAMP_TO_EDGE,[iu]:n.MIRRORED_REPEAT},Te={[Bi]:n.NEAREST,[s0]:n.NEAREST_MIPMAP_NEAREST,[Vl]:n.NEAREST_MIPMAP_LINEAR,[Hi]:n.LINEAR,[Ou]:n.LINEAR_MIPMAP_NEAREST,[gs]:n.LINEAR_MIPMAP_LINEAR},fe={[u0]:n.NEVER,[m0]:n.ALWAYS,[d0]:n.LESS,[Sd]:n.LEQUAL,[f0]:n.EQUAL,[bd]:n.GEQUAL,[h0]:n.GREATER,[p0]:n.NOTEQUAL};function pe(W,w){if(w.type===Yr&&e.has("OES_texture_float_linear")===!1&&(w.magFilter===Hi||w.magFilter===Ou||w.magFilter===Vl||w.magFilter===gs||w.minFilter===Hi||w.minFilter===Ou||w.minFilter===Vl||w.minFilter===gs)&&rn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(W,n.TEXTURE_WRAP_S,ne[w.wrapS]),n.texParameteri(W,n.TEXTURE_WRAP_T,ne[w.wrapT]),(W===n.TEXTURE_3D||W===n.TEXTURE_2D_ARRAY)&&n.texParameteri(W,n.TEXTURE_WRAP_R,ne[w.wrapR]),n.texParameteri(W,n.TEXTURE_MAG_FILTER,Te[w.magFilter]),n.texParameteri(W,n.TEXTURE_MIN_FILTER,Te[w.minFilter]),w.compareFunction&&(n.texParameteri(W,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(W,n.TEXTURE_COMPARE_FUNC,fe[w.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(w.magFilter===Bi||w.minFilter!==Vl&&w.minFilter!==gs||w.type===Yr&&e.has("OES_texture_float_linear")===!1)return;if(w.anisotropy>1||i.get(w).__currentAnisotropy){let ue=e.get("EXT_texture_filter_anisotropic");n.texParameterf(W,ue.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(w.anisotropy,r.getMaxAnisotropy())),i.get(w).__currentAnisotropy=w.anisotropy}}}function Fe(W,w){let ue=!1;W.__webglInit===void 0&&(W.__webglInit=!0,w.addEventListener("dispose",B));let ye=w.source,we=v.get(ye);we===void 0&&(we={},v.set(ye,we));let ze=ee(w);if(ze!==W.__cacheKey){we[ze]===void 0&&(we[ze]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,ue=!0),we[ze].usedTimes++;let Ye=we[W.__cacheKey];Ye!==void 0&&(we[W.__cacheKey].usedTimes--,Ye.usedTimes===0&&z(w)),W.__cacheKey=ze,W.__webglTexture=we[ze].texture}return ue}function ae(W,w,ue){return Math.floor(Math.floor(W/ue)/w)}function de(W,w,ue,ye){let ze=W.updateRanges;if(ze.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,w.width,w.height,ue,ye,w.data);else{ze.sort((je,Ve)=>je.start-Ve.start);let Ye=0;for(let je=1;je<ze.length;je++){let Ve=ze[Ye],qe=ze[je],ot=Ve.start+Ve.count,pt=ae(qe.start,w.width,4),He=ae(Ve.start,w.width,4);qe.start<=ot+1&&pt===He&&ae(qe.start+qe.count-1,w.width,4)===pt?Ve.count=Math.max(Ve.count,qe.start+qe.count-Ve.start):(++Ye,ze[Ye]=qe)}ze.length=Ye+1;let Re=t.getParameter(n.UNPACK_ROW_LENGTH),Ae=t.getParameter(n.UNPACK_SKIP_PIXELS),Ne=t.getParameter(n.UNPACK_SKIP_ROWS);t.pixelStorei(n.UNPACK_ROW_LENGTH,w.width);for(let je=0,Ve=ze.length;je<Ve;je++){let qe=ze[je],ot=Math.floor(qe.start/4),pt=Math.ceil(qe.count/4),He=ot%w.width,ie=Math.floor(ot/w.width),Oe=pt,Pe=1;t.pixelStorei(n.UNPACK_SKIP_PIXELS,He),t.pixelStorei(n.UNPACK_SKIP_ROWS,ie),t.texSubImage2D(n.TEXTURE_2D,0,He,ie,Oe,Pe,ue,ye,w.data)}W.clearUpdateRanges(),t.pixelStorei(n.UNPACK_ROW_LENGTH,Re),t.pixelStorei(n.UNPACK_SKIP_PIXELS,Ae),t.pixelStorei(n.UNPACK_SKIP_ROWS,Ne)}}function _e(W,w,ue){let ye=n.TEXTURE_2D;(w.isDataArrayTexture||w.isCompressedArrayTexture)&&(ye=n.TEXTURE_2D_ARRAY),w.isData3DTexture&&(ye=n.TEXTURE_3D);let we=Fe(W,w),ze=w.source;t.bindTexture(ye,W.__webglTexture,n.TEXTURE0+ue);let Ye=i.get(ze);if(ze.version!==Ye.__version||we===!0){if(t.activeTexture(n.TEXTURE0+ue),(typeof ImageBitmap<"u"&&w.image instanceof ImageBitmap)===!1){let Pe=Ln.getPrimaries(Ln.workingColorSpace),nt=w.colorSpace===Ya?null:Ln.getPrimaries(w.colorSpace),dt=w.colorSpace===Ya||Pe===nt?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,dt)}t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment);let Ae=g(w.image,!1,r.maxTextureSize);Ae=mn(w,Ae);let Ne=a.convert(w.format,w.colorSpace),je=a.convert(w.type),Ve=_(w.internalFormat,Ne,je,w.normalized,w.colorSpace,w.isVideoTexture);pe(ye,w);let qe,ot=w.mipmaps,pt=w.isVideoTexture!==!0,He=Ye.__version===void 0||we===!0,ie=ze.dataReady,Oe=S(w,Ae);if(w.isDepthTexture)Ve=p(w.format===ys,w.type),He&&(pt?t.texStorage2D(n.TEXTURE_2D,1,Ve,Ae.width,Ae.height):t.texImage2D(n.TEXTURE_2D,0,Ve,Ae.width,Ae.height,0,Ne,je,null));else if(w.isDataTexture)if(ot.length>0){pt&&He&&t.texStorage2D(n.TEXTURE_2D,Oe,Ve,ot[0].width,ot[0].height);for(let Pe=0,nt=ot.length;Pe<nt;Pe++)qe=ot[Pe],pt?ie&&t.texSubImage2D(n.TEXTURE_2D,Pe,0,0,qe.width,qe.height,Ne,je,qe.data):t.texImage2D(n.TEXTURE_2D,Pe,Ve,qe.width,qe.height,0,Ne,je,qe.data);w.generateMipmaps=!1}else pt?(He&&t.texStorage2D(n.TEXTURE_2D,Oe,Ve,Ae.width,Ae.height),ie&&de(w,Ae,Ne,je)):t.texImage2D(n.TEXTURE_2D,0,Ve,Ae.width,Ae.height,0,Ne,je,Ae.data);else if(w.isCompressedTexture)if(w.isCompressedArrayTexture){pt&&He&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Oe,Ve,ot[0].width,ot[0].height,Ae.depth);for(let Pe=0,nt=ot.length;Pe<nt;Pe++)if(qe=ot[Pe],w.format!==qr)if(Ne!==null)if(pt){if(ie)if(w.layerUpdates.size>0){let dt=Th(qe.width,qe.height,w.format,w.type);for(let Be of w.layerUpdates){let Rt=qe.data.subarray(Be*dt/qe.data.BYTES_PER_ELEMENT,(Be+1)*dt/qe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Pe,0,0,Be,qe.width,qe.height,1,Ne,Rt)}}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Pe,0,0,0,qe.width,qe.height,Ae.depth,Ne,qe.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Pe,Ve,qe.width,qe.height,Ae.depth,0,qe.data,0,0);else rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else pt?ie&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Pe,0,0,0,qe.width,qe.height,Ae.depth,Ne,je,qe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Pe,Ve,qe.width,qe.height,Ae.depth,0,Ne,je,qe.data);w.layerUpdates.size>0&&w.clearLayerUpdates()}else{pt&&He&&t.texStorage2D(n.TEXTURE_2D,Oe,Ve,ot[0].width,ot[0].height);for(let Pe=0,nt=ot.length;Pe<nt;Pe++)qe=ot[Pe],w.format!==qr?Ne!==null?pt?ie&&t.compressedTexSubImage2D(n.TEXTURE_2D,Pe,0,0,qe.width,qe.height,Ne,qe.data):t.compressedTexImage2D(n.TEXTURE_2D,Pe,Ve,qe.width,qe.height,0,qe.data):rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pt?ie&&t.texSubImage2D(n.TEXTURE_2D,Pe,0,0,qe.width,qe.height,Ne,je,qe.data):t.texImage2D(n.TEXTURE_2D,Pe,Ve,qe.width,qe.height,0,Ne,je,qe.data)}else if(w.isDataArrayTexture)if(pt){if(He&&t.texStorage3D(n.TEXTURE_2D_ARRAY,Oe,Ve,Ae.width,Ae.height,Ae.depth),ie)if(w.layerUpdates.size>0){let Pe=Th(Ae.width,Ae.height,w.format,w.type);for(let nt of w.layerUpdates){let dt=Ae.data.subarray(nt*Pe/Ae.data.BYTES_PER_ELEMENT,(nt+1)*Pe/Ae.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,nt,Ae.width,Ae.height,1,Ne,je,dt)}w.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Ae.width,Ae.height,Ae.depth,Ne,je,Ae.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ve,Ae.width,Ae.height,Ae.depth,0,Ne,je,Ae.data);else if(w.isData3DTexture)pt?(He&&t.texStorage3D(n.TEXTURE_3D,Oe,Ve,Ae.width,Ae.height,Ae.depth),ie&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Ae.width,Ae.height,Ae.depth,Ne,je,Ae.data)):t.texImage3D(n.TEXTURE_3D,0,Ve,Ae.width,Ae.height,Ae.depth,0,Ne,je,Ae.data);else if(w.isFramebufferTexture){if(He)if(pt)t.texStorage2D(n.TEXTURE_2D,Oe,Ve,Ae.width,Ae.height);else{let Pe=Ae.width,nt=Ae.height;for(let dt=0;dt<Oe;dt++)t.texImage2D(n.TEXTURE_2D,dt,Ve,Pe,nt,0,Ne,je,null),Pe>>=1,nt>>=1}}else if(w.isHTMLTexture){if("texElementImage2D"in n){let Pe=n.canvas;if(Pe.hasAttribute("layoutsubtree")||Pe.setAttribute("layoutsubtree","true"),Ae.parentNode!==Pe){Pe.appendChild(Ae),f.add(w),Pe.onpaint=nt=>{let dt=nt.changedElements;for(let Be of f)dt.includes(Be.image)&&(Be.needsUpdate=!0)},Pe.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Ae);else{let dt=n.RGBA,Be=n.RGBA,Rt=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,dt,Be,Rt,Ae)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ot.length>0){if(pt&&He){let Pe=nn(ot[0]);t.texStorage2D(n.TEXTURE_2D,Oe,Ve,Pe.width,Pe.height)}for(let Pe=0,nt=ot.length;Pe<nt;Pe++)qe=ot[Pe],pt?ie&&t.texSubImage2D(n.TEXTURE_2D,Pe,0,0,Ne,je,qe):t.texImage2D(n.TEXTURE_2D,Pe,Ve,Ne,je,qe);w.generateMipmaps=!1}else if(pt){if(He){let Pe=nn(Ae);t.texStorage2D(n.TEXTURE_2D,Oe,Ve,Pe.width,Pe.height)}ie&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,Ne,je,Ae)}else t.texImage2D(n.TEXTURE_2D,0,Ve,Ne,je,Ae);m(w)&&L(ye),Ye.__version=ze.version,w.onUpdate&&w.onUpdate(w)}W.__version=w.version}function Ge(W,w,ue){if(w.image.length!==6)return;let ye=Fe(W,w),we=w.source;t.bindTexture(n.TEXTURE_CUBE_MAP,W.__webglTexture,n.TEXTURE0+ue);let ze=i.get(we);if(we.version!==ze.__version||ye===!0){t.activeTexture(n.TEXTURE0+ue);let Ye=Ln.getPrimaries(Ln.workingColorSpace),Re=w.colorSpace===Ya?null:Ln.getPrimaries(w.colorSpace),Ae=w.colorSpace===Ya||Ye===Re?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,w.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,w.premultiplyAlpha),t.pixelStorei(n.UNPACK_ALIGNMENT,w.unpackAlignment),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae);let Ne=w.isCompressedTexture||w.image[0].isCompressedTexture,je=w.image[0]&&w.image[0].isDataTexture,Ve=[];for(let Be=0;Be<6;Be++)!Ne&&!je?Ve[Be]=g(w.image[Be],!0,r.maxCubemapSize):Ve[Be]=je?w.image[Be].image:w.image[Be],Ve[Be]=mn(w,Ve[Be]);let qe=Ve[0],ot=a.convert(w.format,w.colorSpace),pt=a.convert(w.type),He=_(w.internalFormat,ot,pt,w.normalized,w.colorSpace),ie=w.isVideoTexture!==!0,Oe=ze.__version===void 0||ye===!0,Pe=we.dataReady,nt=S(w,qe);pe(n.TEXTURE_CUBE_MAP,w);let dt;if(Ne){ie&&Oe&&t.texStorage2D(n.TEXTURE_CUBE_MAP,nt,He,qe.width,qe.height);for(let Be=0;Be<6;Be++){dt=Ve[Be].mipmaps;for(let Rt=0;Rt<dt.length;Rt++){let vt=dt[Rt];w.format!==qr?ot!==null?ie?Pe&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt,0,0,vt.width,vt.height,ot,vt.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt,He,vt.width,vt.height,0,vt.data):rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt,0,0,vt.width,vt.height,ot,pt,vt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt,He,vt.width,vt.height,0,ot,pt,vt.data)}}}else{if(dt=w.mipmaps,ie&&Oe){dt.length>0&&nt++;let Be=nn(Ve[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,nt,He,Be.width,Be.height)}for(let Be=0;Be<6;Be++)if(je){ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0,0,0,Ve[Be].width,Ve[Be].height,ot,pt,Ve[Be].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0,He,Ve[Be].width,Ve[Be].height,0,ot,pt,Ve[Be].data);for(let Rt=0;Rt<dt.length;Rt++){let cn=dt[Rt].image[Be].image;ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt+1,0,0,cn.width,cn.height,ot,pt,cn.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt+1,He,cn.width,cn.height,0,ot,pt,cn.data)}}else{ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0,0,0,ot,pt,Ve[Be]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0,He,ot,pt,Ve[Be]);for(let Rt=0;Rt<dt.length;Rt++){let vt=dt[Rt];ie?Pe&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt+1,0,0,ot,pt,vt.image[Be]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Be,Rt+1,He,ot,pt,vt.image[Be])}}}m(w)&&L(n.TEXTURE_CUBE_MAP),ze.__version=we.version,w.onUpdate&&w.onUpdate(w)}W.__version=w.version}function $e(W,w,ue,ye,we,ze){let Ye=a.convert(ue.format,ue.colorSpace),Re=a.convert(ue.type),Ae=_(ue.internalFormat,Ye,Re,ue.normalized,ue.colorSpace),Ne=i.get(w),je=i.get(ue);if(je.__renderTarget=w,!Ne.__hasExternalTextures){let Ve=Math.max(1,w.width>>ze),qe=Math.max(1,w.height>>ze);we===n.TEXTURE_3D||we===n.TEXTURE_2D_ARRAY?t.texImage3D(we,ze,Ae,Ve,qe,w.depth,0,Ye,Re,null):t.texImage2D(we,ze,Ae,Ve,qe,0,Ye,Re,null)}t.bindFramebuffer(n.FRAMEBUFFER,W),an(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ye,we,je.__webglTexture,0,rt(w)):(we===n.TEXTURE_2D||we>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ye,we,je.__webglTexture,ze),t.bindFramebuffer(n.FRAMEBUFFER,null)}function ut(W,w,ue){if(n.bindRenderbuffer(n.RENDERBUFFER,W),w.depthBuffer){let ye=w.depthTexture,we=ye&&ye.isDepthTexture?ye.type:null,ze=p(w.stencilBuffer,we),Ye=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;an(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,rt(w),ze,w.width,w.height):ue?n.renderbufferStorageMultisample(n.RENDERBUFFER,rt(w),ze,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,ze,w.width,w.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ye,n.RENDERBUFFER,W)}else{let ye=w.textures;for(let we=0;we<ye.length;we++){let ze=ye[we],Ye=a.convert(ze.format,ze.colorSpace),Re=a.convert(ze.type),Ae=_(ze.internalFormat,Ye,Re,ze.normalized,ze.colorSpace);an(w)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,rt(w),Ae,w.width,w.height):ue?n.renderbufferStorageMultisample(n.RENDERBUFFER,rt(w),Ae,w.width,w.height):n.renderbufferStorage(n.RENDERBUFFER,Ae,w.width,w.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function zt(W,w,ue){let ye=w.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,W),!(w.depthTexture&&w.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let we=i.get(w.depthTexture);if(we.__renderTarget=w,(!we.__webglTexture||w.depthTexture.image.width!==w.width||w.depthTexture.image.height!==w.height)&&(w.depthTexture.image.width=w.width,w.depthTexture.image.height=w.height,w.depthTexture.needsUpdate=!0),ye){if(we.__webglInit===void 0&&(we.__webglInit=!0,w.depthTexture.addEventListener("dispose",B)),we.__webglTexture===void 0){we.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,we.__webglTexture),pe(n.TEXTURE_CUBE_MAP,w.depthTexture);let Ne=a.convert(w.depthTexture.format),je=a.convert(w.depthTexture.type),Ve;w.depthTexture.format===Ma?Ve=n.DEPTH_COMPONENT24:w.depthTexture.format===ys&&(Ve=n.DEPTH24_STENCIL8);for(let qe=0;qe<6;qe++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+qe,0,Ve,w.width,w.height,0,Ne,je,null)}}else j(w.depthTexture,0);let ze=we.__webglTexture,Ye=rt(w),Re=ye?n.TEXTURE_CUBE_MAP_POSITIVE_X+ue:n.TEXTURE_2D,Ae=w.depthTexture.format===ys?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(w.depthTexture.format===Ma)an(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ae,Re,ze,0,Ye):n.framebufferTexture2D(n.FRAMEBUFFER,Ae,Re,ze,0);else if(w.depthTexture.format===ys)an(w)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Ae,Re,ze,0,Ye):n.framebufferTexture2D(n.FRAMEBUFFER,Ae,Re,ze,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ct(W){let w=i.get(W),ue=W.isWebGLCubeRenderTarget===!0;if(w.__boundDepthTexture!==W.depthTexture){let ye=W.depthTexture;if(w.__depthDisposeCallback&&w.__depthDisposeCallback(),ye){let we=()=>{delete w.__boundDepthTexture,delete w.__depthDisposeCallback,ye.removeEventListener("dispose",we)};ye.addEventListener("dispose",we),w.__depthDisposeCallback=we}w.__boundDepthTexture=ye}if(W.depthTexture&&!w.__autoAllocateDepthBuffer)if(ue)for(let ye=0;ye<6;ye++)zt(w.__webglFramebuffer[ye],W,ye);else{let ye=W.texture.mipmaps;ye&&ye.length>0?zt(w.__webglFramebuffer[0],W,0):zt(w.__webglFramebuffer,W,0)}else if(ue){w.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)if(t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[ye]),w.__webglDepthbuffer[ye]===void 0)w.__webglDepthbuffer[ye]=n.createRenderbuffer(),ut(w.__webglDepthbuffer[ye],W,!1);else{let we=W.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ze=w.__webglDepthbuffer[ye];n.bindRenderbuffer(n.RENDERBUFFER,ze),n.framebufferRenderbuffer(n.FRAMEBUFFER,we,n.RENDERBUFFER,ze)}}else{let ye=W.texture.mipmaps;if(ye&&ye.length>0?t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,w.__webglFramebuffer),w.__webglDepthbuffer===void 0)w.__webglDepthbuffer=n.createRenderbuffer(),ut(w.__webglDepthbuffer,W,!1);else{let we=W.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ze=w.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,ze),n.framebufferRenderbuffer(n.FRAMEBUFFER,we,n.RENDERBUFFER,ze)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Tt(W,w,ue){let ye=i.get(W);w!==void 0&&$e(ye.__webglFramebuffer,W,W.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ue!==void 0&&ct(W)}function Zt(W){let w=W.texture,ue=i.get(W),ye=i.get(w);W.addEventListener("dispose",b);let we=W.textures,ze=W.isWebGLCubeRenderTarget===!0,Ye=we.length>1;if(Ye||(ye.__webglTexture===void 0&&(ye.__webglTexture=n.createTexture()),ye.__version=w.version,s.memory.textures++),ze){ue.__webglFramebuffer=[];for(let Re=0;Re<6;Re++)if(w.mipmaps&&w.mipmaps.length>0){ue.__webglFramebuffer[Re]=[];for(let Ae=0;Ae<w.mipmaps.length;Ae++)ue.__webglFramebuffer[Re][Ae]=n.createFramebuffer()}else ue.__webglFramebuffer[Re]=n.createFramebuffer()}else{if(w.mipmaps&&w.mipmaps.length>0){ue.__webglFramebuffer=[];for(let Re=0;Re<w.mipmaps.length;Re++)ue.__webglFramebuffer[Re]=n.createFramebuffer()}else ue.__webglFramebuffer=n.createFramebuffer();if(Ye)for(let Re=0,Ae=we.length;Re<Ae;Re++){let Ne=i.get(we[Re]);Ne.__webglTexture===void 0&&(Ne.__webglTexture=n.createTexture(),s.memory.textures++)}if(W.samples>0&&an(W)===!1){ue.__webglMultisampledFramebuffer=n.createFramebuffer(),ue.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ue.__webglMultisampledFramebuffer);for(let Re=0;Re<we.length;Re++){let Ae=we[Re];ue.__webglColorRenderbuffer[Re]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,ue.__webglColorRenderbuffer[Re]);let Ne=a.convert(Ae.format,Ae.colorSpace),je=a.convert(Ae.type),Ve=_(Ae.internalFormat,Ne,je,Ae.normalized,Ae.colorSpace,W.isXRRenderTarget===!0),qe=rt(W);n.renderbufferStorageMultisample(n.RENDERBUFFER,qe,Ve,W.width,W.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Re,n.RENDERBUFFER,ue.__webglColorRenderbuffer[Re])}n.bindRenderbuffer(n.RENDERBUFFER,null),W.depthBuffer&&(ue.__webglDepthRenderbuffer=n.createRenderbuffer(),ut(ue.__webglDepthRenderbuffer,W,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(ze){t.bindTexture(n.TEXTURE_CUBE_MAP,ye.__webglTexture),pe(n.TEXTURE_CUBE_MAP,w);for(let Re=0;Re<6;Re++)if(w.mipmaps&&w.mipmaps.length>0)for(let Ae=0;Ae<w.mipmaps.length;Ae++)$e(ue.__webglFramebuffer[Re][Ae],W,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,Ae);else $e(ue.__webglFramebuffer[Re],W,w,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0);m(w)&&L(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Ye){for(let Re=0,Ae=we.length;Re<Ae;Re++){let Ne=we[Re],je=i.get(Ne),Ve=n.TEXTURE_2D;(W.isWebGL3DRenderTarget||W.isWebGLArrayRenderTarget)&&(Ve=W.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ve,je.__webglTexture),pe(Ve,Ne),$e(ue.__webglFramebuffer,W,Ne,n.COLOR_ATTACHMENT0+Re,Ve,0),m(Ne)&&L(Ve)}t.unbindTexture()}else{let Re=n.TEXTURE_2D;if((W.isWebGL3DRenderTarget||W.isWebGLArrayRenderTarget)&&(Re=W.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Re,ye.__webglTexture),pe(Re,w),w.mipmaps&&w.mipmaps.length>0)for(let Ae=0;Ae<w.mipmaps.length;Ae++)$e(ue.__webglFramebuffer[Ae],W,w,n.COLOR_ATTACHMENT0,Re,Ae);else $e(ue.__webglFramebuffer,W,w,n.COLOR_ATTACHMENT0,Re,0);m(w)&&L(Re),t.unbindTexture()}W.depthBuffer&&ct(W)}function wt(W){let w=W.textures;for(let ue=0,ye=w.length;ue<ye;ue++){let we=w[ue];if(m(we)){let ze=F(W),Ye=i.get(we).__webglTexture;t.bindTexture(ze,Ye),L(ze),t.unbindTexture()}}}let bt=[],_t=[];function ln(W){if(W.samples>0){if(an(W)===!1){let w=W.textures,ue=W.width,ye=W.height,we=n.COLOR_BUFFER_BIT,ze=W.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ye=i.get(W),Re=w.length>1;if(Re)for(let Ne=0;Ne<w.length;Ne++)t.bindFramebuffer(n.FRAMEBUFFER,Ye.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ne,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ye.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ne,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ye.__webglMultisampledFramebuffer);let Ae=W.texture.mipmaps;Ae&&Ae.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ye.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ye.__webglFramebuffer);for(let Ne=0;Ne<w.length;Ne++){if(W.resolveDepthBuffer&&(W.depthBuffer&&(we|=n.DEPTH_BUFFER_BIT),W.stencilBuffer&&W.resolveStencilBuffer&&(we|=n.STENCIL_BUFFER_BIT)),Re){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ye.__webglColorRenderbuffer[Ne]);let je=i.get(w[Ne]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,je,0)}n.blitFramebuffer(0,0,ue,ye,0,0,ue,ye,we,n.NEAREST),u===!0&&(bt.length=0,_t.length=0,bt.push(n.COLOR_ATTACHMENT0+Ne),W.depthBuffer&&W.storeMultisampledDepthBuffer===!1&&(bt.push(ze),_t.push(ze),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,_t)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,bt))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Re)for(let Ne=0;Ne<w.length;Ne++){t.bindFramebuffer(n.FRAMEBUFFER,Ye.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ne,n.RENDERBUFFER,Ye.__webglColorRenderbuffer[Ne]);let je=i.get(w[Ne]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ye.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ne,n.TEXTURE_2D,je,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ye.__webglMultisampledFramebuffer)}else if(W.depthBuffer&&W.storeMultisampledDepthBuffer===!1&&u){let w=W.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[w])}}}function rt(W){return Math.min(r.maxSamples,W.samples)}function an(W){let w=i.get(W);return W.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&w.__useRenderToTexture!==!1}function se(W){let w=s.render.frame;d.get(W)!==w&&(d.set(W,w),W.update())}function mn(W,w){let ue=W.colorSpace,ye=W.format,we=W.type;return W.isCompressedTexture===!0||W.isVideoTexture===!0||ue!==fl&&ue!==Ya&&(Ln.getTransfer(ue)===Jn?(ye!==qr||we!==Cr)&&rn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):sn("WebGLTextures: Unsupported texture color space:",ue)),w}function nn(W){return typeof HTMLImageElement<"u"&&W instanceof HTMLImageElement?(l.width=W.naturalWidth||W.width,l.height=W.naturalHeight||W.height):typeof VideoFrame<"u"&&W instanceof VideoFrame?(l.width=W.displayWidth,l.height=W.displayHeight):(l.width=W.width,l.height=W.height),l}this.allocateTextureUnit=H,this.resetTextureUnits=E,this.getTextureUnits=M,this.setTextureUnits=O,this.setTexture2D=j,this.setTexture2DArray=K,this.setTexture3D=re,this.setTextureCube=J,this.rebindTextures=Tt,this.setupRenderTarget=Zt,this.updateRenderTargetMipmap=wt,this.updateMultisampleRenderTarget=ln,this.setupDepthRenderbuffer=ct,this.setupFrameBufferTexture=$e,this.useMultisampledRTT=an,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function gb(n,e){function t(i,r=Ya){let a,s=Ln.getTransfer(r);if(i===Cr)return n.UNSIGNED_BYTE;if(i===ku)return n.UNSIGNED_SHORT_4_4_4_4;if(i===zu)return n.UNSIGNED_SHORT_5_5_5_1;if(i===mh)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===vh)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===hh)return n.BYTE;if(i===ph)return n.SHORT;if(i===Io)return n.UNSIGNED_SHORT;if(i===Bu)return n.INT;if(i===sa)return n.UNSIGNED_INT;if(i===Yr)return n.FLOAT;if(i===oa)return n.HALF_FLOAT;if(i===gh)return n.ALPHA;if(i===yh)return n.RGB;if(i===qr)return n.RGBA;if(i===Ma)return n.DEPTH_COMPONENT;if(i===ys)return n.DEPTH_STENCIL;if(i===Vu)return n.RED;if(i===Gu)return n.RED_INTEGER;if(i===xs)return n.RG;if(i===Hu)return n.RG_INTEGER;if(i===Wu)return n.RGBA_INTEGER;if(i===Gl||i===Hl||i===Wl||i===Xl)if(s===Jn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===Gl)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Hl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Wl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Xl)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===Gl)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Hl)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Wl)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Xl)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Xu||i===Yu||i===qu||i===Zu)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===Xu)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Yu)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===qu)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Zu)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Ju||i===$u||i===Ku||i===Qu||i===ju||i===Yl||i===ed)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===Ju||i===$u)return s===Jn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===Ku)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(i===Qu)return a.COMPRESSED_R11_EAC;if(i===ju)return a.COMPRESSED_SIGNED_R11_EAC;if(i===Yl)return a.COMPRESSED_RG11_EAC;if(i===ed)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===td||i===nd||i===id||i===rd||i===ad||i===sd||i===od||i===ld||i===cd||i===ud||i===dd||i===fd||i===hd||i===pd)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===td)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===nd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===id)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===rd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ad)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===sd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===od)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ld)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===cd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ud)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===dd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===fd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===hd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===pd)return s===Jn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===md||i===vd||i===gd)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===md)return s===Jn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===vd)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===gd)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===yd||i===xd||i===ql||i===_d)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===yd)return a.COMPRESSED_RED_RGTC1_EXT;if(i===xd)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ql)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===_d)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Co?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}var yb=`
4196
+ }`,Lw=[new Se(1,0,0),new Se(-1,0,0),new Se(0,1,0),new Se(0,-1,0),new Se(0,0,1),new Se(0,0,-1)],Dw=[new Se(0,-1,0),new Se(0,-1,0),new Se(0,0,1),new Se(0,0,-1),new Se(0,-1,0),new Se(0,-1,0)],ig=new Jn,Yc=new Se,Op=new Se;function Nw(n,e,t){let i=new cl,r=new ln,a=new ln,s=new Fi,o=new hd,u=new pd,l={},d=t.maxTextureSize,f={[es]:ea,[ea]:es,[Gr]:Gr},h=new pa({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ln},radius:{value:4}},vertexShader:Rw,fragmentShader:Pw}),m=h.clone();m.defines.HORIZONTAL_PASS=1;let x=new pr;x.setAttribute("position",new Vr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new bi(x,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Nc;let v=this.type;this.render=function(p,L,E){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||p.length===0)return;this.type===Cd&&(Rn("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Nc);let D=n.getRenderTarget(),X=n.getActiveCubeFace(),Y=n.getActiveMipmapLevel(),W=n.state;W.setBlending(ts),W.buffers.depth.getReversed()===!0?W.buffers.color.setClear(0,0,0,0):W.buffers.color.setClear(1,1,1,1),W.buffers.depth.setTest(!0),W.setScissorTest(!1);let C=v!==this.type;C&&L.traverse(function(M){M.material&&(Array.isArray(M.material)?M.material.forEach(J=>J.needsUpdate=!0):M.material.needsUpdate=!0)});for(let M=0,J=p.length;M<J;M++){let q=p[M],ce=q.shadow;if(ce===void 0){Rn("WebGLShadowMap:",q,"has no shadow.");continue}if(ce.autoUpdate===!1&&ce.needsUpdate===!1)continue;r.copy(ce.mapSize);let k=ce.getFrameExtents();r.multiply(k),a.copy(ce.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(a.x=Math.floor(d/k.x),r.x=a.x*k.x,ce.mapSize.x=a.x),r.y>d&&(a.y=Math.floor(d/k.y),r.y=a.y*k.y,ce.mapSize.y=a.y));let G=n.state.buffers.depth.getReversed();if(ce.camera._reversedDepth=G,ce.map===null||C===!0){if(ce.map!==null&&(ce.map.depthTexture!==null&&(ce.map.depthTexture.dispose(),ce.map.depthTexture=null),ce.map.dispose()),this.type===gl){if(q.isPointLight){Rn("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}ce.map=new sa(r.x,r.y,{format:Js,type:Va,minFilter:fr,magFilter:fr,generateMipmaps:!1}),ce.map.texture.name=q.name+".shadowMap",ce.map.depthTexture=new Hs(r.x,r.y,va),ce.map.depthTexture.name=q.name+".shadowMapDepth",ce.map.depthTexture.format=Ka,ce.map.depthTexture.compareFunction=null,ce.map.depthTexture.minFilter=ar,ce.map.depthTexture.magFilter=ar}else q.isPointLight?(ce.map=new Mf(r.x),ce.map.depthTexture=new ad(r.x,za)):(ce.map=new sa(r.x,r.y),ce.map.depthTexture=new Hs(r.x,r.y,za)),ce.map.depthTexture.name=q.name+".shadowMap",ce.map.depthTexture.format=Ka,this.type===Nc?(ce.map.depthTexture.compareFunction=G?yf:gf,ce.map.depthTexture.minFilter=fr,ce.map.depthTexture.magFilter=fr):(ce.map.depthTexture.compareFunction=null,ce.map.depthTexture.minFilter=ar,ce.map.depthTexture.magFilter=ar);ce.camera.updateProjectionMatrix()}ce.map.isWebGLCubeRenderTarget!==!0&&(ce.map.width!==r.x||ce.map.height!==r.y)&&ce.map.setSize(r.x,r.y);let te=ce.map.isWebGLCubeRenderTarget?6:ce.getViewportCount();q.isPointLight!==!0&&ce.updateMatrices(q,E);for(let le=0;le<te;le++){let ge=ce.getCamera(le);if(q.isPointLight){let oe=ce.camera,$=ce.matrix,Te=q.distance||oe.far;Te!==oe.far&&(oe.far=Te,oe.updateProjectionMatrix()),Yc.setFromMatrixPosition(q.matrixWorld),oe.position.copy(Yc),Op.copy(oe.position),Op.add(Lw[le]),oe.up.copy(Dw[le]),oe.lookAt(Op),oe.updateMatrixWorld(),$.makeTranslation(-Yc.x,-Yc.y,-Yc.z),ig.multiplyMatrices(oe.projectionMatrix,oe.matrixWorldInverse),ce._frustum.setFromProjectionMatrix(ig,oe.coordinateSystem,oe.reversedDepth)}if(ce.map.isWebGLCubeRenderTarget)n.setRenderTarget(ce.map,le),n.clear();else{le===0&&(n.setRenderTarget(ce.map),n.clear());let oe=ce.getViewport(le);s.set(a.x*oe.x,a.y*oe.y,a.x*oe.z,a.y*oe.w),W.viewport(s)}i=ce.getFrustum(le),S(L,E,ge,q,this.type)}ce.isPointLightShadow!==!0&&this.type===gl&&F(ce,E),ce.needsUpdate=!1}v=this.type,g.needsUpdate=!1,n.setRenderTarget(D,X,Y)};function F(p,L){let E=e.update(_);h.defines.VSM_SAMPLES!==p.blurSamples&&(h.defines.VSM_SAMPLES=p.blurSamples,m.defines.VSM_SAMPLES=p.blurSamples,h.needsUpdate=!0,m.needsUpdate=!0),p.mapPass===null?p.mapPass=new sa(r.x,r.y,{format:Js,type:Va}):(p.mapPass.width!==p.map.width||p.mapPass.height!==p.map.height)&&p.mapPass.setSize(p.map.width,p.map.height),h.uniforms.shadow_pass.value=p.map.depthTexture,h.uniforms.resolution.value.set(p.map.width,p.map.height),h.uniforms.radius.value=p.radius,n.setRenderTarget(p.mapPass),n.clear(),n.renderBufferDirect(L,null,E,h,_,null),m.uniforms.shadow_pass.value=p.mapPass.texture,m.uniforms.resolution.value.set(p.map.width,p.map.height),m.uniforms.radius.value=p.radius,n.setRenderTarget(p.map),n.clear(),n.renderBufferDirect(L,null,E,m,_,null)}function P(p,L,E,D){let X=null,Y=E.isPointLight===!0?p.customDistanceMaterial:p.customDepthMaterial;if(Y!==void 0)X=Y;else if(X=E.isPointLight===!0?u:o,n.localClippingEnabled&&L.clipShadows===!0&&Array.isArray(L.clippingPlanes)&&L.clippingPlanes.length!==0||L.displacementMap&&L.displacementScale!==0||L.alphaMap&&L.alphaTest>0||L.map&&L.alphaTest>0||L.alphaToCoverage===!0){let W=X.uuid,C=L.uuid,M=l[W];M===void 0&&(M={},l[W]=M);let J=M[C];J===void 0&&(J=X.clone(),M[C]=J,L.addEventListener("dispose",N)),X=J}if(X.visible=L.visible,X.wireframe=L.wireframe,D===gl?X.side=L.shadowSide!==null?L.shadowSide:L.side:X.side=L.shadowSide!==null?L.shadowSide:f[L.side],X.alphaMap=L.alphaMap,X.alphaTest=L.alphaToCoverage===!0?.5:L.alphaTest,X.map=L.map,X.clipShadows=L.clipShadows,X.clippingPlanes=L.clippingPlanes,X.clipIntersection=L.clipIntersection,X.displacementMap=L.displacementMap,X.displacementScale=L.displacementScale,X.displacementBias=L.displacementBias,X.wireframeLinewidth=L.wireframeLinewidth,X.linewidth=L.linewidth,E.isPointLight===!0&&X.isMeshDistanceMaterial===!0){let W=n.properties.get(X);W.light=E}return X}function S(p,L,E,D,X){if(p.visible===!1)return;if(p.layers.test(L.layers)&&(p.isMesh||p.isLine||p.isPoints)&&(p.castShadow||p.receiveShadow&&X===gl)&&(!p.frustumCulled||p.intersectsFrustum(i))){p.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,p.matrixWorld);let C=e.update(p),M=p.material;if(Array.isArray(M)){let J=C.groups;for(let q=0,ce=J.length;q<ce;q++){let k=J[q],G=M[k.materialIndex];if(G&&G.visible){let te=P(p,G,D,X);p.onBeforeShadow(n,p,L,E,C,te,k),n.renderBufferDirect(E,null,C,te,p,k),p.onAfterShadow(n,p,L,E,C,te,k)}}}else if(M.visible){let J=P(p,M,D,X);p.onBeforeShadow(n,p,L,E,C,J,null),n.renderBufferDirect(E,null,C,J,p,null),p.onAfterShadow(n,p,L,E,C,J,null)}}let W=p.children;for(let C=0,M=W.length;C<M;C++)S(W[C],L,E,D,X)}function N(p){p.target.removeEventListener("dispose",N);for(let E in l){let D=l[E],X=p.target.uuid;X in D&&(D[X].dispose(),delete D[X])}}}function Uw(n,e){function t(){let he=!1,dt=new Fi,Ee=null,gt=new Fi(0,0,0,0);return{setMask:function(Ke){Ee!==Ke&&!he&&(n.colorMask(Ke,Ke,Ke,Ke),Ee=Ke)},setLocked:function(Ke){he=Ke},setClear:function(Ke,We,Wt,Lt,yt){yt===!0&&(Ke*=Lt,We*=Lt,Wt*=Lt),dt.set(Ke,We,Wt,Lt),gt.equals(dt)===!1&&(n.clearColor(Ke,We,Wt,Lt),gt.copy(dt))},reset:function(){he=!1,Ee=null,gt.set(-1,0,0,0)}}}function i(){let he=!1,dt=!1,Ee=null,gt=null,Ke=null;return{setReversed:function(We){if(dt!==We){let Wt=e.get("EXT_clip_control");We?Wt.clipControlEXT(Wt.LOWER_LEFT_EXT,Wt.ZERO_TO_ONE_EXT):Wt.clipControlEXT(Wt.LOWER_LEFT_EXT,Wt.NEGATIVE_ONE_TO_ONE_EXT),dt=We;let Lt=Ke;Ke=null,this.setClear(Lt)}},getReversed:function(){return dt},setTest:function(We){We?re(n.DEPTH_TEST):Ie(n.DEPTH_TEST)},setMask:function(We){Ee!==We&&!he&&(n.depthMask(We),Ee=We)},setFunc:function(We){if(dt&&(We=I0[We]),gt!==We){switch(We){case qu:n.depthFunc(n.NEVER);break;case Zu:n.depthFunc(n.ALWAYS);break;case Ju:n.depthFunc(n.LESS);break;case jo:n.depthFunc(n.LEQUAL);break;case $u:n.depthFunc(n.EQUAL);break;case Ku:n.depthFunc(n.GEQUAL);break;case Qu:n.depthFunc(n.GREATER);break;case ju:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}gt=We}},setLocked:function(We){he=We},setClear:function(We){Ke!==We&&(Ke=We,dt&&(We=1-We),n.clearDepth(We))},reset:function(){he=!1,Ee=null,gt=null,Ke=null,dt=!1}}}function r(){let he=!1,dt=null,Ee=null,gt=null,Ke=null,We=null,Wt=null,Lt=null,yt=null;return{setTest:function(Et){he||(Et?re(n.STENCIL_TEST):Ie(n.STENCIL_TEST))},setMask:function(Et){dt!==Et&&!he&&(n.stencilMask(Et),dt=Et)},setFunc:function(Et,rt,Ut){(Ee!==Et||gt!==rt||Ke!==Ut)&&(n.stencilFunc(Et,rt,Ut),Ee=Et,gt=rt,Ke=Ut)},setOp:function(Et,rt,Ut){(We!==Et||Wt!==rt||Lt!==Ut)&&(n.stencilOp(Et,rt,Ut),We=Et,Wt=rt,Lt=Ut)},setLocked:function(Et){he=Et},setClear:function(Et){yt!==Et&&(n.clearStencil(Et),yt=Et)},reset:function(){he=!1,dt=null,Ee=null,gt=null,Ke=null,We=null,Wt=null,Lt=null,yt=null}}}let a=new t,s=new i,o=new r,u=new WeakMap,l=new WeakMap,d={},f={},h={},m=new WeakMap,x=[],_=null,g=!1,v=null,F=null,P=null,S=null,N=null,p=null,L=null,E=new Wn(0,0,0),D=0,X=!1,Y=null,W=null,C=null,M=null,J=null,q=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS),ce=!1,k=0,G=n.getParameter(n.VERSION);G.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(G)[1]),ce=k>=1):G.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),ce=k>=2);let te=null,le={},ge=n.getParameter(n.SCISSOR_BOX),oe=n.getParameter(n.VIEWPORT),$=new Fi().fromArray(ge),Te=new Fi().fromArray(oe);function Le(he,dt,Ee,gt){let Ke=new Uint8Array(4),We=n.createTexture();n.bindTexture(he,We),n.texParameteri(he,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(he,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Wt=0;Wt<Ee;Wt++)he===n.TEXTURE_3D||he===n.TEXTURE_2D_ARRAY?n.texImage3D(dt,0,n.RGBA,1,1,gt,0,n.RGBA,n.UNSIGNED_BYTE,Ke):n.texImage2D(dt+Wt,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,Ke);return We}let se={};se[n.TEXTURE_2D]=Le(n.TEXTURE_2D,n.TEXTURE_2D,1),se[n.TEXTURE_CUBE_MAP]=Le(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),se[n.TEXTURE_2D_ARRAY]=Le(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),se[n.TEXTURE_3D]=Le(n.TEXTURE_3D,n.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),re(n.DEPTH_TEST),s.setFunc(jo),at(!1),ot(np),re(n.CULL_FACE),qe(ts);function re(he){d[he]!==!0&&(n.enable(he),d[he]=!0)}function Ie(he){d[he]!==!1&&(n.disable(he),d[he]=!1)}function ke(he,dt){return h[he]!==dt?(n.bindFramebuffer(he,dt),h[he]=dt,he===n.DRAW_FRAMEBUFFER&&(h[n.FRAMEBUFFER]=dt),he===n.FRAMEBUFFER&&(h[n.DRAW_FRAMEBUFFER]=dt),!0):!1}function xe(he,dt){let Ee=x,gt=!1;if(he){Ee=m.get(dt),Ee===void 0&&(Ee=[],m.set(dt,Ee));let Ke=he.textures;if(Ee.length!==Ke.length||Ee[0]!==n.COLOR_ATTACHMENT0){for(let We=0,Wt=Ke.length;We<Wt;We++)Ee[We]=n.COLOR_ATTACHMENT0+We;Ee.length=Ke.length,gt=!0}}else Ee[0]!==n.BACK&&(Ee[0]=n.BACK,gt=!0);gt&&n.drawBuffers(Ee)}function Ye(he){return _!==he?(n.useProgram(he),_=he,!0):!1}let mt={[go]:n.FUNC_ADD,[Jv]:n.FUNC_SUBTRACT,[$v]:n.FUNC_REVERSE_SUBTRACT};mt[Kv]=n.MIN,mt[Qv]=n.MAX;let He={[jv]:n.ZERO,[e0]:n.ONE,[t0]:n.SRC_COLOR,[sp]:n.SRC_ALPHA,[o0]:n.SRC_ALPHA_SATURATE,[a0]:n.DST_COLOR,[i0]:n.DST_ALPHA,[n0]:n.ONE_MINUS_SRC_COLOR,[op]:n.ONE_MINUS_SRC_ALPHA,[s0]:n.ONE_MINUS_DST_COLOR,[r0]:n.ONE_MINUS_DST_ALPHA,[l0]:n.CONSTANT_COLOR,[c0]:n.ONE_MINUS_CONSTANT_COLOR,[u0]:n.CONSTANT_ALPHA,[d0]:n.ONE_MINUS_CONSTANT_ALPHA};function qe(he,dt,Ee,gt,Ke,We,Wt,Lt,yt,Et){if(he===ts){g===!0&&(Ie(n.BLEND),g=!1);return}if(g===!1&&(re(n.BLEND),g=!0),he!==Zv){if(he!==v||Et!==X){if((F!==go||N!==go)&&(n.blendEquation(n.FUNC_ADD),F=go,N=go),Et)switch(he){case yl:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ip:n.blendFunc(n.ONE,n.ONE);break;case rp:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case ap:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:On("WebGLState: Invalid blending: ",he);break}else switch(he){case yl:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case ip:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case rp:On("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ap:On("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:On("WebGLState: Invalid blending: ",he);break}P=null,S=null,p=null,L=null,E.set(0,0,0),D=0,v=he,X=Et}return}Ke=Ke||dt,We=We||Ee,Wt=Wt||gt,(dt!==F||Ke!==N)&&(n.blendEquationSeparate(mt[dt],mt[Ke]),F=dt,N=Ke),(Ee!==P||gt!==S||We!==p||Wt!==L)&&(n.blendFuncSeparate(He[Ee],He[gt],He[We],He[Wt]),P=Ee,S=gt,p=We,L=Wt),(Lt.equals(E)===!1||yt!==D)&&(n.blendColor(Lt.r,Lt.g,Lt.b,yt),E.copy(Lt),D=yt),v=he,X=!1}function pt(he,dt){he.side===Gr?Ie(n.CULL_FACE):re(n.CULL_FACE);let Ee=he.side===ea;dt&&(Ee=!Ee),at(Ee),he.blending===yl&&he.transparent===!1?qe(ts):qe(he.blending,he.blendEquation,he.blendSrc,he.blendDst,he.blendEquationAlpha,he.blendSrcAlpha,he.blendDstAlpha,he.blendColor,he.blendAlpha,he.premultipliedAlpha),s.setFunc(he.depthFunc),s.setTest(he.depthTest),s.setMask(he.depthWrite),a.setMask(he.colorWrite);let gt=he.stencilWrite;o.setTest(gt),gt&&(o.setMask(he.stencilWriteMask),o.setFunc(he.stencilFunc,he.stencilRef,he.stencilFuncMask),o.setOp(he.stencilFail,he.stencilZFail,he.stencilZPass)),cn(he.polygonOffset,he.polygonOffsetFactor,he.polygonOffsetUnits),he.alphaToCoverage===!0?re(n.SAMPLE_ALPHA_TO_COVERAGE):Ie(n.SAMPLE_ALPHA_TO_COVERAGE)}function at(he){Y!==he&&(he?n.frontFace(n.CW):n.frontFace(n.CCW),Y=he)}function ot(he){he!==Yv?(re(n.CULL_FACE),he!==W&&(he===np?n.cullFace(n.BACK):he===qv?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Ie(n.CULL_FACE),W=he}function Vt(he){he!==C&&(ce&&n.lineWidth(he),C=he)}function cn(he,dt,Ee){he?(re(n.POLYGON_OFFSET_FILL),(M!==dt||J!==Ee)&&(M=dt,J=Ee,s.getReversed()&&(dt=-dt),n.polygonOffset(dt,Ee))):Ie(n.POLYGON_OFFSET_FILL)}function Ze(he){he?re(n.SCISSOR_TEST):Ie(n.SCISSOR_TEST)}function pn(he){he===void 0&&(he=n.TEXTURE0+q-1),te!==he&&(n.activeTexture(he),te=he)}function ne(he,dt,Ee){Ee===void 0&&(te===null?Ee=n.TEXTURE0+q-1:Ee=te);let gt=le[Ee];gt===void 0&&(gt={type:void 0,texture:void 0},le[Ee]=gt),(gt.type!==he||gt.texture!==dt)&&(te!==Ee&&(n.activeTexture(Ee),te=Ee),n.bindTexture(he,dt||se[he]),gt.type=he,gt.texture=dt)}function Tn(){let he=le[te];he!==void 0&&he.type!==void 0&&(n.bindTexture(he.type,null),he.type=void 0,he.texture=void 0)}function gn(){try{n.compressedTexImage2D(...arguments)}catch(he){On("WebGLState:",he)}}function Q(){try{n.compressedTexImage3D(...arguments)}catch(he){On("WebGLState:",he)}}function I(){try{n.texSubImage2D(...arguments)}catch(he){On("WebGLState:",he)}}function ie(){try{n.texSubImage3D(...arguments)}catch(he){On("WebGLState:",he)}}function be(){try{n.compressedTexSubImage2D(...arguments)}catch(he){On("WebGLState:",he)}}function De(){try{n.compressedTexSubImage3D(...arguments)}catch(he){On("WebGLState:",he)}}function Je(){try{n.texStorage2D(...arguments)}catch(he){On("WebGLState:",he)}}function je(){try{n.texStorage3D(...arguments)}catch(he){On("WebGLState:",he)}}function Ne(){try{n.texImage2D(...arguments)}catch(he){On("WebGLState:",he)}}function Pe(){try{n.texImage3D(...arguments)}catch(he){On("WebGLState:",he)}}function it(he){return f[he]!==void 0?f[he]:n.getParameter(he)}function Rt(he,dt){f[he]!==dt&&(n.pixelStorei(he,dt),f[he]=dt)}function Mt(he){$.equals(he)===!1&&(n.scissor(he.x,he.y,he.z,he.w),$.copy(he))}function ct(he){Te.equals(he)===!1&&(n.viewport(he.x,he.y,he.z,he.w),Te.copy(he))}function Gt(he,dt){let Ee=l.get(dt);Ee===void 0&&(Ee=new WeakMap,l.set(dt,Ee));let gt=Ee.get(he);gt===void 0&&(gt=n.getUniformBlockIndex(dt,he.name),Ee.set(he,gt))}function Kt(he,dt){let gt=l.get(dt).get(he);u.get(dt)!==gt&&(n.uniformBlockBinding(dt,gt,he.__bindingPointIndex),u.set(dt,gt))}function nn(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),s.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),n.pixelStorei(n.PACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_ALIGNMENT,4),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.BROWSER_DEFAULT_WEBGL),n.pixelStorei(n.PACK_ROW_LENGTH,0),n.pixelStorei(n.PACK_SKIP_PIXELS,0),n.pixelStorei(n.PACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_ROW_LENGTH,0),n.pixelStorei(n.UNPACK_IMAGE_HEIGHT,0),n.pixelStorei(n.UNPACK_SKIP_PIXELS,0),n.pixelStorei(n.UNPACK_SKIP_ROWS,0),n.pixelStorei(n.UNPACK_SKIP_IMAGES,0),d={},f={},te=null,le={},h={},m=new WeakMap,x=[],_=null,g=!1,v=null,F=null,P=null,S=null,N=null,p=null,L=null,E=new Wn(0,0,0),D=0,X=!1,Y=null,W=null,C=null,M=null,J=null,$.set(0,0,n.canvas.width,n.canvas.height),Te.set(0,0,n.canvas.width,n.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:re,disable:Ie,bindFramebuffer:ke,drawBuffers:xe,useProgram:Ye,setBlending:qe,setMaterial:pt,setFlipSided:at,setCullFace:ot,setLineWidth:Vt,setPolygonOffset:cn,setScissorTest:Ze,activeTexture:pn,bindTexture:ne,unbindTexture:Tn,compressedTexImage2D:gn,compressedTexImage3D:Q,texImage2D:Ne,texImage3D:Pe,pixelStorei:Rt,getParameter:it,updateUBOMapping:Gt,uniformBlockBinding:Kt,texStorage2D:Je,texStorage3D:je,texSubImage2D:I,texSubImage3D:ie,compressedTexSubImage2D:be,compressedTexSubImage3D:De,scissor:Mt,viewport:ct,reset:nn}}function Fw(n,e,t,i,r,a,s){let o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,u=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new ln,d=new WeakMap,f=new Set,h,m=new WeakMap,x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(Q,I){return x?new OffscreenCanvas(Q,I):uc("canvas")}function g(Q,I,ie){let be=1,De=gn(Q);if((De.width>ie||De.height>ie)&&(be=ie/Math.max(De.width,De.height)),be<1)if(typeof HTMLImageElement<"u"&&Q instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Q instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Q instanceof ImageBitmap||typeof VideoFrame<"u"&&Q instanceof VideoFrame){let Je=Math.floor(be*De.width),je=Math.floor(be*De.height);h===void 0&&(h=_(Je,je));let Ne=I?_(Je,je):h;return Ne.width=Je,Ne.height=je,Ne.getContext("2d").drawImage(Q,0,0,Je,je),Rn("WebGLRenderer: Texture has been resized from ("+De.width+"x"+De.height+") to ("+Je+"x"+je+")."),Ne}else return"data"in Q&&Rn("WebGLRenderer: Image in DataTexture is too big ("+De.width+"x"+De.height+")."),Q;return Q}function v(Q){return Q.generateMipmaps}function F(Q){n.generateMipmap(Q)}function P(Q){return Q.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:Q.isWebGL3DRenderTarget?n.TEXTURE_3D:Q.isWebGLArrayRenderTarget||Q.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function S(Q,I,ie,be,De,Je=!1){if(Q!==null){if(n[Q]!==void 0)return n[Q];Rn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Q+"'")}let je;be&&(je=e.get("EXT_texture_norm16"),je||Rn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Ne=I;if(I===n.RED&&(ie===n.FLOAT&&(Ne=n.R32F),ie===n.HALF_FLOAT&&(Ne=n.R16F),ie===n.UNSIGNED_BYTE&&(Ne=n.R8),ie===n.UNSIGNED_SHORT&&je&&(Ne=je.R16_EXT),ie===n.SHORT&&je&&(Ne=je.R16_SNORM_EXT)),I===n.RED_INTEGER&&(ie===n.UNSIGNED_BYTE&&(Ne=n.R8UI),ie===n.UNSIGNED_SHORT&&(Ne=n.R16UI),ie===n.UNSIGNED_INT&&(Ne=n.R32UI),ie===n.BYTE&&(Ne=n.R8I),ie===n.SHORT&&(Ne=n.R16I),ie===n.INT&&(Ne=n.R32I)),I===n.RG&&(ie===n.FLOAT&&(Ne=n.RG32F),ie===n.HALF_FLOAT&&(Ne=n.RG16F),ie===n.UNSIGNED_BYTE&&(Ne=n.RG8),ie===n.UNSIGNED_SHORT&&je&&(Ne=je.RG16_EXT),ie===n.SHORT&&je&&(Ne=je.RG16_SNORM_EXT)),I===n.RG_INTEGER&&(ie===n.UNSIGNED_BYTE&&(Ne=n.RG8UI),ie===n.UNSIGNED_SHORT&&(Ne=n.RG16UI),ie===n.UNSIGNED_INT&&(Ne=n.RG32UI),ie===n.BYTE&&(Ne=n.RG8I),ie===n.SHORT&&(Ne=n.RG16I),ie===n.INT&&(Ne=n.RG32I)),I===n.RGB_INTEGER&&(ie===n.UNSIGNED_BYTE&&(Ne=n.RGB8UI),ie===n.UNSIGNED_SHORT&&(Ne=n.RGB16UI),ie===n.UNSIGNED_INT&&(Ne=n.RGB32UI),ie===n.BYTE&&(Ne=n.RGB8I),ie===n.SHORT&&(Ne=n.RGB16I),ie===n.INT&&(Ne=n.RGB32I)),I===n.RGBA_INTEGER&&(ie===n.UNSIGNED_BYTE&&(Ne=n.RGBA8UI),ie===n.UNSIGNED_SHORT&&(Ne=n.RGBA16UI),ie===n.UNSIGNED_INT&&(Ne=n.RGBA32UI),ie===n.BYTE&&(Ne=n.RGBA8I),ie===n.SHORT&&(Ne=n.RGBA16I),ie===n.INT&&(Ne=n.RGBA32I)),I===n.RGB&&(ie===n.UNSIGNED_SHORT&&je&&(Ne=je.RGB16_EXT),ie===n.SHORT&&je&&(Ne=je.RGB16_SNORM_EXT),ie===n.UNSIGNED_INT_5_9_9_9_REV&&(Ne=n.RGB9_E5),ie===n.UNSIGNED_INT_10F_11F_11F_REV&&(Ne=n.R11F_G11F_B10F)),I===n.RGBA){let Pe=Je?cc:vi.getTransfer(De);ie===n.FLOAT&&(Ne=n.RGBA32F),ie===n.HALF_FLOAT&&(Ne=n.RGBA16F),ie===n.UNSIGNED_BYTE&&(Ne=Pe===Di?n.SRGB8_ALPHA8:n.RGBA8),ie===n.UNSIGNED_SHORT&&je&&(Ne=je.RGBA16_EXT),ie===n.SHORT&&je&&(Ne=je.RGBA16_SNORM_EXT),ie===n.UNSIGNED_SHORT_4_4_4_4&&(Ne=n.RGBA4),ie===n.UNSIGNED_SHORT_5_5_5_1&&(Ne=n.RGB5_A1)}return(Ne===n.R16F||Ne===n.R32F||Ne===n.RG16F||Ne===n.RG32F||Ne===n.RGBA16F||Ne===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Ne}function N(Q,I){let ie;return Q?I===null||I===za||I===Sl?ie=n.DEPTH24_STENCIL8:I===va?ie=n.DEPTH32F_STENCIL8:I===Ml&&(ie=n.DEPTH24_STENCIL8,Rn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):I===null||I===za||I===Sl?ie=n.DEPTH_COMPONENT24:I===va?ie=n.DEPTH_COMPONENT32F:I===Ml&&(ie=n.DEPTH_COMPONENT16),ie}function p(Q,I){return v(Q)===!0||Q.isFramebufferTexture&&Q.minFilter!==ar&&Q.minFilter!==fr?Math.log2(Math.max(I.width,I.height))+1:Q.mipmaps!==void 0&&Q.mipmaps.length>0?Q.mipmaps.length:Q.isCompressedTexture&&Array.isArray(Q.image)?I.mipmaps.length:1}function L(Q){let I=Q.target;I.removeEventListener("dispose",L),D(I),I.isVideoTexture&&d.delete(I),I.isHTMLTexture&&f.delete(I)}function E(Q){let I=Q.target;I.removeEventListener("dispose",E),Y(I)}function D(Q){let I=i.get(Q);if(I.__webglInit===void 0)return;let ie=Q.source,be=m.get(ie);if(be){let De=be[I.__cacheKey];De.usedTimes--,De.usedTimes===0&&X(Q),Object.keys(be).length===0&&m.delete(ie)}i.remove(Q)}function X(Q){let I=i.get(Q);n.deleteTexture(I.__webglTexture);let ie=Q.source,be=m.get(ie);delete be[I.__cacheKey],s.memory.textures--}function Y(Q){let I=i.get(Q);if(Q.depthTexture&&(Q.depthTexture.dispose(),i.remove(Q.depthTexture)),Q.isWebGLCubeRenderTarget)for(let be=0;be<6;be++){if(Array.isArray(I.__webglFramebuffer[be]))for(let De=0;De<I.__webglFramebuffer[be].length;De++)n.deleteFramebuffer(I.__webglFramebuffer[be][De]);else n.deleteFramebuffer(I.__webglFramebuffer[be]);I.__webglDepthbuffer&&n.deleteRenderbuffer(I.__webglDepthbuffer[be])}else{if(Array.isArray(I.__webglFramebuffer))for(let be=0;be<I.__webglFramebuffer.length;be++)n.deleteFramebuffer(I.__webglFramebuffer[be]);else n.deleteFramebuffer(I.__webglFramebuffer);if(I.__webglDepthbuffer&&n.deleteRenderbuffer(I.__webglDepthbuffer),I.__webglMultisampledFramebuffer&&n.deleteFramebuffer(I.__webglMultisampledFramebuffer),I.__webglColorRenderbuffer)for(let be=0;be<I.__webglColorRenderbuffer.length;be++)I.__webglColorRenderbuffer[be]&&n.deleteRenderbuffer(I.__webglColorRenderbuffer[be]);I.__webglDepthRenderbuffer&&n.deleteRenderbuffer(I.__webglDepthRenderbuffer)}let ie=Q.textures;for(let be=0,De=ie.length;be<De;be++){let Je=i.get(ie[be]);Je.__webglTexture&&(n.deleteTexture(Je.__webglTexture),s.memory.textures--),i.remove(ie[be])}i.remove(Q)}let W=0;function C(){W=0}function M(){return W}function J(Q){W=Q}function q(){let Q=W;return Q>=r.maxTextures&&Rn("WebGLTextures: Trying to use "+(Q+1)+" texture units while this GPU supports only "+r.maxTextures),W+=1,Q}function ce(Q){let I=[];return I.push(Q.wrapS),I.push(Q.wrapT),I.push(Q.wrapR||0),I.push(Q.magFilter),I.push(Q.minFilter),I.push(Q.anisotropy),I.push(Q.internalFormat),I.push(Q.format),I.push(Q.type),I.push(Q.generateMipmaps),I.push(Q.premultiplyAlpha),I.push(Q.flipY),I.push(Q.unpackAlignment),I.push(Q.colorSpace),I.join()}function k(Q,I){let ie=i.get(Q);if(Q.isVideoTexture&&ne(Q),Q.isRenderTargetTexture===!1&&Q.isExternalTexture!==!0&&Q.version>0&&ie.__version!==Q.version){let be=Q.image;if(be===null)Rn("WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)Rn("WebGLRenderer: Texture marked for update but image is incomplete");else{Ie(ie,Q,I);return}}else Q.isExternalTexture&&(ie.__webglTexture=Q.sourceTexture?Q.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,ie.__webglTexture,n.TEXTURE0+I)}function G(Q,I){let ie=i.get(Q);if(Q.isRenderTargetTexture===!1&&Q.version>0&&ie.__version!==Q.version){Ie(ie,Q,I);return}else Q.isExternalTexture&&(ie.__webglTexture=Q.sourceTexture?Q.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,ie.__webglTexture,n.TEXTURE0+I)}function te(Q,I){let ie=i.get(Q);if(Q.isRenderTargetTexture===!1&&Q.version>0&&ie.__version!==Q.version){Ie(ie,Q,I);return}t.bindTexture(n.TEXTURE_3D,ie.__webglTexture,n.TEXTURE0+I)}function le(Q,I){let ie=i.get(Q);if(Q.isCubeDepthTexture!==!0&&Q.version>0&&ie.__version!==Q.version){ke(ie,Q,I);return}t.bindTexture(n.TEXTURE_CUBE_MAP,ie.__webglTexture,n.TEXTURE0+I)}let ge={[Vs]:n.REPEAT,[Ta]:n.CLAMP_TO_EDGE,[el]:n.MIRRORED_REPEAT},oe={[ar]:n.NEAREST,[Ld]:n.NEAREST_MIPMAP_NEAREST,[xo]:n.NEAREST_MIPMAP_LINEAR,[fr]:n.LINEAR,[_l]:n.LINEAR_MIPMAP_NEAREST,[ns]:n.LINEAR_MIPMAP_LINEAR},$={[y0]:n.NEVER,[b0]:n.ALWAYS,[x0]:n.LESS,[gf]:n.LEQUAL,[_0]:n.EQUAL,[yf]:n.GEQUAL,[M0]:n.GREATER,[S0]:n.NOTEQUAL};function Te(Q,I){if(I.type===va&&e.has("OES_texture_float_linear")===!1&&(I.magFilter===fr||I.magFilter===_l||I.magFilter===xo||I.magFilter===ns||I.minFilter===fr||I.minFilter===_l||I.minFilter===xo||I.minFilter===ns)&&Rn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(Q,n.TEXTURE_WRAP_S,ge[I.wrapS]),n.texParameteri(Q,n.TEXTURE_WRAP_T,ge[I.wrapT]),(Q===n.TEXTURE_3D||Q===n.TEXTURE_2D_ARRAY)&&n.texParameteri(Q,n.TEXTURE_WRAP_R,ge[I.wrapR]),n.texParameteri(Q,n.TEXTURE_MAG_FILTER,oe[I.magFilter]),n.texParameteri(Q,n.TEXTURE_MIN_FILTER,oe[I.minFilter]),I.compareFunction&&(n.texParameteri(Q,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(Q,n.TEXTURE_COMPARE_FUNC,$[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(I.magFilter===ar||I.minFilter!==xo&&I.minFilter!==ns||I.type===va&&e.has("OES_texture_float_linear")===!1)return;if(I.anisotropy>1||i.get(I).__currentAnisotropy){let ie=e.get("EXT_texture_filter_anisotropic");n.texParameterf(Q,ie.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,r.getMaxAnisotropy())),i.get(I).__currentAnisotropy=I.anisotropy}}}function Le(Q,I){let ie=!1;Q.__webglInit===void 0&&(Q.__webglInit=!0,I.addEventListener("dispose",L));let be=I.source,De=m.get(be);De===void 0&&(De={},m.set(be,De));let Je=ce(I);if(Je!==Q.__cacheKey){De[Je]===void 0&&(De[Je]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,ie=!0),De[Je].usedTimes++;let je=De[Q.__cacheKey];je!==void 0&&(De[Q.__cacheKey].usedTimes--,je.usedTimes===0&&X(I)),Q.__cacheKey=Je,Q.__webglTexture=De[Je].texture}return ie}function se(Q,I,ie){return Math.floor(Math.floor(Q/ie)/I)}function re(Q,I,ie,be){let Je=Q.updateRanges;if(Je.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,I.width,I.height,ie,be,I.data);else{Je.sort((Rt,Mt)=>Rt.start-Mt.start);let je=0;for(let Rt=1;Rt<Je.length;Rt++){let Mt=Je[je],ct=Je[Rt],Gt=Mt.start+Mt.count,Kt=se(ct.start,I.width,4),nn=se(Mt.start,I.width,4);ct.start<=Gt+1&&Kt===nn&&se(ct.start+ct.count-1,I.width,4)===Kt?Mt.count=Math.max(Mt.count,ct.start+ct.count-Mt.start):(++je,Je[je]=ct)}Je.length=je+1;let Ne=t.getParameter(n.UNPACK_ROW_LENGTH),Pe=t.getParameter(n.UNPACK_SKIP_PIXELS),it=t.getParameter(n.UNPACK_SKIP_ROWS);t.pixelStorei(n.UNPACK_ROW_LENGTH,I.width);for(let Rt=0,Mt=Je.length;Rt<Mt;Rt++){let ct=Je[Rt],Gt=Math.floor(ct.start/4),Kt=Math.ceil(ct.count/4),nn=Gt%I.width,he=Math.floor(Gt/I.width),dt=Kt,Ee=1;t.pixelStorei(n.UNPACK_SKIP_PIXELS,nn),t.pixelStorei(n.UNPACK_SKIP_ROWS,he),t.texSubImage2D(n.TEXTURE_2D,0,nn,he,dt,Ee,ie,be,I.data)}Q.clearUpdateRanges(),t.pixelStorei(n.UNPACK_ROW_LENGTH,Ne),t.pixelStorei(n.UNPACK_SKIP_PIXELS,Pe),t.pixelStorei(n.UNPACK_SKIP_ROWS,it)}}function Ie(Q,I,ie){let be=n.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(be=n.TEXTURE_2D_ARRAY),I.isData3DTexture&&(be=n.TEXTURE_3D);let De=Le(Q,I),Je=I.source;t.bindTexture(be,Q.__webglTexture,n.TEXTURE0+ie);let je=i.get(Je);if(Je.version!==je.__version||De===!0){if(t.activeTexture(n.TEXTURE0+ie),(typeof ImageBitmap<"u"&&I.image instanceof ImageBitmap)===!1){let Ee=vi.getPrimaries(vi.workingColorSpace),gt=I.colorSpace===ta?null:vi.getPrimaries(I.colorSpace),Ke=I.colorSpace===ta||Ee===gt?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke)}t.pixelStorei(n.UNPACK_ALIGNMENT,I.unpackAlignment);let Pe=g(I.image,!1,r.maxTextureSize);Pe=Tn(I,Pe);let it=a.convert(I.format,I.colorSpace),Rt=a.convert(I.type),Mt=S(I.internalFormat,it,Rt,I.normalized,I.colorSpace,I.isVideoTexture);Te(be,I);let ct,Gt=I.mipmaps,Kt=I.isVideoTexture!==!0,nn=je.__version===void 0||De===!0,he=Je.dataReady,dt=p(I,Pe);if(I.isDepthTexture)Mt=N(I.format===Zs,I.type),nn&&(Kt?t.texStorage2D(n.TEXTURE_2D,1,Mt,Pe.width,Pe.height):t.texImage2D(n.TEXTURE_2D,0,Mt,Pe.width,Pe.height,0,it,Rt,null));else if(I.isDataTexture)if(Gt.length>0){Kt&&nn&&t.texStorage2D(n.TEXTURE_2D,dt,Mt,Gt[0].width,Gt[0].height);for(let Ee=0,gt=Gt.length;Ee<gt;Ee++)ct=Gt[Ee],Kt?he&&t.texSubImage2D(n.TEXTURE_2D,Ee,0,0,ct.width,ct.height,it,Rt,ct.data):t.texImage2D(n.TEXTURE_2D,Ee,Mt,ct.width,ct.height,0,it,Rt,ct.data);I.generateMipmaps=!1}else Kt?(nn&&t.texStorage2D(n.TEXTURE_2D,dt,Mt,Pe.width,Pe.height),he&&re(I,Pe,it,Rt)):t.texImage2D(n.TEXTURE_2D,0,Mt,Pe.width,Pe.height,0,it,Rt,Pe.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){Kt&&nn&&t.texStorage3D(n.TEXTURE_2D_ARRAY,dt,Mt,Gt[0].width,Gt[0].height,Pe.depth);for(let Ee=0,gt=Gt.length;Ee<gt;Ee++)if(ct=Gt[Ee],I.format!==ga)if(it!==null)if(Kt){if(he)if(I.layerUpdates.size>0){let Ke=Ep(ct.width,ct.height,I.format,I.type);for(let We of I.layerUpdates){let Wt=ct.data.subarray(We*Ke/ct.data.BYTES_PER_ELEMENT,(We+1)*Ke/ct.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ee,0,0,We,ct.width,ct.height,1,it,Wt)}}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Ee,0,0,0,ct.width,ct.height,Pe.depth,it,ct.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Ee,Mt,ct.width,ct.height,Pe.depth,0,ct.data,0,0);else Rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Kt?he&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,Ee,0,0,0,ct.width,ct.height,Pe.depth,it,Rt,ct.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Ee,Mt,ct.width,ct.height,Pe.depth,0,it,Rt,ct.data);I.layerUpdates.size>0&&I.clearLayerUpdates()}else{Kt&&nn&&t.texStorage2D(n.TEXTURE_2D,dt,Mt,Gt[0].width,Gt[0].height);for(let Ee=0,gt=Gt.length;Ee<gt;Ee++)ct=Gt[Ee],I.format!==ga?it!==null?Kt?he&&t.compressedTexSubImage2D(n.TEXTURE_2D,Ee,0,0,ct.width,ct.height,it,ct.data):t.compressedTexImage2D(n.TEXTURE_2D,Ee,Mt,ct.width,ct.height,0,ct.data):Rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Kt?he&&t.texSubImage2D(n.TEXTURE_2D,Ee,0,0,ct.width,ct.height,it,Rt,ct.data):t.texImage2D(n.TEXTURE_2D,Ee,Mt,ct.width,ct.height,0,it,Rt,ct.data)}else if(I.isDataArrayTexture)if(Kt){if(nn&&t.texStorage3D(n.TEXTURE_2D_ARRAY,dt,Mt,Pe.width,Pe.height,Pe.depth),he)if(I.layerUpdates.size>0){let Ee=Ep(Pe.width,Pe.height,I.format,I.type);for(let gt of I.layerUpdates){let Ke=Pe.data.subarray(gt*Ee/Pe.data.BYTES_PER_ELEMENT,(gt+1)*Ee/Pe.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,gt,Pe.width,Pe.height,1,it,Rt,Ke)}I.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Pe.width,Pe.height,Pe.depth,it,Rt,Pe.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Mt,Pe.width,Pe.height,Pe.depth,0,it,Rt,Pe.data);else if(I.isData3DTexture)Kt?(nn&&t.texStorage3D(n.TEXTURE_3D,dt,Mt,Pe.width,Pe.height,Pe.depth),he&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Pe.width,Pe.height,Pe.depth,it,Rt,Pe.data)):t.texImage3D(n.TEXTURE_3D,0,Mt,Pe.width,Pe.height,Pe.depth,0,it,Rt,Pe.data);else if(I.isFramebufferTexture){if(nn)if(Kt)t.texStorage2D(n.TEXTURE_2D,dt,Mt,Pe.width,Pe.height);else{let Ee=Pe.width,gt=Pe.height;for(let Ke=0;Ke<dt;Ke++)t.texImage2D(n.TEXTURE_2D,Ke,Mt,Ee,gt,0,it,Rt,null),Ee>>=1,gt>>=1}}else if(I.isHTMLTexture){if("texElementImage2D"in n){let Ee=n.canvas;if(Ee.hasAttribute("layoutsubtree")||Ee.setAttribute("layoutsubtree","true"),Pe.parentNode!==Ee){Ee.appendChild(Pe),f.add(I),Ee.onpaint=gt=>{let Ke=gt.changedElements;for(let We of f)Ke.includes(We.image)&&(We.needsUpdate=!0)},Ee.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Pe);else{let Ke=n.RGBA,We=n.RGBA,Wt=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Ke,We,Wt,Pe)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(Gt.length>0){if(Kt&&nn){let Ee=gn(Gt[0]);t.texStorage2D(n.TEXTURE_2D,dt,Mt,Ee.width,Ee.height)}for(let Ee=0,gt=Gt.length;Ee<gt;Ee++)ct=Gt[Ee],Kt?he&&t.texSubImage2D(n.TEXTURE_2D,Ee,0,0,it,Rt,ct):t.texImage2D(n.TEXTURE_2D,Ee,Mt,it,Rt,ct);I.generateMipmaps=!1}else if(Kt){if(nn){let Ee=gn(Pe);t.texStorage2D(n.TEXTURE_2D,dt,Mt,Ee.width,Ee.height)}he&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,it,Rt,Pe)}else t.texImage2D(n.TEXTURE_2D,0,Mt,it,Rt,Pe);v(I)&&F(be),je.__version=Je.version,I.onUpdate&&I.onUpdate(I)}Q.__version=I.version}function ke(Q,I,ie){if(I.image.length!==6)return;let be=Le(Q,I),De=I.source;t.bindTexture(n.TEXTURE_CUBE_MAP,Q.__webglTexture,n.TEXTURE0+ie);let Je=i.get(De);if(De.version!==Je.__version||be===!0){t.activeTexture(n.TEXTURE0+ie);let je=vi.getPrimaries(vi.workingColorSpace),Ne=I.colorSpace===ta?null:vi.getPrimaries(I.colorSpace),Pe=I.colorSpace===ta||je===Ne?n.NONE:n.BROWSER_DEFAULT_WEBGL;t.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(n.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Pe);let it=I.isCompressedTexture||I.image[0].isCompressedTexture,Rt=I.image[0]&&I.image[0].isDataTexture,Mt=[];for(let We=0;We<6;We++)!it&&!Rt?Mt[We]=g(I.image[We],!0,r.maxCubemapSize):Mt[We]=Rt?I.image[We].image:I.image[We],Mt[We]=Tn(I,Mt[We]);let ct=Mt[0],Gt=a.convert(I.format,I.colorSpace),Kt=a.convert(I.type),nn=S(I.internalFormat,Gt,Kt,I.normalized,I.colorSpace),he=I.isVideoTexture!==!0,dt=Je.__version===void 0||be===!0,Ee=De.dataReady,gt=p(I,ct);Te(n.TEXTURE_CUBE_MAP,I);let Ke;if(it){he&&dt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,gt,nn,ct.width,ct.height);for(let We=0;We<6;We++){Ke=Mt[We].mipmaps;for(let Wt=0;Wt<Ke.length;Wt++){let Lt=Ke[Wt];I.format!==ga?Gt!==null?he?Ee&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,Wt,0,0,Lt.width,Lt.height,Gt,Lt.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,Wt,nn,Lt.width,Lt.height,0,Lt.data):Rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):he?Ee&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,Wt,0,0,Lt.width,Lt.height,Gt,Kt,Lt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,Wt,nn,Lt.width,Lt.height,0,Gt,Kt,Lt.data)}}}else{if(Ke=I.mipmaps,he&&dt){Ke.length>0&&gt++;let We=gn(Mt[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,gt,nn,We.width,We.height)}for(let We=0;We<6;We++)if(Rt){he?Ee&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,0,0,0,Mt[We].width,Mt[We].height,Gt,Kt,Mt[We].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,0,nn,Mt[We].width,Mt[We].height,0,Gt,Kt,Mt[We].data);for(let Wt=0;Wt<Ke.length;Wt++){let yt=Ke[Wt].image[We].image;he?Ee&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,Wt+1,0,0,yt.width,yt.height,Gt,Kt,yt.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,Wt+1,nn,yt.width,yt.height,0,Gt,Kt,yt.data)}}else{he?Ee&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,0,0,0,Gt,Kt,Mt[We]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,0,nn,Gt,Kt,Mt[We]);for(let Wt=0;Wt<Ke.length;Wt++){let Lt=Ke[Wt];he?Ee&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,Wt+1,0,0,Gt,Kt,Lt.image[We]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+We,Wt+1,nn,Gt,Kt,Lt.image[We])}}}v(I)&&F(n.TEXTURE_CUBE_MAP),Je.__version=De.version,I.onUpdate&&I.onUpdate(I)}Q.__version=I.version}function xe(Q,I,ie,be,De,Je){let je=a.convert(ie.format,ie.colorSpace),Ne=a.convert(ie.type),Pe=S(ie.internalFormat,je,Ne,ie.normalized,ie.colorSpace),it=i.get(I),Rt=i.get(ie);if(Rt.__renderTarget=I,!it.__hasExternalTextures){let Mt=Math.max(1,I.width>>Je),ct=Math.max(1,I.height>>Je);De===n.TEXTURE_3D||De===n.TEXTURE_2D_ARRAY?t.texImage3D(De,Je,Pe,Mt,ct,I.depth,0,je,Ne,null):t.texImage2D(De,Je,Pe,Mt,ct,0,je,Ne,null)}t.bindFramebuffer(n.FRAMEBUFFER,Q),pn(I)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,be,De,Rt.__webglTexture,0,Ze(I)):(De===n.TEXTURE_2D||De>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&De<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,be,De,Rt.__webglTexture,Je),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ye(Q,I,ie){if(n.bindRenderbuffer(n.RENDERBUFFER,Q),I.depthBuffer){let be=I.depthTexture,De=be&&be.isDepthTexture?be.type:null,Je=N(I.stencilBuffer,De),je=I.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;pn(I)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ze(I),Je,I.width,I.height):ie?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ze(I),Je,I.width,I.height):n.renderbufferStorage(n.RENDERBUFFER,Je,I.width,I.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,je,n.RENDERBUFFER,Q)}else{let be=I.textures;for(let De=0;De<be.length;De++){let Je=be[De],je=a.convert(Je.format,Je.colorSpace),Ne=a.convert(Je.type),Pe=S(Je.internalFormat,je,Ne,Je.normalized,Je.colorSpace);pn(I)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ze(I),Pe,I.width,I.height):ie?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ze(I),Pe,I.width,I.height):n.renderbufferStorage(n.RENDERBUFFER,Pe,I.width,I.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function mt(Q,I,ie){let be=I.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,Q),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let De=i.get(I.depthTexture);if(De.__renderTarget=I,(!De.__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),be){if(De.__webglInit===void 0&&(De.__webglInit=!0,I.depthTexture.addEventListener("dispose",L)),De.__webglTexture===void 0){De.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,De.__webglTexture),Te(n.TEXTURE_CUBE_MAP,I.depthTexture);let it=a.convert(I.depthTexture.format),Rt=a.convert(I.depthTexture.type),Mt;I.depthTexture.format===Ka?Mt=n.DEPTH_COMPONENT24:I.depthTexture.format===Zs&&(Mt=n.DEPTH24_STENCIL8);for(let ct=0;ct<6;ct++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,Mt,I.width,I.height,0,it,Rt,null)}}else k(I.depthTexture,0);let Je=De.__webglTexture,je=Ze(I),Ne=be?n.TEXTURE_CUBE_MAP_POSITIVE_X+ie:n.TEXTURE_2D,Pe=I.depthTexture.format===Zs?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(I.depthTexture.format===Ka)pn(I)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Pe,Ne,Je,0,je):n.framebufferTexture2D(n.FRAMEBUFFER,Pe,Ne,Je,0);else if(I.depthTexture.format===Zs)pn(I)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Pe,Ne,Je,0,je):n.framebufferTexture2D(n.FRAMEBUFFER,Pe,Ne,Je,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function He(Q){let I=i.get(Q),ie=Q.isWebGLCubeRenderTarget===!0;if(I.__boundDepthTexture!==Q.depthTexture){let be=Q.depthTexture;if(I.__depthDisposeCallback&&I.__depthDisposeCallback(),be){let De=()=>{delete I.__boundDepthTexture,delete I.__depthDisposeCallback,be.removeEventListener("dispose",De)};be.addEventListener("dispose",De),I.__depthDisposeCallback=De}I.__boundDepthTexture=be}if(Q.depthTexture&&!I.__autoAllocateDepthBuffer)if(ie)for(let be=0;be<6;be++)mt(I.__webglFramebuffer[be],Q,be);else{let be=Q.texture.mipmaps;be&&be.length>0?mt(I.__webglFramebuffer[0],Q,0):mt(I.__webglFramebuffer,Q,0)}else if(ie){I.__webglDepthbuffer=[];for(let be=0;be<6;be++)if(t.bindFramebuffer(n.FRAMEBUFFER,I.__webglFramebuffer[be]),I.__webglDepthbuffer[be]===void 0)I.__webglDepthbuffer[be]=n.createRenderbuffer(),Ye(I.__webglDepthbuffer[be],Q,!1);else{let De=Q.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Je=I.__webglDepthbuffer[be];n.bindRenderbuffer(n.RENDERBUFFER,Je),n.framebufferRenderbuffer(n.FRAMEBUFFER,De,n.RENDERBUFFER,Je)}}else{let be=Q.texture.mipmaps;if(be&&be.length>0?t.bindFramebuffer(n.FRAMEBUFFER,I.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer===void 0)I.__webglDepthbuffer=n.createRenderbuffer(),Ye(I.__webglDepthbuffer,Q,!1);else{let De=Q.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Je=I.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,Je),n.framebufferRenderbuffer(n.FRAMEBUFFER,De,n.RENDERBUFFER,Je)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function qe(Q,I,ie){let be=i.get(Q);I!==void 0&&xe(be.__webglFramebuffer,Q,Q.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),ie!==void 0&&He(Q)}function pt(Q){let I=Q.texture,ie=i.get(Q),be=i.get(I);Q.addEventListener("dispose",E);let De=Q.textures,Je=Q.isWebGLCubeRenderTarget===!0,je=De.length>1;if(je||(be.__webglTexture===void 0&&(be.__webglTexture=n.createTexture()),be.__version=I.version,s.memory.textures++),Je){ie.__webglFramebuffer=[];for(let Ne=0;Ne<6;Ne++)if(I.mipmaps&&I.mipmaps.length>0){ie.__webglFramebuffer[Ne]=[];for(let Pe=0;Pe<I.mipmaps.length;Pe++)ie.__webglFramebuffer[Ne][Pe]=n.createFramebuffer()}else ie.__webglFramebuffer[Ne]=n.createFramebuffer()}else{if(I.mipmaps&&I.mipmaps.length>0){ie.__webglFramebuffer=[];for(let Ne=0;Ne<I.mipmaps.length;Ne++)ie.__webglFramebuffer[Ne]=n.createFramebuffer()}else ie.__webglFramebuffer=n.createFramebuffer();if(je)for(let Ne=0,Pe=De.length;Ne<Pe;Ne++){let it=i.get(De[Ne]);it.__webglTexture===void 0&&(it.__webglTexture=n.createTexture(),s.memory.textures++)}if(Q.samples>0&&pn(Q)===!1){ie.__webglMultisampledFramebuffer=n.createFramebuffer(),ie.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,ie.__webglMultisampledFramebuffer);for(let Ne=0;Ne<De.length;Ne++){let Pe=De[Ne];ie.__webglColorRenderbuffer[Ne]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,ie.__webglColorRenderbuffer[Ne]);let it=a.convert(Pe.format,Pe.colorSpace),Rt=a.convert(Pe.type),Mt=S(Pe.internalFormat,it,Rt,Pe.normalized,Pe.colorSpace,Q.isXRRenderTarget===!0),ct=Ze(Q);n.renderbufferStorageMultisample(n.RENDERBUFFER,ct,Mt,Q.width,Q.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ne,n.RENDERBUFFER,ie.__webglColorRenderbuffer[Ne])}n.bindRenderbuffer(n.RENDERBUFFER,null),Q.depthBuffer&&(ie.__webglDepthRenderbuffer=n.createRenderbuffer(),Ye(ie.__webglDepthRenderbuffer,Q,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(Je){t.bindTexture(n.TEXTURE_CUBE_MAP,be.__webglTexture),Te(n.TEXTURE_CUBE_MAP,I);for(let Ne=0;Ne<6;Ne++)if(I.mipmaps&&I.mipmaps.length>0)for(let Pe=0;Pe<I.mipmaps.length;Pe++)xe(ie.__webglFramebuffer[Ne][Pe],Q,I,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Pe);else xe(ie.__webglFramebuffer[Ne],Q,I,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0);v(I)&&F(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(je){for(let Ne=0,Pe=De.length;Ne<Pe;Ne++){let it=De[Ne],Rt=i.get(it),Mt=n.TEXTURE_2D;(Q.isWebGL3DRenderTarget||Q.isWebGLArrayRenderTarget)&&(Mt=Q.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Mt,Rt.__webglTexture),Te(Mt,it),xe(ie.__webglFramebuffer,Q,it,n.COLOR_ATTACHMENT0+Ne,Mt,0),v(it)&&F(Mt)}t.unbindTexture()}else{let Ne=n.TEXTURE_2D;if((Q.isWebGL3DRenderTarget||Q.isWebGLArrayRenderTarget)&&(Ne=Q.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(Ne,be.__webglTexture),Te(Ne,I),I.mipmaps&&I.mipmaps.length>0)for(let Pe=0;Pe<I.mipmaps.length;Pe++)xe(ie.__webglFramebuffer[Pe],Q,I,n.COLOR_ATTACHMENT0,Ne,Pe);else xe(ie.__webglFramebuffer,Q,I,n.COLOR_ATTACHMENT0,Ne,0);v(I)&&F(Ne),t.unbindTexture()}Q.depthBuffer&&He(Q)}function at(Q){let I=Q.textures;for(let ie=0,be=I.length;ie<be;ie++){let De=I[ie];if(v(De)){let Je=P(Q),je=i.get(De).__webglTexture;t.bindTexture(Je,je),F(Je),t.unbindTexture()}}}let ot=[],Vt=[];function cn(Q){if(Q.samples>0){if(pn(Q)===!1){let I=Q.textures,ie=Q.width,be=Q.height,De=n.COLOR_BUFFER_BIT,Je=Q.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,je=i.get(Q),Ne=I.length>1;if(Ne)for(let it=0;it<I.length;it++)t.bindFramebuffer(n.FRAMEBUFFER,je.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+it,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,je.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+it,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,je.__webglMultisampledFramebuffer);let Pe=Q.texture.mipmaps;Pe&&Pe.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,je.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,je.__webglFramebuffer);for(let it=0;it<I.length;it++){if(Q.resolveDepthBuffer&&(Q.depthBuffer&&(De|=n.DEPTH_BUFFER_BIT),Q.stencilBuffer&&Q.resolveStencilBuffer&&(De|=n.STENCIL_BUFFER_BIT)),Ne){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,je.__webglColorRenderbuffer[it]);let Rt=i.get(I[it]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,Rt,0)}n.blitFramebuffer(0,0,ie,be,0,0,ie,be,De,n.NEAREST),u===!0&&(ot.length=0,Vt.length=0,ot.push(n.COLOR_ATTACHMENT0+it),Q.depthBuffer&&Q.storeMultisampledDepthBuffer===!1&&(ot.push(Je),Vt.push(Je),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,Vt)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,ot))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ne)for(let it=0;it<I.length;it++){t.bindFramebuffer(n.FRAMEBUFFER,je.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+it,n.RENDERBUFFER,je.__webglColorRenderbuffer[it]);let Rt=i.get(I[it]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,je.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+it,n.TEXTURE_2D,Rt,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,je.__webglMultisampledFramebuffer)}else if(Q.depthBuffer&&Q.storeMultisampledDepthBuffer===!1&&u){let I=Q.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[I])}}}function Ze(Q){return Math.min(r.maxSamples,Q.samples)}function pn(Q){let I=i.get(Q);return Q.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function ne(Q){let I=s.render.frame;d.get(Q)!==I&&(d.set(Q,I),Q.update())}function Tn(Q,I){let ie=Q.colorSpace,be=Q.format,De=Q.type;return Q.isCompressedTexture===!0||Q.isVideoTexture===!0||ie!==lc&&ie!==ta&&(vi.getTransfer(ie)===Di?(be!==ga||De!==ca)&&Rn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):On("WebGLTextures: Unsupported texture color space:",ie)),I}function gn(Q){return typeof HTMLImageElement<"u"&&Q instanceof HTMLImageElement?(l.width=Q.naturalWidth||Q.width,l.height=Q.naturalHeight||Q.height):typeof VideoFrame<"u"&&Q instanceof VideoFrame?(l.width=Q.displayWidth,l.height=Q.displayHeight):(l.width=Q.width,l.height=Q.height),l}this.allocateTextureUnit=q,this.resetTextureUnits=C,this.getTextureUnits=M,this.setTextureUnits=J,this.setTexture2D=k,this.setTexture2DArray=G,this.setTexture3D=te,this.setTextureCube=le,this.rebindTextures=qe,this.setupRenderTarget=pt,this.updateRenderTargetMipmap=at,this.updateMultisampleRenderTarget=cn,this.setupDepthRenderbuffer=He,this.setupFrameBufferTexture=xe,this.useMultisampledRTT=pn,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ow(n,e){function t(i,r=ta){let a,s=vi.getTransfer(r);if(i===ca)return n.UNSIGNED_BYTE;if(i===Nd)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Ud)return n.UNSIGNED_SHORT_5_5_5_1;if(i===vp)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===gp)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===pp)return n.BYTE;if(i===mp)return n.SHORT;if(i===Ml)return n.UNSIGNED_SHORT;if(i===Dd)return n.INT;if(i===za)return n.UNSIGNED_INT;if(i===va)return n.FLOAT;if(i===Va)return n.HALF_FLOAT;if(i===yp)return n.ALPHA;if(i===xp)return n.RGB;if(i===ga)return n.RGBA;if(i===Ka)return n.DEPTH_COMPONENT;if(i===Zs)return n.DEPTH_STENCIL;if(i===Fd)return n.RED;if(i===Od)return n.RED_INTEGER;if(i===Js)return n.RG;if(i===Bd)return n.RG_INTEGER;if(i===kd)return n.RGBA_INTEGER;if(i===Bc||i===kc||i===zc||i===Vc)if(s===Di)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===Bc)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===kc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===zc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Vc)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===Bc)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===kc)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===zc)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Vc)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===zd||i===Vd||i===Gd||i===Hd)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===zd)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Vd)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Gd)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Hd)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Wd||i===Xd||i===Yd||i===qd||i===Zd||i===Gc||i===Jd)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===Wd||i===Xd)return s===Di?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===Yd)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(i===qd)return a.COMPRESSED_R11_EAC;if(i===Zd)return a.COMPRESSED_SIGNED_R11_EAC;if(i===Gc)return a.COMPRESSED_RG11_EAC;if(i===Jd)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===$d||i===Kd||i===Qd||i===jd||i===ef||i===tf||i===nf||i===rf||i===af||i===sf||i===of||i===lf||i===cf||i===uf)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===$d)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Kd)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Qd)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===jd)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ef)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===tf)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===nf)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===rf)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===af)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===sf)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===of)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===lf)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===cf)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===uf)return s===Di?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===df||i===ff||i===hf)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===df)return s===Di?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ff)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===hf)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===pf||i===mf||i===Hc||i===vf)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===pf)return a.COMPRESSED_RED_RGTC1_EXT;if(i===mf)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Hc)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===vf)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Sl?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}var Bw=`
4197
4197
  void main() {
4198
4198
 
4199
4199
  gl_Position = vec4( position, 1.0 );
4200
4200
 
4201
- }`,xb=`
4201
+ }`,kw=`
4202
4202
  uniform sampler2DArray depthColor;
4203
4203
  uniform float depthWidth;
4204
4204
  uniform float depthHeight;
@@ -4217,8 +4217,8 @@ void main() {
4217
4217
 
4218
4218
  }
4219
4219
 
4220
- }`,Wh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let i=new bl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,i=new kr({vertexShader:yb,fragmentShader:xb,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new jn(new Pl(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Xh=class extends Sa{constructor(e,t){super();let i=this,r=null,a=1,s=null,o="local-floor",u=1,l=null,d=null,f=null,h=null,v=null,y=null,T=typeof XRWebGLBinding<"u",g=new Wh,m={},L=t.getContextAttributes(),F=null,_=null,p=[],S=[],B=new kt,b=null,I=null,z=new er;z.viewport=new fi;let U=new er;U.viewport=new fi;let Y=[z,U],E=new Pu,M=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ae){let de=p[ae];return de===void 0&&(de=new yo,p[ae]=de),de.getTargetRaySpace()},this.getControllerGrip=function(ae){let de=p[ae];return de===void 0&&(de=new yo,p[ae]=de),de.getGripSpace()},this.getHand=function(ae){let de=p[ae];return de===void 0&&(de=new yo,p[ae]=de),de.getHandSpace()};function H(ae){let de=S.indexOf(ae.inputSource);if(de===-1)return;let _e=p[de];_e!==void 0&&(_e.update(ae.inputSource,ae.frame,l||s),_e.dispatchEvent({type:ae.type,data:ae.inputSource}))}function ee(){r.removeEventListener("select",H),r.removeEventListener("selectstart",H),r.removeEventListener("selectend",H),r.removeEventListener("squeeze",H),r.removeEventListener("squeezestart",H),r.removeEventListener("squeezeend",H),r.removeEventListener("end",ee),r.removeEventListener("inputsourceschange",j);for(let ae=0;ae<p.length;ae++){let de=S[ae];de!==null&&(S[ae]=null,p[ae].disconnect(de))}M=null,O=null,g.reset();for(let ae in m)delete m[ae];if(e.setRenderTarget(F),v=null,h=null,f=null,r=null,_=null,Fe.stop(),i.isPresenting=!1,e.setPixelRatio(b),e.setSize(B.width,B.height,!1),I!==null){let ae=I.camera;ae.fov=I.fov,ae.zoom=I.zoom,ae.updateProjectionMatrix(),I=null}i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ae){a=ae,i.isPresenting===!0&&rn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ae){o=ae,i.isPresenting===!0&&rn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(ae){l=ae},this.getBaseLayer=function(){return h!==null?h:v},this.getBinding=function(){return f===null&&T&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return y},this.getSession=function(){return r},this.setSession=async function(ae){if(r=ae,r!==null){if(F=e.getRenderTarget(),r.addEventListener("select",H),r.addEventListener("selectstart",H),r.addEventListener("selectend",H),r.addEventListener("squeeze",H),r.addEventListener("squeezestart",H),r.addEventListener("squeezeend",H),r.addEventListener("end",ee),r.addEventListener("inputsourceschange",j),L.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(B),T&&"createProjectionLayer"in XRWebGLBinding.prototype){let _e=null,Ge=null,$e=null;L.depth&&($e=L.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,_e=L.stencil?ys:Ma,Ge=L.stencil?Co:sa);let ut={colorFormat:t.RGBA8,depthFormat:$e,scaleFactor:a};f=this.getBinding(),h=f.createProjectionLayer(ut),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),_=new Ar(h.textureWidth,h.textureHeight,{format:qr,type:Cr,depthTexture:new us(h.textureWidth,h.textureHeight,Ge,void 0,void 0,void 0,void 0,void 0,void 0,_e),stencilBuffer:L.stencil,colorSpace:e.outputColorSpace,samples:L.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let _e={antialias:L.antialias,alpha:!0,depth:L.depth,stencil:L.stencil,framebufferScaleFactor:a};v=new XRWebGLLayer(r,t,_e),r.updateRenderState({baseLayer:v}),e.setPixelRatio(1),e.setSize(v.framebufferWidth,v.framebufferHeight,!1),_=new Ar(v.framebufferWidth,v.framebufferHeight,{format:qr,type:Cr,colorSpace:e.outputColorSpace,stencilBuffer:L.stencil,resolveDepthBuffer:v.ignoreDepthValues===!1,resolveStencilBuffer:v.ignoreDepthValues===!1,storeMultisampledDepthBuffer:v.ignoreDepthValues===!1,storeMultisampledStencilBuffer:v.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(u),l=null,s=await r.requestReferenceSpace(o),Fe.setContext(r),Fe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function j(ae){for(let de=0;de<ae.removed.length;de++){let _e=ae.removed[de],Ge=S.indexOf(_e);Ge>=0&&(S[Ge]=null,p[Ge].disconnect(_e))}for(let de=0;de<ae.added.length;de++){let _e=ae.added[de],Ge=S.indexOf(_e);if(Ge===-1){for(let ut=0;ut<p.length;ut++)if(ut>=S.length){S.push(_e),Ge=ut;break}else if(S[ut]===null){S[ut]=_e,Ge=ut;break}if(Ge===-1)break}let $e=p[Ge];$e&&$e.connect(_e)}}let K=new ge,re=new ge;function J(ae,de,_e){K.setFromMatrixPosition(de.matrixWorld),re.setFromMatrixPosition(_e.matrixWorld);let Ge=K.distanceTo(re),$e=de.projectionMatrix.elements,ut=_e.projectionMatrix.elements,zt=$e[14]/($e[10]-1),ct=$e[14]/($e[10]+1),Tt=($e[9]+1)/$e[5],Zt=($e[9]-1)/$e[5],wt=($e[8]-1)/$e[0],bt=(ut[8]+1)/ut[0],_t=zt*wt,ln=zt*bt,rt=Ge/(-wt+bt),an=rt*-wt;if(de.matrixWorld.decompose(ae.position,ae.quaternion,ae.scale),ae.translateX(an),ae.translateZ(rt),ae.matrixWorld.compose(ae.position,ae.quaternion,ae.scale),ae.matrixWorldInverse.copy(ae.matrixWorld).invert(),$e[10]===-1)ae.projectionMatrix.copy(de.projectionMatrix),ae.projectionMatrixInverse.copy(de.projectionMatrixInverse);else{let se=zt+rt,mn=ct+rt,nn=_t-an,W=ln+(Ge-an),w=Tt*ct/mn*se,ue=Zt*ct/mn*se;ae.projectionMatrix.makePerspective(nn,W,w,ue,se,mn),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert()}}function ne(ae,de){de===null?ae.matrixWorld.copy(ae.matrix):ae.matrixWorld.multiplyMatrices(de.matrixWorld,ae.matrix),ae.matrixWorldInverse.copy(ae.matrixWorld).invert()}this.updateCamera=function(ae){if(r===null)return;let de=ae.near,_e=ae.far;g.texture!==null&&(g.depthNear>0&&(de=g.depthNear),g.depthFar>0&&(_e=g.depthFar)),E.near=U.near=z.near=de,E.far=U.far=z.far=_e,(M!==E.near||O!==E.far)&&(r.updateRenderState({depthNear:E.near,depthFar:E.far}),M=E.near,O=E.far),E.layers.mask=ae.layers.mask|6,z.layers.mask=E.layers.mask&-5,U.layers.mask=E.layers.mask&-3;let Ge=ae.parent,$e=E.cameras;ne(E,Ge);for(let ut=0;ut<$e.length;ut++)ne($e[ut],Ge);$e.length===2?J(E,z,U):E.projectionMatrix.copy(z.projectionMatrix),I===null&&ae.isPerspectiveCamera&&(I={camera:ae,fov:ae.fov,zoom:ae.zoom}),Te(ae,E,Ge)};function Te(ae,de,_e){_e===null?ae.matrix.copy(de.matrixWorld):(ae.matrix.copy(_e.matrixWorld),ae.matrix.invert(),ae.matrix.multiply(de.matrixWorld)),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.updateMatrixWorld(!0),ae.projectionMatrix.copy(de.projectionMatrix),ae.projectionMatrixInverse.copy(de.projectionMatrixInverse),ae.isPerspectiveCamera&&(ae.fov=au*2*Math.atan(1/ae.projectionMatrix.elements[5]),ae.zoom=1)}this.getCamera=function(){return E},this.getFoveation=function(){if(!(h===null&&v===null))return u},this.setFoveation=function(ae){u=ae,h!==null&&(h.fixedFoveation=ae),v!==null&&v.fixedFoveation!==void 0&&(v.fixedFoveation=ae)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(E)},this.getCameraTexture=function(ae){return m[ae]};let fe=null;function pe(ae,de){if(d=de.getViewerPose(l||s),y=de,d!==null){let _e=d.views;v!==null&&(e.setRenderTargetFramebuffer(_,v.framebuffer),e.setRenderTarget(_));let Ge=!1;_e.length!==E.cameras.length&&(E.cameras.length=0,Ge=!0);for(let ct=0;ct<_e.length;ct++){let Tt=_e[ct],Zt=null;if(v!==null)Zt=v.getViewport(Tt);else{let bt=f.getViewSubImage(h,Tt);Zt=bt.viewport,ct===0&&(e.setRenderTargetTextures(_,bt.colorTexture,bt.depthStencilTexture),e.setRenderTarget(_))}let wt=Y[ct];wt===void 0&&(wt=new er,wt.layers.enable(ct),wt.viewport=new fi,Y[ct]=wt),wt.matrix.fromArray(Tt.transform.matrix),wt.matrix.decompose(wt.position,wt.quaternion,wt.scale),wt.projectionMatrix.fromArray(Tt.projectionMatrix),wt.projectionMatrixInverse.copy(wt.projectionMatrix).invert(),wt.viewport.set(Zt.x,Zt.y,Zt.width,Zt.height),ct===0&&(E.matrix.copy(wt.matrix),E.matrix.decompose(E.position,E.quaternion,E.scale)),Ge===!0&&E.cameras.push(wt)}let $e=r.enabledFeatures;if($e&&$e.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&T){f=i.getBinding();let ct=f.getDepthInformation(_e[0]);ct&&ct.isValid&&ct.texture&&g.init(ct,r.renderState)}if($e&&$e.includes("camera-access")&&T){e.state.unbindTexture(),f=i.getBinding();for(let ct=0;ct<_e.length;ct++){let Tt=_e[ct].camera;if(Tt){let Zt=m[Tt];Zt||(Zt=new bl,m[Tt]=Zt);let wt=f.getCameraImage(Tt);Zt.sourceTexture=wt}}}}for(let _e=0;_e<p.length;_e++){let Ge=S[_e],$e=p[_e];Ge!==null&&$e!==void 0&&$e.update(Ge,de,l||s)}fe&&fe(ae,de),de.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:de}),y=null}let Fe=new $0;Fe.setAnimationLoop(pe),this.setAnimationLoop=function(ae){fe=ae},this.dispose=function(){}}},_b=new $n,nv=new un;nv.set(-1,0,0,0,1,0,0,0,1);function Mb(n,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function i(g,m){m.color.getRGB(g.fogColor.value,Sh(n)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,L,F,_){m.isNodeMaterial?m.uniformsNeedUpdate=!1:m.isMeshBasicMaterial?a(g,m):m.isMeshLambertMaterial?(a(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(a(g,m),f(g,m)):m.isMeshPhongMaterial?(a(g,m),d(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(a(g,m),h(g,m),m.isMeshPhysicalMaterial&&v(g,m,_)):m.isMeshMatcapMaterial?(a(g,m),y(g,m)):m.isMeshDepthMaterial?a(g,m):m.isMeshDistanceMaterial?(a(g,m),T(g,m)):m.isMeshNormalMaterial?a(g,m):m.isLineBasicMaterial?(s(g,m),m.isLineDashedMaterial&&o(g,m)):m.isPointsMaterial?u(g,m,L,F):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function a(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===pr&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===pr&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let L=e.get(m),F=L.envMap,_=L.envMapRotation;F&&(g.envMap.value=F,g.envMapRotation.value.setFromMatrix4(_b.makeRotationFromEuler(_)).transpose(),F.isCubeTexture&&F.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(nv),g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap&&(g.lightMap.value=m.lightMap,g.lightMapIntensity.value=m.lightMapIntensity,t(m.lightMap,g.lightMapTransform)),m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function s(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function o(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function u(g,m,L,F){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*L,g.scale.value=F*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function d(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function f(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function h(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function v(g,m,L){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===pr&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.retroreflectivity>0&&(g.retroreflectivity.value=m.retroreflectivity),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=L.texture,g.transmissionSamplerSize.value.set(L.width,L.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function y(g,m){m.matcap&&(g.matcap.value=m.matcap)}function T(g,m){let L=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(L.matrixWorld),g.nearDistance.value=L.shadow.camera.near,g.farDistance.value=L.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Sb(n,e,t,i){let r={},a={},s=[],o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function u(_,p){let S=p.program;i.uniformBlockBinding(_,S)}function l(_,p){let S=r[_.id];S===void 0&&(g(_),S=d(_),r[_.id]=S,_.addEventListener("dispose",L));let B=p.program;i.updateUBOMapping(_,B);let b=e.render.frame;a[_.id]!==b&&(h(_),a[_.id]=b)}function d(_){let p=f();_.__bindingPointIndex=p;let S=n.createBuffer(),B=_.__size,b=_.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,B,b),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,p,S),S}function f(){for(let _=0;_<o;_++)if(s.indexOf(_)===-1)return s.push(_),_;return sn("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(_){let p=r[_.id],S=_.uniforms,B=_.__cache;n.bindBuffer(n.UNIFORM_BUFFER,p);for(let b=0,I=S.length;b<I;b++){let z=S[b];if(Array.isArray(z))for(let U=0,Y=z.length;U<Y;U++)v(z[U],b,U,B);else v(z,b,0,B)}n.bindBuffer(n.UNIFORM_BUFFER,null)}function v(_,p,S,B){if(T(_,p,S,B)===!0){let b=_.__offset,I=_.value;if(Array.isArray(I)){let z=0;for(let U=0;U<I.length;U++){let Y=I[U],E=m(Y);y(Y,_.__data,z),typeof Y!="number"&&typeof Y!="boolean"&&!Y.isMatrix3&&!ArrayBuffer.isView(Y)&&(z+=E.storage/Float32Array.BYTES_PER_ELEMENT)}}else y(I,_.__data,0);n.bufferSubData(n.UNIFORM_BUFFER,b,_.__data)}}function y(_,p,S){typeof _=="number"||typeof _=="boolean"?p[0]=_:_.isMatrix3?(p[0]=_.elements[0],p[1]=_.elements[1],p[2]=_.elements[2],p[3]=0,p[4]=_.elements[3],p[5]=_.elements[4],p[6]=_.elements[5],p[7]=0,p[8]=_.elements[6],p[9]=_.elements[7],p[10]=_.elements[8],p[11]=0):ArrayBuffer.isView(_)?p.set(new _.constructor(_.buffer,_.byteOffset,p.length)):_.toArray(p,S)}function T(_,p,S,B){let b=_.value,I=p+"_"+S;if(B[I]===void 0)return typeof b=="number"||typeof b=="boolean"?B[I]=b:ArrayBuffer.isView(b)?B[I]=b.slice():B[I]=b.clone(),!0;{let z=B[I];if(typeof b=="number"||typeof b=="boolean"){if(z!==b)return B[I]=b,!0}else{if(ArrayBuffer.isView(b))return!0;if(z.equals(b)===!1)return z.copy(b),!0}}return!1}function g(_){let p=_.uniforms,S=0,B=16;for(let I=0,z=p.length;I<z;I++){let U=Array.isArray(p[I])?p[I]:[p[I]];for(let Y=0,E=U.length;Y<E;Y++){let M=U[Y],O=Array.isArray(M.value)?M.value:[M.value];for(let H=0,ee=O.length;H<ee;H++){let j=O[H],K=m(j),re=S%B,J=re%K.boundary,ne=re+J;S+=J,ne!==0&&B-ne<K.storage&&(S+=B-ne),M.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=S,S+=K.storage}}}let b=S%B;return b>0&&(S+=B-b),_.__size=S,_.__cache={},this}function m(_){let p={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(p.boundary=4,p.storage=4):_.isVector2?(p.boundary=8,p.storage=8):_.isVector3||_.isColor?(p.boundary=16,p.storage=12):_.isVector4?(p.boundary=16,p.storage=16):_.isMatrix3?(p.boundary=48,p.storage=48):_.isMatrix4?(p.boundary=64,p.storage=64):_.isTexture?rn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(p.boundary=16,p.storage=_.byteLength):rn("WebGLRenderer: Unsupported uniform value type.",_),p}function L(_){let p=_.target;p.removeEventListener("dispose",L);let S=s.indexOf(p.__bindingPointIndex);s.splice(S,1),n.deleteBuffer(r[p.id]),delete r[p.id],delete a[p.id]}function F(){for(let _ in r)n.deleteBuffer(r[_]);s=[],r={},a={}}return{bind:u,update:l,dispose:F}}var bb=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Ia=null;function wb(){return Ia===null&&(Ia=new _l(bb,16,16,xs,oa),Ia.name="DFG_LUT",Ia.minFilter=Hi,Ia.magFilter=Hi,Ia.wrapS=_a,Ia.wrapT=_a,Ia.generateMipmaps=!1,Ia.needsUpdate=!0),Ia}var Id=class{constructor(e={}){let{canvas:t=g0(),context:i=null,depth:r=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:l=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:h=!1,outputBufferType:v=Cr}=e;this.isWebGLRenderer=!0;let y;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");y=i.getContextAttributes().alpha}else y=s;let T=v,g=new Set([Wu,Hu,Gu]),m=new Set([Cr,sa,Io,Co,ku,zu]),L=new Uint32Array(4),F=new Int32Array(4),_=new ge,p=null,S=null,B=[],b=[],I=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=aa,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let z=this,U=!1,Y=null,E=null,M=null,O=null;this._outputColorSpace=hr;let H=0,ee=0,j=null,K=-1,re=null,J=new fi,ne=new fi,Te=null,fe=new vn(0),pe=0,Fe=t.width,ae=t.height,de=1,_e=null,Ge=null,$e=new fi(0,0,Fe,ae),ut=new fi(0,0,Fe,ae),zt=!1,ct=new xo,Tt=!1,Zt=!1,wt=new $n,bt=new ge,_t=new fi,ln={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},rt=!1;function an(){return j===null?de:1}let se=i;function mn(D,le){return t.getContext(D,le)}let nn,W,w,ue,ye,we,ze,Ye,Re,Ae,Ne,je,Ve,qe,ot,pt,He,ie,Oe,Pe,nt,dt,Be;try{let D={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:u,preserveDrawingBuffer:l,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"186"}`),t.addEventListener("webglcontextlost",cn,!1),t.addEventListener("webglcontextrestored",dn,!1),t.addEventListener("webglcontextcreationerror",Fn,!1),se===null){let le="webgl2";if(se=mn(le,D),se===null)throw mn(le)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Rt()}catch(D){throw t.removeEventListener("webglcontextlost",cn,!1),t.removeEventListener("webglcontextrestored",dn,!1),t.removeEventListener("webglcontextcreationerror",Fn,!1),sn("WebGLRenderer: "+D.message),D}function Rt(){nn=new PM(se),nn.init(),nt=new gb(se,nn),W=new MM(se,nn,e,nt),w=new mb(se,nn),W.reversedDepthBuffer&&h&&w.buffers.depth.setReversed(!0),E=se.createFramebuffer(),M=se.createFramebuffer(),O=se.createFramebuffer(),ue=new NM(se),ye=new tb,we=new vb(se,nn,w,ye,W,nt,ue),ze=new RM(z),Ye=new Fy(se),dt=new xM(se,Ye),Re=new LM(se,Ye,ue,dt),Ae=new FM(se,Re,Ye,dt,ue),ie=new UM(se,W,we),ot=new SM(ye),Ne=new eb(z,ze,nn,W,dt,ot),je=new Mb(z,ye),Ve=new ib,qe=new cb(nn),He=new yM(z,ze,w,Ae,y,u),pt=new pb(z,Ae,W),Be=new Sb(se,ue,W,w),Oe=new _M(se,nn,ue),Pe=new DM(se,nn,ue),ue.programs=Ne.programs,z.capabilities=W,z.extensions=nn,z.properties=ye,z.renderLists=Ve,z.shadowMap=pt,z.state=w,z.info=ue}T!==Cr&&(I=new BM(T,t.width,t.height,o,r,a));let vt=new Xh(z,se);this.xr=vt,this.getContext=function(){return se},this.getContextAttributes=function(){return se.getContextAttributes()},this.forceContextLoss=function(){let D=nn.get("WEBGL_lose_context");D&&D.loseContext()},this.forceContextRestore=function(){let D=nn.get("WEBGL_lose_context");D&&D.restoreContext()},this.getPixelRatio=function(){return de},this.setPixelRatio=function(D){D!==void 0&&(de=D,this.setSize(Fe,ae,!1))},this.getSize=function(D){return D.set(Fe,ae)},this.setSize=function(D,le,he=!0){if(vt.isPresenting){rn("WebGLRenderer: Can't change size while VR device is presenting.");return}Fe=D,ae=le,t.width=Math.floor(D*de),t.height=Math.floor(le*de),he===!0&&(t.style.width=D+"px",t.style.height=le+"px"),I!==null&&I.setSize(t.width,t.height),this.setViewport(0,0,D,le)},this.getDrawingBufferSize=function(D){return D.set(Fe*de,ae*de).floor()},this.setDrawingBufferSize=function(D,le,he){Fe=D,ae=le,de=he,t.width=Math.floor(D*he),t.height=Math.floor(le*he),this.setViewport(0,0,D,le)},this.setEffects=function(D){if(T===Cr){sn("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(D){for(let le=0;le<D.length;le++)if(D[le].isOutputPass===!0){rn("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}I.setEffects(D||[])},this.getCurrentViewport=function(D){return D.copy(J)},this.getViewport=function(D){return D.copy($e)},this.setViewport=function(D,le,he,Me){D.isVector4?$e.set(D.x,D.y,D.z,D.w):$e.set(D,le,he,Me),w.viewport(J.copy($e).multiplyScalar(de).round())},this.getScissor=function(D){return D.copy(ut)},this.setScissor=function(D,le,he,Me){D.isVector4?ut.set(D.x,D.y,D.z,D.w):ut.set(D,le,he,Me),w.scissor(ne.copy(ut).multiplyScalar(de).round())},this.getScissorTest=function(){return zt},this.setScissorTest=function(D){w.setScissorTest(zt=D)},this.setOpaqueSort=function(D){_e=D},this.setTransparentSort=function(D){Ge=D},this.getClearColor=function(D){return D.copy(He.getClearColor())},this.setClearColor=function(){He.setClearColor(...arguments)},this.getClearAlpha=function(){return He.getClearAlpha()},this.setClearAlpha=function(){He.setClearAlpha(...arguments)},this.clear=function(D=!0,le=!0,he=!0){let Me=0;if(D){let Se=!1;if(j!==null){let ke=j.texture.format;Se=g.has(ke)}if(Se){let ke=j.texture.type,et=m.has(ke),Je=He.getClearColor(),ft=He.getClearAlpha(),Dt=Je.r,tn=Je.g,$t=Je.b;et?(L[0]=Dt,L[1]=tn,L[2]=$t,L[3]=ft,se.clearBufferuiv(se.COLOR,0,L)):(F[0]=Dt,F[1]=tn,F[2]=$t,F[3]=ft,se.clearBufferiv(se.COLOR,0,F))}else Me|=se.COLOR_BUFFER_BIT}le&&(Me|=se.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),he&&(Me|=se.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Me!==0&&se.clear(Me)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(D){D.setRenderer(this),Y=D},this.dispose=function(){t.removeEventListener("webglcontextlost",cn,!1),t.removeEventListener("webglcontextrestored",dn,!1),t.removeEventListener("webglcontextcreationerror",Fn,!1),He.dispose(),Ve.dispose(),qe.dispose(),ye.dispose(),ze.dispose(),Ae.dispose(),dt.dispose(),Be.dispose(),Ne.dispose(),vt.dispose(),vt.removeEventListener("sessionstart",en),vt.removeEventListener("sessionend",xt),ni.stop()};function cn(D){D.preventDefault(),_h("WebGLRenderer: Context Lost."),U=!0}function dn(){_h("WebGLRenderer: Context Restored."),U=!1;let D=ue.autoReset,le=pt.enabled,he=pt.autoUpdate,Me=pt.needsUpdate,Se=pt.type;Rt(),ue.autoReset=D,pt.enabled=le,pt.autoUpdate=he,pt.needsUpdate=Me,pt.type=Se}function Fn(D){sn("WebGLRenderer: A WebGL context could not be created. Reason: ",D.statusMessage)}function Dn(D){let le=D.target;le.removeEventListener("dispose",Dn),vi(le)}function vi(D){rr(D),ye.remove(D)}function rr(D){let le=ye.get(D).programs;le!==void 0&&(le.forEach(function(he){Ne.releaseProgram(he)}),D.isShaderMaterial&&Ne.releaseShaderCache(D))}this.renderBufferDirect=function(D,le,he,Me,Se,ke){le===null&&(le=ln);let et=Se.isMesh&&Se.matrixWorld.determinantAffine()<0,Je=Ei(D,le,he,Me,Se);w.setMaterial(Me,et);let ft=he.index,Dt=1;if(Me.wireframe===!0){if(ft=Re.getWireframeAttribute(he),ft===void 0)return;Dt=2}let tn=he.drawRange,$t=he.attributes.position,Et=tn.start*Dt,hn=(tn.start+tn.count)*Dt;ke!==null&&(Et=Math.max(Et,ke.start*Dt),hn=Math.min(hn,(ke.start+ke.count)*Dt)),ft!==null?(Et=Math.max(Et,0),hn=Math.min(hn,ft.count)):$t!=null&&(Et=Math.max(Et,0),hn=Math.min(hn,$t.count));let Vn=hn-Et;if(Vn<0||Vn===1/0)return;dt.setup(Se,Me,Je,he,ft);let It,Qt=Oe;if(ft!==null&&(It=Ye.get(ft),Qt=Pe,Qt.setIndex(It)),Se.isMesh)Me.wireframe===!0?(w.setLineWidth(Me.wireframeLinewidth*an()),Qt.setMode(se.LINES)):Qt.setMode(se.TRIANGLES);else if(Se.isLine){let jt=Me.linewidth;jt===void 0&&(jt=1),w.setLineWidth(jt*an()),Se.isLineSegments?Qt.setMode(se.LINES):Se.isLineLoop?Qt.setMode(se.LINE_LOOP):Qt.setMode(se.LINE_STRIP)}else Se.isPoints?Qt.setMode(se.POINTS):Se.isSprite&&Qt.setMode(se.TRIANGLES);if(Se.isBatchedMesh)if(nn.get("WEBGL_multi_draw"))Qt.renderMultiDraw(Se._multiDrawStarts,Se._multiDrawCounts,Se._multiDrawCount);else{let jt=Se._multiDrawStarts,Le=Se._multiDrawCounts,An=Se._multiDrawCount,pn=ft?Ye.get(ft).bytesPerElement:1,yi=ye.get(Me).currentProgram.getUniforms();for(let or=0;or<An;or++)yi.setValue(se,"_gl_DrawID",or),Qt.render(jt[or]/pn,Le[or])}else if(Se.isInstancedMesh)Qt.renderInstances(Et,Vn,Se.count);else if(he.isInstancedBufferGeometry){let jt=he._maxInstanceCount!==void 0?he._maxInstanceCount:1/0,Le=Math.min(he.instanceCount,jt);Qt.renderInstances(Et,Vn,Le)}else Qt.render(Et,Vn)};function yn(D,le,he,Me){Y!==null&&D.isNodeMaterial&&Y.setObject(Me,D),Tt===!0&&ot.setState(D,he,!1),D.transparent===!0&&D.side===Ir&&D.forceSinglePass===!1?(D.side=pr,D.needsUpdate=!0,Bn(D,le,Me),D.side=ms,D.needsUpdate=!0,Bn(D,le,Me),D.side=Ir):Bn(D,le,Me)}this.compile=function(D,le,he=null){he===null&&(he=D),Y!==null&&Y.renderStart(D,le,he),S=qe.get(he),S.init(le),b.push(S),he.traverseVisible(function(Se){Se.isLight&&Se.layers.test(le.layers)&&(S.pushLight(Se),Se.castShadow&&S.pushShadow(Se))}),D!==he&&D.traverseVisible(function(Se){Se.isLight&&Se.layers.test(le.layers)&&(S.pushLight(Se),Se.castShadow&&S.pushShadow(Se))}),S.setupLights(),Y!==null&&Y.updateLights(S.state.lightsArray),Zt=this.localClippingEnabled,Tt=ot.init(this.clippingPlanes,Zt),Tt===!0&&ot.setGlobalState(this.clippingPlanes,le),Y!==null&&pt.render(S.state.shadowsArray,he,le);let Me=new Set;return D.traverse(function(Se){if(!(Se.isMesh||Se.isPoints||Se.isLine||Se.isSprite))return;let ke=Se.material;if(ke)if(Array.isArray(ke))for(let et=0;et<ke.length;et++){let Je=ke[et];yn(Je,he,le,Se),Me.add(Je)}else yn(ke,he,le,Se),Me.add(ke)}),S=b.pop(),Y!==null&&Y.renderEnd(),Me},this.compileAsync=function(D,le,he=null){let Me=this.compile(D,le,he);return new Promise(Se=>{function ke(){if(Me.forEach(function(et){let ft=ye.get(et).currentProgram;(ft===void 0||ft.isReady())&&Me.delete(et)}),Me.size===0){Se(D);return}setTimeout(ke,10)}nn.get("KHR_parallel_shader_compile")!==null?ke():setTimeout(ke,10)})};let En=null;function Yi(D){En&&En(D)}function en(){ni.stop()}function xt(){ni.start()}let ni=new $0;ni.setAnimationLoop(Yi),typeof self<"u"&&ni.setContext(self),this.setAnimationLoop=function(D){En=D,vt.setAnimationLoop(D),D===null?ni.stop():ni.start()},vt.addEventListener("sessionstart",en),vt.addEventListener("sessionend",xt),this.render=function(D,le){if(le!==void 0&&le.isCamera!==!0){sn("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(U===!0)return;Y!==null&&Y.renderStart(D,le);let he=vt.enabled===!0&&vt.isPresenting===!0,Me=I!==null&&(j===null||he)&&I.begin(z,j);if(D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),le.parent===null&&le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),vt.enabled===!0&&vt.isPresenting===!0&&(I===null||I.isCompositing()===!1)&&(vt.cameraAutoUpdate===!0&&vt.updateCamera(le),le=vt.getCamera()),D.isScene===!0&&D.onBeforeRender(z,D,le,j),S=qe.get(D,b.length),S.init(le),S.state.textureUnits=we.getTextureUnits(),b.push(S),wt.multiplyMatrices(le.projectionMatrix,le.matrixWorldInverse),ct.setFromProjectionMatrix(wt,ra,le.reversedDepth),Zt=this.localClippingEnabled,Tt=ot.init(this.clippingPlanes,Zt),p=Ve.get(D,B.length),p.init(),B.push(p),vt.enabled===!0&&vt.isPresenting===!0){let et=z.xr.getDepthSensingMesh();et!==null&&fn(et,le,-1/0,z.sortObjects)}fn(D,le,0,z.sortObjects),p.finish(),Y!==null&&Y.updateLights(S.state.lightsArray),z.sortObjects===!0&&p.sort(_e,Ge),rt=vt.enabled===!1||vt.isPresenting===!1||vt.hasDepthSensing()===!1,rt&&He.addToRenderList(p,D),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Tt===!0&&ot.beginShadows();let Se=S.state.shadowsArray;if(pt.render(Se,D,le),Tt===!0&&ot.endShadows(),(Me&&I.hasRenderPass())===!1){let et=p.opaque,Je=p.transmissive;if(S.setupLights(),le.isArrayCamera){let ft=le.cameras;if(Je.length>0)for(let Dt=0,tn=ft.length;Dt<tn;Dt++){let $t=ft[Dt];qi(et,Je,D,$t)}rt&&He.render(D);for(let Dt=0,tn=ft.length;Dt<tn;Dt++){let $t=ft[Dt];bi(p,D,$t,$t.viewport)}}else Je.length>0&&qi(et,Je,D,le),rt&&He.render(D),bi(p,D,le)}j!==null&&ee===0&&(we.updateMultisampleRenderTarget(j),we.updateRenderTargetMipmap(j)),Me&&I.end(z),D.isScene===!0&&D.onAfterRender(z,D,le),dt.resetDefaultState(),K=-1,re=null,b.pop(),b.length>0?(S=b[b.length-1],we.setTextureUnits(S.state.textureUnits),Tt===!0&&ot.setGlobalState(z.clippingPlanes,S.state.camera)):S=null,B.pop(),B.length>0?p=B[B.length-1]:p=null,Y!==null&&Y.renderEnd()};function fn(D,le,he,Me){if(D.visible===!1)return;if(D.layers.test(le.layers)){if(D.isGroup)he=D.renderOrder;else if(D.isLOD)D.autoUpdate===!0&&D.update(le);else if(D.isLightProbeGrid)S.pushLightProbeGrid(D);else if(D.isLight)S.pushLight(D),D.castShadow&&S.pushShadow(D);else if(D.isSprite){if(!D.frustumCulled||D.intersectsFrustum(ct)){Me&&_t.setFromMatrixPosition(D.matrixWorld).applyMatrix4(wt);let et=Ae.update(D),Je=D.material;Je.visible&&p.push(D,et,Je,he,_t.z,null,le)}}else if((D.isMesh||D.isLine||D.isPoints)&&(!D.frustumCulled||D.intersectsFrustum(ct))){let et=Ae.update(D),Je=D.material;if(Me&&(D.boundingSphere!==void 0?(D.boundingSphere===null&&D.computeBoundingSphere(),_t.copy(D.boundingSphere.center)):(et.boundingSphere===null&&et.computeBoundingSphere(),_t.copy(et.boundingSphere.center)),_t.applyMatrix4(D.matrixWorld).applyMatrix4(wt)),Array.isArray(Je)){let ft=et.groups;for(let Dt=0,tn=ft.length;Dt<tn;Dt++){let $t=ft[Dt],Et=Je[$t.materialIndex];Et&&Et.visible&&p.push(D,et,Et,he,_t.z,$t,le)}}else Je.visible&&p.push(D,et,Je,he,_t.z,null,le)}}let ke=D.children;for(let et=0,Je=ke.length;et<Je;et++)fn(ke[et],le,he,Me)}function bi(D,le,he,Me){let{opaque:Se,transmissive:ke,transparent:et}=D;S.setupLightsView(he),Tt===!0&&ot.setGlobalState(z.clippingPlanes,he),Me&&w.viewport(J.copy(Me)),Se.length>0&&wi(Se,le,he),ke.length>0&&wi(ke,le,he),et.length>0&&wi(et,le,he),w.buffers.depth.setTest(!0),w.buffers.depth.setMask(!0),w.buffers.color.setMask(!0),w.setPolygonOffset(!1)}function qi(D,le,he,Me){if((he.isScene===!0?he.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[Me.id]===void 0){let Et=nn.has("EXT_color_buffer_half_float")||nn.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[Me.id]=new Ar(1,1,{generateMipmaps:!0,type:Et?oa:Cr,minFilter:gs,samples:Math.max(4,W.samples),stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Ln.workingColorSpace})}let ke=S.state.transmissionRenderTarget[Me.id],et=Me.viewport||J;ke.setSize(et.z*z.transmissionResolutionScale,et.w*z.transmissionResolutionScale);let Je=z.getRenderTarget(),ft=z.getActiveCubeFace(),Dt=z.getActiveMipmapLevel();z.setRenderTarget(ke),z.getClearColor(fe),pe=z.getClearAlpha(),pe<1&&z.setClearColor(16777215,.5),z.clear(),rt&&He.render(he);let tn=z.toneMapping;z.toneMapping=aa;let $t=Me.viewport;if(Me.viewport!==void 0&&(Me.viewport=void 0),S.setupLightsView(Me),Tt===!0&&ot.setGlobalState(z.clippingPlanes,Me),wi(D,he,Me),we.updateMultisampleRenderTarget(ke),we.updateRenderTargetMipmap(ke),nn.has("WEBGL_multisampled_render_to_texture")===!1){let Et=!1;for(let hn=0,Vn=le.length;hn<Vn;hn++){let It=le[hn],{object:Qt,geometry:jt,material:Le,group:An}=It;if(Le.side===Ir&&Qt.layers.test(Me.layers)){let pn=Le.side;Le.side=pr,Le.needsUpdate=!0,gi(Qt,he,Me,jt,Le,An),Le.side=pn,Le.needsUpdate=!0,Et=!0}}Et===!0&&(we.updateMultisampleRenderTarget(ke),we.updateRenderTargetMipmap(ke))}z.setRenderTarget(Je,ft,Dt),z.setClearColor(fe,pe),$t!==void 0&&(Me.viewport=$t),z.toneMapping=tn}function wi(D,le,he){let Me=le.isScene===!0?le.overrideMaterial:null;for(let Se=0,ke=D.length;Se<ke;Se++){let et=D[Se],{object:Je,geometry:ft,group:Dt}=et,tn=et.material;tn.allowOverride===!0&&Me!==null&&(tn=Me),Je.layers.test(he.layers)&&gi(Je,le,he,ft,tn,Dt)}}function gi(D,le,he,Me,Se,ke){Y!==null&&Se.isNodeMaterial&&Y.setObject(D,Se),D.onBeforeRender(z,le,he,Me,Se,ke),D.modelViewMatrix.multiplyMatrices(he.matrixWorldInverse,D.matrixWorld),D.normalMatrix.getNormalMatrix(D.modelViewMatrix),Se.onBeforeRender(z,le,he,Me,D,ke),Se.transparent===!0&&Se.side===Ir&&Se.forceSinglePass===!1?(Se.side=pr,Se.needsUpdate=!0,z.renderBufferDirect(he,le,Me,Se,D,ke),Se.side=ms,Se.needsUpdate=!0,z.renderBufferDirect(he,le,Me,Se,D,ke),Se.side=Ir):z.renderBufferDirect(he,le,Me,Se,D,ke),D.onAfterRender(z,le,he,Me,Se,ke)}function Bn(D,le,he){le.isScene!==!0&&(le=ln);let Me=ye.get(D),Se=S.state.lights,ke=S.state.shadowsArray,et=Se.state.version,Je=Ne.getParameters(D,Se.state,ke,le,he,S.state.lightProbeGridArray),ft=Ne.getProgramCacheKey(Je),Dt=Me.programs;Me.environment=D.isMeshStandardMaterial||D.isMeshLambertMaterial||D.isMeshPhongMaterial?le.environment:null,Me.fog=le.fog;let tn=D.isMeshStandardMaterial||D.isMeshLambertMaterial&&!D.envMap||D.isMeshPhongMaterial&&!D.envMap;Me.envMap=ze.get(D.envMap||Me.environment,tn),Me.envMapRotation=Me.environment!==null&&D.envMap===null?le.environmentRotation:D.envMapRotation,Dt===void 0&&(D.addEventListener("dispose",Dn),Dt=new Map,Me.programs=Dt);let $t=Dt.get(ft);if($t!==void 0){if(Me.currentProgram===$t&&Me.lightsStateVersion===et)return la(D,Je),$t}else Je.uniforms=Ne.getUniforms(D),Y!==null&&D.isNodeMaterial&&Y.build(D,he,Je),D.onBeforeCompile(Je,z),$t=Ne.acquireProgram(Je,ft),Dt.set(ft,$t),Me.uniforms=Je.uniforms;let Et=Me.uniforms;return(!D.isShaderMaterial&&!D.isRawShaderMaterial||D.clipping===!0)&&(Et.clippingPlanes=ot.uniform),la(D,Je),Me.needsLights=sr(D),Me.lightsStateVersion=et,Me.needsLights&&(Et.ambientLightColor.value=Se.state.ambient,Et.lightProbe.value=Se.state.probe,Et.sunLights.value=Se.state.sun,Et.sunLightShadows.value=Se.state.sunShadow,Et.directionalLights.value=Se.state.directional,Et.directionalLightShadows.value=Se.state.directionalShadow,Et.spotLights.value=Se.state.spot,Et.spotLightShadows.value=Se.state.spotShadow,Et.rectAreaLights.value=Se.state.rectArea,Et.ltc_1.value=Se.state.rectAreaLTC1,Et.ltc_2.value=Se.state.rectAreaLTC2,Et.pointLights.value=Se.state.point,Et.pointLightShadows.value=Se.state.pointShadow,Et.hemisphereLights.value=Se.state.hemi,Et.sunShadowMatrix.value=Se.state.sunShadowMatrix,Et.sunShadowCascade.value=Se.state.sunShadowCascade,Et.directionalShadowMatrix.value=Se.state.directionalShadowMatrix,Et.spotLightMatrix.value=Se.state.spotLightMatrix,Et.spotLightMap.value=Se.state.spotLightMap,Et.pointShadowMatrix.value=Se.state.pointShadowMatrix),Me.lightProbeGrid=S.state.lightProbeGridArray.length>0,Me.currentProgram=$t,Me.uniformsList=null,$t}function ar(D){if(D.uniformsList===null){let le=D.currentProgram.getUniforms();D.uniformsList=Do.seqWithValue(le.seq,D.uniforms)}return D.uniformsList}function la(D,le){let he=ye.get(D);he.outputColorSpace=le.outputColorSpace,he.batching=le.batching,he.batchingColor=le.batchingColor,he.instancing=le.instancing,he.instancingColor=le.instancingColor,he.instancingMorph=le.instancingMorph,he.skinning=le.skinning,he.morphTargets=le.morphTargets,he.morphNormals=le.morphNormals,he.morphColors=le.morphColors,he.morphTargetsCount=le.morphTargetsCount,he.numClippingPlanes=le.numClippingPlanes,he.numIntersection=le.numClipIntersection,he.vertexAlphas=le.vertexAlphas,he.vertexTangents=le.vertexTangents,he.toneMapping=le.toneMapping}function Za(D,le){if(D.length===0)return null;if(D.length===1)return D[0].texture!==null?D[0]:null;_.setFromMatrixPosition(le.matrixWorld);for(let he=0,Me=D.length;he<Me;he++){let Se=D[he];if(Se.texture!==null&&Se.boundingBox.containsPoint(_))return Se}return null}function Ei(D,le,he,Me,Se){le.isScene!==!0&&(le=ln),we.resetTextureUnits();let ke=le.fog,et=Me.isMeshStandardMaterial||Me.isMeshLambertMaterial||Me.isMeshPhongMaterial?le.environment:null,Je=j===null?z.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Ln.workingColorSpace,ft=Me.isMeshStandardMaterial||Me.isMeshLambertMaterial&&!Me.envMap||Me.isMeshPhongMaterial&&!Me.envMap,Dt=ze.get(Me.envMap||et,ft),tn=Me.vertexColors===!0&&!!he.attributes.color&&he.attributes.color.itemSize===4,$t=!!he.attributes.tangent&&(!!Me.normalMap||Me.anisotropy>0),Et=!!he.morphAttributes.position,hn=!!he.morphAttributes.normal,Vn=!!he.morphAttributes.color,It=aa;Me.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(It=z.toneMapping);let Qt=he.morphAttributes.position||he.morphAttributes.normal||he.morphAttributes.color,jt=Qt!==void 0?Qt.length:0,Le=ye.get(Me),An=S.state.lights;if(Tt===!0&&(Zt===!0||D!==re)){let kn=D===re&&Me.id===K;ot.setState(Me,D,kn)}let pn=!1;Me.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==An.state.version||Le.outputColorSpace!==Je||Se.isBatchedMesh&&Le.batching===!1||!Se.isBatchedMesh&&Le.batching===!0||Se.isBatchedMesh&&Le.batchingColor===!0&&Se._colorsTexture===null||Se.isBatchedMesh&&Le.batchingColor===!1&&Se._colorsTexture!==null||Se.isInstancedMesh&&Le.instancing===!1||!Se.isInstancedMesh&&Le.instancing===!0||Se.isSkinnedMesh&&Le.skinning===!1||!Se.isSkinnedMesh&&Le.skinning===!0||Se.isInstancedMesh&&Le.instancingColor===!0&&Se.instanceColor===null||Se.isInstancedMesh&&Le.instancingColor===!1&&Se.instanceColor!==null||Se.isInstancedMesh&&Le.instancingMorph===!0&&Se.morphTexture===null||Se.isInstancedMesh&&Le.instancingMorph===!1&&Se.morphTexture!==null||Le.envMap!==Dt||Me.fog===!0&&Le.fog!==ke||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ot.numPlanes||Le.numIntersection!==ot.numIntersection)||Le.vertexAlphas!==tn||Le.vertexTangents!==$t||Le.morphTargets!==Et||Le.morphNormals!==hn||Le.morphColors!==Vn||Le.toneMapping!==It||Le.morphTargetsCount!==jt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(pn=!0):(pn=!0,Le.__version=Me.version);let yi=Le.currentProgram;pn===!0&&(yi=Bn(Me,le,Se),Y&&Me.isNodeMaterial&&Y.onUpdateProgram(Me,yi,Le));let or=!1,Li=!1,vr=!1,Mn=yi.getUniforms(),Yn=Le.uniforms;if(w.useProgram(yi.program)&&(or=!0,Li=!0,vr=!0),Me.id!==K&&(K=Me.id,Li=!0),Le.needsLights){let kn=Za(S.state.lightProbeGridArray,Se);Le.lightProbeGrid!==kn&&(Le.lightProbeGrid=kn,Li=!0)}if(or||re!==D){w.buffers.depth.getReversed()&&D.reversedDepth!==!0&&(D._reversedDepth=!0,D.updateProjectionMatrix()),Mn.setValue(se,"projectionMatrix",D.projectionMatrix),Mn.setValue(se,"viewMatrix",D.matrixWorldInverse);let ki=Mn.map.cameraPosition;ki!==void 0&&ki.setValue(se,bt.setFromMatrixPosition(D.matrixWorld)),W.logarithmicDepthBuffer&&Mn.setValue(se,"logDepthBufFC",2/(Math.log(D.far+1)/Math.LN2)),(Me.isMeshPhongMaterial||Me.isMeshToonMaterial||Me.isMeshLambertMaterial||Me.isMeshBasicMaterial||Me.isMeshStandardMaterial||Me.isShaderMaterial)&&Mn.setValue(se,"isOrthographic",D.isOrthographicCamera===!0),re!==D&&(re=D,Li=!0,vr=!0)}if(Le.needsLights&&(An.state.sunShadowMap.length>0&&Mn.setValue(se,"sunShadowMap",An.state.sunShadowMap,we),An.state.directionalShadowMap.length>0&&Mn.setValue(se,"directionalShadowMap",An.state.directionalShadowMap,we),An.state.spotShadowMap.length>0&&Mn.setValue(se,"spotShadowMap",An.state.spotShadowMap,we),An.state.pointShadowMap.length>0&&Mn.setValue(se,"pointShadowMap",An.state.pointShadowMap,we)),Se.isSkinnedMesh){Mn.setOptional(se,Se,"bindMatrix"),Mn.setOptional(se,Se,"bindMatrixInverse");let kn=Se.skeleton;kn&&(kn.boneTexture===null&&kn.computeBoneTexture(),Mn.setValue(se,"boneTexture",kn.boneTexture,we))}Se.isBatchedMesh&&(Mn.setOptional(se,Se,"batchingTexture"),Mn.setValue(se,"batchingTexture",Se._matricesTexture,we),Mn.setOptional(se,Se,"batchingIdTexture"),Mn.setValue(se,"batchingIdTexture",Se._indirectTexture,we),Mn.setOptional(se,Se,"batchingColorTexture"),Se._colorsTexture!==null&&Mn.setValue(se,"batchingColorTexture",Se._colorsTexture,we));let Zi=he.morphAttributes;if((Zi.position!==void 0||Zi.normal!==void 0||Zi.color!==void 0)&&ie.update(Se,he,yi),(Li||Le.receiveShadow!==Se.receiveShadow)&&(Le.receiveShadow=Se.receiveShadow,Mn.setValue(se,"receiveShadow",Se.receiveShadow)),(Me.isMeshStandardMaterial||Me.isMeshLambertMaterial||Me.isMeshPhongMaterial)&&Me.envMap===null&&le.environment!==null&&(Yn.envMapIntensity.value=le.environmentIntensity),Yn.dfgLUT!==void 0&&(Yn.dfgLUT.value=wb()),Li){if(Mn.setValue(se,"toneMappingExposure",z.toneMappingExposure),Le.needsLights&&mr(Yn,vr),ke&&Me.fog===!0&&je.refreshFogUniforms(Yn,ke),je.refreshMaterialUniforms(Yn,Me,de,ae,S.state.transmissionRenderTarget[D.id]),Le.needsLights&&Le.lightProbeGrid){let kn=Le.lightProbeGrid;Yn.probesSH.value=kn.texture,Yn.probesMin.value.copy(kn.boundingBox.min),Yn.probesMax.value.copy(kn.boundingBox.max),Yn.probesResolution.value.copy(kn.resolution)}Do.upload(se,ar(Le),Yn,we)}if(Me.isShaderMaterial&&Me.uniformsNeedUpdate===!0&&(Do.upload(se,ar(Le),Yn,we),Me.uniformsNeedUpdate=!1),Me.isSpriteMaterial&&Mn.setValue(se,"center",Se.center),Mn.setValue(se,"modelViewMatrix",Se.modelViewMatrix),Mn.setValue(se,"normalMatrix",Se.normalMatrix),Mn.setValue(se,"modelMatrix",Se.matrixWorld),Me.uniformsGroups!==void 0){let kn=Me.uniformsGroups;for(let ki=0,ca=kn.length;ki<ca;ki++){let lr=kn[ki];Be.update(lr,yi),Be.bind(lr,yi)}}return yi}function mr(D,le){D.ambientLightColor.needsUpdate=le,D.lightProbe.needsUpdate=le,D.sunLights.needsUpdate=le,D.sunLightShadows.needsUpdate=le,D.directionalLights.needsUpdate=le,D.directionalLightShadows.needsUpdate=le,D.pointLights.needsUpdate=le,D.pointLightShadows.needsUpdate=le,D.spotLights.needsUpdate=le,D.spotLightShadows.needsUpdate=le,D.rectAreaLights.needsUpdate=le,D.hemisphereLights.needsUpdate=le}function sr(D){return D.isMeshLambertMaterial||D.isMeshToonMaterial||D.isMeshPhongMaterial||D.isMeshStandardMaterial||D.isShadowMaterial||D.isShaderMaterial&&D.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return ee},this.getRenderTarget=function(){return j},this.setRenderTargetTextures=function(D,le,he){let Me=ye.get(D);Me.__autoAllocateDepthBuffer=D.resolveDepthBuffer===!1,Me.__autoAllocateDepthBuffer===!1&&(Me.__useRenderToTexture=!1),ye.get(D.texture).__webglTexture=le,ye.get(D.depthTexture).__webglTexture=Me.__autoAllocateDepthBuffer?void 0:he,Me.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(D,le){let he=ye.get(D);he.__webglFramebuffer=le,he.__useDefaultFramebuffer=le===void 0},this.setRenderTarget=function(D,le=0,he=0){j=D,H=le,ee=he;let Me=null,Se=!1,ke=!1;if(D){let Je=ye.get(D);if(Je.__useDefaultFramebuffer!==void 0){w.bindFramebuffer(se.FRAMEBUFFER,Je.__webglFramebuffer),J.copy(D.viewport),ne.copy(D.scissor),Te=D.scissorTest,w.viewport(J),w.scissor(ne),w.setScissorTest(Te),K=-1;return}else if(Je.__webglFramebuffer===void 0)we.setupRenderTarget(D);else if(Je.__hasExternalTextures)we.rebindTextures(D,ye.get(D.texture).__webglTexture,ye.get(D.depthTexture).__webglTexture);else if(D.depthBuffer){let tn=D.depthTexture;if(Je.__boundDepthTexture!==tn){if(tn!==null&&ye.has(tn)&&(D.width!==tn.image.width||D.height!==tn.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");we.setupDepthRenderbuffer(D)}}let ft=D.texture;(ft.isData3DTexture||ft.isDataArrayTexture||ft.isCompressedArrayTexture)&&(ke=!0);let Dt=ye.get(D).__webglFramebuffer;D.isWebGLCubeRenderTarget?(Array.isArray(Dt[le])?Me=Dt[le][he]:Me=Dt[le],Se=!0):D.samples>0&&we.useMultisampledRTT(D)===!1?Me=ye.get(D).__webglMultisampledFramebuffer:Array.isArray(Dt)?Me=Dt[he]:Me=Dt,J.copy(D.viewport),ne.copy(D.scissor),Te=D.scissorTest}else J.copy($e).multiplyScalar(de).floor(),ne.copy(ut).multiplyScalar(de).floor(),Te=zt;if(he!==0&&(Me=E),w.bindFramebuffer(se.FRAMEBUFFER,Me)&&w.drawBuffers(D,Me),w.viewport(J),w.scissor(ne),w.setScissorTest(Te),Se){let Je=ye.get(D.texture);se.framebufferTexture2D(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_CUBE_MAP_POSITIVE_X+le,Je.__webglTexture,he)}else if(ke){let Je=le;for(let ft=0;ft<D.textures.length;ft++){let Dt=ye.get(D.textures[ft]);se.framebufferTextureLayer(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0+ft,Dt.__webglTexture,he,Je)}}else if(D!==null&&he!==0){let Je=ye.get(D.texture);se.framebufferTexture2D(se.FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_2D,Je.__webglTexture,he)}K=-1};function Vr(D){let le=ye.get(D);return(le.__readFormat!==D.format||le.__readType!==D.type)&&(le.__readFormat=D.format,le.__readType=D.type,le.__formatReadable=W.textureFormatReadable(D.format),le.__typeReadable=W.textureTypeReadable(D.type)),le}this.readRenderTargetPixels=function(D,le,he,Me,Se,ke,et,Je=0){if(!(D&&D.isWebGLRenderTarget)){sn("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ft=ye.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&et!==void 0&&(ft=ft[et]),ft){w.bindFramebuffer(se.FRAMEBUFFER,ft);try{let Dt=D.textures[Je],tn=Dt.format,$t=Dt.type;D.textures.length>1&&se.readBuffer(se.COLOR_ATTACHMENT0+Je);let Et=Vr(Dt);if(Et.__formatReadable===!1){sn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Et.__typeReadable===!1){sn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}le>=0&&le<=D.width-Me&&he>=0&&he<=D.height-Se&&se.readPixels(le,he,Me,Se,nt.convert(tn),nt.convert($t),ke)}finally{let Dt=j!==null?ye.get(j).__webglFramebuffer:null;w.bindFramebuffer(se.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(D,le,he,Me,Se,ke,et,Je=0){if(!(D&&D.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ft=ye.get(D).__webglFramebuffer;if(D.isWebGLCubeRenderTarget&&et!==void 0&&(ft=ft[et]),ft)if(le>=0&&le<=D.width-Me&&he>=0&&he<=D.height-Se){w.bindFramebuffer(se.FRAMEBUFFER,ft);let Dt=D.textures[Je],tn=Dt.format,$t=Dt.type;D.textures.length>1&&se.readBuffer(se.COLOR_ATTACHMENT0+Je);let Et=Vr(Dt);if(Et.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Et.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let hn=se.createBuffer();se.bindBuffer(se.PIXEL_PACK_BUFFER,hn),se.bufferData(se.PIXEL_PACK_BUFFER,ke.byteLength,se.STREAM_READ),se.readPixels(le,he,Me,Se,nt.convert(tn),nt.convert($t),0),se.bindBuffer(se.PIXEL_PACK_BUFFER,null);let Vn=j!==null?ye.get(j).__webglFramebuffer:null;w.bindFramebuffer(se.FRAMEBUFFER,Vn);let It=se.fenceSync(se.SYNC_GPU_COMMANDS_COMPLETE,0);return se.flush(),await x0(se,It,4),se.bindBuffer(se.PIXEL_PACK_BUFFER,hn),se.getBufferSubData(se.PIXEL_PACK_BUFFER,0,ke),se.bindBuffer(se.PIXEL_PACK_BUFFER,null),se.deleteBuffer(hn),se.deleteSync(It),ke}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(D,le=null,he=0){let Me=Math.pow(2,-he),Se=Math.floor(D.image.width*Me),ke=Math.floor(D.image.height*Me),et=le!==null?le.x:0,Je=le!==null?le.y:0;we.setTexture2D(D,0),se.copyTexSubImage2D(se.TEXTURE_2D,he,0,0,et,Je,Se,ke),w.unbindTexture()},this.copyTextureToTexture=function(D,le,he=null,Me=null,Se=0,ke=0){let et,Je,ft,Dt,tn,$t,Et,hn,Vn,It=D.isCompressedTexture?D.mipmaps[ke]:D.image;if(he!==null)et=he.max.x-he.min.x,Je=he.max.y-he.min.y,ft=he.isBox3?he.max.z-he.min.z:1,Dt=he.min.x,tn=he.min.y,$t=he.isBox3?he.min.z:0;else{let Yn=Math.pow(2,-Se);et=Math.floor(It.width*Yn),Je=Math.floor(It.height*Yn),D.isDataArrayTexture?ft=It.depth:D.isData3DTexture?ft=Math.floor(It.depth*Yn):ft=1,Dt=0,tn=0,$t=0}Me!==null?(Et=Me.x,hn=Me.y,Vn=Me.z):(Et=0,hn=0,Vn=0);let Qt=nt.convert(le.format),jt=nt.convert(le.type),Le;le.isData3DTexture?(we.setTexture3D(le,0),Le=se.TEXTURE_3D):le.isDataArrayTexture||le.isCompressedArrayTexture?(we.setTexture2DArray(le,0),Le=se.TEXTURE_2D_ARRAY):(we.setTexture2D(le,0),Le=se.TEXTURE_2D),w.activeTexture(se.TEXTURE0),w.pixelStorei(se.UNPACK_FLIP_Y_WEBGL,le.flipY),w.pixelStorei(se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,le.premultiplyAlpha),w.pixelStorei(se.UNPACK_ALIGNMENT,le.unpackAlignment);let An=w.getParameter(se.UNPACK_ROW_LENGTH),pn=w.getParameter(se.UNPACK_IMAGE_HEIGHT),yi=w.getParameter(se.UNPACK_SKIP_PIXELS),or=w.getParameter(se.UNPACK_SKIP_ROWS),Li=w.getParameter(se.UNPACK_SKIP_IMAGES);w.pixelStorei(se.UNPACK_ROW_LENGTH,It.width),w.pixelStorei(se.UNPACK_IMAGE_HEIGHT,It.height),w.pixelStorei(se.UNPACK_SKIP_PIXELS,Dt),w.pixelStorei(se.UNPACK_SKIP_ROWS,tn),w.pixelStorei(se.UNPACK_SKIP_IMAGES,$t);let vr=D.isDataArrayTexture||D.isData3DTexture,Mn=le.isDataArrayTexture||le.isData3DTexture;if(D.isDepthTexture){let Yn=ye.get(D),Zi=ye.get(le),kn=ye.get(Yn.__renderTarget),ki=ye.get(Zi.__renderTarget);w.bindFramebuffer(se.READ_FRAMEBUFFER,kn.__webglFramebuffer),w.bindFramebuffer(se.DRAW_FRAMEBUFFER,ki.__webglFramebuffer);for(let ca=0;ca<ft;ca++)vr&&(se.framebufferTextureLayer(se.READ_FRAMEBUFFER,se.COLOR_ATTACHMENT0,ye.get(D).__webglTexture,Se,$t+ca),se.framebufferTextureLayer(se.DRAW_FRAMEBUFFER,se.COLOR_ATTACHMENT0,ye.get(le).__webglTexture,ke,Vn+ca)),se.blitFramebuffer(Dt,tn,et,Je,Et,hn,et,Je,se.DEPTH_BUFFER_BIT,se.NEAREST);w.bindFramebuffer(se.READ_FRAMEBUFFER,null),w.bindFramebuffer(se.DRAW_FRAMEBUFFER,null)}else if(Se!==0||D.isRenderTargetTexture||ye.has(D)){let Yn=ye.get(D),Zi=ye.get(le);w.bindFramebuffer(se.READ_FRAMEBUFFER,M),w.bindFramebuffer(se.DRAW_FRAMEBUFFER,O);for(let kn=0;kn<ft;kn++)vr?se.framebufferTextureLayer(se.READ_FRAMEBUFFER,se.COLOR_ATTACHMENT0,Yn.__webglTexture,Se,$t+kn):se.framebufferTexture2D(se.READ_FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_2D,Yn.__webglTexture,Se),Mn?se.framebufferTextureLayer(se.DRAW_FRAMEBUFFER,se.COLOR_ATTACHMENT0,Zi.__webglTexture,ke,Vn+kn):se.framebufferTexture2D(se.DRAW_FRAMEBUFFER,se.COLOR_ATTACHMENT0,se.TEXTURE_2D,Zi.__webglTexture,ke),Se!==0?se.blitFramebuffer(Dt,tn,et,Je,Et,hn,et,Je,se.COLOR_BUFFER_BIT,se.NEAREST):Mn?se.copyTexSubImage3D(Le,ke,Et,hn,Vn+kn,Dt,tn,et,Je):se.copyTexSubImage2D(Le,ke,Et,hn,Dt,tn,et,Je);w.bindFramebuffer(se.READ_FRAMEBUFFER,null),w.bindFramebuffer(se.DRAW_FRAMEBUFFER,null)}else Mn?D.isDataTexture||D.isData3DTexture?se.texSubImage3D(Le,ke,Et,hn,Vn,et,Je,ft,Qt,jt,It.data):le.isCompressedArrayTexture?se.compressedTexSubImage3D(Le,ke,Et,hn,Vn,et,Je,ft,Qt,It.data):se.texSubImage3D(Le,ke,Et,hn,Vn,et,Je,ft,Qt,jt,It):D.isDataTexture?se.texSubImage2D(se.TEXTURE_2D,ke,Et,hn,et,Je,Qt,jt,It.data):D.isCompressedTexture?se.compressedTexSubImage2D(se.TEXTURE_2D,ke,Et,hn,It.width,It.height,Qt,It.data):se.texSubImage2D(se.TEXTURE_2D,ke,Et,hn,et,Je,Qt,jt,It);w.pixelStorei(se.UNPACK_ROW_LENGTH,An),w.pixelStorei(se.UNPACK_IMAGE_HEIGHT,pn),w.pixelStorei(se.UNPACK_SKIP_PIXELS,yi),w.pixelStorei(se.UNPACK_SKIP_ROWS,or),w.pixelStorei(se.UNPACK_SKIP_IMAGES,Li),ke===0&&le.generateMipmaps&&se.generateMipmap(Le),w.unbindTexture()},this.initRenderTarget=function(D){ye.get(D).__webglFramebuffer===void 0&&we.setupRenderTarget(D)},this.initTexture=function(D){D.isCubeTexture?we.setTextureCube(D,0):D.isData3DTexture?we.setTexture3D(D,0):D.isDataArrayTexture||D.isCompressedArrayTexture?we.setTexture2DArray(D,0):we.setTexture2D(D,0),w.unbindTexture()},this.resetState=function(){H=0,ee=0,j=null,w.reset(),dt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ra}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ln._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ln._getUnpackColorSpace()}};var Pd=function(){return Pd=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Pd.apply(this,arguments)},ti=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Kl=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},iv=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function Tb(n){for(var e=atob(n),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);for(var r=new DataView(t.buffer,t.byteOffset,t.byteLength),a=r.getUint32(8,!0),s=r.getUint32(12,!0),o=new Float32Array(a*3),u=new Float32Array(a*3),l=new Float32Array(a*2),d=16,i=0;i<a;i++)o[i*3]=r.getFloat32(d,!0),o[i*3+1]=r.getFloat32(d+4,!0),o[i*3+2]=r.getFloat32(d+8,!0),u[i*3]=r.getFloat32(d+12,!0),u[i*3+1]=r.getFloat32(d+16,!0),u[i*3+2]=r.getFloat32(d+20,!0),l[i*2]=r.getFloat32(d+24,!0),l[i*2+1]=r.getFloat32(d+28,!0),d+=32;for(var f=new Uint16Array(s),i=0;i<s;i++)f[i]=r.getUint16(d+i*2,!0);var h=new Wi;return h.setAttribute("position",new Xn(o,3)),h.setAttribute("normal",new Xn(u,3)),h.setAttribute("uv",new Xn(l,2)),h.setIndex(Array.from(f)),h}function rv(n,e,t){return!n||t>=1?0:t<=-1?1.1:(1-t)*.55}function Eb(n,e,t){var i,r,a,s,o,u,l,d,f,h,v,y,T,g,m,L,F,_=new Er,p=!!n.fairwayRamp,S=(T=n.cupX)!==null&&T!==void 0?T:0,B=(g=n.cupZ)!==null&&g!==void 0?g:-4.8,b=(m=n.cupRadius)!==null&&m!==void 0?m:.23,I=new Or(1,1,1),z=new Map,U=function(Ae,Ne,je,Ve,qe,ot,pt){var He=z.get(pt);He||(He=new Xi({color:pt}),z.set(pt,He));var ie=new jn(I,He);ie.position.set(Ae,Ne,je),ie.scale.set(Ve,qe,ot),_.add(ie)};try{for(var Y=ti([-3.2,3.2]),E=Y.next();!E.done;E=Y.next()){var M=E.value;U(M,-.65,0,.2,1.1,14.6,"#a1b8b1"),U(M-Math.sign(M)*.1,-.18,0,.2,.25,14.4,"#e9cea5")}}catch(Ae){i={error:Ae}}finally{try{E&&!E.done&&(r=Y.return)&&r.call(Y)}finally{if(i)throw i.error}}try{for(var O=ti([-7.2,7.2]),H=O.next();!H.done;H=O.next()){var ee=H.value;U(0,-.65,ee,6.4,1.1,.2,"#a1b8b1"),U(0,-.18,ee-Math.sign(ee)*.1,6.2,.25,.2,"#e9cea5")}}catch(Ae){a={error:Ae}}finally{try{H&&!H.done&&(s=O.return)&&s.call(O)}finally{if(a)throw a.error}}var j=.5,K=.5;if(t){var re=t.getAttribute("uv"),J=t.getAttribute("normal");if(re&&J){for(var ne=0;ne<J.count&&J.getY(ne)<.9;)ne++;ne<re.count&&(j=re.getX(ne),K=re.getY(ne))}}var Te=!!(e&&(!((L=e.image)===null||L===void 0)&&L.complete)&&((F=e.image)===null||F===void 0?void 0:F.naturalWidth)>0),fe=Te?new Xi({map:e}):new Xi({color:"#6ec458"}),pe=Te?new Xi({map:e,color:"#779263"}):new Xi({color:"#5a9949"});e&&!Te&&(fe.userData.pendingTex={tex:e,color:"#ffffff"},pe.userData.pendingTex={tex:e,color:"#779263"});var Fe=p?[[-7,-1],[-1,1],[1,7]]:[[-7,7]];try{for(var ae=ti(Fe),de=ae.next();!de.done;de=ae.next()){var _e=Kl(de.value,2),Ge=_e[0],$e=_e[1],ut=new So;if(ut.moveTo(-3,Ge),ut.lineTo(3,Ge),ut.lineTo(3,$e),ut.lineTo(-3,$e),ut.closePath(),B>Ge&&B<$e){var zt=new Ns;zt.absarc(S,B,b,0,Math.PI*2,!0),ut.holes.push(zt)}for(var ct=new Ll(ut,32),Tt=ct.getAttribute("position"),Zt=!1,wt=!1,bt=0;bt<Tt.count;bt++){var _t=Tt.getX(bt),ln=Tt.getY(bt),rt=rv(p,_t,ln);rt===0&&(Zt=!0),rt>0&&(wt=!0),Tt.setXYZ(bt,_t,rt,ln)}var an=ct.getIndex();if(an)for(var bt=0;bt<an.count;bt+=3){var se=an.getX(bt+1);an.setX(bt+1,an.getX(bt+2)),an.setX(bt+2,se)}ct.computeVertexNormals();for(var mn=ct.getAttribute("uv"),bt=0;bt<mn.count;bt++)mn.setXY(bt,j,K);var nn=new jn(ct,p&&Zt&&wt?pe:fe);nn.name="continuous-fairway",_.add(nn)}}catch(Ae){o={error:Ae}}finally{try{de&&!de.done&&(u=ae.return)&&u.call(ae)}finally{if(o)throw o.error}}var W="#d69260",w="#f1bd87";try{for(var ue=ti([-3.1,3.1]),ye=ue.next();!ye.done;ye=ue.next()){var M=ye.value;U(M,.12,0,.2,.3,14.2,W),U(M,.29,0,.22,.04,14.2,w)}}catch(Ae){l={error:Ae}}finally{try{ye&&!ye.done&&(d=ue.return)&&d.call(ue)}finally{if(l)throw l.error}}try{for(var we=ti([-7.1,7.1]),ze=we.next();!ze.done;ze=we.next()){var ee=ze.value;U(0,rv(p,0,ee>0?6:-6)+.12,ee,6.4,.3,.2,W)}}catch(Ae){f={error:Ae}}finally{try{ze&&!ze.done&&(h=we.return)&&h.call(we)}finally{if(f)throw f.error}}if(p)try{for(var Ye=ti([-3.1,3.1]),Re=Ye.next();!Re.done;Re=Ye.next()){var M=Re.value;U(M,.7,-4.5,.2,1.1,5.2,W)}}catch(Ae){v={error:Ae}}finally{try{Re&&!Re.done&&(y=Ye.return)&&y.call(Ye)}finally{if(v)throw v.error}}return _}function Ab(n){var e,t=new Er,i=(e=n.cupRadius)!==null&&e!==void 0?e:.23,r=new jn(new Ds(i,i*.89,.48,24,1,!0),new Xi({color:"#244640",side:Ir}));r.position.y=-.24,t.add(r);var a=new jn(new _o(i*.91,24),new Ta({color:"#082c2b"}));a.rotation.x=-Math.PI/2,a.position.y=-.475,t.add(a);var s=new jn(new Ds(i,i*.978,.09,24,1,!0),new Xi({color:"#eee9cf",side:Ir}));s.position.y=-.045,t.add(s);var o=new jn(new wo(i,i+.06,24),new Xi({color:"#fff7d1"}));return o.rotation.x=-Math.PI/2,o.position.y=.004,t.add(o),t}function Ib(){for(var n,e,t=new Er,i=new Or(.18,1,.18),r=new Xi({color:"#b27b59"}),a=new Or(1.5,.2,1.6),s=new Xi({color:"#82b88b"}),o=new ds(.62,7,5),u=new ds(.49,7,5),l=new Xi({color:"#77b86b"}),d=new Xi({color:"#3e9d79"}),f=new Ea(i,r,14),h=new Ea(a,s,14),v=5,y=9,T=new Ea(o,l,v),g=new Ea(u,l,v),m=new Ea(o,d,y),L=new Ea(u,d,y),F=new $n,_=0,p=0,S=0;S<14;S++){var B=S%2?-1:1,b=B*(3.8+S%3*.35),I=-6.5+Math.floor(S/2)*2;F.makeTranslation(b,-.02,I),f.setMatrixAt(S,F),F.makeTranslation(b,-.48,I),h.setMatrixAt(S,F),S%3===0?(F.makeTranslation(b,.5,I),T.setMatrixAt(_,F),F.makeTranslation(b,1,I),g.setMatrixAt(_,F),_++):(F.makeTranslation(b,.5,I),m.setMatrixAt(p,F),F.makeTranslation(b,1,I),L.setMatrixAt(p,F),p++)}try{for(var z=ti([f,h,T,g,m,L]),U=z.next();!U.done;U=z.next()){var Y=U.value;Y.instanceMatrix.needsUpdate=!0,t.add(Y)}}catch(E){n={error:E}}finally{try{U&&!U.done&&(e=z.return)&&e.call(z)}finally{if(n)throw n.error}}return t}function Cb(n,e,t){for(var i=n.getAttribute("position"),r=0;r<i.count;r++){var a=e[r*3],s=e[r*3+1],o=e[r*3+2],u=s>.7?Math.max(0,Math.min(1,(-a-.035)/.32)):0;i.setXYZ(r,a,s+Math.sin(t*3.2+a*10)*.018*u,o+Math.sin(t*3.2+a*10+s*2)*.07*u)}i.needsUpdate=!0,n.computeVertexNormals()}function av(n,e,t){var i=new Map,r=new Map,a=new Map,s,o,u,l,d;function f(){var _,p;if(o!==void 0)return o;try{return s=document.createElement("canvas"),(_=s.addEventListener)===null||_===void 0||_.call(s,"webglcontextrestored",function(){var S,B;d=void 0;try{for(var b=ti(a.values()),I=b.next();!I.done;I=b.next()){var z=I.value;z.compiled=!1,z.textureDirty=!0,z.lastRenderedTime=-1,z.lastFlagStep=-1}}catch(U){S={error:U}}finally{try{I&&!I.done&&(B=b.return)&&B.call(b)}finally{if(S)throw S.error}}t?.()}),u=document.createElement("canvas"),l=(p=u.getContext)===null||p===void 0?void 0:p.call(u,"2d"),o=new Id({canvas:s,antialias:!0,alpha:!1,preserveDrawingBuffer:!1,powerPreference:"default"}),o.shadowMap.type=Du,o}catch{return o=null,null}}function h(_){if(_){if(i.has(_))return i.get(_);var p=e.get(_);if(!(!p||p.mime!=="model/tora-mesh"||!p.data)){var S=Tb(p.data);return i.set(_,S),S}}}function v(_){if(_){if(r.has(_))return r.get(_);var p=e.get(_);if(!(!p||!p.mime.startsWith("image/")||!p.data)){var S=new Image,B=new tr(S);B.colorSpace=hr;var b=function(I){var z,U;B.needsUpdate=!0;try{for(var Y=ti(a.values()),E=Y.next();!E.done;E=Y.next()){var M=E.value;M.scene.traverse(function(O){var H,ee,j,K=O.isMesh&&O.material?Array.isArray(O.material)?O.material:[O.material]:[];try{for(var re=(H=void 0,ti(K)),J=re.next();!J.done;J=re.next()){var ne=J.value;!((j=ne.userData)===null||j===void 0)&&j.pendingTex&&ne.userData.pendingTex.tex===B&&(ne.map=B,ne.color.set(ne.userData.pendingTex.color||"#ffffff"),delete ne.userData.pendingTex,ne.needsUpdate=!0)}}catch(Te){H={error:Te}}finally{try{J&&!J.done&&(ee=re.return)&&ee.call(re)}finally{if(H)throw H.error}}}),M.textureDirty=!0}}catch(O){z={error:O}}finally{try{E&&!E.done&&(U=Y.return)&&U.call(Y)}finally{if(z)throw z.error}}I&&t?.()};return r.set(_,B),S.onload=function(){return b(!0)},S.src="data:"+p.mime+";base64,"+p.data,S.complete&&S.naturalWidth&&b(!1),B}}}function y(_){var p,S,B,b,I,z,U,Y,E,M,O,H,ee,j,K,re,J,ne,Te,fe,pe=_.parameters,Fe=new vl;Fe.background=new vn(pe.skyColor||"#b8e2ed");var ae=new er((B=pe.cameraFov)!==null&&B!==void 0?B:39,1,.1,160);ae.position.set((b=pe.cameraX)!==null&&b!==void 0?b:10,(I=pe.cameraY)!==null&&I!==void 0?I:18,(z=pe.cameraZ)!==null&&z!==void 0?z:21),ae.lookAt((U=pe.lookAtX)!==null&&U!==void 0?U:0,(Y=pe.lookAtY)!==null&&Y!==void 0?Y:.15,(E=pe.lookAtZ)!==null&&E!==void 0?E:0),Fe.add(ae),Fe.add(new Ul(pe.hemiSkyColor||"#fff9dd",pe.hemiGroundColor||"#527b75",(M=pe.hemiIntensity)!==null&&M!==void 0?M:1.8));var de=new Ol(pe.sunColor||"#fff0cf",(O=pe.sunIntensity)!==null&&O!==void 0?O:2.1);de.position.set((H=pe.sunX)!==null&&H!==void 0?H:-9,(ee=pe.sunY)!==null&&ee!==void 0?ee:18,(j=pe.sunZ)!==null&&j!==void 0?j:8),Fe.add(de);var _e=v((re=(K=_.assetSlots)===null||K===void 0?void 0:K[0])===null||re===void 0?void 0:re.assetId),Ge=new Map,$e=new Map,ut=[],zt=[];function ct(Ne,je,Ve,qe){Ne.traverse(function(ot){ot.userData.toraRootId=je,ot.userData.toraSourceId=Ve,qe&&(ot.userData.cameraAttached=!0)})}function Tt(Ne,je,Ve,qe,ot){var pt,He,ie,Oe,Pe,nt,dt,Be,Rt,vt,cn,dn,Fn,Dn,vi,rr,yn,En,Yi,en=Ne.parameters,xt,ni=function(){var qi,wi,gi={},Bn=!!(_e&&(!((qi=_e.image)===null||qi===void 0)&&qi.complete)&&((wi=_e.image)===null||wi===void 0?void 0:wi.naturalWidth)>0);en.useTexture&&_e&&Bn?gi.map=_e:gi.color=en.useTexture?en.waveFlag?"#e85d56":"#d89b6a":en.color||"#ffffff",en.doubleSide&&(gi.side=Ir),en.opacity<1&&(gi.transparent=!0,gi.opacity=en.opacity,gi.depthWrite=!1);var ar=en.unlit?new Ta(gi):new Xi(gi);return en.useTexture&&_e&&!Bn&&(ar.userData.pendingTex={tex:_e,color:"#ffffff"}),ar};if(en.primitive==="group")xt=new Er;else if(en.primitive==="fairway")xt=Eb(en,_e,h((He=(pt=Ne.assetSlots)===null||pt===void 0?void 0:pt[0])===null||He===void 0?void 0:He.assetId));else if(en.primitive==="cup")xt=Ab(en);else if(en.primitive==="garden")xt=Ib();else if(en.primitive==="mesh"){var fn=h((Oe=(ie=Ne.assetSlots)===null||ie===void 0?void 0:ie[0])===null||Oe===void 0?void 0:Oe.assetId),bi=en.waveFlag&&fn?fn.clone():fn??new Or(1,1,1);xt=new jn(bi,ni()),en.waveFlag&&fn&&ut.push({geo:bi,rest:new Float32Array(bi.getAttribute("position").array)})}else en.primitive==="sphere"?xt=new jn(new ds((Pe=en.radiusTop)!==null&&Pe!==void 0?Pe:.5,16,12),ni()):en.primitive==="cylinder"?xt=new jn(new Ds((nt=en.radiusTop)!==null&&nt!==void 0?nt:.23,(dt=en.radiusBottom)!==null&&dt!==void 0?dt:.21,1,32,1,!!en.openEnded),ni()):en.primitive==="ring"?xt=new jn(new wo((Be=en.innerRadius)!==null&&Be!==void 0?Be:0,(Rt=en.radiusTop)!==null&&Rt!==void 0?Rt:.15,24),ni()):en.primitive==="circle"?xt=new jn(new _o((vt=en.radiusTop)!==null&&vt!==void 0?vt:.21,32),ni()):xt=new jn(new Or(1,1,1),ni());return xt.position.set((cn=en.x)!==null&&cn!==void 0?cn:0,(dn=en.y)!==null&&dn!==void 0?dn:0,(Fn=en.z)!==null&&Fn!==void 0?Fn:0),xt.rotation.set((Dn=en.rx)!==null&&Dn!==void 0?Dn:0,(vi=en.ry)!==null&&vi!==void 0?vi:0,(rr=en.rz)!==null&&rr!==void 0?rr:0),xt.scale.set((yn=en.sx)!==null&&yn!==void 0?yn:1,(En=en.sy)!==null&&En!==void 0?En:1,(Yi=en.sz)!==null&&Yi!==void 0?Yi:1),xt.visible=en.visible!==!1,ct(xt,Ve,qe,ot),je.add(xt),xt}var Zt=[],wt=new Map,bt=function(Ne,je,Ve){var qe,ot;try{for(var pt=ti(n.components),He=pt.next();!He.done;He=pt.next()){var ie=He.value;if(ie.parentId===Ne&&ie.contract==="native.mesh3d.v1"&&!ie.prototype){var Oe=je??ie,Pe=Ve||!!ie.parameters.attachToCamera;wt.set(ie.id,{rootId:Oe.id,sourceId:Oe.id,cameraAttached:Pe}),Zt.push(ie),bt(ie.id,Oe,Pe)}}}catch(nt){qe={error:nt}}finally{try{He&&!He.done&&(ot=pt.return)&&ot.call(pt)}finally{if(qe)throw qe.error}}};bt(_.id,null,!1);var _t=function(Ne){var je=Ne.parameters,Ve=wt.get(Ne.id),qe=je.attachToCamera&&Ne.parentId===_.id?ae:Ne.parentId===_.id?Fe:(J=Ge.get(Ne.parentId))!==null&&J!==void 0?J:Fe,ot=Tt(Ne,qe,Ve.rootId,Ve.sourceId,Ve.cameraAttached);if(Ge.set(Ne.id,ot),je.confetti){var pt=new Er;pt.userData.isConfetti=!0;var He=new Or(.08,.025,.12),ie=["#ffda69","#fff6c9","#ef8774","#7cc6bf"].map(function(Pe){return new Ta({color:Pe})}),Oe=Array.from({length:28},function(Pe,nt){var dt=new jn(He,ie[nt%4]);return dt.visible=!1,pt.add(dt),dt});Fe.add(pt),zt.push({id:Ne.id,origin:{x:(ne=je.x)!==null&&ne!==void 0?ne:0,y:(Te=je.y)!==null&&Te!==void 0?Te:0,z:(fe=je.z)!==null&&fe!==void 0?fe:0},pieces:Oe})}};try{for(var ln=ti(Zt),rt=ln.next();!rt.done;rt=ln.next()){var an=rt.value;_t(an)}}catch(Ne){p={error:Ne}}finally{try{rt&&!rt.done&&(S=ln.return)&&S.call(ln)}finally{if(p)throw p.error}}var se=new Er;Fe.add(se);var mn=new ds(1,8,5),nn=new Ta({color:"#fff1a2",transparent:!0,opacity:.85}),W=Array.from({length:24},function(){var Ne=new jn(mn,nn);return Ne.visible=!1,se.add(Ne),Ne}),w=new Bl,ue=new kt,ye=new ge,we=new Ur(new ge(0,1,0),0),ze=new ge,Ye="",Re=Array.from(Ge,function(Ne){var je=Kl(Ne,2),Ve=je[0],qe=je[1];return{id:Ve,obj:qe,comp:n.components.find(function(ot){return ot.id===Ve})}}).filter(function(Ne){return Ne.comp}),Ae={id:_.id,scene:Fe,camera:ae,nodes:Ge,dynamicNodes:$e,nodeEntries:Re,createMeshObject:Tt,wavingFlags:ut,confettiSystems:zt,guideGroup:se,guidePool:W,compiled:!1,lastRenderMs:0,textureDirty:!0,skyColor:pe.skyColor||"#b8e2ed",lastWaveAt:-1,lastRenderedTime:-1,lastRenderedW:0,lastRenderedH:0,lastPoseSig:"",guideDirty:!0,focusZ:0,lastTime:-1,lastWidth:0,lastHeight:0,setGuide:function(Ne){var je=Ne?Math.min(Ne.length,W.length):0,Ve=je?Ne.slice(0,je).map(function(ie){return"".concat(ie.x.toFixed(2),",").concat(ie.y.toFixed(2),",").concat(ie.z.toFixed(2))}).join("|"):"";if(Ve!==Ye){Ye=Ve,Ae.guideDirty=!0;for(var qe=0;qe<W.length;qe++){var ot=W[qe];if(qe<je){var pt=Ne[qe],He=.055*(1-qe/je*.5);ot.visible=!0,ot.scale.setScalar(He),ot.position.set(pt.x,pt.y+.03,pt.z)}else ot.visible=!1}}},project:function(Ne,je,Ve){return ye.set(Ne.x,Ne.y,Ne.z).project(ae),{x:(ye.x+1)*je/2,y:(1-ye.y)*Ve/2}},unproject:function(Ne,je,Ve,qe,ot){return ue.set(Ne/Ve*2-1,1-je/qe*2),w.setFromCamera(ue,ae),we.constant=-ot,w.ray.intersectPlane(we,ze)?{x:ze.x,y:ze.y,z:ze.z}:null},raycast:function(Ne,je,Ve,qe){var ot,pt,He,ie,Oe,Pe;Ve===void 0&&(Ve=80);var nt=qe===void 0?{}:qe,dt=nt.isTarget,Be=dt===void 0?function(){return!0}:dt,Rt=nt.isOccluder,vt=Rt===void 0?function(){return!1}:Rt;Fe.updateMatrixWorld(!0),ae.updateMatrixWorld(!0),ue.set(Ne,je),w.near=.05,w.far=Ve,w.setFromCamera(ue,ae);var cn=w.intersectObjects(Fe.children,!0),dn=new Set;try{for(var Fn=ti(cn),Dn=Fn.next();!Dn.done;Dn=Fn.next()){for(var vi=Dn.value,rr=!1,yn=vi.object;yn;yn=yn.parent)if(!yn.visible||yn===se||!((He=yn.userData)===null||He===void 0)&&He.cameraAttached||!((ie=yn.userData)===null||ie===void 0)&&ie.isConfetti){rr=!0;break}if(!rr){var En=(Oe=vi.object.userData)===null||Oe===void 0?void 0:Oe.toraRootId,Yi=(Pe=vi.object.userData)===null||Pe===void 0?void 0:Pe.toraSourceId;if(!(!En||dn.has(En))){if(dn.add(En),Be(En,Yi))return{id:En,sourceId:Yi,distance:vi.distance,point:{x:vi.point.x,y:vi.point.y,z:vi.point.z}};if(vt(En,Yi))return null}}}}catch(en){ot={error:en}}finally{try{Dn&&!Dn.done&&(pt=Fn.return)&&pt.call(Fn)}finally{if(ot)throw ot.error}}return null}};return a.set(_.id,Ae),Ae}function T(_){var p;return(p=a.get(_.id))!==null&&p!==void 0?p:y(_)}function g(_,p){var S,B,b,I,z,U,Y,E,M,O,H,ee,j,K,re,J,ne,Te,fe,pe,Fe,ae,de,_e,Ge,$e,ut,zt,ct,Tt,Zt,wt,bt,_t,ln,rt,an,se,mn,nn,W,w,ue,ye,we,ze,Ye,Re,Ae,Ne,je,Ve,qe,ot,pt,He,ie,Oe,Pe,nt=p.time,dt=nt===void 0?0:nt,Be=p.ambientTime,Rt=p.propsOf,vt=p.bodies3d,cn=p.fpsPose,dn=p.instances3d,Fn=dn===void 0?[]:dn,Dn=p.aimLocked,vi=Dn===void 0?!1:Dn,rr=p.groundFn,yn=p.worldWidth,En=yn===void 0?390:yn,Yi=p.worldHeight,en=Yi===void 0?700:Yi,xt=T(_),ni=Be??dt,fn=Rt(_),bi=fn.skyColor||"#b8e2ed";xt.skyColor!==bi&&(xt.skyColor=bi,xt.scene.background=new vn(bi));var qi=new Set(Fn.map(function(Sn){return Sn.id}));try{for(var wi=ti(xt.dynamicNodes),gi=wi.next();!gi.done;gi=wi.next()){var Bn=Kl(gi.value,2),ar=Bn[0],la=Bn[1];qi.has(ar)||((H=la.parent)===null||H===void 0||H.remove(la),xt.dynamicNodes.delete(ar))}}catch(Sn){S={error:Sn}}finally{try{gi&&!gi.done&&(B=wi.return)&&B.call(wi)}finally{if(S)throw S.error}}var Za=function(Sn){if(xt.dynamicNodes.has(Sn.id))return"continue";var Di=Sn.parentId===_.id?xt.scene:(j=(ee=xt.dynamicNodes.get(Sn.parentId))!==null&&ee!==void 0?ee:xt.nodes.get(Sn.parentId))!==null&&j!==void 0?j:xt.scene,yr=(K=Sn.instanceId)!==null&&K!==void 0?K:Sn.id,Pa=(re=Fn.find(function($r){return $r.id===yr}))!==null&&re!==void 0?re:Sn,Jt=(J=Pa.prototypeId)!==null&&J!==void 0?J:Pa.id,pi=xt.createMeshObject(Sn,Di,yr,Jt,!!Sn.parameters.attachToCamera);xt.dynamicNodes.set(Sn.id,pi)};try{for(var Ei=ti(Fn),mr=Ei.next();!mr.done;mr=Ei.next()){var sr=mr.value;Za(sr)}}catch(Sn){b={error:Sn}}finally{try{mr&&!mr.done&&(I=Ei.return)&&I.call(Ei)}finally{if(b)throw b.error}}var Vr=iv(iv([],Kl(xt.nodeEntries),!1),Kl(Fn.map(function(Sn){return{id:Sn.id,obj:xt.dynamicNodes.get(Sn.id),comp:Sn}}).filter(function(Sn){return Sn.obj})),!1),D="";try{for(var le=ti(Vr),he=le.next();!he.done;he=le.next()){var Me=he.value,Se=Me.id,ke=Me.obj,sr=Me.comp,et=Rt(sr);ke.visible=et.visible!==!1,!et.useTexture&&ke.isMesh&&(!((ne=ke.material)===null||ne===void 0)&&ne.color)&&et.color&&ke.material.color.set(et.color);var Je=vt?.get(Se);if(Je&&Je.mode==="dynamic"){var ft=Je.captured?Math.min(1,((Te=Je.captureElapsed)!==null&&Te!==void 0?Te:0)/.55):0,Dt=Je.captured&&Je.captureTarget?Je.x+(Je.captureTarget.x-Je.x)*ft:Je.x,tn=Je.y-ft*.45,$t=Je.captured&&Je.captureTarget?Je.z+(Je.captureTarget.z-Je.z)*ft:Je.z;ke.position.set(Dt,tn,$t);var Et=1-ft*.65;ke.scale.set(((fe=et.sx)!==null&&fe!==void 0?fe:1)*Et,((pe=et.sy)!==null&&pe!==void 0?pe:1)*Et,((Fe=et.sz)!==null&&Fe!==void 0?Fe:1)*Et),ke.rotation.set(-((ae=Je.spin)!==null&&ae!==void 0?ae:0),(de=et.ry)!==null&&de!==void 0?de:0,((_e=Je.spin)!==null&&_e!==void 0?_e:0)*.22)}else if(Je&&Je.mode==="kinematic")ke.position.set(Je.x,($e=(Ge=Je.y)!==null&&Ge!==void 0?Ge:et.y)!==null&&$e!==void 0?$e:0,Je.z),ke.rotation.set((ut=et.rx)!==null&&ut!==void 0?ut:0,-((ct=(zt=Je.angle)!==null&&zt!==void 0?zt:et.ry)!==null&&ct!==void 0?ct:0),(Tt=et.rz)!==null&&Tt!==void 0?Tt:0);else if(et.dropShadowOf&&vt?.has(et.dropShadowOf)){var hn=vt.get(et.dropShadowOf),Vn=rr?(Zt=rr(hn,hn.x,hn.z))!==null&&Zt!==void 0?Zt:-1:0;ke.position.set(hn.x,Vn+.008,hn.z);var It=Math.max(0,hn.y-Vn-hn.radius);ke.material&&(ke.material.opacity=.22/(1+It*2));var Et=1+It*.4;ke.scale.set(Et,Et,Et),ke.visible=!hn.captured&&et.visible!==!1}else ke.position.set((wt=et.x)!==null&&wt!==void 0?wt:0,(bt=et.y)!==null&&bt!==void 0?bt:0,(_t=et.z)!==null&&_t!==void 0?_t:0),ke.rotation.set((ln=et.rx)!==null&&ln!==void 0?ln:0,(rt=et.ry)!==null&&rt!==void 0?rt:0,(an=et.rz)!==null&&an!==void 0?an:0),ke.scale.set((se=et.sx)!==null&&se!==void 0?se:1,(mn=et.sy)!==null&&mn!==void 0?mn:1,(nn=et.sz)!==null&&nn!==void 0?nn:1);(cn||xt.dynamicNodes.size>0)&&(D+="".concat(Se,":").concat(ke.visible?1:0,",").concat(ke.position.x.toFixed(3),",").concat(ke.position.y.toFixed(3),",").concat(ke.position.z.toFixed(3),",").concat(ke.rotation.y.toFixed(3),",").concat((W=et.color)!==null&&W!==void 0?W:"","|"))}}catch(Sn){z={error:Sn}}finally{try{he&&!he.done&&(U=le.return)&&U.call(le)}finally{if(z)throw z.error}}var Qt;if(vt)try{for(var jt=ti(vt.values()),Le=jt.next();!Le.done;Le=jt.next()){var Je=Le.value;if(Je.stageId===_.id&&Je.captured){Qt=Je;break}}}catch(Sn){Y={error:Sn}}finally{try{Le&&!Le.done&&(E=jt.return)&&E.call(jt)}finally{if(Y)throw Y.error}}var An=function(Sn){var Di=!!Qt,yr=Qt&&(w=Qt.captureElapsed)!==null&&w!==void 0?w:0;Sn.pieces.forEach(function(Pa,Jt){var pi,$r,Ms,Oo,Bo,Ja;if(Pa.visible=Di,!!Di){var ko=Jt*2.399,kd=($r=(pi=Qt.captureTarget)===null||pi===void 0?void 0:pi.x)!==null&&$r!==void 0?$r:Sn.origin.x,rc=(Oo=(Ms=Qt.captureTarget)===null||Ms===void 0?void 0:Ms.y)!==null&&Oo!==void 0?Oo:Sn.origin.y,ci=(Ja=(Bo=Qt.captureTarget)===null||Bo===void 0?void 0:Bo.z)!==null&&Ja!==void 0?Ja:Sn.origin.z;Pa.position.set(kd+Math.cos(ko)*yr*(.5+Jt%4*.17),rc+.3+Math.sin(Math.min(1,yr/2)*Math.PI)*(1+Jt%5*.15),ci+Math.sin(ko)*yr*(.5+Jt%4*.17)),Pa.rotation.set(yr*3+Jt,yr*2+Jt,Math.sin(yr+Jt))}})};try{for(var pn=ti(xt.confettiSystems),yi=pn.next();!yi.done;yi=pn.next()){var or=yi.value;An(or)}}catch(Sn){M={error:Sn}}finally{try{yi&&!yi.done&&(O=pn.return)&&O.call(pn)}finally{if(M)throw M.error}}var Li=en>=En,vr=xt.lastTime<0||ni<xt.lastTime?0:Math.min(.05,ni-xt.lastTime);xt.camera.aspect=En/Math.max(1,en);var Mn=!1;if(cn)xt.lastTime=ni,xt.camera.rotation.order="YXZ",xt.camera.position.set(cn.x,cn.y+((ue=cn.bob)!==null&&ue!==void 0?ue:0),cn.z),xt.camera.rotation.set(cn.pitch,cn.yaw,0),xt.camera.fov=Li?(ye=fn.cameraFov)!==null&&ye!==void 0?ye:68:(we=fn.landscapeCameraFov)!==null&&we!==void 0?we:54,D+="cam:".concat(xt.camera.position.x.toFixed(3),",").concat(xt.camera.position.y.toFixed(3),",").concat(xt.camera.position.z.toFixed(3),",").concat(cn.yaw.toFixed(4),",").concat(cn.pitch.toFixed(4),",").concat(xt.camera.fov.toFixed(2));else{var Yn=fn.followTargetId?vt?.get(fn.followTargetId):void 0,Zi=Yn?Yn.z*((ze=fn.followZFactor)!==null&&ze!==void 0?ze:.12):(Ye=fn.lookAtZ)!==null&&Ye!==void 0?Ye:0;xt.lastTime<0||ni<xt.lastTime?xt.focusZ=Zi:vi||(xt.focusZ+=(Zi-xt.focusZ)*(1-Math.exp(-6*vr))),xt.lastTime=ni;var kn=Math.max(0,1-ni/1.5);if(Mn=!fn.followTargetId&&((Re=fn.introLift)!==null&&Re!==void 0?Re:2)===0,!vi){var ki=Mn?Math.sin(ni*.42)*1.15:0,ca=Mn?(Math.cos(ni*.42)-1)*.55:0,lr=(Li?(Ae=fn.cameraX)!==null&&Ae!==void 0?Ae:10:(Ne=fn.landscapeCameraX)!==null&&Ne!==void 0?Ne:13)+ki,gr=Li?((je=fn.cameraY)!==null&&je!==void 0?je:18)+kn*((Ve=fn.introLift)!==null&&Ve!==void 0?Ve:2):(qe=fn.landscapeCameraY)!==null&&qe!==void 0?qe:15,Ai=(Li?(ot=fn.cameraZ)!==null&&ot!==void 0?ot:21:(pt=fn.landscapeCameraZ)!==null&&pt!==void 0?pt:18)+ca,Vt=vr===0?gr:xt.camera.position.y+(gr-xt.camera.position.y)*(1-Math.exp(-6*vr));xt.camera.position.set(lr,Vt,Ai+xt.focusZ),xt.camera.fov=Li?(He=fn.cameraFov)!==null&&He!==void 0?He:39:(ie=fn.landscapeCameraFov)!==null&&ie!==void 0?ie:22.6199,xt.camera.lookAt((Oe=fn.lookAtX)!==null&&Oe!==void 0?Oe:0,(Pe=fn.lookAtY)!==null&&Pe!==void 0?Pe:.15,xt.focusZ)}}return xt.camera.updateProjectionMatrix(),xt.camera.updateMatrixWorld(!0),{entry:xt,waveTime:ni,victorySway:Mn,poseParts:D}}function m(_,p,S,B,b,I,z){var U,Y,E,M,O,H,ee,j,K,re,J,ne,Te,fe=g(_,Pd(Pd({},z),{worldWidth:(K=z.worldWidth)!==null&&K!==void 0?K:b,worldHeight:(re=z.worldHeight)!==null&&re!==void 0?re:I})),pe=fe.entry,Fe=fe.waveTime,ae=fe.victorySway,de=fe.poseParts,_e=z.bodies3d;if(S<2||B<2)return p.fillStyle=pe.skyColor,p.fillRect(0,0,b,I),pe;var Ge=f();if(!Ge||!((Te=(ne=(J=Ge.getContext)===null||J===void 0?void 0:J.call(Ge))===null||ne===void 0?void 0:ne.isContextLost)===null||Te===void 0)&&Te.call(ne))return p.fillStyle=pe.skyColor,p.fillRect(0,0,b,I),pe;var $e=Math.max(S,B,1),ut=520,zt=$e>ut?ut/$e:1,ct=Math.max(2,Math.round(S*zt)),Tt=Math.max(2,Math.round(B*zt)),Zt=s.width!==ct||s.height!==Tt;if(Zt&&(Ge.setPixelRatio(1),Ge.setSize(ct,Tt,!1),u.width=ct,u.height=Tt,d=void 0),!pe.compiled){pe.compiled=!0;var wt=[];pe.guidePool[0]&&!pe.guidePool[0].visible&&(pe.guidePool[0].visible=!0,pe.guidePool[0].position.set(0,-99,0),wt.push(pe.guidePool[0]));try{for(var bt=ti(pe.confettiSystems),_t=bt.next();!_t.done;_t=bt.next()){var ln=_t.value;ln.pieces[0]&&!ln.pieces[0].visible&&(ln.pieces[0].visible=!0,ln.pieces[0].position.set(0,-99,0),wt.push(ln.pieces[0]))}}catch(Ve){U={error:Ve}}finally{try{_t&&!_t.done&&(Y=bt.return)&&Y.call(bt)}finally{if(U)throw U.error}}Ge.compile(pe.scene,pe.camera);try{for(var rt=ti(wt),an=rt.next();!an.done;an=rt.next()){var se=an.value;se.visible=!1}}catch(Ve){E={error:Ve}}finally{try{an&&!an.done&&(M=rt.return)&&M.call(rt)}finally{if(E)throw E.error}}}var mn=!1;if(_e)try{for(var nn=ti(_e.values()),W=nn.next();!W.done;W=nn.next()){var w=W.value;if(w.stageId===_.id&&(w.mode==="kinematic"||w.mode==="dynamic"&&(!w.atRest||w.captured))){mn=!0;break}}}catch(Ve){O={error:Ve}}finally{try{W&&!W.done&&(H=nn.return)&&H.call(nn)}finally{if(O)throw O.error}}var ue=Math.floor(Fe*20),ye=pe.wavingFlags.length>0&&pe.lastFlagStep!==ue,we=ae&&Math.abs(Fe-pe.lastRenderedTime)>=.032,ze=mn&&pe.lastRenderedTime!==Fe,Ye=de!==pe.lastPoseSig,Re=Zt||d!==_.id||pe.guideDirty||pe.textureDirty||pe.lastRenderedTime<0||pe.lastRenderedW!==ct||pe.lastRenderedH!==Tt||ye||we||ze||Ye;if(Re){if(pe.wavingFlags.length>0&&pe.lastFlagStep!==ue){try{for(var Ae=ti(pe.wavingFlags),Ne=Ae.next();!Ne.done;Ne=Ae.next()){var je=Ne.value;Cb(je.geo,je.rest,ue/20)}}catch(Ve){ee={error:Ve}}finally{try{Ne&&!Ne.done&&(j=Ae.return)&&j.call(Ae)}finally{if(ee)throw ee.error}}pe.lastFlagStep=ue}Ge.setClearColor(pe.skyColor,1),Ge.render(pe.scene,pe.camera),s.width>0&&s.height>0&&(l.drawImage(s,0,0,ct,Tt),d=_.id),pe.lastRenderedTime=Fe,pe.lastRenderedW=ct,pe.lastRenderedH=Tt,pe.lastPoseSig=de,pe.guideDirty=!1,pe.textureDirty=!1}return pe.lastWidth=b,pe.lastHeight=I,u.width>0&&u.height>0&&p.drawImage(u,0,0,b,I),pe}function L(){var _,p,S,B,b;try{for(var I=ti(a.values()),z=I.next();!z.done;z=I.next()){var U=z.value;try{for(var Y=(S=void 0,ti(U.dynamicNodes.values())),E=Y.next();!E.done;E=Y.next()){var M=E.value;(b=M.parent)===null||b===void 0||b.remove(M)}}catch(O){S={error:O}}finally{try{E&&!E.done&&(B=Y.return)&&B.call(Y)}finally{if(S)throw S.error}}U.dynamicNodes.clear(),U.focusZ=0,U.lastTime=-1,U.lastRenderedTime=-1,U.lastFlagStep=-1,U.lastPoseSig="",U.guideDirty=!0,U.setGuide([])}}catch(O){_={error:O}}finally{try{z&&!z.done&&(p=I.return)&&p.call(I)}finally{if(_)throw _.error}}}function F(){var _,p,S,B,b,I,z;try{for(var U=ti(a.values()),Y=U.next();!Y.done;Y=U.next()){var E=Y.value;E.scene.traverse(function(re){var J,ne;if(re.isMesh&&(re.geometry&&!Array.from(i.values()).includes(re.geometry)&&re.geometry.dispose(),re.material))try{for(var Te=(J=void 0,ti(Array.isArray(re.material)?re.material:[re.material])),fe=Te.next();!fe.done;fe=Te.next()){var pe=fe.value;pe.dispose()}}catch(Fe){J={error:Fe}}finally{try{fe&&!fe.done&&(ne=Te.return)&&ne.call(Te)}finally{if(J)throw J.error}}})}}catch(re){_={error:re}}finally{try{Y&&!Y.done&&(p=U.return)&&p.call(U)}finally{if(_)throw _.error}}try{for(var M=ti(i.values()),O=M.next();!O.done;O=M.next()){var H=O.value;H.dispose()}}catch(re){S={error:re}}finally{try{O&&!O.done&&(B=M.return)&&B.call(M)}finally{if(S)throw S.error}}try{for(var ee=ti(r.values()),j=ee.next();!j.done;j=ee.next()){var K=j.value;K.dispose()}}catch(re){b={error:re}}finally{try{j&&!j.done&&(I=ee.return)&&I.call(ee)}finally{if(b)throw b.error}}a.clear(),i.clear(),r.clear(),(z=o?.forceContextLoss)===null||z===void 0||z.call(o),o?.dispose(),o=void 0,s=void 0,u=void 0,l=void 0,d=void 0}return{getStage:T,syncStage:g,renderStage:m,reset:L,dispose:F}}var qa=function(){return qa=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},qa.apply(this,arguments)},Zr=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Jr=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Ql=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},sv=function(n,e,t){return Math.max(e,Math.min(t,n))},_s=function(n,e){return Math.hypot(e.x-n.x,e.y-n.y)};function ov(n){var e=n.id,t=n.nodes,i=n.edges,r=n.gates,a=r===void 0?[]:r,s=n.onEvent,o=s===void 0?function(){}:s,u=new Map(t.map(function(M){return[M.id,qa({},M)]})),l=new Map(i.map(function(M){return[M.id,qa({speedScale:1,enabled:!0,bidirectional:!1,cost:0},M)]})),d=new Map(a.map(function(M){return[M.id,qa({},M)]})),f=new Map,h=f,v=0,y=0,T=function(M){return u.get(M)},g=function(M){return Jr([],Zr(d.values()),!1).find(function(O){return O.parameters.nodeId===M})},m=function(M){var O=M.parameters;if(O.mode==="open")return!0;if(O.mode==="closed")return!1;var H=O.openSeconds+O.closedSeconds,ee=(v+O.phaseOffsetSeconds)%H;return ee<O.openSeconds},L=function(M){return Jr([],Zr(l.values()),!1).filter(function(O){return O.enabled&&(O.from===M||O.bidirectional&&O.to===M)}).sort(function(O,H){return O.id<H.id?-1:O.id>H.id?1:0})},F=function(M,O){return Jr([],Zr(l.values()),!1).find(function(H){return H.enabled&&(H.from===M&&H.to===O||H.bidirectional&&H.from===O&&H.to===M)})};function _(M,O){var H,ee,j,K;if(M===O)return[M];for(var re=new Map([[M,0]]),J=new Map,ne=new Set([M]);ne.size;){var Te=Jr([],Zr(ne),!1).sort(function(ct,Tt){return re.get(ct)-re.get(Tt)||(ct<Tt?-1:ct>Tt?1:0)})[0];if(ne.delete(Te),Te===O)break;try{for(var fe=(H=void 0,Ql(L(Te))),pe=fe.next();!pe.done;pe=fe.next()){var Fe=pe.value,ae=Fe.from===Te?Fe.to:Fe.from,de=g(ae),_e=T(ae),Ge=de?de.parameters.holdSeconds*90+(m(de)?0:de.parameters.closedSeconds*90):0,$e=re.get(Te)+_s(T(Te),_e)/Fe.speedScale+Fe.cost+((j=_e.cost)!==null&&j!==void 0?j:0)+Ge;$e>=((K=re.get(ae))!==null&&K!==void 0?K:1/0)||(re.set(ae,$e),J.set(ae,Te),ne.add(ae))}}catch(ct){H={error:ct}}finally{try{pe&&!pe.done&&(ee=fe.return)&&ee.call(fe)}finally{if(H)throw H.error}}}if(!re.has(O))return[];for(var ut=[O],zt=O;zt!==M;)zt=J.get(zt),ut.unshift(zt);return ut}function p(M){var O,H=M.route.length>=2&&M.segment<M.route.length-1;if(!H){var ee=(O=M.route[Math.min(M.segment,M.route.length-1)])!==null&&O!==void 0?O:M.startNode,j=_(ee,M.target);M.route=j.length?j:[ee],M.segment=0,M.distance=0,M.arrived=!1,M.active=M.route.length>=2;return}var K=M.route[M.segment],re=M.route[M.segment+1],J=_s(T(K),T(re));if(M.arrived||M.distance>=J-1e-4){var j=_(re,M.target);M.route=j.length?j:[re],M.segment=0,M.distance=0,M.arrived=!1,M.active=M.route.length>=2;return}var ne=_(re,M.target);M.route=ne.length?Jr([K],Zr(ne),!1):[K,re],M.segment=0}function S(M){var O,H=_(M.startNode,M.targetNode),ee=T(M.startNode),j=H.length>=2?T(H[1]):ee,K=H.length>=2?Math.atan2(j.y-ee.y,j.x-ee.x):0,re=Math.floor((K%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4,J=qa(qa({},M),{loop:(O=M.loop)!==null&&O!==void 0?O:"none",originNode:M.startNode,destinationNode:M.targetNode,target:M.targetNode,networkId:e,route:H.length?H:[M.startNode],segment:0,distance:0,x:ee.x,y:ee.y,heading:K,frame:[0,1,2,3][re],flipX:Math.cos(K)<0,hold:0,arrived:!1,active:M.active&&H.length>=2,blockedTicks:0,blockedEmitted:!1,speedMultiplier:1});return f.set(J.id,J),J}function B(M){if(b("pathArrive",M,M.target),M.loop==="none"){M.active=!1;return}var O=M.target,H=M.loop==="ping-pong"?O===M.destinationNode?M.originNode:M.destinationNode:O===M.originNode?M.destinationNode:M.originNode;M.startNode=O,M.target=H,M.route=_(O,H),M.segment=0,M.distance=0,M.arrived=!1,M.route.length<2&&(M.active=!1)}function b(M,O,H){o(M,{componentId:O.id,nodeId:H})}function I(M,O){var H,ee,j=M.route[M.segment+1],K=g(j);if(K&&!m(K)){M.blockedTicks++,M.blockedTicks>=30&&!M.blockedEmitted&&(M.blockedEmitted=!0,b("pathBlocked",M,j));return}if(!M.arrived){if(M.arrived=!0,M.segment+1===M.route.length-1){j===M.target?B(M):(M.active=!1,M.blockedEmitted||(M.blockedEmitted=!0,b("pathBlocked",M,j)));return}M.hold=Math.max((H=T(j).holdSeconds)!==null&&H!==void 0?H:0,(ee=K?.parameters.holdSeconds)!==null&&ee!==void 0?ee:0)}if(M.hold>0){M.hold=Math.max(0,M.hold-O),M.blockedTicks++,M.blockedTicks>=30&&!M.blockedEmitted&&(M.blockedEmitted=!0,b("pathBlocked",M,j));return}M.segment++,M.distance=0,M.arrived=!1,M.blockedTicks=0,M.blockedEmitted=!1}function z(M,O){var H,ee;if(M.spacing<=0)return O;var j=M.route[M.segment],K=M.route[M.segment+1],re=_s(T(j),T(K)),J=re-M.distance,ne=O;try{for(var Te=Ql(h.values()),fe=Te.next();!fe.done;fe=Te.next()){var pe=fe.value;if(!(pe.id===M.id||!pe.active||pe.route.length<2||pe.segment>=pe.route.length-1)){var Fe=pe.route[pe.segment],ae=pe.route[pe.segment+1],de=1/0;if(Fe===j&&ae===K&&(pe.distance>M.distance||pe.distance===M.distance&&pe.id<M.id))de=pe.distance-M.distance;else if(Fe===K)de=J+pe.distance;else if(ae===K&&Fe!==j){var _e=_s(T(Fe),T(ae))-pe.distance;_e<M.spacing&&(_e<J||_e===J&&pe.id<M.id)&&(de=J)}de<1/0&&(ne=Math.min(ne,Math.max(0,de-M.spacing)))}}}catch(Ge){H={error:Ge}}finally{try{fe&&!fe.done&&(ee=Te.return)&&ee.call(Te)}finally{if(H)throw H.error}}return ne}function U(M){var O=T(M.route[M.segment]),H=T(M.route[M.segment+1]),ee=_s(O,H),j=sv(M.distance/Math.max(1e-4,ee),0,1),K=O.x+(H.x-O.x)*j,re=O.y+(H.y-O.y)*j,J=Math.atan2(H.y-O.y,H.x-O.x),ne=Math.min(M.cornerRadius,ee/3),Te=M.route[M.segment+2];if(ne>0&&Te){var fe=T(Te),pe=_s(H,fe),Fe=Math.min(ne,pe/3);if(M.distance>ee-ne){var ae={x:H.x-(H.x-O.x)/ee*ne,y:H.y-(H.y-O.y)/ee*ne},de={x:H.x+(fe.x-H.x)/pe*Fe,y:H.y+(fe.y-H.y)/pe*Fe},_e=sv((M.distance-(ee-ne))/(ne*2),0,.5),Ge=1-_e;K=Ge*Ge*ae.x+2*Ge*_e*H.x+_e*_e*de.x,re=Ge*Ge*ae.y+2*Ge*_e*H.y+_e*_e*de.y;var $e=2*Ge*(H.x-ae.x)+2*_e*(de.x-H.x),ut=2*Ge*(H.y-ae.y)+2*_e*(de.y-H.y);Math.abs($e)+Math.abs(ut)>.001&&(J=Math.atan2(ut,$e))}}return{x:K,y:re,heading:J}}function Y(M){var O,H,ee,j;v+=M,y++;var K=Jr([],Zr(f.values()),!1).sort(function(wt,bt){return wt.id<bt.id?-1:wt.id>bt.id?1:0}),re=K.length?y%K.length:0,J=Jr(Jr([],Zr(K.slice(re)),!1),Zr(K.slice(0,re)),!1);try{for(var ne=Ql(J),Te=ne.next();!Te.done;Te=ne.next()){var fe=Te.value;if(!(!fe.active||fe.route.length<2||fe.segment>=fe.route.length-1)){var pe=fe.route[fe.segment],Fe=fe.route[fe.segment+1],ae=_s(T(pe),T(Fe));if(!(fe.distance>=ae-1e-4&&(I(fe,M),!fe.active||fe.route.length<2||fe.segment>=fe.route.length-1))){var de=fe.route[fe.segment],_e=fe.route[fe.segment+1],Ge=_s(T(de),T(_e)),$e=Ge-fe.distance,ut=(j=(ee=F(de,_e))===null||ee===void 0?void 0:ee.speedScale)!==null&&j!==void 0?j:1,zt=Math.min($e,fe.speed*ut*Math.max(0,fe.speedMultiplier)*M),ct=z(fe,zt);ct<=1e-4?(fe.blockedTicks++,fe.blockedTicks>=30&&!fe.blockedEmitted&&(fe.blockedEmitted=!0,b("pathBlocked",fe,_e))):(fe.distance+=ct,fe.blockedTicks=0,fe.blockedEmitted=!1);var Tt=U(fe);fe.x=Tt.x,fe.y=Tt.y,fe.heading=Tt.heading;var Zt=Math.floor((fe.heading%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4;fe.frame=[0,1,2,3][Zt],fe.flipX=Math.cos(fe.heading)<0}}}}catch(wt){O={error:wt}}finally{try{Te&&!Te.done&&(H=ne.return)&&H.call(ne)}finally{if(O)throw O.error}}}function E(){return{id:e,nodeCount:u.size,edgeCount:l.size,activeAgents:Jr([],Zr(f.values()),!1).filter(function(M){return M.active}).length,queuedAgents:Jr([],Zr(f.values()),!1).filter(function(M){return M.active&&M.blockedTicks>0}).length,agents:Jr([],Zr(f.values()),!1).map(function(M){var O;return{id:M.id,x:M.x,y:M.y,heading:M.heading,frame:(O=M.frame)!==null&&O!==void 0?O:0,flipX:!!M.flipX,active:M.active,targetNode:M.target,route:Jr([],Zr(M.route),!1),segment:M.segment,distance:M.distance,blocked:M.blockedTicks>0}})}}return{addAgent:S,removeAgent:function(M){return f.delete(M)},getAgent:function(M){return f.get(M)},setTarget:function(M,O){var H=f.get(M);return!H||!T(O)?!1:(H.target=O,H.destinationNode=O,H.active=!0,p(H),!0)},setEdge:function(M,O,H){var ee,j,K=l.get(M);if(!K)return!1;K.enabled=O,H!==void 0&&(K.cost=H);try{for(var re=Ql(f.values()),J=re.next();!J.done;J=re.next()){var ne=J.value;p(ne)}}catch(Te){ee={error:Te}}finally{try{J&&!J.done&&(j=re.return)&&j.call(re)}finally{if(ee)throw ee.error}}return!0},setGate:function(M,O,H){var ee,j,K=d.get(M);if(!K)return!1;K.parameters=qa(qa({},K.parameters),{mode:O,holdSeconds:H});try{for(var re=Ql(f.values()),J=re.next();!J.done;J=re.next()){var ne=J.value;p(ne)}}catch(Te){ee={error:Te}}finally{try{J&&!J.done&&(j=re.return)&&j.call(re)}finally{if(ee)throw ee.error}}return!0},tick:Y,snapshot:E}}var jl=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Ld=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Dd=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Nd={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"]},ec=function(n){var e,t,i,r,a=0;try{for(var s=jl(n),o=s.next();!o.done;o=s.next()){var u=o.value;a+=((r=(i=Nd[u])===null||i===void 0?void 0:i[0].length)!==null&&r!==void 0?r:5)+1}}catch(l){e={error:l}}finally{try{o&&!o.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return Math.max(0,a-1)},Rb=function(n,e){var t,i,r=[],a="";try{for(var s=jl(n),o=s.next();!o.done;o=s.next()){var u=o.value;a&&ec(a+u)>e&&(r.push(a),a=""),a+=u}}catch(l){t={error:l}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return a&&r.push(a),r};function Pb(n,e,t){var i,r,a,s,o;t===void 0&&(t=1);var u=Math.max(1,Math.floor(e/Math.max(1,t))),l=[];try{for(var d=jl(String(n).toUpperCase().split(`
4221
- `)),f=d.next();!f.done;f=d.next()){var h=f.value,v=h.split(/\s+/).filter(Boolean);if(!v.length){l.push("");continue}var y="";try{for(var T=(a=void 0,jl(v)),g=T.next();!g.done;g=T.next()){var m=g.value;if(ec(m)>u){y&&l.push(y);var L=Rb(m,u);l.push.apply(l,Dd([],Ld(L.slice(0,-1)),!1)),y=(o=L.at(-1))!==null&&o!==void 0?o:""}else{var F=y?y+" "+m:m;ec(F)<=u?y=F:(y&&l.push(y),y=m)}}}catch(_){a={error:_}}finally{try{g&&!g.done&&(s=T.return)&&s.call(T)}finally{if(a)throw a.error}}y&&l.push(y)}}catch(_){i={error:_}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(i)throw i.error}}return l}var lv=function(n){var e,t=Math.max(0,(e=n.padding)!==null&&e!==void 0?e:4),i=n.pixelPanel&&n.padding===void 0;return{x:i?8:t,y:i?4:t}},Lb=function(n,e,t,i){var r,a=e.wrap===!1?String(n).toUpperCase().split(`
4222
- `):Pb(n,i,t),s=a.slice(0,16),o=Math.round(t*8*((r=e.lineHeight)!==null&&r!==void 0?r:1.2));return{allLines:a,lines:s,renderedWidth:Math.max.apply(Math,Dd([0],Ld(s.map(function(u){return ec(u)*t})),!1)),renderedHeight:(s.length-1)*o+7*t}};function Yh(n,e){for(var t,i=lv(e),r=Math.max(0,e.width-2*i.x),a=Math.max(0,e.height-2*i.y),s=Math.max(1,Math.floor(e.fontSize/8)),o=e.autoFit===!1?s:Math.min(s,Math.max(1,Math.ceil(((t=e.minFontSize)!==null&&t!==void 0?t:12)/8))),u=Dd([],Ld(new Set(Dd([],Ld(String(n).toUpperCase()),!1).filter(function(y){return y!==`
4223
- `&&!Nd[y]}))),!1),l,d=s;d>=o;d--){var f=Lb(n,e,d,r),h=f.renderedWidth>r,v=f.allLines.length>16||f.renderedHeight>a;if(l={lines:f.lines,scale:d,fontSize:d*8,renderedWidth:f.renderedWidth,renderedHeight:f.renderedHeight,overflowsWidth:h,overflowsHeight:v,unsupportedChars:u},e.autoFit===!1||!h&&!v)break}return l}function cv(n,e,t){var i,r=Yh(e,t),a=r.lines,s=r.scale,o=lv(t),u=Math.max(0,t.width-2*o.x),l=Math.max(0,t.height-2*o.y),d=Math.round(r.fontSize*((i=t.lineHeight)!==null&&i!==void 0?i:1.2)),f=o.y+(l-r.renderedHeight)/2;return n.fillStyle=t.color,a.forEach(function(h,v){var y,T,g,m=ec(h)*s,L=t.align==="left"?o.x:t.align==="right"?t.width-m-o.x:o.x+(u-m)/2,F=L;try{for(var _=jl(h),p=_.next();!p.done;p=_.next()){var S=p.value,B=(g=Nd[S])!==null&&g!==void 0?g:Nd["?"];B.forEach(function(b,I){for(var z=0;z<b.length;z++)b[z]==="1"&&n.fillRect(Math.round(F+z*s),Math.round(f+v*d+I*s),s,s)}),F+=(B[0].length+1)*s}}catch(b){y={error:b}}finally{try{p&&!p.done&&(T=_.return)&&T.call(_)}finally{if(y)throw y.error}}}),r}var Ra=function(){return Ra=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Ra.apply(this,arguments)},Zh=Math.PI*2,hi=function(n,e){return((Math.imul(n+1,2654435769)^Math.imul(e,2246822507))>>>0)/4294967296};function Jh(n,e,t){var i,r,a=[n.color,n.color2,n.color3].filter(Boolean),s=((i=n.spread)!==null&&i!==void 0?i:360)*Math.PI/180,o=((r=n.direction)!==null&&r!==void 0?r:-90)*Math.PI/180;return Array.from({length:n.count},function(u,l){var d,f,h=o+((l+.2+hi(l,1)*.6)/n.count-.5)*s,v=n.speed*(.42+.65*hi(l,2));return Ra(Ra({},e),{clipId:t,shape:"pixel-confetti",age:-.12*hi(l,3),vx:Math.cos(h)*v,vy:Math.sin(h)*v,gravity:(d=n.gravity)!==null&&d!==void 0?d:250,life:((f=n.lifetime)!==null&&f!==void 0?f:.7)*(.6+.4*hi(l,4)),color:a[l%a.length],size:3+Math.floor(3*hi(l,5)),angle:Zh*hi(l,6),spin:(hi(l,7)-.5)*12})})}function uv(n){var e=Math.min(12,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return Jh(n).map(function(r,a){return Ra(Ra({},r),{screen:!0,x:(a%e+.15+.7*hi(a,8))/e,y:(Math.floor(a/e)+.15+.7*hi(a,9))/t,vx:i*(hi(a,10)-.5)*.7,vy:i*(.3+.5*hi(a,11)),size:r.size+1})})}var Fd=function(n,e){return(n%e+e)%e};function dv(n,e,t){var i=e.x,r=e.y,a=e.vx,s=e.vy,o=e.age,u=e.life,l=e.gravity,d=e.size,f=e.angle,h=e.spin,v=e.color;if(!(o<0)){var y=a*o,T=s*o+l*o*o/2,g=Math.round(t?t.x+Fd(i*t.width+y,t.width):i+y),m=Math.round(t?t.y+Fd(r*t.height+T,t.height):r+T),L=Math.round((f+h*o)/(Math.PI/4))&3;if(n.globalAlpha*=Math.min(1,(u-o)*4),n.fillStyle="#3c293388",L===0)n.fillRect(g-d+1,m+1,d*2+1,d+1);else if(L===2)n.fillRect(g+1,m-d+1,d+1,d*2+1);else for(var F=-1;F<=1;F++)n.fillRect(g+F*d+1,m+F*d*(L===1?1:-1)+1,d+1,d+1);if(n.fillStyle=v,L===0)n.fillRect(g-d,m,d*2,d);else if(L===2)n.fillRect(g,m-d,d,d*2);else for(var F=-1;F<=1;F++)n.fillRect(g+F*d,m+F*d*(L===1?1:-1),d,d)}}function $h(n,e,t){var i,r,a=[n.color,n.color2,n.color3,"#ff6b6b","#4ecdc4","#fff3b0"].filter(Boolean),s=((i=n.spread)!==null&&i!==void 0?i:360)*Math.PI/180,o=((r=n.direction)!==null&&r!==void 0?r:-90)*Math.PI/180;return Array.from({length:n.count},function(u,l){var d,f,h=o+((l+.2+hi(l,11)*.6)/n.count-.5)*s,v=n.speed*(.45+.65*hi(l,12));return Ra(Ra({},e),{clipId:t,shape:"confetti",age:-.15*hi(l,13),vx:Math.cos(h)*v,vy:Math.sin(h)*v,gravity:(d=n.gravity)!==null&&d!==void 0?d:140,life:((f=n.lifetime)!==null&&f!==void 0?f:2.6)*(.75+.35*hi(l,14)),color:a[l%a.length],size:5+Math.floor(5*hi(l,15)),kind:l%5===0?"star":"ribbon",angle:Zh*hi(l,16),spin:(hi(l,17)-.5)*5.5,flutter:1.6+2.2*hi(l,18),phase:Zh*hi(l,19)})})}function fv(n){var e=Math.min(14,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return $h(n,{x:0,y:0}).map(function(r,a){var s;return Ra(Ra({},r),{screen:!0,x:(a%e+.12+.76*hi(a,20))/e,y:(Math.floor(a/e)+.08+.84*hi(a,21))/t,vx:i*(hi(a,22)-.5)*.65,vy:i*(.38+.55*hi(a,23)),gravity:Math.min((s=n.gravity)!==null&&s!==void 0?s:90,90)})})}function hv(n,e,t){var i=e.x,r=e.y,a=e.vx,s=e.vy,o=e.age,u=e.life,l=e.gravity,d=e.size,f=e.angle,h=e.spin,v=e.flutter,y=e.phase,T=e.color,g=e.kind;if(!(o<0)){var m=Math.sin(o*v+y)*14,L=a*o+m,F=s*o+l*o*o/2,_=t?t.x+Fd(i*t.width+L,t.width):i+L,p=t?t.y+Fd(r*t.height+F,t.height):r+F,S=Math.min(1,o*2.8,(u-o)*2.2);if(!(S<=0)){n.save(),n.globalAlpha*=S,n.translate(_,p),n.rotate(f+h*o);var B=Math.cos(o*v*1.4+y);if(n.scale(1,Math.max(.22,Math.abs(B))),n.fillStyle=T,g==="star"){var b=d*.85;n.beginPath();for(var I=0;I<8;I++){var z=I%2===0?b:b*.38,U=I*Math.PI/4;I===0?n.moveTo(Math.cos(U)*z,Math.sin(U)*z):n.lineTo(Math.cos(U)*z,Math.sin(U)*z)}n.closePath(),n.fill()}else n.fillRect(-d*.7,-d*.34,d*1.4,d*.68),n.fillStyle="#ffffff55",n.fillRect(-d*.7,-d*.34,d*1.4,d*.2);n.restore()}}}function pv(n,e,t,i,r){var a=e.width,s=e.height;if(!(a<=0||s<=0)){var o=Math.min(3,Math.floor(Math.min(a,s)/8));if(!o){n.fillStyle=t,n.fillRect(0,0,a,s);return}var u=i?o*2:0,l=s-(i?o:o*3),d=r>=0?.5+.5*Math.sin(r*4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd05a99",n.shadowBlur=8+d*9,n.fillStyle=t,n.fillRect(o,u+o,a-2*o,s-u-2*o),n.restore()),n.fillStyle=e.stroke,n.fillRect(o,0,a-2*o,s),n.fillRect(0,o,a,s-2*o),n.fillStyle=t,n.fillRect(o,u+o,a-2*o,s-u-2*o),n.fillStyle="#431d1380",n.fillRect(o,l,a-2*o,s-o-l),n.fillStyle=e.enabled?"#fff4be":"#ffffff55",n.fillRect(2*o,u+o,a-4*o,i?o:o*2),n.fillStyle="#ffffff55",n.fillRect(o,u+3*o,o,Math.max(0,l-u-3*o)),n.fillStyle="#521b2444",n.fillRect(a-2*o,u+3*o,o,Math.max(0,l-u-3*o));var f=r>=0?r%1.9:-1,h=(f-.1)/.55;if(e.enabled&&!i&&h>=0&&h<1){n.save(),n.beginPath(),n.rect(2*o,u+3*o,a-4*o,Math.max(0,l-u-3*o)),n.clip();for(var v=Math.floor(((a+14*o)*h-6*o)/o)*o,y=u+3*o,T=0;y<l;y+=o,T++){var g=v-Math.floor(T/2)*o;n.fillStyle="#fff4be44",n.fillRect(g-2*o,y,9*o,o),n.fillStyle="#fffef0aa",n.fillRect(g,y,4*o,o)}n.restore()}if(e.enabled&&!i&&r>=0){var m=Math.max(0,Math.sin(r*4.2)),L=Math.max(0,Math.sin(r*4.2+2.2)),F=function(_,p,S){if(!(S<.25)){n.save(),n.globalAlpha*=S*.95,n.fillStyle="#fffef4";var B=S>.65?o*2:o;n.fillRect(Math.round(_-B),Math.round(p-o/2),B*2+o,o),n.fillRect(Math.round(_-o/2),Math.round(p-B),o,B*2+o),n.restore()}};F(5*o,u+4*o,m),F(a-6*o,u+5*o,L)}}}function Ud(n,e,t,i,r,a){var s=Math.max(0,Math.min(a,i/2,r/2));n.beginPath(),typeof n.roundRect=="function"?n.roundRect(e,t,i,r,s):(n.moveTo(e+s,t),n.arcTo(e+i,t,e+i,t+r,s),n.arcTo(e+i,t+r,e,t+r,s),n.arcTo(e,t+r,e,t,s),n.arcTo(e,t,e+i,t,s),n.closePath())}function qh(n,e,t,i,r){if(!(r<=.02||i<=.5)){n.save(),n.translate(e,t),n.globalAlpha*=r,n.fillStyle="#fffef0",n.beginPath();for(var a=0;a<8;a++){var s=a%2===0?i:i*.24,o=a*Math.PI/4;a===0?n.moveTo(Math.cos(o)*s,Math.sin(o)*s):n.lineTo(Math.cos(o)*s,Math.sin(o)*s)}n.closePath(),n.fill(),n.restore()}}function mv(n,e,t,i,r){var a,s,o,u=e.width,l=e.height;if(!(u<=0||l<=0)){var d=Math.min((a=e.radius)!==null&&a!==void 0?a:16,u/2,l/2),f=i?2:6,h=i?3:0,v=r>=0?.5-.5*Math.cos(r*2.4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd23f99",n.shadowBlur=10+v*12,Ud(n,0,h,u,l-h,d),n.fillStyle=t,n.fill(),n.restore()),n.save(),Ud(n,0,h+2,u,Math.max(4,l-h-2),d),n.fillStyle="#0e2830",n.fill(),n.restore(),n.save(),Ud(n,0,h,u,Math.max(4,l-f),d),n.fillStyle=t,n.fill(),n.clip();var y=(s=n.createLinearGradient)===null||s===void 0?void 0:s.call(n,0,h,0,l-f);if(y?.addColorStop&&(y.addColorStop(0,"#ffffffa8"),y.addColorStop(.42,"#ffffff26"),y.addColorStop(.45,"#00000000"),y.addColorStop(1,"#00000024"),n.fillStyle=y,n.fillRect(0,h,u,l-f)),n.fillStyle="#fffef0bb",n.fillRect(d*.55,h+3,Math.max(0,u-d*1.1),3),e.enabled&&!i&&r>=0){var T=(r%2.4-.15)/.95;if(T>0&&T<1){var g=T*T*(3-2*T),m=Math.sin(T*Math.PI),L=-u*.36+u*1.72*g;n.save(),n.globalAlpha*=m,n.translate(L,h),n.transform(1,0,-.36,1,0,0);var F=(o=n.createLinearGradient)===null||o===void 0?void 0:o.call(n,-48,0,48,0);F?.addColorStop?(F.addColorStop(0,"#ffffff00"),F.addColorStop(.32,"#ffffff48"),F.addColorStop(.5,"#fffef8cc"),F.addColorStop(.68,"#ffffff48"),F.addColorStop(1,"#ffffff00"),n.fillStyle=F,n.fillRect(-48,0,96,l)):(n.fillStyle="#fffef8a8",n.fillRect(-14,0,28,l)),n.restore()}}if(n.restore(),e.strokeWidth&&(n.save(),Ud(n,0,h,u,Math.max(4,l-f),d),n.strokeStyle=e.stroke,n.lineWidth=e.strokeWidth,n.stroke(),n.restore()),e.enabled&&!i&&r>=0){var _=Math.max(0,Math.sin(r*2.4)),p=_*_,S=Math.max(0,Math.sin(r*2.4+2.1)),B=S*S,b=Math.max(0,Math.sin(r*2.4+4.2)),I=b*b;qh(n,u*.12,h+9,4+p*6,p*.92),qh(n,u*.88,h+10,3.8+B*5.5,B*.9),qh(n,u*.76,Math.max(h+14,l-f-8),3+I*4.2,I*.8)}}}function Od(n){if(/\s/.test(n)||n.length>512)return!1;var e=/^https:\/\/play\.google\.com\/store\/apps\/details\?id=[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*){1,9}$/,t=/^https:\/\/apps\.apple\.com\/([a-z]{2}\/)?app\/([a-zA-Z0-9-]+\/)?id[1-9][0-9]{5,19}$/;return e.test(n)&&!/id=example\.|[.=]placeholder(\.|$)|id=com\.example(\.|$)/.test(n)||t.test(n)}var tc=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},nc=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Kh=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function vv(n){var e,t,i;n===void 0&&(n={});var r=(e=n.timeoutMs)!==null&&e!==void 0?e:5e3,a=(t=n.pollMs)!==null&&t!==void 0?t:25;if(![r,a].every(function(j){return Number.isFinite(j)&&j>=1&&j<=6e4}))throw Error("Invalid Unity host deadline/poll interval");var s=(i=n.getHost)!==null&&i!==void 0?i:(function(){return window.mraid}),o=new Set,u=new Set,l=[],d={},f=!1,h=!1,v=!1,y=!1,T=!1,g=!1,m,L,F,_,p,S,B=function(){return v||y};function b(){var j,K,re;clearTimeout(p),clearTimeout(S);try{for(var J=tc(l.splice(0)),ne=J.next();!ne.done;ne=J.next()){var Te=nc(ne.value,2),fe=Te[0],pe=Te[1];try{(re=d.mraid)===null||re===void 0||re.removeEventListener(fe,pe)}catch{}}}catch(Fe){j={error:Fe}}finally{try{ne&&!ne.done&&(K=J.return)&&K.call(J)}finally{if(j)throw j.error}}}function I(j){_?.(j instanceof Error?j:Error(String(j))),F=void 0,_=void 0}function z(j){var K,re;if(!B()){var J=f;if(v=!0,f=!1,h=!1,b(),I(j),J)try{for(var ne=tc(Kh([],nc(u),!1)),Te=ne.next();!Te.done;Te=ne.next()){var fe=Te.value;fe()}}catch(pe){K={error:pe}}finally{try{Te&&!Te.done&&(re=ne.return)&&re.call(ne)}finally{if(K)throw K.error}}o.clear(),u.clear()}}function U(j,K){return l.push([j,K]),d.mraid.addEventListener(j,K),Y(j,K)}function Y(j,K){if(B()){try{d.mraid.removeEventListener(j,K)}catch{}return!1}return!0}function E(j){var K,re;if(!B()){if(typeof j!="boolean"){z(Error("Invalid Unity viewability event"));return}if(!f){m=j;return}if(h!==j){h=j;try{for(var J=tc(Kh([],nc(o),!1)),ne=J.next();!ne.done;ne=J.next()){var Te=ne.value;if(B())break;Te(h)}}catch(fe){K={error:fe}}finally{try{ne&&!ne.done&&(re=J.return)&&re.call(J)}finally{if(K)throw K.error}}}}}var M=function(j){j==="hidden"&&z(Error("Unity host closed"))},O=function(){var j;f&&!B()&&((j=n.onResize)===null||j===void 0||j.call(n))};function H(){var j,K,re,J;if(!(!T||f||g||B())){g=!0;try{var ne=d.mraid.getState();if(B()||ne==="loading")return;if(ne==="hidden")throw Error("Unity host closed before ready");if(!["default","expanded","resized"].includes(ne))throw Error("Invalid Unity host state");var Te=d.mraid.getVersion();if(B())return;if(Te!=="3.0")throw Error("Unity Ads UA requires MRAID 3.0");try{for(var fe=tc([["viewableChange",E],["stateChange",M],["sizeChange",O]]),pe=fe.next();!pe.done;pe=fe.next()){var Fe=nc(pe.value,2),ae=Fe[0],de=Fe[1];if(!U(ae,de))return}}catch(zt){j={error:zt}}finally{try{pe&&!pe.done&&(K=fe.return)&&K.call(fe)}finally{if(j)throw j.error}}var _e=d.mraid.isViewable();if(B())return;if(typeof _e!="boolean")throw Error("Invalid Unity initial viewability");h=m??_e,f=!0,clearTimeout(p),clearTimeout(S),F?.(),F=void 0,_=void 0;try{for(var Ge=tc(Kh([],nc(o),!1)),$e=Ge.next();!$e.done;$e=Ge.next()){var ut=$e.value;if(B())break;ut(h)}}catch(zt){re={error:zt}}finally{try{$e&&!$e.done&&(J=Ge.return)&&J.call(Ge)}finally{if(re)throw re.error}}}catch(zt){z(zt)}finally{g=!1}}}function ee(){if(!B())try{var j=s();if(B())return;if(!j){S=setTimeout(ee,a);return}if(d.mraid=j,l.push(["ready",H]),d.mraid.addEventListener("ready",H),!Y("ready",H))return;T=!0,H()}catch(K){z(K)}}return{init:function(){return L||(L=new Promise(function(j,K){F=j,_=K}),B()?(I(Error("Unity bridge destroyed")),L):(p=setTimeout(function(){return z(Error("Unity MRAID readiness timed out"))},r),ee(),L))},isReady:function(){return f&&!B()},isVisible:function(){return f&&h&&!B()},isClosed:B,onVisibilityChanged:function(j){return B()||o.add(j),function(){return o.delete(j)}},onClosed:function(j){return B()||u.add(j),function(){return u.delete(j)}},openStore:function(j){if(!f||!h||B()||!Od(j))throw Error("Unity store request not permitted");d.mraid.open(j)},destroy:function(){y||(y=!0,f=!1,h=!1,b(),I(Error("Unity bridge destroyed")),o.clear(),u.clear())}}}var Uo=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Fo=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Qh=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function gv(n){var e;n===void 0&&(n={});var t=(e=n.getHost)!==null&&e!==void 0?e:(function(){return window.mraid}),i,r=!1,a=!1,s=!1,o=!1,u=!1,l,d,f,h,v,y=new Set,T=new Set,g=[];function m(){var U,Y;clearTimeout(h),clearTimeout(v);try{for(var E=Uo(g.splice(0)),M=E.next();!M.done;M=E.next()){var O=Fo(M.value,2),H=O[0],ee=O[1];try{i?.removeEventListener(H,ee)}catch{}}}catch(j){U={error:j}}finally{try{M&&!M.done&&(Y=E.return)&&Y.call(E)}finally{if(U)throw U.error}}}function L(U,Y){if(g.push([U,Y]),i.addEventListener(U,Y),s||o){try{i.removeEventListener(U,Y)}catch{}return!1}return!0}function F(U){var Y=U instanceof Error?U:Error(String(U));f?.(Y),d=void 0,f=void 0}function _(U,Y){var E,M;if(!(s||o)&&(s=!0,r=!1,a=!1,m(),F(U),Y))try{for(var O=Uo(Qh([],Fo(T),!1)),H=O.next();!H.done;H=O.next()){var ee=H.value;ee()}}catch(j){E={error:j}}finally{try{H&&!H.done&&(M=O.return)&&M.call(O)}finally{if(E)throw E.error}}}function p(){var U,Y,E,M;if(!(!u||r||s||o))try{var O=i.getState();if(s||o||O==="loading")return;if(O==="hidden"){_(Error("MRAID closed before ready"),!0);return}if(!["default","expanded","resized"].includes(O))throw Error("Invalid MRAID state");try{for(var H=Uo([["viewableChange",B],["stateChange",b],["sizeChange",I]]),ee=H.next();!ee.done;ee=H.next()){var j=Fo(ee.value,2),K=j[0],re=j[1];if(!L(K,re))return}}catch(fe){U={error:fe}}finally{try{ee&&!ee.done&&(Y=H.return)&&Y.call(H)}finally{if(U)throw U.error}}var J=i.isViewable();if(s||o)return;if(typeof J!="boolean")throw Error("Invalid MRAID viewability");a=J,r=!0,clearTimeout(h),clearTimeout(v),d?.(),d=void 0,f=void 0;try{for(var ne=Uo(Qh([],Fo(y),!1)),Te=ne.next();!Te.done;Te=ne.next()){var re=Te.value;re(a)}}catch(fe){E={error:fe}}finally{try{Te&&!Te.done&&(M=ne.return)&&M.call(ne)}finally{if(E)throw E.error}}}catch(fe){_(fe,r)}}var S=function(){return p()},B=function(U){var Y,E;if(!(!r||s||o)){if(typeof U!="boolean"){_(Error("Invalid MRAID visibility event"),!0);return}a=U;try{for(var M=Uo(Qh([],Fo(y),!1)),O=M.next();!O.done;O=M.next()){var H=O.value;H(a)}}catch(ee){Y={error:ee}}finally{try{O&&!O.done&&(E=M.return)&&E.call(M)}finally{if(Y)throw Y.error}}}},b=function(U){U==="hidden"&&_(Error("MRAID closed"),!0)},I=function(){var U;r&&!s&&!o&&((U=n.onResize)===null||U===void 0||U.call(n))};function z(){var U,Y,E;if(!(s||o))try{if(i=t(),s||o)return;if(!i){v=setTimeout(z,(E=n.pollMs)!==null&&E!==void 0?E:50);return}if(![i.getState,i.isViewable,i.addEventListener,i.removeEventListener,i.open].every(function(K){return typeof K=="function"}))throw Error("Incomplete MRAID 2 interface");try{for(var M=Uo([["ready",S]]),O=M.next();!O.done;O=M.next()){var H=Fo(O.value,2),ee=H[0],j=H[1];if(!L(ee,j))return}}catch(K){U={error:K}}finally{try{O&&!O.done&&(Y=M.return)&&Y.call(M)}finally{if(U)throw U.error}}u=!0,p()}catch(K){_(K,!1)}}return{init:function(){var U;return l||(l=new Promise(function(Y,E){d=Y,f=E}),s||o?(F(Error("MRAID bridge destroyed")),l):(h=setTimeout(function(){return _(Error("MRAID readiness timed out"),!1)},(U=n.timeoutMs)!==null&&U!==void 0?U:5e3),z(),l))},isReady:function(){return r&&!s&&!o},isVisible:function(){return a&&r&&!s&&!o},isClosed:function(){return s||o},onVisibilityChanged:function(U){return!s&&!o&&y.add(U),function(){return y.delete(U)}},onClosed:function(U){return!s&&!o&&T.add(U),function(){return T.delete(U)}},openStore:function(U){if(!r||!a||s||o||!Od(U))throw Error("MRAID store request not permitted");i.open(U)},destroy:function(){o||(o=!0,r=!1,a=!1,m(),F(Error("MRAID bridge destroyed")),y.clear(),T.clear())}}}var zs=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Vs=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},ic=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function yv(n){n===void 0&&(n={});var e=new Set,t=new Set,i=new Set,r=[],a,s=!1,o=!1,u=!1,l=!1,d,f,h,v,y,T=function(){return u||l};function g(){var I,z;clearTimeout(v),clearTimeout(y);try{for(var U=zs(r.splice(0)),Y=U.next();!Y.done;Y=U.next()){var E=Vs(Y.value,2),M=E[0],O=E[1];try{a?.removeEventListener(M,O)}catch{}}}catch(H){I={error:H}}finally{try{Y&&!Y.done&&(z=U.return)&&z.call(U)}finally{if(I)throw I.error}}}function m(I){var z,U;if(!T()){u=!0,s=!1,o=!1,g(),h?.(I instanceof Error?I:Error(String(I))),f=void 0,h=void 0;try{for(var Y=zs(ic([],Vs(t),!1)),E=Y.next();!E.done;E=Y.next()){var M=E.value;M()}}catch(O){z={error:O}}finally{try{E&&!E.done&&(U=Y.return)&&U.call(Y)}finally{if(z)throw z.error}}}}var L=function(I){if(!(typeof I!="number"||!Number.isFinite(I)||I<0))return Math.min(1,I>1?I/100:I)},F=function(I){if(typeof I=="boolean")return I;if(I&&typeof I=="object"&&typeof I.isViewable=="boolean")return I.isViewable},_=function(){var I,z,U,Y,E,M;if(!(s||T()||!a||((E=a.isReady)===null||E===void 0?void 0:E.call(a))===!1))try{o=a.isViewable();var O=(M=a.getAudioVolume)===null||M===void 0?void 0:M.call(a),H=O===void 0?void 0:L(O);if(typeof o!="boolean"||O!==void 0&&H===void 0)throw Error("Invalid DAPI initial state");if(s=!0,clearTimeout(v),clearTimeout(y),f?.(),f=void 0,h=void 0,H!==void 0)try{for(var ee=zs(ic([],Vs(i),!1)),j=ee.next();!j.done;j=ee.next()){var K=j.value;K(H)}}catch(ne){I={error:ne}}finally{try{j&&!j.done&&(z=ee.return)&&z.call(ee)}finally{if(I)throw I.error}}try{for(var re=zs(ic([],Vs(e),!1)),J=re.next();!J.done;J=re.next()){var K=J.value;K(o)}}catch(ne){U={error:ne}}finally{try{J&&!J.done&&(Y=re.return)&&Y.call(re)}finally{if(U)throw U.error}}}catch(ne){m(ne)}},p=function(I){var z,U;if(!T()){var Y=F(I);if(Y===void 0){m(Error("Invalid DAPI visibility"));return}o=Y;try{for(var E=zs(ic([],Vs(e),!1)),M=E.next();!M.done;M=E.next()){var O=M.value;O(Y)}}catch(H){z={error:H}}finally{try{M&&!M.done&&(U=E.return)&&U.call(E)}finally{if(z)throw z.error}}}},S=function(I){var z,U;if(!T()){var Y=L(I);if(Y===void 0){m(Error("Invalid DAPI volume"));return}try{for(var E=zs(ic([],Vs(i),!1)),M=E.next();!M.done;M=E.next()){var O=M.value;O(Y)}}catch(H){z={error:H}}finally{try{M&&!M.done&&(U=E.return)&&U.call(E)}finally{if(z)throw z.error}}}},B=function(){var I;s&&!T()&&((I=n.onResize)===null||I===void 0||I.call(n))};function b(){var I,z,U;if(!T()){if(a=window.dapi,!a){y=setTimeout(b,(U=n.pollMs)!==null&&U!==void 0?U:25);return}try{try{for(var Y=zs([["ready",_],["viewableChange",p],["audioVolumeChange",S],["adResized",B]]),E=Y.next();!E.done;E=Y.next()){var M=Vs(E.value,2),O=M[0],H=M[1];r.push([O,H]),a.addEventListener(O,H)}}catch(ee){I={error:ee}}finally{try{E&&!E.done&&(z=Y.return)&&z.call(Y)}finally{if(I)throw I.error}}_()}catch(ee){m(ee)}}}return{init:function(){var I;return d||(d=new Promise(function(z,U){f=z,h=U}),T()?(h?.(Error("DAPI bridge closed")),d):(v=setTimeout(function(){return m(Error("DAPI readiness timed out"))},(I=n.timeoutMs)!==null&&I!==void 0?I:5e3),b(),d))},isReady:function(){return s&&!T()},isVisible:function(){return s&&o&&!T()},isClosed:T,onVisibilityChanged:function(I){return T()||e.add(I),function(){return e.delete(I)}},onClosed:function(I){return T()||t.add(I),function(){return t.delete(I)}},onVolumeChanged:function(I){return T()||i.add(I),function(){return i.delete(I)}},openStore:function(){if(!s||!o||T()||typeof a?.openStoreUrl!="function")throw Error("DAPI store host unavailable");a.openStoreUrl()},destroy:function(){l||(l=!0,s=!1,o=!1,g(),h?.(Error("DAPI bridge destroyed")),e.clear(),t.clear(),i.clear())}}}var Db=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},Nb=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Ub=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Fb=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Ob=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function xv(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=Ob(Fb([],Ub(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return Db(this,void 0,void 0,function(){return Nb(this,function(a){switch(a.label){case 0:if(i)throw Error("Meta bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("Meta bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a=window.FbPlayableAd;if(!e||!t||i||typeof a?.onCTAClick!="function")throw Error("Meta CTA host unavailable");a.onCTAClick()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var Bb=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},kb=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},zb=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Vb=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Gb=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function _v(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=Gb(Vb([],zb(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return Bb(this,void 0,void 0,function(){return kb(this,function(a){switch(a.label){case 0:if(i)throw Error("Google Ads bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("Google Ads bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a=window.ExitApi;if(!e||!t||i||typeof a?.exit!="function")throw Error("Google ExitApi unavailable");a.exit()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var Hb=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},Wb=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},jh=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},ep=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},tp=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Mv(){var n=window,e=new Set,t=new Set,i=n.gameStart,r=n.gameClose,a=!1,s=!1,o=!1,u=!1,l=function(){var f,h;if(!(o||u)){var v=!s||!a;if(a=!0,s=!0,v)try{for(var y=tp(ep([],jh(e),!1)),T=y.next();!T.done;T=y.next()){var g=T.value;g(!0)}}catch(m){f={error:m}}finally{try{T&&!T.done&&(h=y.return)&&h.call(y)}finally{if(f)throw f.error}}}},d=function(){var f,h,v,y;if(!(o||u)){a=!1,s=!1,o=!0;try{for(var T=tp(ep([],jh(e),!1)),g=T.next();!g.done;g=T.next()){var m=g.value;m(!1)}}catch(_){f={error:_}}finally{try{g&&!g.done&&(h=T.return)&&h.call(T)}finally{if(f)throw f.error}}try{for(var L=tp(ep([],jh(t),!1)),F=L.next();!F.done;F=L.next()){var m=F.value;m()}}catch(_){v={error:_}}finally{try{F&&!F.done&&(y=L.return)&&y.call(L)}finally{if(v)throw v.error}}}};return n.gameStart=l,n.gameClose=d,{init:function(){return Hb(this,void 0,void 0,function(){return Wb(this,function(f){if(o||u)throw Error("Mintegral bridge closed");if(typeof n.gameReady!="function")throw Error("Mintegral gameReady host unavailable");return n.gameReady(),[2]})})},isReady:function(){return a&&!o&&!u},isVisible:function(){return a&&s&&!o&&!u},isClosed:function(){return o||u},onVisibilityChanged:function(f){return!o&&!u&&e.add(f),function(){return e.delete(f)}},onClosed:function(f){return!o&&!u&&t.add(f),function(){return t.delete(f)}},notifyGameEnd:function(){var f;!o&&!u&&((f=n.gameEnd)===null||f===void 0||f.call(n))},notifyGameRetry:function(){var f;!o&&!u&&((f=n.gameRetry)===null||f===void 0||f.call(n))},openStore:function(){if(!a||!s||o||u||typeof n.install!="function")throw Error("Mintegral install host unavailable");n.install()},destroy:function(){u||(u=!0,a=!1,s=!1,n.gameStart===l&&(i?n.gameStart=i:delete n.gameStart),n.gameClose===d&&(r?n.gameClose=r:delete n.gameClose),e.clear(),t.clear())}}}var Xb=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},Yb=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},qb=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Zb=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Jb=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Sv(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=Jb(Zb([],qb(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return Xb(this,void 0,void 0,function(){return Yb(this,function(a){switch(a.label){case 0:if(i)throw Error("TikTok bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("TikTok bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a,s,o=window,u=typeof o.openAppStore=="function"?o.openAppStore.bind(o):(s=(a=o.playableSDK)===null||a===void 0?void 0:a.openAppStore)===null||s===void 0?void 0:s.bind(o.playableSDK);if(!e||!t||i||!u)throw Error("TikTok store host unavailable");u()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var gt=function(){return gt=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},gt.apply(this,arguments)},$b=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},Kb=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},De=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Ke=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},Ue=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function wv(n){if(n!=="standalone"){if(n==="unity-ads-ua-playable")return vv();if(n==="applovin-growth-playable")return gv();if(n==="ironsource-levelplay-playable")return yv();if(n==="meta-audience-playable")return xv();if(n==="google-ads-app-playable")return _v();if(n==="mintegral-appgrowth-zip")return Mv();if(n==="tiktok-ads-playable")return Sv();throw Error("E_NATIVE_TARGET")}}function np(n){var e=[{id:"sdk-top-left",left:0,top:0,right:Math.min(48,n.width),bottom:Math.min(48,n.height)},{id:"sdk-top-right",left:Math.max(0,n.width-56),top:0,right:n.width,bottom:Math.min(56,n.height)},{id:"sdk-bottom-left",left:0,top:Math.max(0,n.height-28),right:Math.min(48,n.width),bottom:n.height}];return{left:Math.min(48,n.width),top:Math.min(56,n.height),right:Math.max(0,n.width-56),bottom:Math.max(0,n.height-28),zones:e}}function Bd(n,e){var t,i,r=(i=(t=n.measureText)===null||t===void 0?void 0:t.call(n,e))===null||i===void 0?void 0:i.width,a=/(\d+(?:\.\d+)?)px/.exec(n.font||"");return Number.isFinite(r)?r:Ke([],De(e),!1).length*(a?Number(a[1]):16)*.6}function bv(n,e,t,i){var r,a,s,o,u,l,d;n.font=t.fontWeight+" "+i+"px "+t.fontFamily;var f=Math.max(0,t.width-2*((d=t.padding)!==null&&d!==void 0?d:4)),h=[];try{for(var v=Ue(String(e).split(`
4224
- `)),y=v.next();!y.done;y=v.next()){var T=y.value;if(t.wrap===!1){h.push(T);continue}var g=T.trim()?T.trim().split(/\s+/):[""],m=void 0;try{for(var L=(s=void 0,Ue(g)),F=L.next();!F.done;F=L.next()){var _=F.value,p=m?m+" "+_:_;if(Bd(n,p)<=f){m=p;continue}if(m&&h.push(m),Bd(n,_)<=f){m=_;continue}var S="";try{for(var B=(u=void 0,Ue(_)),b=B.next();!b.done;b=B.next()){var I=b.value;S&&Bd(n,S+I)>f?(h.push(S),S=I):S+=I}}catch(z){u={error:z}}finally{try{b&&!b.done&&(l=B.return)&&l.call(B)}finally{if(u)throw u.error}}m=S}}catch(z){s={error:z}}finally{try{F&&!F.done&&(o=L.return)&&o.call(L)}finally{if(s)throw s.error}}h.push(m)}}catch(z){r={error:z}}finally{try{y&&!y.done&&(a=v.return)&&a.call(v)}finally{if(r)throw r.error}}return h}function Tv(n,e,t){var i,r,a=(i=t.padding)!==null&&i!==void 0?i:4,s=Math.max(0,t.width-2*a),o=Math.max(0,t.height-2*a),u=Math.min(t.fontSize,(r=t.minFontSize)!==null&&r!==void 0?r:12),l=t.fontSize,d=bv(n,e,t,l),f,h=function(){var v;n.font=t.fontWeight+" "+l+"px "+t.fontFamily;var y=Math.max.apply(Math,Ke([0],De(d.map(function(L){return Bd(n,L)})),!1)),T=l*((v=t.lineHeight)!==null&&v!==void 0?v:1.2),g=d.length>16;g&&(d=d.slice(0,16));var m=d.length*T;return{lines:d,fontSize:l,scale:l/t.fontSize,renderedWidth:y,renderedHeight:m,availableWidth:s,availableHeight:o,padding:a,lineHeight:T,overflowsWidth:y>s+.01,overflowsHeight:g||m>o+.01,unsupportedChars:[]}};if(f=h(),t.autoFit!==!1)for(;(f.overflowsWidth||f.overflowsHeight)&&l>u;)l=Math.max(u,l-1),d=bv(n,e,t,l),f=h();return f}function Qb(n,e,t){var i=Tv(n,e,t),r=i.padding;n.fillStyle=t.color,n.font=t.fontWeight+" "+i.fontSize+"px "+t.fontFamily,n.textAlign=t.align,n.textBaseline="middle";var a=t.align==="left"?r:t.align==="right"?t.width-r:t.width/2,s=(t.height-i.renderedHeight)/2;return i.lines.forEach(function(o,u){return n.fillText(o,a,s+(u+.5)*i.lineHeight)}),i}function jb(n,e,t){var i,r,a,s,o,u,l=t===void 0?{}:t,d=l.edit,f=d===void 0?!1:d,h=l.sceneId,v=h===void 0?n.base.startScene:h,y=l.onSelect,T=y===void 0?function(){}:y,g=l.network,m=g===void 0?"standalone":g,L=l.review,F=L===void 0?!1:L,_=wv(m),p=e.getContext("2d"),S=new Map(n.components.map(function(c){return[c.id,c]})),B=new Map(n.assets.map(function(c){return[c.id,c]})),b=new Map,I=new Map(n.events.map(function(c){return[c.id,c]})),z=new Map(n.gameplay.filter(function(c){return c.kind==="responsive-layout"}).map(function(c){return[c.componentId,c.parameters]})),U=(a=globalThis.matchMedia)===null||a===void 0?void 0:a.call(globalThis,"(prefers-reduced-motion: reduce)"),Y,E=new Map,M=E;function O(){var c=z.size>0&&e.clientWidth>e.clientHeight;return{width:c?Math.max(n.base.width,n.base.height):n.base.width,height:c?Math.min(n.base.width,n.base.height):n.base.height,landscape:c}}function H(){Y!==O().landscape&&(gr(),ei())}try{for(var ee=Ue(n.assets),j=ee.next();!j.done;j=ee.next()){var K=j.value;if(K.mime.startsWith("image/")){var re=new Image;re.src="data:"+K.mime+";base64,"+K.data,b.set(K.id,re)}}}catch(c){i={error:c}}finally{try{j&&!j.done&&(r=ee.return)&&r.call(ee)}finally{if(i)throw i.error}}var J=v,ne={},Te=[],fe=[],pe=[],Fe=[],ae=new Set,de=new Map,_e=0,Ge=0,$e=0,ut=0,zt=0,ct=!1,Tt=0,Zt=0,wt=!1,bt=[],_t,ln,rt,an,se,mn,nn,W,w,ue=[],ye,we=[],ze=[],Ye,Re=0,Ae=!1,Ne=0,je=m==="standalone",Ve=m==="standalone",qe=m==="standalone",ot=!1,pt=!1,He=new Map,ie=new Map,Oe=new Map,Pe=new Map,nt=new Set,dt=new Map,Be=new Set,Rt=new Map,vt=new Map,cn=new Map,dn=new Map,Fn=new Map,Dn=new Map,vi=0,rr=0,yn,En,Yi=1,en,xt=new Map,ni=new Map,fn=new Map,bi=new Map,qi=new Map,wi=new Map,gi=new Map,Bn=Up(),ar=Bp(),la=new Map,Za=new Map,Ei=Hp(zp(n.projectId)),mr=new Map,sr=new Map,Vr=new Map,D=new Set,le=new Map,he,Me=1,Se=1,ke,et,Je={x:0,y:0},ft,Dt=[],tn=[],$t=new Map,Et=new Map,hn=new Map,Vn=new Map,It,Qt,jt;n.components.some(function(c){return c.contract==="native.stage3d.v1"})&&(jt=av(n,B,function(){pt||Promise.resolve().then(function(){pt||ei()})}));var Le=function(c){var x;return(x=Oe.get(c))!==null&&x!==void 0?x:S.get(c)},An=function(c,x){return n.gameplay.find(function(R){return R.kind===c&&R.componentId===x})},pn=function(){var c,x;vi++,Be.clear(),Rt.clear(),cn.clear(),dn.clear();try{for(var R=Ue(nt),A=R.next();!A.done;A=R.next()){var C=A.value;try{C.stop()}catch{}}}catch(N){c={error:N}}finally{try{A&&!A.done&&(x=R.return)&&x.call(R)}finally{if(c)throw c.error}}nt.clear(),vt.clear()},yi=function(c){var x,R;if(!he||c!==void 0&&he.pointerId!==c)return!1;var A=he.pointerId;he.behavior.parameters.powerVariableId&&(ne[he.behavior.parameters.powerVariableId]=0),he=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,A)&&((R=e.releasePointerCapture)===null||R===void 0||R.call(e,A))}catch{}return!0},or=function(c){var x,R,A;if(!It||c!==void 0&&It.pointerId!==c)return!1;var C=It.pointerId;It.behavior.parameters.powerVariableId&&(ne[It.behavior.parameters.powerVariableId]=0),(x=jt?.getStage(S.get(It.stageId)))===null||x===void 0||x.setGuide([]),It=void 0;try{!((R=e.hasPointerCapture)===null||R===void 0)&&R.call(e,C)&&((A=e.releasePointerCapture)===null||A===void 0||A.call(e,C))}catch{}return!0},Li=function(c){var x,R;if(!Qt||c!==void 0&&Qt.pointerId!==c)return!1;var A=Qt.pointerId;Qt=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,A)&&((R=e.releasePointerCapture)===null||R===void 0||R.call(e,A))}catch{}return!0},vr=function(c){var x=c.behavior.parameters;x.axisXVariableId&&(ne[x.axisXVariableId]=c.nx),x.axisYVariableId&&(ne[x.axisYVariableId]=c.ny),x.magnitudeVariableId&&(ne[x.magnitudeVariableId]=c.magnitude),x.angleVariableId&&c.magnitude>0&&(ne[x.angleVariableId]=c.angle)},Mn=function(c,x){var R,A,C,N;x===void 0&&(x=!1);try{for(var P=Ue(le.values()),X=P.next();!X.done;X=P.next()){var k=X.value;if(!(k.pointerId===null||c!==void 0&&k.pointerId!==c)){var Z=k.pointerId;k.pointerId=null,k.nx=0,k.ny=0,k.magnitude=0,k.knobX=k.origin.x,k.knobY=k.origin.y,vr(k);try{!((C=e.hasPointerCapture)===null||C===void 0)&&C.call(e,Z)&&((N=e.releasePointerCapture)===null||N===void 0||N.call(e,Z))}catch{}x&&Jt(pi("joystickEnd",k.c))}}}catch(V){R={error:V}}finally{try{X&&!X.done&&(A=P.return)&&A.call(P)}finally{if(R)throw R.error}}},Yn=function(c,x){var R,A;if(x===void 0&&(x=!0),!rt||c!==void 0&&rt.pointerId!==c)return!1;var C=rt,N=C.pointerId;if(rt=void 0,et=void 0,x){var P=Le(C.targetId);P&&C.b.parameters.snapBack&&(ua(P,C.origin.x,C.origin.y),C.originZone&&Bn.place(P.id,C.originZone))}try{!((R=e.hasPointerCapture)===null||R===void 0)&&R.call(e,N)&&((A=e.releasePointerCapture)===null||A===void 0||A.call(e,N))}catch{}return!0},Zi=function(c){var x,R;ye?.pointerId===c.pointerId&&(ye=void 0);try{for(var A=Ue(Fn.values()),C=A.next();!C.done;C=A.next()){var N=C.value;N.pointerId===c.pointerId&&N.held&&(N.held=!1,N.releasedAt=_e)}}catch(X){x={error:X}}finally{try{C&&!C.done&&(R=A.return)&&R.call(A)}finally{if(x)throw x.error}}var P=Yn(c.pointerId);return mn===c.pointerId?(se=void 0,mn=void 0,!0):P},kn=function(c){var x,R,A,C,N,P,X,k;if(c){rt&&((X=Oe.get(rt.targetId))===null||X===void 0?void 0:X.instanceId)===c&&Yn(void 0,!1),he&&((k=Oe.get(he.targetId))===null||k===void 0?void 0:k.instanceId)===c&&yi();var Z=[];Bn.release(c),ar.cancel(c),mr.delete(c),Vr.delete(c),Ei.remove(c),Te=Te.filter(function(be){return be.id!==c});try{for(var V=Ue(Oe),$=V.next();!$.done;$=V.next()){var q=De($.value,2),Q=q[0],te=q[1];if(te.instanceId===c){Z.push(Q),Bn.release(Q),ar.cancel(Q),Oe.delete(Q),He.delete(Q),Pe.delete(Q),fn.delete(Q),qi.delete(Q),wi.delete(Q);try{for(var G=(A=void 0,Ue(bi.values())),ce=G.next();!ce.done;ce=G.next()){var me=ce.value;me.removeAgent(Q)}}catch(be){A={error:be}}finally{try{ce&&!ce.done&&(C=G.return)&&C.call(G)}finally{if(A)throw A.error}}try{for(var ve=(N=void 0,Ue(ie.keys())),xe=ve.next();!xe.done;xe=ve.next()){var oe=xe.value;oe.endsWith(":"+Q)&&ie.delete(oe)}}catch(be){N={error:be}}finally{try{xe&&!xe.done&&(P=ve.return)&&P.call(ve)}finally{if(N)throw N.error}}}}}catch(be){x={error:be}}finally{try{$&&!$.done&&(R=V.return)&&R.call(V)}finally{if(x)throw x.error}}pe=pe.filter(function(be){return!Z.includes(be.targetId)})}},ki=function(c){for(;c;){if(c.prototype)return c.id;c=Le(c.parentId)}},ca=function(){var c,x,R;return{viewport:O(),components:Object.fromEntries(Ke([],De(He),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,gt(gt({},P),{parameters:gt({},P.parameters)})]})),mode:f?"edit":"play",scene:J,variables:gt({},ne),time:_e,instances:Te.map(function(A){return gt({id:A.id,prototypeId:A.prototypeId,x:A.transform[4],y:A.transform[5]},Ei.snapshot(A.id))}),particles:fe.length,animations:pe.length,contacts:ae.size,spriteFrames:Object.fromEntries(Ke([],De(Pe),!1).map(function(A){var C,N=De(A,2),P=N[0],X=N[1];return[P,(C=X.frame)!==null&&C!==void 0?C:0]})),input:{dragging:!!rt,pointerId:(x=(c=rt?.pointerId)!==null&&c!==void 0?c:ke?.pointerId)!==null&&x!==void 0?x:null,pressed:se??null,holding:!!ke?.holds.length,occupancy:Bn.snapshot(),joysticks:Object.fromEntries(Ke([],De(le),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,{active:P.pointerId!==null,x:P.nx,y:P.ny,magnitude:P.magnitude,angle:P.angle}]}))},feedback:{presses:Fn.size,floatingTexts:we.length,flashes:ze.length,shaking:!!Ye,tutorialHands:Ne},match:{boards:Object.fromEntries(Ke([],De(xt),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,P.snapshot()]})),selected:yn??null,cells:Ke([],De(Dn),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return gt({id:N},P)})},physics:Cv(),physics3d:Nv(),paths:Object.fromEntries(Ke([],De(bi),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,P.snapshot()]})),canvas:{masks:Object.fromEntries(Ke([],De(mr),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,{progress:P.progress}]})),strokes:Object.fromEntries(Ke([],De(sr),!1).map(function(A){var C=De(A,2),N=C[0],P=C[1];return[N,P.strokes.length]})),walls:Dt.length,joints:tn.filter(function(A){return!A.broken}).length},audio:{state:(R=_t?.state)!==null&&R!==void 0?R:"locked",voices:nt.size,blocked:rr},network:{target:m,ready:Ve,visible:qe,started:je,closed:ot,hostVolume:Yi},diagnostics:Ke([],De(bt),!1)}},lr=function(){return!f&&!ct&&!document.hidden&&Ve&&qe&&je&&!ot},gr=function(){var c,x,R,A;ye=void 0,yi(),or(),Li(),Mn(),Yn(),ke=void 0,et=void 0,ft=void 0;try{for(var C=Ue(sr.values()),N=C.next();!N.done;N=C.next()){var P=N.value;P.cancel()}}catch(V){c={error:V}}finally{try{N&&!N.done&&(x=C.return)&&x.call(C)}finally{if(c)throw c.error}}ar.clear(),En=void 0;try{for(var X=Ue(xt.values()),k=X.next();!k.done;k=X.next()){var Z=k.value;Z.cancelSelection()}}catch(V){R={error:V}}finally{try{k&&!k.done&&(A=X.return)&&A.call(X)}finally{if(R)throw R.error}}xt.size&&(yn=void 0),se=void 0,mn=void 0,Fn.clear()},Ai=function(c){wt=!0,bt.push(c),bt=bt.slice(-16),Fe=[]},Vt=function(c){var x,R,A;return gt(gt(gt({},c.parameters),c.prototypeId?(x=He.get(c.prototypeId))===null||x===void 0?void 0:x.parameters:{}),(A=He.get((R=c.runtimeId)!==null&&R!==void 0?R:c.id))===null||A===void 0?void 0:A.parameters)};function Sn(c,x){var R,A=Fn.get(c.id);if(!A||U?.matches)return x;var C=Ke([],De(x),!1),N=A.held?0:_e-((R=A.releasedAt)!==null&&R!==void 0?R:_e),P=A.held?0:Math.min(1,N/A.behavior.springBackSeconds),X=A.held?A.behavior.scaleDown:A.behavior.scaleDown+(1-A.behavior.scaleDown)*(1-Math.pow(1-P,3)),k=Vt(c);C[4]+=(1-X)*(C[0]*k.width+C[2]*k.height)/2,C[5]+=(1-X)*(C[1]*k.width+C[3]*k.height)/2;for(var Z=0;Z<4;Z++)C[Z]*=X;return C}function Di(c){var x,R,A,C,N,P,X,k=c.transform,Z=(A=(R=He.get((x=c.runtimeId)!==null&&x!==void 0?x:c.id))===null||R===void 0?void 0:R.transform)!==null&&A!==void 0?A:k,V=z.get((C=c.prototypeId)!==null&&C!==void 0?C:c.id);if(!V)return Sn(c,Z);var $=O(),q=Ke([],De(Z),!1);$.landscape&&(q[4]+=V.x-k[4],q[5]+=V.y-k[5],q[0]*=V.scaleX,q[1]*=V.scaleX,q[2]*=V.scaleY,q[3]*=V.scaleY);var Q=(N=V.anchor)!==null&&N!==void 0?N:"none";if(Q==="none"&&!V.respectSafeArea)return Sn(c,q);var te=V.respectSafeArea?np($):{left:0,top:0,right:$.width,bottom:$.height},G=Vt(c),ce=(P=V.marginX)!==null&&P!==void 0?P:0,me=(X=V.marginY)!==null&&X!==void 0?X:0,ve=Math.abs(q[0])*G.width+Math.abs(q[2])*G.height,xe=Math.abs(q[1])*G.width+Math.abs(q[3])*G.height;return Q!=="none"?(q[4]=Q.endsWith("left")?te.left+ce:Q.endsWith("right")?te.right-ve-ce:(te.left+te.right-ve)/2,q[5]=Q.startsWith("top")?te.top+me:Q.startsWith("bottom")?te.bottom-xe-me:(te.top+te.bottom-xe)/2):(q[4]=Math.max(te.left+ce,Math.min(te.right-ve-ce,q[4])),q[5]=Math.max(te.top+me,Math.min(te.bottom-xe-me,q[5]))),Sn(c,q)}var yr=function(c){return(Oe.has(c)?Ke([],De(Oe.values()),!1):Ke(Ke([],De(n.components),!1),De(Te),!1)).filter(function(x){return x.parentId===c&&!x.prototype}).sort(function(x,R){return x.order-R.order||(x.id<R.id?-1:x.id>R.id?1:0)})},Pa=function(){return n.components.filter(function(c){return c.sceneId===J&&!c.parentId&&!c.prototype}).sort(function(c,x){return c.order-x.order||(c.id<x.id?-1:c.id>x.id?1:0)})},Jt=function(c){var x,R;if(c.kind==="sceneEnter"&&((x=n.scenes.find(function(A){return A.id===c.sceneId}))===null||x===void 0?void 0:x.role)==="end-card"&&en!==c.sceneId&&(en=c.sceneId,(R=_?.notifyGameEnd)===null||R===void 0||R.call(_)),Fe.length>=256){Ai("Event queue budget exhausted");return}Fe.push(c)},pi=function(c,x,R,A){var C,N,P,X;return A===void 0&&(A={}),gt(gt({kind:c,componentId:(C=x.prototypeId)!==null&&C!==void 0?C:x.id,selfInstanceId:(N=x.instanceId)!==null&&N!==void 0?N:x.id,instanceId:x.instanceId},R?{otherId:(P=R.prototypeId)!==null&&P!==void 0?P:R.id,otherInstanceId:(X=R.instanceId)!==null&&X!==void 0?X:R.id}:{}),A)};function $r(c){for(var x,R=c;R;R=Le(R.parentId)){var A=Ei.states.get((x=R.instanceId)!==null&&x!==void 0?x:R.id);if(A)return A}}function Ms(c){var x,R,A=An("instance-state",(x=c.prototypeId)!==null&&x!==void 0?x:c.id);return A?Ei.initialize((R=c.instanceId)!==null&&R!==void 0?R:c.id,A.parameters):void 0}function Oo(){var c,x,R,A;try{for(var C=Ue(n.gameplay.filter(function(V){return V.kind==="instance-state"})),N=C.next();!N.done;N=C.next()){var P=N.value;try{for(var X=(R=void 0,Ue(ci(S.get(P.componentId)))),k=X.next();!k.done;k=X.next()){var Z=k.value;Ms(Z)}}catch(V){R={error:V}}finally{try{k&&!k.done&&(A=X.return)&&A.call(X)}finally{if(R)throw R.error}}}}catch(V){c={error:V}}finally{try{N&&!N.done&&(x=C.return)&&x.call(C)}finally{if(c)throw c.error}}}function Bo(c,x,R,A){var C=$r(c);if(C){var N=C.hp;if(x==="tag")C.tag=R==="set"?String(A):C.tag;else{var P=Number(A);if(C[x]=R==="add"?C[x]+P:R==="sub"?C[x]-P:P,!Number.isFinite(C[x])){Ai("Instance state range exceeded");return}x==="hp"&&(C.hp=Math.max(0,Math.min(C.maxHp,C.hp)))}N>0&&C.hp<=0&&Jt(pi("instanceDepleted",c))}}function Ja(c,x){var R,A,C;if(!c)return!0;if(c.all)return c.all.every(function(Z){return Ja(Z,x)});if(c.any)return c.any.some(function(Z){return Ja(Z,x)});var N=c.instanceTarget==="other"?x?.otherInstanceId:(R=x?.selfInstanceId)!==null&&R!==void 0?R:x?.instanceId,P=c.instanceField?(A=Le(N))!==null&&A!==void 0?A:Ke([],De(Oe.values()),!1).find(function(Z){return Z.instanceId===N}):void 0,X=c.instanceField?(C=$r(P))===null||C===void 0?void 0:C[c.instanceField]:ne[c.variableId],k=c.compareVariableId?ne[c.compareVariableId]:c.value;return{eq:function(){return X===k},ne:function(){return X!==k},lt:function(){return X<k},lte:function(){return X<=k},gt:function(){return X>k},gte:function(){return X>=k}}[c.op]()}function ko(c){var x,R,A;yn=void 0,En=void 0,c||Dn.clear();try{for(var C=Ue(n.gameplay),N=C.next();!N.done;N=C.next()){var P=N.value;if(P.kind==="match-tile"){var X=S.get(P.componentId);if(c&&X.id!==c&&!Rr(X,c))continue;He.delete(X.id),Dn.set(X.id,{row:P.parameters.row,column:P.parameters.column,group:P.parameters.group,sceneId:X.sceneId,boardId:(A=X.parentId)!==null&&A!==void 0?A:X.sceneId})}}}catch(k){x={error:k}}finally{try{N&&!N.done&&(R=C.return)&&R.call(C)}finally{if(x)throw x.error}}}function kd(){var c,x,R=function(P){var X,k;if(xt.has(P.componentId))return"continue";var Z=P.componentId,V=P.parameters,$=n.gameplay.filter(function(oe){return oe.kind==="match-tile"&&S.get(oe.componentId).parentId===Z}).sort(function(oe,be){return oe.parameters.row-be.parameters.row||oe.parameters.column-be.parameters.column}).map(function(oe){return gt({id:oe.componentId},oe.parameters)}),q=new Map;try{for(var Q=(X=void 0,Ue($)),te=Q.next();!te.done;te=Q.next()){var G=te.value;if(!q.has(G.group)){var ce=S.get(G.id);q.set(G.group,{fill:ce.parameters.fill,children:yr(G.id).filter(function(oe){return["native.image.v1","native.text.v1"].includes(oe.contract)})})}}}catch(oe){X={error:oe}}finally{try{te&&!te.done&&(k=Q.return)&&k.call(Q)}finally{if(X)throw X.error}}ni.set(Z,q);var me=S.get($[V.columns].id).transform[5]-S.get($[0].id).transform[5],ve=function(oe,be,Ee){var Ie,Ze=Ee.from,lt=Ze===void 0?oe:Ze,Xe=Ee.progress,ht=Xe===void 0?0:Xe,yt=Ee.offsetRows,Gt=yt===void 0?0:yt,Ut=Ee.scale,at=Ut===void 0?1:Ut,Wt=Ee.opacity,Mt=Wt===void 0?1:Wt,mt=$[oe],Qe=S.get(mt.id),st=S.get($[lt].id),We=q.get(be),tt=Ke([],De(Qe.transform),!1);tt[4]+=(st.transform[4]-Qe.transform[4])*ht,tt[5]+=(st.transform[5]-Qe.transform[5]+Gt*me)*ht,tt[4]+=(1-at)*(tt[0]*Qe.parameters.width+tt[2]*Qe.parameters.height)/2,tt[5]+=(1-at)*(tt[1]*Qe.parameters.width+tt[3]*Qe.parameters.height)/2;for(var St=0;St<4;St++)tt[St]*=at;He.set(mt.id,gt(gt({},He.get(mt.id)),{transform:tt,parameters:gt(gt({},(Ie=He.get(mt.id))===null||Ie===void 0?void 0:Ie.parameters),{fill:We.fill,opacity:Mt})})),Dn.get(mt.id).group=be;var Ct=yr(mt.id).filter(function(Pt){return["native.image.v1","native.text.v1"].includes(Pt.contract)});Ct.forEach(function(Pt,Nt){var Yt,Bt,it=We.children[Nt];if(!(!it||it.contract!==Pt.contract)){var Ft=(Yt=He.get(Pt.id))!==null&&Yt!==void 0?Yt:{transform:Ke([],De(Pt.transform),!1),parameters:{}};Pt.contract==="native.image.v1"?Ft.assetId=(Bt=it.assetSlots[0])===null||Bt===void 0?void 0:Bt.assetId:Ft.parameters.text=it.parameters.text,He.set(Pt.id,Ft)}})},xe=Lp(gt(gt({},V),{slots:$,paint:ve,onEvent:function(oe){yn=void 0,Jt({kind:oe,componentId:Z})}}));xt.set(Z,xe)};try{for(var A=Ue(n.gameplay.filter(function(P){return P.kind==="match-board"})),C=A.next();!C.done;C=A.next()){var N=C.value;R(N)}}catch(P){c={error:P}}finally{try{C&&!C.done&&(x=A.return)&&x.call(A)}finally{if(c)throw c.error}}}function rc(c){var x,R;kd();try{for(var A=Ue(xt),C=A.next();!C.done;C=A.next()){var N=De(C.value,2),P=N[0],X=N[1];(!c||c===P||Rr(S.get(P),c))&&X.reset()}}catch(k){x={error:k}}finally{try{C&&!C.done&&(R=A.return)&&R.call(A)}finally{if(x)throw x.error}}}function ci(c){return ki(c)?Ke([],De(Oe.values()),!1).filter(function(x){return x.prototypeId===c.id}):[c]}function xi(c){var x=Vt(c);return In(zn(c),x.width/2,x.height/2)}function Ss(c,x,R){var A;R===void 0&&(R="self");var C=S.get(c),N=R==="other"?x.otherInstanceId:(A=x.selfInstanceId)!==null&&A!==void 0?A:x.instanceId,P=!!(C&&ki(C));if(N!==void 0){if(c){var X=Ke([],De(Oe.values()),!1).find(function(k){return k.prototypeId===c&&(k.instanceId===N||k.id===N)});if(X)return X}if(R==="other"||!c)return Le(N);if(P&&typeof N=="string"&&N.startsWith("instance."))return}return C?P?ci(C)[0]:Le(c):void 0}function ua(c,x,R){var A,C=Vt(c),N=(A=He.get(c.id))!==null&&A!==void 0?A:{transform:Ke([],De(c.transform),!1),parameters:{}},P=Ke([],De(N.transform),!1),X=c.parentId?zn(Le(c.parentId)):ga(),k=In(wr(X),x,R);P[4]=k.x-(P[0]*C.width+P[2]*C.height)/2,P[5]=k.y-(P[1]*C.width+P[3]*C.height)/2,He.set(c.id,gt(gt({},N),{transform:P})),c.prototypeId&&(c.transform=Ke([],De(P),!1))}function Gs(c,x,R){var A,C,N,P;R===void 0&&(R=!1);var X=(A=He.get(c.id))!==null&&A!==void 0?A:{transform:Ke([],De(c.transform),!1),parameters:{}},k=(P=(N=S.get((C=c.prototypeId)!==null&&C!==void 0?C:c.id))===null||N===void 0?void 0:N.transform)!==null&&P!==void 0?P:c.transform,Z=Math.hypot(k[0],k[1])*(R?-1:1),V=Math.hypot(k[2],k[3]),$=x+(R?0:Math.atan2(k[1],k[0])),q=Math.cos($),Q=Math.sin($),te=Ke([],De(X.transform),!1);te[0]=q*Z,te[1]=Q*Z,te[2]=-Q*V,te[3]=q*V,He.set(c.id,gt(gt({},X),{transform:te}))}function $a(c,x){var R=fn.get(c.id);if(R)return R;var A=zn(c),C=Vt(c),N=In(A,C.width/2,C.height/2);return R=gt({id:c.id,sourceId:x.componentId,instanceId:c.instanceId,x:N.x,y:N.y,vx:0,vy:0,width:Math.hypot(A[0],A[1])*C.width,height:Math.hypot(A[2],A[3])*C.height,angle:Math.atan2(A[1],A[0]),restElapsed:0,atRest:!0},x.parameters),fn.set(c.id,R),R}function zo(c,x){var R,A=mr.get(c.id);if(A)return A;var C=Vt(c),N=x.parameters;return A=Wp(N,{width:C.width,height:C.height,source:c.contract==="native.image.v1"?b.get((R=c.assetSlots[0])===null||R===void 0?void 0:R.assetId):void 0,onProgress:function(P){N.progressVariableId&&(ne[N.progressVariableId]=P),Jt(pi("maskProgress",c))},onComplete:function(){return Jt(pi("maskComplete",c))}}),mr.set(c.id,A),A}function Ev(c){var x=sr.get(c.componentId);return x||(x=qp(c.parameters),sr.set(c.componentId,x)),x}function ip(){var c,x,R,A,C,N,P,X,k,Z,V,$,q=new Set,Q=[];try{for(var te=Ue(n.gameplay.filter(function(tt){return tt.kind==="physics-body"})),G=te.next();!G.done;G=te.next()){var ce=G.value,me=S.get(ce.componentId);if(me.sceneId===J)try{for(var ve=(R=void 0,Ue(ci(me))),xe=ve.next();!xe.done;xe=ve.next()){var oe=xe.value;if(ii(oe)){if(Q.length>=64){Ai("Physics body budget exhausted");break}var be=$a(oe,ce),Ee=zn(oe),Ie=Vt(oe),Ze=In(Ee,Ie.width/2,Ie.height/2);if(q.add(oe.id),be.width=Math.hypot(Ee[0],Ee[1])*Ie.width,be.height=Math.hypot(Ee[2],Ee[3])*Ie.height,be.mode!=="dynamic"){var lt=qi.get(oe.id),Xe=oe.parentId?zn(Le(oe.parentId)):ga(),ht=(V=lt?.vx)!==null&&V!==void 0?V:0,yt=($=lt?.vy)!==null&&$!==void 0?$:0;be.x=Ze.x,be.y=Ze.y,be.angle=Math.atan2(Ee[1],Ee[0]),be.vx=Xe[0]*ht+Xe[2]*yt,be.vy=Xe[1]*ht+Xe[3]*yt}else be.atRest&&(be.x=Ze.x,be.y=Ze.y);Q.push(be)}}}catch(tt){R={error:tt}}finally{try{xe&&!xe.done&&(A=ve.return)&&A.call(ve)}finally{if(R)throw R.error}}}}catch(tt){c={error:tt}}finally{try{G&&!G.done&&(x=te.return)&&x.call(te)}finally{if(c)throw c.error}}try{for(var Gt=Ue(fn.keys()),Ut=Gt.next();!Ut.done;Ut=Gt.next()){var at=Ut.value;!q.has(at)&&!Oe.has(at)&&fn.delete(at)}}catch(tt){C={error:tt}}finally{try{Ut&&!Ut.done&&(N=Gt.return)&&N.call(Gt)}finally{if(C)throw C.error}}var Wt=[];try{for(var Mt=Ue(n.gameplay.filter(function(tt){return tt.kind==="capture-zone"})),mt=Mt.next();!mt.done;mt=Mt.next()){var ce=mt.value,me=S.get(ce.componentId);if(me.sceneId===J)try{for(var Qe=(k=void 0,Ue(ci(me))),st=Qe.next();!st.done;st=Qe.next()){var oe=st.value;if(ii(oe)){var Ee=zn(oe),Ie=Vt(oe),Ze=In(Ee,Ie.width/2,Ie.height/2),We=Math.max(.1,Math.min(Math.hypot(Ee[0],Ee[1]),Math.hypot(Ee[2],Ee[3])));Wt.push(gt(gt({id:oe.id,sourceId:me.id,instanceId:oe.instanceId,x:Ze.x,y:Ze.y},ce.parameters),{radius:ce.parameters.radius*We}))}}}catch(Ct){k={error:Ct}}finally{try{st&&!st.done&&(Z=Qe.return)&&Z.call(Qe)}finally{if(k)throw k.error}}}}catch(tt){P={error:tt}}finally{try{mt&&!mt.done&&(X=Mt.return)&&X.call(Mt)}finally{if(P)throw P.error}}return{bodies:Ke(Ke([],De(Q),!1),De(Dt),!1),zones:Wt}}function Av(c){var x,R,A,C,N,P,X,k=ip(),Z=k.bodies,V=k.zones,$=O();tn=[];try{for(var q=Ue(n.gameplay.filter(function(Xe){return Xe.kind==="physics-joint"})),Q=q.next();!Q.done;Q=q.next()){var te=Q.value,G=S.get(te.componentId);if(G.sceneId===J){var ce=Le(te.parameters.anchorComponentId),me=An("physics-body",G.id);if(!(!ce||!me))try{for(var ve=(A=void 0,Ue(ci(G))),xe=ve.next();!xe.done;xe=ve.next()){var oe=xe.value;$a(oe,me);var be=xi(ce),Ee=te.id+":"+oe.id;tn.push(gt(gt({},te.parameters),{id:te.id,key:Ee,componentId:G.id,bodyId:oe.id,anchorId:ce.id,x:be.x,y:be.y,broken:D.has(Ee)}))}}catch(Xe){A={error:Xe}}finally{try{xe&&!xe.done&&(C=ve.return)&&C.call(ve)}finally{if(A)throw A.error}}}}}catch(Xe){x={error:Xe}}finally{try{Q&&!Q.done&&(R=q.return)&&R.call(q)}finally{if(x)throw x.error}}ff({bodies:Z,zones:V,joints:tn,bounds:{left:0,top:0,right:$.width,bottom:$.height},dt:c,onEvent:function(Xe,ht,yt){var Gt,Ut,at,Wt;if(!(Xe==="bodyBounce"&&yt&&ht.sourceId===yt.sourceId&&ht.id>yt.id)){var Mt=(Gt=ht.instanceId)!==null&&Gt!==void 0?Gt:ht.id,mt=yt?(Ut=yt.instanceId)!==null&&Ut!==void 0?Ut:yt.id:void 0,Qe=gt(gt({kind:Xe,componentId:ht.sourceId,selfInstanceId:Mt},mt?{otherInstanceId:mt}:{}),{instanceId:(at=ht.instanceId)!==null&&at!==void 0?at:yt?.instanceId});if(yt&&(Qe.otherId=yt.sourceId),Jt(Qe),Xe==="zoneCapture"){var st=Le(ht.id),We=S.get(yt.sourceId);if(yt.hideCaptured&&st){var tt=(Wt=He.get(st.id))!==null&&Wt!==void 0?Wt:{transform:Ke([],De(st.transform),!1),parameters:{}};tt.parameters.visible=!1,He.set(st.id,tt)}yt.stopBody&&We&&st&&ua(st,yt.x,yt.y)}}}});try{for(var Ie=Ue(Z),Ze=Ie.next();!Ze.done;Ze=Ie.next()){var lt=Ze.value,oe=Le(lt.id);!oe||lt.mode!=="dynamic"||(lt.spinToRotation&&Gs(oe,(X=lt.angle)!==null&&X!==void 0?X:0),ua(oe,lt.x,lt.y))}}catch(Xe){N={error:Xe}}finally{try{Ze&&!Ze.done&&(P=Ie.return)&&P.call(Ie)}finally{if(N)throw N.error}}}function Iv(){var c,x,R,A,C;try{for(var N=Ue(n.gameplay.filter(function(xe){return xe.kind==="oscillate"})),P=N.next();!P.done;P=N.next()){var X=P.value,k=S.get(X.componentId);if(k.sceneId===J)try{for(var Z=(R=void 0,Ue(ci(k))),V=Z.next();!V.done;V=Z.next()){var $=V.value,q=qi.get($.id);q||(q={base:Ke([],De(Di($)),!1),vx:0,vy:0},qi.set($.id,q));var Q=X.parameters,te=(_e/Q.periodSeconds+Q.phase)*Math.PI*2,G=Math.sin(te)*Q.amplitude,ce=Math.cos(te)*Q.amplitude*Math.PI*2/Q.periodSeconds,me=(C=He.get($.id))!==null&&C!==void 0?C:{parameters:{}},ve=Ke([],De(q.base),!1);Q.axis==="x"?(ve[4]+=G,q.vx=ce,q.vy=0):(ve[5]+=G,q.vy=ce,q.vx=0),He.set($.id,gt(gt({},me),{transform:ve})),qi.set($.id,q)}}catch(xe){R={error:xe}}finally{try{V&&!V.done&&(A=Z.return)&&A.call(Z)}finally{if(R)throw R.error}}}}catch(xe){c={error:xe}}finally{try{P&&!P.done&&(x=N.return)&&x.call(N)}finally{if(c)throw c.error}}}function rp(){var c,x;bi.clear();var R=function(P){var X=n.gameplay.filter(function(Z){return Z.kind==="path-gate"&&Z.parameters.networkBehaviorId===P.id}),k=ov({id:P.id,nodes:P.parameters.nodes,edges:P.parameters.edges,gates:X,onEvent:function(Z,V){var $,q=Le(V.componentId),Q=($=q?.prototypeId)!==null&&$!==void 0?$:V.componentId;Jt(gt({kind:Z,componentId:Q,instanceId:q?.instanceId},V.nodeId?{nodeId:V.nodeId}:{}))}});bi.set(P.id,k)};try{for(var A=Ue(n.gameplay.filter(function(P){return P.kind==="path-network"})),C=A.next();!C.done;C=A.next()){var N=C.value;R(N)}}catch(P){c={error:P}}finally{try{C&&!C.done&&(x=A.return)&&x.call(A)}finally{if(c)throw c.error}}}function ac(c,x){var R,A,C,N,P,X,k,Z,V,$,q,Q,te;x===void 0&&(x=!0);var G=0;try{for(var ce=Ue(n.gameplay.filter(function(tt){return tt.kind==="path-agent"})),me=ce.next();!me.done;me=ce.next()){var ve=me.value,xe=S.get(ve.componentId),oe=bi.get(ve.parameters.networkBehaviorId);if(!(xe.sceneId!==J||!oe))try{for(var be=(C=void 0,Ue(ci(xe))),Ee=be.next();!Ee.done;Ee=be.next()){var Ie=Ee.value;if(++G>64){Ai("Path agent budget exhausted");break}var Ze=oe.getAgent(Ie.id);Ze||(Ze=oe.addAgent(gt(gt({},ve.parameters),{id:Ie.id,startNode:(q=Ie.pathStartNode)!==null&&q!==void 0?q:ve.parameters.startNode,targetNode:(Q=Ie.pathTargetNode)!==null&&Q!==void 0?Q:ve.parameters.targetNode}))),Ze.speedMultiplier=Math.max(0,Number(ve.parameters.speedMultiplierVariableId?ne[ve.parameters.speedMultiplierVariableId]:1))}}catch(tt){C={error:tt}}finally{try{Ee&&!Ee.done&&(N=be.return)&&N.call(be)}finally{if(C)throw C.error}}}}catch(tt){R={error:tt}}finally{try{me&&!me.done&&(A=ce.return)&&A.call(ce)}finally{if(R)throw R.error}}if(x){var lt=function(tt,St){var Ct=n.gameplay.find(function(Pt){return Pt.id===tt});S.get(Ct.componentId).sceneId===J&&St.tick(c)};try{for(var Xe=Ue(bi),ht=Xe.next();!ht.done;ht=Xe.next()){var yt=De(ht.value,2),Gt=yt[0],Ut=yt[1];lt(Gt,Ut)}}catch(tt){P={error:tt}}finally{try{ht&&!ht.done&&(X=Xe.return)&&X.call(Xe)}finally{if(P)throw P.error}}}try{for(var at=Ue(n.gameplay.filter(function(tt){return tt.kind==="path-agent"})),Wt=at.next();!Wt.done;Wt=at.next()){var ve=Wt.value,xe=S.get(ve.componentId),Mt=bi.get(ve.parameters.networkBehaviorId);if(!(xe.sceneId!==J||!Mt))try{for(var mt=(V=void 0,Ue(ci(xe))),Qe=mt.next();!Qe.done;Qe=mt.next()){var Ie=Qe.value,Ze=Mt.getAgent(Ie.id);if(Ze){if(Ze.orientToPath==="rotate")Gs(Ie,Ze.heading);else if(Ze.orientToPath==="flip-x")Gs(Ie,0,Ze.flipX);else if(Ze.orientToPath==="iso-4"){var st=(te=He.get(Ie.id))!==null&&te!==void 0?te:{transform:Ke([],De(Ie.transform),!1),parameters:{}};st.pathFrame=Ze.frame,He.set(Ie.id,st)}var We=Ie.parentId?In(zn(Le(Ie.parentId)),Ze.x,Ze.y):Ze;ua(Ie,We.x,We.y)}}}catch(Ct){V={error:Ct}}finally{try{Qe&&!Qe.done&&($=mt.return)&&$.call(mt)}finally{if(V)throw V.error}}}}catch(tt){k={error:tt}}finally{try{Wt&&!Wt.done&&(Z=at.return)&&Z.call(at)}finally{if(k)throw k.error}}}function zd(c){var x,R,A,C,N,P,X,k,Z,V,$=new Set;try{for(var q=Ue(n.gameplay.filter(function(Ft){return Ft.kind==="value-meter"})),Q=q.next();!Q.done;Q=q.next()){var te=Q.value,G=S.get(te.componentId);if(G.sceneId===J)try{for(var ce=(A=void 0,Ue(ci(G))),me=ce.next();!me.done;me=ce.next()){var ve=me.value,xe=te.parameters,oe=xe.instanceField?$r(ve):void 0,be=xe.instanceField==="hp"&&oe?oe.hp/oe.maxHp*(xe.max-xe.min)+xe.min:xe.instanceField==="value"&&oe?oe.value:Number(ne[xe.variableId]),Ee=wi.get(ve.id);Ee||(Ee={base:Ke([],De(Di(ve)),!1),value:Number.isFinite(be)?Math.max(xe.min,Math.min(xe.max,be)):xe.min},wi.set(ve.id,Ee)),$.add(ve.id);var Ie=Math.max(xe.min,Math.min(xe.max,be)),Ze=xe.smoothingSeconds?1-Math.exp(-c/xe.smoothingSeconds):1;Ee.value+=((Number.isFinite(Ie)?Ie:xe.min)-Ee.value)*Ze;var lt=Math.max(0,Math.min(1,(Ee.value-xe.min)/(xe.max-xe.min))),Xe=Ke([],De(Ee.base),!1),ht=(Z=He.get(ve.id))!==null&&Z!==void 0?Z:{parameters:{}},yt=xe.axis==="x"?Vt(ve).width:Vt(ve).height;if(xe.axis==="x"?(Xe[0]*=lt,Xe[1]*=lt):(Xe[2]*=lt,Xe[3]*=lt),xe.direction==="negative"){var Gt=yt*(1-lt);xe.axis==="x"?(Xe[4]+=Ee.base[0]*Gt,Xe[5]+=Ee.base[1]*Gt):(Xe[4]+=Ee.base[2]*Gt,Xe[5]+=Ee.base[3]*Gt)}He.set(ve.id,gt(gt({},ht),{transform:Xe}))}}catch(Ft){A={error:Ft}}finally{try{me&&!me.done&&(C=ce.return)&&C.call(ce)}finally{if(A)throw A.error}}}}catch(Ft){x={error:Ft}}finally{try{Q&&!Q.done&&(R=q.return)&&R.call(q)}finally{if(x)throw x.error}}try{for(var Ut=Ue(wi.keys()),at=Ut.next();!at.done;at=Ut.next()){var Wt=at.value;$.has(Wt)||wi.delete(Wt)}}catch(Ft){N={error:Ft}}finally{try{at&&!at.done&&(P=Ut.return)&&P.call(Ut)}finally{if(N)throw N.error}}try{for(var Mt=Ue(n.gameplay.filter(function(Ft){return Ft.kind==="camera-follow"})),mt=Mt.next();!mt.done;mt=Mt.next()){var te=mt.value,Qe=S.get(te.componentId),Ie=Le(te.parameters.targetId);if(!(Qe.sceneId!==J||!Ie)){var st=gi.get(Qe.id);st||(st={base:Ke([],De(Qe.transform),!1),x:te.parameters.minX,y:te.parameters.minY},gi.set(Qe.id,st));var We=function(Rn,Hn){for(var si=[],ai=Rn;ai&&ai.id!==Hn.id;ai=Le(ai.parentId))si.unshift(ai);return si.reduce(function(qn,Kr){return qs(qn,Di(Kr))},ga())},Xe=Rr(Ie,Qe.id)?We(Ie,Qe):zn(Ie),xe=Vt(Ie),tt=In(Xe,xe.width/2,xe.height/2),St=O(),Ct=te.parameters,Pt=Math.max(Ct.minX,Ct.maxX-St.width/Ct.zoom),Nt=Math.max(Ct.minY,Ct.maxY-St.height/Ct.zoom),Yt=Math.max(Ct.minX,Math.min(Pt,tt.x-St.width/(2*Ct.zoom))),Bt=Math.max(Ct.minY,Math.min(Nt,tt.y-St.height/(2*Ct.zoom))),Ze=1-Math.exp(-Ct.smoothing*c);st.x+=(Yt-st.x)*Ze,st.y+=(Bt-st.y)*Ze;var ht=(V=He.get(Qe.id))!==null&&V!==void 0?V:{parameters:{}},it=Ke([],De(st.base),!1);it[0]*=Ct.zoom,it[1]*=Ct.zoom,it[2]*=Ct.zoom,it[3]*=Ct.zoom,it[4]-=st.x*Ct.zoom,it[5]-=st.y*Ct.zoom,He.set(Qe.id,gt(gt({},ht),{transform:it}))}}}catch(Ft){X={error:Ft}}finally{try{mt&&!mt.done&&(k=Mt.return)&&k.call(Mt)}finally{if(X)throw X.error}}}function Cv(){return{bodies:Ke([],De(fn.values()),!1).map(function(c){return{id:c.id,sourceId:c.sourceId,x:c.x,y:c.y,vx:c.vx,vy:c.vy,atRest:!!c.atRest,captured:!!c.captured}}),aiming:he?{componentId:he.sourceId,pointerId:he.pointerId,power:he.power}:null}}function sc(c){for(var x=c;x;){if(x.contract==="native.stage3d.v1")return x;x=x.parentId?Le(x.parentId):void 0}}function oc(c,x){var R,A,C,N,P,X,k=$t.get(c.id);if(k)return k;var Z=Vt(c),V=sc(c);return k=gt({id:c.id,sourceId:x.componentId,stageId:V?.id,x:(R=Z.x)!==null&&R!==void 0?R:0,y:(A=Z.y)!==null&&A!==void 0?A:0,z:(C=Z.z)!==null&&C!==void 0?C:0,vx:0,vy:0,vz:0,spin:0,atRest:!0,captured:!1,captureElapsed:0,airborne:!1,restElapsed:0,movingTime:0,lastSafe:{x:(N=Z.x)!==null&&N!==void 0?N:0,y:(P=Z.y)!==null&&P!==void 0?P:0,z:(X=Z.z)!==null&&X!==void 0?X:0}},x.parameters),$t.set(c.id,k),k}function lc(){var c,x,R,A,C,N,P,X=[],k=[],Z=[];if(!jt)return{bodies:X,walls:k,zones:Z};try{for(var V=Ue(n.gameplay.filter(function(ve){return ve.kind==="physics-3d"})),$=V.next();!$.done;$=V.next()){var q=$.value,Q=S.get(q.componentId);if(!(!Q||Q.sceneId!==J||!ii(Q))){var te=oc(Q,q);te.mode==="dynamic"?X.push(te):k.push(te)}}}catch(ve){c={error:ve}}finally{try{$&&!$.done&&(x=V.return)&&x.call(V)}finally{if(c)throw c.error}}try{for(var G=Ue(n.gameplay.filter(function(ve){return ve.kind==="capture-zone-3d"})),ce=G.next();!ce.done;ce=G.next()){var q=ce.value,Q=S.get(q.componentId);if(!(!Q||Q.sceneId!==J||!ii(Q))){var me=Vt(Q);Z.push(gt({id:Q.id,sourceId:Q.id,x:(C=me.x)!==null&&C!==void 0?C:0,y:(N=me.y)!==null&&N!==void 0?N:0,z:(P=me.z)!==null&&P!==void 0?P:0},q.parameters))}}}catch(ve){R={error:ve}}finally{try{ce&&!ce.done&&(A=G.return)&&A.call(G)}finally{if(R)throw R.error}}return{bodies:X,walls:k,zones:Z}}function Rv(c){var x,R,A,C,N,P,X,k,Z,V;if(jt){try{for(var $=Ue(n.gameplay.filter(function(Wt){return Wt.kind==="oscillate-3d"})),q=$.next();!q.done;q=$.next()){var Q=q.value,te=S.get(Q.componentId);if(!(!te||te.sceneId!==J)){var G=Et.get(te.id);if(!G){var ce=Vt(te);G={x:(N=ce.x)!==null&&N!==void 0?N:0,y:(P=ce.y)!==null&&P!==void 0?P:0,z:(X=ce.z)!==null&&X!==void 0?X:0},Et.set(te.id,G)}var me=Q.parameters,ve=_e*me.angularSpeed+me.phase,xe=Math.sin(ve)*me.amplitude,oe=Math.cos(ve)*me.amplitude*me.angularSpeed,be=(k=$t.get(te.id))!==null&&k!==void 0?k:An("physics-3d",te.id)?oc(te,An("physics-3d",te.id)):void 0,Ee=G.x+(me.axis==="x"?xe:0),Ie=G.y+(me.axis==="y"?xe:0),Ze=G.z+(me.axis==="z"?xe:0);if(be)be.x=Ee,be.y=Ie,be.z=Ze,be.vx=me.axis==="x"?oe:0,be.vy=me.axis==="y"?oe:0,be.vz=me.axis==="z"?oe:0;else{var lt=(Z=He.get(te.id))!==null&&Z!==void 0?Z:{transform:Ke([],De(te.transform),!1),parameters:{}};lt.parameters.x=Ee,lt.parameters.y=Ie,lt.parameters.z=Ze,He.set(te.id,lt)}}}}catch(Wt){x={error:Wt}}finally{try{q&&!q.done&&(R=$.return)&&R.call($)}finally{if(x)throw x.error}}var Xe=lc(),ht=Xe.bodies,yt=Xe.walls,Gt=Xe.zones;pf({bodies:ht,walls:yt,zones:Gt,dt:c,onEvent:function(Wt,Mt,mt){var Qe={kind:Wt,componentId:Mt.sourceId};mt&&(Qe.otherId=mt.sourceId),Jt(Qe)}});try{for(var Ut=Ue(ht),at=Ut.next();!at.done;at=Ut.next()){var be=at.value;be.captured&&(be.captureElapsed=((V=be.captureElapsed)!==null&&V!==void 0?V:0)+c)}}catch(Wt){A={error:Wt}}finally{try{at&&!at.done&&(C=Ut.return)&&C.call(Ut)}finally{if(A)throw A.error}}Pv(c,yt)}}function cc(c){var x=Vn.get(c.componentId);if(!x){var R=c.parameters;x={behavior:c,x:R.x,y:R.y,z:R.z,yaw:R.yaw,pitch:R.pitch,bobPhase:0,bob:0},Vn.set(c.componentId,x)}return x}function ap(){var c,x;try{for(var R=Ue(n.gameplay.filter(function(N){var P;return N.kind==="fps-controller-3d"&&((P=S.get(N.componentId))===null||P===void 0?void 0:P.sceneId)===J})),A=R.next();!A.done;A=R.next()){var C=A.value;cc(C)}}catch(N){c={error:N}}finally{try{A&&!A.done&&(x=R.return)&&x.call(R)}finally{if(c)throw c.error}}}function sp(c){var x,R,A,C=[];try{for(var N=Ue(Oe.values()),P=N.next();!P.done;P=N.next()){var X=P.value;X.contract==="native.mesh3d.v1"&&((A=sc(X))===null||A===void 0?void 0:A.id)===c&&C.push(X)}}catch(k){x={error:k}}finally{try{P&&!P.done&&(R=N.return)&&R.call(N)}finally{if(x)throw x.error}}return C}function op(c,x,R){var A,C,N=cc(c),P=c.parameters,X=P.lookSensitivity,k=P.invertAimY?-1:1,Z=N.yaw-x*X;P.minYaw!==void 0&&P.maxYaw!==void 0&&(Z=Math.max(P.minYaw,Math.min(P.maxYaw,Z))),N.yaw=Z,N.pitch=Math.max((A=P.minPitch)!==null&&A!==void 0?A:-.75,Math.min((C=P.maxPitch)!==null&&C!==void 0?C:.75,N.pitch-R*X*k))}function Pv(c,x){var R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be=function(Mt){var mt=S.get(Mt.componentId);if(!mt||mt.sceneId!==J)return"continue";var Qe=cc(Mt),st=Mt.parameters,We=st.aimJoystickBehaviorId?le.get(st.aimJoystickBehaviorId):void 0;if(We&&st.aimMode==="rate"&&We.magnitude>1e-4&&c>0){var tt=(k=st.aimTurnSpeed)!==null&&k!==void 0?k:1.8,St=st.invertAimY?-1:1,Ct=Qe.yaw-We.nx*tt*c;st.minYaw!==void 0&&st.maxYaw!==void 0&&(Ct=Math.max(st.minYaw,Math.min(st.maxYaw,Ct))),Qe.yaw=Ct,Qe.pitch=Math.max((Z=st.minPitch)!==null&&Z!==void 0?Z:-.75,Math.min((V=st.maxPitch)!==null&&V!==void 0?V:.75,Qe.pitch-We.ny*tt*St*c))}var Pt=st.joystickBehaviorId?le.get(st.joystickBehaviorId):void 0,Nt=Pt?Pt.nx:Number(st.moveXVariableId?ne[st.moveXVariableId]:0),Yt=Pt?Pt.ny:Number(st.moveYVariableId?ne[st.moveYVariableId]:0),Bt=Math.min(1,Math.hypot(Nt,Yt));if(Bt>1e-4&&st.moveSpeed>0&&c>0){var it=-Yt,Ft=Nt,Cn=-Math.sin(Qe.yaw),bn=-Math.cos(Qe.yaw),_i=Math.cos(Qe.yaw),ri=-Math.sin(Qe.yaw),wn=st.moveSpeed*c,Rn=x.filter(function(si){return si.stageId===mt.id}),Hn=mf(Qe.x+(Cn*it+_i*Ft)*wn,Qe.z+(bn*it+ri*Ft)*wn,($=st.playerRadius)!==null&&$!==void 0?$:.45,Rn,(q=st.boundsX)!==null&&q!==void 0?q:12,(Q=st.boundsZ)!==null&&Q!==void 0?Q:12);Qe.x=Hn.x,Qe.z=Hn.z,Qe.bobPhase+=c*10*Bt,Qe.bob=U?.matches?0:Math.sin(Qe.bobPhase)*((te=st.bobAmplitude)!==null&&te!==void 0?te:.04)*Bt}else Qe.bob*=Math.max(0,1-12*c)};try{for(var Ee=Ue(n.gameplay.filter(function(Mt){return Mt.kind==="fps-controller-3d"})),Ie=Ee.next();!Ie.done;Ie=Ee.next()){var Ze=Ie.value;be(Ze)}}catch(Mt){R={error:Mt}}finally{try{Ie&&!Ie.done&&(A=Ee.return)&&A.call(Ee)}finally{if(R)throw R.error}}try{for(var lt=Ue(n.gameplay.filter(function(Mt){return Mt.kind==="steer-3d"})),Xe=lt.next();!Xe.done;Xe=lt.next()){var Ze=Xe.value,ht=S.get(Ze.componentId);if(!(!ht||ht.sceneId!==J)){var yt=Ze.parameters,Gt=function(mt){if(!ii(mt))return"continue";var Qe=sc(mt),st=Qe?Vn.get(Qe.id):void 0;if(!st)return"continue";var We=Vt(mt),tt=(G=We.x)!==null&&G!==void 0?G:0,St=(ce=We.z)!==null&&ce!==void 0?ce:0,Ct=st.x-tt,Pt=st.z-St,Nt=Math.hypot(Ct,Pt),Yt=(me=yt.stopDistance)!==null&&me!==void 0?me:2.5,Bt=tt,it=St;if(yt.mode==="chase-camera"&&Nt>Yt&&Nt>1e-4){var Ft=Math.min(Nt-Yt,yt.speed*c);Bt+=Ct/Nt*Ft,it+=Pt/Nt*Ft}else if(yt.mode==="strafe-camera"&&Nt>1e-4){var Cn=-Pt/Nt,bn=Ct/Nt;Bt+=Cn*yt.speed*c,it+=bn*yt.speed*c}else yt.mode==="patrol"&&(Bt+=Math.cos(_e*1.5)*yt.speed*c);var _i=x.filter(function(Rn){return Rn.stageId===Qe.id&&Rn.id!==mt.id}),ri=mf(Bt,it,.45,_i,(ve=yt.boundsX)!==null&&ve!==void 0?ve:12,(xe=yt.boundsZ)!==null&&xe!==void 0?xe:12),wn=(oe=He.get(mt.id))!==null&&oe!==void 0?oe:{transform:Ke([],De(mt.transform),!1),parameters:{}};wn.parameters.x=ri.x,wn.parameters.z=ri.z,yt.faceCamera!==!1&&(wn.parameters.ry=Math.atan2(st.x-ri.x,st.z-ri.z)),He.set(mt.id,wn)};try{for(var Ut=(P=void 0,Ue(ci(ht))),at=Ut.next();!at.done;at=Ut.next()){var Wt=at.value;Gt(Wt)}}catch(mt){P={error:mt}}finally{try{at&&!at.done&&(X=Ut.return)&&X.call(Ut)}finally{if(P)throw P.error}}}}}catch(Mt){C={error:Mt}}finally{try{Xe&&!Xe.done&&(N=lt.return)&&N.call(lt)}finally{if(C)throw C.error}}}function Lv(c,x,R,A){if(Te.length>=128){Ai("Instance budget exhausted");return}var C=S.get(c),N=function(Z){return 1+n.components.filter(function(V){return V.parentId===Z}).reduce(function(V,$){return V+N($.id)},0)};if(Oe.size+N(C.id)>4096){Ai("Runtime node budget exhausted");return}var P="instance."+ ++$e;function X(Z,V){var $,q,Q=Z.id===C.id?P:P+":"+Z.id,te=gt(gt({},Z),{id:Q,runtimeId:Q,instanceId:P,prototypeId:Z.id,prototype:!1,parentId:V,transform:Ke([],De(Z.transform),!1),parameters:gt({},Z.parameters),spawnTime:_e});Oe.set(Q,te);try{for(var G=Ue(n.components.filter(function(ve){return ve.parentId===Z.id})),ce=G.next();!ce.done;ce=G.next()){var me=ce.value;X(me,Q)}}catch(ve){$={error:ve}}finally{try{ce&&!ce.done&&(q=G.return)&&q.call(G)}finally{if($)throw $.error}}return te}var k=X(C,C.parentId);return k.parameters.x=x,k.parameters.y=R,k.parameters.z=A,Te.push(k),Ms(k),k}function Dv(c){var x,R;if(jt){var A=S.get(c.stageId);if(!(!A||A.sceneId!==J)){var C=Vt(A),N=zn(A),P=Math.hypot(N[0],N[1]),X=Math.hypot(N[2],N[3]),k=jt.syncStage(A,{time:_e,ambientTime:Ge,propsOf:Vt,bodies3d:$t,fpsPose:Vn.get(A.id),instances3d:sp(A.id),aimLocked:!!It,groundFn:Js,worldWidth:C.width*P,worldHeight:C.height*X}).entry,Z=0,V=0;if(c.mode==="pointer"){var $=In(wr(N),Je.x,Je.y);Z=$.x/Math.max(1,C.width)*2-1,V=1-$.y/Math.max(1,C.height)*2}var q=new Set(n.gameplay.filter(function(me){return me.kind==="physics-3d"&&me.parameters.mode!=="dynamic"}).map(function(me){return me.componentId})),Q=(x=c.targetTeam)!==null&&x!==void 0?x:"any",te=function(me){var ve,xe,oe=Le(me);return!oe||!ii(oe)?!1:Q!=="any"?((ve=$r(oe))===null||ve===void 0?void 0:ve.team)===Q:!!$r(oe)||!q.has((xe=oe.prototypeId)!==null&&xe!==void 0?xe:oe.id)},G=k.raycast(Z,V,(R=c.maxDistance)!==null&&R!==void 0?R:80,{isTarget:te,isOccluder:function(me){return q.has(me)}});if(G){var ce=Le(G.id);ce&&Jt(pi("raycastHit3d",ce,A))}else Jt({kind:"raycastMiss3d",componentId:A.id})}}}function Vd(c){var x,R,A;if(!jt)return null;var C=Le(c);if(!C||C.contract!=="native.mesh3d.v1")return null;var N=sc(C);if(!N)return null;var P=jt.getStage(N);if(!P||!P.lastWidth||!P.lastHeight)return null;var X=$t.get(C.id),k=Vt(C),Z=P.project({x:X?X.x:(x=k.x)!==null&&x!==void 0?x:0,y:X?X.y:(R=k.y)!==null&&R!==void 0?R:0,z:X?X.z:(A=k.z)!==null&&A!==void 0?A:0},P.lastWidth,P.lastHeight);return In(zn(N),Z.x,Z.y)}function lp(){if(!It||!jt)return{vx:0,vz:0,power:0,pull:0};var c=S.get(It.stageId),x=jt.getStage(c),R=$t.get(It.targetId),A=It.behavior.parameters;if(!x||!R||!x.lastWidth||!x.lastHeight)return{vx:0,vz:0,power:0,pull:0};var C=wr(zn(c)),N=In(C,It.start.x,It.start.y),P=In(C,It.current.x,It.current.y),X=Math.hypot(It.current.x-It.start.x,It.current.y-It.start.y),k=x.unproject(N.x,N.y,x.lastWidth,x.lastHeight,R.y),Z=x.unproject(P.x,P.y,x.lastWidth,x.lastHeight,R.y);if(!k||!Z)return{vx:0,vz:0,power:0,pull:X};var V=(k.x-Z.x)*A.dragScale,$=(k.z-Z.z)*A.dragScale,q=Math.hypot(V,$);return q>A.maxSpeed&&(V*=A.maxSpeed/q,$*=A.maxSpeed/q),{vx:V,vz:$,power:Math.min(1,Math.hypot(V,$)/Math.max(.001,A.maxSpeed)),pull:X}}function cp(c){if(!(!It||!jt)){It.current=c;var x=lp(),R=It.behavior.parameters;It.power=x.power,R.powerVariableId&&(ne[R.powerVariableId]=x.power);var A=S.get(It.stageId),C=jt.getStage(A),N=$t.get(It.targetId);if(C&&N&&R.showTrajectory&&x.pull>=R.minPullPx){var P=lc(),X=P.walls,k=P.zones;C.setGuide(am({body:N,walls:X,zones:k,vx:x.vx,vz:x.vz,dots:R.trajectoryDots}))}else C?.setGuide([])}}function Nv(){return{bodies:Ke([],De($t.values()),!1).map(function(c){return{id:c.id,sourceId:c.sourceId,x:c.x,y:c.y,z:c.z,vx:c.vx,vy:c.vy,vz:c.vz,atRest:!!c.atRest,captured:!!c.captured,airborne:!!c.airborne}}),aiming:It?{componentId:It.sourceId,pointerId:It.pointerId,power:It.power}:null,projected:Object.fromEntries(hn),fps:Object.fromEntries(Ke([],De(Vn),!1).map(function(c){var x=De(c,2),R=x[0],A=x[1];return[R,{x:A.x,y:A.y,z:A.z,yaw:A.yaw,pitch:A.pitch}]}))}}function uc(){en=void 0,gr(),le.clear(),Bn.clear(),la.clear(),Za.clear(),Ei.reset(),mr.clear(),sr.clear(),Dt=[],tn=[],Vr.clear(),D.clear(),E.clear(),we=[],ze=[],Ye=void 0,Re=0,Ae=!1,Ne=0,ne=Object.fromEntries(n.variables.map(function(c){return[c.id,c.initial]})),pn(),rr=0,Oe.clear(),Pe.clear(),fn.clear(),qi.clear(),$t.clear(),Et.clear(),hn.clear(),Vn.clear(),jt?.reset(),wi.clear(),gi.clear(),he=void 0,Te=[],fe=[],pe=[],He.clear(),ko(),ie.clear(),ae.clear(),de.clear(),Fe=[],_e=0,Ge=0,$e=0,wt=!1,ut=0,J=n.base.startScene,se=void 0,mn=void 0,an=void 0,W=void 0,f||(Oo(),rc(),rp(),lc(),ap(),ac(0,!1),Xd(),zd(0),Jt({kind:"sceneEnter",sceneId:J}))}function Gd(){var c,x;if(!(!_t||_t.state!=="running"||!Rt.size)){var R=Ke([],De(Rt.values()),!1);Rt.clear();try{for(var A=Ue(R),C=A.next();!C.done;C=A.next()){var N=C.value;dp(N)}}catch(P){c={error:P}}finally{try{C&&!C.done&&(x=A.return)&&x.call(A)}finally{if(c)throw c.error}}}}function Hs(c){if(c===void 0&&(c=!1),!_t)return Promise.resolve(void 0);if(_t.state==="running")return Promise.resolve().then(Gd),Promise.resolve(_t);if(!ln||c){var x=_t,R=Promise.resolve().then(function(){return x.resume()}).then(function(){if(x.state==="running")return Gd(),x}).catch(function(){}).finally(function(){ln===R&&(ln=void 0)});ln=R}return ln}function Hd(){var c,x,R=Ke([],De(vt.values()),!1),A=R.some(function(V){return V.bus==="voice"}),C=R.some(function(V){return V.bus==="stinger"}),N=C?.2:A?.25:1;try{for(var P=Ue(R),X=P.next();!X.done;X=P.next()){var k=X.value,Z=k.volume*Yi*(k.bus==="music"?N:1);k.gain.gain.setTargetAtTime?k.gain.gain.setTargetAtTime(Z,_t.currentTime,.04):k.gain.gain.value=Z}}catch(V){c={error:V}}finally{try{X&&!X.done&&(x=P.return)&&x.call(P)}finally{if(c)throw c.error}}}function up(c,x,R){var A,C=(A=R.parameters.bus)!==null&&A!==void 0?A:"sfx";c.connect(x),x.connect(_t.destination),nt.add(c),vt.set(c,{gain:x,bus:C,volume:R.parameters.volume}),c.onended=function(){nt.delete(c),vt.delete(c),R.parameters.loop&&Be.delete(R.id),Hd()},Hd()}function dp(c){return $b(this,void 0,void 0,function(){var x,R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be,Ee,Ie,Ze,lt,Xe,ht,yt,Gt,Ut;return Kb(this,function(at){switch(at.label){case 0:return nt.size>=32?[2]:_t?(x=_t,R=vi,A=(Ze=c.parameters.cooldownMs)!==null&&Ze!==void 0?Ze:45,C=x.currentTime,A>0&&C-((lt=cn.get(c.id))!==null&&lt!==void 0?lt:-1/0)<A/1e3?[2]:c.parameters.loop&&Be.has(c.id)?[2]:(N=S.get(c.componentId),P=B.get((Xe=N?.assetSlots[0])===null||Xe===void 0?void 0:Xe.assetId),X=P?.mime==="audio/wav"||P?.mime==="audio/mpeg",!X&&c.parameters.allowSynthFallback===!1?(rr++,[2]):(cn.set(c.id,C),k=x.state!=="running",k?[4,Hs()]:[3,2]))):(c.parameters.loop&&Rt.set(c.id,c),[2]);case 1:k=!at.sent(),at.label=2;case 2:if(k)return c.parameters.loop&&Rt.set(c.id,c),[2];if(_t!==x||x.state!=="running"||R!==vi||nt.size>=32)return[2];if(Z=(ht=dn.get(c.id))!==null&&ht!==void 0?ht:0,V=[0,-.5,.5,-1,1],$=((yt=c.parameters.pitchJitter)!==null&&yt!==void 0?yt:0)*V[Z%V.length],q=Number((Gt=ne[c.parameters.pitchVariableId])!==null&&Gt!==void 0?Gt:0),Q=Math.max(-12,Math.min(12,$+q*((Ut=c.parameters.pitchStep)!==null&&Ut!==void 0?Ut:0))),te=Math.pow(2,Q/12),dn.set(c.id,Z+1),!X)return[3,8];c.parameters.loop&&Be.add(c.id),at.label=3;case 3:if(at.trys.push([3,6,,7]),G=dt.get(P.hash),G)return[3,5];for(ce=atob(P.data),me=new Uint8Array(ce.length),ve=0;ve<ce.length;ve++)me[ve]=ce.charCodeAt(ve);return[4,new Promise(function(Wt,Mt){var mt=x.decodeAudioData(me.buffer,Wt,Mt);mt&&typeof mt.then=="function"&&mt.then(Wt,Mt)})];case 4:G=at.sent(),dt.set(P.hash,G),at.label=5;case 5:return _t!==x||x.state!=="running"||R!==vi||nt.size>=32?(c.parameters.loop&&R===vi&&Be.delete(c.id),[2]):(xe=x.createBufferSource(),oe=x.createGain(),xe.buffer=G,xe.loop=c.parameters.loop,xe.playbackRate&&(xe.playbackRate.value=te),oe.gain.value=c.parameters.volume,up(xe,oe,c),xe.start(),[3,7]);case 6:return be=at.sent(),Be.delete(c.id),Ai("Audio decode failed"),[3,7];case 7:return[2];case 8:return Ee=x.createOscillator(),Ie=x.createGain(),Ee.frequency.value=c.parameters.frequency*te,Ee.type="sine",Ie.gain.setValueAtTime(c.parameters.volume,x.currentTime),Ie.gain.exponentialRampToValueAtTime(.001,x.currentTime+c.parameters.seconds),up(Ee,Ie,c),Ee.start(),Ee.stop(x.currentTime+c.parameters.seconds),[2]}})})}function Uv(c,x){for(var R=Ke([],De(Dn.values()),!1).filter(function(V){return V.boardId===c}),A=function(V,$){var q;return(q=R.find(function(Q){return Q.row===V&&Q.column===$}))===null||q===void 0?void 0:q.group},C=function(V){for(var $=function(te){var G=A(V,te);if(G&&G===A(V,te+1)&&G===A(V,te+2)&&x.some(function(ce){return ce.row===V&&ce.column>=te&&ce.column<=te+2}))return{value:!0}},q=0;q<14;q++){var Q=$(q);if(typeof Q=="object")return Q}},N=0;N<16;N++){var P=C(N);if(typeof P=="object")return P.value}for(var X=function(V){for(var $=function(te){var G=A(te,V);if(G&&G===A(te+1,V)&&G===A(te+2,V)&&x.some(function(ce){return ce.column===V&&ce.row>=te&&ce.row<=te+2}))return{value:!0}},q=0;q<14;q++){var Q=$(q);if(typeof Q=="object")return Q}},k=0;k<16;k++){var Z=X(k);if(typeof Z=="object")return Z.value}return!1}function Fv(c){var x,R,A,C=Dn.get(c.id);if(!(!C||C.sceneId!==J||!Vt(c).enabled||!ii(c))){var N=xt.get(c.parentId);if(N){yn=N.select(c.id);return}if(yn===c.id){yn=void 0;return}var P=Dn.get(yn);if(!P||P.sceneId!==J||P.boardId!==C.boardId){yn=c.id;return}var X=S.get(yn);if(Math.abs(P.row-C.row)+Math.abs(P.column-C.column)!==1){yn=c.id;return}if(P.group===C.group){yn=void 0,Jt({kind:"invalidMatch",componentId:(x=c.parentId)!==null&&x!==void 0?x:c.id});return}var k=P.row,Z=P.column,V=C.row,$=C.column,q=Ke([],De(Di(X)),!1),Q=Ke([],De(Di(c)),!1);if(P.row=V,P.column=$,C.row=k,C.column=Z,Uv(C.boardId,[P,C])){var te=function(G,ce){var me,ve=(me=He.get(G.id))!==null&&me!==void 0?me:{transform:Ke([],De(Di(G)),!1),parameters:{}};ve.transform=Ke([],De(ve.transform),!1),ve.transform[4]=ce[4],ve.transform[5]=ce[5],He.set(G.id,ve)};te(X,Q),te(c,q),yn=void 0,Jt({kind:"validMatch",componentId:(R=c.parentId)!==null&&R!==void 0?R:c.id})}else P.row=k,P.column=Z,C.row=V,C.column=$,yn=void 0,Jt({kind:"invalidMatch",componentId:(A=c.parentId)!==null&&A!==void 0?A:c.id})}}function Wd(c){var x,R,A,C,N=[],P=zi(c,zn(c)),X=xi(c),k=An("drag",(A=c.prototypeId)!==null&&A!==void 0?A:c.id),Z=function(Q){var te,G,ce=S.get(Q.componentId),me=Q.parameters;if(ce.sceneId!==J)return"continue";var ve=function(Ee){if(Ee.id===c.id||Rr(Ee,c.id)||!ii(Ee))return"continue";var Ie=zi(Ee,zn(Ee)),Ze=xi(Ee),lt=Math.hypot(Ze.x-X.x,Ze.y-X.y),Xe=me.radiusPx>0?lt<=me.radiusPx:P.left<Ie.right&&P.right>Ie.left&&P.top<Ie.bottom&&P.bottom>Ie.top;if(!Xe)return"continue";N.push(gt({id:Ee.id,c:Ee,sourceId:ce.id,paintOrder:ue.findIndex(function(ht){return ht.c.id===Ee.id}),distance:lt,itemTarget:n.gameplay.some(function(ht){return ht.kind==="drag"&&ht.componentId===ce.id})},me))};try{for(var xe=(te=void 0,Ue(ci(ce))),oe=xe.next();!oe.done;oe=xe.next()){var be=oe.value;ve(be)}}catch(Ee){te={error:Ee}}finally{try{oe&&!oe.done&&(G=xe.return)&&G.call(xe)}finally{if(te)throw te.error}}};try{for(var V=Ue(n.gameplay.filter(function(Q){return Q.kind==="drop-zone"})),$=V.next();!$.done;$=V.next()){var q=$.value;Z(q)}}catch(Q){x={error:Q}}finally{try{$&&!$.done&&(R=V.return)&&R.call(V)}finally{if(x)throw x.error}}return{zones:N,tag:(C=k?.parameters.tag)!==null&&C!==void 0?C:""}}function Xd(c){var x,R,A=c?[c]:n.gameplay.filter(function($){return $.kind==="drag"}).flatMap(function($){return ci(S.get($.componentId))});try{for(var C=Ue(A),N=C.next();!N.done;N=C.next()){var P=N.value;if(!(!P||!ii(P)||Bn.zoneOf(P.id))){var X=Wd(P),k=X.zones,Z=X.tag,V=wc({itemId:P.id,tag:Z,zones:k.filter(function($){return!$.itemTarget}),occupancy:Bn});V?.kind==="accept"&&Bn.place(P.id,V.zone.id)}}}catch($){x={error:$}}finally{try{N&&!N.done&&(R=C.return)&&R.call(C)}finally{if(x)throw x.error}}}function bs(c,x,R){R===void 0&&(R=.18),c&&ar.to(c.id,xi(c),x,R)}function Yd(c,x,R,A){var C,N,P=A??R?.c;Jt(gt(gt({},pi(c,x,P,gt({},R?{otherId:R.sourceId}:{}))),{instanceId:(C=x.instanceId)!==null&&C!==void 0?C:(N=R?.c)===null||N===void 0?void 0:N.instanceId}))}function Ov(c){var x,R,A,C,N,P,X;if(!rt||rt.pointerId!==c.pointerId)return!1;var k=rt,Z=Le(k.targetId),V=k.b.parameters;rt=void 0,et=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,c.pointerId)&&((R=e.releasePointerCapture)===null||R===void 0||R.call(e,c.pointerId))}catch{}if(!Z)return!0;var $=Wd(Z),q=$.zones,Q=$.tag,te=wc({itemId:Z.id,tag:Q,zones:q,occupancy:Bn}),G=k.origin,ce=k.originZone;if(!te)return Yd("dragReject",Z,void 0,void 0),V.snapBack&&(ce&&Bn.place(Z.id,ce),bs(Z,G,(A=V.snapBackSeconds)!==null&&A!==void 0?A:.18)),!0;var me=te.zone,ve=te.occupantId?Le(te.occupantId):void 0;return te.kind==="reject"?(Yd("dragReject",Z,me,ve),V.snapBack&&(ce&&Bn.place(Z.id,ce),bs(Z,G,(C=V.snapBackSeconds)!==null&&C!==void 0?C:.18)),!0):(te.kind==="accept"?(Bn.place(Z.id,me.id),me.snapMode==="center"&&bs(Z,xi(me.c),(N=V.snapBackSeconds)!==null&&N!==void 0?N:.18)):te.kind==="swap"&&ve&&(Bn.place(Z.id,me.id),ce?Bn.place(ve.id,ce):Bn.release(ve.id),bs(Z,xi(me.c),(P=V.snapBackSeconds)!==null&&P!==void 0?P:.18),bs(ve,G,(X=V.snapBackSeconds)!==null&&X!==void 0?X:.18)),Yd("dragDrop",Z,me,te.kind==="accept"?me.c:ve),!0)}function Bv(c){var x,R,A,C,N;ar.tick(c,function(te,G){var ce=Le(te);ce&&ua(ce,G.x,G.y)});try{for(var P=Ue(Ke([],De(Bn.itemZone.keys()),!1)),X=P.next();!X.done;X=P.next()){var k=X.value,Z=Le(k);(!Z||!ii(Z))&&Bn.release(k)}}catch(te){x={error:te}}finally{try{X&&!X.done&&(R=P.return)&&R.call(P)}finally{if(x)throw x.error}}if(ke)try{for(var V=Ue(ke.holds),$=V.next();!$.done;$=V.next()){var q=$.value,Q=q.charge.tick(c);Q!==ne[q.behavior.parameters.variableId]&&(ne[q.behavior.parameters.variableId]=Q,Jt({kind:"variableChange",variableId:q.behavior.parameters.variableId,instanceId:q.c.instanceId,selfInstanceId:(N=q.c.instanceId)!==null&&N!==void 0?N:q.c.id}))}}catch(te){A={error:te}}finally{try{$&&!$.done&&(C=V.return)&&C.call(V)}finally{if(A)throw A.error}}}function fp(c,x){var R,A,C,N,P=x.targetMode;if(P==="pointer")return gt({},Je);if(P==="component"){var X=Le(x.targetComponentId);return X?xi(X):void 0}if(P==="nearest-team"){var k=xi(c),Z=[],V=x.team,$=(C=x.maxRangePx)!==null&&C!==void 0?C:0;try{for(var q=Ue(Ei.states),Q=q.next();!Q.done;Q=q.next()){var te=De(Q.value,2),G=te[0],ce=te[1],X=Le(G);X&&ii(X)&&Z.push(gt(gt({id:G},xi(X)),{team:ce.team}))}}catch(me){R={error:me}}finally{try{Q&&!Q.done&&(A=q.return)&&A.call(q)}finally{if(R)throw R.error}}return Vp(k,Z,V,$,(N=c.instanceId)!==null&&N!==void 0?N:c.id)}}function kv(c){var x,R,A,C,N;try{for(var P=Ue(n.gameplay.filter(function(be){return be.kind==="steer"})),X=P.next();!X.done;X=P.next()){var k=X.value,Z=S.get(k.componentId),V=k.parameters;if(Z.sceneId===J)try{for(var $=(A=void 0,Ue(ci(Z))),q=$.next();!q.done;q=$.next()){var Q=q.value;if(ii(Q)){var te=fp(Q,V);if(te){var G=xi(Q),ce=te.x-G.x,me=te.y-G.y;if(!(V.maxRangePx>0&&Math.hypot(ce,me)>V.maxRangePx)){var ve=Math.atan2(me,ce);V.mode==="flee"?ve+=Math.PI:V.mode==="orbit"&&(ve+=Math.PI/2);var xe=(N=Ei.headings.get(Q.id))!==null&&N!==void 0?N:ve,oe=Gp(xe,ve,V.turnRateDegPerSec*Math.PI/180*c);Ei.headings.set(Q.id,oe),ua(Q,G.x+Math.cos(oe)*V.speed*c,G.y+Math.sin(oe)*V.speed*c),V.orientToVelocity!==!1&&Gs(Q,oe)}}}}}catch(be){A={error:be}}finally{try{q&&!q.done&&(C=$.return)&&C.call($)}finally{if(A)throw A.error}}}}catch(be){x={error:be}}finally{try{X&&!X.done&&(R=P.return)&&R.call(P)}finally{if(x)throw x.error}}}function qd(c,x,R,A){var C;if(Te.length>=128){Ai("Instance budget exhausted");return}var N=S.get(c),P=function(V){return 1+n.components.filter(function($){return $.parentId===V}).reduce(function($,q){return $+P(q.id)},0)};if(Oe.size+P(N.id)>4096){Ai("Runtime node budget exhausted");return}var X="instance."+ ++$e;function k(V,$){var q,Q,te=V.id===N.id?X:X+":"+V.id,G=gt(gt({},V),{id:te,runtimeId:te,instanceId:X,prototypeId:V.id,prototype:!1,parentId:$,transform:Ke([],De(V.transform),!1),spawnTime:_e});Oe.set(te,G);try{for(var ce=Ue(n.components.filter(function(xe){return xe.parentId===V.id})),me=ce.next();!me.done;me=ce.next()){var ve=me.value;k(ve,te)}}catch(xe){q={error:xe}}finally{try{me&&!me.done&&(Q=ce.return)&&Q.call(ce)}finally{if(q)throw q.error}}return G}var Z=k(N,void 0);return Z.transform[4]=x,Z.transform[5]=R,A&&(Z.pathStartNode=A.startNode,Z.pathTargetNode=A.targetNode,Z.parentId=(C=n.gameplay.find(function(V){return V.id===A.networkBehaviorId}))===null||C===void 0?void 0:C.componentId),Te.push(Z),Ms(Z),Xd(Z),A&&ac(0,!1),Z}function zv(c,x,R){var A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be,Ee,Ie,Ze,lt,Xe,ht,yt,Gt,Ut,at,Wt,Mt,mt;if(++Zt>1024){Ai("Action budget exhausted");return}if(c.kind==="add"||c.kind==="set"){var Qe=ne[c.variableId],st=c.kind==="add"?Qe+c.value:c.value;if(typeof st=="number"&&(!Number.isFinite(st)||Math.abs(st)>1e12)){Ai("Variable range exceeded");return}ne[c.variableId]=st,Qe!==st&&Jt({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="setComponent"||c.kind==="setAsset"){var We=Le(c.componentId);if(!We)return;var tt=($=He.get(We.id))!==null&&$!==void 0?$:{transform:Ke([],De(We.transform),!1),parameters:{}};c.kind==="setComponent"?tt.parameters[c.key]=c.valueVariableId?ne[c.valueVariableId]:c.value:tt.assetId=c.assetId,He.set(We.id,tt),c.kind==="setComponent"&&c.key==="visible"&&c.value===!1&&(Bn.release(We.id),ar.cancel(We.id))}else if(c.kind==="resetMatch")ko(c.componentId),rc(c.componentId);else if(c.kind==="clearStrokes")(q=sr.get(c.componentId))===null||q===void 0||q.clear(),Dt=Dt.filter(function(On){return On.owner!==c.componentId});else if(c.kind==="resetMask"){var We=Le(c.componentId),St=An("erase-mask",c.componentId);We&&St&&zo(We,St).reset()}else if(c.kind==="raycast3d")Dv(c);else if(c.kind==="spawnAt3d")for(var Ct=Math.max(1,Math.min(16,Math.floor((Q=c.count)!==null&&Q!==void 0?Q:1))),Pt=0;Pt<Ct;Pt++){var Nt=c.jitterX?(Ei.rng.next()*2-1)*c.jitterX:0,Yt=c.jitterZ?(Ei.rng.next()*2-1)*c.jitterZ:0;Lv(c.prototypeId,c.x+Nt,c.y,c.z+Yt)}else if(c.kind==="copyMatchAsset"){var Bt=(te=xt.get(c.boardId))===null||te===void 0?void 0:te.snapshot().lastMatch,it=S.get(c.componentId),Ft=Bt&&((ce=(G=ni.get(c.boardId))===null||G===void 0?void 0:G.get(Bt.group))===null||ce===void 0?void 0:ce.children.find(function(On){return On.contract==="native.image.v1"}));if(Bt&&Ft){var Cn=S.get(Bt.from),bn=In(zn(Cn),Cn.parameters.width/2,Cn.parameters.height/2),_i=it.parentId?zn(S.get(it.parentId)):ga(),ri=In(wr(_i),bn.x,bn.y),wn=(me=He.get(it.id))!==null&&me!==void 0?me:{transform:Ke([],De(it.transform),!1),parameters:{}};wn.transform=Ke([],De(wn.transform),!1),wn.transform[4]=ri.x-it.parameters.width/2,wn.transform[5]=ri.y-it.parameters.height/2,wn.assetId=(ve=Ft.assetSlots[0])===null||ve===void 0?void 0:ve.assetId,He.set(it.id,wn)}}else if(c.kind==="hintMatch")yn=void 0,(xe=xt.get(c.componentId))===null||xe===void 0||xe.showHint();else if(c.kind==="spawn")qd(c.prototypeId,c.x,c.y);else if(c.kind==="spawnAt"){var Rn=(c.at==="self"||c.at==="midpoint")&&(x.selfInstanceId!==void 0||x.instanceId!==void 0)?Le((oe=x.selfInstanceId)!==null&&oe!==void 0?oe:x.instanceId):Ss(c.targetComponentId,x,"self"),Hn=(c.at==="other"||c.at==="midpoint")&&x.otherInstanceId!==void 0?Le(x.otherInstanceId):void 0,it=c.at==="other"?Hn:Rn;if(c.at==="pointer"||(c.at==="midpoint"?Rn&&Hn:it))for(var si=Rn?xi(Rn):void 0,ai=Hn?xi(Hn):void 0,bn=c.at==="pointer"?Je:c.at==="midpoint"?{x:(si.x+ai.x)/2,y:(si.y+ai.y)/2}:xi(it),qn=S.get(c.prototypeId),Ct=Math.max(0,Math.min(16,Math.floor(c.countVariableId?Number(ne[c.countVariableId]):(be=c.count)!==null&&be!==void 0?be:1))),Pt=0;Pt<Ct;Pt++){var Kr=c.jitterX?(Ei.rng.next()*2-1)*c.jitterX:0,Gr=c.jitterY?(Ei.rng.next()*2-1)*c.jitterY:0;qd(c.prototypeId,bn.x+c.offsetX+Kr-qn.parameters.width/2,bn.y+c.offsetY+Gr-qn.parameters.height/2)}}else if(c.kind==="random"){var Qe=ne[c.variableId],st=Ei.rng.between(c.min,c.max,c.integer===!0);ne[c.variableId]=st,Qe!==st&&Jt({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="modifyInstanceState"){var We=c.target==="component"?Le(c.componentId):Ss(c.componentId,x,c.target);We&&Bo(We,c.field,c.op,c.variableId?ne[c.variableId]:c.value)}else if(c.kind==="launchToward"){var Cn=S.get(c.componentId),Ii=ci(Cn),Pn=(Ee=x.selfInstanceId)!==null&&Ee!==void 0?Ee:x.instanceId,We=Cn.prototype?(Ie=Ii.find(function(on){return on.instanceId===Pn||on.id===Pn}))!==null&&Ie!==void 0?Ie:Ii[Ii.length-1]:(Ze=Ss(c.componentId,x,"self"))!==null&&Ze!==void 0?Ze:Le(c.componentId),St=An("physics-body",c.componentId),Ht=We&&$a(We,St);if(!Ht)return;var Lt=void 0;if(c.targetMode==="angle-variable")Lt=Number(ne[c.angleVariableId])*Math.PI/180;else{var it=fp(We,c);if(!it)return;var bn=xi(We);Lt=Math.atan2(it.y-bn.y,it.x-bn.x)}var oi=Number(c.speedVariableId?ne[c.speedVariableId]:c.speed);if(!Number.isFinite(oi)){Ai("Launch speed invalid");return}Ht.vx=Math.cos(Lt)*oi,Ht.vy=Math.sin(Lt)*oi,Ht.atRest=!1,Ht.restElapsed=0,Ht.captured=!1,Ht.exited=!1,c.orientToVelocity!==!1&&Gs(We,Lt),Jt(pi("launch",We))}else if(c.kind==="moveToComponent"){var $i=S.get(c.targetComponentId),We=Ss(c.componentId,x,(lt=c.target)!==null&&lt!==void 0?lt:"self"),it=$i&&ki($i)?(Xe=Ss(c.targetComponentId,x,c.target==="other"?"self":"other"))!==null&&Xe!==void 0?Xe:ci($i)[0]:Le(c.targetComponentId);We&&it&&bs(We,xi(it),c.seconds)}else if(c.kind==="returnToOrigin"){var We=Ss(c.componentId,x,"self"),_r=We&&la.get(We.id);We&&_r&&bs(We,_r,c.seconds)}else if(c.kind==="spawnOnPath")qd(c.prototypeId,0,0,{startNode:c.startNode,targetNode:c.targetNode,networkBehaviorId:c.networkBehaviorId});else if(["setVelocity","applyImpulse","stopBody"].includes(c.kind)){var Hr=S.get(c.componentId),Nn=x.instanceId?Ke([],De(Oe.values()),!1).filter(function(xn){return xn.instanceId===x.instanceId&&xn.prototypeId===Hr.id}):ci(Hr),St=An("physics-body",Hr.id);try{for(var cr=Ue(Nn),Pr=cr.next();!Pr.done;Pr=cr.next()){var We=Pr.value,Ht=$a(We,St);c.kind==="setVelocity"?(Ht.vx=c.vxVariableId?ne[c.vxVariableId]:c.vx,Ht.vy=c.vyVariableId?ne[c.vyVariableId]:c.vy):c.kind==="applyImpulse"?(Ht.vx+=c.vxVariableId?ne[c.vxVariableId]:c.ix,Ht.vy+=c.vyVariableId?ne[c.vyVariableId]:c.iy):(Ht.vx=0,Ht.vy=0,Ht.atRest=!0),Ht.captured=!1,Ht.exited=!1,Ht.restElapsed=0,c.kind!=="stopBody"&&(Ht.atRest=!1)}}catch(xn){A={error:xn}}finally{try{Pr&&!Pr.done&&(C=cr.return)&&C.call(cr)}finally{if(A)throw A.error}}}else if(c.kind==="setPosition"){var Qa=S.get(c.componentId),Nn=x.instanceId?Ke([],De(Oe.values()),!1).filter(function(Kt){return Kt.instanceId===x.instanceId&&Kt.prototypeId===Qa.id}):ci(Qa),St=An("physics-body",Qa.id);try{for(var Lr=Ue(Nn),ur=Lr.next();!ur.done;ur=Lr.next()){var We=ur.value,Ht=$a(We,St);Ht.x=c.xVariableId?ne[c.xVariableId]:c.x,Ht.y=c.yVariableId?ne[c.yVariableId]:c.y,Ht.vx=0,Ht.vy=0,Ht.captured=!1,Ht.exited=!1,Ht.atRest=!0,ua(We,Ht.x,Ht.y)}}catch(Kt){N={error:Kt}}finally{try{ur&&!ur.done&&(P=Lr.return)&&P.call(Lr)}finally{if(N)throw N.error}}}else if(c.kind==="setPathEdge")(ht=bi.get(c.behaviorId))===null||ht===void 0||ht.setEdge(c.edgeId,c.enabled,c.cost);else if(c.kind==="setPathGate")(Gt=bi.get((yt=n.gameplay.find(function(On){return On.id===c.behaviorId}))===null||yt===void 0?void 0:yt.parameters.networkBehaviorId))===null||Gt===void 0||Gt.setGate(c.behaviorId,c.mode,c.holdSeconds);else if(c.kind==="setPathTarget"){var da=S.get(c.componentId),St=An("path-agent",da.id),dr=bi.get(St.parameters.networkBehaviorId);try{for(var fa=Ue(x.instanceId?Ke([],De(Oe.values()),!1).filter(function(xn){return xn.instanceId===x.instanceId&&xn.prototypeId===da.id}):ci(da)),Vi=fa.next();!Vi.done;Vi=fa.next()){var We=Vi.value;We.pathTargetNode=c.targetNode,dr?.setTarget(We.id,c.targetNode)}}catch(xn){X={error:xn}}finally{try{Vi&&!Vi.done&&(k=fa.return)&&k.call(fa)}finally{if(X)throw X.error}}}else if(c.kind==="compute"){var Mi=Number(ne[c.variableId]),ui=c.operandVariableId!==void 0?Number(ne[c.operandVariableId]):c.value;if(["div","mod"].includes(c.op)&&ui===0){Ai("Division by zero");return}var st={add:function(){return Mi+ui},sub:function(){return Mi-ui},mul:function(){return Mi*ui},div:function(){return ui===0?Mi:Mi/ui},mod:function(){return ui===0?Mi:Mi%ui},min:function(){return Math.min(Mi,ui)},max:function(){return Math.max(Mi,ui)},set:function(){return ui},floor:function(){return Math.floor(Mi)},ceil:function(){return Math.ceil(Mi)},abs:function(){return Math.abs(Mi)},clamp:function(){return Math.max(c.min,Math.min(c.max,Mi))}}[c.op]();if(c.round&&(st=Math.round(st)),!Number.isFinite(st)||Math.abs(st)>1e12){Ai("Variable range exceeded");return}var Qe=ne[c.variableId];ne[c.variableId]=st,Qe!==st&&Jt({kind:"variableChange",variableId:c.variableId,instanceId:x.instanceId})}else if(c.kind==="despawn"){var Rn=(Ut=x.selfInstanceId)!==null&&Ut!==void 0?Ut:x.instanceId;c.target==="other"?kn(x.otherInstanceId):c.target==="both"?(kn(Rn),kn(x.otherInstanceId)):kn(Rn)}else if(c.kind==="changeScene")W=c.sceneId;else if(c.kind==="restart")(at=_?.notifyGameRetry)===null||at===void 0||at.call(_),W="__restart";else if(c.kind==="cameraShake")U?.matches||(Ye={intensity:c.intensity,seconds:c.seconds,elapsed:0});else if(c.kind==="screenFlash")ze.push({color:c.color,opacity:c.opacity,seconds:c.seconds,elapsed:0}),ze.length>8&&ze.shift();else if(c.kind==="floatingText"){var Da=S.get(c.componentId),Cn=x.instanceId?(Wt=Ke([],De(Oe.values()),!1).find(function(Kt){return Kt.instanceId===x.instanceId&&Kt.prototypeId===c.componentId}))!==null&&Wt!==void 0?Wt:Da:(Mt=Le(c.componentId))!==null&&Mt!==void 0?Mt:Da,it=Cn?.sceneId===J?Cn:Da;if(it){var bn=void 0;if(it.contract==="native.mesh3d.v1"&&(bn=Vd(it.id)),!bn){var Si=Vt(it);bn=In(zn(it),Si.width/2,Si.height/2)}we.push({x:bn.x,y:bn.y,text:c.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(on,Wr){var Ni;return String((Ni=ne[Wr])!==null&&Ni!==void 0?Ni:"")}),color:c.color,fontSize:c.fontSize,risePx:c.risePx,seconds:c.seconds,elapsed:0}),we.length>32&&we.shift()}}else if(c.kind==="store")x.kind==="click"&&x.pointerId!==void 0&&!ye&&(ye={pointerId:x.pointerId,targetId:x.targetId,condition:R},(mt=e.setPointerCapture)===null||mt===void 0||mt.call(e,x.pointerId));else if(c.behaviorId){var Kn=n.gameplay.find(function(On){return On.id===c.behaviorId});if(c.kind==="playAudio")dp(Kn);else if(c.kind==="animate"){var Un=S.get(Kn.componentId),Nn=ki(Un)?Ke([],De(Oe.values()),!1).filter(function(xn){return xn.prototypeId===Un.id&&(!x.instanceId||xn.instanceId===x.instanceId)}):[Un],ha=function(xn){var Kt=Kn.id+":"+xn.id;pe=pe.filter(function(Wr){return Wr.id!==Kt});var on=gt({},Kn.parameters);on.fromCurrent&&(on.from=on.property==="opacity"?Vt(xn).opacity:Di(xn)[on.property==="x"?4:5]),pe.push(gt(gt({},Kn),{parameters:on,id:Kt,behaviorId:Kn.id,targetId:xn.id,elapsed:0,baseTransform:Ke([],De(xn.transform),!1)}))};try{for(var fr=Ue(Nn),Mr=fr.next();!Mr.done;Mr=fr.next()){var it=Mr.value;ha(it)}}catch(xn){Z={error:xn}}finally{try{Mr&&!Mr.done&&(V=fr.return)&&V.call(fr)}finally{if(Z)throw Z.error}}}else c.kind==="stopAnimation"?pe=pe.filter(function(On){return On.behaviorId!==Kn.id}):c.kind==="emit"&&Vv(Kn,x)}}function Vv(c,x){var R,A,C,N,P,X,k=c.parameters,Z=k.shape==="pixel-confetti",V=k.shape==="confetti",$=Z||V;if(!($&&U?.matches)){if(fe.length+k.count>256){Ai("Particle budget exhausted");return}if(Z&&k.coverage==="screen"){fe.push.apply(fe,Ke([],De(uv(k)),!1));return}if(V&&k.coverage==="screen"){fe.push.apply(fe,Ke([],De(fv(k)),!1));return}for(var q=S.get(c.componentId),Q=x.instanceId&&(R=Ke([],De(Oe.values()),!1).find(function(Ee){return Ee.instanceId===x.instanceId&&Ee.prototypeId===q.id}))!==null&&R!==void 0?R:q,te=Di(Q),G,ce=Le(Q.parentId);ce;ce=Le(ce.parentId)){if($&&ce.contract==="native.group.v1"&&Vt(ce).clip){G=ce.id;break}te=qs(Di(ce),te)}var me=Vt(Q),ve=k.origin==="anchor"?In(te,0,0):$||k.origin==="center"?In(te,me.width/2,me.height/2):{x:te[4]+Q.parameters.width/2,y:te[5]+Q.parameters.height/2};if(Z){fe.push.apply(fe,Ke([],De(Jh(k,ve,G)),!1));return}if(V){fe.push.apply(fe,Ke([],De($h(k,ve,G)),!1));return}for(var xe=0;xe<k.count;xe++){var oe=((A=k.spread)!==null&&A!==void 0?A:360)===360?xe*2.399963:-Math.PI/2+((xe+.5)/k.count-.5)*((C=k.spread)!==null&&C!==void 0?C:360)*Math.PI/180,be=k.speed*(.5+xe%7/14);fe.push(gt(gt({},ve),{vx:Math.cos(oe)*be,vy:Math.sin(oe)*be,life:(N=k.lifetime)!==null&&N!==void 0?N:.7,gravity:(P=k.gravity)!==null&&P!==void 0?P:250,color:k.color,shape:(X=k.shape)!==null&&X!==void 0?X:"circle"}))}}}function xr(){for(var c=function(){var x,R,A,C,N,P,X=Fe.shift();Tt++;var k=function(oe){return oe===void 0||!!Le(oe)||Ke([],De(Oe.values()),!1).some(function(be){return be.instanceId===oe})};if(!k(X.selfInstanceId)||!k(X.otherInstanceId)||["contactBegin","boundaryExit"].includes(X.kind)&&X.instanceId&&!Oe.has(X.instanceId))return"continue";try{for(var Z=(x=void 0,Ue(n.eventBindings)),V=Z.next();!V.done;V=Z.next()){var $=V.value;if(Object.entries(I.get($.eventId)).every(function(oe){var be=De(oe,2),Ee=be[0],Ie=be[1];return Ee==="id"||X[Ee]===Ie})&&Ja($.condition,X)){try{for(var q=(A=void 0,Ue($.actions)),Q=q.next();!Q.done;Q=q.next()){var te=Q.value;if(Zt>=1024||wt)break;zv(te,X,$.condition)}}catch(oe){A={error:oe}}finally{try{Q&&!Q.done&&(C=q.return)&&C.call(q)}finally{if(A)throw A.error}}if(W)break}}}catch(oe){x={error:oe}}finally{try{V&&!V.done&&(R=Z.return)&&R.call(Z)}finally{if(x)throw x.error}}if(W){var G=W;if(W=void 0,G==="__restart")uc();else if(G!==J){var ce=J;pn(),J=G,le.clear(),Bn.clear(),la.clear(),Za.clear(),mr.clear(),sr.clear(),Dt=[],tn=[],Vr.clear(),D.clear(),yn=void 0,Te=[],fe=[],we=[],ze=[],Ye=void 0,Ae=!1,Ne=0,Oe.clear(),fn.clear(),qi.clear(),$t.clear(),Et.clear(),hn.clear(),Vn.clear(),jt?.reset(),wi.clear(),gi.clear(),he=void 0,rp(),Fe=Fe.filter(function(oe){return oe.kind==="variableChange"}),He.clear(),En=void 0;try{for(var me=(N=void 0,Ue(xt.values())),ve=me.next();!ve.done;ve=me.next()){var xe=ve.value;xe.reset()}}catch(oe){N={error:oe}}finally{try{ve&&!ve.done&&(P=me.return)&&P.call(me)}finally{if(N)throw N.error}}ae.clear(),de.clear(),ie.clear(),pe=[],gr(),E.clear(),se=void 0,mn=void 0,lc(),ap(),ac(0,!1),Xd(),zd(0),Jt({kind:"sceneExit",sceneId:ce}),Jt({kind:"sceneEnter",sceneId:J})}}};Fe.length&&!wt&&Tt<256&&Zt<1024;)c();Fe.length&&Ai("Event/action budget exhausted")}function zn(c){return qs(c.parentId?zn(Le(c.parentId)):ga(),Di(c))}var In=function(c,x,R){return{x:c[0]*x+c[2]*R+c[4],y:c[1]*x+c[3]*R+c[5]}};function zi(c,x){var R=Vt(c),A=[[0,0],[R.width,0],[R.width,R.height],[0,R.height]].map(function(C){var N=De(C,2),P=N[0],X=N[1];return In(x,P,X)});return{left:Math.min.apply(Math,Ke([],De(A.map(function(C){return C.x})),!1)),right:Math.max.apply(Math,Ke([],De(A.map(function(C){return C.x})),!1)),top:Math.min.apply(Math,Ke([],De(A.map(function(C){return C.y})),!1)),bottom:Math.max.apply(Math,Ke([],De(A.map(function(C){return C.y})),!1))}}function ii(c){return Vt(c).visible&&Vt(c).opacity>0&&(!c.parentId||ii(Le(c.parentId)))}function hp(c,x){for(var R=Vt(c),A=zn(c),C=Math.min(R.width,R.height)/2,N=x==="circle"?Array.from({length:32},function(k,Z){return In(A,R.width/2+Math.cos(Z*Math.PI/16)*C,R.height/2+Math.sin(Z*Math.PI/16)*C)}):[[0,0],[R.width,0],[R.width,R.height],[0,R.height]].map(function(k){var Z=De(k,2),V=Z[0],$=Z[1];return In(A,V,$)}),P=c.parentId?Le(c.parentId):void 0,X=function(){var k=Vt(P);if(P.contract==="native.group.v1"&&k.clip){for(var Z=zn(P),V=[[0,0],[k.width,0],[k.width,k.height],[0,k.height]].map(function(G){var ce=De(G,2),me=ce[0],ve=ce[1];return In(Z,me,ve)}),$=0,q=0;q<4;q++)$+=V[q].x*V[(q+1)%4].y-V[(q+1)%4].x*V[q].y;for(var Q=$>=0?1:-1,te=function(G){var ce,me,ve=V[G],xe=V[(G+1)%4],oe=function(Gt){return Q*((xe.x-ve.x)*(Gt.y-ve.y)-(xe.y-ve.y)*(Gt.x-ve.x))},be=N;N=[];var Ee=be[be.length-1],Ie=oe(Ee);try{for(var Ze=(ce=void 0,Ue(be)),lt=Ze.next();!lt.done;lt=Ze.next()){var Xe=lt.value,ht=oe(Xe);if(ht>=0!=Ie>=0){var yt=Ie/(Ie-ht);N.push({x:Ee.x+(Xe.x-Ee.x)*yt,y:Ee.y+(Xe.y-Ee.y)*yt})}ht>=0&&N.push(Xe),Ee=Xe,Ie=ht}}catch(Gt){ce={error:Gt}}finally{try{lt&&!lt.done&&(me=Ze.return)&&me.call(Ze)}finally{if(ce)throw ce.error}}},q=0;q<4&&N.length;q++)te(q)}P=P.parentId?Le(P.parentId):void 0};P;)X();return N}function Gv(c,x){var R,A,C,N,P,X;if(c.length<3||x.length<3)return!1;try{for(var k=Ue([c,x]),Z=k.next();!Z.done;Z=k.next())for(var V=Z.value,$=0;$<V.length;$++){var q=V[$],Q=V[($+1)%V.length],te=q.y-Q.y,G=Q.x-q.x,ce=1/0,me=-1/0,ve=1/0,xe=-1/0;try{for(var oe=(C=void 0,Ue(c)),be=oe.next();!be.done;be=oe.next()){var Ee=be.value,Ie=Ee.x*te+Ee.y*G;ce=Math.min(ce,Ie),me=Math.max(me,Ie)}}catch(Xe){C={error:Xe}}finally{try{be&&!be.done&&(N=oe.return)&&N.call(oe)}finally{if(C)throw C.error}}try{for(var Ze=(P=void 0,Ue(x)),lt=Ze.next();!lt.done;lt=Ze.next()){var Ee=lt.value,Ie=Ee.x*te+Ee.y*G;ve=Math.min(ve,Ie),xe=Math.max(xe,Ie)}}catch(Xe){P={error:Xe}}finally{try{lt&&!lt.done&&(X=Ze.return)&&X.call(Ze)}finally{if(P)throw P.error}}if(me<ve||xe<ce)return!1}}catch(Xe){R={error:Xe}}finally{try{Z&&!Z.done&&(A=k.return)&&A.call(k)}finally{if(R)throw R.error}}return!0}function Hv(c){var x,R,A,C,N=O();try{for(var P=Ue(le.values()),X=P.next();!X.done;X=P.next()){var k=X.value,Z=k.behavior.parameters;if(!(!Z.moveComponentId||k.magnitude<=0)){var V=Le(Z.moveComponentId);if(!(!V||!ii(V))){var $=(A=Z.moveSpeed)!==null&&A!==void 0?A:220,q=An("physics-body",(C=V.prototypeId)!==null&&C!==void 0?C:V.id);if(q&&q.parameters.mode==="dynamic"){var Q=$a(V,q);Q.vx=k.nx*$,Q.vy=k.ny*$,Q.atRest=!1,Q.restElapsed=0}else{var te=xi(V),G=Vt(V),ce=te.x+k.nx*$*c,me=te.y+k.ny*$*c;mp(V)||(ce=Math.max(G.width/2,Math.min(N.width-G.width/2,ce)),me=Math.max(G.height/2,Math.min(N.height-G.height/2,me))),ua(V,ce,me)}Z.orientToMove&&Gs(V,Math.atan2(k.ny,k.nx))}}}}catch(ve){x={error:ve}}finally{try{X&&!X.done&&(R=P.return)&&R.call(P)}finally{if(x)throw x.error}}}function pp(c){var x,R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be,Ee,Ie,Ze,lt,Xe,ht,yt,Gt,Ut,at,Wt,Mt=O();_e+=c,ig(c),Bv(c),Hv(c),kv(c),Iv();try{for(var mt=Ue(Fn),Qe=mt.next();!Qe.done;Qe=mt.next()){var st=De(Qe.value,2),We=st[0],tt=st[1];!tt.held&&_e-((Ie=tt.releasedAt)!==null&&Ie!==void 0?Ie:_e)>=tt.behavior.springBackSeconds&&Fn.delete(We)}}catch(Xt){x={error:Xt}}finally{try{Qe&&!Qe.done&&(R=mt.return)&&R.call(mt)}finally{if(x)throw x.error}}Ye&&(Ye.elapsed+=c,Ye.elapsed>=Ye.seconds&&(Ye=void 0));try{for(var St=Ue(ze),Ct=St.next();!Ct.done;Ct=St.next()){var Pt=Ct.value;Pt.elapsed+=c}}catch(Xt){A={error:Xt}}finally{try{Ct&&!Ct.done&&(C=St.return)&&C.call(St)}finally{if(A)throw A.error}}ze=ze.filter(function(Xt){return Xt.elapsed<Xt.seconds});try{for(var Nt=Ue(we),Yt=Nt.next();!Yt.done;Yt=Nt.next()){var Bt=Yt.value;Bt.elapsed+=c}}catch(Xt){N={error:Xt}}finally{try{Yt&&!Yt.done&&(P=Nt.return)&&P.call(Nt)}finally{if(N)throw N.error}}we=we.filter(function(Xt){return Xt.elapsed<Xt.seconds});try{for(var it=Ue(xt),Ft=it.next();!Ft.done;Ft=it.next()){var Cn=De(Ft.value,2),We=Cn[0],bn=Cn[1];S.get(We).sceneId===J&&ii(S.get(We))&&bn.tick(c)}}catch(Xt){X={error:Xt}}finally{try{Ft&&!Ft.done&&(k=it.return)&&k.call(it)}finally{if(X)throw X.error}}var _i=function(Xt){var Wn,Ui,Zn=S.get(Xt.componentId);if(Zn.sceneId!==J)return"continue";var br=ki(Zn)?Ke([],De(Oe.values()),!1).filter(function(Xo){return Xo.prototypeId===Zn.id}):[Zn];try{for(var Gn=(Wn=void 0,Ue(br)),Fi=Gn.next();!Fi.done;Fi=Gn.next()){var Gi=Fi.value,Na=Xt.id+":"+Gi.id;if(Xt.kind==="motion"){var Ki=(Ze=He.get(Gi.id))!==null&&Ze!==void 0?Ze:{transform:Ke([],De(Gi.transform),!1),parameters:{}},pa=(lt=Ki.velocity)!==null&&lt!==void 0?lt:{x:Xt.parameters.vx,y:Xt.parameters.vy};pa.y+=Xt.parameters.gravity*c,Ki.transform[4]+=pa.x*c,Ki.transform[5]+=pa.y*c,Ki.velocity=pa,He.set(Gi.id,Ki),Gi.prototypeId&&(Gi.transform=Ki.transform);var Xs=zn(Gi);(Xs[5]>Mt.height||Xs[4]<-300||Xs[4]>Mt.width+300)&&(Ki.exited||(Ki.exited=!0,Jt({kind:"boundaryExit",componentId:Zn.id,instanceId:Gi.instanceId})))}else if(Xt.kind==="timer"){var es=((Xe=ie.get(Na))!==null&&Xe!==void 0?Xe:0)+c;ie.set(Na,es),es>=Xt.parameters.seconds&&es-c<Xt.parameters.seconds&&(Jt({kind:"timer",behaviorId:Xt.id,componentId:Zn.id}),Xt.parameters.repeat&&ie.set(Na,es-Xt.parameters.seconds))}}}catch(Xo){Wn={error:Xo}}finally{try{Fi&&!Fi.done&&(Ui=Gn.return)&&Ui.call(Gn)}finally{if(Wn)throw Wn.error}}};try{for(var ri=Ue(n.gameplay),wn=ri.next();!wn.done;wn=ri.next()){var Rn=wn.value;_i(Rn)}}catch(Xt){Z={error:Xt}}finally{try{wn&&!wn.done&&(V=ri.return)&&V.call(ri)}finally{if(Z)throw Z.error}}Av(c),Rv(c),ac(c),zd(c);var Hn=[],si=function(Xt){var Wn,Ui,Zn=S.get(Xt.componentId);if(Zn.sceneId!==J)return"continue";try{for(var br=(Wn=void 0,Ue(ki(Zn)?Ke([],De(Oe.values()),!1).filter(function(Gi){return Gi.prototypeId===Zn.id}):[Zn])),Gn=br.next();!Gn.done;Gn=br.next()){var Fi=Gn.value;if(ii(Fi)){if(Hn.length>=256){Ai("Collider budget exhausted");break}Hn.push({b:Xt,c:Fi,box:zi(Fi,zn(Fi)),polygon:hp(Fi,Xt.parameters.shape)})}}}catch(Gi){Wn={error:Gi}}finally{try{Gn&&!Gn.done&&(Ui=br.return)&&Ui.call(br)}finally{if(Wn)throw Wn.error}}};try{for(var ai=Ue(n.gameplay.filter(function(Xt){return Xt.kind==="collider"})),qn=ai.next();!qn.done;qn=ai.next()){var Rn=qn.value;si(Rn)}}catch(Xt){$={error:Xt}}finally{try{qn&&!qn.done&&(q=ai.return)&&q.call(ai)}finally{if($)throw $.error}}var Kr=new Set,Gr=new Map,Ii=function(Xt,Wn,Ui){var Zn,br,Gn;((Zn=Wn.c.prototypeId)!==null&&Zn!==void 0?Zn:Wn.c.id)===((br=Ui.c.prototypeId)!==null&&br!==void 0?br:Ui.c.id)&&Wn.c.id>Ui.c.id||Jt(gt(gt({},pi(Xt,Wn.c,Ui.c)),{instanceId:(Gn=Wn.c.instanceId)!==null&&Gn!==void 0?Gn:Ui.c.instanceId}))},Pn=0;e:for(var Ht=0;Ht<Hn.length;Ht++)for(var Rn=Ht+1;Rn<Hn.length;Rn++){var Lt=Hn[Ht],oi=Hn[Rn];if(!(Lt.c.instanceId&&Lt.c.instanceId===oi.c.instanceId)){var $i=Lt.box,_r=oi.box,Hr=$i.left<_r.right&&$i.right>_r.left&&$i.top<_r.bottom&&$i.bottom>_r.top;if(Hr){if(++Pn>4096){Ai("Collision budget exhausted");break e}Hr=Gv(Lt.polygon,oi.polygon)}if(Hr){var Nn=[Lt.c.id,oi.c.id].sort().join("|");if(Kr.add(Nn),Gr.set(Nn,[Lt,oi]),!ae.has(Nn))try{for(var cr=(Q=void 0,Ue([[Lt,oi],[oi,Lt]])),Pr=cr.next();!Pr.done;Pr=cr.next()){var Qa=De(Pr.value,2),Lr=Qa[0],ur=Qa[1];Ii("contactBegin",Lr,ur)}}catch(Wn){Q={error:Wn}}finally{try{Pr&&!Pr.done&&(te=cr.return)&&te.call(cr)}finally{if(Q)throw Q.error}}}}}try{for(var da=Ue(de),dr=da.next();!dr.done;dr=da.next()){var fa=De(dr.value,2),Nn=fa[0],Vi=De(fa[1],2),Lt=Vi[0],oi=Vi[1];if(!Kr.has(Nn))try{for(var Mi=(me=void 0,Ue([[Lt,oi],[oi,Lt]])),ui=Mi.next();!ui.done;ui=Mi.next()){var Da=De(ui.value,2),Lr=Da[0],ur=Da[1];Ii("contactEnd",Lr,ur)}}catch(Zn){me={error:Zn}}finally{try{ui&&!ui.done&&(ve=Mi.return)&&ve.call(Mi)}finally{if(me)throw me.error}}}}catch(Xt){G={error:Xt}}finally{try{dr&&!dr.done&&(ce=da.return)&&ce.call(da)}finally{if(G)throw G.error}}ae=Kr,de=Gr;try{for(var Si=Ue(pe),Kn=Si.next();!Kn.done;Kn=Si.next()){var Ht=Kn.value;Ht.elapsed+=c;var Un=Ht.parameters,ha=(ht=Un.delay)!==null&&ht!==void 0?ht:0,fr=Ht.elapsed-ha;if(!(fr<0)){var Mr=fr/Un.seconds,On=Un.loop?Mr%1:Math.min(1,Mr),xn=(yt=Un.easing)!==null&&yt!==void 0?yt:"ease-out",Kt=On;Un.loop&&xn==="ease-in-out"?Kt=.5-.5*Math.cos(On*Math.PI*2):xn==="ease-out"?Kt=1-Math.pow(1-On,3):xn==="ease-in"?Kt=Math.pow(On,3):xn==="ease-in-out"?Kt=On<.5?4*Math.pow(On,3):1-Math.pow(-2*On+2,3)/2:xn==="back-out"&&(Kt=1+2.70158*Math.pow(On-1,3)+1.70158*Math.pow(On-1,2));var on=Un.from+(Un.to-Un.from)*Kt,Wr=Le((Gt=Ht.targetId)!==null&&Gt!==void 0?Gt:Ht.componentId);if(Wr){var Ni=(Ut=He.get(Wr.id))!==null&&Ut!==void 0?Ut:{transform:Ke([],De(Wr.transform),!1),parameters:{}},Sr=(at=Ht.baseTransform)!==null&&at!==void 0?at:Wr.transform;if(Un.property==="opacity")Ni.parameters.opacity=Math.max(0,Math.min(1,on));else if(["scale","scaleX","scaleY","rotation"].includes(Un.property)){(Wt=Ni.animationAxes)!==null&&Wt!==void 0||(Ni.animationAxes={scale:1,scaleX:1,scaleY:1,rotation:0}),Ni.animationAxes[Un.property]=on;var Qr=Ni.animationAxes,pc=Qr.rotation*Math.PI/180,ws=Math.cos(pc),ja=Math.sin(pc),Ws=Qr.scale*Qr.scaleX,Wo=Qr.scale*Qr.scaleY;Ni.transform[0]=(Sr[0]*ws+Sr[2]*ja)*Ws,Ni.transform[1]=(Sr[1]*ws+Sr[3]*ja)*Ws,Ni.transform[2]=(-Sr[0]*ja+Sr[2]*ws)*Wo,Ni.transform[3]=(-Sr[1]*ja+Sr[3]*ws)*Wo}else Ni.transform[Un.property==="x"?4:5]=on;He.set(Wr.id,Ni),Un.loop&&fr>=Un.seconds&&(Ht.elapsed=ha+fr%Un.seconds)}}}}catch(Xt){xe={error:Xt}}finally{try{Kn&&!Kn.done&&(oe=Si.return)&&oe.call(Si)}finally{if(xe)throw xe.error}}pe=pe.filter(function(Xt){var Wn,Ui;return Le((Wn=Xt.targetId)!==null&&Wn!==void 0?Wn:Xt.componentId)&&(Xt.elapsed<Xt.parameters.seconds+((Ui=Xt.parameters.delay)!==null&&Ui!==void 0?Ui:0)||Xt.parameters.loop)});try{for(var jr=Ue(fe),ea=jr.next();!ea.done;ea=jr.next()){var Un=ea.value;if(Un.shape==="pixel-confetti"||Un.shape==="confetti"){Un.age+=c;continue}Un.life-=c,Un.x+=Un.vx*c,Un.y+=Un.vy*c,Un.vy+=Un.gravity*c}}catch(Xt){be={error:Xt}}finally{try{ea&&!ea.done&&(Ee=jr.return)&&Ee.call(jr)}finally{if(be)throw be.error}}fe=fe.filter(function(Xt){var Wn;return Xt.life>((Wn=Xt.age)!==null&&Wn!==void 0?Wn:0)}),xr()}function dc(c,x){var R,A,C;if(p.beginPath(),c.contract==="native.ellipse.v1")p.ellipse(x.width/2,x.height/2,x.width/2,x.height/2,0,0,Math.PI*2);else if(c.contract==="native.path.v1"){var N=function(q,Q){({M:function(){return p.moveTo.apply(p,Ke([],De(Q),!1))},L:function(){return p.lineTo.apply(p,Ke([],De(Q),!1))},C:function(){return p.bezierCurveTo.apply(p,Ke([],De(Q),!1))},Q:function(){return p.quadraticCurveTo.apply(p,Ke([],De(Q),!1))},Z:function(){return p.closePath()}})[q]()};try{for(var P=Ue(x.commands),X=P.next();!X.done;X=P.next()){var k=De(X.value),Z=k[0],V=k.slice(1);N(Z,V)}}catch(q){R={error:q}}finally{try{X&&!X.done&&(A=P.return)&&A.call(P)}finally{if(R)throw R.error}}}else{var $=Math.min((C=x.radius)!==null&&C!==void 0?C:0,x.width/2,x.height/2);typeof p.roundRect=="function"?p.roundRect(0,0,x.width,x.height,$):(p.moveTo($,0),p.arcTo(x.width,0,x.width,x.height,$),p.arcTo(x.width,x.height,0,x.height,$),p.arcTo(0,x.height,0,0,$),p.arcTo(0,0,x.width,0,$),p.closePath())}}function Wv(c,x,R){var A,C,N,P=(A=He.get(c.id))===null||A===void 0?void 0:A.pathFrame;if(P!==void 0)return Math.min(x.frameCount-1,P);if(f||!x.frameRate)return 0;if(c.contract!=="native.walk-sprite.v1")return Math.floor(Math.max(0,_e-((C=c.spawnTime)!==null&&C!==void 0?C:0))*x.frameRate)%x.frameCount;var X=(N=c.runtimeId)!==null&&N!==void 0?N:c.id,k=Pe.get(X);if(!k)return Pe.set(X,{x:R[4],y:R[5],phase:0,lastMove:-1/0,frame:0}),0;var Z=Math.hypot(R[4]-k.x,R[5]-k.y)>.3;if(Z){var V=_e-k.lastMove;k.phase=Number.isFinite(V)&&V<.25?k.phase+Math.min(V,.12)*x.frameRate:0,k.lastMove=_e}return k.x=R[4],k.y=R[5],_e-k.lastMove>.11&&(k.phase=0),k.frame=Math.floor(k.phase)%x.frameCount,k.frame}function Vo(c,x,R,A){var C,N,P,X,k,Z,V,$,q,Q,te;if(x===void 0&&(x=ga()),R===void 0&&(R=[]),c.contract!=="native.mesh3d.v1"){var G=Vt(c),ce=An("erase-mask",(k=c.prototypeId)!==null&&k!==void 0?k:c.id);if(!(!G.visible||G.opacity<=0)){var me=qs(x,Di(c));p.save(),p.transform.apply(p,Ke([],De(Di(c)),!1)),p.globalAlpha*=G.opacity;var ve=Fn.get(c.id);ve?.behavior.liftShadow&&(p.shadowColor="#00000055",p.shadowBlur=8,p.shadowOffsetY=4);var xe=R;c.contract==="native.group.v1"&&G.clip&&(p.beginPath(),p.rect(0,0,G.width,G.height),p.clip(),xe=Ke(Ke([],De(R),!1),[{matrix:me,width:G.width,height:G.height}],!1));var oe=!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(c.contract)){var be=c.contract==="native.button.v1",Ee=se===c.id,Ie=be?G.enabled?Ee?G.pressedFill:an===c.id?G.hoverFill:G.fill:G.disabledFill:G.fill;if(be&&(G.presentation==="pixel-cta"||G.presentation==="shiny-cta")){var Ze=(Z=M.get(c.id))!==null&&Z!==void 0?Z:Ge;E.set(c.id,Ze);var lt=!f&&!U?.matches?Ge-Ze:-1;G.presentation==="shiny-cta"?mv(p,G,Ie,Ee,lt):pv(p,G,Ie,Ee,lt)}else G.pixelFrame&&(p.save(),p.translate(3,4),dc(c,G),p.fillStyle="#3c293366",p.fill(),p.restore()),dc(c,G),ce?(p.save(),p.clip(),zo(c,ce).render(p),p.restore(),oe=!0,dc(c,G)):(p.fillStyle=Ie,p.fill()),G.pixelFrame&&!(G.radius>0)&&(p.fillStyle="#ffffff22",p.fillRect(2,2,Math.max(0,G.width-4),2),p.fillRect(2,2,2,Math.max(0,G.height-4))),G.strokeWidth&&(p.strokeStyle=G.stroke,p.lineWidth=G.strokeWidth,p.stroke());yn===c.id&&(dc(c,G),p.strokeStyle="#ffffff",p.lineWidth=5,p.stroke())}var Xe;if(c.contract==="native.text.v1"){var ht=G.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(wn,Rn){var Hn;return String((Hn=ne[Rn])!==null&&Hn!==void 0?Hn:"")});G.pixelPanel&&(p.fillStyle="#3c293366",p.fillRect(3,4,G.width,G.height),p.fillStyle=G.panelFill,p.fillRect(0,0,G.width,G.height),p.strokeStyle=(V=G.panelStroke)!==null&&V!==void 0?V:G.color,p.lineWidth=2,p.strokeRect(1,1,G.width-2,G.height-2),p.fillStyle="#ffffff22",p.fillRect(3,3,Math.max(0,G.width-6),2));var yt=G.fontFamily==="pixel"?Yh(ht,G):void 0;yt&&!yt.unsupportedChars.length?Xe=cv(p,ht,G):Xe=Qb(p,ht,yt?gt(gt({},G),{fontFamily:"sans-serif",fontWeight:"700"}):G)}if(["native.image.v1","native.sprite.v1","native.walk-sprite.v1"].includes(c.contract)&&!ce){var Gt=b.get((q=($=He.get(c.id))===null||$===void 0?void 0:$.assetId)!==null&&q!==void 0?q:(Q=c.assetSlots[0])===null||Q===void 0?void 0:Q.assetId);if(Gt?.complete&&Gt.naturalWidth){p.save(),p.beginPath(),p.rect(0,0,G.width,G.height),p.clip();var Ut=c.contract!=="native.image.v1",at=Ut?Math.min(G.frameColumns,G.frameCount):1,Wt=Ut?Math.ceil(G.frameCount/at):1,Mt=Gt.width/at,mt=Gt.height/Wt,Qe=Ut?Wv(c,G,me):0,st=Qe%at*Mt,We=Math.floor(Qe/at)*mt,tt=G.fit==="cover"?Math.max(G.width/Mt,G.height/mt):Math.min(G.width/Mt,G.height/mt),St=G.fit==="stretch"?G.width:Mt*tt,Ct=G.fit==="stretch"?G.height:mt*tt;p.imageSmoothingEnabled=(te=G.smoothing)!==null&&te!==void 0?te:!0,p.drawImage(Gt,st,We,Mt,mt,(G.width-St)/2,(G.height-Ct)/2,St,Ct),p.restore()}}if(ce&&!oe&&zo(c,ce).render(p),c.contract==="native.stage3d.v1"&&jt){var st=Math.hypot(me[0],me[1]),We=Math.hypot(me[2],me[3]),Pt=jt.renderStage(c,p,G.width*st*Me*Se,G.height*We*Me*Se,G.width,G.height,{time:_e,ambientTime:Ge,propsOf:Vt,bodies3d:$t,fpsPose:Vn.get(c.id),instances3d:sp(c.id),aimLocked:!!It,groundFn:Js,worldWidth:G.width*st,worldHeight:G.height*We});try{for(var Nt=Ue($t),Yt=Nt.next();!Yt.done;Yt=Nt.next()){var Bt=De(Yt.value,2),it=Bt[0],Ft=Bt[1];if(Ft.stageId===c.id&&Ft.mode==="dynamic"){var Cn=Pt.project({x:Ft.x,y:Ft.y,z:Ft.z},G.width,G.height);hn.set(it,In(me,Cn.x,Cn.y))}}}catch(Hn){C={error:Hn}}finally{try{Yt&&!Yt.done&&(N=Nt.return)&&N.call(Nt)}finally{if(C)throw C.error}}}ue.push({c,m:me,clips:xe,instance:A??c.prototypeId,textMetrics:Xe});try{for(var bn=Ue(yr(c.id)),_i=bn.next();!_i.done;_i=bn.next()){var ri=_i.value;Vo(ri,me,xe,A??c.prototypeId)}}catch(wn){P={error:wn}}finally{try{_i&&!_i.done&&(X=bn.return)&&X.call(bn)}finally{if(P)throw P.error}}G.clip&&c.contract==="native.group.v1"&&Zd(c.id),p.restore()}}}function Zd(c,x){var R,A;if(!U?.matches)try{for(var C=Ue(fe),N=C.next();!N.done;N=C.next()){var P=N.value;P.shape!=="pixel-confetti"&&P.shape!=="confetti"||P.clipId!==c||!!P.screen!=!!x||(p.save(),P.shape==="confetti"?hv(p,P,x):dv(p,P,x),p.restore())}}catch(X){R={error:X}}finally{try{N&&!N.done&&(A=C.return)&&A.call(C)}finally{if(R)throw R.error}}}function Xv(c,x,R,A){p.save(),p.translate(c,x),p.globalAlpha=.92,p.lineWidth=2,p.lineJoin="round",R==="tap"&&(p.strokeStyle="#fff0bd",p.globalAlpha=.7*(1-A),p.beginPath(),p.arc(0,0,12+A*12,0,Math.PI*2),p.stroke(),p.globalAlpha=.92),p.fillStyle="#fff0bd",p.strokeStyle="#193b46",p.beginPath(),p.moveTo(-7,10),p.lineTo(-9,-1),p.quadraticCurveTo(-9,-5,-5,-5),p.lineTo(-3,-3),p.lineTo(-3,-17),p.quadraticCurveTo(-3,-22,1,-22),p.quadraticCurveTo(5,-22,5,-17),p.lineTo(5,-6),p.quadraticCurveTo(9,-9,11,-5),p.quadraticCurveTo(15,-7,16,-2),p.lineTo(14,9),p.quadraticCurveTo(12,18,3,18),p.lineTo(-1,18),p.quadraticCurveTo(-5,17,-7,10),p.closePath(),p.fill(),p.stroke(),p.restore()}function Yv(){var c,x,R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve;if(Ne=0,!f)try{for(var xe=Ue(n.gameplay.filter(function(Nn){return Nn.kind==="tutorial-hand"})),oe=xe.next();!oe.done;oe=xe.next()){var be=oe.value,Ee=S.get(be.componentId),Ie=Le(be.parameters.targetId);if(!(!Ee||Ee.sceneId!==J||!Ie||Ie.sceneId!==J||!ii(Ie))&&!(be.parameters.hideOnFirstInput&&Ae)){var Ze=je?_e:Ge;if(!(Ze-Re<be.parameters.idleDelaySeconds)){Ne++;var lt=be.parameters.destinationId?Le(be.parameters.destinationId):void 0,Xe=Vt(Ie),ht=void 0;Ie.contract==="native.mesh3d.v1"&&(ht=Vd(Ie.id)),ht||(ht=In(zn(Ie),Xe.width/2,Xe.height/2));var yt=Ze%1.2/1.2,Gt=U?.matches?0:yt*yt*(3-2*yt),Ut=ht.x,at=ht.y;if(be.parameters.mode!=="tap"){var Wt=lt?In(zn(lt),Vt(lt).width/2,Vt(lt).height/2):{x:ht.x-36,y:ht.y+48};Ut=ht.x+(Wt.x-ht.x)*Gt,at=ht.y+(Wt.y-ht.y)*Gt}Xv(Ut+8,at+22,be.parameters.mode,Gt)}}}}catch(Nn){c={error:Nn}}finally{try{oe&&!oe.done&&(x=xe.return)&&x.call(xe)}finally{if(c)throw c.error}}try{for(var Mt=Ue(sr),mt=Mt.next();!mt.done;mt=Mt.next()){var Qe=De(mt.value,2),st=Qe[0],We=Qe[1],tt=An("draw-stroke",st).parameters;try{for(var St=(C=void 0,Ue(We.strokes)),Ct=St.next();!Ct.done;Ct=St.next()){var Pt=Ct.value;if(!(Pt.points.length<2)){p.save(),p.globalAlpha=tt.mode==="slice-blade"?Math.max(0,1-Pt.age/.18):1,p.strokeStyle=tt.color,p.lineWidth=tt.strokeWidth,p.lineCap="round",p.lineJoin="round",p.beginPath(),p.moveTo(Pt.points[0].x,Pt.points[0].y);try{for(var Nt=(P=void 0,Ue(Pt.points.slice(1))),Yt=Nt.next();!Yt.done;Yt=Nt.next()){var Bt=Yt.value;p.lineTo(Bt.x,Bt.y)}}catch(Nn){P={error:Nn}}finally{try{Yt&&!Yt.done&&(X=Nt.return)&&X.call(Nt)}finally{if(P)throw P.error}}p.stroke(),p.restore()}}}catch(Nn){C={error:Nn}}finally{try{Ct&&!Ct.done&&(N=St.return)&&N.call(St)}finally{if(C)throw C.error}}}}catch(Nn){R={error:Nn}}finally{try{mt&&!mt.done&&(A=Mt.return)&&A.call(Mt)}finally{if(R)throw R.error}}try{for(var it=Ue(tn),Ft=it.next();!Ft.done;Ft=it.next()){var Cn=Ft.value;if(!(Cn.broken||!Cn.drawRope)){var bn=fn.get(Cn.bodyId),_i=Le(Cn.anchorId);if(!(!bn||!_i)){var ri=xi(_i);p.save(),p.strokeStyle=Cn.ropeColor,p.lineWidth=Cn.ropeWidth,p.beginPath(),p.moveTo(ri.x,ri.y),p.lineTo(bn.x,bn.y),p.stroke(),p.restore()}}}}catch(Nn){k={error:Nn}}finally{try{Ft&&!Ft.done&&(Z=it.return)&&Z.call(it)}finally{if(k)throw k.error}}try{for(var wn=Ue(n.gameplay.filter(function(Nn){var cr;return Nn.kind==="virtual-joystick"&&((cr=S.get(Nn.componentId))===null||cr===void 0?void 0:cr.sceneId)===J})),Rn=wn.next();!Rn.done;Rn=wn.next()){var be=Rn.value,Hn=Le(be.componentId),Xe=be.parameters;if(!(!Hn||!ii(Hn)||Xe.drawControl===!1)){var si=le.get(be.id),ai=si&&si.pointerId!==null?si.origin:xi(Hn),qn=si&&si.pointerId!==null?si.knobX:ai.x,Kr=si&&si.pointerId!==null?si.knobY:ai.y,Gr=(ce=Xe.radiusPx)!==null&&ce!==void 0?ce:56;p.save(),p.fillStyle=(me=Xe.baseColor)!==null&&me!==void 0?me:"#ffffff44",p.strokeStyle="#ffffffaa",p.lineWidth=2.5,p.beginPath(),p.arc(ai.x,ai.y,Gr,0,Math.PI*2),p.fill(),p.stroke(),p.fillStyle=(ve=Xe.knobColor)!==null&&ve!==void 0?ve:"#fff0bdee",p.strokeStyle="#193b46aa",p.lineWidth=2,p.beginPath(),p.arc(qn,Kr,Gr*.42,0,Math.PI*2),p.fill(),p.stroke(),p.restore()}}}catch(Nn){V={error:Nn}}finally{try{Rn&&!Rn.done&&($=wn.return)&&$.call(wn)}finally{if(V)throw V.error}}try{for(var Ii=Ue(we),Pn=Ii.next();!Pn.done;Pn=Ii.next()){var Ht=Pn.value,Lt=Math.min(1,Ht.elapsed/Ht.seconds);p.save(),p.globalAlpha=1-Lt,p.fillStyle=Ht.color,p.strokeStyle="#193b46",p.lineWidth=3,p.font="900 "+Ht.fontSize+"px sans-serif",p.textAlign="center",p.textBaseline="middle";var at=Ht.y-(U?.matches?0:Ht.risePx*Lt);p.strokeText(Ht.text,Ht.x,at),p.fillText(Ht.text,Ht.x,at),p.restore()}}catch(Nn){q={error:Nn}}finally{try{Pn&&!Pn.done&&(Q=Ii.return)&&Q.call(Ii)}finally{if(q)throw q.error}}try{for(var oi=Ue(ze),$i=oi.next();!$i.done;$i=oi.next()){var _r=$i.value,Lt=Math.min(1,_r.elapsed/_r.seconds),Hr=O();p.save(),p.globalAlpha=_r.opacity*(1-Lt),p.fillStyle=_r.color,p.fillRect(0,0,Hr.width,Hr.height),p.restore()}}catch(Nn){te={error:Nn}}finally{try{$i&&!$i.done&&(G=oi.return)&&G.call(oi)}finally{if(te)throw te.error}}}function qv(){if(he){var c=fn.get(he.targetId),x=he.behavior.parameters;if(c){var R=he.current.x-he.start.x,A=he.current.y-he.start.y,C=Math.hypot(R,A),N=Math.min(x.maxPullPx,C),P=C>.001?N/C:0;p.save(),p.lineCap="round";var X=Math.max(12,Math.min(c.width,c.height)*.62);if(p.strokeStyle="#173a2f66",p.lineWidth=3.5,p.beginPath(),p.arc(c.x,c.y,X,0,Math.PI*2),p.stroke(),p.strokeStyle=x.trajectoryColor,p.lineWidth=2,p.beginPath(),p.arc(c.x,c.y,X,0,Math.PI*2),p.stroke(),x.showTrajectory&&C>=x.minPullPx){var k=Jd(),Z=ip(),V=Z.bodies,$=Z.zones,q=O(),Q=tm({body:gt(gt({},c),{vx:k.vx,vy:k.vy,atRest:!1}),bodies:V,zones:$,bounds:{left:0,top:0,right:q.width,bottom:q.height},dots:x.trajectoryDots,bounces:x.trajectoryBounces});Q.forEach(function(ce,me){var ve=.96-.52*(me/Math.max(1,Q.length)),xe=Math.max(2.2,4.5-me*.22);p.globalAlpha=ve,p.fillStyle="#173a2f88",p.beginPath(),p.arc(ce.x,ce.y,xe+1.3,0,Math.PI*2),p.fill(),p.fillStyle=x.trajectoryColor,p.beginPath(),p.arc(ce.x,ce.y,xe,0,Math.PI*2),p.fill()})}if(C>=4){var te=c.x+R*P,G=c.y+A*P;p.globalAlpha=.9,p.strokeStyle="#173a2f66",p.lineWidth=5,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(te,G),p.stroke(),p.strokeStyle=x.trajectoryColor,p.lineWidth=2.6,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(te,G),p.stroke(),p.fillStyle="#173a2f88",p.beginPath(),p.arc(te,G,5.2,0,Math.PI*2),p.fill(),p.fillStyle=x.trajectoryColor,p.beginPath(),p.arc(te,G,3.6,0,Math.PI*2),p.fill()}p.restore()}}}function Zv(c){var x,R,A,C;try{for(var N=Ue(Pa()),P=N.next();!P.done;P=N.next()){var X=P.value,k=X.contract==="native.group.v1"?yr(X.id):[X];try{for(var Z=(A=void 0,Ue(k)),V=Z.next();!V.done;V=Z.next()){var $=V.value;if($.contract==="native.stage3d.v1"&&ii($)&&Vt($).skyColor)return Vt($).skyColor;if(!($.contract!=="native.rectangle.v1"||!ii($))){var q=Vt($);if(!(q.opacity<.95||!q.fill||q.fill==="transparent")&&(/(?:^|\.)(background|backdrop|bg)(?:\.fill)?$/.test($.id)||q.width>=c.width*.9&&q.height>=c.height*.9))return q.fill}}}catch(Q){A={error:Q}}finally{try{V&&!V.done&&(C=Z.return)&&C.call(Z)}finally{if(A)throw A.error}}}}catch(Q){x={error:Q}}finally{try{P&&!P.done&&(R=N.return)&&R.call(N)}finally{if(x)throw x.error}}return"#102a34"}function Jv(){var c;if(et&&ii(et.c)){var x=et.c,R=Vt(x);p.save(),p.transform.apply(p,Ke([],De(zn(x)),!1)),p.strokeStyle=(c=et.highlightColor)!==null&&c!==void 0?c:"#ffffff",p.lineWidth=4,p.globalAlpha=.85,p.strokeRect(-4,-4,R.width+8,R.height+8),p.restore()}if(rt?.b.parameters.bringToFront){var x=Le(rt.targetId);x&&Vo(x,x.parentId?zn(Le(x.parentId)):ga(),[],x.prototypeId)}}function ei(){var c,x,R,A,C,N;M=E,E=new Map;var P=O();Y!==void 0&&Y!==P.landscape&&gr(),Y=P.landscape;var X=Math.min(devicePixelRatio||1,2),k=e.clientWidth,Z=e.clientHeight;(e.width!==Math.round(k*X)||e.height!==Math.round(Z*X))&&(e.width=Math.round(k*X),e.height=Math.round(Z*X)),p.setTransform(X,0,0,X,0,0),p.fillStyle=Zv(P),p.fillRect(0,0,k,Z);var V=Math.min(k/P.width,Z/P.height),$=(k-P.width*V)/2,q=(Z-P.height*V)/2;if(Me=V||1,Se=X,p.translate($,q),p.scale(V,V),Ye){var Q=Math.min(1,Ye.elapsed/Ye.seconds),te=Ye.intensity*(1-Q);p.translate(Math.sin(Ye.elapsed*95)*te,Math.cos(Ye.elapsed*113)*te)}p.save(),p.beginPath(),p.rect(0,0,P.width,P.height),p.clip(),ue=[];try{for(var G=Ue(Pa()),ce=G.next();!ce.done;ce=G.next()){var me=ce.value;Vo(me)}}catch(at){c={error:at}}finally{try{ce&&!ce.done&&(x=G.return)&&x.call(G)}finally{if(c)throw c.error}}try{for(var ve=Ue(Te),xe=ve.next();!xe.done;xe=ve.next()){var me=xe.value;me.parentId||Vo(me,ga(),[],me.prototypeId)}}catch(at){R={error:at}}finally{try{xe&&!xe.done&&(A=ve.return)&&A.call(ve)}finally{if(R)throw R.error}}if(Jv(),qv(),f&&w){for(var oe=S.get(w);oe?.parentId;)oe=S.get(oe.parentId);oe?.prototype&&Vo(oe)}Zd(),p.save();try{for(var be=Ue(fe),Ee=be.next();!Ee.done;Ee=be.next()){var Ie=Ee.value;if(!(Ie.shape==="pixel-confetti"||Ie.shape==="confetti")){var Ze=Math.min(1,Ie.life*2),lt=1.5+2.5*Ze;if(p.globalAlpha=Ze,p.globalCompositeOperation=Ie.shape==="square"?"source-over":"lighter",p.fillStyle=Ie.color,Ie.shape==="square"){var Xe=Math.max(2,Math.round(lt*1.6));p.fillRect(Math.round(Ie.x-Xe/2),Math.round(Ie.y-Xe/2),Xe,Xe);continue}p.globalCompositeOperation="lighter",p.shadowColor=Ie.color,p.shadowBlur=fe.length<=16?6:0,p.strokeStyle=Ie.color,p.lineWidth=1.5+Ze,p.beginPath(),p.moveTo(Ie.x-Ie.vx*.025,Ie.y-Ie.vy*.025),p.lineTo(Ie.x,Ie.y),p.stroke(),p.beginPath(),p.arc(Ie.x,Ie.y,lt,0,Math.PI*2),p.fill()}}}catch(at){C={error:at}}finally{try{Ee&&!Ee.done&&(N=be.return)&&N.call(be)}finally{if(C)throw C.error}}if(p.restore(),Yv(),f&&w){var ht=ue.filter(function(at){return at.c.contract!=="native.group.v1"&&(at.c.id===w||Rr(at.c,w))});if(ht.length){var yt=ht.map(function(at){return zi(at.c,at.m)}),Gt=Math.min.apply(Math,Ke([],De(yt.map(function(at){return at.left})),!1)),Ut=Math.min.apply(Math,Ke([],De(yt.map(function(at){return at.top})),!1));p.strokeStyle="#55e6ef",p.lineWidth=2/V,p.strokeRect(Gt,Ut,Math.max.apply(Math,Ke([],De(yt.map(function(at){return at.right})),!1))-Gt,Math.max.apply(Math,Ke([],De(yt.map(function(at){return at.bottom})),!1))-Ut)}}p.restore(),V>0&&Zd(void 0,{x:-$/V,y:-q/V,width:k/V,height:Z/V})}function $v(c){var x,R,A,C,N=Array.isArray(c)?Ke([],De(new Set(c)),!1):void 0;ei();var P=O(),X=new Set,k=[];try{for(var Z=Ue(ue),V=Z.next();!V.done;V=Z.next()){var $=V.value,q=(A=$.c.prototypeId)!==null&&A!==void 0?A:$.c.id;if(!($.c.contract==="native.group.v1"||N&&!N.includes(q))){X.add(q);var Q=zi($.c,$.m),te=((C=Vt($.c).strokeWidth)!==null&&C!==void 0?C:0)/2;Q.left-=te,Q.right+=te,Q.top-=te,Q.bottom+=te;var G={left:Math.max(0,-Q.left),right:Math.max(0,Q.right-P.width),top:Math.max(0,-Q.top),bottom:Math.max(0,Q.bottom-P.height)};Object.values(G).some(function(me){return me>.01})&&k.push({id:q,contract:$.c.contract,bounds:Q,overflow:G})}}}catch(me){x={error:me}}finally{try{V&&!V.done&&(R=Z.return)&&R.call(Z)}finally{if(x)throw x.error}}var ce=N?N.filter(function(me){return!X.has(me)}):[];return{ok:k.length===0&&ce.length===0,viewport:gt(gt({},P),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight}),issues:k,missing:ce}}function Kv(c){var x,R,A,C,N,P,X,k,Z,V,$,q,Q,te,G,ce,me,ve,xe,oe,be,Ee,Ie,Ze,lt,Xe,ht,yt,Gt,Ut,at,Wt,Mt,mt=c===void 0?{}:c,Qe=mt.ids,st=mt.interactiveIds,We=mt.network,tt=We===void 0?"standalone":We,St=mt.minTouchPx,Ct=St===void 0?44:St,Pt=Array.isArray(Qe)?Ke([],De(new Set(Qe)),!1):void 0;ei();var Nt=O(),Yt=Math.min(e.clientWidth/Nt.width,e.clientHeight/Nt.height),Bt=np(Nt,tt),it=[],Ft=new Set,Cn=function(Ce){var Ot;return!Pt||Pt.includes((Ot=Ce.c.prototypeId)!==null&&Ot!==void 0?Ot:Ce.c.id)},bn=ue.filter(Cn),_i=new Set(n.events.filter(function(Ce){return Ce.kind==="click"}).map(function(Ce){return Ce.componentId}));try{for(var ri=Ue(n.gameplay),wn=ri.next();!wn.done;wn=ri.next()){var Rn=wn.value;["drag","match-tile","aim-launch","aim-launch-3d","swipe-input","hold-charge","virtual-joystick","draw-stroke","erase-mask"].includes(Rn.kind)&&_i.add(Rn.componentId)}}catch(Ce){x={error:Ce}}finally{try{wn&&!wn.done&&(R=ri.return)&&R.call(ri)}finally{if(x)throw x.error}}var Hn=new Set(st??_i),si=new Set(n.gameplay.filter(function(Ce){return["aim-launch","aim-launch-3d","swipe-input","hold-charge","draw-stroke","virtual-joystick"].includes(Ce.kind)&&(Ce.parameters.dragMode==="anywhere"||Ce.kind==="draw-stroke"||Ce.kind==="virtual-joystick"&&Ce.parameters.mode==="floating")}).map(function(Ce){return Ce.componentId})),ai=function(Ce){var Ot;return Hn.has((Ot=Ce.c.prototypeId)!==null&&Ot!==void 0?Ot:Ce.c.id)},qn=function(Ce,Ot,qt,_n,Ti,di){return it.push(gt(gt({kind:Ce,severity:Ot,id:qt},di?{otherId:di}:{}),{detail:_n,metrics:Ti}))},Kr=function(Ce){var Ot=[[0,0],[Ce.width,0],[Ce.width,Ce.height],[0,Ce.height]].map(function(qt){var _n=De(qt,2),Ti=_n[0],di=_n[1];return In(Ce.matrix,Ti,di)});return{left:Math.min.apply(Math,Ke([],De(Ot.map(function(qt){return qt.x})),!1)),right:Math.max.apply(Math,Ke([],De(Ot.map(function(qt){return qt.x})),!1)),top:Math.min.apply(Math,Ke([],De(Ot.map(function(qt){return qt.y})),!1)),bottom:Math.max.apply(Math,Ke([],De(Ot.map(function(qt){return qt.y})),!1))}};try{for(var Gr=Ue(bn),Ii=Gr.next();!Ii.done;Ii=Gr.next()){var Pn=Ii.value,Ht=(Ie=Pn.c.prototypeId)!==null&&Ie!==void 0?Ie:Pn.c.id;Ft.add(Ht);var Lt=zi(Pn.c,Pn.m),oi=((Ze=Vt(Pn.c).strokeWidth)!==null&&Ze!==void 0?Ze:0)/2;Lt.left-=oi,Lt.right+=oi,Lt.top-=oi,Lt.bottom+=oi;var $i=Pn.c.contract==="native.group.v1"&&!Vt(Pn.c).clip,_r=Pn.c.contract==="native.image.v1"&&Pn.clips.length===0&&Vt(Pn.c).fit==="cover"&&Lt.left<=0&&Lt.top<=0&&Lt.right>=Nt.width&&Lt.bottom>=Nt.height||Pn.c.contract==="native.stage3d.v1"&&Lt.left<=0&&Lt.top<=0&&Lt.right>=Nt.width&&Lt.bottom>=Nt.height,Hr=Pn.c.contract==="native.rectangle.v1"&&oi===0&&Lt.left<=0&&Lt.top<=0&&Lt.right>=Nt.width&&Lt.bottom>=Nt.height||_r;if(!$i){var Nn={left:Math.max(0,-Lt.left),right:Math.max(0,Lt.right-Nt.width),top:Math.max(0,-Lt.top),bottom:Math.max(0,Lt.bottom-Nt.height)};if(!Hr&&!mp(Pn.c)&&Object.values(Nn).some(function(Ce){return Ce>.01})&&qn("stage-overflow","blocker",Ht,"Component extends beyond the active stage.",{bounds:Lt,overflow:Nn}),Pn.c.contract==="native.image.v1"&&Pn.clips.length===0){var cr=Lt.right-Lt.left,Pr=Lt.bottom-Lt.top,Qa=/(?:^|\.)(backdrop|background|bg)$/.test(Ht)||Vt(Pn.c).fit==="cover"&&!Pn.c.parentId&&Lt.left<=1&&Lt.top<=1&&(cr>=Nt.width*.4||Pr>=Nt.height*.4);Qa&&(Lt.left>.5||Lt.top>.5||Lt.right<Nt.width-.5||Lt.bottom<Nt.height-.5)&&qn("backdrop-incomplete","blocker",Ht,"Backdrop image does not cover the full active stage, leaving a visible seam.",{bounds:Lt,stage:{width:Nt.width,height:Nt.height}})}try{for(var Lr=(N=void 0,Ue(Pn.clips)),ur=Lr.next();!ur.done;ur=Lr.next()){var da=ur.value,dr=Kr(da),fa={left:Math.max(0,dr.left-Lt.left),right:Math.max(0,Lt.right-dr.right),top:Math.max(0,dr.top-Lt.top),bottom:Math.max(0,Lt.bottom-dr.bottom)};Object.values(fa).some(function(Ce){return Ce>.01})&&qn("parent-clip-crop","blocker",Ht,"Component is cropped by an ancestor clipping group.",{bounds:Lt,clip:dr,crop:fa})}}catch(Ce){N={error:Ce}}finally{try{ur&&!ur.done&&(P=Lr.return)&&P.call(Lr)}finally{if(N)throw N.error}}}if(Pn.textMetrics){var Vi=Pn.textMetrics;(Vi.overflowsWidth||Vi.overflowsHeight)&&qn("text-overflow","blocker",Ht,"Text does not fit its component after wrapping and auto-fit.",Vi);var Mi=(lt=Vi.fontSize)!==null&&lt!==void 0?lt:Vi.scale*8;Mi<12&&qn("text-illegible",Mi<8?"blocker":"warning",Ht,"Rendered text is below the recommended legible size.",gt({renderedFontSize:Mi},Vi));var ui=Vt(Pn.c);if(ui.pixelPanel&&ui.align!=="center"){var Da=Math.max(0,ui.width-2*(ui.padding===void 0?8:ui.padding));Da-((Xe=Vi.renderedWidth)!==null&&Xe!==void 0?Xe:0)>12&&qn("panel-off-center","blocker",Ht,"Text inside a framed pixel panel is not horizontally centered.",{align:ui.align,innerWidth:Da,renderedWidth:(ht=Vi.renderedWidth)!==null&&ht!==void 0?ht:0})}}if(ai(Pn)&&!si.has(Ht)&&(Pn.c.contract!=="native.group.v1"||Lt.right>Lt.left&&Lt.bottom>Lt.top)){var Si=(Lt.right-Lt.left)*Yt,Kn=(Lt.bottom-Lt.top)*Yt;(Si<Ct-.01||Kn<Ct-.01)&&qn("touch-target-small","blocker",Ht,"Interactive target is smaller than the required physical touch size.",{width:Si,height:Kn,minTouchPx:Ct,scale:Yt})}if(ai(Pn)&&!si.has(Ht)||Pn.c.contract==="native.text.v1")try{for(var Un=(X=void 0,Ue(Bt.zones)),ha=Un.next();!ha.done;ha=Un.next()){var fr=ha.value,Si=Math.min(Lt.right,fr.right)-Math.max(Lt.left,fr.left),Kn=Math.min(Lt.bottom,fr.bottom)-Math.max(Lt.top,fr.top);Si>.01&&Kn>.01&&qn("sdk-safe-area-collision","blocker",Ht,"Component intersects a reserved ad-SDK overlay zone.",{bounds:Lt,zone:fr,intersection:{width:Si,height:Kn},network:tt})}}catch(Ce){X={error:Ce}}finally{try{ha&&!ha.done&&(k=Un.return)&&k.call(Un)}finally{if(X)throw X.error}}}}catch(Ce){A={error:Ce}}finally{try{Ii&&!Ii.done&&(C=Gr.return)&&C.call(Gr)}finally{if(A)throw A.error}}for(var Mr=bn.filter(function(Ce){return ai(Ce)&&Ce.c.contract!=="native.group.v1"}),On=0;On<Mr.length;On++)for(var xn=On+1;xn<Mr.length;xn++){var Kt=Mr[On],on=Mr[xn],Wr=(yt=Kt.c.prototypeId)!==null&&yt!==void 0?yt:Kt.c.id,Ni=(Gt=on.c.prototypeId)!==null&&Gt!==void 0?Gt:on.c.id;if(!(Wr===Ni||Rr(Kt.c,on.c.id)||Rr(on.c,Kt.c.id))){var Sr=zi(Kt.c,Kt.m),Qr=zi(on.c,on.m),Si=Math.min(Sr.right,Qr.right)-Math.max(Sr.left,Qr.left),Kn=Math.min(Sr.bottom,Qr.bottom)-Math.max(Sr.top,Qr.top);Si>1&&Kn>1&&qn("interactive-overlap","blocker",Wr,"Interactive targets overlap.",{intersection:{width:Si,height:Kn},first:Sr,second:Qr},Ni)}}var pc=function(Ce){if(!Ce||Ce==="transparent")return!1;var Ot=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(Ce);if(Ot)return Ot[1].length===4?Ot[1][3].toLowerCase()==="f":Ot[1].slice(6).toLowerCase()==="ff";var qt=/^rgba\([^,]+,[^,]+,[^,]+,\s*([0-9.]+)\s*\)$/i.exec(Ce);return qt?Number(qt[1])>=.95:!0},ws=[];bn.forEach(function(Ce,Ot){var qt,_n;Ce.c.contract==="native.rectangle.v1"&&!ai(Ce)&&((qt=Vt(Ce.c).opacity)!==null&&qt!==void 0?qt:1)>=.95&&pc(Vt(Ce.c).fill)&&ws.push({rowIndex:Ot,row:Ce,order:(_n=Ce.c.order)!==null&&_n!==void 0?_n:0,bounds:zi(Ce.c,Ce.m)})});var ja=bn.filter(function(Ce,Ot){var qt,_n=zi(Ce.c,Ce.m),Ti=(qt=Ce.c.order)!==null&&qt!==void 0?qt:0;return!ws.some(function(di){return di.rowIndex>Ot&&di.order>Ti&&di.row.c.id!==Ce.c.id&&!Rr(di.row.c,Ce.c.id)&&!Rr(Ce.c,di.row.c.id)&&di.bounds.left<=_n.left+1&&di.bounds.right>=_n.right-1&&di.bounds.top<=_n.top+1&&di.bounds.bottom>=_n.bottom-1})}),Ws=ja.map(function(Ce,Ot){return{row:Ce,rowIndex:Ot}}).filter(function(Ce){var Ot,qt=Ce.row;if(qt.c.contract!=="native.rectangle.v1")return!1;var _n=zi(qt.c,qt.m),Ti=_n.right-_n.left,di=_n.bottom-_n.top,Ua=((Ot=Vt(qt.c).strokeWidth)!==null&&Ot!==void 0?Ot:0)===0&&_n.left<=0&&_n.right>=Nt.width;return!Ua&&Ti>=180&&di>=140&&!ai(qt)}).map(function(Ce){var Ot,qt=Ce.row,_n=Ce.rowIndex;return{id:(Ot=qt.c.prototypeId)!==null&&Ot!==void 0?Ot:qt.c.id,row:qt,rowIndex:_n,bounds:zi(qt.c,qt.m)}}),Wo=function(Ce,Ot,qt,_n){var Ti,di;_n===void 0&&(_n=!1);var Ua=(Ti=Ce.c.prototypeId)!==null&&Ti!==void 0?Ti:Ce.c.id,Qo=(qt.left+qt.right)/2,Fa=(qt.top+qt.bottom)/2,rf=(di=Ce.c.order)!==null&&di!==void 0?di:0;return Ws.filter(function(Qn){var Oa;return Qn.id!==Ua&&(!_n||Qn.rowIndex<Ot||((Oa=Qn.row.c.order)!==null&&Oa!==void 0?Oa:0)===rf)&&qt.right-qt.left<=Qn.bounds.right-Qn.bounds.left+4&&qt.bottom-qt.top<=Qn.bounds.bottom-Qn.bounds.top+4&&Qo>=Qn.bounds.left&&Qo<=Qn.bounds.right&&Fa>=Qn.bounds.top&&Fa<=Qn.bounds.bottom}).sort(function(Qn,Oa){return(Qn.bounds.right-Qn.bounds.left)*(Qn.bounds.bottom-Qn.bounds.top)-(Oa.bounds.right-Oa.bounds.left)*(Oa.bounds.bottom-Oa.bounds.top)||Oa.rowIndex-Qn.rowIndex})[0]},jr=new Map,ea=new Map;if(Ws.length){ja.forEach(function(Ce,Ot){var qt,_n=(qt=Ce.c.prototypeId)!==null&&qt!==void 0?qt:Ce.c.id,Ti=zi(Ce.c,Ce.m),di=(Ti.left+Ti.right)/2,Ua=(Ti.top+Ti.bottom)/2,Qo=Ce.c.contract==="native.button.v1"&&!Dn.has(Ce.c.id),Fa=Ce.c.parentId?Le(Ce.c.parentId):void 0,rf=Ce.c.contract==="native.text.v1"&&Vt(Ce.c).align==="center"&&Fa?.contract!=="native.button.v1";if(Qo||rf){var Qn=Wo(Ce,Ot,Ti,!1);Qn&&(jr.has(Qn.id)||jr.set(Qn.id,{panel:Qn,items:[]}),jr.get(Qn.id).items.push({id:_n,bounds:Ti,cx:di,cy:Ua,isBtn:Qo}))}if(["native.text.v1","native.image.v1","native.button.v1"].includes(Ce.c.contract)&&Fa?.contract!=="native.button.v1"){var Qn=Wo(Ce,Ot,Ti,!0);Qn&&(ea.has(Qn.id)||ea.set(Qn.id,{panel:Qn,content:[]}),ea.get(Qn.id).content.push({row:Ce,id:_n,bounds:Ti}))}});try{for(var Xt=Ue(jr.values()),Wn=Xt.next();!Wn.done;Wn=Xt.next()){var Ui=Wn.value,Zn=Ui.panel,br=Ui.items;if(br.some(function(Ce){return Ce.isBtn})){var Gn=Zn.bounds,Fi=(Gn.left+Gn.right)/2;try{for(var Gi=($=void 0,Ue(br)),Na=Gi.next();!Na.done;Na=Gi.next()){var Ki=Na.value,pa={left:Ki.bounds.left-Gn.left,right:Gn.right-Ki.bounds.right,top:Ki.bounds.top-Gn.top,bottom:Gn.bottom-Ki.bounds.bottom},Xs=Math.min(pa.left,pa.right,pa.top,pa.bottom);(Xs<10||Xs*Yt<8)&&qn("panel-edge-cramped","blocker",Ki.id,"Element sits too close to its enclosing panel edge.",{panelId:Zn.id,margins:pa,scale:Yt,minStagePx:10,minCssPx:8},Zn.id)}}catch(Ce){$={error:Ce}}finally{try{Na&&!Na.done&&(q=Gi.return)&&q.call(Gi)}finally{if($)throw $.error}}var es=[],Xo=function(Ce){var Ot=es.find(function(qt){return Math.abs(qt.cy-Ce.cy)<=16&&qt.isBtn===Ce.isBtn});Ot?Ot.items.push(Ce):es.push({cy:Ce.cy,isBtn:Ce.isBtn,items:[Ce]})};try{for(var mc=(Q=void 0,Ue(br)),Yo=mc.next();!Yo.done;Yo=mc.next()){var Ki=Yo.value;Xo(Ki)}}catch(Ce){Q={error:Ce}}finally{try{Yo&&!Yo.done&&(te=mc.return)&&te.call(mc)}finally{if(Q)throw Q.error}}try{for(var vc=(G=void 0,Ue(es)),qo=vc.next();!qo.done;qo=vc.next()){var tf=qo.value,lg=Math.min.apply(Math,Ke([],De(tf.items.map(function(Ce){return Ce.bounds.left})),!1)),cg=Math.max.apply(Math,Ke([],De(tf.items.map(function(Ce){return Ce.bounds.right})),!1)),wp=(lg+cg)/2,Tp=wp-Fi;Math.abs(Tp)>3&&qn("panel-off-center","blocker",tf.items[0].id,"Element is not horizontally centered inside its enclosing panel.",{panelId:Zn.id,offsetX:Tp,groupCenterX:wp,panelCenterX:Fi,scale:Yt},Zn.id)}}catch(Ce){G={error:Ce}}finally{try{qo&&!qo.done&&(ce=vc.return)&&ce.call(vc)}finally{if(G)throw G.error}}}}}catch(Ce){Z={error:Ce}}finally{try{Wn&&!Wn.done&&(V=Xt.return)&&V.call(Xt)}finally{if(Z)throw Z.error}}try{for(var gc=Ue(ea.values()),Zo=gc.next();!Zo.done;Zo=gc.next())for(var Ep=Zo.value,Zn=Ep.panel,yc=Ep.content,ug=jr.has(Zn.id),On=0;On<yc.length;On++)for(var xn=On+1;xn<yc.length;xn++){var Kt=yc[On],on=yc[xn];if(!(Kt.id===on.id||Rr(Kt.row.c,on.row.c.id)||Rr(on.row.c,Kt.row.c.id))){var dg=Kt.row.c.contract==="native.image.v1"&&on.row.c.contract==="native.image.v1";if(!(dg&&(!ug||Kt.row.c.parentId&&Kt.row.c.parentId===on.row.c.parentId))){var Si=Math.min(Kt.bounds.right,on.bounds.right)-Math.max(Kt.bounds.left,on.bounds.left),Kn=Math.min(Kt.bounds.bottom,on.bounds.bottom)-Math.max(Kt.bounds.top,on.bounds.top);Si>2&&Kn>2&&qn("panel-content-overlap","blocker",Kt.id,"Panel elements overlap each other.",{panelId:Zn.id,intersection:{width:Si,height:Kn},first:Kt.bounds,second:on.bounds},on.id)}}}}catch(Ce){me={error:Ce}}finally{try{Zo&&!Zo.done&&(ve=gc.return)&&ve.call(gc)}finally{if(me)throw me.error}}}var Ys=ja.filter(function(Ce){if(Ce.c.contract!=="native.text.v1")return!1;var Ot=Ce.c.parentId?Le(Ce.c.parentId):void 0;return Ot?.contract!=="native.button.v1"}).map(function(Ce){var Ot,qt,_n=String((Ot=Vt(Ce.c).text)!==null&&Ot!==void 0?Ot:"").replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Ti,di){var Ua;return String((Ua=ne[di])!==null&&Ua!==void 0?Ua:"")}).trim();return{row:Ce,id:(qt=Ce.c.prototypeId)!==null&&qt!==void 0?qt:Ce.c.id,bounds:zi(Ce.c,Ce.m),raw:_n,norm:_n.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}}).filter(function(Ce){return Ce.raw.length>0}),fg=Ws.filter(function(Ce){var Ot,qt;return((Ot=jr.get(Ce.id))===null||Ot===void 0?void 0:Ot.items.some(function(_n){return _n.isBtn}))||((qt=ea.get(Ce.id))===null||qt===void 0?void 0:qt.content.some(function(_n){return _n.row.c.contract==="native.button.v1"}))});try{for(var xc=Ue(fg),Jo=xc.next();!Jo.done;Jo=xc.next()){var Zn=Jo.value,Gn=Zn.bounds,Fi=(Gn.left+Gn.right)/2,hg=Gn.right-Gn.left;try{for(var _c=(be=void 0,Ue(Ys)),$o=_c.next();!$o.done;$o=_c.next()){var ma=$o.value;if(Vt(ma.row.c).align==="center"&&!(ma.bounds.bottom>Gn.top+6||Gn.top-ma.bounds.bottom>48)){var Ap=ma.bounds.right-ma.bounds.left,Ko=(ma.bounds.left+ma.bounds.right)/2,pg=Math.min(ma.bounds.right,Gn.right)-Math.max(ma.bounds.left,Gn.left);(Ko>=Gn.left&&Ko<=Gn.right||pg>=Ap*.6)&&Ap<=hg+60&&Math.abs(Ko-Fi)>4&&qn("header-off-center","blocker",ma.id,"Centered text above a panel is not horizontally aligned with the panel below it.",{panelId:Zn.id,offsetX:Ko-Fi,textCenterX:Ko,panelCenterX:Fi,scale:Yt},Zn.id)}}}catch(_n){be={error:_n}}finally{try{$o&&!$o.done&&(Ee=_c.return)&&Ee.call(_c)}finally{if(be)throw be.error}}}}catch(Ce){xe={error:Ce}}finally{try{Jo&&!Jo.done&&(oe=xc.return)&&oe.call(xc)}finally{if(xe)throw xe.error}}for(var On=0;On<Ys.length;On++)for(var xn=On+1;xn<Ys.length;xn++){var Kt=Ys[On],on=Ys[xn];if(!(Kt.id===on.id||Rr(Kt.row.c,on.row.c.id)||Rr(on.row.c,Kt.row.c.id))){var Si=Math.min(Kt.bounds.right,on.bounds.right)-Math.max(Kt.bounds.left,on.bounds.left),Kn=Math.min(Kt.bounds.bottom,on.bounds.bottom)-Math.max(Kt.bounds.top,on.bounds.top);if(Si>2&&Kn>2&&qn("panel-content-overlap","blocker",Kt.id,"Visible text elements overlap.",{intersection:{width:Si,height:Kn},first:Kt.bounds,second:on.bounds},on.id),Kt.norm&&on.norm){var Ip=De(Kt.norm.length<=on.norm.length?[Kt.norm,on.norm]:[on.norm,Kt.norm],2),Mc=Ip[0],Cp=Ip[1];(Mc===Cp&&Mc.length>=6||Mc.length>=12&&Cp.includes(Mc))&&qn("duplicate-visible-copy","blocker",Kt.id,"Duplicate visible copy appears in multiple text elements simultaneously.",{first:Kt.raw,second:on.raw},on.id)}}}var va=Ys.filter(function(Ce){return!/^[\d\s/.,:%+\-x]+$/i.test(Ce.raw)}),Sc=va.reduce(function(Ce,Ot){return Ce+(Ot.norm?Ot.norm.split(" ").filter(Boolean).length:0)},0),nf=va.reduce(function(Ce,Ot){return Ce+Ot.raw.replace(/\s+/g," ").length},0);Sc>20||nf>130||va.length>5?qn("text-clutter-heavy","blocker",(at=(Ut=va[0])===null||Ut===void 0?void 0:Ut.id)!==null&&at!==void 0?at:null,"Too much visible copy on one screen; keep playable ads visual and concise.",{blocks:va.length,wordCount:Sc,charCount:nf,texts:va.map(function(Ce){return Ce.raw})}):(Sc>12||va.length>4)&&qn("text-clutter-heavy","warning",(Mt=(Wt=va[0])===null||Wt===void 0?void 0:Wt.id)!==null&&Mt!==void 0?Mt:null,"Screen copy is getting dense; consider trimming narration so gameplay carries the experience.",{blocks:va.length,wordCount:Sc,charCount:nf,texts:va.map(function(Ce){return Ce.raw})});var Rp=Pt?Pt.filter(function(Ce){if(Ft.has(Ce))return!1;var Ot=Le(Ce);return Ot?.contract==="native.mesh3d.v1"?!1:!Ot||ii(Ot)}):[];return{ok:!it.some(function(Ce){return Ce.severity==="blocker"})&&Rp.length===0,viewport:gt(gt({},Nt),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight,scale:Yt}),defects:it,missing:Rp,interactive:Mr.map(function(Ce){var Ot;return{id:(Ot=Ce.c.prototypeId)!==null&&Ot!==void 0?Ot:Ce.c.id,bounds:zi(Ce.c,Ce.m)}}),safeArea:Bt}}function Rr(c,x){for(;c.parentId;){if(c.parentId===x)return!0;c=Le(c.parentId)}return!1}function mp(c){for(var x=function(C){if(n.gameplay.some(function(N){var P;return N.kind==="camera-follow"&&N.componentId===((P=C.prototypeId)!==null&&P!==void 0?P:C.id)}))return{value:!0}},R=c;R;R=R.parentId?Le(R.parentId):void 0){var A=x(R);if(typeof A=="object")return A.value}return!1}function fc(c){var x=O(),R=e.getBoundingClientRect(),A=Math.min(R.width/x.width,R.height/x.height);return{x:(c.clientX-R.left-(R.width-x.width*A)/2)/A,y:(c.clientY-R.top-(R.height-x.height*A)/2)/A}}function Qv(c,x){var R,A,C,N;try{try{for(var P=Ue(c.clips),X=P.next();!X.done;X=P.next()){var k=X.value,Z=In(wr(k.matrix),x.x,x.y);if(Z.x<0||Z.y<0||Z.x>k.width||Z.y>k.height)return!1}}catch(oe){R={error:oe}}finally{try{X&&!X.done&&(A=P.return)&&A.call(P)}finally{if(R)throw R.error}}var V=In(wr(c.m),x.x,x.y),$=Vt(c.c);if(c.c.contract==="native.path.v1"){var q=new Path2D,Q=function(oe,be){({M:function(){return q.moveTo.apply(q,Ke([],De(be),!1))},L:function(){return q.lineTo.apply(q,Ke([],De(be),!1))},C:function(){return q.bezierCurveTo.apply(q,Ke([],De(be),!1))},Q:function(){return q.quadraticCurveTo.apply(q,Ke([],De(be),!1))},Z:function(){return q.closePath()}})[oe]()};try{for(var te=Ue($.commands),G=te.next();!G.done;G=te.next()){var ce=De(G.value),me=ce[0],ve=ce.slice(1);Q(me,ve)}}catch(oe){C={error:oe}}finally{try{G&&!G.done&&(N=te.return)&&N.call(te)}finally{if(C)throw C.error}}p.save(),p.setTransform(1,0,0,1,0,0),p.lineWidth=$.strokeWidth;var xe=p.isPointInPath(q,V.x,V.y)||$.strokeWidth>0&&p.isPointInStroke(q,V.x,V.y);return p.restore(),xe}return c.c.contract==="native.ellipse.v1"?Math.pow((V.x-$.width/2)/($.width/2),2)+Math.pow((V.y-$.height/2)/($.height/2),2)<=1:V.x>=0&&V.y>=0&&V.x<=$.width&&V.y<=$.height}catch{return!1}}function Go(c){return Ke([],De(ue),!1).reverse().find(function(x){return x.c.contract!=="native.group.v1"&&x.c.sceneId===J&&Le(x.c.id)&&ii(x.c)&&Qv(x,c)})}function Ho(c){for(var x=[];c;)x.push(c),c=Le(c.parentId);return x}function Jd(){if(!he)return{vx:0,vy:0,power:0,pull:0};var c=he.behavior.parameters,x=he.current.x-he.start.x,R=he.current.y-he.start.y,A=Math.hypot(x,R),C=Math.max(0,Math.min(1,(A-c.minPullPx)/Math.max(1,c.maxPullPx-c.minPullPx))),N=c.minSpeed+(c.maxSpeed-c.minSpeed)*C,P=c.invert?-1:1;return{vx:A?x/A*N*P:0,vy:A?R/A*N*P:0,power:C,pull:A}}function vp(c){if(he){he.current=c;var x=Jd();he.power=x.power,he.behavior.parameters.powerVariableId&&(ne[he.behavior.parameters.powerVariableId]=x.power)}}function $d(c){var x,R;c===void 0&&(c=!1);try{var A=(x=globalThis.AudioContext)!==null&&x!==void 0?x:globalThis.webkitAudioContext;A&&!_t&&(_t=new A,(R=_t.addEventListener)===null||R===void 0||R.call(_t,"statechange",function(){_t?.state==="running"&&Gd()})),Hs(c)}catch{}}function jv(c,x,R){var A,C,N,P,X,k,Z=function(be){var Ee=R.find(function(lt){var Xe;return((Xe=lt.prototypeId)!==null&&Xe!==void 0?Xe:lt.id)===be.componentId});if(!Ee)return"continue";var Ie=In(wr(zn(Ee)),x.x,x.y),Ze=zo(Ee,be);return Ze.stampSegment(Ie,Ie),ft={kind:"mask",pointerId:c.pointerId,c:Ee,behavior:be,last:Ie},(X=e.setPointerCapture)===null||X===void 0||X.call(e,c.pointerId),{value:!0}};try{for(var V=Ue(n.gameplay.filter(function(be){var Ee;return be.kind==="erase-mask"&&((Ee=S.get(be.componentId))===null||Ee===void 0?void 0:Ee.sceneId)===J})),$=V.next();!$.done;$=V.next()){var q=$.value,Q=Z(q);if(typeof Q=="object")return Q.value}}catch(be){A={error:be}}finally{try{$&&!$.done&&(C=V.return)&&C.call(V)}finally{if(A)throw A.error}}if(R.some(function(be){return be.contract==="native.button.v1"||n.events.some(function(Ee){var Ie;return Ee.kind==="click"&&Ee.componentId===((Ie=be.prototypeId)!==null&&Ie!==void 0?Ie:be.id)})}))return!1;try{for(var te=Ue(n.gameplay.filter(function(be){var Ee;return be.kind==="draw-stroke"&&((Ee=S.get(be.componentId))===null||Ee===void 0?void 0:Ee.sceneId)===J})),G=te.next();!G.done;G=te.next()){var q=G.value,ce=S.get(q.componentId),me=wr(zn(ce)),ve=In(me,x.x,x.y),xe=Vt(ce);if(!(ve.x<0||ve.y<0||ve.x>xe.width||ve.y>xe.height)){var oe=Ev(q);return oe.begin(x),ft={kind:"stroke",pointerId:c.pointerId,c:ce,behavior:q,store:oe,last:x},Jt({kind:"strokeStart",componentId:ce.id}),(k=e.setPointerCapture)===null||k===void 0||k.call(e,c.pointerId),!0}}}catch(be){N={error:be}}finally{try{G&&!G.done&&(P=te.return)&&P.call(te)}finally{if(N)throw N.error}}return!1}function eg(c,x,R){var A,C,N,P,X,k,Z,V=R.store.active;if(V){try{for(var $=Ue(n.gameplay.filter(function(Ze){var lt;return Ze.kind==="collider"&&((lt=S.get(Ze.componentId))===null||lt===void 0?void 0:lt.sceneId)===J})),q=$.next();!q.done;q=$.next()){var Q=q.value,te=S.get(Q.componentId);try{for(var G=(N=void 0,Ue(ci(te))),ce=G.next();!ce.done;ce=G.next()){var me=ce.value;!ii(me)||V.hitIds.has(me.id)||Yp(c,x,hp(me,Q.parameters.shape))&&(V.hitIds.add(me.id),Jt(pi("sliceHit",me)))}}catch(Ze){N={error:Ze}}finally{try{ce&&!ce.done&&(P=G.return)&&P.call(G)}finally{if(N)throw N.error}}}}catch(Ze){A={error:Ze}}finally{try{q&&!q.done&&(C=$.return)&&C.call($)}finally{if(A)throw A.error}}try{for(var ve=Ue(tn),xe=ve.next();!xe.done;xe=ve.next()){var oe=xe.value;if(!(oe.broken||!oe.breakable||V.hitIds.has(oe.key))){var be=fn.get(oe.bodyId),Ee=Le(oe.anchorId);if(!(!be||!Ee)){var Ie=xi(Ee);df(c,x,{x:Ie.x,y:Ie.y},{x:be.x,y:be.y})&&(V.hitIds.add(oe.key),oe.broken=!0,D.add(oe.key),Jt({kind:"jointBreak",behaviorId:oe.id,componentId:oe.componentId,selfInstanceId:oe.bodyId,instanceId:(Z=Le(oe.bodyId))===null||Z===void 0?void 0:Z.instanceId}))}}}}catch(Ze){X={error:Ze}}finally{try{xe&&!xe.done&&(k=ve.return)&&k.call(ve)}finally{if(X)throw X.error}}}}function tg(c,x){var R,A=x.last,C=x.behavior.parameters;if(C.inkVariableId){var N=C.inkVariableId,P=Math.hypot(c.x-A.x,c.y-A.y);if(((R=ne[N])!==null&&R!==void 0?R:0)<P)return;ne[N]-=P}x.store.add(c)&&(C.mode==="slice-blade"&&eg(A,c,x),x.last=c)}function ng(c){var x,R;if(!(!ft||ft.pointerId!==c.pointerId)){var A=ft;ft=void 0;try{!((x=e.hasPointerCapture)===null||x===void 0)&&x.call(e,c.pointerId)&&((R=e.releasePointerCapture)===null||R===void 0||R.call(e,c.pointerId))}catch{}if(A.kind==="stroke"){var C=A.store.end(),N=A.behavior.parameters;if(C){if(N.mode==="physics-wall"){var P=new Set(A.store.strokes.map(function(k){return k.id}));Dt=Dt.filter(function(k){return k.owner!==A.c.id||P.has(k.strokeId)}),Dt.push.apply(Dt,Ke([],De(Zp(C,N.strokeWidth).map(function(k){return gt(gt({},k),{owner:A.c.id})})),!1))}else if(N.mode==="path-trace"){var X=Le(N.followComponentId);X&&C.points.length>1&&Vr.set(X.id,{points:C.points,index:1,speed:N.followSpeed})}}Jt({kind:"strokeEnd",componentId:A.c.id})}}}function ig(c){var x,R,A,C;try{for(var N=Ue(sr.values()),P=N.next();!P.done;P=N.next()){var X=P.value;X.tick(c)}}catch(oe){x={error:oe}}finally{try{P&&!P.done&&(R=N.return)&&R.call(N)}finally{if(x)throw x.error}}try{for(var k=Ue(Vr),Z=k.next();!Z.done;Z=k.next()){var V=De(Z.value,2),$=V[0],q=V[1],Q=Le($);if(!Q){Vr.delete($);continue}var te=q.points[q.index];if(!te){Vr.delete($),Jt(pi("pathArrive",Q));continue}var G=xi(Q),ce=te.x-G.x,me=te.y-G.y,ve=Math.hypot(ce,me),xe=q.speed*c;ve<=xe?(ua(Q,te.x,te.y),q.index++):ve>.001&&ua(Q,G.x+ce/ve*xe,G.y+me/ve*xe)}}catch(oe){A={error:oe}}finally{try{Z&&!Z.done&&(C=k.return)&&C.call(k)}finally{if(A)throw A.error}}}function rg(c,x,R){var A,C,N=[],P=[],X=function($){var q=S.get($.componentId),Q=$.parameters.dragMode==="anywhere"?ci(q).find(function(ce){return ii(ce)}):R.find(function(ce){var me;return((me=ce.prototypeId)!==null&&me!==void 0?me:ce.id)===q.id});if(!Q)return"continue";if($.kind==="swipe-input")P.push({behavior:$,c:Q});else{var te=$.parameters,G=Math.max(te.min,Math.min(te.max,Number(ne[te.variableId])));ne[te.variableId]=G,N.push({behavior:$,c:Q,charge:Op(te,G)}),Jt(pi("holdStart",Q))}};try{for(var k=Ue(n.gameplay.filter(function($){var q;return["swipe-input","hold-charge"].includes($.kind)&&((q=S.get($.componentId))===null||q===void 0?void 0:q.sceneId)===J})),Z=k.next();!Z.done;Z=k.next()){var V=Z.value;X(V)}}catch($){A={error:$}}finally{try{Z&&!Z.done&&(C=k.return)&&C.call(k)}finally{if(A)throw A.error}}(N.length||P.length)&&(ke={pointerId:c.pointerId,start:x,current:x,holds:N,swipes:P})}function ag(c,x){var R,A,C,N,P,X,k,Z;if(!(!ke||ke.pointerId!==c.pointerId)){var V=ke,$=new Set;ke=void 0;try{for(var q=Ue(Ke(Ke([],De(V.holds),!1),De(V.swipes),!1)),Q=q.next();!Q.done;Q=q.next()){var te=Q.value,G=te.behavior,ce=te.c;$.has(G.componentId)||($.add(G.componentId),Jt(pi("pointerUp",ce,void 0,{targetId:ce.id,pointerId:c.pointerId})))}}catch(Xe){R={error:Xe}}finally{try{Q&&!Q.done&&(A=q.return)&&A.call(q)}finally{if(R)throw R.error}}try{for(var me=Ue(V.holds),ve=me.next();!ve.done;ve=me.next()){var xe=ve.value,oe=xe.behavior.parameters;if(Jt(pi("holdRelease",xe.c)),oe.resetOnRelease!==!1){var be=ne[oe.variableId];ne[oe.variableId]=oe.min,be!==oe.min&&Jt({kind:"variableChange",variableId:oe.variableId,selfInstanceId:(k=xe.c.instanceId)!==null&&k!==void 0?k:xe.c.id,instanceId:xe.c.instanceId})}}}catch(Xe){C={error:Xe}}finally{try{ve&&!ve.done&&(N=me.return)&&N.call(me)}finally{if(C)throw C.error}}try{for(var Ee=Ue(V.swipes),Ie=Ee.next();!Ie.done;Ie=Ee.next()){var Ze=Ie.value,lt=Fp(V.start,x,Ze.behavior.parameters.minDistancePx,(Z=Za.get(Ze.behavior.id))!==null&&Z!==void 0?Z:-1/0,_e*1e3,Ze.behavior.parameters.cooldownMs);lt&&(Za.set(Ze.behavior.id,_e*1e3),Jt(pi("swipe",Ze.c,void 0,{direction:lt})))}}catch(Xe){P={error:Xe}}finally{try{Ie&&!Ie.done&&(X=Ee.return)&&X.call(Ee)}finally{if(P)throw P.error}}return $}}function sg(c,x,R){var A,C,N;if(R.some(function(G){return G.contract==="native.button.v1"&&Vt(G).enabled}))return!1;try{for(var P=Ue(n.gameplay.filter(function(G){var ce;return G.kind==="virtual-joystick"&&((ce=S.get(G.componentId))===null||ce===void 0?void 0:ce.sceneId)===J})),X=P.next();!X.done;X=P.next()){var k=X.value,Z=S.get(k.componentId);if(ii(Z)){var V=le.get(k.id);if(!(V&&V.pointerId!==null)){var $=In(wr(zn(Z)),x.x,x.y),q=Vt(Z);if(!($.x<0||$.y<0||$.x>q.width||$.y>q.height)){var Q=k.parameters.mode==="floating"?gt({},x):xi(Z),te=cf(Q,x,k.parameters.radiusPx,k.parameters.deadZone);return V=gt({behavior:k,c:Z,pointerId:c.pointerId,origin:Q,current:x},te),le.set(k.id,V),vr(V),Jt(pi("joystickStart",Z)),(N=e.setPointerCapture)===null||N===void 0||N.call(e,c.pointerId),!0}}}}}catch(G){A={error:G}}finally{try{X&&!X.done&&(C=P.return)&&C.call(P)}finally{if(A)throw A.error}}return!1}var gp=function(c){var x,R,A,C,N,P,X,k,Z,V,$,q,Q;H();var te=fc(c),G=Go(te);if(Je=te,!(!G&&f)){if(f){G&&(w=G.c.id,T((N=G.c.prototypeId)!==null&&N!==void 0?N:G.c.id));return}var ce=n.gameplay.some(function(Bt){return Bt.kind==="virtual-joystick"||Bt.kind==="fps-controller-3d"});if(!(!c.isTrusted||c.button!==void 0&&c.button!==0||!ce&&c.isPrimary===!1||ct||ot||!ce&&(rt&&rt.pointerId!==c.pointerId||ke&&ke.pointerId!==c.pointerId||he&&he.pointerId!==c.pointerId||It&&It.pointerId!==c.pointerId)||_&&(!Ve||!qe))){var me=!je;Re=_e,Ae=!0,je=!0,$d(!0),me&&!wt&&(Tt=Zt=0,xr());var ve=G?Ho(G.c):[];if(sg(c,te,ve)){Tt=Zt=0,wt=!1,xr(),ei();return}if(jv(c,te,ve)){xr(),ei();return}rg(c,te,ve);var xe=jt&&!ve.some(function(Bt){return Bt.contract==="native.button.v1"})?n.gameplay.find(function(Bt){var it;return Bt.kind==="aim-launch-3d"&&((it=S.get(Bt.componentId))===null||it===void 0?void 0:it.sceneId)===J}):void 0;if(xe){var oe=S.get(xe.componentId),be=An("physics-3d",oe.id),Ee=be?oc(oe,be):void 0,Ie=Vd(oe.id),Ze=xe.parameters.dragMode==="anywhere"||Ie&&Math.hypot(te.x-Ie.x,te.y-Ie.y)<=xe.parameters.hitRadiusPx;if(Ee&&Ee.atRest&&!Ee.captured&&Ze){It={behavior:xe,targetId:oe.id,sourceId:oe.id,stageId:xe.parameters.stageId,pointerId:c.pointerId,start:te,current:te,power:0},cp(te),(P=e.setPointerCapture)===null||P===void 0||P.call(e,c.pointerId);return}}var lt=ve.some(function(Bt){return Bt.contract==="native.button.v1"&&Vt(Bt).enabled||n.events.some(function(it){var Ft;return it.kind==="click"&&it.componentId===((Ft=Bt.prototypeId)!==null&&Ft!==void 0?Ft:Bt.id)})});if(jt&&!Qt&&!lt){var Xe=n.gameplay.find(function(Bt){var it;return Bt.kind==="fps-controller-3d"&&Bt.parameters.lookMode!=="none"&&((it=S.get(Bt.componentId))===null||it===void 0?void 0:it.sceneId)===J});if(Xe){var ht=S.get(Xe.componentId),yt=In(wr(zn(ht)),te.x,te.y),Gt=Vt(ht);if(yt.x>=0&&yt.y>=0&&yt.x<=Gt.width&&yt.y<=Gt.height){cc(Xe),Qt={pointerId:c.pointerId,stageId:ht.id,behavior:Xe,last:te},(X=e.setPointerCapture)===null||X===void 0||X.call(e,c.pointerId);return}}}var Ut=n.gameplay.find(function(Bt){return Bt.kind==="aim-launch"&&S.get(Bt.componentId).sceneId===J&&(Bt.parameters.dragMode==="anywhere"&&!ve.some(function(it){return it.contract==="native.button.v1"})||ve.some(function(it){var Ft;return((Ft=it.prototypeId)!==null&&Ft!==void 0?Ft:it.id)===Bt.componentId}))});if(Ut){var at=S.get(Ut.componentId),Wt=(k=ve.find(function(it){var Ft;return((Ft=it.prototypeId)!==null&&Ft!==void 0?Ft:it.id)===at.id}))!==null&&k!==void 0?k:ci(at).find(function(it){return ii(it)}),Ee=Wt&&$a(Wt,An("physics-body",at.id));if(Ee&&(!Ut.parameters.onlyWhenAtRest||Ee.atRest)){he={behavior:Ut,targetId:Wt.id,sourceId:at.id,pointerId:c.pointerId,start:te,current:te,power:0},vp(te),(Z=e.setPointerCapture)===null||Z===void 0||Z.call(e,c.pointerId),ei();return}}try{for(var Mt=Ue(ve),mt=Mt.next();!mt.done;mt=Mt.next()){var Qe=mt.value,st=An("press-feedback",(V=Qe.prototypeId)!==null&&V!==void 0?V:Qe.id);st&&(Qe.contract!=="native.button.v1"||Vt(Qe).enabled)&&Fn.set(Qe.id,{behavior:st.parameters,pointerId:c.pointerId,held:!0})}}catch(Bt){x={error:Bt}}finally{try{mt&&!mt.done&&(R=Mt.return)&&R.call(Mt)}finally{if(x)throw x.error}}var We=ve.find(function(Bt){var it;return((it=Dn.get(Bt.id))===null||it===void 0?void 0:it.sceneId)===J});if(We){var tt=xt.get(We.parentId);if(tt?.snapshot().busy)return;Fv(We),tt&&!tt.snapshot().busy&&(En={pointerId:c.pointerId,boardId:We.parentId,tileId:We.id,start:te},($=e.setPointerCapture)===null||$===void 0||$.call(e,c.pointerId))}se=(q=ve.find(function(Bt){return Bt.contract==="native.button.v1"&&Vt(Bt).enabled}))===null||q===void 0?void 0:q.id,mn=se?c.pointerId:void 0;var St=n.gameplay.find(function(Bt){return Bt.kind==="drag"&&ve.some(function(it){var Ft;return((Ft=it.prototypeId)!==null&&Ft!==void 0?Ft:it.id)===Bt.componentId})});if(St){var Qe=ve.find(function(it){var Ft;return((Ft=it.prototypeId)!==null&&Ft!==void 0?Ft:it.id)===St.componentId}),Ct=xi(Qe),Pt=Bn.zoneOf(Qe.id);la.set(Qe.id,Ct),Bn.release(Qe.id),rt={b:St,targetId:Qe.id,start:te,current:te,origin:Ct,originZone:Pt,m:Ke([],De(Di(Qe)),!1),pointerId:c.pointerId},Jt(pi("dragStart",Qe)),e.setPointerCapture(c.pointerId)}Tt=Zt=0,wt=!1;try{for(var Nt=Ue(ve),Yt=Nt.next();!Yt.done;Yt=Nt.next()){var Qe=Yt.value;(Qe.contract!=="native.button.v1"||Vt(Qe).enabled)&&Jt({kind:"click",componentId:(Q=Qe.prototypeId)!==null&&Q!==void 0?Q:Qe.id,instanceId:Qe.instanceId,targetId:Qe.id,pointerId:c.pointerId})}}catch(Bt){A={error:Bt}}finally{try{Yt&&!Yt.done&&(C=Nt.return)&&C.call(Nt)}finally{if(A)throw A.error}}xr(),ei()}}};function yp(c,x){if(!En||En.pointerId!==c.pointerId)return!1;if(!c.isTrusted||!lr())return!0;var R=En,A=xt.get(R.boardId);if(A.snapshot().busy)return En=void 0,!0;var C=wr(zn(S.get(R.boardId))),N=In(C,R.start.x,R.start.y),P=In(C,x.x,x.y),X=P.x-N.x,k=P.y-N.y,Z=S.get(R.tileId);if(Math.max(Math.abs(X),Math.abs(k))<Math.min(Z.parameters.width,Z.parameters.height)*.35)return!0;var V=Dn.get(Z.id),$=Math.abs(X)>Math.abs(k),q=V.row+($?0:Math.sign(k)),Q=V.column+($?Math.sign(X):0),te=Ke([],De(Dn),!1).find(function(G){var ce=De(G,2),me=ce[1];return me.boardId===R.boardId&&me.row===q&&me.column===Q});return te&&A.swap(Z.id,te[0])&&(yn=void 0,ei()),En=void 0,!0}var xp=function(c){var x,R,A,C;if(!ct){H();var N=O(),P=fc(c);Je=P,ke?.pointerId===c.pointerId&&(ke.current=P);var X=function(Mt){var mt,Qe;if(Mt.pointerId===c.pointerId){var st=P.x-Mt.current.x,We=P.y-Mt.current.y;if(c.isTrusted&&lr())try{for(var tt=(mt=void 0,Ue(n.gameplay.filter(function(Pt){var Nt,Yt;return Pt.kind==="fps-controller-3d"&&Pt.parameters.aimJoystickBehaviorId===Mt.behavior.id&&((Nt=Pt.parameters.aimMode)!==null&&Nt!==void 0?Nt:"delta")==="delta"&&((Yt=S.get(Pt.componentId))===null||Yt===void 0?void 0:Yt.sceneId)===J}))),St=tt.next();!St.done;St=tt.next()){var Ct=St.value;op(Ct,st,We)}}catch(Pt){mt={error:Pt}}finally{try{St&&!St.done&&(Qe=tt.return)&&Qe.call(tt)}finally{if(mt)throw mt.error}}return Object.assign(Mt,{current:P},cf(Mt.origin,P,Mt.behavior.parameters.radiusPx,Mt.behavior.parameters.deadZone)),vr(Mt),ei(),{value:void 0}}};try{for(var k=Ue(le.values()),Z=k.next();!Z.done;Z=k.next()){var V=Z.value,$=X(V);if(typeof $=="object")return $.value}}catch(Mt){x={error:Mt}}finally{try{Z&&!Z.done&&(R=k.return)&&R.call(k)}finally{if(x)throw x.error}}if(ft?.pointerId===c.pointerId){if(ft.kind==="mask"){var q=ft,Q=In(wr(zn(q.c)),P.x,P.y);zo(q.c,q.behavior).stampSegment(q.last,Q),q.last=Q}else tg(P,ft);xr(),ei();return}if(Qt?.pointerId===c.pointerId){c.isTrusted&&lr()&&(op(Qt.behavior,P.x-Qt.last.x,P.y-Qt.last.y),Qt.last=P,ei());return}if(It?.pointerId===c.pointerId){c.isTrusted&&lr()&&cp(P);return}if(he?.pointerId===c.pointerId){c.isTrusted&&lr()&&vp(P),ei();return}var te=Go(P);if(an=te?(A=Ho(te.c).find(function(Mt){return Mt.contract==="native.button.v1"}))===null||A===void 0?void 0:A.id:void 0,!yp(c,P)&&!(!rt||rt.pointerId!==c.pointerId)){var G=Le(rt.targetId);if(!G){Yn();return}var ce=G.parentId?zn(Le(G.parentId)):ga(),me=wr(ce),ve=In(me,rt.start.x,rt.start.y),xe=In(me,P.x,P.y),oe=Ke([],De(rt.m),!1),be=rt.b.parameters.axis;if(be!=="y"){var Ee=rt.m[4]+xe.x-ve.x;Number.isFinite(rt.b.parameters.minX)&&(Ee=Math.max(rt.b.parameters.minX,Ee)),Number.isFinite(rt.b.parameters.maxX)&&(Ee=Math.min(rt.b.parameters.maxX,Ee)),oe[4]=Ee}if(be!=="x"){var Ie=rt.m[5]+xe.y-ve.y;Number.isFinite(rt.b.parameters.minY)&&(Ie=Math.max(rt.b.parameters.minY,Ie)),Number.isFinite(rt.b.parameters.maxY)&&(Ie=Math.min(rt.b.parameters.maxY,Ie)),oe[5]=Ie}if(!G.parentId)be!=="y"&&(oe[4]=Math.max(0,Math.min(N.width-G.parameters.width,oe[4])));else{var Ze=zi(G,qs(ce,oe)),lt=0;Ze.left<0||Ze.right-Ze.left>N.width?lt=-Ze.left:Ze.right>N.width&&(lt=N.width-Ze.right);var Xe=be==="y"?0:ce[0],ht=be==="x"?0:ce[2];Math.abs(Xe)>=Math.abs(ht)&&Math.abs(Xe)>1e-8?oe[4]+=lt/Xe:Math.abs(ht)>1e-8&&(oe[5]+=lt/ht)}var yt=(C=He.get(G.id))!==null&&C!==void 0?C:{parameters:{}};He.set(G.id,gt(gt({},yt),{transform:oe})),rt.current=P;var Gt=Wd(G),Ut=Gt.zones,at=Gt.tag,Wt=wc({itemId:G.id,tag:at,zones:Ut,occupancy:Bn});et=Wt&&Wt.kind!=="reject"?Wt.zone:void 0}}},_p=function(c){var x,R,A,C,N;H();var P=fc(c),X=ye;Je=P,Mn(c.pointerId,!0),Li(c.pointerId),ng(c);var k=(A=ag(c,P))!==null&&A!==void 0?A:new Set;if(Ov(c),c.isTrusted&&lr()){var Z=Go(P);try{for(var V=Ue(Z?Ho(Z.c):[]),$=V.next();!$.done;$=V.next()){var q=$.value;!k.has((C=q.prototypeId)!==null&&C!==void 0?C:q.id)&&(q.contract!=="native.button.v1"||Vt(q).enabled)&&Jt(pi("pointerUp",q,void 0,{targetId:q.id,pointerId:c.pointerId}))}}catch(ve){x={error:ve}}finally{try{$&&!$.done&&(R=V.return)&&R.call(V)}finally{if(x)throw x.error}}}if(xr(),ei(),It?.pointerId===c.pointerId){var Q=It,te=lp(),G=$t.get(Q.targetId);(N=jt?.getStage(S.get(Q.stageId)))===null||N===void 0||N.setGuide([]),It=void 0,Q.behavior.parameters.powerVariableId&&(ne[Q.behavior.parameters.powerVariableId]=0);var ce=Math.hypot(te.vx,te.vz);c.isTrusted&&$d(!0),G&&c.isTrusted&&lr()&&te.pull>=Q.behavior.parameters.minPullPx&&ce>=Q.behavior.parameters.minSpeed&&(G.vx=te.vx,G.vy=0,G.vz=te.vz,G.atRest=!1,G.restElapsed=0,G.movingTime=0,G.captured=!1,G.lastSafe={x:G.x,y:G.y,z:G.z},Jt({kind:"launch",componentId:Q.sourceId})),Zi(c),xr();return}if(he?.pointerId===c.pointerId){var Q=he,te=Jd(),G=fn.get(Q.targetId);he=void 0,Q.behavior.parameters.powerVariableId&&(ne[Q.behavior.parameters.powerVariableId]=0),G&&c.isTrusted&&lr()&&te.pull>=Q.behavior.parameters.minPullPx&&(G.vx=te.vx,G.vy=te.vy,G.atRest=!1,G.restElapsed=0,G.captured=!1,G.exited=!1,Jt({kind:"launch",componentId:Q.sourceId,instanceId:G.instanceId})),Zi(c),xr(),ei();return}if(yp(c,P),En?.pointerId===c.pointerId&&(En=void 0),Zi(c),!(F||X?.pointerId!==c.pointerId||!c.isTrusted||!lr()||navigator.userActivation&&navigator.userActivation.isActive!==!0||!Ja(X.condition))){var me=Go(P);!me||!Ho(me.c).some(function(ve){return ve.id===X.targetId&&(ve.contract!=="native.button.v1"||Vt(ve).enabled)})||(_?_.openStore(n.base.storeUrl):window.open(n.base.storeUrl,"_blank","noopener"))}},hc=function(c){var x,R;if(It?.pointerId===c.pointerId&&or(c.pointerId),Qt?.pointerId===c.pointerId&&Li(c.pointerId),Mn(c.pointerId,!0),he?.pointerId===c.pointerId&&(he.behavior.parameters.powerVariableId&&(ne[he.behavior.parameters.powerVariableId]=0),he=void 0),En?.pointerId===c.pointerId&&(En=void 0),ft?.pointerId===c.pointerId&&(ft.kind==="stroke"&&ft.store.cancel(),ft=void 0),ke?.pointerId===c.pointerId){try{for(var A=Ue(ke.holds),C=A.next();!C.done;C=A.next()){var N=C.value;N.behavior.parameters.resetOnRelease!==!1&&(ne[N.behavior.parameters.variableId]=N.behavior.parameters.min)}}catch(P){x={error:P}}finally{try{C&&!C.done&&(R=A.return)&&R.call(A)}finally{if(x)throw x.error}}ke=void 0}Zi(c)},Mp=function(c){c?.isTrusted&&!f&&!ct&&!ot&&$d(!0)},Kd=function(){pt||ei()},Ka=typeof globalThis.ResizeObserver=="function"?new globalThis.ResizeObserver(Kd):void 0;try{(s=Ka?.observe)===null||s===void 0||s.call(Ka,e)}catch{}var Sp=function(){ut=0,zt=0,document.hidden&&gr(),_t&&(document.hidden?_t.suspend().catch(function(){}):!ct&&je&&Hs())};document.addEventListener("visibilitychange",Sp),(o=globalThis.addEventListener)===null||o===void 0||o.call(globalThis,"resize",Kd),e.addEventListener("pointerdown",gp),e.addEventListener("pointermove",xp),e.addEventListener("pointerup",_p),e.addEventListener("pointercancel",hc),e.addEventListener("lostpointercapture",hc),e.addEventListener("click",Mp);var Qd=_?.onVisibilityChanged(function(c){qe=c,ut=0,zt=0,c||gr(),_t&&(c?!ct&&je&&Hs():_t.suspend().catch(function(){}))}),jd=_?.onClosed(function(){ot=!0,ut=0,zt=0,gr(),pn()}),ef=(u=_?.onVolumeChanged)===null||u===void 0?void 0:u.call(_,function(c){typeof c=="number"&&Number.isFinite(c)&&c>=0&&(Yi=Math.min(1,c>1?c/100:c),Hd())}),Ji,La;function bp(c){var x=!f&&!ct&&!document.hidden&&Ve&&qe&&!ot;if(x&&zt&&(Ge+=Math.min((c-zt)/1e3,5/60)),lr()){Tt=Zt=0,wt=!1,zt&&(ut+=Math.min((c-zt)/1e3,5/60));for(var R=0;R<5&&ut>=1/60;R++)La?.(),pp(1/60),ut-=1/60;xr(),Ji?.()&&(ct=!0,Ji=void 0,La=void 0)}else ut=0;zt=c,ei(),nn=requestAnimationFrame(bp)}uc(),f&&(J=v),ei(),nn=requestAnimationFrame(bp),_&&_.init().then(function(){pt||(Ve=!0,qe=_.isVisible(),ut=0,zt=0)}).catch(function(){pt||(ot=!0,gr(),pn())});var og=F?{freezeReview:function(){ct=!0,Ji=void 0,La=void 0,ut=0,zt=0,yi(),Yn(),En=void 0,_t?.suspend().catch(function(){}),ei()},seekReview:function(c,x){var R,A,C,N,P=x===void 0?{}:x,X=P.motion,k=X===void 0?!1:X,Z=P.trustedEvent;ct=!0,Ji=void 0,La=void 0,uc();var V=xt.get("harvest.board"),$=k&&Z instanceof globalThis.Event&&Z.isTrusted,q=function(){var We=_t;_t=void 0;try{Tt=Zt=0,wt=!1,pp(1/60),xr()}finally{_t=We}},Q=function(){var We;if($)try{var tt=(We=globalThis.AudioContext)!==null&&We!==void 0?We:globalThis.webkitAudioContext;tt&&(_t??(_t=new tt)),Hs()}catch{}ut=0,zt=0,ct=!1,ei()};if(S.has("salvage.ship")&&Object.hasOwn(ne,"salvage.phase")){if(!["opening","first-catch","end-card","timeout"].includes(c))throw Error("Review moment unavailable");var te=S.get("salvage.ship"),G=function(We){var tt,St=Te.filter(function(Nt){return Nt.prototypeId.startsWith("salvage.core")}).sort(function(Nt,Yt){return Yt.transform[5]-Nt.transform[5]})[0],Ct=He.get(te.id),Pt=Ke([],De((tt=Ct?.transform)!==null&&tt!==void 0?tt:te.transform),!1);Pt[4]=We&&St?Math.max(20,Math.min(306,St.transform[4]-8)):20,He.set(te.id,gt(gt({},Ct),{transform:Pt,parameters:gt(gt({},Ct?.parameters),{visible:We})}))},ce,me,ve=function(){return ne["salvage.phase"]!=="cta"?!1:(ce??(ce=_e),_e-ce>=.65)};if(c==="opening"){if(k){Ji=function(){return _e>=4},Q();return}ei();return}if(c==="timeout"){var xe=(R=n.gameplay.find(function(We){return We.id==="salvage.deadline"}))===null||R===void 0?void 0:R.parameters.seconds;if(!Number.isFinite(xe))throw Error("Timeout replay unavailable");if(G(!1),k){for(;_e<xe-.25&&ne["salvage.phase"]!=="cta";)G(!1),q();if(ne["salvage.phase"]==="cta")throw Error("Timeout replay unavailable");La=function(){ne["salvage.phase"]!=="cta"&&G(!1)},Ji=function(){return ve()||_e>=xe+1},Q();return}for(var oe=0;ne["salvage.phase"]!=="cta"&&oe<3600;oe++)G(!1),q();if(ne["salvage.phase"]!=="cta")throw Error("Timeout card unavailable");ei();return}var be=c==="first-catch"?1:3;if(k){for(var oe=0;ne["salvage.catches"]<be-1&&oe<3600;oe++)G(!0),q();if(ne["salvage.catches"]!==be-1)throw Error("Review replay unavailable");La=function(){ne["salvage.catches"]<be&&G(!0)},Ji=function(){return be===1&&ne["salvage.catches"]>=1?(me??(me=_e),_e-me>=1):be===3&&ve()||_e>=20},Q();return}for(var oe=0;ne["salvage.catches"]<be&&oe<3600;oe++)G(!0),q();if(ne["salvage.catches"]!==be)throw Error("Review catch unavailable");if(be===1)for(var oe=0;oe<84;oe++)q();else{for(var oe=0;ne["salvage.phase"]!=="cta"&&oe<300;oe++)q();if(ne["salvage.phase"]!=="cta")throw Error("End card unavailable")}ei();return}if(!V){if(!["opening","first-input","end-card","timeout"].includes(c))throw Error("Review moment unavailable");if(c==="opening"){k?(Ji=function(){return _e>=4},Q()):ei();return}var Ee=n.gameplay.find(function(We){return We.kind==="aim-launch"&&S.get(We.componentId).sceneId===J}),Ie=n.gameplay.find(function(We){return We.kind==="aim-launch-3d"&&S.get(We.componentId).sceneId===J}),Ze=n.events.find(function(We){var tt;return We.kind==="click"&&((tt=S.get(We.componentId))===null||tt===void 0?void 0:tt.sceneId)===J&&n.eventBindings.some(function(St){return St.eventId===We.id})}),lt=function(){var We,tt;if(Ie){var St=S.get(Ie.componentId),Ct=An("physics-3d",St.id),Pt=oc(St,Ct),Nt=n.gameplay.find(function(ai){return ai.kind==="capture-zone-3d"&&S.get(ai.componentId).sceneId===J}),Yt=0,Bt=-Ie.parameters.maxSpeed*.45;if(Nt){var it=S.get(Nt.componentId),Ft=Vt(it),Cn=((We=Ft.x)!==null&&We!==void 0?We:0)-Pt.x,bn=((tt=Ft.z)!==null&&tt!==void 0?tt:0)-Pt.z,_i=Math.hypot(Cn,bn)||1;Yt=Cn/_i*Ie.parameters.maxSpeed*.55,Bt=bn/_i*Ie.parameters.maxSpeed*.55}Pt.vx=Yt,Pt.vy=0,Pt.vz=Bt,Pt.atRest=!1,Pt.restElapsed=0,Pt.movingTime=0,Pt.lastSafe={x:Pt.x,y:Pt.y,z:Pt.z},Jt({kind:"launch",componentId:St.id}),xr();return}if(Ee){var St=S.get(Ee.componentId),ri=ci(St)[0],Pt=$a(ri,An("physics-body",St.id)),Nt=n.gameplay.find(function(Ii){return Ii.kind==="capture-zone"&&S.get(Ii.componentId).sceneId===J}),Yt=Ee.parameters.maxSpeed*.45,wn=0;if(Nt){var it=S.get(Nt.componentId),Rn=In(zn(it),Vt(it).width/2,Vt(it).height/2),Cn=Rn.x-Pt.x,Hn=Rn.y-Pt.y,si=Math.hypot(Cn,Hn)||1;Yt=Cn/si*Ee.parameters.maxSpeed*.45,wn=Hn/si*Ee.parameters.maxSpeed*.45}Pt.vx=Yt,Pt.vy=wn,Pt.atRest=!1,Pt.restElapsed=0,Jt({kind:"launch",componentId:St.id,instanceId:ri.instanceId})}else if(Ze)Jt({kind:"click",componentId:Ze.componentId,targetId:Ze.componentId});else throw Error("Review primary input unavailable");xr()};if(c==="first-input"){if(lt(),k)Ji=function(){return _e>=2},Q();else{for(var oe=0;oe<60;oe++)q();ei()}return}c==="end-card"&&lt();var Xe=c==="timeout"?Math.min(60,Math.max(1,(C=(A=n.gameplay.find(function(We){return We.kind==="timer"}))===null||A===void 0?void 0:A.parameters.seconds)!==null&&C!==void 0?C:10)):60,ht=function(){var We;return((We=n.scenes.find(function(tt){return tt.id===J}))===null||We===void 0?void 0:We.role)==="end-card"},yt=function(){var We,tt;return c==="timeout"?(We=n.scenes.find(function(St){return St.role==="end-card"&&/fail|loss|timeout/i.test(St.id)}))!==null&&We!==void 0?We:n.scenes.find(function(St){return St.role==="end-card"}):(tt=n.scenes.find(function(St){return St.role==="end-card"&&!/fail|loss|timeout/i.test(St.id)}))!==null&&tt!==void 0?tt:n.scenes.find(function(St){return St.role==="end-card"})};if(k){Ji=function(){return ht()&&_e>=1||_e>=Xe+1},Q();return}for(var oe=0;oe<Xe*60&&!ht();oe++)q();if(!ht()||c==="timeout"&&!/fail|loss|timeout/i.test(J)||c==="end-card"&&/fail|loss|timeout/i.test(J)){var Gt=yt();if(!Gt)throw Error("End card unavailable");J=Gt.id,he=void 0,gr(),Jt({kind:"sceneEnter",sceneId:J}),xr()}for(var oe=0;oe<45;oe++)q();ei();return}var Ut,at=function(){return ne["harvest.phase"]!=="cta"?!1:(Ut??(Ut=_e),_e-Ut>=.65)};if(c==="opening"&&k&&(Ji=function(){return _e>=7},ut=0,zt=0,ct=!1),c==="timeout"){if(!V)throw Error("Review moment unavailable");if(k){var Wt=(N=n.gameplay.find(function(We){return We.id==="harvest.deadline"}))===null||N===void 0?void 0:N.parameters.seconds;if(!Number.isFinite(Wt))throw Error("Timeout replay unavailable");for(;_e<Wt-.25&&ne["harvest.phase"]!=="cta";)q();if(ne["harvest.phase"]==="cta")throw Error("Timeout replay unavailable");Ji=function(){return at()||_e>=Wt+1},Q();return}for(var oe=0;ne["harvest.phase"]!=="cta"&&oe<3600;oe++)q();if(ne["harvest.phase"]!=="cta")throw Error("Timeout card unavailable")}else if(c!=="opening"){if(!V||!["first-harvest","end-card"].includes(c))throw Error("Review moment unavailable");for(var Mt=c==="first-harvest"?1:3,mt=function(We){var tt=V.snapshot().legalMoves[0];if(!tt||!V.swap(tt.from,tt.to))throw Error("Review move unavailable");if(k&&We===Mt-1){var St=_e+(Mt===1?3:8);return Ji=function(){return _e>=St||Mt===3&&at()},Q(),{value:void 0}}for(var Ct=0;V.snapshot().busy&&Ct<240;Ct++)q();if(V.snapshot().busy)throw Error("Review replay did not settle")},Qe=0;Qe<Mt;Qe++){var st=mt(Qe);if(typeof st=="object")return st.value}if(Mt===1)for(var oe=0;oe<84;oe++)q();else{for(var oe=0;ne["harvest.phase"]!=="cta"&&oe<300;oe++)q();if(ne["harvest.phase"]!=="cta")throw Error("End card unavailable")}}ei()},pickReview:function(c,x){var R=Go(fc({clientX:c,clientY:x}));return R?Ho(R.c).map(function(A){var C;return(C=A.prototypeId)!==null&&C!==void 0?C:A.id}):[]},reviewBounds:function(c){var x=O(),R=e.clientWidth,A=e.clientHeight,C=Math.min(R/x.width,A/x.height);return ue.filter(function(N){return c.includes(N.c.id)}).map(function(N){var P=zi(N.c,N.m);return{left:(R-x.width*C)/2+P.left*C,top:(A-x.height*C)/2+P.top*C,width:(P.right-P.left)*C,height:(P.bottom-P.top)*C}})}}:void 0;return gt(gt({},og),{state:ca,auditViewport:$v,auditSceneLayout:Kv,restart:function(){var c;Ji=void 0,La=void 0,(c=_?.notifyGameRetry)===null||c===void 0||c.call(_),uc(),ei()},select:function(c){w=c},inspectScene:function(c){f&&n.scenes.some(function(x){return x.id===c})&&(J=c,w=void 0)},pause:function(c){ct=c,ut=0,zt=0,c&&gr(),_t&&(c?_t.suspend().catch(function(){}):je&&Hs())},destroy:function(){var c,x;pt=!0,cancelAnimationFrame(nn),gr(),pn(),jt?.dispose(),Qd?.(),jd?.(),ef?.(),_?.destroy(),(c=Ka?.disconnect)===null||c===void 0||c.call(Ka),document.removeEventListener("visibilitychange",Sp),(x=globalThis.removeEventListener)===null||x===void 0||x.call(globalThis,"resize",Kd),e.removeEventListener("pointerdown",gp),e.removeEventListener("pointermove",xp),e.removeEventListener("pointerup",_p),e.removeEventListener("pointercancel",hc),e.removeEventListener("lostpointercapture",hc),e.removeEventListener("click",Mp),_t?.close().catch(function(){})}})}return _g(ew);})();
4220
+ }`,Xp=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let i=new yc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,i=new pa({vertexShader:Bw,fragmentShader:kw,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new bi(new Ec(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Yp=class extends Qa{constructor(e,t){super();let i=this,r=null,a=1,s=null,o="local-floor",u=1,l=null,d=null,f=null,h=null,m=null,x=null,_=typeof XRWebGLBinding<"u",g=new Xp,v={},F=t.getContextAttributes(),P=null,S=null,N=[],p=[],L=new ln,E=null,D=null,X=new zr;X.viewport=new Fi;let Y=new zr;Y.viewport=new Fi;let W=[X,Y],C=new Ad,M=null,J=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(se){let re=N[se];return re===void 0&&(re=new al,N[se]=re),re.getTargetRaySpace()},this.getControllerGrip=function(se){let re=N[se];return re===void 0&&(re=new al,N[se]=re),re.getGripSpace()},this.getHand=function(se){let re=N[se];return re===void 0&&(re=new al,N[se]=re),re.getHandSpace()};function q(se){let re=p.indexOf(se.inputSource);if(re===-1)return;let Ie=N[re];Ie!==void 0&&(Ie.update(se.inputSource,se.frame,l||s),Ie.dispatchEvent({type:se.type,data:se.inputSource}))}function ce(){r.removeEventListener("select",q),r.removeEventListener("selectstart",q),r.removeEventListener("selectend",q),r.removeEventListener("squeeze",q),r.removeEventListener("squeezestart",q),r.removeEventListener("squeezeend",q),r.removeEventListener("end",ce),r.removeEventListener("inputsourceschange",k);for(let se=0;se<N.length;se++){let re=p[se];re!==null&&(p[se]=null,N[se].disconnect(re))}M=null,J=null,g.reset();for(let se in v)delete v[se];if(e.setRenderTarget(P),m=null,h=null,f=null,r=null,S=null,Le.stop(),i.isPresenting=!1,e.setPixelRatio(E),e.setSize(L.width,L.height,!1),D!==null){let se=D.camera;se.fov=D.fov,se.zoom=D.zoom,se.updateProjectionMatrix(),D=null}i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(se){a=se,i.isPresenting===!0&&Rn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(se){o=se,i.isPresenting===!0&&Rn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(se){l=se},this.getBaseLayer=function(){return h!==null?h:m},this.getBinding=function(){return f===null&&_&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return x},this.getSession=function(){return r},this.setSession=async function(se){if(r=se,r!==null){if(P=e.getRenderTarget(),r.addEventListener("select",q),r.addEventListener("selectstart",q),r.addEventListener("selectend",q),r.addEventListener("squeeze",q),r.addEventListener("squeezestart",q),r.addEventListener("squeezeend",q),r.addEventListener("end",ce),r.addEventListener("inputsourceschange",k),F.xrCompatible!==!0&&await t.makeXRCompatible(),E=e.getPixelRatio(),e.getSize(L),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ie=null,ke=null,xe=null;F.depth&&(xe=F.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ie=F.stencil?Zs:Ka,ke=F.stencil?Sl:za);let Ye={colorFormat:t.RGBA8,depthFormat:xe,scaleFactor:a};f=this.getBinding(),h=f.createProjectionLayer(Ye),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),S=new sa(h.textureWidth,h.textureHeight,{format:ga,type:ca,depthTexture:new Hs(h.textureWidth,h.textureHeight,ke,void 0,void 0,void 0,void 0,void 0,void 0,Ie),stencilBuffer:F.stencil,colorSpace:e.outputColorSpace,samples:F.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1,storeMultisampledDepthBuffer:h.ignoreDepthValues===!1,storeMultisampledStencilBuffer:h.ignoreDepthValues===!1})}else{let Ie={antialias:F.antialias,alpha:!0,depth:F.depth,stencil:F.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(r,t,Ie),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),S=new sa(m.framebufferWidth,m.framebufferHeight,{format:ga,type:ca,colorSpace:e.outputColorSpace,stencilBuffer:F.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1,storeMultisampledDepthBuffer:m.ignoreDepthValues===!1,storeMultisampledStencilBuffer:m.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(u),l=null,s=await r.requestReferenceSpace(o),Le.setContext(r),Le.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function k(se){for(let re=0;re<se.removed.length;re++){let Ie=se.removed[re],ke=p.indexOf(Ie);ke>=0&&(p[ke]=null,N[ke].disconnect(Ie))}for(let re=0;re<se.added.length;re++){let Ie=se.added[re],ke=p.indexOf(Ie);if(ke===-1){for(let Ye=0;Ye<N.length;Ye++)if(Ye>=p.length){p.push(Ie),ke=Ye;break}else if(p[Ye]===null){p[Ye]=Ie,ke=Ye;break}if(ke===-1)break}let xe=N[ke];xe&&xe.connect(Ie)}}let G=new Se,te=new Se;function le(se,re,Ie){G.setFromMatrixPosition(re.matrixWorld),te.setFromMatrixPosition(Ie.matrixWorld);let ke=G.distanceTo(te),xe=re.projectionMatrix.elements,Ye=Ie.projectionMatrix.elements,mt=xe[14]/(xe[10]-1),He=xe[14]/(xe[10]+1),qe=(xe[9]+1)/xe[5],pt=(xe[9]-1)/xe[5],at=(xe[8]-1)/xe[0],ot=(Ye[8]+1)/Ye[0],Vt=mt*at,cn=mt*ot,Ze=ke/(-at+ot),pn=Ze*-at;if(re.matrixWorld.decompose(se.position,se.quaternion,se.scale),se.translateX(pn),se.translateZ(Ze),se.matrixWorld.compose(se.position,se.quaternion,se.scale),se.matrixWorldInverse.copy(se.matrixWorld).invert(),xe[10]===-1)se.projectionMatrix.copy(re.projectionMatrix),se.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{let ne=mt+Ze,Tn=He+Ze,gn=Vt-pn,Q=cn+(ke-pn),I=qe*He/Tn*ne,ie=pt*He/Tn*ne;se.projectionMatrix.makePerspective(gn,Q,I,ie,ne,Tn),se.projectionMatrixInverse.copy(se.projectionMatrix).invert()}}function ge(se,re){re===null?se.matrixWorld.copy(se.matrix):se.matrixWorld.multiplyMatrices(re.matrixWorld,se.matrix),se.matrixWorldInverse.copy(se.matrixWorld).invert()}this.updateCamera=function(se){if(r===null)return;let re=se.near,Ie=se.far;g.texture!==null&&(g.depthNear>0&&(re=g.depthNear),g.depthFar>0&&(Ie=g.depthFar)),C.near=Y.near=X.near=re,C.far=Y.far=X.far=Ie,(M!==C.near||J!==C.far)&&(r.updateRenderState({depthNear:C.near,depthFar:C.far}),M=C.near,J=C.far),C.layers.mask=se.layers.mask|6,X.layers.mask=C.layers.mask&-5,Y.layers.mask=C.layers.mask&-3;let ke=se.parent,xe=C.cameras;ge(C,ke);for(let Ye=0;Ye<xe.length;Ye++)ge(xe[Ye],ke);xe.length===2?le(C,X,Y):C.projectionMatrix.copy(X.projectionMatrix),D===null&&se.isPerspectiveCamera&&(D={camera:se,fov:se.fov,zoom:se.zoom}),oe(se,C,ke)};function oe(se,re,Ie){Ie===null?se.matrix.copy(re.matrixWorld):(se.matrix.copy(Ie.matrixWorld),se.matrix.invert(),se.matrix.multiply(re.matrixWorld)),se.matrix.decompose(se.position,se.quaternion,se.scale),se.updateMatrixWorld(!0),se.projectionMatrix.copy(re.projectionMatrix),se.projectionMatrixInverse.copy(re.projectionMatrixInverse),se.isPerspectiveCamera&&(se.fov=td*2*Math.atan(1/se.projectionMatrix.elements[5]),se.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(h===null&&m===null))return u},this.setFoveation=function(se){u=se,h!==null&&(h.fixedFoveation=se),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=se)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(C)},this.getCameraTexture=function(se){return v[se]};let $=null;function Te(se,re){if(d=re.getViewerPose(l||s),x=re,d!==null){let Ie=d.views;m!==null&&(e.setRenderTargetFramebuffer(S,m.framebuffer),e.setRenderTarget(S));let ke=!1;Ie.length!==C.cameras.length&&(C.cameras.length=0,ke=!0);for(let He=0;He<Ie.length;He++){let qe=Ie[He],pt=null;if(m!==null)pt=m.getViewport(qe);else{let ot=f.getViewSubImage(h,qe);pt=ot.viewport,He===0&&(e.setRenderTargetTextures(S,ot.colorTexture,ot.depthStencilTexture),e.setRenderTarget(S))}let at=W[He];at===void 0&&(at=new zr,at.layers.enable(He),at.viewport=new Fi,W[He]=at),at.matrix.fromArray(qe.transform.matrix),at.matrix.decompose(at.position,at.quaternion,at.scale),at.projectionMatrix.fromArray(qe.projectionMatrix),at.projectionMatrixInverse.copy(at.projectionMatrix).invert(),at.viewport.set(pt.x,pt.y,pt.width,pt.height),He===0&&(C.matrix.copy(at.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),ke===!0&&C.cameras.push(at)}let xe=r.enabledFeatures;if(xe&&xe.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&_){f=i.getBinding();let He=f.getDepthInformation(Ie[0]);He&&He.isValid&&He.texture&&g.init(He,r.renderState)}if(xe&&xe.includes("camera-access")&&_){e.state.unbindTexture(),f=i.getBinding();for(let He=0;He<Ie.length;He++){let qe=Ie[He].camera;if(qe){let pt=v[qe];pt||(pt=new yc,v[qe]=pt);let at=f.getCameraImage(qe);pt.sourceTexture=at}}}}for(let Ie=0;Ie<N.length;Ie++){let ke=p[Ie],xe=N[Ie];ke!==null&&xe!==void 0&&xe.update(ke,re,l||s)}$&&$(se,re),re.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:re}),x=null}let Le=new rg;Le.setAnimationLoop(Te),this.setAnimationLoop=function(se){$=se},this.dispose=function(){}}},zw=new Jn,ug=new qn;ug.set(-1,0,0,0,1,0,0,0,1);function Vw(n,e){function t(g,v){g.matrixAutoUpdate===!0&&g.updateMatrix(),v.value.copy(g.matrix)}function i(g,v){v.color.getRGB(g.fogColor.value,bp(n)),v.isFog?(g.fogNear.value=v.near,g.fogFar.value=v.far):v.isFogExp2&&(g.fogDensity.value=v.density)}function r(g,v,F,P,S){v.isNodeMaterial?v.uniformsNeedUpdate=!1:v.isMeshBasicMaterial?a(g,v):v.isMeshLambertMaterial?(a(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshToonMaterial?(a(g,v),f(g,v)):v.isMeshPhongMaterial?(a(g,v),d(g,v),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)):v.isMeshStandardMaterial?(a(g,v),h(g,v),v.isMeshPhysicalMaterial&&m(g,v,S)):v.isMeshMatcapMaterial?(a(g,v),x(g,v)):v.isMeshDepthMaterial?a(g,v):v.isMeshDistanceMaterial?(a(g,v),_(g,v)):v.isMeshNormalMaterial?a(g,v):v.isLineBasicMaterial?(s(g,v),v.isLineDashedMaterial&&o(g,v)):v.isPointsMaterial?u(g,v,F,P):v.isSpriteMaterial?l(g,v):v.isShadowMaterial?(g.color.value.copy(v.color),g.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(g,v){g.opacity.value=v.opacity,v.color&&g.diffuse.value.copy(v.color),v.emissive&&g.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(g.map.value=v.map,t(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,t(v.alphaMap,g.alphaMapTransform)),v.bumpMap&&(g.bumpMap.value=v.bumpMap,t(v.bumpMap,g.bumpMapTransform),g.bumpScale.value=v.bumpScale,v.side===ea&&(g.bumpScale.value*=-1)),v.normalMap&&(g.normalMap.value=v.normalMap,t(v.normalMap,g.normalMapTransform),g.normalScale.value.copy(v.normalScale),v.side===ea&&g.normalScale.value.negate()),v.displacementMap&&(g.displacementMap.value=v.displacementMap,t(v.displacementMap,g.displacementMapTransform),g.displacementScale.value=v.displacementScale,g.displacementBias.value=v.displacementBias),v.emissiveMap&&(g.emissiveMap.value=v.emissiveMap,t(v.emissiveMap,g.emissiveMapTransform)),v.specularMap&&(g.specularMap.value=v.specularMap,t(v.specularMap,g.specularMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest);let F=e.get(v),P=F.envMap,S=F.envMapRotation;P&&(g.envMap.value=P,g.envMapRotation.value.setFromMatrix4(zw.makeRotationFromEuler(S)).transpose(),P.isCubeTexture&&P.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(ug),g.reflectivity.value=v.reflectivity,g.ior.value=v.ior,g.refractionRatio.value=v.refractionRatio),v.lightMap&&(g.lightMap.value=v.lightMap,g.lightMapIntensity.value=v.lightMapIntensity,t(v.lightMap,g.lightMapTransform)),v.aoMap&&(g.aoMap.value=v.aoMap,g.aoMapIntensity.value=v.aoMapIntensity,t(v.aoMap,g.aoMapTransform))}function s(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,v.map&&(g.map.value=v.map,t(v.map,g.mapTransform))}function o(g,v){g.dashSize.value=v.dashSize,g.totalSize.value=v.dashSize+v.gapSize,g.scale.value=v.scale}function u(g,v,F,P){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.size.value=v.size*F,g.scale.value=P*.5,v.map&&(g.map.value=v.map,t(v.map,g.uvTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,t(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function l(g,v){g.diffuse.value.copy(v.color),g.opacity.value=v.opacity,g.rotation.value=v.rotation,v.map&&(g.map.value=v.map,t(v.map,g.mapTransform)),v.alphaMap&&(g.alphaMap.value=v.alphaMap,t(v.alphaMap,g.alphaMapTransform)),v.alphaTest>0&&(g.alphaTest.value=v.alphaTest)}function d(g,v){g.specular.value.copy(v.specular),g.shininess.value=Math.max(v.shininess,1e-4)}function f(g,v){v.gradientMap&&(g.gradientMap.value=v.gradientMap)}function h(g,v){g.metalness.value=v.metalness,v.metalnessMap&&(g.metalnessMap.value=v.metalnessMap,t(v.metalnessMap,g.metalnessMapTransform)),g.roughness.value=v.roughness,v.roughnessMap&&(g.roughnessMap.value=v.roughnessMap,t(v.roughnessMap,g.roughnessMapTransform)),v.envMap&&(g.envMapIntensity.value=v.envMapIntensity)}function m(g,v,F){g.ior.value=v.ior,v.sheen>0&&(g.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),g.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(g.sheenColorMap.value=v.sheenColorMap,t(v.sheenColorMap,g.sheenColorMapTransform)),v.sheenRoughnessMap&&(g.sheenRoughnessMap.value=v.sheenRoughnessMap,t(v.sheenRoughnessMap,g.sheenRoughnessMapTransform))),v.clearcoat>0&&(g.clearcoat.value=v.clearcoat,g.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(g.clearcoatMap.value=v.clearcoatMap,t(v.clearcoatMap,g.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,t(v.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(g.clearcoatNormalMap.value=v.clearcoatNormalMap,t(v.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ea&&g.clearcoatNormalScale.value.negate())),v.dispersion>0&&(g.dispersion.value=v.dispersion),v.retroreflectivity>0&&(g.retroreflectivity.value=v.retroreflectivity),v.iridescence>0&&(g.iridescence.value=v.iridescence,g.iridescenceIOR.value=v.iridescenceIOR,g.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(g.iridescenceMap.value=v.iridescenceMap,t(v.iridescenceMap,g.iridescenceMapTransform)),v.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=v.iridescenceThicknessMap,t(v.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),v.transmission>0&&(g.transmission.value=v.transmission,g.transmissionSamplerMap.value=F.texture,g.transmissionSamplerSize.value.set(F.width,F.height),v.transmissionMap&&(g.transmissionMap.value=v.transmissionMap,t(v.transmissionMap,g.transmissionMapTransform)),g.thickness.value=v.thickness,v.thicknessMap&&(g.thicknessMap.value=v.thicknessMap,t(v.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=v.attenuationDistance,g.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(g.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(g.anisotropyMap.value=v.anisotropyMap,t(v.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=v.specularIntensity,g.specularColor.value.copy(v.specularColor),v.specularColorMap&&(g.specularColorMap.value=v.specularColorMap,t(v.specularColorMap,g.specularColorMapTransform)),v.specularIntensityMap&&(g.specularIntensityMap.value=v.specularIntensityMap,t(v.specularIntensityMap,g.specularIntensityMapTransform))}function x(g,v){v.matcap&&(g.matcap.value=v.matcap)}function _(g,v){let F=e.get(v).light;g.referencePosition.value.setFromMatrixPosition(F.matrixWorld),g.nearDistance.value=F.shadow.camera.near,g.farDistance.value=F.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Gw(n,e,t,i){let r={},a={},s=[],o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function u(S,N){let p=N.program;i.uniformBlockBinding(S,p)}function l(S,N){let p=r[S.id];p===void 0&&(g(S),p=d(S),r[S.id]=p,S.addEventListener("dispose",F));let L=N.program;i.updateUBOMapping(S,L);let E=e.render.frame;a[S.id]!==E&&(h(S),a[S.id]=E)}function d(S){let N=f();S.__bindingPointIndex=N;let p=n.createBuffer(),L=S.__size,E=S.usage;return n.bindBuffer(n.UNIFORM_BUFFER,p),n.bufferData(n.UNIFORM_BUFFER,L,E),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,N,p),p}function f(){for(let S=0;S<o;S++)if(s.indexOf(S)===-1)return s.push(S),S;return On("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(S){let N=r[S.id],p=S.uniforms,L=S.__cache;n.bindBuffer(n.UNIFORM_BUFFER,N);for(let E=0,D=p.length;E<D;E++){let X=p[E];if(Array.isArray(X))for(let Y=0,W=X.length;Y<W;Y++)m(X[Y],E,Y,L);else m(X,E,0,L)}n.bindBuffer(n.UNIFORM_BUFFER,null)}function m(S,N,p,L){if(_(S,N,p,L)===!0){let E=S.__offset,D=S.value;if(Array.isArray(D)){let X=0;for(let Y=0;Y<D.length;Y++){let W=D[Y],C=v(W);x(W,S.__data,X),typeof W!="number"&&typeof W!="boolean"&&!W.isMatrix3&&!ArrayBuffer.isView(W)&&(X+=C.storage/Float32Array.BYTES_PER_ELEMENT)}}else x(D,S.__data,0);n.bufferSubData(n.UNIFORM_BUFFER,E,S.__data)}}function x(S,N,p){typeof S=="number"||typeof S=="boolean"?N[0]=S:S.isMatrix3?(N[0]=S.elements[0],N[1]=S.elements[1],N[2]=S.elements[2],N[3]=0,N[4]=S.elements[3],N[5]=S.elements[4],N[6]=S.elements[5],N[7]=0,N[8]=S.elements[6],N[9]=S.elements[7],N[10]=S.elements[8],N[11]=0):ArrayBuffer.isView(S)?N.set(new S.constructor(S.buffer,S.byteOffset,N.length)):S.toArray(N,p)}function _(S,N,p,L){let E=S.value,D=N+"_"+p;if(L[D]===void 0)return typeof E=="number"||typeof E=="boolean"?L[D]=E:ArrayBuffer.isView(E)?L[D]=E.slice():L[D]=E.clone(),!0;{let X=L[D];if(typeof E=="number"||typeof E=="boolean"){if(X!==E)return L[D]=E,!0}else{if(ArrayBuffer.isView(E))return!0;if(X.equals(E)===!1)return X.copy(E),!0}}return!1}function g(S){let N=S.uniforms,p=0,L=16;for(let D=0,X=N.length;D<X;D++){let Y=Array.isArray(N[D])?N[D]:[N[D]];for(let W=0,C=Y.length;W<C;W++){let M=Y[W],J=Array.isArray(M.value)?M.value:[M.value];for(let q=0,ce=J.length;q<ce;q++){let k=J[q],G=v(k),te=p%L,le=te%G.boundary,ge=te+le;p+=le,ge!==0&&L-ge<G.storage&&(p+=L-ge),M.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=p,p+=G.storage}}}let E=p%L;return E>0&&(p+=L-E),S.__size=p,S.__cache={},this}function v(S){let N={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(N.boundary=4,N.storage=4):S.isVector2?(N.boundary=8,N.storage=8):S.isVector3||S.isColor?(N.boundary=16,N.storage=12):S.isVector4?(N.boundary=16,N.storage=16):S.isMatrix3?(N.boundary=48,N.storage=48):S.isMatrix4?(N.boundary=64,N.storage=64):S.isTexture?Rn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(N.boundary=16,N.storage=S.byteLength):Rn("WebGLRenderer: Unsupported uniform value type.",S),N}function F(S){let N=S.target;N.removeEventListener("dispose",F);let p=s.indexOf(N.__bindingPointIndex);s.splice(p,1),n.deleteBuffer(r[N.id]),delete r[N.id],delete a[N.id]}function P(){for(let S in r)n.deleteBuffer(r[S]);s=[],r={},a={}}return{bind:u,update:l,dispose:P}}var Hw=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),is=null;function Ww(){return is===null&&(is=new Gs(Hw,16,16,Js,Va),is.name="DFG_LUT",is.minFilter=fr,is.magFilter=fr,is.wrapS=Ta,is.wrapT=Ta,is.generateMipmaps=!1,is.needsUpdate=!0),is}var Sf=class{constructor(e={}){let{canvas:t=T0(),context:i=null,depth:r=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:l=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:h=!1,outputBufferType:m=ca}=e;this.isWebGLRenderer=!0;let x;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");x=i.getContextAttributes().alpha}else x=s;let _=m,g=new Set([kd,Bd,Od]),v=new Set([ca,za,Ml,Sl,Nd,Ud]),F=new Uint32Array(4),P=new Int32Array(4),S=new Se,N=null,p=null,L=[],E=[],D=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=la,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let X=this,Y=!1,W=null,C=null,M=null,J=null;this._outputColorSpace=Ir;let q=0,ce=0,k=null,G=-1,te=null,le=new Fi,ge=new Fi,oe=null,$=new Wn(0),Te=0,Le=t.width,se=t.height,re=1,Ie=null,ke=null,xe=new Fi(0,0,Le,se),Ye=new Fi(0,0,Le,se),mt=!1,He=new cl,qe=!1,pt=!1,at=new Jn,ot=new Se,Vt=new Fi,cn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ze=!1;function pn(){return k===null?re:1}let ne=i;function Tn(A,ae){return t.getContext(A,ae)}let gn,Q,I,ie,be,De,Je,je,Ne,Pe,it,Rt,Mt,ct,Gt,Kt,nn,he,dt,Ee,gt,Ke,We;try{let A={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:u,preserveDrawingBuffer:l,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"186"}`),t.addEventListener("webglcontextlost",yt,!1),t.addEventListener("webglcontextrestored",Et,!1),t.addEventListener("webglcontextcreationerror",rt,!1),ne===null){let ae="webgl2";if(ne=Tn(ae,A),ne===null)throw Tn(ae)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Wt()}catch(A){throw t.removeEventListener("webglcontextlost",yt,!1),t.removeEventListener("webglcontextrestored",Et,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),On("WebGLRenderer: "+A.message),A}function Wt(){gn=new KS(ne),gn.init(),gt=new Ow(ne,gn),Q=new VS(ne,gn,e,gt),I=new Uw(ne,gn),Q.reversedDepthBuffer&&h&&I.buffers.depth.setReversed(!0),C=ne.createFramebuffer(),M=ne.createFramebuffer(),J=ne.createFramebuffer(),ie=new eb(ne),be=new Mw,De=new Fw(ne,gn,I,be,Q,gt,ie),Je=new $S(X),je=new n_(ne),Ke=new kS(ne,je),Ne=new QS(ne,je,ie,Ke),Pe=new nb(ne,Ne,je,Ke,ie),he=new tb(ne,Q,De),Gt=new GS(be),it=new _w(X,Je,gn,Q,Ke,Gt),Rt=new Vw(X,be),Mt=new bw,ct=new Cw(gn),nn=new BS(X,Je,I,Pe,x,u),Kt=new Nw(X,Pe,Q),We=new Gw(ne,ie,Q,I),dt=new zS(ne,gn,ie),Ee=new jS(ne,gn,ie),ie.programs=it.programs,X.capabilities=Q,X.extensions=gn,X.properties=be,X.renderLists=Mt,X.shadowMap=Kt,X.state=I,X.info=ie}_!==ca&&(D=new rb(_,t.width,t.height,o,r,a));let Lt=new Yp(X,ne);this.xr=Lt,this.getContext=function(){return ne},this.getContextAttributes=function(){return ne.getContextAttributes()},this.forceContextLoss=function(){let A=gn.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){let A=gn.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(A){A!==void 0&&(re=A,this.setSize(Le,se,!1))},this.getSize=function(A){return A.set(Le,se)},this.setSize=function(A,ae,we=!0){if(Lt.isPresenting){Rn("WebGLRenderer: Can't change size while VR device is presenting.");return}Le=A,se=ae,t.width=Math.floor(A*re),t.height=Math.floor(ae*re),we===!0&&(t.style.width=A+"px",t.style.height=ae+"px"),D!==null&&D.setSize(t.width,t.height),this.setViewport(0,0,A,ae)},this.getDrawingBufferSize=function(A){return A.set(Le*re,se*re).floor()},this.setDrawingBufferSize=function(A,ae,we){Le=A,se=ae,re=we,t.width=Math.floor(A*we),t.height=Math.floor(ae*we),this.setViewport(0,0,A,ae)},this.setEffects=function(A){if(_===ca){On("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(A){for(let ae=0;ae<A.length;ae++)if(A[ae].isOutputPass===!0){Rn("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}D.setEffects(A||[])},this.getCurrentViewport=function(A){return A.copy(le)},this.getViewport=function(A){return A.copy(xe)},this.setViewport=function(A,ae,we,me){A.isVector4?xe.set(A.x,A.y,A.z,A.w):xe.set(A,ae,we,me),I.viewport(le.copy(xe).multiplyScalar(re).round())},this.getScissor=function(A){return A.copy(Ye)},this.setScissor=function(A,ae,we,me){A.isVector4?Ye.set(A.x,A.y,A.z,A.w):Ye.set(A,ae,we,me),I.scissor(ge.copy(Ye).multiplyScalar(re).round())},this.getScissorTest=function(){return mt},this.setScissorTest=function(A){I.setScissorTest(mt=A)},this.setOpaqueSort=function(A){Ie=A},this.setTransparentSort=function(A){ke=A},this.getClearColor=function(A){return A.copy(nn.getClearColor())},this.setClearColor=function(){nn.setClearColor(...arguments)},this.getClearAlpha=function(){return nn.getClearAlpha()},this.setClearAlpha=function(){nn.setClearAlpha(...arguments)},this.clear=function(A=!0,ae=!0,we=!0){let me=0;if(A){let Me=!1;if(k!==null){let et=k.texture.format;Me=g.has(et)}if(Me){let et=k.texture.type,Ge=v.has(et),ut=nn.getClearColor(),Nt=nn.getClearAlpha(),lt=ut.r,It=ut.g,Ft=ut.b;Ge?(F[0]=lt,F[1]=It,F[2]=Ft,F[3]=Nt,ne.clearBufferuiv(ne.COLOR,0,F)):(P[0]=lt,P[1]=It,P[2]=Ft,P[3]=Nt,ne.clearBufferiv(ne.COLOR,0,P))}else me|=ne.COLOR_BUFFER_BIT}ae&&(me|=ne.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),we&&(me|=ne.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),me!==0&&ne.clear(me)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(A){A.setRenderer(this),W=A},this.dispose=function(){t.removeEventListener("webglcontextlost",yt,!1),t.removeEventListener("webglcontextrestored",Et,!1),t.removeEventListener("webglcontextcreationerror",rt,!1),nn.dispose(),Mt.dispose(),ct.dispose(),be.dispose(),Je.dispose(),Pe.dispose(),Ke.dispose(),We.dispose(),it.dispose(),Lt.dispose(),Lt.removeEventListener("sessionstart",bn),Lt.removeEventListener("sessionend",Yt),Ot.stop()};function yt(A){A.preventDefault(),Mp("WebGLRenderer: Context Lost."),Y=!0}function Et(){Mp("WebGLRenderer: Context Restored."),Y=!1;let A=ie.autoReset,ae=Kt.enabled,we=Kt.autoUpdate,me=Kt.needsUpdate,Me=Kt.type;Wt(),ie.autoReset=A,Kt.enabled=ae,Kt.autoUpdate=we,Kt.needsUpdate=me,Kt.type=Me}function rt(A){On("WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Ut(A){let ae=A.target;ae.removeEventListener("dispose",Ut),an(ae)}function an(A){hn(A),be.remove(A)}function hn(A){let ae=be.get(A).programs;ae!==void 0&&(ae.forEach(function(we){it.releaseProgram(we)}),A.isShaderMaterial&&it.releaseShaderCache(A))}this.renderBufferDirect=function(A,ae,we,me,Me,et){ae===null&&(ae=cn);let Ge=Me.isMesh&&Me.matrixWorld.determinantAffine()<0,ut=dn(A,ae,we,me,Me);I.setMaterial(me,Ge);let Nt=we.index,lt=1;if(me.wireframe===!0){if(Nt=Ne.getWireframeAttribute(we),Nt===void 0)return;lt=2}let It=we.drawRange,Ft=we.attributes.position,Ce=It.start*lt,qt=(It.start+It.count)*lt;et!==null&&(Ce=Math.max(Ce,et.start*lt),qt=Math.min(qt,(et.start+et.count)*lt)),Nt!==null?(Ce=Math.max(Ce,0),qt=Math.min(qt,Nt.count)):Ft!=null&&(Ce=Math.max(Ce,0),qt=Math.min(qt,Ft.count));let Qt=qt-Ce;if(Qt<0||Qt===1/0)return;Ke.setup(Me,me,ut,we,Nt);let sn,Mn=dt;if(Nt!==null&&(sn=je.get(Nt),Mn=Ee,Mn.setIndex(sn)),Me.isMesh)me.wireframe===!0?(I.setLineWidth(me.wireframeLinewidth*pn()),Mn.setMode(ne.LINES)):Mn.setMode(ne.TRIANGLES);else if(Me.isLine){let In=me.linewidth;In===void 0&&(In=1),I.setLineWidth(In*pn()),Me.isLineSegments?Mn.setMode(ne.LINES):Me.isLineLoop?Mn.setMode(ne.LINE_LOOP):Mn.setMode(ne.LINE_STRIP)}else Me.isPoints?Mn.setMode(ne.POINTS):Me.isSprite&&Mn.setMode(ne.TRIANGLES);if(Me.isBatchedMesh)if(gn.get("WEBGL_multi_draw"))Mn.renderMultiDraw(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount);else{let In=Me._multiDrawStarts,wt=Me._multiDrawCounts,ri=Me._multiDrawCount,xn=Nt?je.get(Nt).bytesPerElement:1,Kn=be.get(me).currentProgram.getUniforms();for(let Dt=0;Dt<ri;Dt++)Kn.setValue(ne,"_gl_DrawID",Dt),Mn.render(In[Dt]/xn,wt[Dt])}else if(Me.isInstancedMesh)Mn.renderInstances(Ce,Qt,Me.count);else if(we.isInstancedBufferGeometry){let In=we._maxInstanceCount!==void 0?we._maxInstanceCount:1/0,wt=Math.min(we.instanceCount,In);Mn.renderInstances(Ce,Qt,wt)}else Mn.render(Ce,Qt)};function en(A,ae,we,me){W!==null&&A.isNodeMaterial&&W.setObject(me,A),qe===!0&&Gt.setState(A,we,!1),A.transparent===!0&&A.side===Gr&&A.forceSinglePass===!1?(A.side=ea,A.needsUpdate=!0,Pn(A,ae,me),A.side=es,A.needsUpdate=!0,Pn(A,ae,me),A.side=Gr):Pn(A,ae,me)}this.compile=function(A,ae,we=null){we===null&&(we=A),W!==null&&W.renderStart(A,ae,we),p=ct.get(we),p.init(ae),E.push(p),we.traverseVisible(function(Me){Me.isLight&&Me.layers.test(ae.layers)&&(p.pushLight(Me),Me.castShadow&&p.pushShadow(Me))}),A!==we&&A.traverseVisible(function(Me){Me.isLight&&Me.layers.test(ae.layers)&&(p.pushLight(Me),Me.castShadow&&p.pushShadow(Me))}),p.setupLights(),W!==null&&W.updateLights(p.state.lightsArray),pt=this.localClippingEnabled,qe=Gt.init(this.clippingPlanes,pt),qe===!0&&Gt.setGlobalState(this.clippingPlanes,ae),W!==null&&Kt.render(p.state.shadowsArray,we,ae);let me=new Set;return A.traverse(function(Me){if(!(Me.isMesh||Me.isPoints||Me.isLine||Me.isSprite))return;let et=Me.material;if(et)if(Array.isArray(et))for(let Ge=0;Ge<et.length;Ge++){let ut=et[Ge];en(ut,we,ae,Me),me.add(ut)}else en(et,we,ae,Me),me.add(et)}),p=E.pop(),W!==null&&W.renderEnd(),me},this.compileAsync=function(A,ae,we=null){let me=this.compile(A,ae,we);return new Promise(Me=>{function et(){if(me.forEach(function(Ge){let Nt=be.get(Ge).currentProgram;(Nt===void 0||Nt.isReady())&&me.delete(Ge)}),me.size===0){Me(A);return}setTimeout(et,10)}gn.get("KHR_parallel_shader_compile")!==null?et():setTimeout(et,10)})};let Ht=null;function yn(A){Ht&&Ht(A)}function bn(){Ot.stop()}function Yt(){Ot.start()}let Ot=new rg;Ot.setAnimationLoop(yn),typeof self<"u"&&Ot.setContext(self),this.setAnimationLoop=function(A){Ht=A,Lt.setAnimationLoop(A),A===null?Ot.stop():Ot.start()},Lt.addEventListener("sessionstart",bn),Lt.addEventListener("sessionend",Yt),this.render=function(A,ae){if(ae!==void 0&&ae.isCamera!==!0){On("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(Y===!0)return;W!==null&&W.renderStart(A,ae);let we=Lt.enabled===!0&&Lt.isPresenting===!0,me=D!==null&&(k===null||we)&&D.begin(X,k);if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),ae.parent===null&&ae.matrixWorldAutoUpdate===!0&&ae.updateMatrixWorld(),Lt.enabled===!0&&Lt.isPresenting===!0&&(D===null||D.isCompositing()===!1)&&(Lt.cameraAutoUpdate===!0&&Lt.updateCamera(ae),ae=Lt.getCamera()),A.isScene===!0&&A.onBeforeRender(X,A,ae,k),p=ct.get(A,E.length),p.init(ae),p.state.textureUnits=De.getTextureUnits(),E.push(p),at.multiplyMatrices(ae.projectionMatrix,ae.matrixWorldInverse),He.setFromProjectionMatrix(at,Ba,ae.reversedDepth),pt=this.localClippingEnabled,qe=Gt.init(this.clippingPlanes,pt),N=Mt.get(A,L.length),N.init(),L.push(N),Lt.enabled===!0&&Lt.isPresenting===!0){let Ge=X.xr.getDepthSensingMesh();Ge!==null&&$n(Ge,ae,-1/0,X.sortObjects)}$n(A,ae,0,X.sortObjects),N.finish(),W!==null&&W.updateLights(p.state.lightsArray),X.sortObjects===!0&&N.sort(Ie,ke),Ze=Lt.enabled===!1||Lt.isPresenting===!1||Lt.hasDepthSensing()===!1,Ze&&nn.addToRenderList(N,A),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),qe===!0&&Gt.beginShadows();let Me=p.state.shadowsArray;if(Kt.render(Me,A,ae),qe===!0&&Gt.endShadows(),(me&&D.hasRenderPass())===!1){let Ge=N.opaque,ut=N.transmissive;if(p.setupLights(),ae.isArrayCamera){let Nt=ae.cameras;if(ut.length>0)for(let lt=0,It=Nt.length;lt<It;lt++){let Ft=Nt[lt];Nn(Ge,ut,A,Ft)}Ze&&nn.render(A);for(let lt=0,It=Nt.length;lt<It;lt++){let Ft=Nt[lt];Xn(N,A,Ft,Ft.viewport)}}else ut.length>0&&Nn(Ge,ut,A,ae),Ze&&nn.render(A),Xn(N,A,ae)}k!==null&&ce===0&&(De.updateMultisampleRenderTarget(k),De.updateRenderTargetMipmap(k)),me&&D.end(X),A.isScene===!0&&A.onAfterRender(X,A,ae),Ke.resetDefaultState(),G=-1,te=null,E.pop(),E.length>0?(p=E[E.length-1],De.setTextureUnits(p.state.textureUnits),qe===!0&&Gt.setGlobalState(X.clippingPlanes,p.state.camera)):p=null,L.pop(),L.length>0?N=L[L.length-1]:N=null,W!==null&&W.renderEnd()};function $n(A,ae,we,me){if(A.visible===!1)return;if(A.layers.test(ae.layers)){if(A.isGroup)we=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(ae);else if(A.isLightProbeGrid)p.pushLightProbeGrid(A);else if(A.isLight)p.pushLight(A),A.castShadow&&p.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||A.intersectsFrustum(He)){me&&Vt.setFromMatrixPosition(A.matrixWorld).applyMatrix4(at);let Ge=Pe.update(A),ut=A.material;ut.visible&&N.push(A,Ge,ut,we,Vt.z,null,ae)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||A.intersectsFrustum(He))){let Ge=Pe.update(A),ut=A.material;if(me&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),Vt.copy(A.boundingSphere.center)):(Ge.boundingSphere===null&&Ge.computeBoundingSphere(),Vt.copy(Ge.boundingSphere.center)),Vt.applyMatrix4(A.matrixWorld).applyMatrix4(at)),Array.isArray(ut)){let Nt=Ge.groups;for(let lt=0,It=Nt.length;lt<It;lt++){let Ft=Nt[lt],Ce=ut[Ft.materialIndex];Ce&&Ce.visible&&N.push(A,Ge,Ce,we,Vt.z,Ft,ae)}}else ut.visible&&N.push(A,Ge,ut,we,Vt.z,null,ae)}}let et=A.children;for(let Ge=0,ut=et.length;Ge<ut;Ge++)$n(et[Ge],ae,we,me)}function Xn(A,ae,we,me){let{opaque:Me,transmissive:et,transparent:Ge}=A;p.setupLightsView(we),qe===!0&&Gt.setGlobalState(X.clippingPlanes,we),me&&I.viewport(le.copy(me)),Me.length>0&&ni(Me,ae,we),et.length>0&&ni(et,ae,we),Ge.length>0&&ni(Ge,ae,we),I.buffers.depth.setTest(!0),I.buffers.depth.setMask(!0),I.buffers.color.setMask(!0),I.setPolygonOffset(!1)}function Nn(A,ae,we,me){if((we.isScene===!0?we.overrideMaterial:null)!==null)return;if(p.state.transmissionRenderTarget[me.id]===void 0){let Ce=gn.has("EXT_color_buffer_half_float")||gn.has("EXT_color_buffer_float");p.state.transmissionRenderTarget[me.id]=new sa(1,1,{generateMipmaps:!0,type:Ce?Va:ca,minFilter:ns,samples:Math.max(4,Q.samples),stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:vi.workingColorSpace})}let et=p.state.transmissionRenderTarget[me.id],Ge=me.viewport||le;et.setSize(Ge.z*X.transmissionResolutionScale,Ge.w*X.transmissionResolutionScale);let ut=X.getRenderTarget(),Nt=X.getActiveCubeFace(),lt=X.getActiveMipmapLevel();X.setRenderTarget(et),X.getClearColor($),Te=X.getClearAlpha(),Te<1&&X.setClearColor(16777215,.5),X.clear(),Ze&&nn.render(we);let It=X.toneMapping;X.toneMapping=la;let Ft=me.viewport;if(me.viewport!==void 0&&(me.viewport=void 0),p.setupLightsView(me),qe===!0&&Gt.setGlobalState(X.clippingPlanes,me),ni(A,we,me),De.updateMultisampleRenderTarget(et),De.updateRenderTargetMipmap(et),gn.has("WEBGL_multisampled_render_to_texture")===!1){let Ce=!1;for(let qt=0,Qt=ae.length;qt<Qt;qt++){let sn=ae[qt],{object:Mn,geometry:In,material:wt,group:ri}=sn;if(wt.side===Gr&&Mn.layers.test(me.layers)){let xn=wt.side;wt.side=ea,wt.needsUpdate=!0,wn(Mn,we,me,In,wt,ri),wt.side=xn,wt.needsUpdate=!0,Ce=!0}}Ce===!0&&(De.updateMultisampleRenderTarget(et),De.updateRenderTargetMipmap(et))}X.setRenderTarget(ut,Nt,lt),X.setClearColor($,Te),Ft!==void 0&&(me.viewport=Ft),X.toneMapping=It}function ni(A,ae,we){let me=ae.isScene===!0?ae.overrideMaterial:null;for(let Me=0,et=A.length;Me<et;Me++){let Ge=A[Me],{object:ut,geometry:Nt,group:lt}=Ge,It=Ge.material;It.allowOverride===!0&&me!==null&&(It=me),ut.layers.test(we.layers)&&wn(ut,ae,we,Nt,It,lt)}}function wn(A,ae,we,me,Me,et){W!==null&&Me.isNodeMaterial&&W.setObject(A,Me),A.onBeforeRender(X,ae,we,me,Me,et),A.modelViewMatrix.multiplyMatrices(we.matrixWorldInverse,A.matrixWorld),A.normalMatrix.getNormalMatrix(A.modelViewMatrix),Me.onBeforeRender(X,ae,we,me,A,et),Me.transparent===!0&&Me.side===Gr&&Me.forceSinglePass===!1?(Me.side=ea,Me.needsUpdate=!0,X.renderBufferDirect(we,ae,me,Me,A,et),Me.side=es,Me.needsUpdate=!0,X.renderBufferDirect(we,ae,me,Me,A,et),Me.side=Gr):X.renderBufferDirect(we,ae,me,Me,A,et),A.onAfterRender(X,ae,we,me,Me,et)}function Pn(A,ae,we){ae.isScene!==!0&&(ae=cn);let me=be.get(A),Me=p.state.lights,et=p.state.shadowsArray,Ge=Me.state.version,ut=it.getParameters(A,Me.state,et,ae,we,p.state.lightProbeGridArray),Nt=it.getProgramCacheKey(ut),lt=me.programs;me.environment=A.isMeshStandardMaterial||A.isMeshLambertMaterial||A.isMeshPhongMaterial?ae.environment:null,me.fog=ae.fog;let It=A.isMeshStandardMaterial||A.isMeshLambertMaterial&&!A.envMap||A.isMeshPhongMaterial&&!A.envMap;me.envMap=Je.get(A.envMap||me.environment,It),me.envMapRotation=me.environment!==null&&A.envMap===null?ae.environmentRotation:A.envMapRotation,lt===void 0&&(A.addEventListener("dispose",Ut),lt=new Map,me.programs=lt);let Ft=lt.get(Nt);if(Ft!==void 0){if(me.currentProgram===Ft&&me.lightsStateVersion===Ge)return fn(A,ut),Ft}else ut.uniforms=it.getUniforms(A),W!==null&&A.isNodeMaterial&&W.build(A,we,ut),A.onBeforeCompile(ut,X),Ft=it.acquireProgram(ut,Nt),lt.set(Nt,Ft),me.uniforms=ut.uniforms;let Ce=me.uniforms;return(!A.isShaderMaterial&&!A.isRawShaderMaterial||A.clipping===!0)&&(Ce.clippingPlanes=Gt.uniform),fn(A,ut),me.needsLights=ii(A),me.lightsStateVersion=Ge,me.needsLights&&(Ce.ambientLightColor.value=Me.state.ambient,Ce.lightProbe.value=Me.state.probe,Ce.sunLights.value=Me.state.sun,Ce.sunLightShadows.value=Me.state.sunShadow,Ce.directionalLights.value=Me.state.directional,Ce.directionalLightShadows.value=Me.state.directionalShadow,Ce.spotLights.value=Me.state.spot,Ce.spotLightShadows.value=Me.state.spotShadow,Ce.rectAreaLights.value=Me.state.rectArea,Ce.ltc_1.value=Me.state.rectAreaLTC1,Ce.ltc_2.value=Me.state.rectAreaLTC2,Ce.pointLights.value=Me.state.point,Ce.pointLightShadows.value=Me.state.pointShadow,Ce.hemisphereLights.value=Me.state.hemi,Ce.sunShadowMatrix.value=Me.state.sunShadowMatrix,Ce.sunShadowCascade.value=Me.state.sunShadowCascade,Ce.directionalShadowMatrix.value=Me.state.directionalShadowMatrix,Ce.spotLightMatrix.value=Me.state.spotLightMatrix,Ce.spotLightMap.value=Me.state.spotLightMap,Ce.pointShadowMatrix.value=Me.state.pointShadowMatrix),me.lightProbeGrid=p.state.lightProbeGridArray.length>0,me.currentProgram=Ft,me.uniformsList=null,Ft}function Bn(A){if(A.uniformsList===null){let ae=A.currentProgram.getUniforms();A.uniformsList=Tl.seqWithValue(ae.seq,A.uniforms)}return A.uniformsList}function fn(A,ae){let we=be.get(A);we.outputColorSpace=ae.outputColorSpace,we.batching=ae.batching,we.batchingColor=ae.batchingColor,we.instancing=ae.instancing,we.instancingColor=ae.instancingColor,we.instancingMorph=ae.instancingMorph,we.skinning=ae.skinning,we.morphTargets=ae.morphTargets,we.morphNormals=ae.morphNormals,we.morphColors=ae.morphColors,we.morphTargetsCount=ae.morphTargetsCount,we.numClippingPlanes=ae.numClippingPlanes,we.numIntersection=ae.numClipIntersection,we.vertexAlphas=ae.vertexAlphas,we.vertexTangents=ae.vertexTangents,we.toneMapping=ae.toneMapping}function En(A,ae){if(A.length===0)return null;if(A.length===1)return A[0].texture!==null?A[0]:null;S.setFromMatrixPosition(ae.matrixWorld);for(let we=0,me=A.length;we<me;we++){let Me=A[we];if(Me.texture!==null&&Me.boundingBox.containsPoint(S))return Me}return null}function dn(A,ae,we,me,Me){ae.isScene!==!0&&(ae=cn),De.resetTextureUnits();let et=ae.fog,Ge=me.isMeshStandardMaterial||me.isMeshLambertMaterial||me.isMeshPhongMaterial?ae.environment:null,ut=k===null?X.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:vi.workingColorSpace,Nt=me.isMeshStandardMaterial||me.isMeshLambertMaterial&&!me.envMap||me.isMeshPhongMaterial&&!me.envMap,lt=Je.get(me.envMap||Ge,Nt),It=me.vertexColors===!0&&!!we.attributes.color&&we.attributes.color.itemSize===4,Ft=!!we.attributes.tangent&&(!!me.normalMap||me.anisotropy>0),Ce=!!we.morphAttributes.position,qt=!!we.morphAttributes.normal,Qt=!!we.morphAttributes.color,sn=la;me.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(sn=X.toneMapping);let Mn=we.morphAttributes.position||we.morphAttributes.normal||we.morphAttributes.color,In=Mn!==void 0?Mn.length:0,wt=be.get(me),ri=p.state.lights;if(qe===!0&&(pt===!0||A!==te)){let Cn=A===te&&me.id===G;Gt.setState(me,A,Cn)}let xn=!1;me.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==ri.state.version||wt.outputColorSpace!==ut||Me.isBatchedMesh&&wt.batching===!1||!Me.isBatchedMesh&&wt.batching===!0||Me.isBatchedMesh&&wt.batchingColor===!0&&Me._colorsTexture===null||Me.isBatchedMesh&&wt.batchingColor===!1&&Me._colorsTexture!==null||Me.isInstancedMesh&&wt.instancing===!1||!Me.isInstancedMesh&&wt.instancing===!0||Me.isSkinnedMesh&&wt.skinning===!1||!Me.isSkinnedMesh&&wt.skinning===!0||Me.isInstancedMesh&&wt.instancingColor===!0&&Me.instanceColor===null||Me.isInstancedMesh&&wt.instancingColor===!1&&Me.instanceColor!==null||Me.isInstancedMesh&&wt.instancingMorph===!0&&Me.morphTexture===null||Me.isInstancedMesh&&wt.instancingMorph===!1&&Me.morphTexture!==null||wt.envMap!==lt||me.fog===!0&&wt.fog!==et||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==Gt.numPlanes||wt.numIntersection!==Gt.numIntersection)||wt.vertexAlphas!==It||wt.vertexTangents!==Ft||wt.morphTargets!==Ce||wt.morphNormals!==qt||wt.morphColors!==Qt||wt.toneMapping!==sn||wt.morphTargetsCount!==In||!!wt.lightProbeGrid!=p.state.lightProbeGridArray.length>0)&&(xn=!0):(xn=!0,wt.__version=me.version);let Kn=wt.currentProgram;xn===!0&&(Kn=Pn(me,ae,Me),W&&me.isNodeMaterial&&W.onUpdateProgram(me,Kn,wt));let Dt=!1,Ln=!1,Zt=!1,zn=Kn.getUniforms(),nt=wt.uniforms;if(I.useProgram(Kn.program)&&(Dt=!0,Ln=!0,Zt=!0),me.id!==G&&(G=me.id,Ln=!0),wt.needsLights){let Cn=En(p.state.lightProbeGridArray,Me);wt.lightProbeGrid!==Cn&&(wt.lightProbeGrid=Cn,Ln=!0)}if(Dt||te!==A){I.buffers.depth.getReversed()&&A.reversedDepth!==!0&&(A._reversedDepth=!0,A.updateProjectionMatrix()),zn.setValue(ne,"projectionMatrix",A.projectionMatrix),zn.setValue(ne,"viewMatrix",A.matrixWorldInverse);let wi=zn.map.cameraPosition;wi!==void 0&&wi.setValue(ne,ot.setFromMatrixPosition(A.matrixWorld)),Q.logarithmicDepthBuffer&&zn.setValue(ne,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(me.isMeshPhongMaterial||me.isMeshToonMaterial||me.isMeshLambertMaterial||me.isMeshBasicMaterial||me.isMeshStandardMaterial||me.isShaderMaterial)&&zn.setValue(ne,"isOrthographic",A.isOrthographicCamera===!0),te!==A&&(te=A,Ln=!0,Zt=!0)}if(wt.needsLights&&(ri.state.sunShadowMap.length>0&&zn.setValue(ne,"sunShadowMap",ri.state.sunShadowMap,De),ri.state.directionalShadowMap.length>0&&zn.setValue(ne,"directionalShadowMap",ri.state.directionalShadowMap,De),ri.state.spotShadowMap.length>0&&zn.setValue(ne,"spotShadowMap",ri.state.spotShadowMap,De),ri.state.pointShadowMap.length>0&&zn.setValue(ne,"pointShadowMap",ri.state.pointShadowMap,De)),Me.isSkinnedMesh){zn.setOptional(ne,Me,"bindMatrix"),zn.setOptional(ne,Me,"bindMatrixInverse");let Cn=Me.skeleton;Cn&&(Cn.boneTexture===null&&Cn.computeBoneTexture(),zn.setValue(ne,"boneTexture",Cn.boneTexture,De))}Me.isBatchedMesh&&(zn.setOptional(ne,Me,"batchingTexture"),zn.setValue(ne,"batchingTexture",Me._matricesTexture,De),zn.setOptional(ne,Me,"batchingIdTexture"),zn.setValue(ne,"batchingIdTexture",Me._indirectTexture,De),zn.setOptional(ne,Me,"batchingColorTexture"),Me._colorsTexture!==null&&zn.setValue(ne,"batchingColorTexture",Me._colorsTexture,De));let Vn=we.morphAttributes;if((Vn.position!==void 0||Vn.normal!==void 0||Vn.color!==void 0)&&he.update(Me,we,Kn),(Ln||wt.receiveShadow!==Me.receiveShadow)&&(wt.receiveShadow=Me.receiveShadow,zn.setValue(ne,"receiveShadow",Me.receiveShadow)),(me.isMeshStandardMaterial||me.isMeshLambertMaterial||me.isMeshPhongMaterial)&&me.envMap===null&&ae.environment!==null&&(nt.envMapIntensity.value=ae.environmentIntensity),nt.dfgLUT!==void 0&&(nt.dfgLUT.value=Ww()),Ln){if(zn.setValue(ne,"toneMappingExposure",X.toneMappingExposure),wt.needsLights&&di(nt,Zt),et&&me.fog===!0&&Rt.refreshFogUniforms(nt,et),Rt.refreshMaterialUniforms(nt,me,re,se,p.state.transmissionRenderTarget[A.id]),wt.needsLights&&wt.lightProbeGrid){let Cn=wt.lightProbeGrid;nt.probesSH.value=Cn.texture,nt.probesMin.value.copy(Cn.boundingBox.min),nt.probesMax.value.copy(Cn.boundingBox.max),nt.probesResolution.value.copy(Cn.resolution)}Tl.upload(ne,Bn(wt),nt,De)}if(me.isShaderMaterial&&me.uniformsNeedUpdate===!0&&(Tl.upload(ne,Bn(wt),nt,De),me.uniformsNeedUpdate=!1),me.isSpriteMaterial&&zn.setValue(ne,"center",Me.center),zn.setValue(ne,"modelViewMatrix",Me.modelViewMatrix),zn.setValue(ne,"normalMatrix",Me.normalMatrix),zn.setValue(ne,"modelMatrix",Me.matrixWorld),me.uniformsGroups!==void 0){let Cn=me.uniformsGroups;for(let wi=0,fi=Cn.length;wi<fi;wi++){let xr=Cn[wi];We.update(xr,Kn),We.bind(xr,Kn)}}return Kn}function di(A,ae){A.ambientLightColor.needsUpdate=ae,A.lightProbe.needsUpdate=ae,A.sunLights.needsUpdate=ae,A.sunLightShadows.needsUpdate=ae,A.directionalLights.needsUpdate=ae,A.directionalLightShadows.needsUpdate=ae,A.pointLights.needsUpdate=ae,A.pointLightShadows.needsUpdate=ae,A.spotLights.needsUpdate=ae,A.spotLightShadows.needsUpdate=ae,A.rectAreaLights.needsUpdate=ae,A.hemisphereLights.needsUpdate=ae}function ii(A){return A.isMeshLambertMaterial||A.isMeshToonMaterial||A.isMeshPhongMaterial||A.isMeshStandardMaterial||A.isShadowMaterial||A.isShaderMaterial&&A.lights===!0}this.getActiveCubeFace=function(){return q},this.getActiveMipmapLevel=function(){return ce},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(A,ae,we){let me=be.get(A);me.__autoAllocateDepthBuffer=A.resolveDepthBuffer===!1,me.__autoAllocateDepthBuffer===!1&&(me.__useRenderToTexture=!1),be.get(A.texture).__webglTexture=ae,be.get(A.depthTexture).__webglTexture=me.__autoAllocateDepthBuffer?void 0:we,me.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(A,ae){let we=be.get(A);we.__webglFramebuffer=ae,we.__useDefaultFramebuffer=ae===void 0},this.setRenderTarget=function(A,ae=0,we=0){k=A,q=ae,ce=we;let me=null,Me=!1,et=!1;if(A){let ut=be.get(A);if(ut.__useDefaultFramebuffer!==void 0){I.bindFramebuffer(ne.FRAMEBUFFER,ut.__webglFramebuffer),le.copy(A.viewport),ge.copy(A.scissor),oe=A.scissorTest,I.viewport(le),I.scissor(ge),I.setScissorTest(oe),G=-1;return}else if(ut.__webglFramebuffer===void 0)De.setupRenderTarget(A);else if(ut.__hasExternalTextures)De.rebindTextures(A,be.get(A.texture).__webglTexture,be.get(A.depthTexture).__webglTexture);else if(A.depthBuffer){let It=A.depthTexture;if(ut.__boundDepthTexture!==It){if(It!==null&&be.has(It)&&(A.width!==It.image.width||A.height!==It.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");De.setupDepthRenderbuffer(A)}}let Nt=A.texture;(Nt.isData3DTexture||Nt.isDataArrayTexture||Nt.isCompressedArrayTexture)&&(et=!0);let lt=be.get(A).__webglFramebuffer;A.isWebGLCubeRenderTarget?(Array.isArray(lt[ae])?me=lt[ae][we]:me=lt[ae],Me=!0):A.samples>0&&De.useMultisampledRTT(A)===!1?me=be.get(A).__webglMultisampledFramebuffer:Array.isArray(lt)?me=lt[we]:me=lt,le.copy(A.viewport),ge.copy(A.scissor),oe=A.scissorTest}else le.copy(xe).multiplyScalar(re).floor(),ge.copy(Ye).multiplyScalar(re).floor(),oe=mt;if(we!==0&&(me=C),I.bindFramebuffer(ne.FRAMEBUFFER,me)&&I.drawBuffers(A,me),I.viewport(le),I.scissor(ge),I.setScissorTest(oe),Me){let ut=be.get(A.texture);ne.framebufferTexture2D(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_CUBE_MAP_POSITIVE_X+ae,ut.__webglTexture,we)}else if(et){let ut=ae;for(let Nt=0;Nt<A.textures.length;Nt++){let lt=be.get(A.textures[Nt]);ne.framebufferTextureLayer(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0+Nt,lt.__webglTexture,we,ut)}}else if(A!==null&&we!==0){let ut=be.get(A.texture);ne.framebufferTexture2D(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_2D,ut.__webglTexture,we)}G=-1};function si(A){let ae=be.get(A);return(ae.__readFormat!==A.format||ae.__readType!==A.type)&&(ae.__readFormat=A.format,ae.__readType=A.type,ae.__formatReadable=Q.textureFormatReadable(A.format),ae.__typeReadable=Q.textureTypeReadable(A.type)),ae}this.readRenderTargetPixels=function(A,ae,we,me,Me,et,Ge,ut=0){if(!(A&&A.isWebGLRenderTarget)){On("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Nt=be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ge!==void 0&&(Nt=Nt[Ge]),Nt){I.bindFramebuffer(ne.FRAMEBUFFER,Nt);try{let lt=A.textures[ut],It=lt.format,Ft=lt.type;A.textures.length>1&&ne.readBuffer(ne.COLOR_ATTACHMENT0+ut);let Ce=si(lt);if(Ce.__formatReadable===!1){On("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ce.__typeReadable===!1){On("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ae>=0&&ae<=A.width-me&&we>=0&&we<=A.height-Me&&ne.readPixels(ae,we,me,Me,gt.convert(It),gt.convert(Ft),et)}finally{let lt=k!==null?be.get(k).__webglFramebuffer:null;I.bindFramebuffer(ne.FRAMEBUFFER,lt)}}},this.readRenderTargetPixelsAsync=async function(A,ae,we,me,Me,et,Ge,ut=0){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Nt=be.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&Ge!==void 0&&(Nt=Nt[Ge]),Nt)if(ae>=0&&ae<=A.width-me&&we>=0&&we<=A.height-Me){I.bindFramebuffer(ne.FRAMEBUFFER,Nt);let lt=A.textures[ut],It=lt.format,Ft=lt.type;A.textures.length>1&&ne.readBuffer(ne.COLOR_ATTACHMENT0+ut);let Ce=si(lt);if(Ce.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ce.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let qt=ne.createBuffer();ne.bindBuffer(ne.PIXEL_PACK_BUFFER,qt),ne.bufferData(ne.PIXEL_PACK_BUFFER,et.byteLength,ne.STREAM_READ),ne.readPixels(ae,we,me,Me,gt.convert(It),gt.convert(Ft),0),ne.bindBuffer(ne.PIXEL_PACK_BUFFER,null);let Qt=k!==null?be.get(k).__webglFramebuffer:null;I.bindFramebuffer(ne.FRAMEBUFFER,Qt);let sn=ne.fenceSync(ne.SYNC_GPU_COMMANDS_COMPLETE,0);return ne.flush(),await A0(ne,sn,4),ne.bindBuffer(ne.PIXEL_PACK_BUFFER,qt),ne.getBufferSubData(ne.PIXEL_PACK_BUFFER,0,et),ne.bindBuffer(ne.PIXEL_PACK_BUFFER,null),ne.deleteBuffer(qt),ne.deleteSync(sn),et}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(A,ae=null,we=0){let me=Math.pow(2,-we),Me=Math.floor(A.image.width*me),et=Math.floor(A.image.height*me),Ge=ae!==null?ae.x:0,ut=ae!==null?ae.y:0;De.setTexture2D(A,0),ne.copyTexSubImage2D(ne.TEXTURE_2D,we,0,0,Ge,ut,Me,et),I.unbindTexture()},this.copyTextureToTexture=function(A,ae,we=null,me=null,Me=0,et=0){let Ge,ut,Nt,lt,It,Ft,Ce,qt,Qt,sn=A.isCompressedTexture?A.mipmaps[et]:A.image;if(we!==null)Ge=we.max.x-we.min.x,ut=we.max.y-we.min.y,Nt=we.isBox3?we.max.z-we.min.z:1,lt=we.min.x,It=we.min.y,Ft=we.isBox3?we.min.z:0;else{let nt=Math.pow(2,-Me);Ge=Math.floor(sn.width*nt),ut=Math.floor(sn.height*nt),A.isDataArrayTexture?Nt=sn.depth:A.isData3DTexture?Nt=Math.floor(sn.depth*nt):Nt=1,lt=0,It=0,Ft=0}me!==null?(Ce=me.x,qt=me.y,Qt=me.z):(Ce=0,qt=0,Qt=0);let Mn=gt.convert(ae.format),In=gt.convert(ae.type),wt;ae.isData3DTexture?(De.setTexture3D(ae,0),wt=ne.TEXTURE_3D):ae.isDataArrayTexture||ae.isCompressedArrayTexture?(De.setTexture2DArray(ae,0),wt=ne.TEXTURE_2D_ARRAY):(De.setTexture2D(ae,0),wt=ne.TEXTURE_2D),I.activeTexture(ne.TEXTURE0),I.pixelStorei(ne.UNPACK_FLIP_Y_WEBGL,ae.flipY),I.pixelStorei(ne.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ae.premultiplyAlpha),I.pixelStorei(ne.UNPACK_ALIGNMENT,ae.unpackAlignment);let ri=I.getParameter(ne.UNPACK_ROW_LENGTH),xn=I.getParameter(ne.UNPACK_IMAGE_HEIGHT),Kn=I.getParameter(ne.UNPACK_SKIP_PIXELS),Dt=I.getParameter(ne.UNPACK_SKIP_ROWS),Ln=I.getParameter(ne.UNPACK_SKIP_IMAGES);I.pixelStorei(ne.UNPACK_ROW_LENGTH,sn.width),I.pixelStorei(ne.UNPACK_IMAGE_HEIGHT,sn.height),I.pixelStorei(ne.UNPACK_SKIP_PIXELS,lt),I.pixelStorei(ne.UNPACK_SKIP_ROWS,It),I.pixelStorei(ne.UNPACK_SKIP_IMAGES,Ft);let Zt=A.isDataArrayTexture||A.isData3DTexture,zn=ae.isDataArrayTexture||ae.isData3DTexture;if(A.isDepthTexture){let nt=be.get(A),Vn=be.get(ae),Cn=be.get(nt.__renderTarget),wi=be.get(Vn.__renderTarget);I.bindFramebuffer(ne.READ_FRAMEBUFFER,Cn.__webglFramebuffer),I.bindFramebuffer(ne.DRAW_FRAMEBUFFER,wi.__webglFramebuffer);for(let fi=0;fi<Nt;fi++)Zt&&(ne.framebufferTextureLayer(ne.READ_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,be.get(A).__webglTexture,Me,Ft+fi),ne.framebufferTextureLayer(ne.DRAW_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,be.get(ae).__webglTexture,et,Qt+fi)),ne.blitFramebuffer(lt,It,Ge,ut,Ce,qt,Ge,ut,ne.DEPTH_BUFFER_BIT,ne.NEAREST);I.bindFramebuffer(ne.READ_FRAMEBUFFER,null),I.bindFramebuffer(ne.DRAW_FRAMEBUFFER,null)}else if(Me!==0||A.isRenderTargetTexture||be.has(A)){let nt=be.get(A),Vn=be.get(ae);I.bindFramebuffer(ne.READ_FRAMEBUFFER,M),I.bindFramebuffer(ne.DRAW_FRAMEBUFFER,J);for(let Cn=0;Cn<Nt;Cn++)Zt?ne.framebufferTextureLayer(ne.READ_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,nt.__webglTexture,Me,Ft+Cn):ne.framebufferTexture2D(ne.READ_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_2D,nt.__webglTexture,Me),zn?ne.framebufferTextureLayer(ne.DRAW_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,Vn.__webglTexture,et,Qt+Cn):ne.framebufferTexture2D(ne.DRAW_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_2D,Vn.__webglTexture,et),Me!==0?ne.blitFramebuffer(lt,It,Ge,ut,Ce,qt,Ge,ut,ne.COLOR_BUFFER_BIT,ne.NEAREST):zn?ne.copyTexSubImage3D(wt,et,Ce,qt,Qt+Cn,lt,It,Ge,ut):ne.copyTexSubImage2D(wt,et,Ce,qt,lt,It,Ge,ut);I.bindFramebuffer(ne.READ_FRAMEBUFFER,null),I.bindFramebuffer(ne.DRAW_FRAMEBUFFER,null)}else zn?A.isDataTexture||A.isData3DTexture?ne.texSubImage3D(wt,et,Ce,qt,Qt,Ge,ut,Nt,Mn,In,sn.data):ae.isCompressedArrayTexture?ne.compressedTexSubImage3D(wt,et,Ce,qt,Qt,Ge,ut,Nt,Mn,sn.data):ne.texSubImage3D(wt,et,Ce,qt,Qt,Ge,ut,Nt,Mn,In,sn):A.isDataTexture?ne.texSubImage2D(ne.TEXTURE_2D,et,Ce,qt,Ge,ut,Mn,In,sn.data):A.isCompressedTexture?ne.compressedTexSubImage2D(ne.TEXTURE_2D,et,Ce,qt,sn.width,sn.height,Mn,sn.data):ne.texSubImage2D(ne.TEXTURE_2D,et,Ce,qt,Ge,ut,Mn,In,sn);I.pixelStorei(ne.UNPACK_ROW_LENGTH,ri),I.pixelStorei(ne.UNPACK_IMAGE_HEIGHT,xn),I.pixelStorei(ne.UNPACK_SKIP_PIXELS,Kn),I.pixelStorei(ne.UNPACK_SKIP_ROWS,Dt),I.pixelStorei(ne.UNPACK_SKIP_IMAGES,Ln),et===0&&ae.generateMipmaps&&ne.generateMipmap(wt),I.unbindTexture()},this.initRenderTarget=function(A){be.get(A).__webglFramebuffer===void 0&&De.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?De.setTextureCube(A,0):A.isData3DTexture?De.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?De.setTexture2DArray(A,0):De.setTexture2D(A,0),I.unbindTexture()},this.resetState=function(){q=0,ce=0,k=null,I.reset(),Ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ba}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=vi._getDrawingBufferColorSpace(e),t.unpackColorSpace=vi._getUnpackColorSpace()}};var Zc=function(){return Zc=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Zc.apply(this,arguments)},Tf=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Xw=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},yr=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Yw={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5126:Float32Array},qw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT4:16},dg={POSITION:"position",NORMAL:"normal",COLOR_0:"color",TEXCOORD_0:"uv",JOINTS_0:"skinIndex",WEIGHTS_0:"skinWeight"},fg={33071:Ta,33648:el,10497:Vs},hg={9728:ar,9729:fr,9984:Ld,9985:_l,9986:xo,9987:ns};function Wr(n){if(!n)throw Error("E_MODEL_CORRUPT")}function Zw(n,e,t){var i,r,a,s=Yw[t.componentType],o=qw[t.type];Wr(s&&o&&e&&!t.sparse);var u=s.BYTES_PER_ELEMENT,l=o*u,d=(i=e.byteStride)!==null&&i!==void 0?i:l,f=(r=t.byteOffset)!==null&&r!==void 0?r:0,h=((a=e.byteOffset)!==null&&a!==void 0?a:0)+f,m=t.count;Wr(Number.isSafeInteger(m)&&m>0&&f>=0&&h>=0&&d>=l&&d%u===0&&h%u===0&&f+(m-1)*d+l<=e.byteLength&&h+(m-1)*d+l<=n.length);var x=new s(n.buffer,n.byteOffset+h,((m-1)*d+l)/u);if(d===l)return new Vr(x,o,!!t.normalized);for(var _=new s(m*o),g=0;g<m;g++){var v=g*d/u;_.set(x.subarray(v,v+o),g*o)}return new Vr(_,o,!!t.normalized)}function Jw(n,e,t){for(var i="",r=0;r<n.length;r+=8192)i+=String.fromCharCode.apply(String,Xw([],Tf(n.subarray(r,r+8192)),!1));var a=new Image;return a.onload=function(){return t(!0)},a.onerror=function(){return t(!1)},a.src="data:"+e+";base64,"+btoa(i),a}function yg(n,e){var t,i,r,a,s,o,u,l,d,f,h,m,x,_,g,v,F,P,S,N,p,L,E,D,X,Y,W,C,M;Wr(n.byteLength>=28&&n.byteLength<=7e5);var J=new DataView(n.buffer,n.byteOffset,n.byteLength),q=function(rt){return J.getUint32(rt,!0)};Wr(q(0)===1179937895&&q(4)===2&&q(8)===n.byteLength&&q(16)===1313821514);var ce=20+q(12);Wr(ce%4===0&&ce+8<=n.byteLength&&q(ce+4)===5130562&&q(ce)===n.byteLength-ce-8);var k=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n.subarray(20,ce)));Wr(((x=k.asset)===null||x===void 0?void 0:x.version)==="2.0"&&((_=k.buffers)===null||_===void 0?void 0:_.length)===1&&k.buffers[0].uri===void 0&&((v=(g=k.skins)===null||g===void 0?void 0:g.length)!==null&&v!==void 0?v:0)<=4&&((P=(F=k.animations)===null||F===void 0?void 0:F.length)!==null&&P!==void 0?P:0)<=16);var G=n.subarray(ce+8),te=new Map,le=new Map,ge=new Map,oe=new Map,$=new Set,Te=new Set;function Le(rt){if(!ge.has(rt)){var Ut=k.accessors[rt];ge.set(rt,Zw(G,k.bufferViews[Ut.bufferView],Ut))}return ge.get(rt)}function se(rt,Ut){var an,hn,en,Ht,yn,bn,Yt,Ot,$n,Xn,Nn,ni;if(!rt)return null;var wn=(hn=(an=rt.extensions)===null||an===void 0?void 0:an.KHR_texture_transform)!==null&&hn!==void 0?hn:{};Wr(((Ht=(en=wn.texCoord)!==null&&en!==void 0?en:rt.texCoord)!==null&&Ht!==void 0?Ht:0)===0);var Pn=JSON.stringify([rt.index,Ut,wn]);if(te.has(Pn))return te.get(Pn);var Bn=k.textures[rt.index],fn=k.images[Bn.source],En=(bn=(yn=k.samplers)===null||yn===void 0?void 0:yn[Bn.sampler])!==null&&bn!==void 0?bn:{},dn=new Cr;if(dn.colorSpace=Ut,dn.flipY=!1,dn.wrapS=fg[(Yt=En.wrapS)!==null&&Yt!==void 0?Yt:10497],dn.wrapT=fg[(Ot=En.wrapT)!==null&&Ot!==void 0?Ot:10497],dn.magFilter=hg[($n=En.magFilter)!==null&&$n!==void 0?$n:9729],dn.minFilter=hg[(Xn=En.minFilter)!==null&&Xn!==void 0?Xn:9987],wn.offset&&dn.offset.fromArray(wn.offset),wn.scale&&dn.repeat.fromArray(wn.scale),dn.rotation=(Nn=wn.rotation)!==null&&Nn!==void 0?Nn:0,te.set(Pn,dn),!le.has(Bn.source)){var di=k.bufferViews[fn.bufferView],ii=(ni=di?.byteOffset)!==null&&ni!==void 0?ni:0;Wr(di&&!fn.uri&&["image/png","image/jpeg"].includes(fn.mimeType)&&ii+di.byteLength<=G.length);var si={textures:[],ready:!1,failed:!1};le.set(Bn.source,si),si.image=Jw(G.subarray(ii,ii+di.byteLength),fn.mimeType,function(ae){var we,me;if(si.ready=!0,si.failed=!ae,ae)try{for(var Me=yr(si.textures),et=Me.next();!et.done;et=Me.next()){var Ge=et.value;Ge.needsUpdate=!0}}catch(ut){we={error:ut}}finally{try{et&&!et.done&&(me=Me.return)&&me.call(Me)}finally{if(we)throw we.error}}e?.()})}var A=le.get(Bn.source);return dn.image=A.image,A.textures.push(dn),A.ready&&!A.failed&&(dn.needsUpdate=!0),dn}var re=new Map;function Ie(rt,Ut){var an,hn,en,Ht,yn,bn,Yt,Ot,$n,Xn,Nn,ni,wn,Pn,Bn,fn,En,dn,di=String(rt)+"/"+Ut;if(re.has(di))return re.get(di);var ii=(hn=(an=k.materials)===null||an===void 0?void 0:an[rt])!==null&&hn!==void 0?hn:{},si=(en=ii.pbrMetallicRoughness)!==null&&en!==void 0?en:{},A=(Ht=si.baseColorFactor)!==null&&Ht!==void 0?Ht:[1,1,1,1],ae=(yn=ii.alphaMode)!==null&&yn!==void 0?yn:"OPAQUE",we={name:(bn=ii.name)!==null&&bn!==void 0?bn:"",color:new Wn().fromArray(A),vertexColors:Ut,map:se(si.baseColorTexture,Ir),side:ii.doubleSided?Gr:es,opacity:ae==="OPAQUE"?1:A[3],transparent:ae==="BLEND",depthWrite:ae!=="BLEND",alphaTest:ae==="MASK"?(Yt=ii.alphaCutoff)!==null&&Yt!==void 0?Yt:.5:0},me;if(!((Ot=ii.extensions)===null||Ot===void 0)&&Ot.KHR_materials_unlit)me=new oa(we);else{var Me=se(si.metallicRoughnessTexture,ta);me=new ml(Zc(Zc({},we),{roughness:($n=si.roughnessFactor)!==null&&$n!==void 0?$n:1,metalness:(Xn=si.metallicFactor)!==null&&Xn!==void 0?Xn:1,roughnessMap:Me,metalnessMap:Me,normalMap:se(ii.normalTexture,ta),normalScale:new ln().setScalar((ni=(Nn=ii.normalTexture)===null||Nn===void 0?void 0:Nn.scale)!==null&&ni!==void 0?ni:1),aoMap:se(ii.occlusionTexture,ta),aoMapIntensity:(Pn=(wn=ii.occlusionTexture)===null||wn===void 0?void 0:wn.strength)!==null&&Pn!==void 0?Pn:1,emissive:new Wn().fromArray((Bn=ii.emissiveFactor)!==null&&Bn!==void 0?Bn:[0,0,0]),emissiveMap:se(ii.emissiveTexture,Ir),emissiveIntensity:(dn=(En=(fn=ii.extensions)===null||fn===void 0?void 0:fn.KHR_materials_emissive_strength)===null||En===void 0?void 0:En.emissiveStrength)!==null&&dn!==void 0?dn:1})),me.normalScale.y*=-1}return Te.add(me),re.set(di,me),me}var ke=k.meshes.map(function(rt){return rt.primitives.map(function(Ut){var an,hn,en;Wr(((en=Ut.mode)!==null&&en!==void 0?en:4)===4&&Ut.attributes.POSITION!==void 0&&!Ut.targets);var Ht=new pr;try{for(var yn=yr(Object.entries(Ut.attributes)),bn=yn.next();!bn.done;bn=yn.next()){var Yt=Tf(bn.value,2),Ot=Yt[0],$n=Yt[1];Wr(Object.hasOwn(dg,Ot)),Ht.setAttribute(dg[Ot],Le($n))}}catch(Xn){an={error:Xn}}finally{try{bn&&!bn.done&&(hn=yn.return)&&hn.call(yn)}finally{if(an)throw an.error}}return Ut.indices!==void 0&&Ht.setIndex(Le(Ut.indices)),Ht.attributes.normal||Ht.computeVertexNormals(),$.add(Ht),{geo:Ht,mat:Ie(Ut.material,!!Ht.attributes.color)}})}),xe=new Set;try{for(var Ye=yr((S=k.skins)!==null&&S!==void 0?S:[]),mt=Ye.next();!mt.done;mt=Ye.next()){var He=mt.value;try{for(var qe=(r=void 0,yr((N=He.joints)!==null&&N!==void 0?N:[])),pt=qe.next();!pt.done;pt=qe.next()){var at=pt.value;xe.add(at)}}catch(rt){r={error:rt}}finally{try{pt&&!pt.done&&(a=qe.return)&&a.call(qe)}finally{if(r)throw r.error}}}}catch(rt){t={error:rt}}finally{try{mt&&!mt.done&&(i=Ye.return)&&i.call(Ye)}finally{if(t)throw t.error}}var ot=new dr,Vt=new Set,cn=new Map,Ze=[];function pn(rt,Ut){var an,hn,en,Ht,yn,bn;Wr(!Vt.has(rt)&&Vt.size<128),Vt.add(rt);var Yt=k.nodes[rt],Ot=xe.has(rt)?new ol:new dr;if(Ot.name=(yn=Yt.name)!==null&&yn!==void 0?yn:"",Ot.userData.gltfNodeIndex=rt,cn.set(rt,Ot),Ot.name&&!oe.has(Ot.name)&&oe.set(Ot.name,Ot),Yt.matrix?Ot.matrix.fromArray(Yt.matrix).decompose(Ot.position,Ot.quaternion,Ot.scale):(Yt.translation&&Ot.position.fromArray(Yt.translation),Yt.rotation&&Ot.quaternion.fromArray(Yt.rotation),Yt.scale&&Ot.scale.fromArray(Yt.scale)),Ut.add(Ot),Yt.mesh!==void 0)try{for(var $n=yr(ke[Yt.mesh]),Xn=$n.next();!Xn.done;Xn=$n.next()){var Nn=Xn.value,ni=Nn.geo,wn=Nn.mat;if(Yt.skin!==void 0){var Pn=new mc(ni,wn);Pn.userData.gltfSkinIndex=Yt.skin,Ot.add(Pn),Ze.push(Pn)}else Ot.add(new bi(ni,wn))}}catch(dn){an={error:dn}}finally{try{Xn&&!Xn.done&&(hn=$n.return)&&hn.call($n)}finally{if(an)throw an.error}}try{for(var Bn=yr((bn=Yt.children)!==null&&bn!==void 0?bn:[]),fn=Bn.next();!fn.done;fn=Bn.next()){var En=fn.value;pn(En,Ot)}}catch(dn){en={error:dn}}finally{try{fn&&!fn.done&&(Ht=Bn.return)&&Ht.call(Bn)}finally{if(en)throw en.error}}}try{for(var ne=yr((L=k.scenes[(p=k.scene)!==null&&p!==void 0?p:0].nodes)!==null&&L!==void 0?L:[]),Tn=ne.next();!Tn.done;Tn=ne.next()){var gn=Tn.value;pn(gn,ot)}}catch(rt){s={error:rt}}finally{try{Tn&&!Tn.done&&(o=ne.return)&&o.call(ne)}finally{if(s)throw s.error}}ot.updateMatrixWorld(!0);var Q=((E=k.skins)!==null&&E!==void 0?E:[]).map(function(rt){var Ut,an=(Ut=rt.joints)!==null&&Ut!==void 0?Ut:[];Wr(an.length>0&&an.length<=64);var hn;if(rt.inverseBindMatrices!==void 0){var en=Le(rt.inverseBindMatrices).array;hn=Array.from({length:an.length},function(Ht,yn){return new Jn().fromArray(en,yn*16)})}else hn=an.map(function(){return new Jn});return{joints:an,inverseBindMatrices:hn}});try{for(var I=yr(Ze),ie=I.next();!ie.done;ie=I.next()){var be=ie.value,De=Q[be.userData.gltfSkinIndex];Wr(De);var Je=De.joints.map(function(rt){return cn.get(rt)});Wr(Je.every(Boolean)),be.bind(new ll(Je,De.inverseBindMatrices.map(function(rt){return rt.clone()})),new Jn)}}catch(rt){u={error:rt}}finally{try{ie&&!ie.done&&(l=I.return)&&l.call(I)}finally{if(u)throw u.error}}var je=[],Ne=new Map;try{for(var Pe=yr(((D=k.animations)!==null&&D!==void 0?D:[]).entries()),it=Pe.next();!it.done;it=Pe.next()){var Rt=Tf(it.value,2),Mt=Rt[0],ct=Rt[1],Gt=ct.name||"clip_"+Mt,Kt=[],nn=0;try{for(var he=(h=void 0,yr((X=ct.channels)!==null&&X!==void 0?X:[])),dt=he.next();!dt.done;dt=he.next()){var Ee=dt.value,gt=(Y=Ee.target)===null||Y===void 0?void 0:Y.node,Ke=(W=Ee.target)===null||W===void 0?void 0:W.path;if(!(gt===void 0||!["translation","rotation","scale"].includes(Ke))){var We=(C=ct.samplers)===null||C===void 0?void 0:C[Ee.sampler];Wr(We);var Wt=(M=We.interpolation)!==null&&M!==void 0?M:"LINEAR";Wr(Wt==="LINEAR"||Wt==="STEP");var Lt=Le(We.input).array,yt=Le(We.output).array;Lt.length&&(nn=Math.max(nn,Lt[Lt.length-1])),Kt.push({nodeIndex:gt,path:Ke,interp:Wt,times:Lt,values:yt})}}}catch(rt){h={error:rt}}finally{try{dt&&!dt.done&&(m=he.return)&&m.call(he)}finally{if(h)throw h.error}}var Et={name:Gt,duration:nn,tracks:Kt};je.push(Et),Ne.has(Gt)||Ne.set(Gt,Et)}}catch(rt){d={error:rt}}finally{try{it&&!it.done&&(f=Pe.return)&&f.call(Pe)}finally{if(d)throw d.error}}return{root:ot,nodesByName:oe,skins:Q,animations:je,animationsByName:Ne,geometries:$,materials:Te,textures:te,imageStatus:function(){var rt,Ut,an=0,hn=0;try{for(var en=yr(le.values()),Ht=en.next();!Ht.done;Ht=en.next()){var yn=Ht.value;yn.ready||an++,yn.failed&&hn++}}catch(bn){rt={error:bn}}finally{try{Ht&&!Ht.done&&(Ut=en.return)&&Ut.call(en)}finally{if(rt)throw rt.error}}return{texturesPending:an,textureErrors:hn}}}}function $w(n,e,t){var i,r,a,s,o,u,l,d,f,h,m,x,_=(o=e.materialMode)!==null&&o!==void 0?o:"asset",g=!e.overrideMaterialName||n.name===e.overrideMaterialName,v=g&&Object.keys(t).length>0;if(_==="asset"&&!v&&((u=e.opacity)!==null&&u!==void 0?u:1)===1&&(!e.tintColor||e.tintColor==="#ffffff")&&((l=e.roughnessScale)!==null&&l!==void 0?l:1)===1&&((d=e.metalnessScale)!==null&&d!==void 0?d:1)===1)return n;var F={lambert:mr,unlit:oa,standard:ml}[_],P;if(!F||n.constructor===F)P=n.clone();else{P=new F;try{for(var S=yr(["name","map","alphaTest","transparent","opacity","side","depthWrite","vertexColors","roughness","metalness","roughnessMap","metalnessMap","normalMap","aoMap","aoMapIntensity","emissiveMap","emissiveIntensity"]),N=S.next();!N.done;N=S.next()){var p=N.value;p in P&&p in n&&(P[p]=n[p])}}catch(D){i={error:D}}finally{try{N&&!N.done&&(r=S.return)&&r.call(S)}finally{if(i)throw i.error}}try{for(var L=yr(["color","emissive","normalScale"]),E=L.next();!E.done;E=L.next()){var p=E.value;P[p]&&n[p]&&P[p].copy(n[p])}}catch(D){a={error:D}}finally{try{E&&!E.done&&(s=L.return)&&s.call(L)}finally{if(a)throw a.error}}}return e.tintColor&&P.color.multiply(new Wn(e.tintColor)),P.opacity*=(f=e.opacity)!==null&&f!==void 0?f:1,P.opacity<1&&((h=e.opacity)!==null&&h!==void 0?h:1)<1&&(P.transparent=!0,P.depthWrite=!1),P.isMeshStandardMaterial&&(P.roughness=Math.min(1,P.roughness*((m=e.roughnessScale)!==null&&m!==void 0?m:1)),P.metalness=Math.min(1,P.metalness*((x=e.metalnessScale)!==null&&x!==void 0?x:1))),v&&(t.texture&&(P.map=t.texture),t.normalMap&&"normalMap"in P&&(P.normalMap=t.normalMap),t.emissiveMap&&"emissiveMap"in P&&(P.emissiveMap=t.emissiveMap)),P}function xg(n,e,t){var i,r,a;e===void 0&&(e={}),t===void 0&&(t={});var s=e.subNode?n.nodesByName.get(e.subNode):n.root;if(!s)throw Error("E_MODEL_SUBNODE "+e.subNode);var o=s.clone(!0),u=new dr,l=new Map;if(e.subNode&&(o.position.set(0,0,0),s.parent)){var d=s.parent.matrixWorld.clone().setPosition(0,0,0);o.updateMatrix(),o.matrix.premultiply(d),o.matrixAutoUpdate=!1}u.add(o);var f=new Map,h=[];if(o.traverse(function(p){var L,E;if(((L=p.userData)===null||L===void 0?void 0:L.gltfNodeIndex)!==void 0&&f.set(p.userData.gltfNodeIndex,p),!!p.isMesh){var D=p.material;l.has(D)||l.set(D,$w(D,e,t)),p.material=l.get(D),p.castShadow=!!e.castShadow,p.receiveShadow=!!e.receiveShadow,p.isSkinnedMesh&&((E=p.userData)===null||E===void 0?void 0:E.gltfSkinIndex)!==void 0&&h.push(p)}}),h.length){u.updateMatrixWorld(!0);try{for(var m=yr(h),x=m.next();!x.done;x=m.next()){var _=x.value,g=(a=n.skins)===null||a===void 0?void 0:a[_.userData.gltfSkinIndex];if(g){var v=g.joints.map(function(p){return f.get(p)}).filter(Boolean);v.length===g.joints.length&&_.bind(new ll(v,g.inverseBindMatrices.map(function(p){return p.clone()})),new Jn)}}}catch(p){i={error:p}}finally{try{x&&!x.done&&(r=m.return)&&r.call(m)}finally{if(i)throw i.error}}}u.userData.clonedByIndex=f,u.userData.template=n;var F=new Qr().setFromObject(u,!0);if(!F.isEmpty()){var P=F.getSize(new Se),S=new Se,N=Math.max(P.x,P.y,P.z);(e.pivotMode==="center"||e.pivotMode==="bottom-center")&&(F.getCenter(S),e.pivotMode==="bottom-center"&&(S.y=F.min.y)),e.normalizeSize>0&&N>0&&u.scale.setScalar(e.normalizeSize/N),u.position.copy(S).multiplyScalar(-u.scale.x),u.userData.modelBounds={width:P.x*u.scale.x,height:P.y*u.scale.y,depth:P.z*u.scale.z}}return u}var qp=new Se,pg=new Se,Zp=new aa,mg=new aa;function vg(n,e,t,i){var r=n.times,a=n.values,s=r.length,o=n.path==="rotation"?4:3;if(s!==0){var u=0,l=0,d=0;if(s>1&&e>r[0])if(e>=r[s-1])u=l=s-1;else{for(var f=0,h=s-1;f+1<h;){var m=f+h>>1;r[m]<=e?f=m:h=m}u=f,l=h,d=n.interp==="STEP"?0:(e-r[u])/Math.max(1e-8,r[l]-r[u])}var x=u*o,_=l*o;if(n.path==="rotation"){if(Zp.set(a[x],a[x+1],a[x+2],a[x+3]),u===l||d===0){i.copy(Zp);return}mg.set(a[_],a[_+1],a[_+2],a[_+3]),i.copy(Zp).slerp(mg,d)}else{if(qp.set(a[x],a[x+1],a[x+2]),u===l||d===0){t.copy(qp);return}pg.set(a[_],a[_+1],a[_+2]),t.copy(qp).lerp(pg,d)}}}function gg(n,e,t){if(e<=0)return 0;if(t==="once")return Math.min(e,Math.max(0,n));if(t==="pingpong"){var i=e*2,r=(n%i+i)%i;return r<=e?r:i-r}return(n%e+e)%e}function _g(n){var e,t,i,r,a,s,o,u=(a=n?.userData)===null||a===void 0?void 0:a.template,l=(s=n?.userData)===null||s===void 0?void 0:s.clonedByIndex;if(!(!((o=u?.animations)===null||o===void 0)&&o.length)||!l)return null;var d=new Map;try{for(var f=yr(u.animations),h=f.next();!h.done;h=f.next()){var m=h.value;try{for(var x=(i=void 0,yr(m.tracks)),_=x.next();!_.done;_=x.next()){var g=_.value,v=l.get(g.nodeIndex);v&&!d.has(g.nodeIndex)&&d.set(g.nodeIndex,{pos:v.position.clone(),quat:v.quaternion.clone(),scl:v.scale.clone()})}}catch(X){i={error:X}}finally{try{_&&!_.done&&(r=x.return)&&r.call(x)}finally{if(i)throw i.error}}}}catch(X){e={error:X}}finally{try{h&&!h.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}var F=function(){var X,Y;try{for(var W=yr(d),C=W.next();!C.done;C=W.next()){var M=Tf(C.value,2),J=M[0],q=M[1],ce=l.get(J);ce&&(ce.position.copy(q.pos),ce.quaternion.copy(q.quat),ce.scale.copy(q.scl))}}catch(k){X={error:k}}finally{try{C&&!C.done&&(Y=W.return)&&Y.call(W)}finally{if(X)throw X.error}}},P=null,S=null,N=0,p=0,L=new Se,E=new aa,D=function(){var X,Y,W,C;F();var M=S&&p>0?Math.min(1,N/p):1;if(S&&M<1){var J=gg(S.time,S.clip.duration,S.loop);try{for(var q=yr(S.clip.tracks),ce=q.next();!ce.done;ce=q.next()){var k=ce.value,G=l.get(k.nodeIndex);G&&(vg(k,J,L,E),k.path==="translation"?G.position.copy(L):k.path==="rotation"?G.quaternion.copy(E):k.path==="scale"&&G.scale.copy(L))}}catch(oe){X={error:oe}}finally{try{ce&&!ce.done&&(Y=q.return)&&Y.call(q)}finally{if(X)throw X.error}}}if(P){var te=gg(P.time,P.clip.duration,P.loop);try{for(var le=yr(P.clip.tracks),ge=le.next();!ge.done;ge=le.next()){var k=ge.value,G=l.get(k.nodeIndex);G&&(vg(k,te,L,E),k.path==="translation"?M<1?G.position.lerp(L,M):G.position.copy(L):k.path==="rotation"?M<1?G.quaternion.slerp(E,M):G.quaternion.copy(E):k.path==="scale"&&(M<1?G.scale.lerp(L,M):G.scale.copy(L)))}}catch(oe){W={error:oe}}finally{try{ge&&!ge.done&&(C=le.return)&&C.call(le)}finally{if(W)throw W.error}}}};return{play:function(X,Y){var W=Y===void 0?{}:Y,C=W.loop,M=C===void 0?"repeat":C,J=W.speed,q=J===void 0?1:J,ce=W.fadeSeconds,k=ce===void 0?.15:ce,G=W.restart,te=G===void 0?!1:G,le=W.startTime,ge=le===void 0?0:le,oe=X?u.animationsByName.get(X):u.animations[0];return oe?P?.clip===oe&&!te&&P.playing?(P.loop=M,P.speed=q,!0):(S=P&&k>0?Zc({},P):null,p=S?k:0,N=0,P={clip:oe,loop:M,speed:q,time:ge,playing:!0,ended:!1},D(),!0):!1},step:function(X,Y){if(!P||!P.playing)return!1;var W=Math.max(0,X);S&&p>0&&(S.time+=W*S.speed,N+=W,N>=p&&(S=null,p=0)),P.time+=W*P.speed;var C=null;return P.loop==="once"&&P.clip.duration>0&&P.time>=P.clip.duration&&(P.time=P.clip.duration,P.playing=!1,P.ended||(P.ended=!0,C=P.clip.name)),D(),C&&Y?.(C),!0},reset:function(){P=null,S=null,N=0,p=0,F()},snapshot:function(){var X,Y,W;return{clip:(Y=(X=P?.clip)===null||X===void 0?void 0:X.name)!==null&&Y!==void 0?Y:null,time:P?Number(P.time.toFixed(4)):0,playing:!!P?.playing,loop:(W=P?.loop)!==null&&W!==void 0?W:"repeat",clips:u.animations.map(function(C){return C.name})}}}}var Jc=function(){return Jc=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Jc.apply(this,arguments)},vn=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Ga=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Mg=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function bg(n,e,t,i){for(var r,a,s,o,u,l,d,f=new Se,h=new Se,m=new Ea,x=n;x?.contract==="native.mesh3d.v1";x=e(x.parentId)){var _=t(x),g=i.get(x.id),v=g?.mode==="dynamic",F=v&&g.captured,P=F?Math.min(1,((r=g.captureElapsed)!==null&&r!==void 0?r:0)/.55):0,S=g?.captureTarget,N=1-P*.65;h.set(_.sx*N,_.sy*N,_.sz*N),m.set(v?-((a=g.spin)!==null&&a!==void 0?a:0):_.rx,g?.mode==="kinematic"?-((s=g.angle)!==null&&s!==void 0?s:_.ry):_.ry,v?((o=g.spin)!==null&&o!==void 0?o:0)*.22:_.rz),f.multiply(h).applyEuler(m),h.set(((u=g?.x)!==null&&u!==void 0?u:_.x)+(F&&S?(S.x-g.x)*P:0),((l=g?.y)!==null&&l!==void 0?l:_.y)-P*.45,((d=g?.z)!==null&&d!==void 0?d:_.z)+(F&&S?(S.z-g.z)*P:0)),f.add(h)}return{x:f.x,y:f.y,z:f.z}}function Kw(n){for(var e=atob(n),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);for(var r=new DataView(t.buffer,t.byteOffset,t.byteLength),a=r.getUint32(8,!0),s=r.getUint32(12,!0),o=new Float32Array(a*3),u=new Float32Array(a*3),l=new Float32Array(a*2),d=16,i=0;i<a;i++)o[i*3]=r.getFloat32(d,!0),o[i*3+1]=r.getFloat32(d+4,!0),o[i*3+2]=r.getFloat32(d+8,!0),u[i*3]=r.getFloat32(d+12,!0),u[i*3+1]=r.getFloat32(d+16,!0),u[i*3+2]=r.getFloat32(d+20,!0),l[i*2]=r.getFloat32(d+24,!0),l[i*2+1]=r.getFloat32(d+28,!0),d+=32;for(var f=new Uint16Array(s),i=0;i<s;i++)f[i]=r.getUint16(d+i*2,!0);var h=new pr;return h.setAttribute("position",new Ci(o,3)),h.setAttribute("normal",new Ci(u,3)),h.setAttribute("uv",new Ci(l,2)),h.setIndex(Array.from(f)),h}function Sg(n,e,t){return!n||t>=1?0:t<=-1?1.1:(1-t)*.55}function Qw(n,e,t){var i,r,a,s,o,u,l,d,f,h,m,x,_,g,v,F,P,S=new dr,N=!!n.fairwayRamp,p=(_=n.cupX)!==null&&_!==void 0?_:0,L=(g=n.cupZ)!==null&&g!==void 0?g:-4.8,E=(v=n.cupRadius)!==null&&v!==void 0?v:.23,D=new jr(1,1,1),X=new Map,Y=function(Pe,it,Rt,Mt,ct,Gt,Kt){var nn=X.get(Kt);nn||(nn=new mr({color:Kt}),X.set(Kt,nn));var he=new bi(D,nn);he.position.set(Pe,it,Rt),he.scale.set(Mt,ct,Gt),S.add(he)};try{for(var W=vn([-3.2,3.2]),C=W.next();!C.done;C=W.next()){var M=C.value;Y(M,-.65,0,.2,1.1,14.6,"#a1b8b1"),Y(M-Math.sign(M)*.1,-.18,0,.2,.25,14.4,"#e9cea5")}}catch(Pe){i={error:Pe}}finally{try{C&&!C.done&&(r=W.return)&&r.call(W)}finally{if(i)throw i.error}}try{for(var J=vn([-7.2,7.2]),q=J.next();!q.done;q=J.next()){var ce=q.value;Y(0,-.65,ce,6.4,1.1,.2,"#a1b8b1"),Y(0,-.18,ce-Math.sign(ce)*.1,6.2,.25,.2,"#e9cea5")}}catch(Pe){a={error:Pe}}finally{try{q&&!q.done&&(s=J.return)&&s.call(J)}finally{if(a)throw a.error}}var k=.5,G=.5;if(t){var te=t.getAttribute("uv"),le=t.getAttribute("normal");if(te&&le){for(var ge=0;ge<le.count&&le.getY(ge)<.9;)ge++;ge<te.count&&(k=te.getX(ge),G=te.getY(ge))}}var oe=!!(e&&(!((F=e.image)===null||F===void 0)&&F.complete)&&((P=e.image)===null||P===void 0?void 0:P.naturalWidth)>0),$=oe?new mr({map:e}):new mr({color:"#6ec458"}),Te=oe?new mr({map:e,color:"#779263"}):new mr({color:"#5a9949"});e&&!oe&&($.userData.pendingTex={tex:e,color:"#ffffff"},Te.userData.pendingTex={tex:e,color:"#779263"});var Le=N?[[-7,-1],[-1,1],[1,7]]:[[-7,7]];try{for(var se=vn(Le),re=se.next();!re.done;re=se.next()){var Ie=Ga(re.value,2),ke=Ie[0],xe=Ie[1],Ye=new fl;if(Ye.moveTo(-3,ke),Ye.lineTo(3,ke),Ye.lineTo(3,xe),Ye.lineTo(-3,xe),Ye.closePath(),L>ke&&L<xe){var mt=new mo;mt.absarc(p,L,E,0,Math.PI*2,!0),Ye.holes.push(mt)}for(var He=new Ac(Ye,32),qe=He.getAttribute("position"),pt=!1,at=!1,ot=0;ot<qe.count;ot++){var Vt=qe.getX(ot),cn=qe.getY(ot),Ze=Sg(N,Vt,cn);Ze===0&&(pt=!0),Ze>0&&(at=!0),qe.setXYZ(ot,Vt,Ze,cn)}var pn=He.getIndex();if(pn)for(var ot=0;ot<pn.count;ot+=3){var ne=pn.getX(ot+1);pn.setX(ot+1,pn.getX(ot+2)),pn.setX(ot+2,ne)}He.computeVertexNormals();for(var Tn=He.getAttribute("uv"),ot=0;ot<Tn.count;ot++)Tn.setXY(ot,k,G);var gn=new bi(He,N&&pt&&at?Te:$);gn.name="continuous-fairway",S.add(gn)}}catch(Pe){o={error:Pe}}finally{try{re&&!re.done&&(u=se.return)&&u.call(se)}finally{if(o)throw o.error}}var Q="#d69260",I="#f1bd87";try{for(var ie=vn([-3.1,3.1]),be=ie.next();!be.done;be=ie.next()){var M=be.value;Y(M,.12,0,.2,.3,14.2,Q),Y(M,.29,0,.22,.04,14.2,I)}}catch(Pe){l={error:Pe}}finally{try{be&&!be.done&&(d=ie.return)&&d.call(ie)}finally{if(l)throw l.error}}try{for(var De=vn([-7.1,7.1]),Je=De.next();!Je.done;Je=De.next()){var ce=Je.value;Y(0,Sg(N,0,ce>0?6:-6)+.12,ce,6.4,.3,.2,Q)}}catch(Pe){f={error:Pe}}finally{try{Je&&!Je.done&&(h=De.return)&&h.call(De)}finally{if(f)throw f.error}}if(N)try{for(var je=vn([-3.1,3.1]),Ne=je.next();!Ne.done;Ne=je.next()){var M=Ne.value;Y(M,.7,-4.5,.2,1.1,5.2,Q)}}catch(Pe){m={error:Pe}}finally{try{Ne&&!Ne.done&&(x=je.return)&&x.call(je)}finally{if(m)throw m.error}}return S}function jw(n){var e,t=new dr,i=(e=n.cupRadius)!==null&&e!==void 0?e:.23,r=new bi(new po(i,i*.89,.48,24,1,!0),new mr({color:"#244640",side:Gr}));r.position.y=-.24,t.add(r);var a=new bi(new ul(i*.91,24),new oa({color:"#082c2b"}));a.rotation.x=-Math.PI/2,a.position.y=-.475,t.add(a);var s=new bi(new po(i,i*.978,.09,24,1,!0),new mr({color:"#eee9cf",side:Gr}));s.position.y=-.045,t.add(s);var o=new bi(new pl(i,i+.06,24),new mr({color:"#fff7d1"}));return o.rotation.x=-Math.PI/2,o.position.y=.004,t.add(o),t}function e1(){for(var n,e,t=new dr,i=new jr(.18,1,.18),r=new mr({color:"#b27b59"}),a=new jr(1.5,.2,1.6),s=new mr({color:"#82b88b"}),o=new Ss(.62,7,5),u=new Ss(.49,7,5),l=new mr({color:"#77b86b"}),d=new mr({color:"#3e9d79"}),f=new ka(i,r,14),h=new ka(a,s,14),m=5,x=9,_=new ka(o,l,m),g=new ka(u,l,m),v=new ka(o,d,x),F=new ka(u,d,x),P=new Jn,S=0,N=0,p=0;p<14;p++){var L=p%2?-1:1,E=L*(3.8+p%3*.35),D=-6.5+Math.floor(p/2)*2;P.makeTranslation(E,-.02,D),f.setMatrixAt(p,P),P.makeTranslation(E,-.48,D),h.setMatrixAt(p,P),p%3===0?(P.makeTranslation(E,.5,D),_.setMatrixAt(S,P),P.makeTranslation(E,1,D),g.setMatrixAt(S,P),S++):(P.makeTranslation(E,.5,D),v.setMatrixAt(N,P),P.makeTranslation(E,1,D),F.setMatrixAt(N,P),N++)}try{for(var X=vn([f,h,_,g,v,F]),Y=X.next();!Y.done;Y=X.next()){var W=Y.value;W.instanceMatrix.needsUpdate=!0,t.add(W)}}catch(C){n={error:C}}finally{try{Y&&!Y.done&&(e=X.return)&&e.call(X)}finally{if(n)throw n.error}}return t}function t1(n,e,t){for(var i=n.getAttribute("position"),r=0;r<i.count;r++){var a=e[r*3],s=e[r*3+1],o=e[r*3+2],u=s>.7?Math.max(0,Math.min(1,(-a-.035)/.32)):0;i.setXYZ(r,a,s+Math.sin(t*3.2+a*10)*.018*u,o+Math.sin(t*3.2+a*10+s*2)*.07*u)}i.needsUpdate=!0,n.computeVertexNormals()}function n1(n){for(var e=64,t=32,i=new Uint8Array(e*t*4),r=0;r<t;r++)for(var a=r/(t-1),s=0;s<e;s++){var o=s/e,u=(r*e+s)*4,l=Math.exp(-(Math.pow(o-.35,2)/.012+Math.pow(a-.7,2)/.018)),d=Math.exp(-(Math.pow(o-.79,2)/.004+Math.pow(a-.58,2)/.055));i[u]=Math.min(255,21+a*90+l*180+d*125),i[u+1]=Math.min(255,22+a*105+l*158+d*145),i[u+2]=Math.min(255,24+a*127+l*128+d*180),i[u+3]=255}var f=new Gs(i,e,t);f.mapping=xl,f.needsUpdate=!0;var h=new El(n);try{return h.fromEquirectangular(f)}finally{h.dispose(),f.dispose()}}function wg(n,e,t,i){i===void 0&&(i=new Map);var r=new Map,a=new Map,s=new Map,o=new Set,u=new Set,l;function d(){var k,G;try{for(var te=vn(m.values()),le=te.next();!le.done;le=te.next()){var ge=le.value;ge.textureDirty=!0}}catch(oe){k={error:oe}}finally{try{le&&!le.done&&(G=te.return)&&G.call(te)}finally{if(k)throw k.error}}t?.()}function f(k){var G,te,le,ge,oe,$,Te;if(!s.has((oe=k.hash)!==null&&oe!==void 0?oe:k.id)){var Le=Uint8Array.from(atob(k.data),function(He){return He.charCodeAt(0)}),se=yg(Le,d);try{for(var re=vn(se.geometries),Ie=re.next();!Ie.done;Ie=re.next()){var ke=Ie.value;o.add(ke)}}catch(He){G={error:He}}finally{try{Ie&&!Ie.done&&(te=re.return)&&te.call(re)}finally{if(G)throw G.error}}try{for(var xe=vn(se.materials),Ye=xe.next();!Ye.done;Ye=xe.next()){var mt=Ye.value;u.add(mt)}}catch(He){le={error:He}}finally{try{Ye&&!Ye.done&&(ge=xe.return)&&ge.call(xe)}finally{if(le)throw le.error}}s.set(($=k.hash)!==null&&$!==void 0?$:k.id,se)}return s.get((Te=k.hash)!==null&&Te!==void 0?Te:k.id)}function h(k){var G,te,le,ge,oe=new Set,$=new Set;k.traverse(function(xe){var Ye,mt;if(xe.geometry&&!o.has(xe.geometry)&&oe.add(xe.geometry),xe.material)try{for(var He=vn(Array.isArray(xe.material)?xe.material:[xe.material]),qe=He.next();!qe.done;qe=He.next()){var pt=qe.value;u.has(pt)||$.add(pt)}}catch(at){Ye={error:at}}finally{try{qe&&!qe.done&&(mt=He.return)&&mt.call(He)}finally{if(Ye)throw Ye.error}}});try{for(var Te=vn(oe),Le=Te.next();!Le.done;Le=Te.next()){var se=Le.value;se.dispose()}}catch(xe){G={error:xe}}finally{try{Le&&!Le.done&&(te=Te.return)&&te.call(Te)}finally{if(G)throw G.error}}try{for(var re=vn($),Ie=re.next();!Ie.done;Ie=re.next()){var ke=Ie.value;ke.dispose()}}catch(xe){le={error:xe}}finally{try{Ie&&!Ie.done&&(ge=re.return)&&ge.call(re)}finally{if(le)throw le.error}}}var m=new Map,x,_,g,v,F;function P(){var k,G;if(_!==void 0)return _;try{return x=document.createElement("canvas"),(k=x.addEventListener)===null||k===void 0||k.call(x,"webglcontextrestored",function(){var te,le;F=void 0;try{for(var ge=vn(m.values()),oe=ge.next();!oe.done;oe=ge.next()){var $=oe.value;$.compiled=!1,$.textureDirty=!0,$.lastRenderedTime=-1,$.lastFlagStep=-1}}catch(Te){te={error:Te}}finally{try{oe&&!oe.done&&(le=ge.return)&&le.call(ge)}finally{if(te)throw te.error}}t?.()}),g=document.createElement("canvas"),v=(G=g.getContext)===null||G===void 0?void 0:G.call(g,"2d"),_=new Sf({canvas:x,antialias:!0,alpha:!1,preserveDrawingBuffer:!1,powerPreference:"default"}),_.shadowMap.type=Cd,_}catch{return _=null,null}}function S(k){if(k){if(r.has(k))return r.get(k);var G=e.get(k);if(!(!G||G.mime!=="model/tora-mesh"||!G.data)){var te=Kw(G.data);return r.set(k,te),o.add(te),te}}}function N(k,G){if(k){var te=(G??"stage")+":"+k;if(a.has(te))return a.get(te);var le=e.get(k);if(!(!le||!le.mime.startsWith("image/")||!le.data)){var ge=new Image,oe=new Cr(ge);oe.colorSpace=G==="normalMap"?ta:Ir,G&&(oe.flipY=!1,oe.wrapS=oe.wrapT=Vs);var $=function(Te){var Le,se;oe.needsUpdate=!0;try{for(var re=vn(m.values()),Ie=re.next();!Ie.done;Ie=re.next()){var ke=Ie.value;ke.scene.traverse(function(xe){var Ye,mt,He,qe=xe.isMesh&&xe.material?Array.isArray(xe.material)?xe.material:[xe.material]:[];try{for(var pt=(Ye=void 0,vn(qe)),at=pt.next();!at.done;at=pt.next()){var ot=at.value;!((He=ot.userData)===null||He===void 0)&&He.pendingTex&&ot.userData.pendingTex.tex===oe&&(ot.map=oe,ot.color.set(ot.userData.pendingTex.color||"#ffffff"),delete ot.userData.pendingTex,ot.needsUpdate=!0)}}catch(Vt){Ye={error:Vt}}finally{try{at&&!at.done&&(mt=pt.return)&&mt.call(pt)}finally{if(Ye)throw Ye.error}}}),ke.textureDirty=!0}}catch(xe){Le={error:xe}}finally{try{Ie&&!Ie.done&&(se=re.return)&&se.call(re)}finally{if(Le)throw Le.error}}Te&&t?.()};return a.set(te,oe),ge.onload=function(){return $(!0)},ge.src="data:"+le.mime+";base64,"+le.data,ge.complete&&ge.naturalWidth&&$(!1),oe}}}function p(k){var G,te,le,ge,oe,$,Te,Le,se,re,Ie,ke,xe,Ye,mt,He,qe,pt,at,ot,Vt=k.parameters,cn=new fc;cn.background=new Wn(Vt.skyColor||"#b8e2ed");var Ze=new zr((le=Vt.cameraFov)!==null&&le!==void 0?le:39,1,.1,160);Ze.position.set((ge=Vt.cameraX)!==null&&ge!==void 0?ge:10,(oe=Vt.cameraY)!==null&&oe!==void 0?oe:18,($=Vt.cameraZ)!==null&&$!==void 0?$:21),Ze.lookAt((Te=Vt.lookAtX)!==null&&Te!==void 0?Te:0,(Le=Vt.lookAtY)!==null&&Le!==void 0?Le:.15,(se=Vt.lookAtZ)!==null&&se!==void 0?se:0),cn.add(Ze),cn.add(new Rc(Vt.hemiSkyColor||"#fff9dd",Vt.hemiGroundColor||"#527b75",(re=Vt.hemiIntensity)!==null&&re!==void 0?re:1.8));var pn=new Lc(Vt.sunColor||"#fff0cf",(Ie=Vt.sunIntensity)!==null&&Ie!==void 0?Ie:2.1);pn.position.set((ke=Vt.sunX)!==null&&ke!==void 0?ke:-9,(xe=Vt.sunY)!==null&&xe!==void 0?xe:18,(Ye=Vt.sunZ)!==null&&Ye!==void 0?Ye:8),cn.add(pn),pn.shadow.camera.left=pn.shadow.camera.bottom=-16,pn.shadow.camera.right=pn.shadow.camera.top=16,pn.shadow.camera.far=100,pn.shadow.camera.updateProjectionMatrix();var ne=N((He=(mt=k.assetSlots)===null||mt===void 0?void 0:mt[0])===null||He===void 0?void 0:He.assetId),Tn=new Map,gn=new Map,Q=[],I=[],ie=new Map;function be(yt,Et,rt,Ut,an,hn){hn===void 0&&(hn=!1),yt.traverse(function(en){en.userData.toraRootId=Et,en.userData.toraSourceId=rt,an&&(en.userData.toraNodeId=an),Ut&&(en.userData.cameraAttached=!0),hn&&(en.userData.isDropShadow=!0)})}function De(yt,Et,rt,Ut,an){var hn,en,Ht,yn,bn,Yt,Ot,$n,Xn,Nn,ni,wn,Pn,Bn,fn,En,dn,di,ii,si,A=yt.parameters,ae,we=function(){var It,Ft,Ce={},qt=!!(ne&&(!((It=ne.image)===null||It===void 0)&&It.complete)&&((Ft=ne.image)===null||Ft===void 0?void 0:Ft.naturalWidth)>0);A.useTexture&&ne&&qt?Ce.map=ne:Ce.color=A.useTexture?A.waveFlag?"#e85d56":"#d89b6a":A.color||"#ffffff",A.doubleSide&&(Ce.side=Gr),A.opacity<1&&(Ce.transparent=!0,Ce.opacity=A.opacity,Ce.depthWrite=!1);var Qt=A.unlit?new oa(Ce):new mr(Ce);return A.useTexture&&ne&&!qt&&(Qt.userData.pendingTex={tex:ne,color:"#ffffff"}),Qt};if(A.primitive==="model"||A.primitive==="mesh"&&!A.waveFlag){ae=new dr;var me,Me,et,Ge=((hn=n.gameplay)!==null&&hn!==void 0?hn:[]).find(function(It){var Ft;return It.kind==="animate-3d"&&It.componentId===((Ft=yt.prototypeId)!==null&&Ft!==void 0?Ft:yt.id)}),ut={sourceId:Ut,animator:null,modelBounds:null,startDefaultAnimation:function(){var It,Ft,Ce;if(!(!ut.animator||!Ge)){var qt=Ge.parameters;qt.autoplay!==!1&&ut.animator.play(qt.clipName||"",{loop:(It=qt.loop)!==null&&It!==void 0?It:"repeat",speed:(Ft=qt.speed)!==null&&Ft!==void 0?Ft:1,fadeSeconds:0,restart:!0,startTime:(Ce=qt.startTime)!==null&&Ce!==void 0?Ce:0})}},update:function(It){var Ft,Ce,qt,Qt,sn,Mn,In,wt=(qt=i.get(yt.id))===null||qt===void 0?void 0:qt.slots,ri=(Qt=i.get(yt.prototypeId))===null||Qt===void 0?void 0:Qt.slots,xn=function(fi){var xr,ss,ya,na;return(ss=(xr=wt?.[fi])!==null&&xr!==void 0?xr:ri?.[fi])!==null&&ss!==void 0?ss:(na=(ya=yt.assetSlots)===null||ya===void 0?void 0:ya.find(function(xa){return xa.slotId===fi}))===null||na===void 0?void 0:na.assetId},Kn=["source","texture","normalMap","emissiveMap"].map(xn),Dt=["subNode","materialMode","overrideMaterialName","opacity","tintColor","roughnessScale","metalnessScale","castShadow","receiveShadow","normalizeSize","pivotMode","color","useTexture"];if(Me&&Kn.every(function(fi,xr){return fi===Me[xr]})&&Dt.every(function(fi){return It[fi]===et[fi]}))return!1;var Ln=e.get(Kn[0]);if(me&&(ae.remove(me),h(me)),ut.animator=null,ut.modelBounds=null,Ln?.mime==="model/gltf-binary"){var Zt={};try{for(var zn=vn(["texture","normalMap","emissiveMap"].entries()),nt=zn.next();!nt.done;nt=zn.next()){var Vn=Ga(nt.value,2),Cn=Vn[0],wi=Vn[1];Kn[Cn+1]&&(Zt[wi]=N(Kn[Cn+1],wi))}}catch(fi){Ft={error:fi}}finally{try{nt&&!nt.done&&(Ce=zn.return)&&Ce.call(zn)}finally{if(Ft)throw Ft.error}}me=xg(f(Ln),It,Zt),ut.modelBounds=(Mn=(sn=me.userData)===null||sn===void 0?void 0:sn.modelBounds)!==null&&Mn!==void 0?Mn:null,ut.animator=_g(me),ut.startDefaultAnimation()}else me=new bi((In=S(Kn[0]))!==null&&In!==void 0?In:new jr(1,1,1),we()),me.castShadow=!!It.castShadow,me.receiveShadow=!!It.receiveShadow,Kn[1]?me.material.map=N(Kn[1]):It.color&&!It.useTexture&&me.material.color.set(It.color);return ae.add(me),be(me,rt,Ut,an,yt.id,!!A.dropShadowOf),Me=Kn,et=Jc({},It),!0}};ut.update(A),ie.set(yt.id,ut)}else if(A.primitive==="group")ae=new dr;else if(A.primitive==="fairway")ae=Qw(A,ne,S((Ht=(en=yt.assetSlots)===null||en===void 0?void 0:en[0])===null||Ht===void 0?void 0:Ht.assetId));else if(A.primitive==="cup")ae=jw(A);else if(A.primitive==="garden")ae=e1();else if(A.primitive==="mesh"){var Nt=S((bn=(yn=yt.assetSlots)===null||yn===void 0?void 0:yn[0])===null||bn===void 0?void 0:bn.assetId),lt=A.waveFlag&&Nt?Nt.clone():Nt??new jr(1,1,1);ae=new bi(lt,we()),A.waveFlag&&Nt&&Q.push({geo:lt,rest:new Float32Array(lt.getAttribute("position").array)})}else A.primitive==="sphere"?ae=new bi(new Ss((Yt=A.radiusTop)!==null&&Yt!==void 0?Yt:.5,16,12),we()):A.primitive==="cylinder"?ae=new bi(new po((Ot=A.radiusTop)!==null&&Ot!==void 0?Ot:.23,($n=A.radiusBottom)!==null&&$n!==void 0?$n:.21,1,32,1,!!A.openEnded),we()):A.primitive==="ring"?ae=new bi(new pl((Xn=A.innerRadius)!==null&&Xn!==void 0?Xn:0,(Nn=A.radiusTop)!==null&&Nn!==void 0?Nn:.15,24),we()):A.primitive==="circle"?ae=new bi(new ul((ni=A.radiusTop)!==null&&ni!==void 0?ni:.21,32),we()):ae=new bi(new jr(1,1,1),we());return ae.position.set((wn=A.x)!==null&&wn!==void 0?wn:0,(Pn=A.y)!==null&&Pn!==void 0?Pn:0,(Bn=A.z)!==null&&Bn!==void 0?Bn:0),ae.rotation.set((fn=A.rx)!==null&&fn!==void 0?fn:0,(En=A.ry)!==null&&En!==void 0?En:0,(dn=A.rz)!==null&&dn!==void 0?dn:0),ae.scale.set((di=A.sx)!==null&&di!==void 0?di:1,(ii=A.sy)!==null&&ii!==void 0?ii:1,(si=A.sz)!==null&&si!==void 0?si:1),ae.visible=A.visible!==!1,be(ae,rt,Ut,an,yt.id,!!A.dropShadowOf),Et.add(ae),ae}var Je=[],je=new Map,Ne=function(yt,Et,rt){var Ut,an;try{for(var hn=vn(n.components),en=hn.next();!en.done;en=hn.next()){var Ht=en.value;if(Ht.parentId===yt&&Ht.contract==="native.mesh3d.v1"&&!Ht.prototype){var yn=Et??Ht,bn=rt||!!Ht.parameters.attachToCamera;je.set(Ht.id,{rootId:yn.id,sourceId:yn.id,cameraAttached:bn}),Je.push(Ht),Ne(Ht.id,yn,bn)}}}catch(Yt){Ut={error:Yt}}finally{try{en&&!en.done&&(an=hn.return)&&an.call(hn)}finally{if(Ut)throw Ut.error}}};Ne(k.id,null,!1);var Pe=function(yt){var Et=yt.parameters,rt=je.get(yt.id),Ut=Et.attachToCamera&&yt.parentId===k.id?Ze:yt.parentId===k.id?cn:(qe=Tn.get(yt.parentId))!==null&&qe!==void 0?qe:cn,an=De(yt,Ut,rt.rootId,rt.sourceId,rt.cameraAttached);if(Tn.set(yt.id,an),Et.confetti){var hn=new dr;hn.userData.isConfetti=!0;var en=new jr(.08,.025,.12),Ht=["#ffda69","#fff6c9","#ef8774","#7cc6bf"].map(function(bn){return new oa({color:bn})}),yn=Array.from({length:28},function(bn,Yt){var Ot=new bi(en,Ht[Yt%4]);return Ot.visible=!1,hn.add(Ot),Ot});cn.add(hn),I.push({id:yt.id,origin:{x:(pt=Et.x)!==null&&pt!==void 0?pt:0,y:(at=Et.y)!==null&&at!==void 0?at:0,z:(ot=Et.z)!==null&&ot!==void 0?ot:0},pieces:yn})}};try{for(var it=vn(Je),Rt=it.next();!Rt.done;Rt=it.next()){var Mt=Rt.value;Pe(Mt)}}catch(yt){G={error:yt}}finally{try{Rt&&!Rt.done&&(te=it.return)&&te.call(it)}finally{if(G)throw G.error}}var ct=new dr;cn.add(ct);var Gt=new Ss(1,8,5),Kt=new oa({color:"#fff1a2",transparent:!0,opacity:.85}),nn=Array.from({length:24},function(){var yt=new bi(Gt,Kt);return yt.visible=!1,ct.add(yt),yt}),he=new Dc,dt=new ln,Ee=new Se,gt=new fa(new Se(0,1,0),0),Ke=new Se,We="",Wt=Array.from(Tn,function(yt){var Et=Ga(yt,2),rt=Et[0],Ut=Et[1];return{id:rt,obj:Ut,comp:n.components.find(function(an){return an.id===rt})}}).filter(function(yt){return yt.comp}),Lt={id:k.id,scene:cn,camera:Ze,nodes:Tn,dynamicNodes:gn,nodeEntries:Wt,createMeshObject:De,modelBindings:ie,sun:pn,wavingFlags:Q,confettiSystems:I,guideGroup:ct,guidePool:nn,compiled:!1,lastRenderMs:0,textureDirty:!0,animDirty:!1,skyColor:Vt.skyColor||"#b8e2ed",lastWaveAt:-1,lastRenderedTime:-1,lastRenderedW:0,lastRenderedH:0,lastPoseSig:"",guideDirty:!0,focusZ:0,lastTime:-1,lastWidth:0,lastHeight:0,setGuide:function(yt){var Et=yt?Math.min(yt.length,nn.length):0,rt=Et?yt.slice(0,Et).map(function(Ht){return"".concat(Ht.x.toFixed(2),",").concat(Ht.y.toFixed(2),",").concat(Ht.z.toFixed(2))}).join("|"):"";if(rt!==We){We=rt,Lt.guideDirty=!0;for(var Ut=0;Ut<nn.length;Ut++){var an=nn[Ut];if(Ut<Et){var hn=yt[Ut],en=.055*(1-Ut/Et*.5);an.visible=!0,an.scale.setScalar(en),an.position.set(hn.x,hn.y+.03,hn.z)}else an.visible=!1}}},project:function(yt,Et,rt){return Ee.set(yt.x,yt.y,yt.z).project(Ze),{x:(Ee.x+1)*Et/2,y:(1-Ee.y)*rt/2}},projectNodeBounds:function(yt,Et,rt){var Ut,an,hn,en,Ht,yn,bn,Yt,Ot,$n,Xn,Nn,ni,wn=(ni=Lt.nodes.get(yt))!==null&&ni!==void 0?ni:Lt.dynamicNodes.get(yt);if(!wn||Et<=0||rt<=0)return null;cn.updateMatrixWorld(!0),Ze.updateMatrixWorld(!0);for(var Pn=!0,Bn=wn;Bn;Bn=Bn.parent)if(!Bn.visible){Pn=!1;break}var fn=new Qr().setFromObject(wn),En=new Se;fn.isEmpty()?(wn.getWorldPosition(En),fn.set(En,En)):fn.getCenter(En);var dn=function(Cn){var wi=Cn.clone().applyMatrix4(Ze.matrixWorldInverse);if(wi.z>=-Ze.near)return{x:0,y:0,behind:!0};var fi=Cn.clone().project(Ze);return{x:(fi.x+1)*Et/2,y:(1-fi.y)*rt/2,behind:!1}},di=[fn.min.x,fn.max.x],ii=[fn.min.y,fn.max.y],si=[fn.min.z,fn.max.z],A=1/0,ae=-1/0,we=1/0,me=-1/0,Me=0;try{for(var et=vn(di),Ge=et.next();!Ge.done;Ge=et.next()){var ut=Ge.value;try{for(var Nt=(hn=void 0,vn(ii)),lt=Nt.next();!lt.done;lt=Nt.next()){var It=lt.value;try{for(var Ft=(Ht=void 0,vn(si)),Ce=Ft.next();!Ce.done;Ce=Ft.next()){var qt=Ce.value,Qt=new Se(ut,It,qt),sn=Qt.clone().applyMatrix4(Ze.matrixWorldInverse);if(sn.z<-Ze.near){Me++,Qt.project(Ze);var Mn=(Qt.x+1)*Et/2,In=(1-Qt.y)*rt/2;Mn<A&&(A=Mn),Mn>ae&&(ae=Mn),In<we&&(we=In),In>me&&(me=In)}}}catch(Cn){Ht={error:Cn}}finally{try{Ce&&!Ce.done&&(yn=Ft.return)&&yn.call(Ft)}finally{if(Ht)throw Ht.error}}}}catch(Cn){hn={error:Cn}}finally{try{lt&&!lt.done&&(en=Nt.return)&&en.call(Nt)}finally{if(hn)throw hn.error}}}}catch(Cn){Ut={error:Cn}}finally{try{Ge&&!Ge.done&&(an=et.return)&&an.call(et)}finally{if(Ut)throw Ut.error}}if(Me===0)return{id:yt,visible:Pn,behindCamera:!0,left:0,right:0,top:0,bottom:0,width:0,height:0,centerX:0,centerY:0,anchors:{center:{x:0,y:0},top:{x:0,y:0},bottom:{x:0,y:0}},worldCenter:{x:En.x,y:En.y,z:En.z}};if(Me<8)try{for(var wt=vn(di),ri=wt.next();!ri.done;ri=wt.next()){var ut=ri.value;try{for(var xn=(Ot=void 0,vn(ii)),Kn=xn.next();!Kn.done;Kn=xn.next()){var It=Kn.value;try{for(var Dt=(Xn=void 0,vn(si)),Ln=Dt.next();!Ln.done;Ln=Dt.next()){var qt=Ln.value,sn=new Se(ut,It,qt).applyMatrix4(Ze.matrixWorldInverse);if(sn.z>=-Ze.near){sn.z=-(Ze.near+.01),sn.applyMatrix4(Ze.projectionMatrix);var Mn=(sn.x+1)*Et/2,In=(1-sn.y)*rt/2;Mn<A&&(A=Mn),Mn>ae&&(ae=Mn),In<we&&(we=In),In>me&&(me=In)}}}catch(fi){Xn={error:fi}}finally{try{Ln&&!Ln.done&&(Nn=Dt.return)&&Nn.call(Dt)}finally{if(Xn)throw Xn.error}}}}catch(wi){Ot={error:wi}}finally{try{Kn&&!Kn.done&&($n=xn.return)&&$n.call(xn)}finally{if(Ot)throw Ot.error}}}}catch(Cn){bn={error:Cn}}finally{try{ri&&!ri.done&&(Yt=wt.return)&&Yt.call(wt)}finally{if(bn)throw bn.error}}var Zt=dn(En),zn=dn(new Se(En.x,fn.max.y,En.z)),nt=dn(new Se(En.x,fn.min.y,En.z)),Vn={x:(A+ae)/2,y:(we+me)/2};return{id:yt,visible:Pn,behindCamera:!1,left:A,right:ae,top:we,bottom:me,width:Math.max(0,ae-A),height:Math.max(0,me-we),centerX:Vn.x,centerY:Vn.y,anchors:{center:Zt.behind?Vn:{x:Zt.x,y:Zt.y},top:zn.behind?{x:Vn.x,y:we}:{x:zn.x,y:zn.y},bottom:nt.behind?{x:Vn.x,y:me}:{x:nt.x,y:nt.y}},worldCenter:{x:En.x,y:En.y,z:En.z}}},checkNodeOcclusion:function(yt,Et,rt,Ut){var an,hn,en,Ht,yn,bn,Yt,Ot,$n,Xn,Nn,ni,wn=(Yt=Lt.nodes.get(yt))!==null&&Yt!==void 0?Yt:Lt.dynamicNodes.get(yt);if(!wn||!Et||Et.behindCamera||rt<=0||Ut<=0)return{occluded:!1,occluderId:null,targetHitSamples:0,occludedSamples:0,occludedRatio:0};cn.updateMatrixWorld(!0),Ze.updateMatrixWorld(!0);var Pn=function(Dt){for(var Ln=Dt;Ln;Ln=Ln.parent)if(Ln===wn)return!0;return!1},Bn=function(Dt){for(var Ln,Zt,zn,nt,Vn,Cn,wi=Dt;wi;wi=wi.parent)if(!wi.visible||wi===ct||!((Ln=wi.userData)===null||Ln===void 0)&&Ln.cameraAttached||!((Zt=wi.userData)===null||Zt===void 0)&&Zt.isConfetti||!((zn=wi.userData)===null||zn===void 0)&&zn.isDropShadow)return!1;var fi=Dt.material;return fi&&!Array.isArray(fi)&&fi.transparent&&((nt=fi.opacity)!==null&&nt!==void 0?nt:1)<.25?!1:!!(!((Vn=Dt.userData)===null||Vn===void 0)&&Vn.toraNodeId||!((Cn=Dt.userData)===null||Cn===void 0)&&Cn.toraRootId)},fn=Et.centerX,En=Et.centerY,dn=Math.max(1,Et.width*.22),di=Math.max(1,Et.height*.22),ii=[{x:fn,y:En,center:!0},{x:fn-dn,y:En-di,center:!1},{x:fn+dn,y:En-di,center:!1},{x:fn-dn,y:En+di,center:!1},{x:fn+dn,y:En+di,center:!1}],si=0,A=0,ae=!1,we=new Map;try{for(var me=vn(ii),Me=me.next();!Me.done;Me=me.next()){var et=Me.value;if(!(et.x<0||et.x>rt||et.y<0||et.y>Ut)){dt.set(et.x/rt*2-1,1-et.y/Ut*2),he.near=.05,he.far=200,he.setFromCamera(dt,Ze);var Ge=he.intersectObject(wn,!0).filter(function(Dt){return Bn(Dt.object)});if(Ge.length){si++;var ut=Ge[0].distance,Nt=he.intersectObjects(cn.children,!0);try{for(var lt=(en=void 0,vn(Nt)),It=lt.next();!It.done;It=lt.next()){var Ft=It.value;if(Bn(Ft.object)){if(Ft.distance>=ut-.02||Pn(Ft.object))break;var Ce=(Nn=($n=(Ot=Ft.object.userData)===null||Ot===void 0?void 0:Ot.toraNodeId)!==null&&$n!==void 0?$n:(Xn=Ft.object.userData)===null||Xn===void 0?void 0:Xn.toraRootId)!==null&&Nn!==void 0?Nn:null;Ce&&Ce!==yt&&(A++,et.center&&(ae=!0),we.set(Ce,((ni=we.get(Ce))!==null&&ni!==void 0?ni:0)+1));break}}}catch(Dt){en={error:Dt}}finally{try{It&&!It.done&&(Ht=lt.return)&&Ht.call(lt)}finally{if(en)throw en.error}}}}}}catch(Dt){an={error:Dt}}finally{try{Me&&!Me.done&&(hn=me.return)&&hn.call(me)}finally{if(an)throw an.error}}var qt=si>0?A/si:0,Qt=null,sn=0;try{for(var Mn=vn(we),In=Mn.next();!In.done;In=Mn.next()){var wt=Ga(In.value,2),ri=wt[0],xn=wt[1];xn>sn&&(sn=xn,Qt=ri)}}catch(Dt){yn={error:Dt}}finally{try{In&&!In.done&&(bn=Mn.return)&&bn.call(Mn)}finally{if(yn)throw yn.error}}var Kn=si>0&&(qt>=.6||ae&&qt>=.5);return{occluded:Kn,occluderId:Kn?Qt:null,targetHitSamples:si,occludedSamples:A,occludedRatio:qt}},unproject:function(yt,Et,rt,Ut,an){return dt.set(yt/rt*2-1,1-Et/Ut*2),he.setFromCamera(dt,Ze),gt.constant=-an,he.ray.intersectPlane(gt,Ke)?{x:Ke.x,y:Ke.y,z:Ke.z}:null},raycast:function(yt,Et,rt,Ut){var an,hn,en,Ht,yn,bn,Yt,Ot,$n,Xn,Nn,ni,wn,Pn,Bn,fn;rt===void 0&&(rt=80);var En=Ut===void 0?{}:Ut,dn=En.isTarget,di=dn===void 0?function(){return!0}:dn,ii=En.isOccluder,si=ii===void 0?function(){return!1}:ii;cn.updateMatrixWorld(!0),Ze.updateMatrixWorld(!0),dt.set(yt,Et),he.near=.05,he.far=rt,he.setFromCamera(dt,Ze);var A=[];try{for(var ae=vn(Lt.nodes.values()),we=ae.next();!we.done;we=ae.next()){var me=we.value;if(!(!me.visible||!((Yt=me.userData)===null||Yt===void 0)&&Yt.cameraAttached)){var Me=(Ot=me.userData)===null||Ot===void 0?void 0:Ot.toraRootId,et=($n=me.userData)===null||$n===void 0?void 0:$n.toraSourceId;Me&&(di(Me,et)||si(Me,et))&&A.push(me)}}}catch(In){an={error:In}}finally{try{we&&!we.done&&(hn=ae.return)&&hn.call(ae)}finally{if(an)throw an.error}}try{for(var Ge=vn(Lt.dynamicNodes.values()),ut=Ge.next();!ut.done;ut=Ge.next()){var me=ut.value;if(!(!me.visible||!((Xn=me.userData)===null||Xn===void 0)&&Xn.cameraAttached)){var Me=(Nn=me.userData)===null||Nn===void 0?void 0:Nn.toraRootId,et=(ni=me.userData)===null||ni===void 0?void 0:ni.toraSourceId;Me&&(di(Me,et)||si(Me,et))&&A.push(me)}}}catch(In){en={error:In}}finally{try{ut&&!ut.done&&(Ht=Ge.return)&&Ht.call(Ge)}finally{if(en)throw en.error}}var Nt=he.intersectObjects(A.length?A:cn.children,!0),lt=new Set;try{for(var It=vn(Nt),Ft=It.next();!Ft.done;Ft=It.next()){for(var Ce=Ft.value,qt=!1,Qt=Ce.object;Qt;Qt=Qt.parent)if(!Qt.visible||Qt===ct||!((wn=Qt.userData)===null||wn===void 0)&&wn.cameraAttached||!((Pn=Qt.userData)===null||Pn===void 0)&&Pn.isConfetti){qt=!0;break}if(!qt){var sn=(Bn=Ce.object.userData)===null||Bn===void 0?void 0:Bn.toraRootId,Mn=(fn=Ce.object.userData)===null||fn===void 0?void 0:fn.toraSourceId;if(!(!sn||lt.has(sn))){if(lt.add(sn),di(sn,Mn))return{id:sn,sourceId:Mn,distance:Ce.distance,point:{x:Ce.point.x,y:Ce.point.y,z:Ce.point.z}};if(si(sn,Mn))return null}}}}catch(In){yn={error:In}}finally{try{Ft&&!Ft.done&&(bn=It.return)&&bn.call(It)}finally{if(yn)throw yn.error}}return null}};return m.set(k.id,Lt),Lt}function L(k){var G;return(G=m.get(k.id))!==null&&G!==void 0?G:p(k)}function E(k,G){var te,le,ge,oe,$,Te;if(!G.length&&!k.contactBatches)return!1;k.contactBatches||(k.contactBatches=[new Ss(1,6,4),new jr(1,.2,1.6)].map(function(Vt){var cn=new ka(Vt,new oa({toneMapped:!1}),256);return cn.userData.isConfetti=!0,cn.frustumCulled=!1,cn.count=0,k.scene.add(cn),cn}),k.contactPose=new hr,k.contactColor=new Wn);var Le=k.contactBatches.some(function(Vt){return Vt.count>0});try{for(var se=vn(k.contactBatches),re=se.next();!re.done;re=se.next()){var Ie=re.value;Ie.count=0}}catch(Vt){te={error:Vt}}finally{try{re&&!re.done&&(le=se.return)&&le.call(se)}finally{if(te)throw te.error}}var ke=k.contactBatches,xe=k.contactPose,Ye=k.contactColor;try{for(var mt=vn(G),He=mt.next();!He.done;He=mt.next()){var qe=He.value,Ie=ke[Number(qe.confetti)],pt=qe.age;xe.position.set(qe.x+qe.vx*pt,qe.y+qe.vy*pt-qe.gravity*pt*pt/2,qe.z+qe.vz*pt),xe.rotation.set(qe.spinX*pt,qe.spinZ*pt/2,qe.spinZ*pt),xe.scale.setScalar(qe.size*Math.min(1,(qe.life-pt)*7)),xe.updateMatrix(),Ie.setMatrixAt(Ie.count,xe.matrix),Ie.setColorAt(Ie.count,Ye.set(qe.color)),Ie.count++}}catch(Vt){ge={error:Vt}}finally{try{He&&!He.done&&(oe=mt.return)&&oe.call(mt)}finally{if(ge)throw ge.error}}try{for(var at=vn(ke),ot=at.next();!ot.done;ot=at.next()){var Ie=ot.value;Ie.instanceMatrix.needsUpdate=!0,Ie.instanceColor&&(Ie.instanceColor.needsUpdate=!0)}}catch(Vt){$={error:Vt}}finally{try{ot&&!ot.done&&(Te=at.return)&&Te.call(at)}finally{if($)throw $.error}}return Le||G.length>0}function D(k,G){var te,le,ge,oe,$,Te,Le,se,re,Ie,ke,xe,Ye,mt,He,qe,pt,at,ot,Vt,cn,Ze,pn,ne,Tn,gn,Q,I,ie,be,De,Je,je,Ne,Pe,it,Rt,Mt,ct,Gt,Kt,nn,he,dt,Ee,gt,Ke,We,Wt,Lt,yt,Et,rt,Ut,an,hn,en,Ht,yn,bn,Yt,Ot,$n,Xn,Nn,ni,wn,Pn,Bn,fn,En,dn=G.time,di=dn===void 0?0:dn,ii=G.ambientTime,si=G.propsOf,A=G.bodies3d,ae=G.fpsPose,we=G.instances3d,me=we===void 0?[]:we,Me=G.aimLocked,et=Me===void 0?!1:Me,Ge=G.groundFn,ut=G.worldWidth,Nt=ut===void 0?390:ut,lt=G.worldHeight,It=lt===void 0?700:lt,Ft=G.designHeight,Ce=L(k),qt=ii??di,Qt=si(k),sn=Qt.skyColor||"#b8e2ed";Ce.skyColor!==sn&&(Ce.skyColor=sn,Ce.scene.background=new Wn(sn));var Mn=new Set(me.map(function(li){return li.id}));try{for(var In=vn(Ce.dynamicNodes),wt=In.next();!wt.done;wt=In.next()){var ri=Ga(wt.value,2),xn=ri[0],Kn=ri[1];Mn.has(xn)||((ke=Kn.parent)===null||ke===void 0||ke.remove(Kn),h(Kn),Ce.modelBindings.delete(xn),Ce.dynamicNodes.delete(xn))}}catch(li){te={error:li}}finally{try{wt&&!wt.done&&(le=In.return)&&le.call(In)}finally{if(te)throw te.error}}var Dt=function(li){if(Ce.dynamicNodes.has(li.id))return"continue";var Ma=li.parentId===k.id?Ce.scene:(Ye=(xe=Ce.dynamicNodes.get(li.parentId))!==null&&xe!==void 0?xe:Ce.nodes.get(li.parentId))!==null&&Ye!==void 0?Ye:Ce.scene,ia=(mt=li.instanceId)!==null&&mt!==void 0?mt:li.id,Ra=(He=me.find(function(Es){return Es.id===ia}))!==null&&He!==void 0?He:li,Pa=(qe=Ra.prototypeId)!==null&&qe!==void 0?qe:Ra.id,Xa=Ce.createMeshObject(li,Ma,ia,Pa,!!li.parameters.attachToCamera);Ce.dynamicNodes.set(li.id,Xa)};try{for(var Ln=vn(me),Zt=Ln.next();!Zt.done;Zt=Ln.next()){var zn=Zt.value;Dt(zn)}}catch(li){ge={error:li}}finally{try{Zt&&!Zt.done&&(oe=Ln.return)&&oe.call(Ln)}finally{if(ge)throw ge.error}}var nt=It>=Nt,Vn=Ce.lastTime<0||qt<Ce.lastTime?0:Math.min(.05,qt-Ce.lastTime),Cn=Math.max(1,It/Math.max(1,Ft??It)),wi=function(li){return Cn>1.001?Math.min(135,2*Math.atan(Math.tan(li*Math.PI/360)*Cn)*(180/Math.PI)):li},fi=Nt/Math.max(1,It),xr=wi(ae?nt?(pt=Qt.cameraFov)!==null&&pt!==void 0?pt:68:(at=Qt.landscapeCameraFov)!==null&&at!==void 0?at:54:nt?(ot=Qt.cameraFov)!==null&&ot!==void 0?ot:39:(Vt=Qt.landscapeCameraFov)!==null&&Vt!==void 0?Vt:22.6199);Ce.recoil>0&&(Ce.recoil=Vn>0?Ce.recoil*Math.exp(-10*Vn):Ce.recoil,Ce.recoil<.002&&(Ce.recoil=0));var ss=Mg(Mg([],Ga(Ce.nodeEntries),!1),Ga(me.map(function(li){return{id:li.id,obj:Ce.dynamicNodes.get(li.id),comp:li}}).filter(function(li){return li.obj})),!1),ya="";try{for(var na=vn(ss),xa=na.next();!xa.done;xa=na.next()){var ws=xa.value,Ha=ws.id,Oi=ws.obj,zn=ws.comp,Gn=si(zn);Oi.visible=Gn.visible!==!1,!((cn=Ce.modelBindings.get(Ha))===null||cn===void 0)&&cn.update(Gn)&&(Ce.textureDirty=!0,Ce.compiled=!1),!Gn.useTexture&&Oi.isMesh&&(!((Ze=Oi.material)===null||Ze===void 0)&&Ze.color)&&Gn.color&&Oi.material.color.set(Gn.color);var jn=A?.get(Ha);if(jn&&jn.mode==="dynamic"){var Zi=jn.captured?Math.min(1,((pn=jn.captureElapsed)!==null&&pn!==void 0?pn:0)/.55):0,Ks=jn.captured&&jn.captureTarget?jn.x+(jn.captureTarget.x-jn.x)*Zi:jn.x,tn=jn.y-Zi*.45,To=jn.captured&&jn.captureTarget?jn.z+(jn.captureTarget.z-jn.z)*Zi:jn.z;Oi.position.set(Ks,tn,To);var sr=1-Zi*.65;Oi.scale.set(((ne=Gn.sx)!==null&&ne!==void 0?ne:1)*sr,((Tn=Gn.sy)!==null&&Tn!==void 0?Tn:1)*sr,((gn=Gn.sz)!==null&&gn!==void 0?gn:1)*sr),Oi.rotation.set(-((Q=jn.spin)!==null&&Q!==void 0?Q:0),(I=Gn.ry)!==null&&I!==void 0?I:0,((ie=jn.spin)!==null&&ie!==void 0?ie:0)*.22)}else if(jn&&jn.mode==="kinematic")Oi.position.set(jn.x,(De=(be=jn.y)!==null&&be!==void 0?be:Gn.y)!==null&&De!==void 0?De:0,jn.z),Oi.rotation.set((Je=Gn.rx)!==null&&Je!==void 0?Je:0,-((Ne=(je=jn.angle)!==null&&je!==void 0?je:Gn.ry)!==null&&Ne!==void 0?Ne:0),(Pe=Gn.rz)!==null&&Pe!==void 0?Pe:0);else if(Gn.dropShadowOf&&A?.has(Gn.dropShadowOf)){var Qi=A.get(Gn.dropShadowOf),os=Ge?(it=Ge(Qi,Qi.x,Qi.z))!==null&&it!==void 0?it:-1:0;Oi.position.set(Qi.x,os+.008,Qi.z);var Rl=Math.max(0,Qi.y-os-Qi.radius);Oi.material&&(Oi.material.opacity=.22/(1+Rl*2));var sr=1+Rl*.4;Oi.scale.set(sr,sr,sr),Oi.visible=!Qi.captured&&Gn.visible!==!1}else if(Gn.attachToCamera){var Un=Math.tan(((Rt=Qt.cameraFov)!==null&&Rt!==void 0?Rt:68)*Math.PI/360),or=Math.tan(xr*Math.PI/360),Wa=or/Math.max(.05,Un),sr=Math.min(1,Wa),Eo=Math.min(1.15,Wa)*(fi>1.3?1.12:1),Df=Eo*Math.min(3.55,fi/(390/700)),Ao=(Mt=Ce.recoil)!==null&&Mt!==void 0?Mt:0;Oi.position.set(((ct=Gn.x)!==null&&ct!==void 0?ct:0)*Df,((Gt=Gn.y)!==null&&Gt!==void 0?Gt:0)*Eo+Ao*.085*sr,((Kt=Gn.z)!==null&&Kt!==void 0?Kt:0)+Ao*.3*sr),Oi.rotation.set(((nn=Gn.rx)!==null&&nn!==void 0?nn:0)+Ao*.34,((he=Gn.ry)!==null&&he!==void 0?he:0)+(fi>1.1?.1:0),((dt=Gn.rz)!==null&&dt!==void 0?dt:0)-Ao*.09),Oi.scale.set(((Ee=Gn.sx)!==null&&Ee!==void 0?Ee:1)*sr,((gt=Gn.sy)!==null&&gt!==void 0?gt:1)*sr,((Ke=Gn.sz)!==null&&Ke!==void 0?Ke:1)*sr)}else Oi.position.set((We=Gn.x)!==null&&We!==void 0?We:0,(Wt=Gn.y)!==null&&Wt!==void 0?Wt:0,(Lt=Gn.z)!==null&&Lt!==void 0?Lt:0),Oi.rotation.set((yt=Gn.rx)!==null&&yt!==void 0?yt:0,(Et=Gn.ry)!==null&&Et!==void 0?Et:0,(rt=Gn.rz)!==null&&rt!==void 0?rt:0),Oi.scale.set((Ut=Gn.sx)!==null&&Ut!==void 0?Ut:1,(an=Gn.sy)!==null&&an!==void 0?an:1,(hn=Gn.sz)!==null&&hn!==void 0?hn:1);(ae||Ce.dynamicNodes.size>0)&&(ya+="".concat(Ha,":").concat(+Oi.visible,",").concat(Oi.position.x*100|0,",").concat(Oi.position.y*100|0,",").concat(Oi.position.z*100|0,",").concat(Oi.rotation.x*100|0,",").concat(Oi.rotation.y*100|0,"|"))}}catch(li){$={error:li}}finally{try{xa&&!xa.done&&(Te=na.return)&&Te.call(na)}finally{if($)throw $.error}}var _a;if(A)try{for(var Qs=vn(A.values()),js=Qs.next();!js.done;js=Qs.next()){var jn=js.value;if(jn.stageId===k.id&&jn.captured){_a=jn;break}}}catch(li){Le={error:li}}finally{try{js&&!js.done&&(se=Qs.return)&&se.call(Qs)}finally{if(Le)throw Le.error}}var nu=function(li){var Ma=!!_a,ia=_a&&(en=_a.captureElapsed)!==null&&en!==void 0?en:0;li.pieces.forEach(function(Ra,Pa){var Xa,Es,As,Co,Dl,Nl;if(Ra.visible=Ma,!!Ma){var Ro=Pa*2.399,Of=(Es=(Xa=_a.captureTarget)===null||Xa===void 0?void 0:Xa.x)!==null&&Es!==void 0?Es:li.origin.x,ru=(Co=(As=_a.captureTarget)===null||As===void 0?void 0:As.y)!==null&&Co!==void 0?Co:li.origin.y,Bf=(Nl=(Dl=_a.captureTarget)===null||Dl===void 0?void 0:Dl.z)!==null&&Nl!==void 0?Nl:li.origin.z;Ra.position.set(Of+Math.cos(Ro)*ia*(.5+Pa%4*.17),ru+.3+Math.sin(Math.min(1,ia/2)*Math.PI)*(1+Pa%5*.15),Bf+Math.sin(Ro)*ia*(.5+Pa%4*.17)),Ra.rotation.set(ia*3+Pa,ia*2+Pa,Math.sin(ia+Pa))}})};try{for(var Bi=vn(Ce.confettiSystems),ki=Bi.next();!ki.done;ki=Bi.next()){var ls=ki.value;nu(ls)}}catch(li){re={error:li}}finally{try{ki&&!ki.done&&(Ie=Bi.return)&&Ie.call(Bi)}finally{if(re)throw re.error}}Ce.camera.aspect=fi;var Xr=!1;if(ae)Ce.lastTime=qt,Ce.camera.rotation.order="YXZ",Ce.camera.position.set(ae.x,ae.y+((Ht=ae.bob)!==null&&Ht!==void 0?Ht:0),ae.z),Ce.camera.rotation.set(ae.pitch,ae.yaw,0),Ce.camera.fov=xr,ya+="c:".concat(Ce.camera.position.x*100|0,",").concat(Ce.camera.position.y*100|0,",").concat(Ce.camera.position.z*100|0,",").concat(ae.yaw*1e3|0,",").concat(ae.pitch*1e3|0,",").concat(xr*100|0,",").concat(fi*1e3|0,",").concat(((yn=Ce.recoil)!==null&&yn!==void 0?yn:0)*1e3|0);else{var cs=Qt.followTargetId?A?.get(Qt.followTargetId):void 0,Ca=cs?cs.z*((bn=Qt.followZFactor)!==null&&bn!==void 0?bn:.12):(Yt=Qt.lookAtZ)!==null&&Yt!==void 0?Yt:0,Ts=Ce.lastTime<0||qt<Ce.lastTime;Ts?Ce.focusZ=Ca:!et&&Vn>0&&(Ce.focusZ+=(Ca-Ce.focusZ)*(1-Math.exp(-6*Vn))),Ce.lastTime=qt;var Nf=Math.max(0,1-qt/1.5);if(Xr=!Qt.followTargetId&&((Ot=Qt.introLift)!==null&&Ot!==void 0?Ot:2)===0,!et){var iu=Xr?Math.sin(qt*.42)*1.15:0,Uf=Xr?(Math.cos(qt*.42)-1)*.55:0,Ff=(nt?($n=Qt.cameraX)!==null&&$n!==void 0?$n:10:(Xn=Qt.landscapeCameraX)!==null&&Xn!==void 0?Xn:13)+iu,Pl=nt?((Nn=Qt.cameraY)!==null&&Nn!==void 0?Nn:18)+Nf*((ni=Qt.introLift)!==null&&ni!==void 0?ni:2):(wn=Qt.landscapeCameraY)!==null&&wn!==void 0?wn:15,Io=(nt?(Pn=Qt.cameraZ)!==null&&Pn!==void 0?Pn:21:(Bn=Qt.landscapeCameraZ)!==null&&Bn!==void 0?Bn:18)+Uf,Ll=Ts?Pl:Vn===0?Ce.camera.position.y:Ce.camera.position.y+(Pl-Ce.camera.position.y)*(1-Math.exp(-6*Vn));Ce.camera.position.set(Ff,Ll,Io+Ce.focusZ),Ce.camera.fov=xr,Ce.camera.lookAt((fn=Qt.lookAtX)!==null&&fn!==void 0?fn:0,(En=Qt.lookAtY)!==null&&En!==void 0?En:.15,Ce.focusZ)}ya+="a:".concat(fi*1e3|0,",").concat(xr*100|0)}return Ce.camera.updateProjectionMatrix(),Ce.camera.updateMatrixWorld(!0),Ce.scene.updateMatrixWorld(!0),{entry:Ce,waveTime:qt,victorySway:Xr,poseParts:ya}}function X(k,G,te,le,ge,oe,$){var Te,Le,se,re,Ie,ke,xe,Ye,mt,He,qe,pt,at,ot,Vt,cn,Ze,pn,ne,Tn,gn,Q,I=D(k,Jc(Jc({},$),{worldWidth:(mt=$.worldWidth)!==null&&mt!==void 0?mt:ge,worldHeight:(He=$.worldHeight)!==null&&He!==void 0?He:oe})),ie=I.entry,be=I.waveTime,De=I.victorySway,Je=I.poseParts,je=$.bodies3d,Ne=(qe=$.drawX)!==null&&qe!==void 0?qe:0,Pe=(pt=$.drawY)!==null&&pt!==void 0?pt:0,it=E(ie,(at=$.contactParticles)!==null&&at!==void 0?at:[]);Object.assign(ie,{lastX:Ne,lastY:Pe,lastWidth:ge,lastHeight:oe,lastDesignH:(ot=$.designHeight)!==null&&ot!==void 0?ot:oe,isFullBleed:!!$.fullBleed});var Rt=te>=2&&le>=2?P():null;if(!Rt||!((Ze=(cn=(Vt=Rt.getContext)===null||Vt===void 0?void 0:Vt.call(Rt))===null||cn===void 0?void 0:cn.isContextLost)===null||Ze===void 0)&&Ze.call(cn))return G.fillStyle=ie.skyColor,G.fillRect(Ne,Pe,ge,oe),ie;var Mt=Math.max(te,le,1),ct=$.propsOf(k),Gt=(pn={none:la,neutral:Fc,aces:Uc}[ct.toneMapping])!==null&&pn!==void 0?pn:la;Rt.toneMapping=Gt;var Kt=!!ct.shadowsEnabled,nn=Number((ne=ct.shadowMapSize)!==null&&ne!==void 0?ne:512);Rt.shadowMap.enabled=Kt,ie.sun.castShadow=Kt,ie.sun.shadow.mapSize.x!==nn&&(ie.sun.shadow.mapSize.set(nn,nn),(Tn=ie.sun.shadow.map)===null||Tn===void 0||Tn.dispose(),ie.sun.shadow.map=null);var he=(gn=ct.envIntensity)!==null&&gn!==void 0?gn:.8;(ie.textureDirty||!ie.compiled)&&(ie.usesPbr=!1,ie.scene.traverse(function(fn){var En;!((En=fn.material)===null||En===void 0)&&En.isMeshStandardMaterial&&(ie.usesPbr=!0)})),ie.usesPbr&&he>0&&(l??(l=n1(Rt))),ie.scene.environment=ie.usesPbr&&he>0?l?.texture:null,ie.scene.environmentIntensity=he;var dt=[Gt,Kt,nn,he].join("/");ie.lightingKey!==dt&&(ie.textureDirty=!0,ie.lightingKey=dt);var Ee=(Q=ct.renderMaxDim)!==null&&Q!==void 0?Q:520,gt=Mt>Ee?Ee/Mt:1,Ke=Math.max(2,Math.round(te*gt)),We=Math.max(2,Math.round(le*gt)),Wt=x.width!==Ke||x.height!==We;if(Wt&&(Rt.setPixelRatio(1),Rt.setSize(Ke,We,!1),g.width=Ke,g.height=We,F=void 0),!ie.compiled){ie.compiled=!0;var Lt=[];ie.guidePool[0]&&!ie.guidePool[0].visible&&(ie.guidePool[0].visible=!0,ie.guidePool[0].position.set(0,-99,0),Lt.push(ie.guidePool[0]));try{for(var yt=vn(ie.confettiSystems),Et=yt.next();!Et.done;Et=yt.next()){var rt=Et.value;rt.pieces[0]&&!rt.pieces[0].visible&&(rt.pieces[0].visible=!0,rt.pieces[0].position.set(0,-99,0),Lt.push(rt.pieces[0]))}}catch(fn){Te={error:fn}}finally{try{Et&&!Et.done&&(Le=yt.return)&&Le.call(yt)}finally{if(Te)throw Te.error}}Rt.compile(ie.scene,ie.camera);try{for(var Ut=vn(Lt),an=Ut.next();!an.done;an=Ut.next()){var hn=an.value;hn.visible=!1}}catch(fn){se={error:fn}}finally{try{an&&!an.done&&(re=Ut.return)&&re.call(Ut)}finally{if(se)throw se.error}}}var en=!1;if(je)try{for(var Ht=vn(je.values()),yn=Ht.next();!yn.done;yn=Ht.next()){var bn=yn.value;if(bn.stageId===k.id&&(bn.mode==="kinematic"||bn.mode==="dynamic"&&(!bn.atRest||bn.captured))){en=!0;break}}}catch(fn){Ie={error:fn}}finally{try{yn&&!yn.done&&(ke=Ht.return)&&ke.call(Ht)}finally{if(Ie)throw Ie.error}}var Yt=Math.floor(be*20),Ot=ie.wavingFlags.length>0&&ie.lastFlagStep!==Yt,$n=De&&Math.abs(be-ie.lastRenderedTime)>=.032,Xn=en&&ie.lastRenderedTime!==be,Nn=Je!==ie.lastPoseSig,ni=Wt||F!==k.id||ie.guideDirty||ie.textureDirty||ie.animDirty||ie.lastRenderedTime<0||ie.lastRenderedW!==Ke||ie.lastRenderedH!==We||Ot||$n||Xn||Nn||it;if(ni){if(ie.wavingFlags.length>0&&ie.lastFlagStep!==Yt){try{for(var wn=vn(ie.wavingFlags),Pn=wn.next();!Pn.done;Pn=wn.next()){var Bn=Pn.value;t1(Bn.geo,Bn.rest,Yt/20)}}catch(fn){xe={error:fn}}finally{try{Pn&&!Pn.done&&(Ye=wn.return)&&Ye.call(wn)}finally{if(xe)throw xe.error}}ie.lastFlagStep=Yt}Rt.setClearColor(ie.skyColor,1),Rt.render(ie.scene,ie.camera),x.width>0&&x.height>0&&(v.drawImage(x,0,0,Ke,We),F=k.id),ie.lastRenderedTime=be,ie.lastRenderedW=Ke,ie.lastRenderedH=We,ie.lastPoseSig=Je,ie.guideDirty=!1,ie.textureDirty=!1,ie.animDirty=!1}return g.width>0&&g.height>0&&G.drawImage(g,Ne,Pe,ge,oe),ie}function Y(){var k,G,te,le,ge,oe,$,Te;try{for(var Le=vn(m.values()),se=Le.next();!se.done;se=Le.next()){var re=se.value;try{for(var Ie=(te=void 0,vn(re.dynamicNodes)),ke=Ie.next();!ke.done;ke=Ie.next()){var xe=Ga(ke.value,2),Ye=xe[0],mt=xe[1];($=mt.parent)===null||$===void 0||$.remove(mt),h(mt),re.modelBindings.delete(Ye)}}catch(at){te={error:at}}finally{try{ke&&!ke.done&&(le=Ie.return)&&le.call(Ie)}finally{if(te)throw te.error}}re.dynamicNodes.clear();try{for(var He=(ge=void 0,vn(re.modelBindings.values())),qe=He.next();!qe.done;qe=He.next()){var pt=qe.value;(Te=pt.animator)===null||Te===void 0||Te.reset(),pt.startDefaultAnimation()}}catch(at){ge={error:at}}finally{try{qe&&!qe.done&&(oe=He.return)&&oe.call(He)}finally{if(ge)throw ge.error}}re.animDirty=!0,re.focusZ=0,re.lastTime=-1,re.lastRenderedTime=-1,re.lastFlagStep=-1,re.lastPoseSig="",re.guideDirty=!0,re.setGuide([])}}catch(at){k={error:at}}finally{try{se&&!se.done&&(G=Le.return)&&G.call(Le)}finally{if(k)throw k.error}}}function W(){var k,G,te,le,ge,oe,$,Te,Le,se,re,Ie,ke,xe,Ye,mt;try{for(var He=vn(m.values()),qe=He.next();!qe.done;qe=He.next()){var pt=qe.value;try{for(var at=(te=void 0,vn((Ye=pt.contactBatches)!==null&&Ye!==void 0?Ye:[])),ot=at.next();!ot.done;ot=at.next()){var Vt=ot.value;Vt.dispose()}}catch(Pe){te={error:Pe}}finally{try{ot&&!ot.done&&(le=at.return)&&le.call(at)}finally{if(te)throw te.error}}h(pt.scene),pt.sun.shadow.dispose()}}catch(Pe){k={error:Pe}}finally{try{qe&&!qe.done&&(G=He.return)&&G.call(He)}finally{if(k)throw k.error}}try{for(var cn=vn(o),Ze=cn.next();!Ze.done;Ze=cn.next()){var pn=Ze.value;pn.dispose()}}catch(Pe){ge={error:Pe}}finally{try{Ze&&!Ze.done&&(oe=cn.return)&&oe.call(cn)}finally{if(ge)throw ge.error}}try{for(var ne=vn(u),Tn=ne.next();!Tn.done;Tn=ne.next()){var gn=Tn.value;gn.dispose()}}catch(Pe){$={error:Pe}}finally{try{Tn&&!Tn.done&&(Te=ne.return)&&Te.call(ne)}finally{if($)throw $.error}}try{for(var Q=vn(a.values()),I=Q.next();!I.done;I=Q.next()){var ie=I.value;ie.dispose()}}catch(Pe){Le={error:Pe}}finally{try{I&&!I.done&&(se=Q.return)&&se.call(Q)}finally{if(Le)throw Le.error}}try{for(var be=vn(s.values()),De=be.next();!De.done;De=be.next()){var Je=De.value;try{for(var je=(ke=void 0,vn(Je.textures.values())),Ne=je.next();!Ne.done;Ne=je.next()){var ie=Ne.value;ie.dispose()}}catch(Pe){ke={error:Pe}}finally{try{Ne&&!Ne.done&&(xe=je.return)&&xe.call(je)}finally{if(ke)throw ke.error}}}}catch(Pe){re={error:Pe}}finally{try{De&&!De.done&&(Ie=be.return)&&Ie.call(be)}finally{if(re)throw re.error}}u.clear(),o.clear(),s.clear(),l?.dispose(),l=void 0,m.clear(),r.clear(),a.clear(),(mt=_?.forceContextLoss)===null||mt===void 0||mt.call(_),_?.dispose(),_=void 0,x=void 0,g=void 0,v=void 0,F=void 0}function C(k,G){var te,le,ge,oe;try{for(var $=vn(m.values()),Te=$.next();!Te.done;Te=$.next()){var Le=Te.value,se=function(mt,He){if(!He.animator)return"continue";He.animator.step(k,function(qe){var pt;return G?.(mt,(pt=He.sourceId)!==null&&pt!==void 0?pt:mt,qe)})&&(Le.animDirty=!0)};try{for(var re=(ge=void 0,vn(Le.modelBindings)),Ie=re.next();!Ie.done;Ie=re.next()){var ke=Ga(Ie.value,2),xe=ke[0],Ye=ke[1];se(xe,Ye)}}catch(mt){ge={error:mt}}finally{try{Ie&&!Ie.done&&(oe=re.return)&&oe.call(re)}finally{if(ge)throw ge.error}}}}catch(mt){te={error:mt}}finally{try{Te&&!Te.done&&(le=$.return)&&le.call($)}finally{if(te)throw te.error}}}function M(k,G){var te,le,ge,oe,$;G===void 0&&(G={});var Te=!1;try{for(var Le=vn(m.values()),se=Le.next();!se.done;se=Le.next()){var re=se.value;try{for(var Ie=(ge=void 0,vn(re.modelBindings)),ke=Ie.next();!ke.done;ke=Ie.next()){var xe=Ga(ke.value,2),Ye=xe[0],mt=xe[1];Ye!==k&&mt.sourceId!==k||!(($=mt.animator)===null||$===void 0)&&$.play(G.clipName||"",G)&&(re.animDirty=!0,Te=!0)}}catch(He){ge={error:He}}finally{try{ke&&!ke.done&&(oe=Ie.return)&&oe.call(Ie)}finally{if(ge)throw ge.error}}}}catch(He){te={error:He}}finally{try{se&&!se.done&&(le=Le.return)&&le.call(Le)}finally{if(te)throw te.error}}return Te}function J(k){var G,te;try{for(var le=vn(m.values()),ge=le.next();!ge.done;ge=le.next()){var oe=ge.value,$=oe.modelBindings.get(k);if($?.modelBounds)return $.modelBounds}}catch(Te){G={error:Te}}finally{try{ge&&!ge.done&&(te=le.return)&&te.call(le)}finally{if(G)throw G.error}}return null}function q(){var k,G,te,le,ge,oe,$={texturesPending:0,textureErrors:0,animations:{}};try{for(var Te=vn(s.values()),Le=Te.next();!Le.done;Le=Te.next()){var se=Le.value,re=se.imageStatus();$.texturesPending+=re.texturesPending,$.textureErrors+=re.textureErrors}}catch(at){k={error:at}}finally{try{Le&&!Le.done&&(G=Te.return)&&G.call(Te)}finally{if(k)throw k.error}}try{for(var Ie=vn(m.values()),ke=Ie.next();!ke.done;ke=Ie.next()){var xe=ke.value;try{for(var Ye=(ge=void 0,vn(xe.modelBindings)),mt=Ye.next();!mt.done;mt=Ye.next()){var He=Ga(mt.value,2),qe=He[0],pt=He[1];pt.animator&&($.animations[qe]=pt.animator.snapshot())}}catch(at){ge={error:at}}finally{try{mt&&!mt.done&&(oe=Ye.return)&&oe.call(Ye)}finally{if(ge)throw ge.error}}}}catch(at){te={error:at}}finally{try{ke&&!ke.done&&(le=Ie.return)&&le.call(Ie)}finally{if(te)throw te.error}}return $}function ce(k){var G=m.get(k);G&&(G.recoil=1)}return{getStage:L,syncStage:D,renderStage:X,reset:Y,dispose:W,stepAnimations:C,playModelAnimation:M,modelBoundsFor:J,modelStatus:q,triggerRecoil:ce}}var bs=function(){return bs=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},bs.apply(this,arguments)},Aa=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Ia=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},$c=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Tg=function(n,e,t){return Math.max(e,Math.min(t,n))},$s=function(n,e){return Math.hypot(e.x-n.x,e.y-n.y)};function Eg(n){var e=n.id,t=n.nodes,i=n.edges,r=n.gates,a=r===void 0?[]:r,s=n.onEvent,o=s===void 0?function(){}:s,u=new Map(t.map(function(M){return[M.id,bs({},M)]})),l=new Map(i.map(function(M){return[M.id,bs({speedScale:1,enabled:!0,bidirectional:!1,cost:0},M)]})),d=new Map(a.map(function(M){return[M.id,bs({},M)]})),f=new Map,h=f,m=0,x=0,_=function(M){return u.get(M)},g=function(M){return Ia([],Aa(d.values()),!1).find(function(J){return J.parameters.nodeId===M})},v=function(M){var J=M.parameters;if(J.mode==="open")return!0;if(J.mode==="closed")return!1;var q=J.openSeconds+J.closedSeconds,ce=(m+J.phaseOffsetSeconds)%q;return ce<J.openSeconds},F=function(M){return Ia([],Aa(l.values()),!1).filter(function(J){return J.enabled&&(J.from===M||J.bidirectional&&J.to===M)}).sort(function(J,q){return J.id<q.id?-1:J.id>q.id?1:0})},P=function(M,J){return Ia([],Aa(l.values()),!1).find(function(q){return q.enabled&&(q.from===M&&q.to===J||q.bidirectional&&q.from===J&&q.to===M)})};function S(M,J){var q,ce,k,G;if(M===J)return[M];for(var te=new Map([[M,0]]),le=new Map,ge=new Set([M]);ge.size;){var oe=Ia([],Aa(ge),!1).sort(function(He,qe){return te.get(He)-te.get(qe)||(He<qe?-1:He>qe?1:0)})[0];if(ge.delete(oe),oe===J)break;try{for(var $=(q=void 0,$c(F(oe))),Te=$.next();!Te.done;Te=$.next()){var Le=Te.value,se=Le.from===oe?Le.to:Le.from,re=g(se),Ie=_(se),ke=re?re.parameters.holdSeconds*90+(v(re)?0:re.parameters.closedSeconds*90):0,xe=te.get(oe)+$s(_(oe),Ie)/Le.speedScale+Le.cost+((k=Ie.cost)!==null&&k!==void 0?k:0)+ke;xe>=((G=te.get(se))!==null&&G!==void 0?G:1/0)||(te.set(se,xe),le.set(se,oe),ge.add(se))}}catch(He){q={error:He}}finally{try{Te&&!Te.done&&(ce=$.return)&&ce.call($)}finally{if(q)throw q.error}}}if(!te.has(J))return[];for(var Ye=[J],mt=J;mt!==M;)mt=le.get(mt),Ye.unshift(mt);return Ye}function N(M){var J,q=M.route.length>=2&&M.segment<M.route.length-1;if(!q){var ce=(J=M.route[Math.min(M.segment,M.route.length-1)])!==null&&J!==void 0?J:M.startNode,k=S(ce,M.target);M.route=k.length?k:[ce],M.segment=0,M.distance=0,M.arrived=!1,M.active=M.route.length>=2;return}var G=M.route[M.segment],te=M.route[M.segment+1],le=$s(_(G),_(te));if(M.arrived||M.distance>=le-1e-4){var k=S(te,M.target);M.route=k.length?k:[te],M.segment=0,M.distance=0,M.arrived=!1,M.active=M.route.length>=2;return}var ge=S(te,M.target);M.route=ge.length?Ia([G],Aa(ge),!1):[G,te],M.segment=0}function p(M){var J,q=S(M.startNode,M.targetNode),ce=_(M.startNode),k=q.length>=2?_(q[1]):ce,G=q.length>=2?Math.atan2(k.y-ce.y,k.x-ce.x):0,te=Math.floor((G%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4,le=bs(bs({},M),{loop:(J=M.loop)!==null&&J!==void 0?J:"none",originNode:M.startNode,destinationNode:M.targetNode,target:M.targetNode,networkId:e,route:q.length?q:[M.startNode],segment:0,distance:0,x:ce.x,y:ce.y,heading:G,frame:[0,1,2,3][te],flipX:Math.cos(G)<0,hold:0,arrived:!1,active:M.active&&q.length>=2,blockedTicks:0,blockedEmitted:!1,speedMultiplier:1});return f.set(le.id,le),le}function L(M){if(E("pathArrive",M,M.target),M.loop==="none"){M.active=!1;return}var J=M.target,q=M.loop==="ping-pong"?J===M.destinationNode?M.originNode:M.destinationNode:J===M.originNode?M.destinationNode:M.originNode;M.startNode=J,M.target=q,M.route=S(J,q),M.segment=0,M.distance=0,M.arrived=!1,M.route.length<2&&(M.active=!1)}function E(M,J,q){o(M,{componentId:J.id,nodeId:q})}function D(M,J){var q,ce,k=M.route[M.segment+1],G=g(k);if(G&&!v(G)){M.blockedTicks++,M.blockedTicks>=30&&!M.blockedEmitted&&(M.blockedEmitted=!0,E("pathBlocked",M,k));return}if(!M.arrived){if(M.arrived=!0,M.segment+1===M.route.length-1){k===M.target?L(M):(M.active=!1,M.blockedEmitted||(M.blockedEmitted=!0,E("pathBlocked",M,k)));return}M.hold=Math.max((q=_(k).holdSeconds)!==null&&q!==void 0?q:0,(ce=G?.parameters.holdSeconds)!==null&&ce!==void 0?ce:0)}if(M.hold>0){M.hold=Math.max(0,M.hold-J),M.blockedTicks++,M.blockedTicks>=30&&!M.blockedEmitted&&(M.blockedEmitted=!0,E("pathBlocked",M,k));return}M.segment++,M.distance=0,M.arrived=!1,M.blockedTicks=0,M.blockedEmitted=!1}function X(M,J){var q,ce;if(M.spacing<=0)return J;var k=M.route[M.segment],G=M.route[M.segment+1],te=$s(_(k),_(G)),le=te-M.distance,ge=J;try{for(var oe=$c(h.values()),$=oe.next();!$.done;$=oe.next()){var Te=$.value;if(!(Te.id===M.id||!Te.active||Te.route.length<2||Te.segment>=Te.route.length-1)){var Le=Te.route[Te.segment],se=Te.route[Te.segment+1],re=1/0;if(Le===k&&se===G&&(Te.distance>M.distance||Te.distance===M.distance&&Te.id<M.id))re=Te.distance-M.distance;else if(Le===G)re=le+Te.distance;else if(se===G&&Le!==k){var Ie=$s(_(Le),_(se))-Te.distance;Ie<M.spacing&&(Ie<le||Ie===le&&Te.id<M.id)&&(re=le)}re<1/0&&(ge=Math.min(ge,Math.max(0,re-M.spacing)))}}}catch(ke){q={error:ke}}finally{try{$&&!$.done&&(ce=oe.return)&&ce.call(oe)}finally{if(q)throw q.error}}return ge}function Y(M){var J=_(M.route[M.segment]),q=_(M.route[M.segment+1]),ce=$s(J,q),k=Tg(M.distance/Math.max(1e-4,ce),0,1),G=J.x+(q.x-J.x)*k,te=J.y+(q.y-J.y)*k,le=Math.atan2(q.y-J.y,q.x-J.x),ge=Math.min(M.cornerRadius,ce/3),oe=M.route[M.segment+2];if(ge>0&&oe){var $=_(oe),Te=$s(q,$),Le=Math.min(ge,Te/3);if(M.distance>ce-ge){var se={x:q.x-(q.x-J.x)/ce*ge,y:q.y-(q.y-J.y)/ce*ge},re={x:q.x+($.x-q.x)/Te*Le,y:q.y+($.y-q.y)/Te*Le},Ie=Tg((M.distance-(ce-ge))/(ge*2),0,.5),ke=1-Ie;G=ke*ke*se.x+2*ke*Ie*q.x+Ie*Ie*re.x,te=ke*ke*se.y+2*ke*Ie*q.y+Ie*Ie*re.y;var xe=2*ke*(q.x-se.x)+2*Ie*(re.x-q.x),Ye=2*ke*(q.y-se.y)+2*Ie*(re.y-q.y);Math.abs(xe)+Math.abs(Ye)>.001&&(le=Math.atan2(Ye,xe))}}return{x:G,y:te,heading:le}}function W(M){var J,q,ce,k;m+=M,x++;var G=Ia([],Aa(f.values()),!1).sort(function(at,ot){return at.id<ot.id?-1:at.id>ot.id?1:0}),te=G.length?x%G.length:0,le=Ia(Ia([],Aa(G.slice(te)),!1),Aa(G.slice(0,te)),!1);try{for(var ge=$c(le),oe=ge.next();!oe.done;oe=ge.next()){var $=oe.value;if(!(!$.active||$.route.length<2||$.segment>=$.route.length-1)){var Te=$.route[$.segment],Le=$.route[$.segment+1],se=$s(_(Te),_(Le));if(!($.distance>=se-1e-4&&(D($,M),!$.active||$.route.length<2||$.segment>=$.route.length-1))){var re=$.route[$.segment],Ie=$.route[$.segment+1],ke=$s(_(re),_(Ie)),xe=ke-$.distance,Ye=(k=(ce=P(re,Ie))===null||ce===void 0?void 0:ce.speedScale)!==null&&k!==void 0?k:1,mt=Math.min(xe,$.speed*Ye*Math.max(0,$.speedMultiplier)*M),He=X($,mt);He<=1e-4?($.blockedTicks++,$.blockedTicks>=30&&!$.blockedEmitted&&($.blockedEmitted=!0,E("pathBlocked",$,Ie))):($.distance+=He,$.blockedTicks=0,$.blockedEmitted=!1);var qe=Y($);$.x=qe.x,$.y=qe.y,$.heading=qe.heading;var pt=Math.floor(($.heading%(Math.PI*2)+Math.PI*2+1e-6)%(Math.PI*2)/(Math.PI/2))%4;$.frame=[0,1,2,3][pt],$.flipX=Math.cos($.heading)<0}}}}catch(at){J={error:at}}finally{try{oe&&!oe.done&&(q=ge.return)&&q.call(ge)}finally{if(J)throw J.error}}}function C(){return{id:e,nodeCount:u.size,edgeCount:l.size,activeAgents:Ia([],Aa(f.values()),!1).filter(function(M){return M.active}).length,queuedAgents:Ia([],Aa(f.values()),!1).filter(function(M){return M.active&&M.blockedTicks>0}).length,agents:Ia([],Aa(f.values()),!1).map(function(M){var J;return{id:M.id,x:M.x,y:M.y,heading:M.heading,frame:(J=M.frame)!==null&&J!==void 0?J:0,flipX:!!M.flipX,active:M.active,targetNode:M.target,route:Ia([],Aa(M.route),!1),segment:M.segment,distance:M.distance,blocked:M.blockedTicks>0}})}}return{addAgent:p,removeAgent:function(M){return f.delete(M)},getAgent:function(M){return f.get(M)},setTarget:function(M,J){var q=f.get(M);return!q||!_(J)?!1:(q.target=J,q.destinationNode=J,q.active=!0,N(q),!0)},setEdge:function(M,J,q){var ce,k,G=l.get(M);if(!G)return!1;G.enabled=J,q!==void 0&&(G.cost=q);try{for(var te=$c(f.values()),le=te.next();!le.done;le=te.next()){var ge=le.value;N(ge)}}catch(oe){ce={error:oe}}finally{try{le&&!le.done&&(k=te.return)&&k.call(te)}finally{if(ce)throw ce.error}}return!0},setGate:function(M,J,q){var ce,k,G=d.get(M);if(!G)return!1;G.parameters=bs(bs({},G.parameters),{mode:J,holdSeconds:q});try{for(var te=$c(f.values()),le=te.next();!le.done;le=te.next()){var ge=le.value;N(ge)}}catch(oe){ce={error:oe}}finally{try{le&&!le.done&&(k=te.return)&&k.call(te)}finally{if(ce)throw ce.error}}return!0},tick:W,snapshot:C}}var Kc=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Ef=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},Af=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},If={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"]},Qc=function(n){var e,t,i,r,a=0;try{for(var s=Kc(n),o=s.next();!o.done;o=s.next()){var u=o.value;a+=((r=(i=If[u])===null||i===void 0?void 0:i[0].length)!==null&&r!==void 0?r:5)+1}}catch(l){e={error:l}}finally{try{o&&!o.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return Math.max(0,a-1)},i1=function(n,e){var t,i,r=[],a="";try{for(var s=Kc(n),o=s.next();!o.done;o=s.next()){var u=o.value;a&&Qc(a+u)>e&&(r.push(a),a=""),a+=u}}catch(l){t={error:l}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return a&&r.push(a),r};function r1(n,e,t){var i,r,a,s,o;t===void 0&&(t=1);var u=Math.max(1,Math.floor(e/Math.max(1,t))),l=[];try{for(var d=Kc(String(n).toUpperCase().split(`
4221
+ `)),f=d.next();!f.done;f=d.next()){var h=f.value,m=h.split(/\s+/).filter(Boolean);if(!m.length){l.push("");continue}var x="";try{for(var _=(a=void 0,Kc(m)),g=_.next();!g.done;g=_.next()){var v=g.value;if(Qc(v)>u){x&&l.push(x);var F=i1(v,u);l.push.apply(l,Af([],Ef(F.slice(0,-1)),!1)),x=(o=F.at(-1))!==null&&o!==void 0?o:""}else{var P=x?x+" "+v:v;Qc(P)<=u?x=P:(x&&l.push(x),x=v)}}}catch(S){a={error:S}}finally{try{g&&!g.done&&(s=_.return)&&s.call(_)}finally{if(a)throw a.error}}x&&l.push(x)}}catch(S){i={error:S}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(i)throw i.error}}return l}var Ag=function(n){var e,t=Math.max(0,(e=n.padding)!==null&&e!==void 0?e:4),i=n.pixelPanel&&n.padding===void 0;return{x:i?8:t,y:i?4:t}},a1=function(n,e,t,i){var r,a=e.wrap===!1?String(n).toUpperCase().split(`
4222
+ `):r1(n,i,t),s=a.slice(0,16),o=Math.round(t*8*((r=e.lineHeight)!==null&&r!==void 0?r:1.2));return{allLines:a,lines:s,renderedWidth:Math.max.apply(Math,Af([0],Ef(s.map(function(u){return Qc(u)*t})),!1)),renderedHeight:(s.length-1)*o+7*t}};function Jp(n,e){for(var t,i=Ag(e),r=Math.max(0,e.width-2*i.x),a=Math.max(0,e.height-2*i.y),s=Math.max(1,Math.floor(e.fontSize/8)),o=e.autoFit===!1?s:Math.min(s,Math.max(1,Math.ceil(((t=e.minFontSize)!==null&&t!==void 0?t:12)/8))),u=Af([],Ef(new Set(Af([],Ef(String(n).toUpperCase()),!1).filter(function(x){return x!==`
4223
+ `&&!If[x]}))),!1),l,d=s;d>=o;d--){var f=a1(n,e,d,r),h=f.renderedWidth>r,m=f.allLines.length>16||f.renderedHeight>a;if(l={lines:f.lines,scale:d,fontSize:d*8,renderedWidth:f.renderedWidth,renderedHeight:f.renderedHeight,overflowsWidth:h,overflowsHeight:m,unsupportedChars:u},e.autoFit===!1||!h&&!m)break}return l}function Ig(n,e,t){var i,r=Jp(e,t),a=r.lines,s=r.scale,o=Ag(t),u=Math.max(0,t.width-2*o.x),l=Math.max(0,t.height-2*o.y),d=Math.round(r.fontSize*((i=t.lineHeight)!==null&&i!==void 0?i:1.2)),f=o.y+(l-r.renderedHeight)/2;return n.fillStyle=t.color,a.forEach(function(h,m){var x,_,g,v=Qc(h)*s,F=t.align==="left"?o.x:t.align==="right"?t.width-v-o.x:o.x+(u-v)/2,P=F;try{for(var S=Kc(h),N=S.next();!N.done;N=S.next()){var p=N.value,L=(g=If[p])!==null&&g!==void 0?g:If["?"];L.forEach(function(E,D){for(var X=0;X<E.length;X++)E[X]==="1"&&n.fillRect(Math.round(P+X*s),Math.round(f+m*d+D*s),s,s)}),P+=(L[0].length+1)*s}}catch(E){x={error:E}}finally{try{N&&!N.done&&(_=S.return)&&_.call(S)}finally{if(x)throw x.error}}}),r}var as=function(){return as=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},as.apply(this,arguments)},Kp=Math.PI*2,qi=function(n,e){return((Math.imul(n+1,2654435769)^Math.imul(e,2246822507))>>>0)/4294967296};function Qp(n,e,t){var i,r,a=[n.color,n.color2,n.color3].filter(Boolean),s=((i=n.spread)!==null&&i!==void 0?i:360)*Math.PI/180,o=((r=n.direction)!==null&&r!==void 0?r:-90)*Math.PI/180;return Array.from({length:n.count},function(u,l){var d,f,h=o+((l+.2+qi(l,1)*.6)/n.count-.5)*s,m=n.speed*(.42+.65*qi(l,2));return as(as({},e),{clipId:t,shape:"pixel-confetti",age:-.12*qi(l,3),vx:Math.cos(h)*m,vy:Math.sin(h)*m,gravity:(d=n.gravity)!==null&&d!==void 0?d:250,life:((f=n.lifetime)!==null&&f!==void 0?f:.7)*(.6+.4*qi(l,4)),color:a[l%a.length],size:3+Math.floor(3*qi(l,5)),angle:Kp*qi(l,6),spin:(qi(l,7)-.5)*12})})}function Cg(n){var e=Math.min(12,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return Qp(n).map(function(r,a){return as(as({},r),{screen:!0,x:(a%e+.15+.7*qi(a,8))/e,y:(Math.floor(a/e)+.15+.7*qi(a,9))/t,vx:i*(qi(a,10)-.5)*.7,vy:i*(.3+.5*qi(a,11)),size:r.size+1})})}var Rf=function(n,e){return(n%e+e)%e};function Rg(n,e,t){var i=e.x,r=e.y,a=e.vx,s=e.vy,o=e.age,u=e.life,l=e.gravity,d=e.size,f=e.angle,h=e.spin,m=e.color;if(!(o<0)){var x=a*o,_=s*o+l*o*o/2,g=Math.round(t?t.x+Rf(i*t.width+x,t.width):i+x),v=Math.round(t?t.y+Rf(r*t.height+_,t.height):r+_),F=Math.round((f+h*o)/(Math.PI/4))&3;if(n.globalAlpha*=Math.min(1,(u-o)*4),n.fillStyle="#3c293388",F===0)n.fillRect(g-d+1,v+1,d*2+1,d+1);else if(F===2)n.fillRect(g+1,v-d+1,d+1,d*2+1);else for(var P=-1;P<=1;P++)n.fillRect(g+P*d+1,v+P*d*(F===1?1:-1)+1,d+1,d+1);if(n.fillStyle=m,F===0)n.fillRect(g-d,v,d*2,d);else if(F===2)n.fillRect(g,v-d,d,d*2);else for(var P=-1;P<=1;P++)n.fillRect(g+P*d,v+P*d*(F===1?1:-1),d,d)}}function jp(n,e,t){var i,r,a=[n.color,n.color2,n.color3,"#ff6b6b","#4ecdc4","#fff3b0"].filter(Boolean),s=((i=n.spread)!==null&&i!==void 0?i:360)*Math.PI/180,o=((r=n.direction)!==null&&r!==void 0?r:-90)*Math.PI/180;return Array.from({length:n.count},function(u,l){var d,f,h=o+((l+.2+qi(l,11)*.6)/n.count-.5)*s,m=n.speed*(.45+.65*qi(l,12));return as(as({},e),{clipId:t,shape:"confetti",age:-.15*qi(l,13),vx:Math.cos(h)*m,vy:Math.sin(h)*m,gravity:(d=n.gravity)!==null&&d!==void 0?d:140,life:((f=n.lifetime)!==null&&f!==void 0?f:2.6)*(.75+.35*qi(l,14)),color:a[l%a.length],size:5+Math.floor(5*qi(l,15)),kind:l%5===0?"star":"ribbon",angle:Kp*qi(l,16),spin:(qi(l,17)-.5)*5.5,flutter:1.6+2.2*qi(l,18),phase:Kp*qi(l,19)})})}function Pg(n){var e=Math.min(14,Math.ceil(Math.sqrt(n.count))),t=Math.ceil(n.count/e),i=n.speed;return jp(n,{x:0,y:0}).map(function(r,a){var s;return as(as({},r),{screen:!0,x:(a%e+.12+.76*qi(a,20))/e,y:(Math.floor(a/e)+.08+.84*qi(a,21))/t,vx:i*(qi(a,22)-.5)*.65,vy:i*(.38+.55*qi(a,23)),gravity:Math.min((s=n.gravity)!==null&&s!==void 0?s:90,90)})})}function Lg(n,e,t){var i=e.x,r=e.y,a=e.vx,s=e.vy,o=e.age,u=e.life,l=e.gravity,d=e.size,f=e.angle,h=e.spin,m=e.flutter,x=e.phase,_=e.color,g=e.kind;if(!(o<0)){var v=Math.sin(o*m+x)*14,F=a*o+v,P=s*o+l*o*o/2,S=t?t.x+Rf(i*t.width+F,t.width):i+F,N=t?t.y+Rf(r*t.height+P,t.height):r+P,p=Math.min(1,o*2.8,(u-o)*2.2);if(!(p<=0)){n.save(),n.globalAlpha*=p,n.translate(S,N),n.rotate(f+h*o);var L=Math.cos(o*m*1.4+x);if(n.scale(1,Math.max(.22,Math.abs(L))),n.fillStyle=_,g==="star"){var E=d*.85;n.beginPath();for(var D=0;D<8;D++){var X=D%2===0?E:E*.38,Y=D*Math.PI/4;D===0?n.moveTo(Math.cos(Y)*X,Math.sin(Y)*X):n.lineTo(Math.cos(Y)*X,Math.sin(Y)*X)}n.closePath(),n.fill()}else n.fillRect(-d*.7,-d*.34,d*1.4,d*.68),n.fillStyle="#ffffff55",n.fillRect(-d*.7,-d*.34,d*1.4,d*.2);n.restore()}}}function Dg(n,e,t,i,r){var a=e.width,s=e.height;if(!(a<=0||s<=0)){var o=Math.min(3,Math.floor(Math.min(a,s)/8));if(!o){n.fillStyle=t,n.fillRect(0,0,a,s);return}var u=i?o*2:0,l=s-(i?o:o*3),d=r>=0?.5+.5*Math.sin(r*4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd05a99",n.shadowBlur=8+d*9,n.fillStyle=t,n.fillRect(o,u+o,a-2*o,s-u-2*o),n.restore()),n.fillStyle=e.stroke,n.fillRect(o,0,a-2*o,s),n.fillRect(0,o,a,s-2*o),n.fillStyle=t,n.fillRect(o,u+o,a-2*o,s-u-2*o),n.fillStyle="#431d1380",n.fillRect(o,l,a-2*o,s-o-l),n.fillStyle=e.enabled?"#fff4be":"#ffffff55",n.fillRect(2*o,u+o,a-4*o,i?o:o*2),n.fillStyle="#ffffff55",n.fillRect(o,u+3*o,o,Math.max(0,l-u-3*o)),n.fillStyle="#521b2444",n.fillRect(a-2*o,u+3*o,o,Math.max(0,l-u-3*o));var f=r>=0?r%1.9:-1,h=(f-.1)/.55;if(e.enabled&&!i&&h>=0&&h<1){n.save(),n.beginPath(),n.rect(2*o,u+3*o,a-4*o,Math.max(0,l-u-3*o)),n.clip();for(var m=Math.floor(((a+14*o)*h-6*o)/o)*o,x=u+3*o,_=0;x<l;x+=o,_++){var g=m-Math.floor(_/2)*o;n.fillStyle="#fff4be44",n.fillRect(g-2*o,x,9*o,o),n.fillStyle="#fffef0aa",n.fillRect(g,x,4*o,o)}n.restore()}if(e.enabled&&!i&&r>=0){var v=Math.max(0,Math.sin(r*4.2)),F=Math.max(0,Math.sin(r*4.2+2.2)),P=function(S,N,p){if(!(p<.25)){n.save(),n.globalAlpha*=p*.95,n.fillStyle="#fffef4";var L=p>.65?o*2:o;n.fillRect(Math.round(S-L),Math.round(N-o/2),L*2+o,o),n.fillRect(Math.round(S-o/2),Math.round(N-L),o,L*2+o),n.restore()}};P(5*o,u+4*o,v),P(a-6*o,u+5*o,F)}}}function Cf(n,e,t,i,r,a){var s=Math.max(0,Math.min(a,i/2,r/2));n.beginPath(),typeof n.roundRect=="function"?n.roundRect(e,t,i,r,s):(n.moveTo(e+s,t),n.arcTo(e+i,t,e+i,t+r,s),n.arcTo(e+i,t+r,e,t+r,s),n.arcTo(e,t+r,e,t,s),n.arcTo(e,t,e+i,t,s),n.closePath())}function $p(n,e,t,i,r){if(!(r<=.02||i<=.5)){n.save(),n.translate(e,t),n.globalAlpha*=r,n.fillStyle="#fffef0",n.beginPath();for(var a=0;a<8;a++){var s=a%2===0?i:i*.24,o=a*Math.PI/4;a===0?n.moveTo(Math.cos(o)*s,Math.sin(o)*s):n.lineTo(Math.cos(o)*s,Math.sin(o)*s)}n.closePath(),n.fill(),n.restore()}}function Ng(n,e,t,i,r){var a,s,o,u=e.width,l=e.height;if(!(u<=0||l<=0)){var d=Math.min((a=e.radius)!==null&&a!==void 0?a:16,u/2,l/2),f=i?2:6,h=i?3:0,m=r>=0?.5-.5*Math.cos(r*2.4):0;e.enabled&&!i&&r>=0&&(n.save(),n.shadowColor="#ffd23f99",n.shadowBlur=10+m*12,Cf(n,0,h,u,l-h,d),n.fillStyle=t,n.fill(),n.restore()),n.save(),Cf(n,0,h+2,u,Math.max(4,l-h-2),d),n.fillStyle="#0e2830",n.fill(),n.restore(),n.save(),Cf(n,0,h,u,Math.max(4,l-f),d),n.fillStyle=t,n.fill(),n.clip();var x=(s=n.createLinearGradient)===null||s===void 0?void 0:s.call(n,0,h,0,l-f);if(x?.addColorStop&&(x.addColorStop(0,"#ffffffa8"),x.addColorStop(.42,"#ffffff26"),x.addColorStop(.45,"#00000000"),x.addColorStop(1,"#00000024"),n.fillStyle=x,n.fillRect(0,h,u,l-f)),n.fillStyle="#fffef0bb",n.fillRect(d*.55,h+3,Math.max(0,u-d*1.1),3),e.enabled&&!i&&r>=0){var _=(r%2.4-.15)/.95;if(_>0&&_<1){var g=_*_*(3-2*_),v=Math.sin(_*Math.PI),F=-u*.36+u*1.72*g;n.save(),n.globalAlpha*=v,n.translate(F,h),n.transform(1,0,-.36,1,0,0);var P=(o=n.createLinearGradient)===null||o===void 0?void 0:o.call(n,-48,0,48,0);P?.addColorStop?(P.addColorStop(0,"#ffffff00"),P.addColorStop(.32,"#ffffff48"),P.addColorStop(.5,"#fffef8cc"),P.addColorStop(.68,"#ffffff48"),P.addColorStop(1,"#ffffff00"),n.fillStyle=P,n.fillRect(-48,0,96,l)):(n.fillStyle="#fffef8a8",n.fillRect(-14,0,28,l)),n.restore()}}if(n.restore(),e.strokeWidth&&(n.save(),Cf(n,0,h,u,Math.max(4,l-f),d),n.strokeStyle=e.stroke,n.lineWidth=e.strokeWidth,n.stroke(),n.restore()),e.enabled&&!i&&r>=0){var S=Math.max(0,Math.sin(r*2.4)),N=S*S,p=Math.max(0,Math.sin(r*2.4+2.1)),L=p*p,E=Math.max(0,Math.sin(r*2.4+4.2)),D=E*E;$p(n,u*.12,h+9,4+N*6,N*.92),$p(n,u*.88,h+10,3.8+L*5.5,L*.9),$p(n,u*.76,Math.max(h+14,l-f-8),3+D*4.2,D*.8)}}}function Pf(n){if(/\s/.test(n)||n.length>512)return!1;var e=/^https:\/\/play\.google\.com\/store\/apps\/details\?id=[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*){1,9}$/,t=/^https:\/\/apps\.apple\.com\/([a-z]{2}\/)?app\/([a-zA-Z0-9-]+\/)?id[1-9][0-9]{5,19}$/;return e.test(n)&&!/id=example\.|[.=]placeholder(\.|$)|id=com\.example(\.|$)/.test(n)||t.test(n)}var jc=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},eu=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},em=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function Ug(n){var e,t,i;n===void 0&&(n={});var r=(e=n.timeoutMs)!==null&&e!==void 0?e:5e3,a=(t=n.pollMs)!==null&&t!==void 0?t:25;if(![r,a].every(function(k){return Number.isFinite(k)&&k>=1&&k<=6e4}))throw Error("Invalid Unity host deadline/poll interval");var s=(i=n.getHost)!==null&&i!==void 0?i:(function(){return window.mraid}),o=new Set,u=new Set,l=[],d={},f=!1,h=!1,m=!1,x=!1,_=!1,g=!1,v,F,P,S,N,p,L=function(){return m||x};function E(){var k,G,te;clearTimeout(N),clearTimeout(p);try{for(var le=jc(l.splice(0)),ge=le.next();!ge.done;ge=le.next()){var oe=eu(ge.value,2),$=oe[0],Te=oe[1];try{(te=d.mraid)===null||te===void 0||te.removeEventListener($,Te)}catch{}}}catch(Le){k={error:Le}}finally{try{ge&&!ge.done&&(G=le.return)&&G.call(le)}finally{if(k)throw k.error}}}function D(k){S?.(k instanceof Error?k:Error(String(k))),P=void 0,S=void 0}function X(k){var G,te;if(!L()){var le=f;if(m=!0,f=!1,h=!1,E(),D(k),le)try{for(var ge=jc(em([],eu(u),!1)),oe=ge.next();!oe.done;oe=ge.next()){var $=oe.value;$()}}catch(Te){G={error:Te}}finally{try{oe&&!oe.done&&(te=ge.return)&&te.call(ge)}finally{if(G)throw G.error}}o.clear(),u.clear()}}function Y(k,G){return l.push([k,G]),d.mraid.addEventListener(k,G),W(k,G)}function W(k,G){if(L()){try{d.mraid.removeEventListener(k,G)}catch{}return!1}return!0}function C(k){var G,te;if(!L()){if(typeof k!="boolean"){X(Error("Invalid Unity viewability event"));return}if(!f){v=k;return}if(h!==k){h=k;try{for(var le=jc(em([],eu(o),!1)),ge=le.next();!ge.done;ge=le.next()){var oe=ge.value;if(L())break;oe(h)}}catch($){G={error:$}}finally{try{ge&&!ge.done&&(te=le.return)&&te.call(le)}finally{if(G)throw G.error}}}}}var M=function(k){k==="hidden"&&X(Error("Unity host closed"))},J=function(){var k;f&&!L()&&((k=n.onResize)===null||k===void 0||k.call(n))};function q(){var k,G,te,le;if(!(!_||f||g||L())){g=!0;try{var ge=d.mraid.getState();if(L()||ge==="loading")return;if(ge==="hidden")throw Error("Unity host closed before ready");if(!["default","expanded","resized"].includes(ge))throw Error("Invalid Unity host state");var oe=d.mraid.getVersion();if(L())return;if(oe!=="3.0")throw Error("Unity Ads UA requires MRAID 3.0");try{for(var $=jc([["viewableChange",C],["stateChange",M],["sizeChange",J]]),Te=$.next();!Te.done;Te=$.next()){var Le=eu(Te.value,2),se=Le[0],re=Le[1];if(!Y(se,re))return}}catch(mt){k={error:mt}}finally{try{Te&&!Te.done&&(G=$.return)&&G.call($)}finally{if(k)throw k.error}}var Ie=d.mraid.isViewable();if(L())return;if(typeof Ie!="boolean")throw Error("Invalid Unity initial viewability");h=v??Ie,f=!0,clearTimeout(N),clearTimeout(p),P?.(),P=void 0,S=void 0;try{for(var ke=jc(em([],eu(o),!1)),xe=ke.next();!xe.done;xe=ke.next()){var Ye=xe.value;if(L())break;Ye(h)}}catch(mt){te={error:mt}}finally{try{xe&&!xe.done&&(le=ke.return)&&le.call(ke)}finally{if(te)throw te.error}}}catch(mt){X(mt)}finally{g=!1}}}function ce(){if(!L())try{var k=s();if(L())return;if(!k){p=setTimeout(ce,a);return}if(d.mraid=k,l.push(["ready",q]),d.mraid.addEventListener("ready",q),!W("ready",q))return;_=!0,q()}catch(G){X(G)}}return{init:function(){return F||(F=new Promise(function(k,G){P=k,S=G}),L()?(D(Error("Unity bridge destroyed")),F):(N=setTimeout(function(){return X(Error("Unity MRAID readiness timed out"))},r),ce(),F))},isReady:function(){return f&&!L()},isVisible:function(){return f&&h&&!L()},isClosed:L,onVisibilityChanged:function(k){return L()||o.add(k),function(){return o.delete(k)}},onClosed:function(k){return L()||u.add(k),function(){return u.delete(k)}},openStore:function(k){if(!f||!h||L()||!Pf(k))throw Error("Unity store request not permitted");d.mraid.open(k)},destroy:function(){x||(x=!0,f=!1,h=!1,E(),D(Error("Unity bridge destroyed")),o.clear(),u.clear())}}}var Il=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Cl=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},tm=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function Fg(n){var e;n===void 0&&(n={});var t=(e=n.getHost)!==null&&e!==void 0?e:(function(){return window.mraid}),i,r=!1,a=!1,s=!1,o=!1,u=!1,l,d,f,h,m,x=new Set,_=new Set,g=[];function v(){var Y,W;clearTimeout(h),clearTimeout(m);try{for(var C=Il(g.splice(0)),M=C.next();!M.done;M=C.next()){var J=Cl(M.value,2),q=J[0],ce=J[1];try{i?.removeEventListener(q,ce)}catch{}}}catch(k){Y={error:k}}finally{try{M&&!M.done&&(W=C.return)&&W.call(C)}finally{if(Y)throw Y.error}}}function F(Y,W){if(g.push([Y,W]),i.addEventListener(Y,W),s||o){try{i.removeEventListener(Y,W)}catch{}return!1}return!0}function P(Y){var W=Y instanceof Error?Y:Error(String(Y));f?.(W),d=void 0,f=void 0}function S(Y,W){var C,M;if(!(s||o)&&(s=!0,r=!1,a=!1,v(),P(Y),W))try{for(var J=Il(tm([],Cl(_),!1)),q=J.next();!q.done;q=J.next()){var ce=q.value;ce()}}catch(k){C={error:k}}finally{try{q&&!q.done&&(M=J.return)&&M.call(J)}finally{if(C)throw C.error}}}function N(){var Y,W,C,M;if(!(!u||r||s||o))try{var J=i.getState();if(s||o||J==="loading")return;if(J==="hidden"){S(Error("MRAID closed before ready"),!0);return}if(!["default","expanded","resized"].includes(J))throw Error("Invalid MRAID state");try{for(var q=Il([["viewableChange",L],["stateChange",E],["sizeChange",D]]),ce=q.next();!ce.done;ce=q.next()){var k=Cl(ce.value,2),G=k[0],te=k[1];if(!F(G,te))return}}catch($){Y={error:$}}finally{try{ce&&!ce.done&&(W=q.return)&&W.call(q)}finally{if(Y)throw Y.error}}var le=i.isViewable();if(s||o)return;if(typeof le!="boolean")throw Error("Invalid MRAID viewability");a=le,r=!0,clearTimeout(h),clearTimeout(m),d?.(),d=void 0,f=void 0;try{for(var ge=Il(tm([],Cl(x),!1)),oe=ge.next();!oe.done;oe=ge.next()){var te=oe.value;te(a)}}catch($){C={error:$}}finally{try{oe&&!oe.done&&(M=ge.return)&&M.call(ge)}finally{if(C)throw C.error}}}catch($){S($,r)}}var p=function(){return N()},L=function(Y){var W,C;if(!(!r||s||o)){if(typeof Y!="boolean"){S(Error("Invalid MRAID visibility event"),!0);return}a=Y;try{for(var M=Il(tm([],Cl(x),!1)),J=M.next();!J.done;J=M.next()){var q=J.value;q(a)}}catch(ce){W={error:ce}}finally{try{J&&!J.done&&(C=M.return)&&C.call(M)}finally{if(W)throw W.error}}}},E=function(Y){Y==="hidden"&&S(Error("MRAID closed"),!0)},D=function(){var Y;r&&!s&&!o&&((Y=n.onResize)===null||Y===void 0||Y.call(n))};function X(){var Y,W,C;if(!(s||o))try{if(i=t(),s||o)return;if(!i){m=setTimeout(X,(C=n.pollMs)!==null&&C!==void 0?C:50);return}if(![i.getState,i.isViewable,i.addEventListener,i.removeEventListener,i.open].every(function(G){return typeof G=="function"}))throw Error("Incomplete MRAID 2 interface");try{for(var M=Il([["ready",p]]),J=M.next();!J.done;J=M.next()){var q=Cl(J.value,2),ce=q[0],k=q[1];if(!F(ce,k))return}}catch(G){Y={error:G}}finally{try{J&&!J.done&&(W=M.return)&&W.call(M)}finally{if(Y)throw Y.error}}u=!0,N()}catch(G){S(G,!1)}}return{init:function(){var Y;return l||(l=new Promise(function(W,C){d=W,f=C}),s||o?(P(Error("MRAID bridge destroyed")),l):(h=setTimeout(function(){return S(Error("MRAID readiness timed out"),!1)},(Y=n.timeoutMs)!==null&&Y!==void 0?Y:5e3),X(),l))},isReady:function(){return r&&!s&&!o},isVisible:function(){return a&&r&&!s&&!o},isClosed:function(){return s||o},onVisibilityChanged:function(Y){return!s&&!o&&x.add(Y),function(){return x.delete(Y)}},onClosed:function(Y){return!s&&!o&&_.add(Y),function(){return _.delete(Y)}},openStore:function(Y){if(!r||!a||s||o||!Pf(Y))throw Error("MRAID store request not permitted");i.open(Y)},destroy:function(){o||(o=!0,r=!1,a=!1,v(),P(Error("MRAID bridge destroyed")),x.clear(),_.clear())}}}var bo=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},wo=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},tu=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))};function Og(n){n===void 0&&(n={});var e=new Set,t=new Set,i=new Set,r=[],a,s=!1,o=!1,u=!1,l=!1,d,f,h,m,x,_=function(){return u||l};function g(){var D,X;clearTimeout(m),clearTimeout(x);try{for(var Y=bo(r.splice(0)),W=Y.next();!W.done;W=Y.next()){var C=wo(W.value,2),M=C[0],J=C[1];try{a?.removeEventListener(M,J)}catch{}}}catch(q){D={error:q}}finally{try{W&&!W.done&&(X=Y.return)&&X.call(Y)}finally{if(D)throw D.error}}}function v(D){var X,Y;if(!_()){u=!0,s=!1,o=!1,g(),h?.(D instanceof Error?D:Error(String(D))),f=void 0,h=void 0;try{for(var W=bo(tu([],wo(t),!1)),C=W.next();!C.done;C=W.next()){var M=C.value;M()}}catch(J){X={error:J}}finally{try{C&&!C.done&&(Y=W.return)&&Y.call(W)}finally{if(X)throw X.error}}}}var F=function(D){if(!(typeof D!="number"||!Number.isFinite(D)||D<0))return Math.min(1,D>1?D/100:D)},P=function(D){if(typeof D=="boolean")return D;if(D&&typeof D=="object"&&typeof D.isViewable=="boolean")return D.isViewable},S=function(){var D,X,Y,W,C,M;if(!(s||_()||!a||((C=a.isReady)===null||C===void 0?void 0:C.call(a))===!1))try{o=a.isViewable();var J=(M=a.getAudioVolume)===null||M===void 0?void 0:M.call(a),q=J===void 0?void 0:F(J);if(typeof o!="boolean"||J!==void 0&&q===void 0)throw Error("Invalid DAPI initial state");if(s=!0,clearTimeout(m),clearTimeout(x),f?.(),f=void 0,h=void 0,q!==void 0)try{for(var ce=bo(tu([],wo(i),!1)),k=ce.next();!k.done;k=ce.next()){var G=k.value;G(q)}}catch(ge){D={error:ge}}finally{try{k&&!k.done&&(X=ce.return)&&X.call(ce)}finally{if(D)throw D.error}}try{for(var te=bo(tu([],wo(e),!1)),le=te.next();!le.done;le=te.next()){var G=le.value;G(o)}}catch(ge){Y={error:ge}}finally{try{le&&!le.done&&(W=te.return)&&W.call(te)}finally{if(Y)throw Y.error}}}catch(ge){v(ge)}},N=function(D){var X,Y;if(!_()){var W=P(D);if(W===void 0){v(Error("Invalid DAPI visibility"));return}o=W;try{for(var C=bo(tu([],wo(e),!1)),M=C.next();!M.done;M=C.next()){var J=M.value;J(W)}}catch(q){X={error:q}}finally{try{M&&!M.done&&(Y=C.return)&&Y.call(C)}finally{if(X)throw X.error}}}},p=function(D){var X,Y;if(!_()){var W=F(D);if(W===void 0){v(Error("Invalid DAPI volume"));return}try{for(var C=bo(tu([],wo(i),!1)),M=C.next();!M.done;M=C.next()){var J=M.value;J(W)}}catch(q){X={error:q}}finally{try{M&&!M.done&&(Y=C.return)&&Y.call(C)}finally{if(X)throw X.error}}}},L=function(){var D;s&&!_()&&((D=n.onResize)===null||D===void 0||D.call(n))};function E(){var D,X,Y;if(!_()){if(a=window.dapi,!a){x=setTimeout(E,(Y=n.pollMs)!==null&&Y!==void 0?Y:25);return}try{try{for(var W=bo([["ready",S],["viewableChange",N],["audioVolumeChange",p],["adResized",L]]),C=W.next();!C.done;C=W.next()){var M=wo(C.value,2),J=M[0],q=M[1];r.push([J,q]),a.addEventListener(J,q)}}catch(ce){D={error:ce}}finally{try{C&&!C.done&&(X=W.return)&&X.call(W)}finally{if(D)throw D.error}}S()}catch(ce){v(ce)}}}return{init:function(){var D;return d||(d=new Promise(function(X,Y){f=X,h=Y}),_()?(h?.(Error("DAPI bridge closed")),d):(m=setTimeout(function(){return v(Error("DAPI readiness timed out"))},(D=n.timeoutMs)!==null&&D!==void 0?D:5e3),E(),d))},isReady:function(){return s&&!_()},isVisible:function(){return s&&o&&!_()},isClosed:_,onVisibilityChanged:function(D){return _()||e.add(D),function(){return e.delete(D)}},onClosed:function(D){return _()||t.add(D),function(){return t.delete(D)}},onVolumeChanged:function(D){return _()||i.add(D),function(){return i.delete(D)}},openStore:function(){if(!s||!o||_()||typeof a?.openStoreUrl!="function")throw Error("DAPI store host unavailable");a.openStoreUrl()},destroy:function(){l||(l=!0,s=!1,o=!1,g(),h?.(Error("DAPI bridge destroyed")),e.clear(),t.clear(),i.clear())}}}var s1=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},o1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},l1=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},c1=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},u1=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Bg(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=u1(c1([],l1(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return s1(this,void 0,void 0,function(){return o1(this,function(a){switch(a.label){case 0:if(i)throw Error("Meta bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("Meta bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a=window.FbPlayableAd;if(!e||!t||i||typeof a?.onCTAClick!="function")throw Error("Meta CTA host unavailable");a.onCTAClick()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var d1=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},f1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},h1=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},p1=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},m1=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function kg(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=m1(p1([],h1(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return d1(this,void 0,void 0,function(){return f1(this,function(a){switch(a.label){case 0:if(i)throw Error("Google Ads bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("Google Ads bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a=window.ExitApi;if(!e||!t||i||typeof a?.exit!="function")throw Error("Google ExitApi unavailable");a.exit()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var v1=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},g1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},nm=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},im=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},rm=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function zg(){var n=window,e=new Set,t=new Set,i=n.gameStart,r=n.gameClose,a=!1,s=!1,o=!1,u=!1,l=function(){var f,h;if(!(o||u)){var m=!s||!a;if(a=!0,s=!0,m)try{for(var x=rm(im([],nm(e),!1)),_=x.next();!_.done;_=x.next()){var g=_.value;g(!0)}}catch(v){f={error:v}}finally{try{_&&!_.done&&(h=x.return)&&h.call(x)}finally{if(f)throw f.error}}}},d=function(){var f,h,m,x;if(!(o||u)){a=!1,s=!1,o=!0;try{for(var _=rm(im([],nm(e),!1)),g=_.next();!g.done;g=_.next()){var v=g.value;v(!1)}}catch(S){f={error:S}}finally{try{g&&!g.done&&(h=_.return)&&h.call(_)}finally{if(f)throw f.error}}try{for(var F=rm(im([],nm(t),!1)),P=F.next();!P.done;P=F.next()){var v=P.value;v()}}catch(S){m={error:S}}finally{try{P&&!P.done&&(x=F.return)&&x.call(F)}finally{if(m)throw m.error}}}};return n.gameStart=l,n.gameClose=d,{init:function(){return v1(this,void 0,void 0,function(){return g1(this,function(f){if(o||u)throw Error("Mintegral bridge closed");if(typeof n.gameReady!="function")throw Error("Mintegral gameReady host unavailable");return n.gameReady(),[2]})})},isReady:function(){return a&&!o&&!u},isVisible:function(){return a&&s&&!o&&!u},isClosed:function(){return o||u},onVisibilityChanged:function(f){return!o&&!u&&e.add(f),function(){return e.delete(f)}},onClosed:function(f){return!o&&!u&&t.add(f),function(){return t.delete(f)}},notifyGameEnd:function(){var f;!o&&!u&&((f=n.gameEnd)===null||f===void 0||f.call(n))},notifyGameRetry:function(){var f;!o&&!u&&((f=n.gameRetry)===null||f===void 0||f.call(n))},openStore:function(){if(!a||!s||o||u||typeof n.install!="function")throw Error("Mintegral install host unavailable");n.install()},destroy:function(){u||(u=!0,a=!1,s=!1,n.gameStart===l&&(i?n.gameStart=i:delete n.gameStart),n.gameClose===d&&(r?n.gameClose=r:delete n.gameClose),e.clear(),t.clear())}}}var y1=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},x1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},_1=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},M1=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},S1=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Vg(){var n=new Set,e=!1,t=!1,i=!1,r=function(){var a,s;if(!i){t=document.visibilityState!=="hidden";try{for(var o=S1(M1([],_1(n),!1)),u=o.next();!u.done;u=o.next()){var l=u.value;l(t)}}catch(d){a={error:d}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(a)throw a.error}}}};return{init:function(){return y1(this,void 0,void 0,function(){return x1(this,function(a){switch(a.label){case 0:if(i)throw Error("TikTok bridge destroyed");return document.readyState!=="loading"?[3,2]:[4,new Promise(function(s){return document.addEventListener("DOMContentLoaded",function(){return s()},{once:!0})})];case 1:a.sent(),a.label=2;case 2:if(i)throw Error("TikTok bridge destroyed");return document.addEventListener("visibilitychange",r),t=document.visibilityState!=="hidden",e=!0,r(),[2]}})})},isReady:function(){return e&&!i},isVisible:function(){return e&&t&&!i},isClosed:function(){return i},onVisibilityChanged:function(a){return i||n.add(a),function(){return n.delete(a)}},onClosed:function(){return function(){}},openStore:function(){var a,s,o=window,u=typeof o.openAppStore=="function"?o.openAppStore.bind(o):(s=(a=o.playableSDK)===null||a===void 0?void 0:a.openAppStore)===null||s===void 0?void 0:s.bind(o.playableSDK);if(!e||!t||i||!u)throw Error("TikTok store host unavailable");u()},destroy:function(){i=!0,e=!1,t=!1,document.removeEventListener("visibilitychange",r),n.clear()}}}var ht=function(){return ht=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},ht.apply(this,arguments)},b1=function(n,e,t,i){function r(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(d){try{l(i.next(d))}catch(f){s(f)}}function u(d){try{l(i.throw(d))}catch(f){s(f)}}function l(d){d.done?a(d.value):r(d.value).then(o,u)}l((i=i.apply(n,e||[])).next())})},w1=function(n,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,r,a,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=o(0),s.throw=o(1),s.return=o(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function o(l){return function(d){return u([l,d])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(t=0)),t;)try{if(i=1,r&&(a=l[0]&2?r.return:l[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,l[1])).done)return a;switch(r=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,r=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(n,t)}catch(d){l=[6,d],r=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Ue=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,a=[],s;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(o){s={error:o}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(s)throw s.error}}return a},$e=function(n,e,t){if(t||arguments.length===2)for(var i=0,r=e.length,a;i<r;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return n.concat(a||Array.prototype.slice.call(e))},ze=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Hg(n){if(n!=="standalone"){if(n==="unity-ads-ua-playable")return Ug();if(n==="applovin-growth-playable")return Fg();if(n==="ironsource-levelplay-playable")return Og();if(n==="meta-audience-playable")return Bg();if(n==="google-ads-app-playable")return kg();if(n==="mintegral-appgrowth-zip")return zg();if(n==="tiktok-ads-playable")return Vg();throw Error("E_NATIVE_TARGET")}}function am(n){var e,t,i,r,a=(e=n.left)!==null&&e!==void 0?e:0,s=(t=n.top)!==null&&t!==void 0?t:0,o=(i=n.right)!==null&&i!==void 0?i:a+n.width,u=(r=n.bottom)!==null&&r!==void 0?r:s+n.height,l=[{id:"sdk-top-left",left:a,top:s,right:Math.min(a+48,o),bottom:Math.min(s+48,u)},{id:"sdk-top-right",left:Math.max(a,o-56),top:s,right:o,bottom:Math.min(s+56,u)},{id:"sdk-bottom-left",left:a,top:Math.max(s,u-28),right:Math.min(a+48,o),bottom:u}];return{left:Math.min(a+48,o),top:Math.min(s+56,u),right:Math.max(a,o-56),bottom:Math.max(s,u-28),zones:l}}function Lf(n,e){var t,i,r=(i=(t=n.measureText)===null||t===void 0?void 0:t.call(n,e))===null||i===void 0?void 0:i.width,a=/(\d+(?:\.\d+)?)px/.exec(n.font||"");return Number.isFinite(r)?r:$e([],Ue(e),!1).length*(a?Number(a[1]):16)*.6}function Gg(n,e,t,i){var r,a,s,o,u,l,d;n.font=t.fontWeight+" "+i+"px "+t.fontFamily;var f=Math.max(0,t.width-2*((d=t.padding)!==null&&d!==void 0?d:4)),h=[];try{for(var m=ze(String(e).split(`
4224
+ `)),x=m.next();!x.done;x=m.next()){var _=x.value;if(t.wrap===!1){h.push(_);continue}var g=_.trim()?_.trim().split(/\s+/):[""],v=void 0;try{for(var F=(s=void 0,ze(g)),P=F.next();!P.done;P=F.next()){var S=P.value,N=v?v+" "+S:S;if(Lf(n,N)<=f){v=N;continue}if(v&&h.push(v),Lf(n,S)<=f){v=S;continue}var p="";try{for(var L=(u=void 0,ze(S)),E=L.next();!E.done;E=L.next()){var D=E.value;p&&Lf(n,p+D)>f?(h.push(p),p=D):p+=D}}catch(X){u={error:X}}finally{try{E&&!E.done&&(l=L.return)&&l.call(L)}finally{if(u)throw u.error}}v=p}}catch(X){s={error:X}}finally{try{P&&!P.done&&(o=F.return)&&o.call(F)}finally{if(s)throw s.error}}h.push(v)}}catch(X){r={error:X}}finally{try{x&&!x.done&&(a=m.return)&&a.call(m)}finally{if(r)throw r.error}}return h}function Wg(n,e,t){var i,r,a=(i=t.padding)!==null&&i!==void 0?i:4,s=Math.max(0,t.width-2*a),o=Math.max(0,t.height-2*a),u=Math.min(t.fontSize,(r=t.minFontSize)!==null&&r!==void 0?r:12),l=t.fontSize,d=Gg(n,e,t,l),f,h=function(){var m;n.font=t.fontWeight+" "+l+"px "+t.fontFamily;var x=Math.max.apply(Math,$e([0],Ue(d.map(function(F){return Lf(n,F)})),!1)),_=l*((m=t.lineHeight)!==null&&m!==void 0?m:1.2),g=d.length>16;g&&(d=d.slice(0,16));var v=d.length*_;return{lines:d,fontSize:l,scale:l/t.fontSize,renderedWidth:x,renderedHeight:v,availableWidth:s,availableHeight:o,padding:a,lineHeight:_,overflowsWidth:x>s+.01,overflowsHeight:g||v>o+.01,unsupportedChars:[]}};if(f=h(),t.autoFit!==!1)for(;(f.overflowsWidth||f.overflowsHeight)&&l>u;)l=Math.max(u,l-1),d=Gg(n,e,t,l),f=h();return f}function T1(n,e,t,i){i===void 0&&(i="en");var r=Wg(n,e,t),a=r.padding,s=t.direction==="rtl"||t.direction!=="ltr"&&/^(ar|fa|he|iw|ps|sd|ug|ur|yi)(?:-|$)/.test(i),o=s&&t.direction!=="rtl"?t.align==="left"?"right":t.align==="right"?"left":t.align:t.align;n.fillStyle=t.color,n.font=t.fontWeight+" "+r.fontSize+"px "+t.fontFamily,n.direction=s?"rtl":"ltr",n.textAlign=o,n.textBaseline="middle";var u=o==="left"?a:o==="right"?t.width-a:t.width/2,l=(t.height-r.renderedHeight)/2;return r.lines.forEach(function(d,f){return n.fillText(d,u,l+(f+.5)*r.lineHeight)}),ht(ht({},r),{direction:s?"rtl":"ltr",resolvedAlign:o,clipped:r.overflowsHeight})}function E1(n,e,t){var i,r,a,s,o,u,l=t===void 0?{}:t,d=l.edit,f=d===void 0?!1:d,h=l.sceneId,m=h===void 0?n.base.startScene:h,x=l.onSelect,_=x===void 0?function(){}:x,g=l.network,v=g===void 0?"standalone":g,F=l.review,P=F===void 0?!1:F,S=l.sharedImageCache,N=Hg(v),p=e.getContext("2d"),L=new Map(n.components.map(function(c){return[c.id,c]})),E=new Map(n.assets.map(function(c){return[c.id,c]})),D=S??new Map,X=new Map(n.events.map(function(c){return[c.id,c]})),Y=new Map(n.gameplay.filter(function(c){return c.kind==="responsive-layout"}).map(function(c){return[c.componentId,c.parameters]})),W=(a=globalThis.matchMedia)===null||a===void 0?void 0:a.call(globalThis,"(prefers-reduced-motion: reduce)"),C,M=new Map,J=M;function q(){var c=Y.size>0&&e.clientWidth>e.clientHeight;return{width:c?Math.max(n.base.width,n.base.height):n.base.width,height:c?Math.min(n.base.width,n.base.height):n.base.height,landscape:c}}function ce(){C!==q().landscape&&(jn(),Ri())}var k=function(c){var y,w=E.get(c);return((y=w?.hash)!==null&&y!==void 0?y:c)+":"+c};try{for(var G=ze(n.assets),te=G.next();!te.done;te=G.next()){var le=te.value;if(le.mime.startsWith("image/")&&!D.has(k(le.id))){var ge=new Image;ge.src="data:"+le.mime+";base64,"+le.data,D.set(k(le.id),ge)}}}catch(c){i={error:c}}finally{try{te&&!te.done&&(r=G.return)&&r.call(G)}finally{if(i)throw i.error}}var oe=m,$={},Te=[],Le=[],se=[],re=[],Ie=new Set,ke=new Map,xe=0,Ye=0,mt=0,He=0,qe=0,pt=!1,at=0,ot=0,Vt=!1,cn=[],Ze,pn,ne,Tn,gn,Q,I,ie,be,De,Je=[],je,Ne=[],Pe=[],it,Rt=0,Mt=!1,ct=0,Gt=v==="standalone",Kt=v==="standalone",nn=v==="standalone",he=!1,dt=!1,Ee=new Map,gt=new Map,Ke=new Map,We=new Map,Wt=new Set,Lt=new Map,yt=new Map,Et=new Set,rt=new Map,Ut=new Map,an=new Map,hn=new Map,en=new Map,Ht=new Map,yn=0,bn=0,Yt,Ot,$n=1,Xn,Nn=new Map,ni=new Map,wn=new Map,Pn=new Map,Bn=new Map,fn=new Map,En=new Map,dn=km(),di=Gm(),ii=new Map,si=new Map,A=Ym(_u(n.projectId)),ae=new Map,we=new Map,me=new Map,Me=new Set,et=new Map,Ge,ut=1,Nt=1,lt,It,Ft={x:0,y:0},Ce,qt=[],Qt=[],sn=new Map,Mn=new Map,In=new Map,wt=new Map,ri=new Map,xn=new Map,Kn=new Set,Dt,Ln,Zt,zn=new Map(n.gameplay.filter(function(c){return c.kind==="ui-anchor-3d"}).map(function(c){return[c.componentId,c.parameters]}));n.components.some(function(c){return c.contract==="native.stage3d.v1"})&&(Zt=wg(n,E,function(){dt||Promise.resolve().then(function(){dt||Ri()})},Ee));var nt=function(c){var y;return(y=Ke.get(c))!==null&&y!==void 0?y:L.get(c)},Vn=function(c,y){return n.gameplay.find(function(w){return w.kind===c&&w.componentId===y})},Cn=function(){var c,y;yn++,Et.clear(),rt.clear(),an.clear(),hn.clear();try{for(var w=ze(Wt),T=w.next();!T.done;T=w.next()){var b=T.value;try{b.stop()}catch{}}}catch(U){c={error:U}}finally{try{T&&!T.done&&(y=w.return)&&y.call(w)}finally{if(c)throw c.error}}Wt.clear(),Ut.clear()},wi=function(c){var y,w;if(!Ge||c!==void 0&&Ge.pointerId!==c)return!1;var T=Ge.pointerId;Ge.behavior.parameters.powerVariableId&&($[Ge.behavior.parameters.powerVariableId]=0),Ge=void 0;try{!((y=e.hasPointerCapture)===null||y===void 0)&&y.call(e,T)&&((w=e.releasePointerCapture)===null||w===void 0||w.call(e,T))}catch{}return!0},fi=function(c){var y,w,T;if(!Dt||c!==void 0&&Dt.pointerId!==c)return!1;var b=Dt.pointerId;Dt.behavior.parameters.powerVariableId&&($[Dt.behavior.parameters.powerVariableId]=0),(y=Zt?.getStage(L.get(Dt.stageId)))===null||y===void 0||y.setGuide([]),Dt=void 0;try{!((w=e.hasPointerCapture)===null||w===void 0)&&w.call(e,b)&&((T=e.releasePointerCapture)===null||T===void 0||T.call(e,b))}catch{}return!0},xr=function(c){var y,w;if(!Ln||c!==void 0&&Ln.pointerId!==c)return!1;var T=Ln.pointerId;Ln=void 0;try{!((y=e.hasPointerCapture)===null||y===void 0)&&y.call(e,T)&&((w=e.releasePointerCapture)===null||w===void 0||w.call(e,T))}catch{}return!0},ss=function(c){var y=c.behavior.parameters;y.axisXVariableId&&($[y.axisXVariableId]=c.nx),y.axisYVariableId&&($[y.axisYVariableId]=c.ny),y.magnitudeVariableId&&($[y.magnitudeVariableId]=c.magnitude),y.angleVariableId&&c.magnitude>0&&($[y.angleVariableId]=c.angle)},ya=function(c,y){var w,T,b,U;y===void 0&&(y=!1);try{for(var R=ze(et.values()),H=R.next();!H.done;H=R.next()){var O=H.value;if(!(O.pointerId===null||c!==void 0&&O.pointerId!==c)){var Z=O.pointerId;O.pointerId=null,O.nx=0,O.ny=0,O.magnitude=0,O.knobX=O.origin.x,O.knobY=O.origin.y,ss(O);try{!((b=e.hasPointerCapture)===null||b===void 0)&&b.call(e,Z)&&((U=e.releasePointerCapture)===null||U===void 0||U.call(e,Z))}catch{}y&&Un(or("joystickEnd",O.c))}}}catch(B){w={error:B}}finally{try{H&&!H.done&&(T=R.return)&&T.call(R)}finally{if(w)throw w.error}}},na=function(c,y){var w,T;if(y===void 0&&(y=!0),!ne||c!==void 0&&ne.pointerId!==c)return!1;var b=ne,U=b.pointerId;if(ne=void 0,It=void 0,y){var R=nt(b.targetId);R&&b.b.parameters.snapBack&&(Xr(R,b.origin.x,b.origin.y),b.originZone&&dn.place(R.id,b.originZone))}try{!((w=e.hasPointerCapture)===null||w===void 0)&&w.call(e,U)&&((T=e.releasePointerCapture)===null||T===void 0||T.call(e,U))}catch{}return!0},xa=function(c){var y,w;je?.pointerId===c.pointerId&&(je=void 0);try{for(var T=ze(en.values()),b=T.next();!b.done;b=T.next()){var U=b.value;U.pointerId===c.pointerId&&U.held&&(U.held=!1,U.releasedAt=xe)}}catch(H){y={error:H}}finally{try{b&&!b.done&&(w=T.return)&&w.call(T)}finally{if(y)throw y.error}}var R=na(c.pointerId);return Q===c.pointerId?(gn=void 0,Q=void 0,!0):R},ws=function(c){var y,w,T,b,U,R,H,O;if(c){ne&&((H=Ke.get(ne.targetId))===null||H===void 0?void 0:H.instanceId)===c&&na(void 0,!1),Ge&&((O=Ke.get(Ge.targetId))===null||O===void 0?void 0:O.instanceId)===c&&wi();var Z=[];dn.release(c),di.cancel(c),ae.delete(c),me.delete(c),A.remove(c),Te=Te.filter(function(pe){return pe.id!==c});try{for(var B=ze(Ke),V=B.next();!V.done;V=B.next()){var z=Ue(V.value,2),j=z[0],K=z[1];if(K.instanceId===c){Z.push(j),dn.release(j),di.cancel(j),Ke.delete(j),Ee.delete(j),We.delete(j),wn.delete(j),Bn.delete(j),fn.delete(j);try{for(var ee=(T=void 0,ze(Pn.values())),ue=ee.next();!ue.done;ue=ee.next()){var _e=ue.value;_e.removeAgent(j)}}catch(pe){T={error:pe}}finally{try{ue&&!ue.done&&(b=ee.return)&&b.call(ee)}finally{if(T)throw T.error}}try{for(var ve=(U=void 0,ze(gt.keys())),Ae=ve.next();!Ae.done;Ae=ve.next()){var fe=Ae.value;fe.endsWith(":"+j)&&gt.delete(fe)}}catch(pe){U={error:pe}}finally{try{Ae&&!Ae.done&&(R=ve.return)&&R.call(ve)}finally{if(U)throw U.error}}}}}catch(pe){y={error:pe}}finally{try{V&&!V.done&&(w=B.return)&&w.call(B)}finally{if(y)throw y.error}}se=se.filter(function(pe){return!Z.includes(pe.targetId)})}},Ha=function(c){for(;c;){if(c.prototype)return c.id;c=nt(c.parentId)}},Oi=function(){var c,y,w;return{viewport:q(),components:Object.fromEntries($e([],Ue(Ee),!1).map(function(T){var b=Ue(T,2),U=b[0],R=b[1];return[U,ht(ht({},R),{parameters:ht({},R.parameters)})]})),mode:f?"edit":"play",scene:oe,variables:ht({},$),time:xe,instances:Te.map(function(T){return ht({id:T.id,prototypeId:T.prototypeId,x:T.transform[4],y:T.transform[5]},A.snapshot(T.id))}),particles:Le.length,animations:se.length,contacts:Ie.size,spriteFrames:Object.fromEntries($e([],Ue(We),!1).map(function(T){var b,U=Ue(T,2),R=U[0],H=U[1];return[R,(b=H.frame)!==null&&b!==void 0?b:0]})),input:{dragging:!!ne,pointerId:(y=(c=ne?.pointerId)!==null&&c!==void 0?c:lt?.pointerId)!==null&&y!==void 0?y:null,pressed:gn??null,holding:!!lt?.holds.length,occupancy:dn.snapshot(),joysticks:Object.fromEntries($e([],Ue(et),!1).map(function(T){var b=Ue(T,2),U=b[0],R=b[1];return[U,{active:R.pointerId!==null,x:R.nx,y:R.ny,magnitude:R.magnitude,angle:R.angle}]}))},feedback:{presses:en.size,floatingTexts:Ne.length,flashes:Pe.length,shaking:!!it,tutorialHands:ct},match:{boards:Object.fromEntries($e([],Ue(Nn),!1).map(function(T){var b=Ue(T,2),U=b[0],R=b[1];return[U,R.snapshot()]})),selected:Yt??null,cells:$e([],Ue(Ht),!1).map(function(T){var b=Ue(T,2),U=b[0],R=b[1];return ht({id:U},R)})},physics:li(),physics3d:Zg(),model3d:Zt?.modelStatus(),paths:Object.fromEntries($e([],Ue(Pn),!1).map(function(T){var b=Ue(T,2),U=b[0],R=b[1];return[U,R.snapshot()]})),canvas:{masks:Object.fromEntries($e([],Ue(ae),!1).map(function(T){var b=Ue(T,2),U=b[0],R=b[1];return[U,{progress:R.progress}]})),strokes:Object.fromEntries($e([],Ue(we),!1).map(function(T){var b=Ue(T,2),U=b[0],R=b[1];return[U,R.strokes.length]})),walls:qt.length,joints:Qt.filter(function(T){return!T.broken}).length},audio:{state:(w=Ze?.state)!==null&&w!==void 0?w:"locked",voices:Wt.size,blocked:bn},network:{target:v,ready:Kt,visible:nn,started:Gt,closed:he,hostVolume:$n},diagnostics:$e([],Ue(cn),!1)}},Gn=function(){return!f&&!pt&&!document.hidden&&Kt&&nn&&Gt&&!he},jn=function(){var c,y,w,T;je=void 0,wi(),fi(),xr(),ya(),na(),lt=void 0,It=void 0,Ce=void 0;try{for(var b=ze(we.values()),U=b.next();!U.done;U=b.next()){var R=U.value;R.cancel()}}catch(B){c={error:B}}finally{try{U&&!U.done&&(y=b.return)&&y.call(b)}finally{if(c)throw c.error}}di.clear(),Ot=void 0;try{for(var H=ze(Nn.values()),O=H.next();!O.done;O=H.next()){var Z=O.value;Z.cancelSelection()}}catch(B){w={error:B}}finally{try{O&&!O.done&&(T=H.return)&&T.call(H)}finally{if(w)throw w.error}}Nn.size&&(Yt=void 0),gn=void 0,Q=void 0,en.clear()},Zi=function(c){Vt=!0,cn.push(c),cn=cn.slice(-16),re=[]},Ks=function(c){var y,w,T;return ht(ht(ht({},c.parameters),c.prototypeId?(y=Ee.get(c.prototypeId))===null||y===void 0?void 0:y.parameters:{}),(T=Ee.get((w=c.runtimeId)!==null&&w!==void 0?w:c.id))===null||T===void 0?void 0:T.parameters)};function tn(c){var y,w=Ks(c),T=(y=c.runtimeId)!==null&&y!==void 0?y:c.id,b=ri.get(T);if(b)b.fittedWidth!==void 0&&c.contract!=="native.group.v1"&&(w.width=b.fittedWidth,w.height=b.fittedHeight),b.visible||(w.visible=!1);else if(c.contract==="native.text.v1"&&c.parentId){var U=ri.get(c.parentId),R=U&&nt(c.parentId);R?.contract==="native.button.v1"&&U.fittedWidth!==void 0&&c.transform[0]===1&&c.transform[1]===0&&c.transform[2]===0&&c.transform[3]===1&&c.transform[4]===0&&c.transform[5]===0&&c.parameters.width===R.parameters.width&&c.parameters.height===R.parameters.height&&(w.width=U.fittedWidth,w.height=U.fittedHeight)}return w}function To(c,y){var w,T=en.get(c.id);if(!T||W?.matches)return y;var b=$e([],Ue(y),!1),U=T.held?0:xe-((w=T.releasedAt)!==null&&w!==void 0?w:xe),R=T.held?0:Math.min(1,U/T.behavior.springBackSeconds),H=T.held?T.behavior.scaleDown:T.behavior.scaleDown+(1-T.behavior.scaleDown)*(1-Math.pow(1-R,3)),O=tn(c);b[4]+=(1-H)*(b[0]*O.width+b[2]*O.height)/2,b[5]+=(1-H)*(b[1]*O.width+b[3]*O.height)/2;for(var Z=0;Z<4;Z++)b[Z]*=H;return b}function sr(c){return Zt&&Kn.size>0&&mi?{left:mi.x,top:mi.y,right:mi.x+mi.w,bottom:mi.y+mi.h,width:mi.w,height:mi.h}:{left:0,top:0,right:c.width,bottom:c.height,width:c.width,height:c.height}}function Qi(c){var y,w,T,b,U,R,H,O,Z=c.transform,B=(T=(w=Ee.get((y=c.runtimeId)!==null&&y!==void 0?y:c.id))===null||w===void 0?void 0:w.transform)!==null&&T!==void 0?T:Z,V=ri.get((b=c.runtimeId)!==null&&b!==void 0?b:c.id);if(V&&V.anchorPoint){var z=$e([],Ue(B),!1),j=tn(c);c.contract==="native.group.v1"&&V.groupScaleX!==void 0&&(z[0]*=V.groupScaleX,z[1]*=V.groupScaleX,z[2]*=V.groupScaleY,z[3]*=V.groupScaleY);var K=c.parentId?ci(nt(c.parentId)):Na(),ee=oi(Or(K),V.cx,V.cy);return z[4]=ee.x-(z[0]*j.width+z[2]*j.height)/2,z[5]=ee.y-(z[1]*j.width+z[3]*j.height)/2,To(c,z)}var ue=Y.get((U=c.prototypeId)!==null&&U!==void 0?U:c.id);if(!ue)return To(c,B);var _e=q(),ve=$e([],Ue(B),!1);_e.landscape&&(ve[4]+=ue.x-Z[4],ve[5]+=ue.y-Z[5],ve[0]*=ue.scaleX,ve[1]*=ue.scaleX,ve[2]*=ue.scaleY,ve[3]*=ue.scaleY);var Ae=(R=ue.anchor)!==null&&R!==void 0?R:"none";if(Ae==="none"&&!ue.respectSafeArea)return To(c,ve);var fe=sr(_e),pe=ue.respectSafeArea?am(fe):fe,Re=tn(c),de=(H=ue.marginX)!==null&&H!==void 0?H:0,Fe=(O=ue.marginY)!==null&&O!==void 0?O:0,Be=Math.abs(ve[0])*Re.width+Math.abs(ve[2])*Re.height,Oe=Math.abs(ve[1])*Re.width+Math.abs(ve[3])*Re.height;return Ae!=="none"?(ve[4]=Ae.endsWith("left")?pe.left+de:Ae.endsWith("right")?pe.right-Be-de:(pe.left+pe.right-Be)/2,ve[5]=Ae.startsWith("top")?pe.top+Fe:Ae.startsWith("bottom")?pe.bottom-Oe-Fe:(pe.top+pe.bottom-Oe)/2):(ve[4]=Math.max(pe.left+de,Math.min(pe.right-Be-de,ve[4])),ve[5]=Math.max(pe.top+Fe,Math.min(pe.bottom-Oe-Fe,ve[5]))),To(c,ve)}var os=function(c){return(Ke.has(c)?$e([],Ue(Ke.values()),!1):$e($e([],Ue(n.components),!1),Ue(Te),!1)).filter(function(y){return y.parentId===c&&!y.prototype}).sort(function(y,w){return y.order-w.order||(y.id<w.id?-1:y.id>w.id?1:0)})},Rl=function(){return n.components.filter(function(c){return c.sceneId===oe&&!c.parentId&&!c.prototype}).sort(function(c,y){return c.order-y.order||(c.id<y.id?-1:c.id>y.id?1:0)})},Un=function(c){var y,w;if(c.kind==="sceneEnter"&&((y=n.scenes.find(function(T){return T.id===c.sceneId}))===null||y===void 0?void 0:y.role)==="end-card"&&Xn!==c.sceneId&&(Xn=c.sceneId,(w=N?.notifyGameEnd)===null||w===void 0||w.call(N)),re.length>=256){Zi("Event queue budget exhausted");return}re.push(c)},or=function(c,y,w,T){var b,U,R,H;return T===void 0&&(T={}),ht(ht({kind:c,componentId:(b=y.prototypeId)!==null&&b!==void 0?b:y.id,selfInstanceId:(U=y.instanceId)!==null&&U!==void 0?U:y.id,instanceId:y.instanceId},w?{otherId:(R=w.prototypeId)!==null&&R!==void 0?R:w.id,otherInstanceId:(H=w.instanceId)!==null&&H!==void 0?H:w.id}:{}),T)};function Wa(c){for(var y,w=c;w;w=nt(w.parentId)){var T=A.states.get((y=w.instanceId)!==null&&y!==void 0?y:w.id);if(T)return T}}function Eo(c){var y,w,T=Vn("instance-state",(y=c.prototypeId)!==null&&y!==void 0?y:c.id);return T?A.initialize((w=c.instanceId)!==null&&w!==void 0?w:c.id,T.parameters):void 0}function Df(){var c,y,w,T;try{for(var b=ze(n.gameplay.filter(function(B){return B.kind==="instance-state"})),U=b.next();!U.done;U=b.next()){var R=U.value;try{for(var H=(w=void 0,ze(Bi(L.get(R.componentId)))),O=H.next();!O.done;O=H.next()){var Z=O.value;Eo(Z)}}catch(B){w={error:B}}finally{try{O&&!O.done&&(T=H.return)&&T.call(H)}finally{if(w)throw w.error}}}}catch(B){c={error:B}}finally{try{U&&!U.done&&(y=b.return)&&y.call(b)}finally{if(c)throw c.error}}}function Ao(c,y,w,T){var b=Wa(c);if(b){var U=b.hp;if(y==="tag")b.tag=w==="set"?String(T):b.tag;else{var R=Number(T);if(b[y]=w==="add"?b[y]+R:w==="sub"?b[y]-R:R,!Number.isFinite(b[y])){Zi("Instance state range exceeded");return}y==="hp"&&(b.hp=Math.max(0,Math.min(b.maxHp,b.hp)))}U>0&&b.hp<=0&&Un(or("instanceDepleted",c))}}function _a(c,y){var w,T,b;if(!c)return!0;if(c.all)return c.all.every(function(Z){return _a(Z,y)});if(c.any)return c.any.some(function(Z){return _a(Z,y)});var U=c.instanceTarget==="other"?y?.otherInstanceId:(w=y?.selfInstanceId)!==null&&w!==void 0?w:y?.instanceId,R=c.instanceField?(T=nt(U))!==null&&T!==void 0?T:$e([],Ue(Ke.values()),!1).find(function(Z){return Z.instanceId===U}):void 0,H=c.instanceField?(b=Wa(R))===null||b===void 0?void 0:b[c.instanceField]:$[c.variableId],O=c.compareVariableId?$[c.compareVariableId]:c.value;return{eq:function(){return H===O},ne:function(){return H!==O},lt:function(){return H<O},lte:function(){return H<=O},gt:function(){return H>O},gte:function(){return H>=O}}[c.op]()}function Qs(c){var y,w,T;Yt=void 0,Ot=void 0,c||Ht.clear();try{for(var b=ze(n.gameplay),U=b.next();!U.done;U=b.next()){var R=U.value;if(R.kind==="match-tile"){var H=L.get(R.componentId);if(c&&H.id!==c&&!qr(H,c))continue;Ee.delete(H.id),Ht.set(H.id,{row:R.parameters.row,column:R.parameters.column,group:R.parameters.group,sceneId:H.sceneId,boardId:(T=H.parentId)!==null&&T!==void 0?T:H.sceneId})}}}catch(O){y={error:O}}finally{try{U&&!U.done&&(w=b.return)&&w.call(b)}finally{if(y)throw y.error}}}function js(){var c,y,w=function(R){var H,O;if(Nn.has(R.componentId))return"continue";var Z=R.componentId,B=R.parameters,V=n.gameplay.filter(function(fe){return fe.kind==="match-tile"&&L.get(fe.componentId).parentId===Z}).sort(function(fe,pe){return fe.parameters.row-pe.parameters.row||fe.parameters.column-pe.parameters.column}).map(function(fe){return ht({id:fe.componentId},fe.parameters)}),z=new Map;try{for(var j=(H=void 0,ze(V)),K=j.next();!K.done;K=j.next()){var ee=K.value;if(!z.has(ee.group)){var ue=L.get(ee.id);z.set(ee.group,{fill:ue.parameters.fill,children:os(ee.id).filter(function(fe){return["native.image.v1","native.text.v1"].includes(fe.contract)})})}}}catch(fe){H={error:fe}}finally{try{K&&!K.done&&(O=j.return)&&O.call(j)}finally{if(H)throw H.error}}ni.set(Z,z);var _e=L.get(V[B.columns].id).transform[5]-L.get(V[0].id).transform[5],ve=function(fe,pe,Re){var de,Fe=Re.from,Be=Fe===void 0?fe:Fe,Oe=Re.progress,Xe=Oe===void 0?0:Oe,vt=Re.offsetRows,Pt=vt===void 0?0:vt,Tt=Re.scale,Ct=Tt===void 0?1:Tt,kt=Re.opacity,At=kt===void 0?1:kt,_t=V[fe],St=L.get(_t.id),bt=L.get(V[Be].id),Ve=z.get(pe),tt=$e([],Ue(St.transform),!1);tt[4]+=(bt.transform[4]-St.transform[4])*Xe,tt[5]+=(bt.transform[5]-St.transform[5]+Pt*_e)*Xe,tt[4]+=(1-Ct)*(tt[0]*St.parameters.width+tt[2]*St.parameters.height)/2,tt[5]+=(1-Ct)*(tt[1]*St.parameters.width+tt[3]*St.parameters.height)/2;for(var xt=0;xt<4;xt++)tt[xt]*=Ct;Ee.set(_t.id,ht(ht({},Ee.get(_t.id)),{transform:tt,parameters:ht(ht({},(de=Ee.get(_t.id))===null||de===void 0?void 0:de.parameters),{fill:Ve.fill,opacity:At})})),Ht.get(_t.id).group=pe;var Qe=os(_t.id).filter(function(zt){return["native.image.v1","native.text.v1"].includes(zt.contract)});Qe.forEach(function(zt,jt){var Sn,Xt,Jt=Ve.children[jt];if(!(!Jt||Jt.contract!==zt.contract)){var ft=(Sn=Ee.get(zt.id))!==null&&Sn!==void 0?Sn:{transform:$e([],Ue(zt.transform),!1),parameters:{}};zt.contract==="native.image.v1"?ft.assetId=(Xt=Jt.assetSlots[0])===null||Xt===void 0?void 0:Xt.assetId:ft.parameters.text=Jt.parameters.text,Ee.set(zt.id,ft)}})},Ae=Fm(ht(ht({},B),{slots:V,paint:ve,onEvent:function(fe){Yt=void 0,Un({kind:fe,componentId:Z})}}));Nn.set(Z,Ae)};try{for(var T=ze(n.gameplay.filter(function(R){return R.kind==="match-board"})),b=T.next();!b.done;b=T.next()){var U=b.value;w(U)}}catch(R){c={error:R}}finally{try{b&&!b.done&&(y=T.return)&&y.call(T)}finally{if(c)throw c.error}}}function nu(c){var y,w;js();try{for(var T=ze(Nn),b=T.next();!b.done;b=T.next()){var U=Ue(b.value,2),R=U[0],H=U[1];(!c||c===R||qr(L.get(R),c))&&H.reset()}}catch(O){y={error:O}}finally{try{b&&!b.done&&(w=T.return)&&w.call(T)}finally{if(y)throw y.error}}}function Bi(c){return Ha(c)?$e([],Ue(Ke.values()),!1).filter(function(y){return y.prototypeId===c.id}):[c]}function ki(c){var y=tn(c);return oi(ci(c),y.width/2,y.height/2)}function ls(c,y,w){var T;w===void 0&&(w="self");var b=L.get(c),U=w==="other"?y.otherInstanceId:(T=y.selfInstanceId)!==null&&T!==void 0?T:y.instanceId,R=!!(b&&Ha(b));if(U!==void 0){if(c){var H=$e([],Ue(Ke.values()),!1).find(function(O){return O.prototypeId===c&&(O.instanceId===U||O.id===U)});if(H)return H}if(w==="other"||!c)return nt(U);if(R&&typeof U=="string"&&U.startsWith("instance."))return}return b?R?Bi(b)[0]:nt(c):void 0}function Xr(c,y,w){var T,b=tn(c),U=(T=Ee.get(c.id))!==null&&T!==void 0?T:{transform:$e([],Ue(c.transform),!1),parameters:{}},R=$e([],Ue(U.transform),!1),H=c.parentId?ci(nt(c.parentId)):Na(),O=oi(Or(H),y,w);R[4]=O.x-(R[0]*b.width+R[2]*b.height)/2,R[5]=O.y-(R[1]*b.width+R[3]*b.height)/2,Ee.set(c.id,ht(ht({},U),{transform:R})),c.prototypeId&&(c.transform=$e([],Ue(R),!1))}function cs(c,y,w){var T,b,U,R;w===void 0&&(w=!1);var H=(T=Ee.get(c.id))!==null&&T!==void 0?T:{transform:$e([],Ue(c.transform),!1),parameters:{}},O=(R=(U=L.get((b=c.prototypeId)!==null&&b!==void 0?b:c.id))===null||U===void 0?void 0:U.transform)!==null&&R!==void 0?R:c.transform,Z=Math.hypot(O[0],O[1])*(w?-1:1),B=Math.hypot(O[2],O[3]),V=y+(w?0:Math.atan2(O[1],O[0])),z=Math.cos(V),j=Math.sin(V),K=$e([],Ue(H.transform),!1);K[0]=z*Z,K[1]=j*Z,K[2]=-j*B,K[3]=z*B,Ee.set(c.id,ht(ht({},H),{transform:K}))}function Ca(c,y){var w=wn.get(c.id);if(w)return w;var T=ci(c),b=tn(c),U=oi(T,b.width/2,b.height/2);return w=ht({id:c.id,sourceId:y.componentId,instanceId:c.instanceId,x:U.x,y:U.y,vx:0,vy:0,width:Math.hypot(T[0],T[1])*b.width,height:Math.hypot(T[2],T[3])*b.height,angle:Math.atan2(T[1],T[0]),restElapsed:0,atRest:!0},y.parameters),wn.set(c.id,w),w}function Ts(c,y){var w,T=ae.get(c.id);if(T)return T;var b=tn(c),U=y.parameters;return T=qm(U,{width:b.width,height:b.height,source:c.contract==="native.image.v1"?D.get(k((w=c.assetSlots[0])===null||w===void 0?void 0:w.assetId)):void 0,onProgress:function(R){U.progressVariableId&&($[U.progressVariableId]=R),Un(or("maskProgress",c))},onComplete:function(){return Un(or("maskComplete",c))}}),ae.set(c.id,T),T}function Nf(c){var y=we.get(c.componentId);return y||(y=$m(c.parameters),we.set(c.componentId,y)),y}function iu(){var c,y,w,T,b,U,R,H,O,Z,B,V,z=new Set,j=[];try{for(var K=ze(n.gameplay.filter(function(tt){return tt.kind==="physics-body"})),ee=K.next();!ee.done;ee=K.next()){var ue=ee.value,_e=L.get(ue.componentId);if(_e.sceneId===oe)try{for(var ve=(w=void 0,ze(Bi(_e))),Ae=ve.next();!Ae.done;Ae=ve.next()){var fe=Ae.value;if(Ti(fe)){if(j.length>=64){Zi("Physics body budget exhausted");break}var pe=Ca(fe,ue),Re=ci(fe),de=tn(fe),Fe=oi(Re,de.width/2,de.height/2);if(z.add(fe.id),pe.width=Math.hypot(Re[0],Re[1])*de.width,pe.height=Math.hypot(Re[2],Re[3])*de.height,pe.mode!=="dynamic"){var Be=Bn.get(fe.id),Oe=fe.parentId?ci(nt(fe.parentId)):Na(),Xe=(B=Be?.vx)!==null&&B!==void 0?B:0,vt=(V=Be?.vy)!==null&&V!==void 0?V:0;pe.x=Fe.x,pe.y=Fe.y,pe.angle=Math.atan2(Re[1],Re[0]),pe.vx=Oe[0]*Xe+Oe[2]*vt,pe.vy=Oe[1]*Xe+Oe[3]*vt}else pe.atRest&&(pe.x=Fe.x,pe.y=Fe.y);j.push(pe)}}}catch(tt){w={error:tt}}finally{try{Ae&&!Ae.done&&(T=ve.return)&&T.call(ve)}finally{if(w)throw w.error}}}}catch(tt){c={error:tt}}finally{try{ee&&!ee.done&&(y=K.return)&&y.call(K)}finally{if(c)throw c.error}}try{for(var Pt=ze(wn.keys()),Tt=Pt.next();!Tt.done;Tt=Pt.next()){var Ct=Tt.value;!z.has(Ct)&&!Ke.has(Ct)&&wn.delete(Ct)}}catch(tt){b={error:tt}}finally{try{Tt&&!Tt.done&&(U=Pt.return)&&U.call(Pt)}finally{if(b)throw b.error}}var kt=[];try{for(var At=ze(n.gameplay.filter(function(tt){return tt.kind==="capture-zone"})),_t=At.next();!_t.done;_t=At.next()){var ue=_t.value,_e=L.get(ue.componentId);if(_e.sceneId===oe)try{for(var St=(O=void 0,ze(Bi(_e))),bt=St.next();!bt.done;bt=St.next()){var fe=bt.value;if(Ti(fe)){var Re=ci(fe),de=tn(fe),Fe=oi(Re,de.width/2,de.height/2),Ve=Math.max(.1,Math.min(Math.hypot(Re[0],Re[1]),Math.hypot(Re[2],Re[3])));kt.push(ht(ht({id:fe.id,sourceId:_e.id,instanceId:fe.instanceId,x:Fe.x,y:Fe.y},ue.parameters),{radius:ue.parameters.radius*Ve}))}}}catch(Qe){O={error:Qe}}finally{try{bt&&!bt.done&&(Z=St.return)&&Z.call(St)}finally{if(O)throw O.error}}}}catch(tt){R={error:tt}}finally{try{_t&&!_t.done&&(H=At.return)&&H.call(At)}finally{if(R)throw R.error}}return{bodies:$e($e([],Ue(j),!1),Ue(qt),!1),zones:kt}}function Uf(c){var y,w,T,b,U,R,H,O=iu(),Z=O.bodies,B=O.zones,V=q();Qt=[];try{for(var z=ze(n.gameplay.filter(function(Oe){return Oe.kind==="physics-joint"})),j=z.next();!j.done;j=z.next()){var K=j.value,ee=L.get(K.componentId);if(ee.sceneId===oe){var ue=nt(K.parameters.anchorComponentId),_e=Vn("physics-body",ee.id);if(!(!ue||!_e))try{for(var ve=(T=void 0,ze(Bi(ee))),Ae=ve.next();!Ae.done;Ae=ve.next()){var fe=Ae.value;Ca(fe,_e);var pe=ki(ue),Re=K.id+":"+fe.id;Qt.push(ht(ht({},K.parameters),{id:K.id,key:Re,componentId:ee.id,bodyId:fe.id,anchorId:ue.id,x:pe.x,y:pe.y,broken:Me.has(Re)}))}}catch(Oe){T={error:Oe}}finally{try{Ae&&!Ae.done&&(b=ve.return)&&b.call(ve)}finally{if(T)throw T.error}}}}}catch(Oe){y={error:Oe}}finally{try{j&&!j.done&&(w=z.return)&&w.call(z)}finally{if(y)throw y.error}}fh({bodies:Z,zones:B,joints:Qt,bounds:{left:0,top:0,right:V.width,bottom:V.height},dt:c,onEvent:function(Oe,Xe,vt){var Pt,Tt,Ct,kt;if(!(Oe==="bodyBounce"&&vt&&Xe.sourceId===vt.sourceId&&Xe.id>vt.id)){var At=(Pt=Xe.instanceId)!==null&&Pt!==void 0?Pt:Xe.id,_t=vt?(Tt=vt.instanceId)!==null&&Tt!==void 0?Tt:vt.id:void 0,St=ht(ht({kind:Oe,componentId:Xe.sourceId,selfInstanceId:At},_t?{otherInstanceId:_t}:{}),{instanceId:(Ct=Xe.instanceId)!==null&&Ct!==void 0?Ct:vt?.instanceId});if(vt&&(St.otherId=vt.sourceId),Un(St),Oe==="zoneCapture"){var bt=nt(Xe.id),Ve=L.get(vt.sourceId);if(vt.hideCaptured&&bt){var tt=(kt=Ee.get(bt.id))!==null&&kt!==void 0?kt:{transform:$e([],Ue(bt.transform),!1),parameters:{}};tt.parameters.visible=!1,Ee.set(bt.id,tt)}vt.stopBody&&Ve&&bt&&Xr(bt,vt.x,vt.y)}}}});try{for(var de=ze(Z),Fe=de.next();!Fe.done;Fe=de.next()){var Be=Fe.value,fe=nt(Be.id);!fe||Be.mode!=="dynamic"||(Be.spinToRotation&&cs(fe,(H=Be.angle)!==null&&H!==void 0?H:0),Xr(fe,Be.x,Be.y))}}catch(Oe){U={error:Oe}}finally{try{Fe&&!Fe.done&&(R=de.return)&&R.call(de)}finally{if(U)throw U.error}}}function Ff(){var c,y,w,T,b;try{for(var U=ze(n.gameplay.filter(function(Ae){return Ae.kind==="oscillate"})),R=U.next();!R.done;R=U.next()){var H=R.value,O=L.get(H.componentId);if(O.sceneId===oe)try{for(var Z=(w=void 0,ze(Bi(O))),B=Z.next();!B.done;B=Z.next()){var V=B.value,z=Bn.get(V.id);z||(z={base:$e([],Ue(Qi(V)),!1),vx:0,vy:0},Bn.set(V.id,z));var j=H.parameters,K=(xe/j.periodSeconds+j.phase)*Math.PI*2,ee=Math.sin(K)*j.amplitude,ue=Math.cos(K)*j.amplitude*Math.PI*2/j.periodSeconds,_e=(b=Ee.get(V.id))!==null&&b!==void 0?b:{parameters:{}},ve=$e([],Ue(z.base),!1);j.axis==="x"?(ve[4]+=ee,z.vx=ue,z.vy=0):(ve[5]+=ee,z.vy=ue,z.vx=0),Ee.set(V.id,ht(ht({},_e),{transform:ve})),Bn.set(V.id,z)}}catch(Ae){w={error:Ae}}finally{try{B&&!B.done&&(T=Z.return)&&T.call(Z)}finally{if(w)throw w.error}}}}catch(Ae){c={error:Ae}}finally{try{R&&!R.done&&(y=U.return)&&y.call(U)}finally{if(c)throw c.error}}}function Pl(){var c,y;Pn.clear();var w=function(R){var H=n.gameplay.filter(function(Z){return Z.kind==="path-gate"&&Z.parameters.networkBehaviorId===R.id}),O=Eg({id:R.id,nodes:R.parameters.nodes,edges:R.parameters.edges,gates:H,onEvent:function(Z,B){var V,z=nt(B.componentId),j=(V=z?.prototypeId)!==null&&V!==void 0?V:B.componentId;Un(ht({kind:Z,componentId:j,instanceId:z?.instanceId},B.nodeId?{nodeId:B.nodeId}:{}))}});Pn.set(R.id,O)};try{for(var T=ze(n.gameplay.filter(function(R){return R.kind==="path-network"})),b=T.next();!b.done;b=T.next()){var U=b.value;w(U)}}catch(R){c={error:R}}finally{try{b&&!b.done&&(y=T.return)&&y.call(T)}finally{if(c)throw c.error}}}function Io(c,y){var w,T,b,U,R,H,O,Z,B,V,z,j,K;y===void 0&&(y=!0);var ee=0;try{for(var ue=ze(n.gameplay.filter(function(tt){return tt.kind==="path-agent"})),_e=ue.next();!_e.done;_e=ue.next()){var ve=_e.value,Ae=L.get(ve.componentId),fe=Pn.get(ve.parameters.networkBehaviorId);if(!(Ae.sceneId!==oe||!fe))try{for(var pe=(b=void 0,ze(Bi(Ae))),Re=pe.next();!Re.done;Re=pe.next()){var de=Re.value;if(++ee>64){Zi("Path agent budget exhausted");break}var Fe=fe.getAgent(de.id);Fe||(Fe=fe.addAgent(ht(ht({},ve.parameters),{id:de.id,startNode:(z=de.pathStartNode)!==null&&z!==void 0?z:ve.parameters.startNode,targetNode:(j=de.pathTargetNode)!==null&&j!==void 0?j:ve.parameters.targetNode}))),Fe.speedMultiplier=Math.max(0,Number(ve.parameters.speedMultiplierVariableId?$[ve.parameters.speedMultiplierVariableId]:1))}}catch(tt){b={error:tt}}finally{try{Re&&!Re.done&&(U=pe.return)&&U.call(pe)}finally{if(b)throw b.error}}}}catch(tt){w={error:tt}}finally{try{_e&&!_e.done&&(T=ue.return)&&T.call(ue)}finally{if(w)throw w.error}}if(y){var Be=function(tt,xt){var Qe=n.gameplay.find(function(zt){return zt.id===tt});L.get(Qe.componentId).sceneId===oe&&xt.tick(c)};try{for(var Oe=ze(Pn),Xe=Oe.next();!Xe.done;Xe=Oe.next()){var vt=Ue(Xe.value,2),Pt=vt[0],Tt=vt[1];Be(Pt,Tt)}}catch(tt){R={error:tt}}finally{try{Xe&&!Xe.done&&(H=Oe.return)&&H.call(Oe)}finally{if(R)throw R.error}}}try{for(var Ct=ze(n.gameplay.filter(function(tt){return tt.kind==="path-agent"})),kt=Ct.next();!kt.done;kt=Ct.next()){var ve=kt.value,Ae=L.get(ve.componentId),At=Pn.get(ve.parameters.networkBehaviorId);if(!(Ae.sceneId!==oe||!At))try{for(var _t=(B=void 0,ze(Bi(Ae))),St=_t.next();!St.done;St=_t.next()){var de=St.value,Fe=At.getAgent(de.id);if(Fe){if(Fe.orientToPath==="rotate")cs(de,Fe.heading);else if(Fe.orientToPath==="flip-x")cs(de,0,Fe.flipX);else if(Fe.orientToPath==="iso-4"){var bt=(K=Ee.get(de.id))!==null&&K!==void 0?K:{transform:$e([],Ue(de.transform),!1),parameters:{}};bt.pathFrame=Fe.frame,Ee.set(de.id,bt)}var Ve=de.parentId?oi(ci(nt(de.parentId)),Fe.x,Fe.y):Fe;Xr(de,Ve.x,Ve.y)}}}catch(Qe){B={error:Qe}}finally{try{St&&!St.done&&(V=_t.return)&&V.call(_t)}finally{if(B)throw B.error}}}}catch(tt){O={error:tt}}finally{try{kt&&!kt.done&&(Z=Ct.return)&&Z.call(Ct)}finally{if(O)throw O.error}}}function Ll(c){var y,w,T,b,U,R,H,O,Z,B,V=new Set;try{for(var z=ze(n.gameplay.filter(function(ft){return ft.kind==="value-meter"})),j=z.next();!j.done;j=z.next()){var K=j.value,ee=L.get(K.componentId);if(ee.sceneId===oe)try{for(var ue=(T=void 0,ze(Bi(ee))),_e=ue.next();!_e.done;_e=ue.next()){var ve=_e.value,Ae=K.parameters,fe=Ae.instanceField?Wa(ve):void 0,pe=Ae.instanceField==="hp"&&fe?fe.hp/fe.maxHp*(Ae.max-Ae.min)+Ae.min:Ae.instanceField==="value"&&fe?fe.value:Number($[Ae.variableId]),Re=fn.get(ve.id);Re||(Re={base:$e([],Ue(Qi(ve)),!1),value:Number.isFinite(pe)?Math.max(Ae.min,Math.min(Ae.max,pe)):Ae.min},fn.set(ve.id,Re)),V.add(ve.id);var de=Math.max(Ae.min,Math.min(Ae.max,pe)),Fe=Ae.smoothingSeconds?1-Math.exp(-c/Ae.smoothingSeconds):1;Re.value+=((Number.isFinite(de)?de:Ae.min)-Re.value)*Fe;var Be=Math.max(0,Math.min(1,(Re.value-Ae.min)/(Ae.max-Ae.min))),Oe=$e([],Ue(Re.base),!1),Xe=(Z=Ee.get(ve.id))!==null&&Z!==void 0?Z:{parameters:{}},vt=Ae.axis==="x"?tn(ve).width:tn(ve).height;if(Ae.axis==="x"?(Oe[0]*=Be,Oe[1]*=Be):(Oe[2]*=Be,Oe[3]*=Be),Ae.direction==="negative"){var Pt=vt*(1-Be);Ae.axis==="x"?(Oe[4]+=Re.base[0]*Pt,Oe[5]+=Re.base[1]*Pt):(Oe[4]+=Re.base[2]*Pt,Oe[5]+=Re.base[3]*Pt)}Ee.set(ve.id,ht(ht({},Xe),{transform:Oe}))}}catch(ft){T={error:ft}}finally{try{_e&&!_e.done&&(b=ue.return)&&b.call(ue)}finally{if(T)throw T.error}}}}catch(ft){y={error:ft}}finally{try{j&&!j.done&&(w=z.return)&&w.call(z)}finally{if(y)throw y.error}}try{for(var Tt=ze(fn.keys()),Ct=Tt.next();!Ct.done;Ct=Tt.next()){var kt=Ct.value;V.has(kt)||fn.delete(kt)}}catch(ft){U={error:ft}}finally{try{Ct&&!Ct.done&&(R=Tt.return)&&R.call(Tt)}finally{if(U)throw U.error}}try{for(var At=ze(n.gameplay.filter(function(ft){return ft.kind==="camera-follow"})),_t=At.next();!_t.done;_t=At.next()){var K=_t.value,St=L.get(K.componentId),de=nt(K.parameters.targetId);if(!(St.sceneId!==oe||!de)){var bt=En.get(St.id);bt||(bt={base:$e([],Ue(St.transform),!1),x:K.parameters.minX,y:K.parameters.minY},En.set(St.id,bt));var Ve=function(Qn,gi){for(var ei=[],An=Qn;An&&An.id!==gi.id;An=nt(An.parentId))ei.unshift(An);return ei.reduce(function(Hi,_r){return Uo(Hi,Qi(_r))},Na())},Oe=qr(de,St.id)?Ve(de,St):ci(de),Ae=tn(de),tt=oi(Oe,Ae.width/2,Ae.height/2),xt=q(),Qe=K.parameters,zt=Math.max(Qe.minX,Qe.maxX-xt.width/Qe.zoom),jt=Math.max(Qe.minY,Qe.maxY-xt.height/Qe.zoom),Sn=Math.max(Qe.minX,Math.min(zt,tt.x-xt.width/(2*Qe.zoom))),Xt=Math.max(Qe.minY,Math.min(jt,tt.y-xt.height/(2*Qe.zoom))),Fe=1-Math.exp(-Qe.smoothing*c);bt.x+=(Sn-bt.x)*Fe,bt.y+=(Xt-bt.y)*Fe;var Xe=(B=Ee.get(St.id))!==null&&B!==void 0?B:{parameters:{}},Jt=$e([],Ue(bt.base),!1);Jt[0]*=Qe.zoom,Jt[1]*=Qe.zoom,Jt[2]*=Qe.zoom,Jt[3]*=Qe.zoom,Jt[4]-=bt.x*Qe.zoom,Jt[5]-=bt.y*Qe.zoom,Ee.set(St.id,ht(ht({},Xe),{transform:Jt}))}}}catch(ft){H={error:ft}}finally{try{_t&&!_t.done&&(O=At.return)&&O.call(At)}finally{if(H)throw H.error}}}function li(){return{bodies:$e([],Ue(wn.values()),!1).map(function(c){return{id:c.id,sourceId:c.sourceId,x:c.x,y:c.y,vx:c.vx,vy:c.vy,atRest:!!c.atRest,captured:!!c.captured}}),aiming:Ge?{componentId:Ge.sourceId,pointerId:Ge.pointerId,power:Ge.power}:null}}function Ma(c){for(var y=c;y;){if(y.contract==="native.stage3d.v1")return y;y=y.parentId?nt(y.parentId):void 0}}function ia(c,y){var w,T,b,U,R,H,O,Z,B=sn.get(c.id);if(B)return B;var V=tn(c),z=Ma(c),j={};if(y.parameters.fitColliderFromModel&&z&&Zt){Zt.getStage(z);var K=Zt.modelBoundsFor(c.id);if(K){var ee=Math.max(.02,K.width*Math.abs((w=V.sx)!==null&&w!==void 0?w:1)*.5),ue=Math.max(.02,K.depth*Math.abs((T=V.sz)!==null&&T!==void 0?T:1)*.5);j.hx=ee,j.hz=ue,j.radius=Math.max(.02,Math.max(ee,ue))}}return B=ht(ht({id:c.id,sourceId:y.componentId,stageId:z?.id,x:(b=V.x)!==null&&b!==void 0?b:0,y:(U=V.y)!==null&&U!==void 0?U:0,z:(R=V.z)!==null&&R!==void 0?R:0,vx:0,vy:0,vz:0,spin:0,atRest:!0,captured:!1,captureElapsed:0,airborne:!1,restElapsed:0,movingTime:0,lastSafe:{x:(H=V.x)!==null&&H!==void 0?H:0,y:(O=V.y)!==null&&O!==void 0?O:0,z:(Z=V.z)!==null&&Z!==void 0?Z:0}},y.parameters),j),sn.set(c.id,B),B}function Ra(){var c,y,w,T,b,U,R,H=[],O=[],Z=[];if(!Zt)return{bodies:H,walls:O,zones:Z};try{for(var B=ze(n.gameplay.filter(function(ve){return ve.kind==="physics-3d"})),V=B.next();!V.done;V=B.next()){var z=V.value,j=L.get(z.componentId);if(!(!j||j.sceneId!==oe||!Ti(j))){var K=ia(j,z);K.mode==="dynamic"?H.push(K):O.push(K)}}}catch(ve){c={error:ve}}finally{try{V&&!V.done&&(y=B.return)&&y.call(B)}finally{if(c)throw c.error}}try{for(var ee=ze(n.gameplay.filter(function(ve){return ve.kind==="capture-zone-3d"})),ue=ee.next();!ue.done;ue=ee.next()){var z=ue.value,j=L.get(z.componentId);if(!(!j||j.sceneId!==oe||!Ti(j))){var _e=tn(j);Z.push(ht({id:j.id,sourceId:j.id,x:(b=_e.x)!==null&&b!==void 0?b:0,y:(U=_e.y)!==null&&U!==void 0?U:0,z:(R=_e.z)!==null&&R!==void 0?R:0},z.parameters))}}}catch(ve){w={error:ve}}finally{try{ue&&!ue.done&&(T=ee.return)&&T.call(ee)}finally{if(w)throw w.error}}return{bodies:H,walls:O,zones:Z}}function Pa(c){var y,w,T,b,U,R,H,O,Z,B;if(Zt){try{for(var V=ze(n.gameplay.filter(function(kt){return kt.kind==="oscillate-3d"})),z=V.next();!z.done;z=V.next()){var j=z.value,K=L.get(j.componentId);if(!(!K||K.sceneId!==oe)){var ee=Mn.get(K.id);if(!ee){var ue=tn(K);ee={x:(U=ue.x)!==null&&U!==void 0?U:0,y:(R=ue.y)!==null&&R!==void 0?R:0,z:(H=ue.z)!==null&&H!==void 0?H:0},Mn.set(K.id,ee)}var _e=j.parameters,ve=xe*_e.angularSpeed+_e.phase,Ae=Math.sin(ve)*_e.amplitude,fe=Math.cos(ve)*_e.amplitude*_e.angularSpeed,pe=(O=sn.get(K.id))!==null&&O!==void 0?O:Vn("physics-3d",K.id)?ia(K,Vn("physics-3d",K.id)):void 0,Re=ee.x+(_e.axis==="x"?Ae:0),de=ee.y+(_e.axis==="y"?Ae:0),Fe=ee.z+(_e.axis==="z"?Ae:0);if(pe)pe.x=Re,pe.y=de,pe.z=Fe,pe.vx=_e.axis==="x"?fe:0,pe.vy=_e.axis==="y"?fe:0,pe.vz=_e.axis==="z"?fe:0;else{var Be=(Z=Ee.get(K.id))!==null&&Z!==void 0?Z:{transform:$e([],Ue(K.transform),!1),parameters:{}};Be.parameters.x=Re,Be.parameters.y=de,Be.parameters.z=Fe,Ee.set(K.id,Be)}}}}catch(kt){y={error:kt}}finally{try{z&&!z.done&&(w=V.return)&&w.call(V)}finally{if(y)throw y.error}}var Oe=Ra(),Xe=Oe.bodies,vt=Oe.walls,Pt=Oe.zones;ph({bodies:Xe,walls:vt,zones:Pt,dt:c,onEvent:function(kt,At,_t){var St={kind:kt,componentId:At.sourceId};_t&&(St.otherId=_t.sourceId),Un(St)}});try{for(var Tt=ze(Xe),Ct=Tt.next();!Ct.done;Ct=Tt.next()){var pe=Ct.value;pe.captured&&(pe.captureElapsed=((B=pe.captureElapsed)!==null&&B!==void 0?B:0)+c)}}catch(kt){T={error:kt}}finally{try{Ct&&!Ct.done&&(b=Tt.return)&&b.call(Tt)}finally{if(T)throw T.error}}Dl(c,vt),Zt.stepAnimations(c,function(kt,At,_t){Un(ht(ht({kind:"modelAnimationEnd",componentId:At},kt!==At?{selfInstanceId:kt,instanceId:kt}:{}),{clipName:_t}))})}}function Xa(c){var y=xn.get(c.componentId);if(!y){var w=c.parameters;y={behavior:c,x:w.x,y:w.y,z:w.z,yaw:w.yaw,pitch:w.pitch,bobPhase:0,bob:0},xn.set(c.componentId,y)}return y}function Es(){var c,y;try{for(var w=ze(n.gameplay.filter(function(U){var R;return U.kind==="fps-controller-3d"&&((R=L.get(U.componentId))===null||R===void 0?void 0:R.sceneId)===oe})),T=w.next();!T.done;T=w.next()){var b=T.value;Xa(b)}}catch(U){c={error:U}}finally{try{T&&!T.done&&(y=w.return)&&y.call(w)}finally{if(c)throw c.error}}}function As(c){var y,w,T,b=[];try{for(var U=ze(Ke.values()),R=U.next();!R.done;R=U.next()){var H=R.value;H.contract==="native.mesh3d.v1"&&((T=Ma(H))===null||T===void 0?void 0:T.id)===c&&b.push(H)}}catch(O){y={error:O}}finally{try{R&&!R.done&&(w=U.return)&&w.call(U)}finally{if(y)throw y.error}}return b}function Co(c,y,w){var T,b,U=Xa(c),R=c.parameters,H=R.lookSensitivity,O=R.invertAimY?-1:1,Z=U.yaw-y*H;R.minYaw!==void 0&&R.maxYaw!==void 0&&(Z=Math.max(R.minYaw,Math.min(R.maxYaw,Z))),U.yaw=Z,U.pitch=Math.max((T=R.minPitch)!==null&&T!==void 0?T:-.75,Math.min((b=R.maxPitch)!==null&&b!==void 0?b:.75,U.pitch-w*H*O))}function Dl(c,y){var w,T,b,U,R,H,O,Z,B,V,z,j,K,ee,ue,_e,ve,Ae,fe,pe,Re=function(_t){var St=L.get(_t.componentId);if(!St||St.sceneId!==oe)return"continue";var bt=Xa(_t),Ve=_t.parameters,tt=Ve.aimJoystickBehaviorId?et.get(Ve.aimJoystickBehaviorId):void 0;if(tt&&Ve.aimMode==="rate"&&tt.magnitude>1e-4&&c>0){var xt=(O=Ve.aimTurnSpeed)!==null&&O!==void 0?O:1.8,Qe=Ve.invertAimY?-1:1,zt=bt.yaw-tt.nx*xt*c;Ve.minYaw!==void 0&&Ve.maxYaw!==void 0&&(zt=Math.max(Ve.minYaw,Math.min(Ve.maxYaw,zt))),bt.yaw=zt,bt.pitch=Math.max((Z=Ve.minPitch)!==null&&Z!==void 0?Z:-.75,Math.min((B=Ve.maxPitch)!==null&&B!==void 0?B:.75,bt.pitch-tt.ny*xt*Qe*c))}var jt=Ve.joystickBehaviorId?et.get(Ve.joystickBehaviorId):void 0,Sn=jt?jt.nx:Number(Ve.moveXVariableId?$[Ve.moveXVariableId]:0),Xt=jt?jt.ny:Number(Ve.moveYVariableId?$[Ve.moveYVariableId]:0),Jt=Math.min(1,Math.hypot(Sn,Xt));if(Jt>1e-4&&Ve.moveSpeed>0&&c>0){var ft=-Xt,st=Sn,Dn=-Math.sin(bt.yaw),Ni=-Math.cos(bt.yaw),_i=Math.cos(bt.yaw),on=-Math.sin(bt.yaw),Qn=Ve.moveSpeed*c,gi=y.filter(function(An){return An.stageId===St.id}),ei=mh(bt.x+(Dn*ft+_i*st)*Qn,bt.z+(Ni*ft+on*st)*Qn,(V=Ve.playerRadius)!==null&&V!==void 0?V:.45,gi,(z=Ve.boundsX)!==null&&z!==void 0?z:12,(j=Ve.boundsZ)!==null&&j!==void 0?j:12);bt.x=ei.x,bt.z=ei.z,bt.bobPhase+=c*10*Jt,bt.bob=W?.matches?0:Math.sin(bt.bobPhase)*((K=Ve.bobAmplitude)!==null&&K!==void 0?K:.04)*Jt}else bt.bob*=Math.max(0,1-12*c)};try{for(var de=ze(n.gameplay.filter(function(_t){return _t.kind==="fps-controller-3d"})),Fe=de.next();!Fe.done;Fe=de.next()){var Be=Fe.value;Re(Be)}}catch(_t){w={error:_t}}finally{try{Fe&&!Fe.done&&(T=de.return)&&T.call(de)}finally{if(w)throw w.error}}try{for(var Oe=ze(n.gameplay.filter(function(_t){return _t.kind==="steer-3d"})),Xe=Oe.next();!Xe.done;Xe=Oe.next()){var Be=Xe.value,vt=L.get(Be.componentId);if(!(!vt||vt.sceneId!==oe)){var Pt=Be.parameters,Tt=function(St){if(!Ti(St))return"continue";var bt=Ma(St),Ve=bt?xn.get(bt.id):void 0;if(!Ve)return"continue";var tt=tn(St),xt=(ee=tt.x)!==null&&ee!==void 0?ee:0,Qe=(ue=tt.y)!==null&&ue!==void 0?ue:0,zt=(_e=tt.z)!==null&&_e!==void 0?_e:0,jt=Ve.x-xt,Sn=Ve.z-zt,Xt=Math.hypot(jt,Sn),Jt=(ve=Pt.stopDistance)!==null&&ve!==void 0?ve:2.5,ft=xt,st=Qe,Dn=zt,Ni=Pt.mode==="chase-camera"&&Jt<=.5;if(Pt.mode==="chase-camera"&&Xt>Jt&&Xt>1e-4){var _i=Math.min(Xt-Jt,Pt.speed*c);ft+=jt/Xt*_i,Dn+=Sn/Xt*_i,Ni&&(st+=(Ve.y-.14-Qe)*(_i/Xt))}else if(Pt.mode==="strafe-camera"&&Xt>1e-4){var on=-Sn/Xt,Qn=jt/Xt;ft+=on*Pt.speed*c,Dn+=Qn*Pt.speed*c}else Pt.mode==="patrol"&&(ft+=Math.cos(xe*1.5)*Pt.speed*c);var gi=Ni?[]:y.filter(function(Hi){return Hi.stageId===bt.id&&Hi.id!==St.id}),ei=Ni?{x:ft,z:Dn}:mh(ft,Dn,.45,gi,(Ae=Pt.boundsX)!==null&&Ae!==void 0?Ae:12,(fe=Pt.boundsZ)!==null&&fe!==void 0?fe:12),An=(pe=Ee.get(St.id))!==null&&pe!==void 0?pe:{transform:$e([],Ue(St.transform),!1),parameters:{}};An.parameters.x=ei.x,Ni&&(An.parameters.y=st),An.parameters.z=ei.z,Pt.faceCamera!==!1&&(An.parameters.ry=Math.atan2(Ve.x-ei.x,Ve.z-ei.z)),Ee.set(St.id,An)};try{for(var Ct=(R=void 0,ze(Bi(vt))),kt=Ct.next();!kt.done;kt=Ct.next()){var At=kt.value;Tt(At)}}catch(St){R={error:St}}finally{try{kt&&!kt.done&&(H=Ct.return)&&H.call(Ct)}finally{if(R)throw R.error}}}}}catch(_t){b={error:_t}}finally{try{Xe&&!Xe.done&&(U=Oe.return)&&U.call(Oe)}finally{if(b)throw b.error}}}function Nl(c){for(var y,w,T,b,U,R,H=[],O=c;O&&O.contract==="native.mesh3d.v1";O=nt(O.parentId))H.push(O);for(var Z=0,B=0,V=0,z=0,j=H.length-1;j>=0;j--){var K=H[j],ee=sn.get(K.id),ue=tn(K),_e=ee?ee.x:(y=ue.x)!==null&&y!==void 0?y:0,ve=ee?(T=(w=ee.y)!==null&&w!==void 0?w:ue.y)!==null&&T!==void 0?T:0:(b=ue.y)!==null&&b!==void 0?b:0,Ae=ee?ee.z:(U=ue.z)!==null&&U!==void 0?U:0,fe=Math.cos(z),pe=Math.sin(z);Z+=_e*fe+Ae*pe,B+=ve,V+=-_e*pe+Ae*fe,z+=(R=ue.ry)!==null&&R!==void 0?R:0}return{x:Z,y:B,z:V,ry:z}}var Ro=0;function Of(c){var y,w,T,b,U,R,H=Math.max(1,Math.min(16,Math.floor((T=c.count)!==null&&T!==void 0?T:1)));if(c.fromComponentId!==void 0||c.fromTeam!==void 0){var O=[];if(c.fromComponentId!==void 0){var Z=L.get(c.fromComponentId);Z&&Z.sceneId===oe&&(O=Bi(Z).filter(function(Oe){var Xe,vt;return Ti(Oe)&&((vt=(Xe=Wa(Oe))===null||Xe===void 0?void 0:Xe.hp)!==null&&vt!==void 0?vt:1)>0}))}else{var B=new Set;try{for(var V=ze($e($e([],Ue(n.components),!1),Ue(Te),!1)),z=V.next();!z.done;z=V.next()){var j=z.value;if(!(j.contract!=="native.mesh3d.v1"||j.sceneId!==oe||j.prototype||B.has(j.id)||!Ti(j))){var K=Wa(j);K&&K.hp>0&&(c.fromTeam==="any"||K.team===c.fromTeam)&&(B.add(j.id),O.push(j))}}}catch(Oe){y={error:Oe}}finally{try{z&&!z.done&&(w=V.return)&&w.call(V)}finally{if(y)throw y.error}}}if(!O.length)return;for(var ee=(b=c.offsetX)!==null&&b!==void 0?b:0,ue=(U=c.offsetY)!==null&&U!==void 0?U:0,_e=(R=c.offsetZ)!==null&&R!==void 0?R:0,ve=0;ve<H;ve++){var Ae=O[Ro++%O.length],fe=Nl(Ae),pe=Math.cos(fe.ry),Re=Math.sin(fe.ry),de=c.jitterX?(A.rng.next()*2-1)*c.jitterX:0,Fe=c.jitterZ?(A.rng.next()*2-1)*c.jitterZ:0;ru(c.prototypeId,fe.x+ee*pe+_e*Re+de,fe.y+ue,fe.z-ee*Re+_e*pe+Fe)}return}for(var Be=0;Be<H;Be++){var de=c.jitterX?(A.rng.next()*2-1)*c.jitterX:0,Fe=c.jitterZ?(A.rng.next()*2-1)*c.jitterZ:0;ru(c.prototypeId,c.x+de,c.y,c.z+Fe)}}function ru(c,y,w,T){if(Te.length>=128){Zi("Instance budget exhausted");return}var b=L.get(c),U=function(Z){return 1+n.components.filter(function(B){return B.parentId===Z}).reduce(function(B,V){return B+U(V.id)},0)};if(Ke.size+U(b.id)>4096){Zi("Runtime node budget exhausted");return}var R="instance."+ ++mt;function H(Z,B){var V,z,j=Z.id===b.id?R:R+":"+Z.id,K=ht(ht({},Z),{id:j,runtimeId:j,instanceId:R,prototypeId:Z.id,prototype:!1,parentId:B,transform:$e([],Ue(Z.transform),!1),parameters:ht({},Z.parameters),spawnTime:xe});Ke.set(j,K);try{for(var ee=ze(n.components.filter(function(ve){return ve.parentId===Z.id})),ue=ee.next();!ue.done;ue=ee.next()){var _e=ue.value;H(_e,j)}}catch(ve){V={error:ve}}finally{try{ue&&!ue.done&&(z=ee.return)&&z.call(ee)}finally{if(V)throw V.error}}return K}var O=H(b,b.parentId);return O.parameters.x=y,O.parameters.y=w,O.parameters.z=T,Te.push(O),Eo(O),O}function Bf(c){var y,w,T;if(Zt){var b=L.get(c.stageId);if(!(!b||b.sceneId!==oe)){(y=Zt.triggerRecoil)===null||y===void 0||y.call(Zt,b.id);var U=tn(b),R=ci(b),H=Math.hypot(R[0],R[1]),O=Math.hypot(R[2],R[3]),Z=Zt.getStage(b),B=!!(Z?.isFullBleed&&Z.lastWidth>0&&Z.lastHeight>0),V=Zt.syncStage(b,{time:xe,ambientTime:Ye,propsOf:tn,bodies3d:sn,fpsPose:xn.get(b.id),instances3d:As(b.id),aimLocked:!!Dt,groundFn:Ns,worldWidth:B?Z.lastWidth:U.width*H,worldHeight:B?Z.lastHeight:U.height*O,designHeight:B?Z.lastDesignH:U.height*O}).entry,z=0,j=0;if(c.mode==="pointer")if(B)z=(Ft.x-Z.lastX)/Math.max(1,Z.lastWidth)*2-1,j=1-(Ft.y-Z.lastY)/Math.max(1,Z.lastHeight)*2;else{var K=oi(Or(R),Ft.x,Ft.y);z=K.x/Math.max(1,U.width)*2-1,j=1-K.y/Math.max(1,U.height)*2}var ee=new Set(n.gameplay.filter(function(fe){return fe.kind==="physics-3d"&&fe.parameters.mode!=="dynamic"}).map(function(fe){return fe.componentId})),ue=(w=c.targetTeam)!==null&&w!==void 0?w:"any",_e=function(fe){var pe,Re,de=nt(fe);return!de||!Ti(de)?!1:ue!=="any"?((pe=Wa(de))===null||pe===void 0?void 0:pe.team)===ue:!!Wa(de)||!ee.has((Re=de.prototypeId)!==null&&Re!==void 0?Re:de.id)},ve=V.raycast(z,j,(T=c.maxDistance)!==null&&T!==void 0?T:80,{isTarget:_e,isOccluder:function(fe){return ee.has(fe)}});if(ve){var Ae=nt(ve.id);Ae&&Un(or("raycastHit3d",Ae,b))}else Un({kind:"raycastMiss3d",componentId:b.id})}}}function Xg(c,y){var w,T,b,U,R;if(!Zt||!c||c.contract!=="native.mesh3d.v1")return null;var H=(w=y?.stageComp)!==null&&w!==void 0?w:Ma(c);if(!H)return null;var O=(T=y?.entry)!==null&&T!==void 0?T:Zt.getStage(H),Z=y?y.fullBleed:!!O?.isFullBleed,B=y?Z?y.worldWidth:y.stageWidth:(b=O?.lastWidth)!==null&&b!==void 0?b:0,V=y?Z?y.worldHeight:y.stageHeight:(U=O?.lastHeight)!==null&&U!==void 0?U:0;if(!O||B<=0||V<=0)return null;var z=(R=O.projectNodeBounds)===null||R===void 0?void 0:R.call(O,c.id,B,V);if(!z)return null;var j=function(pe){var Re,de,Fe;if(Z){var Be=y?y.drawX:(Re=O.lastX)!==null&&Re!==void 0?Re:0,Oe=y?y.drawY:(de=O.lastY)!==null&&de!==void 0?de:0;return{x:Be+pe.x,y:Oe+pe.y}}var Xe=(Fe=y?.m)!==null&&Fe!==void 0?Fe:ci(H);return oi(Xe,pe.x,pe.y)};if(z.behindCamera)return{id:c.id,stageId:H.id,visible:z.visible,behindCamera:!0,localBounds:z,stageLocalWidth:B,stageLocalHeight:V,stageEntry:O,bounds:{left:0,right:0,top:0,bottom:0,width:0,height:0,centerX:0,centerY:0},anchors:{center:{x:0,y:0},top:{x:0,y:0},bottom:{x:0,y:0}}};var K=[[z.left,z.top],[z.right,z.top],[z.right,z.bottom],[z.left,z.bottom]].map(function(pe){var Re=Ue(pe,2),de=Re[0],Fe=Re[1];return j({x:de,y:Fe})}),ee=Math.min.apply(Math,$e([],Ue(K.map(function(pe){return pe.x})),!1)),ue=Math.max.apply(Math,$e([],Ue(K.map(function(pe){return pe.x})),!1)),_e=Math.min.apply(Math,$e([],Ue(K.map(function(pe){return pe.y})),!1)),ve=Math.max.apply(Math,$e([],Ue(K.map(function(pe){return pe.y})),!1)),Ae={left:ee,right:ue,top:_e,bottom:ve,width:Math.max(0,ue-ee),height:Math.max(0,ve-_e),centerX:(ee+ue)/2,centerY:(_e+ve)/2},fe={center:j(z.anchors.center),top:j(z.anchors.top),bottom:j(z.anchors.bottom)};return{id:c.id,stageId:H.id,visible:z.visible,behindCamera:!1,localBounds:z,stageLocalWidth:B,stageLocalHeight:V,stageEntry:O,bounds:Ae,anchors:fe}}function Yg(c){var y,w,T,b,U,R,H,O,Z,B,V,z,j,K,ee,ue,_e,ve,Ae;if(ri.clear(),wt.clear(),!!Zt){var fe=[];try{for(var pe=ze(zn),Re=pe.next();!Re.done;Re=pe.next()){var de=Ue(Re.value,2),Fe=de[0],Be=de[1],Oe=L.get(Fe);Oe&&Oe.sceneId===oe&&fe.push({comp:Oe,cfg:Be})}}catch(Vi){y={error:Vi}}finally{try{Re&&!Re.done&&(w=pe.return)&&w.call(pe)}finally{if(y)throw y.error}}if(fe.length){var Xe=new Map;try{for(var vt=ze(n.components),Pt=vt.next();!Pt.done;Pt=vt.next()){var Tt=Pt.value;if(!(Tt.contract!=="native.stage3d.v1"||Tt.sceneId!==oe||Tt.prototype||!Ti(Tt))){var Ct=!!(Kn.has(Tt.id)&&mi),kt=ci(Tt),At=Ks(Tt),_t=Math.hypot(kt[0],kt[1]),St=Math.hypot(kt[2],kt[3]),bt=Ct?mi.w:At.width*_t,Ve=Ct?mi.h:At.height*St,tt=Ct?mi.x:0,xt=Ct?mi.y:0,Qe=Ct?c.height:At.height*St,zt=Zt.syncStage(Tt,{time:xe,ambientTime:Ye,propsOf:Ks,bodies3d:sn,fpsPose:xn.get(Tt.id),instances3d:As(Tt.id),aimLocked:!!Dt,groundFn:Ns,worldWidth:bt,worldHeight:Ve,designHeight:Qe}).entry;Object.assign(zt,{lastX:tt,lastY:xt,lastWidth:Ct?bt:At.width,lastHeight:Ct?Ve:At.height,lastDesignH:Qe,isFullBleed:Ct}),Xe.set(Tt.id,{stageComp:Tt,entry:zt,m:kt,fullBleed:Ct,drawX:tt,drawY:xt,worldWidth:bt,worldHeight:Ve,stageWidth:At.width,stageHeight:At.height})}}}catch(Vi){T={error:Vi}}finally{try{Pt&&!Pt.done&&(b=vt.return)&&b.call(vt)}finally{if(T)throw T.error}}var jt=sr(c),Sn=function(Vi){for(var br=Vi;br;br=br.parentId?nt(br.parentId):void 0){var Hn=Ks(br);if(!Hn.visible||Hn.opacity<=0)return!1}return!0};try{for(var Xt=ze(fe),Jt=Xt.next();!Jt.done;Jt=Xt.next()){var ft=Jt.value,Oe=ft.comp,Be=ft.cfg,st=Sn(Oe),Dn=nt(Be.targetId),Tt=Dn?Ma(Dn):void 0,Ni=Tt?Xe.get(Tt.id):void 0,_i=!!(Dn&&Ni&&Sn(Dn)),on=Dn&&Ni?Xg(Dn,Ni):null,Qn=!!(!on||on.behindCamera),gi=1,ei=!0;if(on&&!on.behindCamera){var An=on.bounds,Hi=Math.max(0,Math.min(An.right,jt.right)-Math.max(An.left,jt.left)),_r=Math.max(0,Math.min(An.bottom,jt.bottom)-Math.max(An.top,jt.top));if(An.width<.5&&An.height<.5){var Mr=An.centerX>=jt.left&&An.centerX<=jt.right&&An.centerY>=jt.top&&An.centerY<=jt.bottom;gi=Mr?0:1,ei=!Mr}else{var Gi=Math.max(1,An.width*An.height);gi=Math.max(0,Math.min(1,1-Hi*_r/Gi)),ei=Hi<=0||_r<=0}}var Zn=Ks(Oe),ui=void 0,mn=void 0,yi=void 0,Fn=void 0;if(on&&!on.behindCamera&&Be.fitToProjectedBounds){var Mi=(H=Be.paddingPx)!==null&&H!==void 0?H:10,un=(O=Be.minSizePx)!==null&&O!==void 0?O:48,Yn=(Z=Be.maxSizePx)!==null&&Z!==void 0?Z:260,Ei=on.bounds.width+Mi*2,Sr=on.bounds.height+Mi*2;if(Be.squareBounds){var Rr=Math.max(Ei,Sr);Ei=Rr,Sr=Rr}ui=Math.max(un,Math.min(Yn,Ei)),mn=Math.max(un,Math.min(Yn,Sr)),Oe.contract==="native.group.v1"&&Zn.width>0&&Zn.height>0&&(yi=ui/Zn.width,Fn=mn/Zn.height)}var Dr=ui??Zn.width,Sa=mn??Zn.height,cr=on&&!on.behindCamera?(V=on.anchors[(B=Be.anchor)!==null&&B!==void 0?B:"center"])!==null&&V!==void 0?V:{x:on.bounds.centerX,y:on.bounds.centerY}:null,Zr=cr?cr.x+((z=Be.offsetX)!==null&&z!==void 0?z:0):0,Jr=cr?cr.y+((j=Be.offsetY)!==null&&j!==void 0?j:0):0,Nr=(K=Be.offscreen)!==null&&K!==void 0?K:"hide";if(cr&&Nr==="clamp"){var $r=Dr/2,zi=Sa/2;Zr=Math.max(jt.left+$r,Math.min(jt.right-$r,Zr)),Jr=Math.max(jt.top+zi,Math.min(jt.bottom-zi,Jr))}var Ji=st;Be.syncVisibility!==!1&&!_i&&(Ji=!1),Qn&&(Ji=!1),Nr==="hide"&&ei&&(Ji=!1);var zt={componentId:Oe.id,targetId:Be.targetId,stageId:(ee=Tt?.id)!==null&&ee!==void 0?ee:null,config:Be,ownerHiddenByAuthor:!st,targetVisible:_i,visible:Ji,behindCamera:Qn,offscreen:ei,clippedFraction:gi,targetBounds:on&&!on.behindCamera?on.bounds:null,localBounds:(ue=on?.localBounds)!==null&&ue!==void 0?ue:null,stageLocalWidth:(_e=on?.stageLocalWidth)!==null&&_e!==void 0?_e:0,stageLocalHeight:(ve=on?.stageLocalHeight)!==null&&ve!==void 0?ve:0,stageEntry:(Ae=on?.stageEntry)!==null&&Ae!==void 0?Ae:null,anchorPoint:cr,cx:Zr,cy:Jr,fittedWidth:ui,fittedHeight:mn,groupScaleX:yi,groupScaleY:Fn,showHighlight:!!(Be.showHighlight&&Ji&&on&&!on.behindCamera)};ri.set(Oe.id,zt),on&&!on.behindCamera&&wt.set(Be.targetId,ht(ht({},on.bounds),{visible:_i,behindCamera:!1,offscreen:ei,clippedFraction:Number(gi.toFixed(3))}))}}catch(Vi){U={error:Vi}}finally{try{Jt&&!Jt.done&&(R=Xt.return)&&R.call(Xt)}finally{if(U)throw U.error}}}}}function qg(c){var y,w,T,b,U;if(!(!c?.showHighlight||!c.targetBounds)){var R=c.targetBounds,H=c.config,O=(y=H.paddingPx)!==null&&y!==void 0?y:10,Z=(w=H.minSizePx)!==null&&w!==void 0?w:48,B=(T=H.maxSizePx)!==null&&T!==void 0?T:260,V=Math.max(Z,Math.min(B,R.width+O*2)),z=Math.max(Z,Math.min(B,R.height+O*2));if(H.squareBounds){var j=Math.max(V,z);V=j,z=j}var K=R.centerX,ee=R.centerY,ue=(b=H.highlightStyle)!==null&&b!==void 0?b:"pulse-ring",_e=(U=H.highlightColor)!==null&&U!==void 0?U:"#fff0bd",ve=ue==="pulse-ring"&&!W?.matches?Math.sin(Ye*4.2):0,Ae=ue==="pulse-ring"&&!W?.matches?Ye*.9%1:0;if(p.save(),ue==="box"){var fe=V/2,pe=z/2,Re=K-fe,de=ee-pe,Fe=K+fe,Be=ee+pe,Oe=Math.max(8,Math.min(18,Math.min(V,z)*.28)),Xe=function(Tt,Ct){p.strokeStyle=Tt,p.lineWidth=Ct,p.lineCap="round",p.lineJoin="round",p.beginPath(),p.moveTo(Re,de+Oe),p.lineTo(Re,de),p.lineTo(Re+Oe,de),p.moveTo(Fe-Oe,de),p.lineTo(Fe,de),p.lineTo(Fe,de+Oe),p.moveTo(Fe,Be-Oe),p.lineTo(Fe,Be),p.lineTo(Fe-Oe,Be),p.moveTo(Re+Oe,Be),p.lineTo(Re,Be),p.lineTo(Re,Be-Oe),p.stroke()};Xe("#00000066",6),Xe(_e,3)}else{var vt=Math.max(22,V/2*(1+ve*.035)),Pt=Math.max(22,z/2*(1+ve*.035));ue==="pulse-ring"&&!W?.matches&&(p.save(),p.globalAlpha*=.48*(1-Ae),p.strokeStyle=_e,p.lineWidth=2.5,p.beginPath(),p.ellipse(K,ee,vt*(1+Ae*.18),Pt*(1+Ae*.18),0,0,Math.PI*2),p.stroke(),p.restore()),p.save(),p.globalAlpha*=.1,p.fillStyle=_e,p.beginPath(),p.ellipse(K,ee,vt,Pt,0,0,Math.PI*2),p.fill(),p.restore(),p.strokeStyle="#00000066",p.lineWidth=5.5,p.beginPath(),p.ellipse(K,ee,vt,Pt,0,0,Math.PI*2),p.stroke(),p.strokeStyle=_e,p.lineWidth=3,p.beginPath(),p.ellipse(K,ee,vt,Pt,0,0,Math.PI*2),p.stroke()}p.restore()}}function kf(c){var y,w,T,b,U,R;if(!Zt)return null;var H=nt(c);if(!H||H.contract!=="native.mesh3d.v1")return null;var O=Ma(H);if(!O)return null;var Z=Zt.getStage(O);if(!Z||!Z.lastWidth||!Z.lastHeight)return null;var B=(y=Z.projectNodeBounds)===null||y===void 0?void 0:y.call(Z,H.id,Z.lastWidth,Z.lastHeight);if(B&&!B.behindCamera){var V=(T=(w=B.anchors)===null||w===void 0?void 0:w.center)!==null&&T!==void 0?T:{x:B.centerX,y:B.centerY};return Z.isFullBleed?{x:Z.lastX+V.x,y:Z.lastY+V.y}:oi(ci(O),V.x,V.y)}var z=sn.get(H.id),j=tn(H),K=Z.project({x:z?z.x:(b=j.x)!==null&&b!==void 0?b:0,y:z?z.y:(U=j.y)!==null&&U!==void 0?U:0,z:z?z.z:(R=j.z)!==null&&R!==void 0?R:0},Z.lastWidth,Z.lastHeight);return Z.isFullBleed?{x:Z.lastX+K.x,y:Z.lastY+K.y}:oi(ci(O),K.x,K.y)}function sm(){if(!Dt||!Zt)return{vx:0,vz:0,power:0,pull:0};var c=L.get(Dt.stageId),y=Zt.getStage(c),w=sn.get(Dt.targetId),T=Dt.behavior.parameters;if(!y||!w||!y.lastWidth||!y.lastHeight)return{vx:0,vz:0,power:0,pull:0};var b,U;if(y.isFullBleed)b={x:Dt.start.x-y.lastX,y:Dt.start.y-y.lastY},U={x:Dt.current.x-y.lastX,y:Dt.current.y-y.lastY};else{var R=Or(ci(c));b=oi(R,Dt.start.x,Dt.start.y),U=oi(R,Dt.current.x,Dt.current.y)}var H=Math.hypot(Dt.current.x-Dt.start.x,Dt.current.y-Dt.start.y),O=y.unproject(b.x,b.y,y.lastWidth,y.lastHeight,w.y),Z=y.unproject(U.x,U.y,y.lastWidth,y.lastHeight,w.y);if(!O||!Z)return{vx:0,vz:0,power:0,pull:H};var B=(O.x-Z.x)*T.dragScale,V=(O.z-Z.z)*T.dragScale,z=Math.hypot(B,V);return z>T.maxSpeed&&(B*=T.maxSpeed/z,V*=T.maxSpeed/z),{vx:B,vz:V,power:Math.min(1,Math.hypot(B,V)/Math.max(.001,T.maxSpeed)),pull:H}}function om(c){if(!(!Dt||!Zt)){Dt.current=c;var y=sm(),w=Dt.behavior.parameters;Dt.power=y.power,w.powerVariableId&&($[w.powerVariableId]=y.power);var T=L.get(Dt.stageId),b=Zt.getStage(T),U=sn.get(Dt.targetId);if(b&&U&&w.showTrajectory&&y.pull>=w.minPullPx){var R=Ra(),H=R.walls,O=R.zones;b.setGuide(lv({body:U,walls:H,zones:O,vx:y.vx,vz:y.vz,dots:w.trajectoryDots}))}else b?.setGuide([])}}function Zg(){return{bodies:$e([],Ue(sn.values()),!1).map(function(c){return{id:c.id,sourceId:c.sourceId,x:c.x,y:c.y,z:c.z,vx:c.vx,vy:c.vy,vz:c.vz,atRest:!!c.atRest,captured:!!c.captured,airborne:!!c.airborne}}),aiming:Dt?{componentId:Dt.sourceId,pointerId:Dt.pointerId,power:Dt.power}:null,projected:Object.fromEntries(In),projectedBounds:Object.fromEntries(wt),fps:Object.fromEntries($e([],Ue(xn),!1).map(function(c){var y=Ue(c,2),w=y[0],T=y[1];return[w,{x:T.x,y:T.y,z:T.z,yaw:T.yaw,pitch:T.pitch}]}))}}function Ul(){be=void 0,Xn=void 0,jn(),et.clear(),dn.clear(),ii.clear(),si.clear(),A.reset(),ae.clear(),we.clear(),qt=[],Qt=[],me.clear(),Me.clear(),M.clear(),Ne=[],Pe=[],it=void 0,Rt=0,Mt=!1,ct=0,$=Object.fromEntries(n.variables.map(function(c){return[c.id,c.initial]})),Cn(),bn=0,Ke.clear(),We.clear(),wn.clear(),Bn.clear(),sn.clear(),Mn.clear(),In.clear(),wt.clear(),ri.clear(),xn.clear(),Ro=0,Zt?.reset(),fn.clear(),En.clear(),Ge=void 0,Te=[],Le=[],se=[],Ee.clear(),Qs(),gt.clear(),Ie.clear(),ke.clear(),re=[],xe=0,Ye=0,mt=0,Vt=!1,He=0,oe=n.base.startScene,gn=void 0,Q=void 0,Tn=void 0,ie=void 0,f||(Df(),nu(),Pl(),Ra(),Es(),Io(0,!1),Hf(),Ll(0),Un({kind:"sceneEnter",sceneId:oe}))}function zf(){var c,y;if(!(!Ze||Ze.state!=="running"||!rt.size)){var w=$e([],Ue(rt.values()),!1);rt.clear();try{for(var T=ze(w),b=T.next();!b.done;b=T.next()){var U=b.value;cm(U)}}catch(R){c={error:R}}finally{try{b&&!b.done&&(y=T.return)&&y.call(T)}finally{if(c)throw c.error}}}}function Po(c){if(c===void 0&&(c=!1),!Ze)return Promise.resolve(void 0);if(Ze.state==="running")return Promise.resolve().then(zf),Promise.resolve(Ze);if(!pn||c){var y=Ze,w=Promise.resolve().then(function(){return y.resume()}).then(function(){if(y.state==="running")return zf(),y}).catch(function(){}).finally(function(){pn===w&&(pn=void 0)});pn=w}return pn}function Vf(){var c,y,w=$e([],Ue(Ut.values()),!1),T=w.some(function(B){return B.bus==="voice"}),b=w.some(function(B){return B.bus==="stinger"}),U=b?.2:T?.25:1;try{for(var R=ze(w),H=R.next();!H.done;H=R.next()){var O=H.value,Z=O.volume*$n*(O.bus==="music"?U:1);O.gain.gain.setTargetAtTime?O.gain.gain.setTargetAtTime(Z,Ze.currentTime,.04):O.gain.gain.value=Z}}catch(B){c={error:B}}finally{try{H&&!H.done&&(y=R.return)&&y.call(R)}finally{if(c)throw c.error}}}function Jg(c,y){if(!y||typeof c.createBuffer!="function"||typeof y.getChannelData!="function"||!y.numberOfChannels)return y;var w=y.sampleRate||44100,T=y.length;if(T<Math.round(w*.2))return y;for(var b=y.numberOfChannels,U=.002,R=T,H=0,O=0;O<b;O++){for(var Z=y.getChannelData(O),B=0;B<R;B++)if(Math.abs(Z[B])>U){R=B;break}for(var B=T-1;B>H;B--)if(Math.abs(Z[B])>U){H=B;break}}if(R>=H)return y;var V=H-R+1;if(V<Math.round(w*.15))return y;var z=Math.min(Math.round(w*.06),Math.floor(V*.1)),j=V-z;if(z<8||j<Math.round(w*.1))return y;for(var K=c.createBuffer(b,j,w),O=0;O<b;O++){for(var ee=y.getChannelData(O),ue=K.getChannelData(O),B=0;B<z;B++){var _e=B/z;ue[B]=ee[R+B]*Math.sin(_e*Math.PI*.5)+ee[R+j+B]*Math.cos(_e*Math.PI*.5)}for(var B=z;B<j;B++)ue[B]=ee[R+B]}return K}function lm(c,y,w){var T,b=(T=w.parameters.bus)!==null&&T!==void 0?T:"sfx";c.connect(y),y.connect(Ze.destination),Wt.add(c),Ut.set(c,{gain:y,bus:b,volume:w.parameters.volume}),c.onended=function(){Wt.delete(c),Ut.delete(c),w.parameters.loop&&Et.delete(w.id),Vf()},Vf()}function cm(c){return b1(this,void 0,void 0,function(){var y,w,T,b,U,R,H,O,Z,B,V,z,j,K,ee,ue,_e,ve,Ae,fe,pe,Re,de,Fe,Be,Oe,Xe,vt,Pt,Tt,Ct,kt;return w1(this,function(At){switch(At.label){case 0:return Wt.size>=32?[2]:(y=!!c.parameters.loop,Ze?(w=Ze,T=yn,b=(Oe=c.parameters.cooldownMs)!==null&&Oe!==void 0?Oe:45,U=w.currentTime,b>0&&U-((Xe=an.get(c.id))!==null&&Xe!==void 0?Xe:-1/0)<b/1e3?[2]:y&&Et.has(c.id)?[2]:(R=L.get(c.componentId),H=E.get((vt=R?.assetSlots[0])===null||vt===void 0?void 0:vt.assetId),O=H?.mime==="audio/wav"||H?.mime==="audio/mpeg",!O&&c.parameters.allowSynthFallback===!1?(bn++,[2]):(an.set(c.id,U),Z=w.state!=="running",Z?[4,Po()]:[3,2]))):(y&&rt.set(c.id,c),[2]));case 1:Z=!At.sent(),At.label=2;case 2:if(Z)return y&&rt.set(c.id,c),[2];if(Ze!==w||w.state!=="running"||T!==yn||Wt.size>=32)return[2];if(B=(Pt=hn.get(c.id))!==null&&Pt!==void 0?Pt:0,V=[0,-.5,.5,-1,1],z=((Tt=c.parameters.pitchJitter)!==null&&Tt!==void 0?Tt:0)*V[B%V.length],j=Number((Ct=$[c.parameters.pitchVariableId])!==null&&Ct!==void 0?Ct:0),K=Math.max(-12,Math.min(12,z+j*((kt=c.parameters.pitchStep)!==null&&kt!==void 0?kt:0))),ee=Math.pow(2,K/12),hn.set(c.id,B+1),!O)return[3,8];y&&Et.add(c.id),At.label=3;case 3:if(At.trys.push([3,6,,7]),ue=Lt.get(H.hash),ue)return[3,5];for(_e=atob(H.data),ve=new Uint8Array(_e.length),Ae=0;Ae<_e.length;Ae++)ve[Ae]=_e.charCodeAt(Ae);return[4,new Promise(function(_t,St){var bt=w.decodeAudioData(ve.buffer,_t,St);bt&&typeof bt.then=="function"&&bt.then(_t,St)})];case 4:ue=At.sent(),Lt.set(H.hash,ue),At.label=5;case 5:return Ze!==w||w.state!=="running"||T!==yn||Wt.size>=32?(y&&T===yn&&Et.delete(c.id),[2]):(fe=ue,y&&(fe=yt.get(H.hash),fe||(fe=Jg(w,ue),yt.set(H.hash,fe))),pe=w.createBufferSource(),Re=w.createGain(),pe.buffer=fe,pe.loop=y,pe.playbackRate&&(pe.playbackRate.value=ee),y&&Re.gain.setValueAtTime&&Re.gain.linearRampToValueAtTime?(Re.gain.setValueAtTime(1e-4,w.currentTime),Re.gain.linearRampToValueAtTime(c.parameters.volume,w.currentTime+.025)):Re.gain.value=c.parameters.volume,lm(pe,Re,c),pe.start(),[3,7]);case 6:return de=At.sent(),Et.delete(c.id),Zi("Audio decode failed"),[3,7];case 7:return[2];case 8:return Fe=w.createOscillator(),Be=w.createGain(),Fe.frequency.value=c.parameters.frequency*ee,Fe.type="sine",Be.gain.setValueAtTime(c.parameters.volume,w.currentTime),Be.gain.exponentialRampToValueAtTime(.001,w.currentTime+c.parameters.seconds),lm(Fe,Be,c),Fe.start(),Fe.stop(w.currentTime+c.parameters.seconds),[2]}})})}function $g(c,y){for(var w=$e([],Ue(Ht.values()),!1).filter(function(B){return B.boardId===c}),T=function(B,V){var z;return(z=w.find(function(j){return j.row===B&&j.column===V}))===null||z===void 0?void 0:z.group},b=function(B){for(var V=function(K){var ee=T(B,K);if(ee&&ee===T(B,K+1)&&ee===T(B,K+2)&&y.some(function(ue){return ue.row===B&&ue.column>=K&&ue.column<=K+2}))return{value:!0}},z=0;z<14;z++){var j=V(z);if(typeof j=="object")return j}},U=0;U<16;U++){var R=b(U);if(typeof R=="object")return R.value}for(var H=function(B){for(var V=function(K){var ee=T(K,B);if(ee&&ee===T(K+1,B)&&ee===T(K+2,B)&&y.some(function(ue){return ue.column===B&&ue.row>=K&&ue.row<=K+2}))return{value:!0}},z=0;z<14;z++){var j=V(z);if(typeof j=="object")return j}},O=0;O<16;O++){var Z=H(O);if(typeof Z=="object")return Z.value}return!1}function Kg(c){var y,w,T,b=Ht.get(c.id);if(!(!b||b.sceneId!==oe||!tn(c).enabled||!Ti(c))){var U=Nn.get(c.parentId);if(U){Yt=U.select(c.id);return}if(Yt===c.id){Yt=void 0;return}var R=Ht.get(Yt);if(!R||R.sceneId!==oe||R.boardId!==b.boardId){Yt=c.id;return}var H=L.get(Yt);if(Math.abs(R.row-b.row)+Math.abs(R.column-b.column)!==1){Yt=c.id;return}if(R.group===b.group){Yt=void 0,Un({kind:"invalidMatch",componentId:(y=c.parentId)!==null&&y!==void 0?y:c.id});return}var O=R.row,Z=R.column,B=b.row,V=b.column,z=$e([],Ue(Qi(H)),!1),j=$e([],Ue(Qi(c)),!1);if(R.row=B,R.column=V,b.row=O,b.column=Z,$g(b.boardId,[R,b])){var K=function(ee,ue){var _e,ve=(_e=Ee.get(ee.id))!==null&&_e!==void 0?_e:{transform:$e([],Ue(Qi(ee)),!1),parameters:{}};ve.transform=$e([],Ue(ve.transform),!1),ve.transform[4]=ue[4],ve.transform[5]=ue[5],Ee.set(ee.id,ve)};K(H,j),K(c,z),Yt=void 0,Un({kind:"validMatch",componentId:(w=c.parentId)!==null&&w!==void 0?w:c.id})}else R.row=O,R.column=Z,b.row=B,b.column=V,Yt=void 0,Un({kind:"invalidMatch",componentId:(T=c.parentId)!==null&&T!==void 0?T:c.id})}}function Gf(c){var y,w,T,b,U=[],R=lr(c,ci(c)),H=ki(c),O=Vn("drag",(T=c.prototypeId)!==null&&T!==void 0?T:c.id),Z=function(j){var K,ee,ue=L.get(j.componentId),_e=j.parameters;if(ue.sceneId!==oe)return"continue";var ve=function(Re){if(Re.id===c.id||qr(Re,c.id)||!Ti(Re))return"continue";var de=lr(Re,ci(Re)),Fe=ki(Re),Be=Math.hypot(Fe.x-H.x,Fe.y-H.y),Oe=_e.radiusPx>0?Be<=_e.radiusPx:R.left<de.right&&R.right>de.left&&R.top<de.bottom&&R.bottom>de.top;if(!Oe)return"continue";U.push(ht({id:Re.id,c:Re,sourceId:ue.id,paintOrder:Je.findIndex(function(Xe){return Xe.c.id===Re.id}),distance:Be,itemTarget:n.gameplay.some(function(Xe){return Xe.kind==="drag"&&Xe.componentId===ue.id})},_e))};try{for(var Ae=(K=void 0,ze(Bi(ue))),fe=Ae.next();!fe.done;fe=Ae.next()){var pe=fe.value;ve(pe)}}catch(Re){K={error:Re}}finally{try{fe&&!fe.done&&(ee=Ae.return)&&ee.call(Ae)}finally{if(K)throw K.error}}};try{for(var B=ze(n.gameplay.filter(function(j){return j.kind==="drop-zone"})),V=B.next();!V.done;V=B.next()){var z=V.value;Z(z)}}catch(j){y={error:j}}finally{try{V&&!V.done&&(w=B.return)&&w.call(B)}finally{if(y)throw y.error}}return{zones:U,tag:(b=O?.parameters.tag)!==null&&b!==void 0?b:""}}function Hf(c){var y,w,T=c?[c]:n.gameplay.filter(function(V){return V.kind==="drag"}).flatMap(function(V){return Bi(L.get(V.componentId))});try{for(var b=ze(T),U=b.next();!U.done;U=b.next()){var R=U.value;if(!(!R||!Ti(R)||dn.zoneOf(R.id))){var H=Gf(R),O=H.zones,Z=H.tag,B=xu({itemId:R.id,tag:Z,zones:O.filter(function(V){return!V.itemTarget}),occupancy:dn});B?.kind==="accept"&&dn.place(R.id,B.zone.id)}}}catch(V){y={error:V}}finally{try{U&&!U.done&&(w=b.return)&&w.call(b)}finally{if(y)throw y.error}}}function eo(c,y,w){w===void 0&&(w=.18),c&&di.to(c.id,ki(c),y,w)}function Wf(c,y,w,T){var b,U,R=T??w?.c;Un(ht(ht({},or(c,y,R,ht({},w?{otherId:w.sourceId}:{}))),{instanceId:(b=y.instanceId)!==null&&b!==void 0?b:(U=w?.c)===null||U===void 0?void 0:U.instanceId}))}function Qg(c){var y,w,T,b,U,R,H;if(!ne||ne.pointerId!==c.pointerId)return!1;var O=ne,Z=nt(O.targetId),B=O.b.parameters;ne=void 0,It=void 0;try{!((y=e.hasPointerCapture)===null||y===void 0)&&y.call(e,c.pointerId)&&((w=e.releasePointerCapture)===null||w===void 0||w.call(e,c.pointerId))}catch{}if(!Z)return!0;var V=Gf(Z),z=V.zones,j=V.tag,K=xu({itemId:Z.id,tag:j,zones:z,occupancy:dn}),ee=O.origin,ue=O.originZone;if(!K)return Wf("dragReject",Z,void 0,void 0),B.snapBack&&(ue&&dn.place(Z.id,ue),eo(Z,ee,(T=B.snapBackSeconds)!==null&&T!==void 0?T:.18)),!0;var _e=K.zone,ve=K.occupantId?nt(K.occupantId):void 0;return K.kind==="reject"?(Wf("dragReject",Z,_e,ve),B.snapBack&&(ue&&dn.place(Z.id,ue),eo(Z,ee,(b=B.snapBackSeconds)!==null&&b!==void 0?b:.18)),!0):(K.kind==="accept"?(dn.place(Z.id,_e.id),_e.snapMode==="center"&&eo(Z,ki(_e.c),(U=B.snapBackSeconds)!==null&&U!==void 0?U:.18)):K.kind==="swap"&&ve&&(dn.place(Z.id,_e.id),ue?dn.place(ve.id,ue):dn.release(ve.id),eo(Z,ki(_e.c),(R=B.snapBackSeconds)!==null&&R!==void 0?R:.18),eo(ve,ee,(H=B.snapBackSeconds)!==null&&H!==void 0?H:.18)),Wf("dragDrop",Z,_e,K.kind==="accept"?_e.c:ve),!0)}function jg(c){var y,w,T,b,U;di.tick(c,function(K,ee){var ue=nt(K);ue&&Xr(ue,ee.x,ee.y)});try{for(var R=ze($e([],Ue(dn.itemZone.keys()),!1)),H=R.next();!H.done;H=R.next()){var O=H.value,Z=nt(O);(!Z||!Ti(Z))&&dn.release(O)}}catch(K){y={error:K}}finally{try{H&&!H.done&&(w=R.return)&&w.call(R)}finally{if(y)throw y.error}}if(lt)try{for(var B=ze(lt.holds),V=B.next();!V.done;V=B.next()){var z=V.value,j=z.charge.tick(c);j!==$[z.behavior.parameters.variableId]&&($[z.behavior.parameters.variableId]=j,Un({kind:"variableChange",variableId:z.behavior.parameters.variableId,instanceId:z.c.instanceId,selfInstanceId:(U=z.c.instanceId)!==null&&U!==void 0?U:z.c.id}))}}catch(K){T={error:K}}finally{try{V&&!V.done&&(b=B.return)&&b.call(B)}finally{if(T)throw T.error}}}function um(c,y){var w,T,b,U,R=y.targetMode;if(R==="pointer")return ht({},Ft);if(R==="component"){var H=nt(y.targetComponentId);return H?ki(H):void 0}if(R==="nearest-team"){var O=ki(c),Z=[],B=y.team,V=(b=y.maxRangePx)!==null&&b!==void 0?b:0;try{for(var z=ze(A.states),j=z.next();!j.done;j=z.next()){var K=Ue(j.value,2),ee=K[0],ue=K[1],H=nt(ee);H&&Ti(H)&&Z.push(ht(ht({id:ee},ki(H)),{team:ue.team}))}}catch(_e){w={error:_e}}finally{try{j&&!j.done&&(T=z.return)&&T.call(z)}finally{if(w)throw w.error}}return Wm(O,Z,B,V,(U=c.instanceId)!==null&&U!==void 0?U:c.id)}}function ey(c){var y,w,T,b,U;try{for(var R=ze(n.gameplay.filter(function(pe){return pe.kind==="steer"})),H=R.next();!H.done;H=R.next()){var O=H.value,Z=L.get(O.componentId),B=O.parameters;if(Z.sceneId===oe)try{for(var V=(T=void 0,ze(Bi(Z))),z=V.next();!z.done;z=V.next()){var j=z.value;if(Ti(j)){var K=um(j,B);if(K){var ee=ki(j),ue=K.x-ee.x,_e=K.y-ee.y;if(!(B.maxRangePx>0&&Math.hypot(ue,_e)>B.maxRangePx)){var ve=Math.atan2(_e,ue);B.mode==="flee"?ve+=Math.PI:B.mode==="orbit"&&(ve+=Math.PI/2);var Ae=(U=A.headings.get(j.id))!==null&&U!==void 0?U:ve,fe=Xm(Ae,ve,B.turnRateDegPerSec*Math.PI/180*c);A.headings.set(j.id,fe),Xr(j,ee.x+Math.cos(fe)*B.speed*c,ee.y+Math.sin(fe)*B.speed*c),B.orientToVelocity!==!1&&cs(j,fe)}}}}}catch(pe){T={error:pe}}finally{try{z&&!z.done&&(b=V.return)&&b.call(V)}finally{if(T)throw T.error}}}}catch(pe){y={error:pe}}finally{try{H&&!H.done&&(w=R.return)&&w.call(R)}finally{if(y)throw y.error}}}function Xf(c,y,w,T){var b;if(Te.length>=128){Zi("Instance budget exhausted");return}var U=L.get(c),R=function(B){return 1+n.components.filter(function(V){return V.parentId===B}).reduce(function(V,z){return V+R(z.id)},0)};if(Ke.size+R(U.id)>4096){Zi("Runtime node budget exhausted");return}var H="instance."+ ++mt;function O(B,V){var z,j,K=B.id===U.id?H:H+":"+B.id,ee=ht(ht({},B),{id:K,runtimeId:K,instanceId:H,prototypeId:B.id,prototype:!1,parentId:V,transform:$e([],Ue(B.transform),!1),spawnTime:xe});Ke.set(K,ee);try{for(var ue=ze(n.components.filter(function(Ae){return Ae.parentId===B.id})),_e=ue.next();!_e.done;_e=ue.next()){var ve=_e.value;O(ve,K)}}catch(Ae){z={error:Ae}}finally{try{_e&&!_e.done&&(j=ue.return)&&j.call(ue)}finally{if(z)throw z.error}}return ee}var Z=O(U,void 0);return Z.transform[4]=y,Z.transform[5]=w,T&&(Z.pathStartNode=T.startNode,Z.pathTargetNode=T.targetNode,Z.parentId=(b=n.gameplay.find(function(B){return B.id===T.networkBehaviorId}))===null||b===void 0?void 0:b.componentId),Te.push(Z),Eo(Z),Hf(Z),T&&Io(0,!1),Z}function ty(c,y,w){var T,b,U,R,H,O,Z,B,V,z,j,K,ee,ue,_e,ve,Ae,fe,pe,Re,de,Fe,Be,Oe,Xe,vt,Pt,Tt,Ct,kt,At,_t,St,bt,Ve;if(++ot>1024){Zi("Action budget exhausted");return}if(c.kind==="add"||c.kind==="set"){var tt=$[c.variableId],xt=c.kind==="add"?tt+c.value:c.value;if(typeof xt=="number"&&(!Number.isFinite(xt)||Math.abs(xt)>1e12)){Zi("Variable range exceeded");return}$[c.variableId]=xt,tt!==xt&&Un({kind:"variableChange",variableId:c.variableId,instanceId:y.instanceId})}else if(c.kind==="setAsset"&&((V=nt(c.componentId))===null||V===void 0?void 0:V.contract)==="native.mesh3d.v1"){var Qe=nt(c.componentId),zt=(z=Ee.get(Qe.id))!==null&&z!==void 0?z:{transform:$e([],Ue(Qe.transform),!1),parameters:{}};((j=zt.slots)!==null&&j!==void 0?j:zt.slots={})[(K=c.slotId)!==null&&K!==void 0?K:"source"]=c.assetId,Ee.set(Qe.id,zt)}else if(c.kind==="setComponent"||c.kind==="setAsset"){var Qe=nt(c.componentId);if(!Qe)return;var zt=(ee=Ee.get(Qe.id))!==null&&ee!==void 0?ee:{transform:$e([],Ue(Qe.transform),!1),parameters:{}};c.kind==="setComponent"?zt.parameters[c.key]=c.valueVariableId?$[c.valueVariableId]:c.value:zt.assetId=c.assetId,Ee.set(Qe.id,zt),c.kind==="setComponent"&&c.key==="visible"&&c.value===!1&&(dn.release(Qe.id),di.cancel(Qe.id))}else if(c.kind==="resetMatch")Qs(c.componentId),nu(c.componentId);else if(c.kind==="clearStrokes")(ue=we.get(c.componentId))===null||ue===void 0||ue.clear(),qt=qt.filter(function(nr){return nr.owner!==c.componentId});else if(c.kind==="resetMask"){var Qe=nt(c.componentId),jt=Vn("erase-mask",c.componentId);Qe&&jt&&Ts(Qe,jt).reset()}else if(c.kind==="raycast3d")Bf(c);else if(c.kind==="spawnAt3d")Of(c);else if(c.kind==="playModelAnimation")Zt?.playModelAnimation(c.componentId,c);else if(c.kind==="copyMatchAsset"){var Sn=(_e=Nn.get(c.boardId))===null||_e===void 0?void 0:_e.snapshot().lastMatch,Xt=L.get(c.componentId),Jt=Sn&&((Ae=(ve=ni.get(c.boardId))===null||ve===void 0?void 0:ve.get(Sn.group))===null||Ae===void 0?void 0:Ae.children.find(function(nr){return nr.contract==="native.image.v1"}));if(Sn&&Jt){var ft=L.get(Sn.from),st=oi(ci(ft),ft.parameters.width/2,ft.parameters.height/2),Dn=Xt.parentId?ci(L.get(Xt.parentId)):Na(),Ni=oi(Or(Dn),st.x,st.y),_i=(fe=Ee.get(Xt.id))!==null&&fe!==void 0?fe:{transform:$e([],Ue(Xt.transform),!1),parameters:{}};_i.transform=$e([],Ue(_i.transform),!1),_i.transform[4]=Ni.x-Xt.parameters.width/2,_i.transform[5]=Ni.y-Xt.parameters.height/2,_i.assetId=(pe=Jt.assetSlots[0])===null||pe===void 0?void 0:pe.assetId,Ee.set(Xt.id,_i)}}else if(c.kind==="hintMatch")Yt=void 0,(Re=Nn.get(c.componentId))===null||Re===void 0||Re.showHint();else if(c.kind==="spawn")Xf(c.prototypeId,c.x,c.y);else if(c.kind==="spawnAt"){var on=(c.at==="self"||c.at==="midpoint")&&(y.selfInstanceId!==void 0||y.instanceId!==void 0)?nt((de=y.selfInstanceId)!==null&&de!==void 0?de:y.instanceId):ls(c.targetComponentId,y,"self"),Qn=(c.at==="other"||c.at==="midpoint")&&y.otherInstanceId!==void 0?nt(y.otherInstanceId):void 0,Xt=c.at==="other"?Qn:on;if(c.at==="pointer"||(c.at==="midpoint"?on&&Qn:Xt))for(var gi=on?ki(on):void 0,ei=Qn?ki(Qn):void 0,st=c.at==="pointer"?Ft:c.at==="midpoint"?{x:(gi.x+ei.x)/2,y:(gi.y+ei.y)/2}:ki(Xt),An=L.get(c.prototypeId),Hi=Math.max(0,Math.min(16,Math.floor(c.countVariableId?Number($[c.countVariableId]):(Fe=c.count)!==null&&Fe!==void 0?Fe:1))),_r=0;_r<Hi;_r++){var Mr=c.jitterX?(A.rng.next()*2-1)*c.jitterX:0,Gi=c.jitterY?(A.rng.next()*2-1)*c.jitterY:0;Xf(c.prototypeId,st.x+c.offsetX+Mr-An.parameters.width/2,st.y+c.offsetY+Gi-An.parameters.height/2)}}else if(c.kind==="random"){var tt=$[c.variableId],xt=A.rng.between(c.min,c.max,c.integer===!0);$[c.variableId]=xt,tt!==xt&&Un({kind:"variableChange",variableId:c.variableId,instanceId:y.instanceId})}else if(c.kind==="modifyInstanceState"){var Qe=c.target==="component"?nt(c.componentId):ls(c.componentId,y,c.target);Qe&&Ao(Qe,c.field,c.op,c.variableId?$[c.variableId]:c.value)}else if(c.kind==="launchToward"){var ft=L.get(c.componentId),Zn=Bi(ft),ui=(Be=y.selfInstanceId)!==null&&Be!==void 0?Be:y.instanceId,Qe=ft.prototype?(Oe=Zn.find(function(er){return er.instanceId===ui||er.id===ui}))!==null&&Oe!==void 0?Oe:Zn[Zn.length-1]:(Xe=ls(c.componentId,y,"self"))!==null&&Xe!==void 0?Xe:nt(c.componentId),jt=Vn("physics-body",c.componentId),mn=Qe&&Ca(Qe,jt);if(!mn)return;var yi=void 0;if(c.targetMode==="angle-variable")yi=Number($[c.angleVariableId])*Math.PI/180;else{var Xt=um(Qe,c);if(!Xt)return;var st=ki(Qe);yi=Math.atan2(Xt.y-st.y,Xt.x-st.x)}var Fn=Number(c.speedVariableId?$[c.speedVariableId]:c.speed);if(!Number.isFinite(Fn)){Zi("Launch speed invalid");return}mn.vx=Math.cos(yi)*Fn,mn.vy=Math.sin(yi)*Fn,mn.atRest=!1,mn.restElapsed=0,mn.captured=!1,mn.exited=!1,c.orientToVelocity!==!1&&cs(Qe,yi),Un(or("launch",Qe))}else if(c.kind==="moveToComponent"){var Mi=L.get(c.targetComponentId),Qe=ls(c.componentId,y,(vt=c.target)!==null&&vt!==void 0?vt:"self"),Xt=Mi&&Ha(Mi)?(Pt=ls(c.targetComponentId,y,c.target==="other"?"self":"other"))!==null&&Pt!==void 0?Pt:Bi(Mi)[0]:nt(c.targetComponentId);Qe&&Xt&&eo(Qe,ki(Xt),c.seconds)}else if(c.kind==="returnToOrigin"){var Qe=ls(c.componentId,y,"self"),un=Qe&&ii.get(Qe.id);Qe&&un&&eo(Qe,un,c.seconds)}else if(c.kind==="spawnOnPath")Xf(c.prototypeId,0,0,{startNode:c.startNode,targetNode:c.targetNode,networkBehaviorId:c.networkBehaviorId});else if(["setVelocity","applyImpulse","stopBody"].includes(c.kind)){var Yn=L.get(c.componentId),Ei=y.instanceId?$e([],Ue(Ke.values()),!1).filter(function(Si){return Si.instanceId===y.instanceId&&Si.prototypeId===Yn.id}):Bi(Yn),jt=Vn("physics-body",Yn.id);try{for(var Sr=ze(Ei),Rr=Sr.next();!Rr.done;Rr=Sr.next()){var Qe=Rr.value,mn=Ca(Qe,jt);c.kind==="setVelocity"?(mn.vx=c.vxVariableId?$[c.vxVariableId]:c.vx,mn.vy=c.vyVariableId?$[c.vyVariableId]:c.vy):c.kind==="applyImpulse"?(mn.vx+=c.vxVariableId?$[c.vxVariableId]:c.ix,mn.vy+=c.vyVariableId?$[c.vyVariableId]:c.iy):(mn.vx=0,mn.vy=0,mn.atRest=!0),mn.captured=!1,mn.exited=!1,mn.restElapsed=0,c.kind!=="stopBody"&&(mn.atRest=!1)}}catch(Si){T={error:Si}}finally{try{Rr&&!Rr.done&&(b=Sr.return)&&b.call(Sr)}finally{if(T)throw T.error}}}else if(c.kind==="setPosition"){var Dr=L.get(c.componentId),Ei=y.instanceId?$e([],Ue(Ke.values()),!1).filter(function(ir){return ir.instanceId===y.instanceId&&ir.prototypeId===Dr.id}):Bi(Dr),jt=Vn("physics-body",Dr.id);try{for(var Sa=ze(Ei),cr=Sa.next();!cr.done;cr=Sa.next()){var Qe=cr.value,mn=Ca(Qe,jt);mn.x=c.xVariableId?$[c.xVariableId]:c.x,mn.y=c.yVariableId?$[c.yVariableId]:c.y,mn.vx=0,mn.vy=0,mn.captured=!1,mn.exited=!1,mn.atRest=!0,Xr(Qe,mn.x,mn.y)}}catch(ir){U={error:ir}}finally{try{cr&&!cr.done&&(R=Sa.return)&&R.call(Sa)}finally{if(U)throw U.error}}}else if(c.kind==="setPathEdge")(Tt=Pn.get(c.behaviorId))===null||Tt===void 0||Tt.setEdge(c.edgeId,c.enabled,c.cost);else if(c.kind==="setPathGate")(kt=Pn.get((Ct=n.gameplay.find(function(nr){return nr.id===c.behaviorId}))===null||Ct===void 0?void 0:Ct.parameters.networkBehaviorId))===null||kt===void 0||kt.setGate(c.behaviorId,c.mode,c.holdSeconds);else if(c.kind==="setPathTarget"){var Zr=L.get(c.componentId),jt=Vn("path-agent",Zr.id),Jr=Pn.get(jt.parameters.networkBehaviorId);try{for(var Nr=ze(y.instanceId?$e([],Ue(Ke.values()),!1).filter(function(Si){return Si.instanceId===y.instanceId&&Si.prototypeId===Zr.id}):Bi(Zr)),$r=Nr.next();!$r.done;$r=Nr.next()){var Qe=$r.value;Qe.pathTargetNode=c.targetNode,Jr?.setTarget(Qe.id,c.targetNode)}}catch(Si){H={error:Si}}finally{try{$r&&!$r.done&&(O=Nr.return)&&O.call(Nr)}finally{if(H)throw H.error}}}else if(c.kind==="compute"){var zi=Number($[c.variableId]),Ji=c.operandVariableId!==void 0?Number($[c.operandVariableId]):c.value;if(["div","mod"].includes(c.op)&&Ji===0){Zi("Division by zero");return}var xt={add:function(){return zi+Ji},sub:function(){return zi-Ji},mul:function(){return zi*Ji},div:function(){return Ji===0?zi:zi/Ji},mod:function(){return Ji===0?zi:zi%Ji},min:function(){return Math.min(zi,Ji)},max:function(){return Math.max(zi,Ji)},set:function(){return Ji},floor:function(){return Math.floor(zi)},ceil:function(){return Math.ceil(zi)},abs:function(){return Math.abs(zi)},clamp:function(){return Math.max(c.min,Math.min(c.max,zi))}}[c.op]();if(c.round&&(xt=Math.round(xt)),!Number.isFinite(xt)||Math.abs(xt)>1e12){Zi("Variable range exceeded");return}var tt=$[c.variableId];$[c.variableId]=xt,tt!==xt&&Un({kind:"variableChange",variableId:c.variableId,instanceId:y.instanceId})}else if(c.kind==="despawn"){var on=(At=y.selfInstanceId)!==null&&At!==void 0?At:y.instanceId;c.target==="other"?ws(y.otherInstanceId):c.target==="both"?(ws(on),ws(y.otherInstanceId)):ws(on)}else if(c.kind==="changeScene")c.delaySeconds>0?c.sceneId!==oe&&(be??(be={sceneId:c.sceneId,at:xe+c.delaySeconds})):ie=c.sceneId;else if(c.kind==="restart")(_t=N?.notifyGameRetry)===null||_t===void 0||_t.call(N),ie="__restart";else if(c.kind==="cameraShake")W?.matches||(it={intensity:c.intensity,seconds:c.seconds,elapsed:0});else if(c.kind==="screenFlash")Pe.push({color:c.color,opacity:c.opacity,seconds:c.seconds,elapsed:0}),Pe.length>8&&Pe.shift();else if(c.kind==="floatingText"){var Vi=L.get(c.componentId),ft=y.instanceId?(St=$e([],Ue(Ke.values()),!1).find(function(ir){return ir.instanceId===y.instanceId&&ir.prototypeId===c.componentId}))!==null&&St!==void 0?St:Vi:(bt=nt(c.componentId))!==null&&bt!==void 0?bt:Vi,Xt=ft?.sceneId===oe?ft:Vi;if(Xt){var st=void 0;if(Xt.contract==="native.mesh3d.v1"&&(st=kf(Xt.id)),!st){var br=tn(Xt);st=oi(ci(Xt),br.width/2,br.height/2)}Ne.push({x:st.x,y:st.y,text:c.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(er,Li){var Xi;return String((Xi=$[Li])!==null&&Xi!==void 0?Xi:"")}),color:c.color,fontSize:c.fontSize,risePx:c.risePx,seconds:c.seconds,elapsed:0}),Ne.length>32&&Ne.shift()}}else if(c.kind==="store")y.kind==="click"&&y.pointerId!==void 0&&!je&&(je={pointerId:y.pointerId,targetId:y.targetId,condition:w},(Ve=e.setPointerCapture)===null||Ve===void 0||Ve.call(e,y.pointerId));else if(c.behaviorId){var Hn=n.gameplay.find(function(nr){return nr.id===c.behaviorId});if(c.kind==="playAudio")cm(Hn);else if(c.kind==="animate"){var Cs=L.get(Hn.componentId),Ei=Ha(Cs)?$e([],Ue(Ke.values()),!1).filter(function(Si){return Si.prototypeId===Cs.id&&(!y.instanceId||Si.instanceId===y.instanceId)}):[Cs],ds=function(Si){var ir=Hn.id+":"+Si.id;se=se.filter(function(Li){return Li.id!==ir});var er=ht({},Hn.parameters);er.fromCurrent&&(er.from=er.property==="opacity"?tn(Si).opacity:Qi(Si)[er.property==="x"?4:5]),se.push(ht(ht({},Hn),{parameters:er,id:ir,behaviorId:Hn.id,targetId:Si.id,elapsed:0,baseTransform:$e([],Ue(Si.transform),!1)}))};try{for(var ji=ze(Ei),Pi=ji.next();!Pi.done;Pi=ji.next()){var Xt=Pi.value;ds(Xt)}}catch(Si){Z={error:Si}}finally{try{Pi&&!Pi.done&&(B=ji.return)&&B.call(ji)}finally{if(Z)throw Z.error}}}else c.kind==="stopAnimation"?se=se.filter(function(nr){return nr.behaviorId!==Hn.id}):c.kind==="emit"&&ny(Hn,y)}}function ny(c,y){var w,T,b,U,R,H,O,Z,B,V=c.parameters,z=V.shape==="pixel-confetti",j=V.shape==="confetti",K=z||j;if(!(K&&W?.matches)){if(Le.length+V.count>256){Zi("Particle budget exhausted");return}if(z&&V.coverage==="screen"){Le.push.apply(Le,$e([],Ue(Cg(V)),!1));return}if(j&&V.coverage==="screen"){Le.push.apply(Le,$e([],Ue(Pg(V)),!1));return}var ee=L.get(c.componentId),ue=y.instanceId&&(w=$e([],Ue(Ke.values()),!1).find(function(kt){return kt.instanceId===y.instanceId&&kt.prototypeId===ee.id}))!==null&&w!==void 0?w:ee;if(V.origin==="contact-3d"){if(W?.matches)return;var _e=Ma(ue);if(!_e)return;for(var ve=bg(ue,nt,tn,sn),Ae=[V.color,V.color2,V.color3].filter(Boolean),fe=Mu(_u(ue.id+":"+xe.toFixed(3))),pe=((T=V.spread)!==null&&T!==void 0?T:360)*Math.PI/180,Re=((b=V.direction)!==null&&b!==void 0?b:-90)*Math.PI/180,de=0;de<V.count;de++){var Fe=Re+pe*(fe.next()-.5),Be=V.speed/100*fe.between(.42,1.1);Le.push(ht(ht({},ve),{stageId:_e.id,shape:"contact-3d",confetti:j,age:0,vx:Math.cos(Fe)*Be,vy:fe.between(.55,.95)*Be,vz:Math.sin(Fe)*Be,life:((U=V.lifetime)!==null&&U!==void 0?U:.5)*fe.between(.7,1),gravity:((R=V.gravity)!==null&&R!==void 0?R:300)/100,color:Ae[de%Ae.length],size:fe.between(.024,.058),spinX:fe.between(-13,13),spinZ:fe.between(-17,17)}))}return}for(var Oe=Qi(ue),Xe,vt=nt(ue.parentId);vt;vt=nt(vt.parentId)){if(K&&vt.contract==="native.group.v1"&&tn(vt).clip){Xe=vt.id;break}Oe=Uo(Qi(vt),Oe)}var Pt=tn(ue),Tt=V.origin==="anchor"?oi(Oe,0,0):K||V.origin==="center"?oi(Oe,Pt.width/2,Pt.height/2):{x:Oe[4]+ue.parameters.width/2,y:Oe[5]+ue.parameters.height/2};if(z){Le.push.apply(Le,$e([],Ue(Qp(V,Tt,Xe)),!1));return}if(j){Le.push.apply(Le,$e([],Ue(jp(V,Tt,Xe)),!1));return}for(var Ct=Mu(_u(ue.id+":"+xe.toFixed(3))),de=0;de<V.count;de++){var Fe=-Math.PI/2+((de+Ct.next())/V.count-.5)*((H=V.spread)!==null&&H!==void 0?H:360)*Math.PI/180,Be=V.speed*Ct.between(.5,.95);Le.push(ht(ht({},Tt),{vx:Math.cos(Fe)*Be,vy:Math.sin(Fe)*Be,life:(O=V.lifetime)!==null&&O!==void 0?O:.7,gravity:(Z=V.gravity)!==null&&Z!==void 0?Z:250,color:V.color,shape:(B=V.shape)!==null&&B!==void 0?B:"circle"}))}}}function dm(c){var y,w;if(c==="__restart"){Ul();return}if(c!==oe){be=void 0;var T=oe;Cn(),oe=c,et.clear(),dn.clear(),ii.clear(),si.clear(),ae.clear(),we.clear(),qt=[],Qt=[],me.clear(),Me.clear(),Yt=void 0,Te=[],Le=[],Ne=[],Pe=[],it=void 0,Mt=!1,ct=0,Ke.clear(),wn.clear(),Bn.clear(),sn.clear(),Mn.clear(),In.clear(),wt.clear(),ri.clear(),xn.clear(),Ro=0,Zt?.reset(),fn.clear(),En.clear(),Ge=void 0,Pl(),re=re.filter(function(H){return H.kind==="variableChange"}),Ee.clear(),Ot=void 0;try{for(var b=ze(Nn.values()),U=b.next();!U.done;U=b.next()){var R=U.value;R.reset()}}catch(H){y={error:H}}finally{try{U&&!U.done&&(w=b.return)&&w.call(b)}finally{if(y)throw y.error}}Ie.clear(),ke.clear(),gt.clear(),se=[],jn(),M.clear(),gn=void 0,Q=void 0,Ra(),Es(),Io(0,!1),Hf(),Ll(0),Un({kind:"sceneExit",sceneId:T}),Un({kind:"sceneEnter",sceneId:oe})}}function Yr(){for(var c=function(){var y,w,T,b,U=re.shift();at++;var R=function(K){return K===void 0||!!nt(K)||$e([],Ue(Ke.values()),!1).some(function(ee){return ee.instanceId===K})};if(!R(U.selfInstanceId)||!R(U.otherInstanceId)||["contactBegin","boundaryExit"].includes(U.kind)&&U.instanceId&&!Ke.has(U.instanceId))return"continue";try{for(var H=(y=void 0,ze(n.eventBindings)),O=H.next();!O.done;O=H.next()){var Z=O.value;if(Object.entries(X.get(Z.eventId)).every(function(K){var ee=Ue(K,2),ue=ee[0],_e=ee[1];return ue==="id"||U[ue]===_e})&&_a(Z.condition,U)){try{for(var B=(T=void 0,ze(Z.actions)),V=B.next();!V.done;V=B.next()){var z=V.value;if(ot>=1024||Vt)break;ty(z,U,Z.condition)}}catch(K){T={error:K}}finally{try{V&&!V.done&&(b=B.return)&&b.call(B)}finally{if(T)throw T.error}}if(ie)break}}}catch(K){y={error:K}}finally{try{O&&!O.done&&(w=H.return)&&w.call(H)}finally{if(y)throw y.error}}if(ie){var j=ie;ie=void 0,dm(j)}};re.length&&!Vt&&at<256&&ot<1024;)c();re.length&&Zi("Event/action budget exhausted")}function ci(c){return Uo(c.parentId?ci(nt(c.parentId)):Na(),Qi(c))}var oi=function(c,y,w){return{x:c[0]*y+c[2]*w+c[4],y:c[1]*y+c[3]*w+c[5]}};function lr(c,y){var w=tn(c),T=[[0,0],[w.width,0],[w.width,w.height],[0,w.height]].map(function(b){var U=Ue(b,2),R=U[0],H=U[1];return oi(y,R,H)});return{left:Math.min.apply(Math,$e([],Ue(T.map(function(b){return b.x})),!1)),right:Math.max.apply(Math,$e([],Ue(T.map(function(b){return b.x})),!1)),top:Math.min.apply(Math,$e([],Ue(T.map(function(b){return b.y})),!1)),bottom:Math.max.apply(Math,$e([],Ue(T.map(function(b){return b.y})),!1))}}function Ti(c){return tn(c).visible&&tn(c).opacity>0&&(!c.parentId||Ti(nt(c.parentId)))}function fm(c,y){for(var w=tn(c),T=ci(c),b=Math.min(w.width,w.height)/2,U=y==="circle"?Array.from({length:32},function(O,Z){return oi(T,w.width/2+Math.cos(Z*Math.PI/16)*b,w.height/2+Math.sin(Z*Math.PI/16)*b)}):[[0,0],[w.width,0],[w.width,w.height],[0,w.height]].map(function(O){var Z=Ue(O,2),B=Z[0],V=Z[1];return oi(T,B,V)}),R=c.parentId?nt(c.parentId):void 0,H=function(){var O=tn(R);if(R.contract==="native.group.v1"&&O.clip){for(var Z=ci(R),B=[[0,0],[O.width,0],[O.width,O.height],[0,O.height]].map(function(ee){var ue=Ue(ee,2),_e=ue[0],ve=ue[1];return oi(Z,_e,ve)}),V=0,z=0;z<4;z++)V+=B[z].x*B[(z+1)%4].y-B[(z+1)%4].x*B[z].y;for(var j=V>=0?1:-1,K=function(ee){var ue,_e,ve=B[ee],Ae=B[(ee+1)%4],fe=function(Pt){return j*((Ae.x-ve.x)*(Pt.y-ve.y)-(Ae.y-ve.y)*(Pt.x-ve.x))},pe=U;U=[];var Re=pe[pe.length-1],de=fe(Re);try{for(var Fe=(ue=void 0,ze(pe)),Be=Fe.next();!Be.done;Be=Fe.next()){var Oe=Be.value,Xe=fe(Oe);if(Xe>=0!=de>=0){var vt=de/(de-Xe);U.push({x:Re.x+(Oe.x-Re.x)*vt,y:Re.y+(Oe.y-Re.y)*vt})}Xe>=0&&U.push(Oe),Re=Oe,de=Xe}}catch(Pt){ue={error:Pt}}finally{try{Be&&!Be.done&&(_e=Fe.return)&&_e.call(Fe)}finally{if(ue)throw ue.error}}},z=0;z<4&&U.length;z++)K(z)}R=R.parentId?nt(R.parentId):void 0};R;)H();return U}function iy(c,y){var w,T,b,U,R,H;if(c.length<3||y.length<3)return!1;try{for(var O=ze([c,y]),Z=O.next();!Z.done;Z=O.next())for(var B=Z.value,V=0;V<B.length;V++){var z=B[V],j=B[(V+1)%B.length],K=z.y-j.y,ee=j.x-z.x,ue=1/0,_e=-1/0,ve=1/0,Ae=-1/0;try{for(var fe=(b=void 0,ze(c)),pe=fe.next();!pe.done;pe=fe.next()){var Re=pe.value,de=Re.x*K+Re.y*ee;ue=Math.min(ue,de),_e=Math.max(_e,de)}}catch(Oe){b={error:Oe}}finally{try{pe&&!pe.done&&(U=fe.return)&&U.call(fe)}finally{if(b)throw b.error}}try{for(var Fe=(R=void 0,ze(y)),Be=Fe.next();!Be.done;Be=Fe.next()){var Re=Be.value,de=Re.x*K+Re.y*ee;ve=Math.min(ve,de),Ae=Math.max(Ae,de)}}catch(Oe){R={error:Oe}}finally{try{Be&&!Be.done&&(H=Fe.return)&&H.call(Fe)}finally{if(R)throw R.error}}if(_e<ve||Ae<ue)return!1}}catch(Oe){w={error:Oe}}finally{try{Z&&!Z.done&&(T=O.return)&&T.call(O)}finally{if(w)throw w.error}}return!0}function ry(c){var y,w,T,b,U=q();try{for(var R=ze(et.values()),H=R.next();!H.done;H=R.next()){var O=H.value,Z=O.behavior.parameters;if(!(!Z.moveComponentId||O.magnitude<=0)){var B=nt(Z.moveComponentId);if(!(!B||!Ti(B))){var V=(T=Z.moveSpeed)!==null&&T!==void 0?T:220,z=Vn("physics-body",(b=B.prototypeId)!==null&&b!==void 0?b:B.id);if(z&&z.parameters.mode==="dynamic"){var j=Ca(B,z);j.vx=O.nx*V,j.vy=O.ny*V,j.atRest=!1,j.restElapsed=0}else{var K=ki(B),ee=tn(B),ue=K.x+O.nx*V*c,_e=K.y+O.ny*V*c;pm(B)||(ue=Math.max(ee.width/2,Math.min(U.width-ee.width/2,ue)),_e=Math.max(ee.height/2,Math.min(U.height-ee.height/2,_e))),Xr(B,ue,_e)}Z.orientToMove&&cs(B,Math.atan2(O.ny,O.nx))}}}}catch(ve){y={error:ve}}finally{try{H&&!H.done&&(w=R.return)&&w.call(R)}finally{if(y)throw y.error}}}function hm(c){var y,w,T,b,U,R,H,O,Z,B,V,z,j,K,ee,ue,_e,ve,Ae,fe,pe,Re,de,Fe,Be,Oe,Xe,vt,Pt,Tt,Ct,kt,At=q();xe+=c,be&&xe>=be.at&&dm(be.sceneId),yy(c),jg(c),ry(c),ey(c),Ff();try{for(var _t=ze(en),St=_t.next();!St.done;St=_t.next()){var bt=Ue(St.value,2),Ve=bt[0],tt=bt[1];!tt.held&&xe-((de=tt.releasedAt)!==null&&de!==void 0?de:xe)>=tt.behavior.springBackSeconds&&en.delete(Ve)}}catch(_n){y={error:_n}}finally{try{St&&!St.done&&(w=_t.return)&&w.call(_t)}finally{if(y)throw y.error}}it&&(it.elapsed+=c,it.elapsed>=it.seconds&&(it=void 0));try{for(var xt=ze(Pe),Qe=xt.next();!Qe.done;Qe=xt.next()){var zt=Qe.value;zt.elapsed+=c}}catch(_n){T={error:_n}}finally{try{Qe&&!Qe.done&&(b=xt.return)&&b.call(xt)}finally{if(T)throw T.error}}Pe=Pe.filter(function(_n){return _n.elapsed<_n.seconds});try{for(var jt=ze(Ne),Sn=jt.next();!Sn.done;Sn=jt.next()){var Xt=Sn.value;Xt.elapsed+=c}}catch(_n){U={error:_n}}finally{try{Sn&&!Sn.done&&(R=jt.return)&&R.call(jt)}finally{if(U)throw U.error}}Ne=Ne.filter(function(_n){return _n.elapsed<_n.seconds});try{for(var Jt=ze(Nn),ft=Jt.next();!ft.done;ft=Jt.next()){var st=Ue(ft.value,2),Ve=st[0],Dn=st[1];L.get(Ve).sceneId===oe&&Ti(L.get(Ve))&&Dn.tick(c)}}catch(_n){H={error:_n}}finally{try{ft&&!ft.done&&(O=Jt.return)&&O.call(Jt)}finally{if(H)throw H.error}}var Ni=function(_n){var Ui,wr,Yi=L.get(_n.componentId);if(Yi.sceneId!==oe)return"continue";var Ur=Ha(Yi)?$e([],Ue(Ke.values()),!1).filter(function(hs){return hs.prototypeId===Yi.id}):[Yi];try{for(var ur=(Ui=void 0,ze(Ur)),Pr=ur.next();!Pr.done;Pr=ur.next()){var Tr=Pr.value,Fr=_n.id+":"+Tr.id;if(_n.kind==="motion"){var ba=(Fe=Ee.get(Tr.id))!==null&&Fe!==void 0?Fe:{transform:$e([],Ue(Tr.transform),!1),parameters:{}},tr=(Be=ba.velocity)!==null&&Be!==void 0?Be:{x:_n.parameters.vx,y:_n.parameters.vy};tr.y+=_n.parameters.gravity*c,ba.transform[4]+=tr.x*c,ba.transform[5]+=tr.y*c,ba.velocity=tr,Ee.set(Tr.id,ba),Tr.prototypeId&&(Tr.transform=ba.transform);var Ya=ci(Tr);(Ya[5]>At.height||Ya[4]<-300||Ya[4]>At.width+300)&&(ba.exited||(ba.exited=!0,Un({kind:"boundaryExit",componentId:Yi.id,instanceId:Tr.instanceId})))}else if(_n.kind==="timer"){var fs=((Oe=gt.get(Fr))!==null&&Oe!==void 0?Oe:0)+c;gt.set(Fr,fs),fs>=_n.parameters.seconds&&fs-c<_n.parameters.seconds&&(Un(ht({kind:"timer",behaviorId:_n.id,componentId:Yi.id},Tr.instanceId?{instanceId:Tr.instanceId,selfInstanceId:Tr.instanceId}:{})),_n.parameters.repeat&&gt.set(Fr,fs-_n.parameters.seconds))}}}catch(hs){Ui={error:hs}}finally{try{Pr&&!Pr.done&&(wr=ur.return)&&wr.call(ur)}finally{if(Ui)throw Ui.error}}};try{for(var _i=ze(n.gameplay),on=_i.next();!on.done;on=_i.next()){var Qn=on.value;Ni(Qn)}}catch(_n){Z={error:_n}}finally{try{on&&!on.done&&(B=_i.return)&&B.call(_i)}finally{if(Z)throw Z.error}}Uf(c),Pa(c),Io(c),Ll(c);var gi=[],ei=function(_n){var Ui,wr,Yi=L.get(_n.componentId);if(Yi.sceneId!==oe)return"continue";try{for(var Ur=(Ui=void 0,ze(Ha(Yi)?$e([],Ue(Ke.values()),!1).filter(function(Tr){return Tr.prototypeId===Yi.id}):[Yi])),ur=Ur.next();!ur.done;ur=Ur.next()){var Pr=ur.value;if(Ti(Pr)){if(gi.length>=256){Zi("Collider budget exhausted");break}gi.push({b:_n,c:Pr,box:lr(Pr,ci(Pr)),polygon:fm(Pr,_n.parameters.shape)})}}}catch(Tr){Ui={error:Tr}}finally{try{ur&&!ur.done&&(wr=Ur.return)&&wr.call(Ur)}finally{if(Ui)throw Ui.error}}};try{for(var An=ze(n.gameplay.filter(function(_n){return _n.kind==="collider"})),Hi=An.next();!Hi.done;Hi=An.next()){var Qn=Hi.value;ei(Qn)}}catch(_n){V={error:_n}}finally{try{Hi&&!Hi.done&&(z=An.return)&&z.call(An)}finally{if(V)throw V.error}}var _r=new Set,Mr=new Map,Gi=function(_n,Ui,wr){var Yi,Ur,ur;((Yi=Ui.c.prototypeId)!==null&&Yi!==void 0?Yi:Ui.c.id)===((Ur=wr.c.prototypeId)!==null&&Ur!==void 0?Ur:wr.c.id)&&Ui.c.id>wr.c.id||Un(ht(ht({},or(_n,Ui.c,wr.c)),{instanceId:(ur=Ui.c.instanceId)!==null&&ur!==void 0?ur:wr.c.instanceId}))},Zn=0;e:for(var ui=0;ui<gi.length;ui++)for(var Qn=ui+1;Qn<gi.length;Qn++){var mn=gi[ui],yi=gi[Qn];if(!(mn.c.instanceId&&mn.c.instanceId===yi.c.instanceId)){var Fn=mn.box,Mi=yi.box,un=Fn.left<Mi.right&&Fn.right>Mi.left&&Fn.top<Mi.bottom&&Fn.bottom>Mi.top;if(un){if(++Zn>4096){Zi("Collision budget exhausted");break e}un=iy(mn.polygon,yi.polygon)}if(un){var Yn=[mn.c.id,yi.c.id].sort().join("|");if(_r.add(Yn),Mr.set(Yn,[mn,yi]),!Ie.has(Yn))try{for(var Ei=(j=void 0,ze([[mn,yi],[yi,mn]])),Sr=Ei.next();!Sr.done;Sr=Ei.next()){var Rr=Ue(Sr.value,2),Dr=Rr[0],Sa=Rr[1];Gi("contactBegin",Dr,Sa)}}catch(Ui){j={error:Ui}}finally{try{Sr&&!Sr.done&&(K=Ei.return)&&K.call(Ei)}finally{if(j)throw j.error}}}}}try{for(var cr=ze(ke),Zr=cr.next();!Zr.done;Zr=cr.next()){var Jr=Ue(Zr.value,2),Yn=Jr[0],Nr=Ue(Jr[1],2),mn=Nr[0],yi=Nr[1];if(!_r.has(Yn))try{for(var $r=(_e=void 0,ze([[mn,yi],[yi,mn]])),zi=$r.next();!zi.done;zi=$r.next()){var Ji=Ue(zi.value,2),Dr=Ji[0],Sa=Ji[1];Gi("contactEnd",Dr,Sa)}}catch(Yi){_e={error:Yi}}finally{try{zi&&!zi.done&&(ve=$r.return)&&ve.call($r)}finally{if(_e)throw _e.error}}}}catch(_n){ee={error:_n}}finally{try{Zr&&!Zr.done&&(ue=cr.return)&&ue.call(cr)}finally{if(ee)throw ee.error}}Ie=_r,ke=Mr;try{for(var Vi=ze(se),br=Vi.next();!br.done;br=Vi.next()){var ui=br.value;ui.elapsed+=c;var Hn=ui.parameters,Cs=(Xe=Hn.delay)!==null&&Xe!==void 0?Xe:0,ds=ui.elapsed-Cs;if(!(ds<0)){var ji=ds/Hn.seconds,Pi=Hn.loop?ji%1:Math.min(1,ji),nr=(vt=Hn.easing)!==null&&vt!==void 0?vt:"ease-out",Si=Pi;Hn.loop&&nr==="ease-in-out"?Si=.5-.5*Math.cos(Pi*Math.PI*2):nr==="ease-out"?Si=1-Math.pow(1-Pi,3):nr==="ease-in"?Si=Math.pow(Pi,3):nr==="ease-in-out"?Si=Pi<.5?4*Math.pow(Pi,3):1-Math.pow(-2*Pi+2,3)/2:nr==="back-out"&&(Si=1+2.70158*Math.pow(Pi-1,3)+1.70158*Math.pow(Pi-1,2));var ir=Hn.from+(Hn.to-Hn.from)*Si,er=nt((Pt=ui.targetId)!==null&&Pt!==void 0?Pt:ui.componentId);if(er){var Li=(Tt=Ee.get(er.id))!==null&&Tt!==void 0?Tt:{transform:$e([],Ue(er.transform),!1),parameters:{}},Xi=(Ct=ui.baseTransform)!==null&&Ct!==void 0?Ct:er.transform;if(Hn.property==="opacity")Li.parameters.opacity=Math.max(0,Math.min(1,ir));else if(["scale","scaleX","scaleY","rotation"].includes(Hn.property)){(kt=Li.animationAxes)!==null&&kt!==void 0||(Li.animationAxes={scale:1,scaleX:1,scaleY:1,rotation:0}),Li.animationAxes[Hn.property]=ir;var ti=Li.animationAxes,hi=ti.rotation*Math.PI/180,no=Math.cos(hi),io=Math.sin(hi),Rs=ti.scale*ti.scaleX,Ps=ti.scale*ti.scaleY;Li.transform[0]=(Xi[0]*no+Xi[2]*io)*Rs,Li.transform[1]=(Xi[1]*no+Xi[3]*io)*Rs,Li.transform[2]=(-Xi[0]*io+Xi[2]*no)*Ps,Li.transform[3]=(-Xi[1]*io+Xi[3]*no)*Ps}else Li.transform[Hn.property==="x"?4:5]=ir;Ee.set(er.id,Li),Hn.loop&&ds>=Hn.seconds&&(ui.elapsed=Cs+ds%Hn.seconds)}}}}catch(_n){Ae={error:_n}}finally{try{br&&!br.done&&(fe=Vi.return)&&fe.call(Vi)}finally{if(Ae)throw Ae.error}}se=se.filter(function(_n){var Ui,wr;return nt((Ui=_n.targetId)!==null&&Ui!==void 0?Ui:_n.componentId)&&(_n.elapsed<_n.parameters.seconds+((wr=_n.parameters.delay)!==null&&wr!==void 0?wr:0)||_n.parameters.loop)});try{for(var Do=ze(Le),Ls=Do.next();!Ls.done;Ls=Do.next()){var Hn=Ls.value;if(Hn.age!==void 0){Hn.age+=c;continue}Hn.life-=c,Hn.x+=Hn.vx*c,Hn.y+=Hn.vy*c,Hn.vy+=Hn.gravity*c}}catch(_n){pe={error:_n}}finally{try{Ls&&!Ls.done&&(Re=Do.return)&&Re.call(Do)}finally{if(pe)throw pe.error}}Le=Le.filter(function(_n){var Ui;return _n.life>((Ui=_n.age)!==null&&Ui!==void 0?Ui:0)}),Yr()}function au(c,y){var w,T,b;if(p.beginPath(),c.contract==="native.ellipse.v1")p.ellipse(y.width/2,y.height/2,y.width/2,y.height/2,0,0,Math.PI*2);else if(c.contract==="native.path.v1"){var U=function(z,j){({M:function(){return p.moveTo.apply(p,$e([],Ue(j),!1))},L:function(){return p.lineTo.apply(p,$e([],Ue(j),!1))},C:function(){return p.bezierCurveTo.apply(p,$e([],Ue(j),!1))},Q:function(){return p.quadraticCurveTo.apply(p,$e([],Ue(j),!1))},Z:function(){return p.closePath()}})[z]()};try{for(var R=ze(y.commands),H=R.next();!H.done;H=R.next()){var O=Ue(H.value),Z=O[0],B=O.slice(1);U(Z,B)}}catch(z){w={error:z}}finally{try{H&&!H.done&&(T=R.return)&&T.call(R)}finally{if(w)throw w.error}}}else{var V=Math.min((b=y.radius)!==null&&b!==void 0?b:0,y.width/2,y.height/2);typeof p.roundRect=="function"?p.roundRect(0,0,y.width,y.height,V):(p.moveTo(V,0),p.arcTo(y.width,0,y.width,y.height,V),p.arcTo(y.width,y.height,0,y.height,V),p.arcTo(0,y.height,0,0,V),p.arcTo(0,0,y.width,0,V),p.closePath())}}function ay(c,y,w){var T,b,U,R=(T=Ee.get(c.id))===null||T===void 0?void 0:T.pathFrame;if(R!==void 0)return Math.min(y.frameCount-1,R);if(f||!y.frameRate)return 0;if(c.contract!=="native.walk-sprite.v1")return Math.floor(Math.max(0,xe-((b=c.spawnTime)!==null&&b!==void 0?b:0))*y.frameRate)%y.frameCount;var H=(U=c.runtimeId)!==null&&U!==void 0?U:c.id,O=We.get(H);if(!O)return We.set(H,{x:w[4],y:w[5],phase:0,lastMove:-1/0,frame:0}),0;var Z=Math.hypot(w[4]-O.x,w[5]-O.y)>.3;if(Z){var B=xe-O.lastMove;O.phase=Number.isFinite(B)&&B<.25?O.phase+Math.min(B,.12)*y.frameRate:0,O.lastMove=xe}return O.x=w[4],O.y=w[5],xe-O.lastMove>.11&&(O.phase=0),O.frame=Math.floor(O.phase)%y.frameCount,O.frame}var Fl=!1,Lo={width:390,height:700},mi,Yf=new Set;function su(c){var y,w;c!==Fl&&(c?(p.save(),p.beginPath(),p.rect((y=Lo.left)!==null&&y!==void 0?y:0,(w=Lo.top)!==null&&w!==void 0?w:0,Lo.width,Lo.height),p.clip(),Fl=!0):(p.restore(),Fl=!1))}function to(c,y,w,T,b){var U,R,H,O,Z,B,V,z,j,K,ee,ue,_e,ve,Ae,fe,pe,Re;if(y===void 0&&(y=Na()),w===void 0&&(w=[]),b===void 0&&(b=!1),c.contract!=="native.mesh3d.v1"){var de=tn(c),Fe=Vn("erase-mask",(ee=c.prototypeId)!==null&&ee!==void 0?ee:c.id);if(!(!de.visible||de.opacity<=0)){var Be=Uo(y,Qi(c));if(Yf.has(c.id)){Je.push({c,m:Be,clips:w,instance:T??c.prototypeId});try{for(var Oe=ze(os(c.id)),Xe=Oe.next();!Xe.done;Xe=Oe.next()){var vt=Xe.value;to(vt,Be,w,T??c.prototypeId,!0)}}catch(Ei){U={error:Ei}}finally{try{Xe&&!Xe.done&&(R=Oe.return)&&R.call(Oe)}finally{if(U)throw U.error}}return}if(c.contract==="native.stage3d.v1"&&Zt&&mi&&Kn.has(c.id)){su(!1);var Pt=Zt.renderStage(c,p,mi.pw,mi.ph,mi.w,mi.h,{time:xe,ambientTime:Ye,propsOf:tn,bodies3d:sn,fpsPose:xn.get(c.id),instances3d:As(c.id),contactParticles:W?.matches?[]:Le.filter(function(Ei){return Ei.stageId===c.id}),aimLocked:!!Dt,groundFn:Ns,worldWidth:mi.w,worldHeight:mi.h,designHeight:q().height,drawX:mi.x,drawY:mi.y,fullBleed:!0});try{for(var Tt=ze(sn),Ct=Tt.next();!Ct.done;Ct=Tt.next()){var kt=Ue(Ct.value,2),At=kt[0],_t=kt[1];if(_t.stageId===c.id&&_t.mode==="dynamic"){var St=Pt.project({x:_t.x,y:_t.y,z:_t.z},mi.w,mi.h);In.set(At,{x:mi.x+St.x,y:mi.y+St.y})}}}catch(Ei){H={error:Ei}}finally{try{Ct&&!Ct.done&&(O=Tt.return)&&O.call(Tt)}finally{if(H)throw H.error}}Je.push({c,m:Be,clips:w,instance:T??c.prototypeId});try{for(var bt=ze(os(c.id)),Ve=bt.next();!Ve.done;Ve=bt.next()){var vt=Ve.value;to(vt,Be,w,T??c.prototypeId,!0)}}catch(Ei){Z={error:Ei}}finally{try{Ve&&!Ve.done&&(B=bt.return)&&B.call(bt)}finally{if(Z)throw Z.error}}return}Fl||su(!0);var tt=ri.get((ue=c.runtimeId)!==null&&ue!==void 0?ue:c.id);tt?.showHighlight&&(p.save(),!b&&c.parentId&&p.transform.apply(p,$e([],Ue(Or(y)),!1)),qg(tt),p.restore()),p.save(),p.transform.apply(p,$e([],Ue(b?Be:Qi(c)),!1)),p.globalAlpha*=de.opacity;var xt=en.get(c.id);xt?.behavior.liftShadow&&(p.shadowColor="#00000055",p.shadowBlur=8,p.shadowOffsetY=4);var Qe=w;c.contract==="native.group.v1"&&de.clip&&(p.beginPath(),p.rect(0,0,de.width,de.height),p.clip(),Qe=$e($e([],Ue(w),!1),[{matrix:Be,width:de.width,height:de.height}],!1));var zt=!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(c.contract)){var jt=c.contract==="native.button.v1",Sn=gn===c.id,Xt=jt?de.enabled?Sn?de.pressedFill:Tn===c.id?de.hoverFill:de.fill:de.disabledFill:de.fill;if(jt&&(de.presentation==="pixel-cta"||de.presentation==="shiny-cta")){var Jt=(_e=J.get(c.id))!==null&&_e!==void 0?_e:Ye;M.set(c.id,Jt);var ft=!f&&!W?.matches?Ye-Jt:-1;de.presentation==="shiny-cta"?Ng(p,de,Xt,Sn,ft):Dg(p,de,Xt,Sn,ft)}else de.pixelFrame&&(p.save(),p.translate(3,4),au(c,de),p.fillStyle="#3c293366",p.fill(),p.restore()),au(c,de),Fe?(p.save(),p.clip(),Ts(c,Fe).render(p),p.restore(),zt=!0,au(c,de)):(p.fillStyle=Xt,p.fill()),de.pixelFrame&&!(de.radius>0)&&(p.fillStyle="#ffffff22",p.fillRect(2,2,Math.max(0,de.width-4),2),p.fillRect(2,2,2,Math.max(0,de.height-4))),de.strokeWidth&&(p.strokeStyle=de.stroke,p.lineWidth=de.strokeWidth,p.stroke());Yt===c.id&&(au(c,de),p.strokeStyle="#ffffff",p.lineWidth=5,p.stroke())}var st,Dn;if(c.contract==="native.text.v1"){var Ni=Dn=de.text.replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(Ei,Sr){var Rr;return String((Rr=$[Sr])!==null&&Rr!==void 0?Rr:"")});de.pixelPanel&&(p.fillStyle="#3c293366",p.fillRect(3,4,de.width,de.height),p.fillStyle=de.panelFill,p.fillRect(0,0,de.width,de.height),p.strokeStyle=(ve=de.panelStroke)!==null&&ve!==void 0?ve:de.color,p.lineWidth=2,p.strokeRect(1,1,de.width-2,de.height-2),p.fillStyle="#ffffff22",p.fillRect(3,3,Math.max(0,de.width-6),2));var _i=de.fontFamily==="pixel"?Jp(Ni,de):void 0;_i&&!_i.unsupportedChars.length?st=Ig(p,Ni,de):st=T1(p,Ni,_i?ht(ht({},de),{fontFamily:"sans-serif",fontWeight:"700"}):de,n.creativeBrief.language)}if(["native.image.v1","native.sprite.v1","native.walk-sprite.v1"].includes(c.contract)&&!Fe){var on=D.get(k((fe=(Ae=Ee.get(c.id))===null||Ae===void 0?void 0:Ae.assetId)!==null&&fe!==void 0?fe:(pe=c.assetSlots[0])===null||pe===void 0?void 0:pe.assetId));if(on?.complete&&on.naturalWidth){p.save(),p.beginPath(),p.rect(0,0,de.width,de.height),p.clip();var Qn=c.contract!=="native.image.v1",gi=Qn?Math.min(de.frameColumns,de.frameCount):1,ei=Qn?Math.ceil(de.frameCount/gi):1,An=on.width/gi,Hi=on.height/ei,_r=Qn?ay(c,de,Be):0,Mr=_r%gi*An,Gi=Math.floor(_r/gi)*Hi,Zn=de.fit==="cover"?Math.max(de.width/An,de.height/Hi):Math.min(de.width/An,de.height/Hi),ui=de.fit==="stretch"?de.width:An*Zn,mn=de.fit==="stretch"?de.height:Hi*Zn;p.imageSmoothingEnabled=(Re=de.smoothing)!==null&&Re!==void 0?Re:!0,p.drawImage(on,Mr,Gi,An,Hi,(de.width-ui)/2,(de.height-mn)/2,ui,mn),p.restore()}}if(Fe&&!zt&&Ts(c,Fe).render(p),c.contract==="native.stage3d.v1"&&Zt&&!Kn.has(c.id)){var Mr=Math.hypot(Be[0],Be[1]),Gi=Math.hypot(Be[2],Be[3]),Pt=Zt.renderStage(c,p,de.width*Mr*ut*Nt,de.height*Gi*ut*Nt,de.width,de.height,{time:xe,ambientTime:Ye,propsOf:tn,bodies3d:sn,fpsPose:xn.get(c.id),instances3d:As(c.id),contactParticles:W?.matches?[]:Le.filter(function(Dr){return Dr.stageId===c.id}),aimLocked:!!Dt,groundFn:Ns,worldWidth:de.width*Mr,worldHeight:de.height*Gi});try{for(var yi=ze(sn),Fn=yi.next();!Fn.done;Fn=yi.next()){var Mi=Ue(Fn.value,2),At=Mi[0],_t=Mi[1];if(_t.stageId===c.id&&_t.mode==="dynamic"){var St=Pt.project({x:_t.x,y:_t.y,z:_t.z},de.width,de.height);In.set(At,oi(Be,St.x,St.y))}}}catch(Dr){V={error:Dr}}finally{try{Fn&&!Fn.done&&(z=yi.return)&&z.call(yi)}finally{if(V)throw V.error}}}Je.push({c,m:Be,clips:Qe,instance:T??c.prototypeId,textMetrics:st,textContent:Dn});try{for(var un=ze(os(c.id)),Yn=un.next();!Yn.done;Yn=un.next()){var vt=Yn.value;to(vt,Be,Qe,T??c.prototypeId)}}catch(Ei){j={error:Ei}}finally{try{Yn&&!Yn.done&&(K=un.return)&&K.call(un)}finally{if(j)throw j.error}}de.clip&&c.contract==="native.group.v1"&&qf(c.id),p.restore()}}}function qf(c,y){var w,T;if(!W?.matches)try{for(var b=ze(Le),U=b.next();!U.done;U=b.next()){var R=U.value;R.shape!=="pixel-confetti"&&R.shape!=="confetti"||R.clipId!==c||!!R.screen!=!!y||(p.save(),R.shape==="confetti"?Lg(p,R,y):Rg(p,R,y),p.restore())}}catch(H){w={error:H}}finally{try{U&&!U.done&&(T=b.return)&&T.call(b)}finally{if(w)throw w.error}}}function sy(c,y,w,T){p.save(),p.translate(c,y),p.globalAlpha=.92,p.lineWidth=2,p.lineJoin="round",w==="tap"&&(p.strokeStyle="#fff0bd",p.globalAlpha=.7*(1-T),p.beginPath(),p.arc(0,0,12+T*12,0,Math.PI*2),p.stroke(),p.globalAlpha=.92),p.fillStyle="#fff0bd",p.strokeStyle="#193b46",p.beginPath(),p.moveTo(-7,10),p.lineTo(-9,-1),p.quadraticCurveTo(-9,-5,-5,-5),p.lineTo(-3,-3),p.lineTo(-3,-17),p.quadraticCurveTo(-3,-22,1,-22),p.quadraticCurveTo(5,-22,5,-17),p.lineTo(5,-6),p.quadraticCurveTo(9,-9,11,-5),p.quadraticCurveTo(15,-7,16,-2),p.lineTo(14,9),p.quadraticCurveTo(12,18,3,18),p.lineTo(-1,18),p.quadraticCurveTo(-5,17,-7,10),p.closePath(),p.fill(),p.stroke(),p.restore()}function oy(){var c,y,w,T,b,U,R,H,O,Z,B,V,z,j,K,ee,ue,_e,ve;if(ct=0,!f)try{for(var Ae=ze(n.gameplay.filter(function(Yn){return Yn.kind==="tutorial-hand"})),fe=Ae.next();!fe.done;fe=Ae.next()){var pe=fe.value,Re=L.get(pe.componentId),de=nt(pe.parameters.targetId);if(!(!Re||Re.sceneId!==oe||!de||de.sceneId!==oe||!Ti(de))&&!(pe.parameters.hideOnFirstInput&&Mt)){var Fe=Gt?xe:Ye;if(!(Fe-Rt<pe.parameters.idleDelaySeconds)){ct++;var Be=pe.parameters.destinationId?nt(pe.parameters.destinationId):void 0,Oe=tn(de),Xe=void 0;de.contract==="native.mesh3d.v1"&&(Xe=kf(de.id)),Xe||(Xe=oi(ci(de),Oe.width/2,Oe.height/2));var vt=Fe%1.2/1.2,Pt=W?.matches?0:vt*vt*(3-2*vt),Tt=Xe.x,Ct=Xe.y;if(pe.parameters.mode!=="tap"){var kt=Be?oi(ci(Be),tn(Be).width/2,tn(Be).height/2):{x:Xe.x-36,y:Xe.y+48};Tt=Xe.x+(kt.x-Xe.x)*Pt,Ct=Xe.y+(kt.y-Xe.y)*Pt}sy(Tt+8,Ct+22,pe.parameters.mode,Pt)}}}}catch(Yn){c={error:Yn}}finally{try{fe&&!fe.done&&(y=Ae.return)&&y.call(Ae)}finally{if(c)throw c.error}}try{for(var At=ze(we),_t=At.next();!_t.done;_t=At.next()){var St=Ue(_t.value,2),bt=St[0],Ve=St[1],tt=Vn("draw-stroke",bt).parameters;try{for(var xt=(b=void 0,ze(Ve.strokes)),Qe=xt.next();!Qe.done;Qe=xt.next()){var zt=Qe.value;if(!(zt.points.length<2)){p.save(),p.globalAlpha=tt.mode==="slice-blade"?Math.max(0,1-zt.age/.18):1,p.strokeStyle=tt.color,p.lineWidth=tt.strokeWidth,p.lineCap="round",p.lineJoin="round",p.beginPath(),p.moveTo(zt.points[0].x,zt.points[0].y);try{for(var jt=(R=void 0,ze(zt.points.slice(1))),Sn=jt.next();!Sn.done;Sn=jt.next()){var Xt=Sn.value;p.lineTo(Xt.x,Xt.y)}}catch(Yn){R={error:Yn}}finally{try{Sn&&!Sn.done&&(H=jt.return)&&H.call(jt)}finally{if(R)throw R.error}}p.stroke(),p.restore()}}}catch(Yn){b={error:Yn}}finally{try{Qe&&!Qe.done&&(U=xt.return)&&U.call(xt)}finally{if(b)throw b.error}}}}catch(Yn){w={error:Yn}}finally{try{_t&&!_t.done&&(T=At.return)&&T.call(At)}finally{if(w)throw w.error}}try{for(var Jt=ze(Qt),ft=Jt.next();!ft.done;ft=Jt.next()){var st=ft.value;if(!(st.broken||!st.drawRope)){var Dn=wn.get(st.bodyId),Ni=nt(st.anchorId);if(!(!Dn||!Ni)){var _i=ki(Ni);p.save(),p.strokeStyle=st.ropeColor,p.lineWidth=st.ropeWidth,p.beginPath(),p.moveTo(_i.x,_i.y),p.lineTo(Dn.x,Dn.y),p.stroke(),p.restore()}}}}catch(Yn){O={error:Yn}}finally{try{ft&&!ft.done&&(Z=Jt.return)&&Z.call(Jt)}finally{if(O)throw O.error}}try{for(var on=ze(n.gameplay.filter(function(Yn){var Ei;return Yn.kind==="virtual-joystick"&&((Ei=L.get(Yn.componentId))===null||Ei===void 0?void 0:Ei.sceneId)===oe})),Qn=on.next();!Qn.done;Qn=on.next()){var pe=Qn.value,gi=nt(pe.componentId),Oe=pe.parameters;if(!(!gi||!Ti(gi)||Oe.drawControl===!1)){var ei=et.get(pe.id),An=ei&&ei.pointerId!==null?ei.origin:ki(gi),Hi=ei&&ei.pointerId!==null?ei.knobX:An.x,_r=ei&&ei.pointerId!==null?ei.knobY:An.y,Mr=(ue=Oe.radiusPx)!==null&&ue!==void 0?ue:56;p.save(),p.fillStyle=(_e=Oe.baseColor)!==null&&_e!==void 0?_e:"#ffffff44",p.strokeStyle="#ffffffaa",p.lineWidth=2.5,p.beginPath(),p.arc(An.x,An.y,Mr,0,Math.PI*2),p.fill(),p.stroke(),p.fillStyle=(ve=Oe.knobColor)!==null&&ve!==void 0?ve:"#fff0bdee",p.strokeStyle="#193b46aa",p.lineWidth=2,p.beginPath(),p.arc(Hi,_r,Mr*.42,0,Math.PI*2),p.fill(),p.stroke(),p.restore()}}}catch(Yn){B={error:Yn}}finally{try{Qn&&!Qn.done&&(V=on.return)&&V.call(on)}finally{if(B)throw B.error}}try{for(var Gi=ze(Ne),Zn=Gi.next();!Zn.done;Zn=Gi.next()){var ui=Zn.value,mn=Math.min(1,ui.elapsed/ui.seconds);p.save(),p.globalAlpha=1-mn,p.fillStyle=ui.color,p.strokeStyle="#193b46",p.lineWidth=3,p.font="900 "+ui.fontSize+"px sans-serif",p.textAlign="center",p.textBaseline="middle";var Ct=ui.y-(W?.matches?0:ui.risePx*mn);p.strokeText(ui.text,ui.x,Ct),p.fillText(ui.text,ui.x,Ct),p.restore()}}catch(Yn){z={error:Yn}}finally{try{Zn&&!Zn.done&&(j=Gi.return)&&j.call(Gi)}finally{if(z)throw z.error}}try{for(var yi=ze(Pe),Fn=yi.next();!Fn.done;Fn=yi.next()){var Mi=Fn.value,mn=Math.min(1,Mi.elapsed/Mi.seconds),un=q();p.save(),p.globalAlpha=Mi.opacity*(1-mn),p.fillStyle=Mi.color,p.fillRect(0,0,un.width,un.height),p.restore()}}catch(Yn){K={error:Yn}}finally{try{Fn&&!Fn.done&&(ee=yi.return)&&ee.call(yi)}finally{if(K)throw K.error}}}function ly(){if(Ge){var c=wn.get(Ge.targetId),y=Ge.behavior.parameters;if(c){var w=Ge.current.x-Ge.start.x,T=Ge.current.y-Ge.start.y,b=Math.hypot(w,T),U=Math.min(y.maxPullPx,b),R=b>.001?U/b:0;p.save(),p.lineCap="round";var H=Math.max(12,Math.min(c.width,c.height)*.62);if(p.strokeStyle="#173a2f66",p.lineWidth=3.5,p.beginPath(),p.arc(c.x,c.y,H,0,Math.PI*2),p.stroke(),p.strokeStyle=y.trajectoryColor,p.lineWidth=2,p.beginPath(),p.arc(c.x,c.y,H,0,Math.PI*2),p.stroke(),y.showTrajectory&&b>=y.minPullPx){var O=Zf(),Z=iu(),B=Z.bodies,V=Z.zones,z=q(),j=rv({body:ht(ht({},c),{vx:O.vx,vy:O.vy,atRest:!1}),bodies:B,zones:V,bounds:{left:0,top:0,right:z.width,bottom:z.height},dots:y.trajectoryDots,bounces:y.trajectoryBounces});j.forEach(function(ue,_e){var ve=.96-.52*(_e/Math.max(1,j.length)),Ae=Math.max(2.2,4.5-_e*.22);p.globalAlpha=ve,p.fillStyle="#173a2f88",p.beginPath(),p.arc(ue.x,ue.y,Ae+1.3,0,Math.PI*2),p.fill(),p.fillStyle=y.trajectoryColor,p.beginPath(),p.arc(ue.x,ue.y,Ae,0,Math.PI*2),p.fill()})}if(b>=4){var K=c.x+w*R,ee=c.y+T*R;p.globalAlpha=.9,p.strokeStyle="#173a2f66",p.lineWidth=5,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(K,ee),p.stroke(),p.strokeStyle=y.trajectoryColor,p.lineWidth=2.6,p.beginPath(),p.moveTo(c.x,c.y),p.lineTo(K,ee),p.stroke(),p.fillStyle="#173a2f88",p.beginPath(),p.arc(K,ee,5.2,0,Math.PI*2),p.fill(),p.fillStyle=y.trajectoryColor,p.beginPath(),p.arc(K,ee,3.6,0,Math.PI*2),p.fill()}p.restore()}}}function cy(c){var y,w,T,b;try{for(var U=ze(Rl()),R=U.next();!R.done;R=U.next()){var H=R.value,O=H.contract==="native.group.v1"?os(H.id):[H];try{for(var Z=(T=void 0,ze(O)),B=Z.next();!B.done;B=Z.next()){var V=B.value;if(V.contract==="native.stage3d.v1"&&Ti(V)&&tn(V).skyColor)return tn(V).skyColor;if(!(V.contract!=="native.rectangle.v1"||!Ti(V))){var z=tn(V);if(!(z.opacity<.95||!z.fill||z.fill==="transparent")&&(/(?:^|\.)(background|backdrop|bg)(?:\.fill)?$/.test(V.id)||z.width>=c.width*.9&&z.height>=c.height*.9))return z.fill}}}catch(j){T={error:j}}finally{try{B&&!B.done&&(b=Z.return)&&b.call(Z)}finally{if(T)throw T.error}}}}catch(j){y={error:j}}finally{try{R&&!R.done&&(w=U.return)&&w.call(U)}finally{if(y)throw y.error}}return"#102a34"}function uy(){var c;if(It&&Ti(It.c)){var y=It.c,w=tn(y);p.save(),p.transform.apply(p,$e([],Ue(ci(y)),!1)),p.strokeStyle=(c=It.highlightColor)!==null&&c!==void 0?c:"#ffffff",p.lineWidth=4,p.globalAlpha=.85,p.strokeRect(-4,-4,w.width+8,w.height+8),p.restore()}if(ne?.b.parameters.bringToFront){var y=nt(ne.targetId);y&&to(y,y.parentId?ci(nt(y.parentId)):Na(),[],y.prototypeId)}}function Ri(){var c,y,w,T,b,U,R,H,O,Z;J=M,M=new Map;var B=q();C!==void 0&&C!==B.landscape&&jn(),C=B.landscape;var V=Math.min(devicePixelRatio||1,2),z=e.clientWidth,j=e.clientHeight;(e.width!==Math.round(z*V)||e.height!==Math.round(j*V))&&(e.width=Math.round(z*V),e.height=Math.round(j*V)),p.setTransform(V,0,0,V,0,0),p.fillStyle=cy(B),p.fillRect(0,0,z,j);var K=Math.min(z/B.width,j/B.height),ee=(z-B.width*K)/2,ue=(j-B.height*K)/2;if(ut=K||1,Nt=V,p.translate(ee,ue),p.scale(K,K),it){var _e=Math.min(1,it.elapsed/it.seconds),ve=it.intensity*(1-_e);p.translate(Math.sin(it.elapsed*95)*ve,Math.cos(it.elapsed*113)*ve)}if(Lo=B,Fl=!1,mi=void 0,Yf.clear(),Kn.clear(),Zt&&K>0&&z>=2&&j>=2){mi={x:-ee/K,y:-ue/K,w:z/K,h:j/K,pw:z*V,ph:j*V};try{for(var Ae=ze(n.components),fe=Ae.next();!fe.done;fe=Ae.next()){var pe=fe.value;if(!(pe.contract!=="native.stage3d.v1"||pe.sceneId!==oe||pe.prototype||!Ti(pe))){for(var Re=!0,de=[],Fe=pe.parentId?nt(pe.parentId):void 0;Fe;Fe=Fe.parentId?nt(Fe.parentId):void 0){var Be=tn(Fe);if(Fe.contract!=="native.group.v1"||Be.clip||Be.opacity<1){Re=!1;break}de.push(Fe.id)}if(Re){var Oe=ci(pe),Xe=tn(pe);if(!(Math.abs(Oe[1])>.001||Math.abs(Oe[2])>.001)){var vt=Math.hypot(Oe[0],Oe[1]),Pt=Math.hypot(Oe[2],Oe[3]);if(!(Oe[4]>1||Oe[5]>1||Oe[4]+Xe.width*vt<B.width-1||Oe[5]+Xe.height*Pt<B.height-1)){Kn.add(pe.id);try{for(var Tt=(w=void 0,ze(de)),Ct=Tt.next();!Ct.done;Ct=Tt.next()){var kt=Ct.value;Yf.add(kt)}}catch(st){w={error:st}}finally{try{Ct&&!Ct.done&&(T=Tt.return)&&T.call(Tt)}finally{if(w)throw w.error}}}}}}}}catch(st){c={error:st}}finally{try{fe&&!fe.done&&(y=Ae.return)&&y.call(Ae)}finally{if(c)throw c.error}}}Yg(B),Lo=sr(B),Je=[];try{for(var At=ze(Rl()),_t=At.next();!_t.done;_t=At.next()){var pe=_t.value;to(pe)}}catch(st){b={error:st}}finally{try{_t&&!_t.done&&(U=At.return)&&U.call(At)}finally{if(b)throw b.error}}su(!0);try{for(var St=ze(Te),bt=St.next();!bt.done;bt=St.next()){var pe=bt.value;pe.parentId||to(pe,Na(),[],pe.prototypeId)}}catch(st){R={error:st}}finally{try{bt&&!bt.done&&(H=St.return)&&H.call(St)}finally{if(R)throw R.error}}if(uy(),ly(),f&&De){for(var Ve=L.get(De);Ve?.parentId;)Ve=L.get(Ve.parentId);Ve?.prototype&&to(Ve)}qf(),p.save();try{for(var tt=ze(Le),xt=tt.next();!xt.done;xt=tt.next()){var Xe=xt.value;if(Xe.age===void 0){var Qe=Math.min(1,Xe.life*2),zt=1.5+2.5*Qe;if(p.globalAlpha=Qe,p.globalCompositeOperation=Xe.shape==="square"?"source-over":"lighter",p.fillStyle=Xe.color,Xe.shape==="square"){var jt=Math.max(2,Math.round(zt*1.6));p.fillRect(Math.round(Xe.x-jt/2),Math.round(Xe.y-jt/2),jt,jt);continue}p.globalCompositeOperation="lighter",p.shadowColor=Xe.color,p.shadowBlur=Le.length<=16?6:0,p.strokeStyle=Xe.color,p.lineWidth=1.5+Qe,p.beginPath(),p.moveTo(Xe.x-Xe.vx*.025,Xe.y-Xe.vy*.025),p.lineTo(Xe.x,Xe.y),p.stroke(),p.beginPath(),p.arc(Xe.x,Xe.y,zt,0,Math.PI*2),p.fill()}}}catch(st){O={error:st}}finally{try{xt&&!xt.done&&(Z=tt.return)&&Z.call(tt)}finally{if(O)throw O.error}}if(p.restore(),oy(),f&&De){var Sn=Je.filter(function(st){return st.c.contract!=="native.group.v1"&&(st.c.id===De||qr(st.c,De))});if(Sn.length){var Xt=Sn.map(function(st){return lr(st.c,st.m)}),Jt=Math.min.apply(Math,$e([],Ue(Xt.map(function(st){return st.left})),!1)),ft=Math.min.apply(Math,$e([],Ue(Xt.map(function(st){return st.top})),!1));p.strokeStyle="#55e6ef",p.lineWidth=2/K,p.strokeRect(Jt,ft,Math.max.apply(Math,$e([],Ue(Xt.map(function(st){return st.right})),!1))-Jt,Math.max.apply(Math,$e([],Ue(Xt.map(function(st){return st.bottom})),!1))-ft)}}su(!1),K>0&&qf(void 0,{x:-ee/K,y:-ue/K,width:z/K,height:j/K})}function dy(c){var y,w,T,b,U=Array.isArray(c)?$e([],Ue(new Set(c)),!1):void 0;Ri();var R=q(),H=sr(R),O=new Set,Z=[];try{for(var B=ze(Je),V=B.next();!V.done;V=B.next()){var z=V.value,j=(T=z.c.prototypeId)!==null&&T!==void 0?T:z.c.id;if(!(z.c.contract==="native.group.v1"||U&&!U.includes(j))){O.add(j);var K=lr(z.c,z.m),ee=((b=tn(z.c).strokeWidth)!==null&&b!==void 0?b:0)/2;K.left-=ee,K.right+=ee,K.top-=ee,K.bottom+=ee;var ue={left:Math.max(0,H.left-K.left),right:Math.max(0,K.right-H.right),top:Math.max(0,H.top-K.top),bottom:Math.max(0,K.bottom-H.bottom)};Object.values(ue).some(function(ve){return ve>.01})&&Z.push({id:j,contract:z.c.contract,bounds:K,overflow:ue})}}}catch(ve){y={error:ve}}finally{try{V&&!V.done&&(w=B.return)&&w.call(B)}finally{if(y)throw y.error}}var _e=U?U.filter(function(ve){return!O.has(ve)}):[];return{ok:Z.length===0&&_e.length===0,viewport:ht(ht({},R),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight}),issues:Z,missing:_e}}function fy(c){var y,w,T,b,U,R,H,O,Z,B,V,z,j,K,ee,ue,_e,ve,Ae,fe,pe,Re,de,Fe,Be,Oe,Xe,vt,Pt,Tt,Ct,kt,At,_t,St,bt,Ve=c===void 0?{}:c,tt=Ve.ids,xt=Ve.interactiveIds,Qe=Ve.network,zt=Qe===void 0?"standalone":Qe,jt=Ve.minTouchPx,Sn=jt===void 0?44:jt,Xt=Array.isArray(tt)?$e([],Ue(new Set(tt)),!1):void 0;Ri();var Jt=q(),ft=sr(Jt),st=Math.min(e.clientWidth/Jt.width,e.clientHeight/Jt.height),Dn=am(ft,zt),Ni=[],_i=new Set,on=function(ye){var Bt;return!Xt||Xt.includes((Bt=ye.c.prototypeId)!==null&&Bt!==void 0?Bt:ye.c.id)},Qn=Je.filter(on),gi=new Set(n.events.filter(function(ye){return ye.kind==="click"}).map(function(ye){return ye.componentId}));try{for(var ei=ze(n.gameplay),An=ei.next();!An.done;An=ei.next()){var Hi=An.value;["drag","match-tile","aim-launch","aim-launch-3d","swipe-input","hold-charge","virtual-joystick","draw-stroke","erase-mask"].includes(Hi.kind)&&gi.add(Hi.componentId)}}catch(ye){y={error:ye}}finally{try{An&&!An.done&&(w=ei.return)&&w.call(ei)}finally{if(y)throw y.error}}var _r=new Set(xt??gi),Mr=new Set($e($e([],Ue(n.gameplay.filter(function(ye){return["aim-launch","aim-launch-3d","swipe-input","hold-charge","draw-stroke","virtual-joystick"].includes(ye.kind)&&(ye.parameters.dragMode==="anywhere"||ye.kind==="draw-stroke"||ye.kind==="virtual-joystick"&&ye.parameters.mode==="floating")}).map(function(ye){return ye.componentId})),!1),Ue(n.components.filter(function(ye){return ye.contract==="native.stage3d.v1"}).map(function(ye){return ye.id})),!1)),Gi=function(ye){var Bt;return _r.has((Bt=ye.c.prototypeId)!==null&&Bt!==void 0?Bt:ye.c.id)},Zn=function(ye,Bt,rn,kn,xi,Ai){return Ni.push(ht(ht({kind:ye,severity:Bt,id:rn},Ai?{otherId:Ai}:{}),{detail:kn,metrics:xi}))},ui=function(ye){var Bt=[[0,0],[ye.width,0],[ye.width,ye.height],[0,ye.height]].map(function(rn){var kn=Ue(rn,2),xi=kn[0],Ai=kn[1];return oi(ye.matrix,xi,Ai)});return{left:Math.min.apply(Math,$e([],Ue(Bt.map(function(rn){return rn.x})),!1)),right:Math.max.apply(Math,$e([],Ue(Bt.map(function(rn){return rn.x})),!1)),top:Math.min.apply(Math,$e([],Ue(Bt.map(function(rn){return rn.y})),!1)),bottom:Math.max.apply(Math,$e([],Ue(Bt.map(function(rn){return rn.y})),!1))}};try{for(var mn=ze(Qn),yi=mn.next();!yi.done;yi=mn.next()){var Fn=yi.value,Mi=(Be=Fn.c.prototypeId)!==null&&Be!==void 0?Be:Fn.c.id;_i.add(Mi);var un=lr(Fn.c,Fn.m),Yn=((Oe=tn(Fn.c).strokeWidth)!==null&&Oe!==void 0?Oe:0)/2;un.left-=Yn,un.right+=Yn,un.top-=Yn,un.bottom+=Yn;var Ei=Fn.c.contract==="native.group.v1"&&!tn(Fn.c).clip,Sr=Fn.c.contract==="native.image.v1"&&Fn.clips.length===0&&tn(Fn.c).fit==="cover"&&un.left<=0&&un.top<=0&&un.right>=Jt.width&&un.bottom>=Jt.height||Fn.c.contract==="native.stage3d.v1"&&un.left<=0&&un.top<=0&&un.right>=Jt.width&&un.bottom>=Jt.height,Rr=Fn.c.contract==="native.rectangle.v1"&&Yn===0&&un.left<=0&&un.top<=0&&un.right>=Jt.width&&un.bottom>=Jt.height||Sr;if(!Ei){var Dr={left:Math.max(0,ft.left-un.left),right:Math.max(0,un.right-ft.right),top:Math.max(0,ft.top-un.top),bottom:Math.max(0,un.bottom-ft.bottom)};if(!Rr&&!pm(Fn.c)&&Object.values(Dr).some(function(ye){return ye>.01})&&Zn("stage-overflow","blocker",Mi,"Component extends beyond the active stage.",{bounds:un,overflow:Dr}),Fn.c.contract==="native.image.v1"&&Fn.clips.length===0){var Sa=un.right-un.left,cr=un.bottom-un.top,Zr=/(?:^|\.)(backdrop|background|bg)$/.test(Mi)||tn(Fn.c).fit==="cover"&&!Fn.c.parentId&&un.left<=1&&un.top<=1&&(Sa>=Jt.width*.4||cr>=Jt.height*.4);Zr&&(un.left>.5||un.top>.5||un.right<Jt.width-.5||un.bottom<Jt.height-.5)&&Zn("backdrop-incomplete","blocker",Mi,"Backdrop image does not cover the full active stage, leaving a visible seam.",{bounds:un,stage:{width:Jt.width,height:Jt.height}})}try{for(var Jr=(U=void 0,ze(Fn.clips)),Nr=Jr.next();!Nr.done;Nr=Jr.next()){var $r=Nr.value,zi=ui($r),Ji={left:Math.max(0,zi.left-un.left),right:Math.max(0,un.right-zi.right),top:Math.max(0,zi.top-un.top),bottom:Math.max(0,un.bottom-zi.bottom)};Object.values(Ji).some(function(ye){return ye>.01})&&Zn("parent-clip-crop","blocker",Mi,"Component is cropped by an ancestor clipping group.",{bounds:un,clip:zi,crop:Ji})}}catch(ye){U={error:ye}}finally{try{Nr&&!Nr.done&&(R=Jr.return)&&R.call(Jr)}finally{if(U)throw U.error}}}if(Fn.textMetrics){var Vi=Fn.textMetrics;Vi.overflowsWidth&&Zn("text-overflow","blocker",Mi,"Text exceeds its component width after wrapping and auto-fit.",Vi),Vi.overflowsHeight&&Zn("text-clipped","blocker",Mi,"Text is vertically clipped by its component after wrapping and auto-fit.",Vi);var br=(Xe=Vi.fontSize)!==null&&Xe!==void 0?Xe:Vi.scale*8;br<12&&Zn("text-illegible",br<8?"blocker":"warning",Mi,"Rendered text is below the recommended legible size.",ht({renderedFontSize:br},Vi));var Hn=tn(Fn.c),Cs=Hn.direction==="rtl"||Hn.direction!=="ltr"&&/^(ar|fa|he|iw|ps|sd|ug|ur|yi)(?:-|$)/.test(n.creativeBrief.language);if(Cs&&Vi.resolvedAlign==="left"&&Zn("rtl-alignment","blocker",Mi,"Right-to-left copy must resolve to right or center alignment.",{direction:"rtl",align:Hn.align,resolvedAlign:Vi.resolvedAlign}),Hn.pixelPanel&&Hn.align!=="center"){var ds=Math.max(0,Hn.width-2*(Hn.padding===void 0?8:Hn.padding));ds-((vt=Vi.renderedWidth)!==null&&vt!==void 0?vt:0)>12&&Zn("panel-off-center","blocker",Mi,"Text inside a framed pixel panel is not horizontally centered.",{align:Hn.align,innerWidth:ds,renderedWidth:(Pt=Vi.renderedWidth)!==null&&Pt!==void 0?Pt:0})}}if(Gi(Fn)&&!Mr.has(Mi)&&(Fn.c.contract!=="native.group.v1"||un.right>un.left&&un.bottom>un.top)){var ji=(un.right-un.left)*st,Pi=(un.bottom-un.top)*st;(ji<Sn-.01||Pi<Sn-.01)&&Zn("touch-target-small","blocker",Mi,"Interactive target is smaller than the required physical touch size.",{width:ji,height:Pi,minTouchPx:Sn,scale:st})}if(Gi(Fn)&&!Mr.has(Mi)||Fn.c.contract==="native.text.v1")try{for(var nr=(H=void 0,ze(Dn.zones)),Si=nr.next();!Si.done;Si=nr.next()){var ir=Si.value,ji=Math.min(un.right,ir.right)-Math.max(un.left,ir.left),Pi=Math.min(un.bottom,ir.bottom)-Math.max(un.top,ir.top);ji>.01&&Pi>.01&&Zn("sdk-safe-area-collision","blocker",Mi,"Component intersects a reserved ad-SDK overlay zone.",{bounds:un,zone:ir,intersection:{width:ji,height:Pi},network:zt})}}catch(ye){H={error:ye}}finally{try{Si&&!Si.done&&(O=nr.return)&&O.call(nr)}finally{if(H)throw H.error}}}}catch(ye){T={error:ye}}finally{try{yi&&!yi.done&&(b=mn.return)&&b.call(mn)}finally{if(T)throw T.error}}for(var er=Qn.filter(function(ye){return Gi(ye)&&ye.c.contract!=="native.group.v1"&&ye.c.contract!=="native.stage3d.v1"}),Li=0;Li<er.length;Li++)for(var Xi=Li+1;Xi<er.length;Xi++){var ti=er[Li],hi=er[Xi],no=(Tt=ti.c.prototypeId)!==null&&Tt!==void 0?Tt:ti.c.id,io=(Ct=hi.c.prototypeId)!==null&&Ct!==void 0?Ct:hi.c.id;if(!(no===io||qr(ti.c,hi.c.id)||qr(hi.c,ti.c.id))){var Rs=lr(ti.c,ti.m),Ps=lr(hi.c,hi.m),ji=Math.min(Rs.right,Ps.right)-Math.max(Rs.left,Ps.left),Pi=Math.min(Rs.bottom,Ps.bottom)-Math.max(Rs.top,Ps.top);ji>1&&Pi>1&&Zn("interactive-overlap","blocker",no,"Interactive targets overlap.",{intersection:{width:ji,height:Pi},first:Rs,second:Ps},io)}}var Do=function(ye){if(!ye||ye==="transparent")return!1;var Bt=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(ye);if(Bt)return Bt[1].length===4?Bt[1][3].toLowerCase()==="f":Bt[1].slice(6).toLowerCase()==="ff";var rn=/^rgba\([^,]+,[^,]+,[^,]+,\s*([0-9.]+)\s*\)$/i.exec(ye);return rn?Number(rn[1])>=.95:!0},Ls=[];Qn.forEach(function(ye,Bt){var rn,kn;ye.c.contract==="native.rectangle.v1"&&!Gi(ye)&&((rn=tn(ye.c).opacity)!==null&&rn!==void 0?rn:1)>=.95&&Do(tn(ye.c).fill)&&Ls.push({rowIndex:Bt,row:ye,order:(kn=ye.c.order)!==null&&kn!==void 0?kn:0,bounds:lr(ye.c,ye.m)})});var _n=Qn.filter(function(ye,Bt){var rn,kn=lr(ye.c,ye.m),xi=(rn=ye.c.order)!==null&&rn!==void 0?rn:0;return!Ls.some(function(Ai){return Ai.rowIndex>Bt&&Ai.order>xi&&Ai.row.c.id!==ye.c.id&&!qr(Ai.row.c,ye.c.id)&&!qr(ye.c,Ai.row.c.id)&&Ai.bounds.left<=kn.left+1&&Ai.bounds.right>=kn.right-1&&Ai.bounds.top<=kn.top+1&&Ai.bounds.bottom>=kn.bottom-1})}),Ui=_n.map(function(ye,Bt){return{row:ye,rowIndex:Bt}}).filter(function(ye){var Bt,rn=ye.row;if(rn.c.contract!=="native.rectangle.v1")return!1;var kn=lr(rn.c,rn.m),xi=kn.right-kn.left,Ai=kn.bottom-kn.top,$i=((Bt=tn(rn.c).strokeWidth)!==null&&Bt!==void 0?Bt:0)===0&&kn.left<=0&&kn.right>=Jt.width;return!$i&&xi>=180&&Ai>=140&&!Gi(rn)}).map(function(ye){var Bt,rn=ye.row,kn=ye.rowIndex;return{id:(Bt=rn.c.prototypeId)!==null&&Bt!==void 0?Bt:rn.c.id,row:rn,rowIndex:kn,bounds:lr(rn.c,rn.m)}}),wr=function(ye,Bt,rn,kn){var xi,Ai;kn===void 0&&(kn=!1);var $i=(xi=ye.c.prototypeId)!==null&&xi!==void 0?xi:ye.c.id,Kr=(rn.left+rn.right)/2,La=(rn.top+rn.bottom)/2,ql=(Ai=ye.c.order)!==null&&Ai!==void 0?Ai:0;return Ui.filter(function(Ii){var Da;return Ii.id!==$i&&(!kn||Ii.rowIndex<Bt||((Da=Ii.row.c.order)!==null&&Da!==void 0?Da:0)===ql)&&rn.right-rn.left<=Ii.bounds.right-Ii.bounds.left+4&&rn.bottom-rn.top<=Ii.bounds.bottom-Ii.bounds.top+4&&Kr>=Ii.bounds.left&&Kr<=Ii.bounds.right&&La>=Ii.bounds.top&&La<=Ii.bounds.bottom}).sort(function(Ii,Da){return(Ii.bounds.right-Ii.bounds.left)*(Ii.bounds.bottom-Ii.bounds.top)-(Da.bounds.right-Da.bounds.left)*(Da.bounds.bottom-Da.bounds.top)||Da.rowIndex-Ii.rowIndex})[0]},Yi=new Map,Ur=new Map;if(Ui.length){_n.forEach(function(ye,Bt){var rn,kn=(rn=ye.c.prototypeId)!==null&&rn!==void 0?rn:ye.c.id,xi=lr(ye.c,ye.m),Ai=(xi.left+xi.right)/2,$i=(xi.top+xi.bottom)/2,Kr=ye.c.contract==="native.button.v1"&&!Ht.has(ye.c.id),La=ye.c.parentId?nt(ye.c.parentId):void 0,ql=ye.c.contract==="native.text.v1"&&tn(ye.c).align==="center"&&La?.contract!=="native.button.v1";if(Kr||ql){var Ii=wr(ye,Bt,xi,!1);Ii&&(Yi.has(Ii.id)||Yi.set(Ii.id,{panel:Ii,items:[]}),Yi.get(Ii.id).items.push({id:kn,bounds:xi,cx:Ai,cy:$i,isBtn:Kr}))}if(["native.text.v1","native.image.v1","native.button.v1"].includes(ye.c.contract)&&La?.contract!=="native.button.v1"){var Ii=wr(ye,Bt,xi,!0);Ii&&(Ur.has(Ii.id)||Ur.set(Ii.id,{panel:Ii,content:[]}),Ur.get(Ii.id).content.push({row:ye,id:kn,bounds:xi}))}});try{for(var ur=ze(Yi.values()),Pr=ur.next();!Pr.done;Pr=ur.next()){var Tr=Pr.value,Fr=Tr.panel,ba=Tr.items;if(ba.some(function(ye){return ye.isBtn})){var tr=Fr.bounds,Ya=(tr.left+tr.right)/2;try{for(var fs=(V=void 0,ze(ba)),hs=fs.next();!hs.done;hs=fs.next()){var ro=hs.value,kl={left:ro.bounds.left-tr.left,right:tr.right-ro.bounds.right,top:ro.bounds.top-tr.top,bottom:tr.bottom-ro.bounds.bottom},wm=Math.min(kl.left,kl.right,kl.top,kl.bottom);(wm<10||wm*st<8)&&Zn("panel-edge-cramped","blocker",ro.id,"Element sits too close to its enclosing panel edge.",{panelId:Fr.id,margins:kl,scale:st,minStagePx:10,minCssPx:8},Fr.id)}}catch(ye){V={error:ye}}finally{try{hs&&!hs.done&&(z=fs.return)&&z.call(fs)}finally{if(V)throw V.error}}var eh=[],by=function(ye){var Bt=eh.find(function(rn){return Math.abs(rn.cy-ye.cy)<=16&&rn.isBtn===ye.isBtn});Bt?Bt.items.push(ye):eh.push({cy:ye.cy,isBtn:ye.isBtn,items:[ye]})};try{for(var cu=(j=void 0,ze(ba)),zl=cu.next();!zl.done;zl=cu.next()){var ro=zl.value;by(ro)}}catch(ye){j={error:ye}}finally{try{zl&&!zl.done&&(K=cu.return)&&K.call(cu)}finally{if(j)throw j.error}}try{for(var uu=(ee=void 0,ze(eh)),Vl=uu.next();!Vl.done;Vl=uu.next()){var th=Vl.value,wy=Math.min.apply(Math,$e([],Ue(th.items.map(function(ye){return ye.bounds.left})),!1)),Ty=Math.max.apply(Math,$e([],Ue(th.items.map(function(ye){return ye.bounds.right})),!1)),Tm=(wy+Ty)/2,Em=Tm-Ya;Math.abs(Em)>3&&Zn("panel-off-center","blocker",th.items[0].id,"Element is not horizontally centered inside its enclosing panel.",{panelId:Fr.id,offsetX:Em,groupCenterX:Tm,panelCenterX:Ya,scale:st},Fr.id)}}catch(ye){ee={error:ye}}finally{try{Vl&&!Vl.done&&(ue=uu.return)&&ue.call(uu)}finally{if(ee)throw ee.error}}}}}catch(ye){Z={error:ye}}finally{try{Pr&&!Pr.done&&(B=ur.return)&&B.call(ur)}finally{if(Z)throw Z.error}}try{for(var du=ze(Ur.values()),Gl=du.next();!Gl.done;Gl=du.next())for(var Am=Gl.value,Fr=Am.panel,fu=Am.content,Ey=Yi.has(Fr.id),Li=0;Li<fu.length;Li++)for(var Xi=Li+1;Xi<fu.length;Xi++){var ti=fu[Li],hi=fu[Xi];if(!(ti.id===hi.id||qr(ti.row.c,hi.row.c.id)||qr(hi.row.c,ti.row.c.id))){var Ay=ti.row.c.contract==="native.image.v1"&&hi.row.c.contract==="native.image.v1";if(!(Ay&&(!Ey||ti.row.c.parentId&&ti.row.c.parentId===hi.row.c.parentId))){var ji=Math.min(ti.bounds.right,hi.bounds.right)-Math.max(ti.bounds.left,hi.bounds.left),Pi=Math.min(ti.bounds.bottom,hi.bounds.bottom)-Math.max(ti.bounds.top,hi.bounds.top);ji>2&&Pi>2&&Zn("panel-content-overlap","blocker",ti.id,"Panel elements overlap each other.",{panelId:Fr.id,intersection:{width:ji,height:Pi},first:ti.bounds,second:hi.bounds},hi.id)}}}}catch(ye){_e={error:ye}}finally{try{Gl&&!Gl.done&&(ve=du.return)&&ve.call(du)}finally{if(_e)throw _e.error}}}var No=_n.filter(function(ye){if(ye.c.contract!=="native.text.v1")return!1;var Bt=ye.c.parentId?nt(ye.c.parentId):void 0;return Bt?.contract!=="native.button.v1"}).map(function(ye){var Bt,rn,kn=String((Bt=tn(ye.c).text)!==null&&Bt!==void 0?Bt:"").replace(/\{\{([a-z0-9_.-]+)\}\}/g,function(xi,Ai){var $i;return String(($i=$[Ai])!==null&&$i!==void 0?$i:"")}).trim();return{row:ye,id:(rn=ye.c.prototypeId)!==null&&rn!==void 0?rn:ye.c.id,bounds:lr(ye.c,ye.m),raw:kn,norm:kn.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}}).filter(function(ye){return ye.raw.length>0}),Iy=Ui.filter(function(ye){var Bt,rn;return((Bt=Yi.get(ye.id))===null||Bt===void 0?void 0:Bt.items.some(function(kn){return kn.isBtn}))||((rn=Ur.get(ye.id))===null||rn===void 0?void 0:rn.content.some(function(kn){return kn.row.c.contract==="native.button.v1"}))});try{for(var hu=ze(Iy),Hl=hu.next();!Hl.done;Hl=hu.next()){var Fr=Hl.value,tr=Fr.bounds,Ya=(tr.left+tr.right)/2,Cy=tr.right-tr.left;try{for(var pu=(pe=void 0,ze(No)),Wl=pu.next();!Wl.done;Wl=pu.next()){var qa=Wl.value;if(tn(qa.row.c).align==="center"&&!(qa.bounds.bottom>tr.top+6||tr.top-qa.bounds.bottom>48)){var Im=qa.bounds.right-qa.bounds.left,Xl=(qa.bounds.left+qa.bounds.right)/2,Ry=Math.min(qa.bounds.right,tr.right)-Math.max(qa.bounds.left,tr.left);(Xl>=tr.left&&Xl<=tr.right||Ry>=Im*.6)&&Im<=Cy+60&&Math.abs(Xl-Ya)>4&&Zn("header-off-center","blocker",qa.id,"Centered text above a panel is not horizontally aligned with the panel below it.",{panelId:Fr.id,offsetX:Xl-Ya,textCenterX:Xl,panelCenterX:Ya,scale:st},Fr.id)}}}catch(kn){pe={error:kn}}finally{try{Wl&&!Wl.done&&(Re=pu.return)&&Re.call(pu)}finally{if(pe)throw pe.error}}}}catch(ye){Ae={error:ye}}finally{try{Hl&&!Hl.done&&(fe=hu.return)&&fe.call(hu)}finally{if(Ae)throw Ae.error}}for(var Li=0;Li<No.length;Li++)for(var Xi=Li+1;Xi<No.length;Xi++){var ti=No[Li],hi=No[Xi];if(!(ti.id===hi.id||qr(ti.row.c,hi.row.c.id)||qr(hi.row.c,ti.row.c.id))){var ji=Math.min(ti.bounds.right,hi.bounds.right)-Math.max(ti.bounds.left,hi.bounds.left),Pi=Math.min(ti.bounds.bottom,hi.bounds.bottom)-Math.max(ti.bounds.top,hi.bounds.top);if(ji>2&&Pi>2&&Zn("panel-content-overlap","blocker",ti.id,"Visible text elements overlap.",{intersection:{width:ji,height:Pi},first:ti.bounds,second:hi.bounds},hi.id),ti.norm&&hi.norm){var Cm=Ue(ti.norm.length<=hi.norm.length?[ti.norm,hi.norm]:[hi.norm,ti.norm],2),mu=Cm[0],Rm=Cm[1];(mu===Rm&&mu.length>=6||mu.length>=12&&Rm.includes(mu))&&Zn("duplicate-visible-copy","blocker",ti.id,"Duplicate visible copy appears in multiple text elements simultaneously.",{first:ti.raw,second:hi.raw},hi.id)}}}var Za=No.filter(function(ye){return!/^[\d\s/.,:%+\-x]+$/i.test(ye.raw)}),vu=Za.reduce(function(ye,Bt){return ye+(Bt.norm?Bt.norm.split(" ").filter(Boolean).length:0)},0),nh=Za.reduce(function(ye,Bt){return ye+Bt.raw.replace(/\s+/g," ").length},0);vu>20||nh>130||Za.length>5?Zn("text-clutter-heavy","blocker",(At=(kt=Za[0])===null||kt===void 0?void 0:kt.id)!==null&&At!==void 0?At:null,"Too much visible copy on one screen; keep playable ads visual and concise.",{blocks:Za.length,wordCount:vu,charCount:nh,texts:Za.map(function(ye){return ye.raw})}):(vu>12||Za.length>4)&&Zn("text-clutter-heavy","warning",(St=(_t=Za[0])===null||_t===void 0?void 0:_t.id)!==null&&St!==void 0?St:null,"Screen copy is getting dense; consider trimming narration so gameplay carries the experience.",{blocks:Za.length,wordCount:vu,charCount:nh,texts:Za.map(function(ye){return ye.raw})});var ih=[],Py=function(ye){if(Xt&&!Xt.includes(ye.componentId)||ye.ownerHiddenByAuthor||!ye.targetVisible)return"continue";var Bt=Qn.find(function(Er){var rh;return((rh=Er.c.prototypeId)!==null&&rh!==void 0?rh:Er.c.id)===ye.componentId}),rn=Bt?lr(Bt.c,Bt.m):null;if(Bt&&Bt.c.contract==="native.group.v1"&&(!rn||rn.right<=rn.left||rn.bottom<=rn.top)){var kn=Qn.filter(function(Er){return Er.c.contract!=="native.group.v1"&&qr(Er.c,Bt.c.id)}).map(function(Er){return lr(Er.c,Er.m)});kn.length&&(rn={left:Math.min.apply(Math,$e([],Ue(kn.map(function(Er){return Er.left})),!1)),right:Math.max.apply(Math,$e([],Ue(kn.map(function(Er){return Er.right})),!1)),top:Math.min.apply(Math,$e([],Ue(kn.map(function(Er){return Er.top})),!1)),bottom:Math.max.apply(Math,$e([],Ue(kn.map(function(Er){return Er.bottom})),!1))})}var xi={occluded:!1,occluderId:null,targetHitSamples:0,occludedSamples:0,occludedRatio:0};!ye.behindCamera&&!ye.offscreen&&ye.stageEntry&&ye.localBounds&&(xi=ye.stageEntry.checkNodeOcclusion(ye.targetId,ye.localBounds,ye.stageLocalWidth,ye.stageLocalHeight));var Ai={id:ye.componentId,targetId:ye.targetId,stageId:ye.stageId,visible:ye.visible,behindCamera:ye.behindCamera,offscreen:ye.offscreen,clippedFraction:Number(ye.clippedFraction.toFixed(3)),targetBounds:ye.targetBounds,overlayBounds:rn,occluded:xi.occluded,occluderId:xi.occluderId};if(ih.push(Ai),(ye.behindCamera||ye.offscreen||ye.clippedFraction>.25)&&Zn("anchor-3d-target-offscreen","blocker",ye.componentId,"Anchored 3D target is behind the camera, off-screen, or significantly clipped in this viewport.",{targetId:ye.targetId,behindCamera:ye.behindCamera,offscreen:ye.offscreen,clippedFraction:Ai.clippedFraction,targetBounds:ye.targetBounds,viewportBounds:ft},ye.targetId),rn&&ye.targetBounds&&!ye.behindCamera&&!ye.offscreen){var $i=ye.targetBounds,Kr=rn,La=Math.min(Kr.right,$i.right)-Math.max(Kr.left,$i.left),ql=Math.min(Kr.bottom,$i.bottom)-Math.max(Kr.top,$i.top),Ii=La>0&&ql>0,Da=Math.max(0,Math.max(Kr.left-$i.right,$i.left-Kr.right)),Dy=Math.max(0,Math.max(Kr.top-$i.bottom,$i.top-Kr.bottom)),Lm=Math.hypot(Da,Dy),Dm=er.some(function(Er){return qr(Er.c,ye.componentId)}),Nm=!!(Bt&&Gi(Bt)||Dm||ye.config.fitToProjectedBounds);(Nm&&!Ii||!Nm&&Lm>72)&&Zn("anchor-3d-misaligned","blocker",ye.componentId,"Anchored 2D overlay does not align with its projected 3D target bounds.",{targetId:ye.targetId,targetBounds:$i,overlayBounds:Kr,edgeGap:Number(Lm.toFixed(1)),interactive:!!(Bt&&Gi(Bt)||Dm)},ye.targetId)}xi.occluded&&Zn("anchor-3d-occluded","blocker",ye.componentId,"Anchored 3D target is occluded from the camera by another foreground 3D mesh.",{targetId:ye.targetId,occluderId:xi.occluderId,occludedRatio:Number(xi.occludedRatio.toFixed(2)),targetHitSamples:xi.targetHitSamples,occludedSamples:xi.occludedSamples},(bt=xi.occluderId)!==null&&bt!==void 0?bt:ye.targetId)};try{for(var gu=ze(ri.values()),Yl=gu.next();!Yl.done;Yl=gu.next()){var Ly=Yl.value;Py(Ly)}}catch(ye){de={error:ye}}finally{try{Yl&&!Yl.done&&(Fe=gu.return)&&Fe.call(gu)}finally{if(de)throw de.error}}var Pm=Xt?Xt.filter(function(ye){if(_i.has(ye))return!1;var Bt=nt(ye);return Bt?.contract==="native.mesh3d.v1"?!1:!Bt||Ti(Bt)}):[];return ht(ht({ok:!Ni.some(function(ye){return ye.severity==="blocker"})&&Pm.length===0,viewport:ht(ht({},Jt),{canvasWidth:e.clientWidth,canvasHeight:e.clientHeight,scale:st}),defects:Ni,missing:Pm,interactive:er.map(function(ye){var Bt;return{id:(Bt=ye.c.prototypeId)!==null&&Bt!==void 0?Bt:ye.c.id,bounds:lr(ye.c,ye.m)}}),texts:Qn.filter(function(ye){return ye.c.contract==="native.text.v1"}).map(function(ye){var Bt,rn,kn,xi,Ai,$i;return{id:(Bt=ye.c.prototypeId)!==null&&Bt!==void 0?Bt:ye.c.id,text:(rn=ye.textContent)!==null&&rn!==void 0?rn:"",direction:(xi=(kn=ye.textMetrics)===null||kn===void 0?void 0:kn.direction)!==null&&xi!==void 0?xi:"ltr",align:($i=(Ai=ye.textMetrics)===null||Ai===void 0?void 0:Ai.resolvedAlign)!==null&&$i!==void 0?$i:tn(ye.c).align}})},ih.length?{anchors3d:ih}:{}),{safeArea:Dn})}function qr(c,y){for(;c.parentId;){if(c.parentId===y)return!0;c=nt(c.parentId)}return!1}function pm(c){for(var y=function(b){if(n.gameplay.some(function(U){var R;return U.kind==="camera-follow"&&U.componentId===((R=b.prototypeId)!==null&&R!==void 0?R:b.id)}))return{value:!0}},w=c;w;w=w.parentId?nt(w.parentId):void 0){var T=y(w);if(typeof T=="object")return T.value}return!1}function ou(c){var y=q(),w=e.getBoundingClientRect(),T=Math.min(w.width/y.width,w.height/y.height);return{x:(c.clientX-w.left-(w.width-y.width*T)/2)/T,y:(c.clientY-w.top-(w.height-y.height*T)/2)/T}}function hy(c,y){var w,T,b,U;try{if(c.c.contract==="native.stage3d.v1"&&Kn.has(c.c.id)&&mi)return y.x>=mi.x&&y.y>=mi.y&&y.x<=mi.x+mi.w&&y.y<=mi.y+mi.h;try{for(var R=ze(c.clips),H=R.next();!H.done;H=R.next()){var O=H.value,Z=oi(Or(O.matrix),y.x,y.y);if(Z.x<0||Z.y<0||Z.x>O.width||Z.y>O.height)return!1}}catch(fe){w={error:fe}}finally{try{H&&!H.done&&(T=R.return)&&T.call(R)}finally{if(w)throw w.error}}var B=oi(Or(c.m),y.x,y.y),V=tn(c.c);if(c.c.contract==="native.path.v1"){var z=new Path2D,j=function(fe,pe){({M:function(){return z.moveTo.apply(z,$e([],Ue(pe),!1))},L:function(){return z.lineTo.apply(z,$e([],Ue(pe),!1))},C:function(){return z.bezierCurveTo.apply(z,$e([],Ue(pe),!1))},Q:function(){return z.quadraticCurveTo.apply(z,$e([],Ue(pe),!1))},Z:function(){return z.closePath()}})[fe]()};try{for(var K=ze(V.commands),ee=K.next();!ee.done;ee=K.next()){var ue=Ue(ee.value),_e=ue[0],ve=ue.slice(1);j(_e,ve)}}catch(fe){b={error:fe}}finally{try{ee&&!ee.done&&(U=K.return)&&U.call(K)}finally{if(b)throw b.error}}p.save(),p.setTransform(1,0,0,1,0,0),p.lineWidth=V.strokeWidth;var Ae=p.isPointInPath(z,B.x,B.y)||V.strokeWidth>0&&p.isPointInStroke(z,B.x,B.y);return p.restore(),Ae}return c.c.contract==="native.ellipse.v1"?Math.pow((B.x-V.width/2)/(V.width/2),2)+Math.pow((B.y-V.height/2)/(V.height/2),2)<=1:B.x>=0&&B.y>=0&&B.x<=V.width&&B.y<=V.height}catch{return!1}}function Ol(c){return $e([],Ue(Je),!1).reverse().find(function(y){return y.c.contract!=="native.group.v1"&&y.c.sceneId===oe&&nt(y.c.id)&&Ti(y.c)&&hy(y,c)})}function Bl(c){for(var y=[];c;)y.push(c),c=nt(c.parentId);return y}function Zf(){if(!Ge)return{vx:0,vy:0,power:0,pull:0};var c=Ge.behavior.parameters,y=Ge.current.x-Ge.start.x,w=Ge.current.y-Ge.start.y,T=Math.hypot(y,w),b=Math.max(0,Math.min(1,(T-c.minPullPx)/Math.max(1,c.maxPullPx-c.minPullPx))),U=c.minSpeed+(c.maxSpeed-c.minSpeed)*b,R=c.invert?-1:1;return{vx:T?y/T*U*R:0,vy:T?w/T*U*R:0,power:b,pull:T}}function mm(c){if(Ge){Ge.current=c;var y=Zf();Ge.power=y.power,Ge.behavior.parameters.powerVariableId&&($[Ge.behavior.parameters.powerVariableId]=y.power)}}function Jf(c){var y,w;c===void 0&&(c=!1);try{var T=(y=globalThis.AudioContext)!==null&&y!==void 0?y:globalThis.webkitAudioContext;T&&!Ze&&(Ze=new T,(w=Ze.addEventListener)===null||w===void 0||w.call(Ze,"statechange",function(){Ze?.state==="running"&&zf()})),Po(c)}catch{}}function py(c,y,w){var T,b,U,R,H,O,Z=function(pe){var Re=w.find(function(Be){var Oe;return((Oe=Be.prototypeId)!==null&&Oe!==void 0?Oe:Be.id)===pe.componentId});if(!Re)return"continue";var de=oi(Or(ci(Re)),y.x,y.y),Fe=Ts(Re,pe);return Fe.stampSegment(de,de),Ce={kind:"mask",pointerId:c.pointerId,c:Re,behavior:pe,last:de},(H=e.setPointerCapture)===null||H===void 0||H.call(e,c.pointerId),{value:!0}};try{for(var B=ze(n.gameplay.filter(function(pe){var Re;return pe.kind==="erase-mask"&&((Re=L.get(pe.componentId))===null||Re===void 0?void 0:Re.sceneId)===oe})),V=B.next();!V.done;V=B.next()){var z=V.value,j=Z(z);if(typeof j=="object")return j.value}}catch(pe){T={error:pe}}finally{try{V&&!V.done&&(b=B.return)&&b.call(B)}finally{if(T)throw T.error}}if(w.some(function(pe){return pe.contract==="native.button.v1"||n.events.some(function(Re){var de;return Re.kind==="click"&&Re.componentId===((de=pe.prototypeId)!==null&&de!==void 0?de:pe.id)})}))return!1;try{for(var K=ze(n.gameplay.filter(function(pe){var Re;return pe.kind==="draw-stroke"&&((Re=L.get(pe.componentId))===null||Re===void 0?void 0:Re.sceneId)===oe})),ee=K.next();!ee.done;ee=K.next()){var z=ee.value,ue=L.get(z.componentId),_e=Or(ci(ue)),ve=oi(_e,y.x,y.y),Ae=tn(ue);if(!(ve.x<0||ve.y<0||ve.x>Ae.width||ve.y>Ae.height)){var fe=Nf(z);return fe.begin(y),Ce={kind:"stroke",pointerId:c.pointerId,c:ue,behavior:z,store:fe,last:y},Un({kind:"strokeStart",componentId:ue.id}),(O=e.setPointerCapture)===null||O===void 0||O.call(e,c.pointerId),!0}}}catch(pe){U={error:pe}}finally{try{ee&&!ee.done&&(R=K.return)&&R.call(K)}finally{if(U)throw U.error}}return!1}function my(c,y,w){var T,b,U,R,H,O,Z,B=w.store.active;if(B){try{for(var V=ze(n.gameplay.filter(function(Fe){var Be;return Fe.kind==="collider"&&((Be=L.get(Fe.componentId))===null||Be===void 0?void 0:Be.sceneId)===oe})),z=V.next();!z.done;z=V.next()){var j=z.value,K=L.get(j.componentId);try{for(var ee=(U=void 0,ze(Bi(K))),ue=ee.next();!ue.done;ue=ee.next()){var _e=ue.value;!Ti(_e)||B.hitIds.has(_e.id)||Jm(c,y,fm(_e,j.parameters.shape))&&(B.hitIds.add(_e.id),Un(or("sliceHit",_e)))}}catch(Fe){U={error:Fe}}finally{try{ue&&!ue.done&&(R=ee.return)&&R.call(ee)}finally{if(U)throw U.error}}}}catch(Fe){T={error:Fe}}finally{try{z&&!z.done&&(b=V.return)&&b.call(V)}finally{if(T)throw T.error}}try{for(var ve=ze(Qt),Ae=ve.next();!Ae.done;Ae=ve.next()){var fe=Ae.value;if(!(fe.broken||!fe.breakable||B.hitIds.has(fe.key))){var pe=wn.get(fe.bodyId),Re=nt(fe.anchorId);if(!(!pe||!Re)){var de=ki(Re);dh(c,y,{x:de.x,y:de.y},{x:pe.x,y:pe.y})&&(B.hitIds.add(fe.key),fe.broken=!0,Me.add(fe.key),Un({kind:"jointBreak",behaviorId:fe.id,componentId:fe.componentId,selfInstanceId:fe.bodyId,instanceId:(Z=nt(fe.bodyId))===null||Z===void 0?void 0:Z.instanceId}))}}}}catch(Fe){H={error:Fe}}finally{try{Ae&&!Ae.done&&(O=ve.return)&&O.call(ve)}finally{if(H)throw H.error}}}}function vy(c,y){var w,T=y.last,b=y.behavior.parameters;if(b.inkVariableId){var U=b.inkVariableId,R=Math.hypot(c.x-T.x,c.y-T.y);if(((w=$[U])!==null&&w!==void 0?w:0)<R)return;$[U]-=R}y.store.add(c)&&(b.mode==="slice-blade"&&my(T,c,y),y.last=c)}function gy(c){var y,w;if(!(!Ce||Ce.pointerId!==c.pointerId)){var T=Ce;Ce=void 0;try{!((y=e.hasPointerCapture)===null||y===void 0)&&y.call(e,c.pointerId)&&((w=e.releasePointerCapture)===null||w===void 0||w.call(e,c.pointerId))}catch{}if(T.kind==="stroke"){var b=T.store.end(),U=T.behavior.parameters;if(b){if(U.mode==="physics-wall"){var R=new Set(T.store.strokes.map(function(O){return O.id}));qt=qt.filter(function(O){return O.owner!==T.c.id||R.has(O.strokeId)}),qt.push.apply(qt,$e([],Ue(Km(b,U.strokeWidth).map(function(O){return ht(ht({},O),{owner:T.c.id})})),!1))}else if(U.mode==="path-trace"){var H=nt(U.followComponentId);H&&b.points.length>1&&me.set(H.id,{points:b.points,index:1,speed:U.followSpeed})}}Un({kind:"strokeEnd",componentId:T.c.id})}}}function yy(c){var y,w,T,b;try{for(var U=ze(we.values()),R=U.next();!R.done;R=U.next()){var H=R.value;H.tick(c)}}catch(fe){y={error:fe}}finally{try{R&&!R.done&&(w=U.return)&&w.call(U)}finally{if(y)throw y.error}}try{for(var O=ze(me),Z=O.next();!Z.done;Z=O.next()){var B=Ue(Z.value,2),V=B[0],z=B[1],j=nt(V);if(!j){me.delete(V);continue}var K=z.points[z.index];if(!K){me.delete(V),Un(or("pathArrive",j));continue}var ee=ki(j),ue=K.x-ee.x,_e=K.y-ee.y,ve=Math.hypot(ue,_e),Ae=z.speed*c;ve<=Ae?(Xr(j,K.x,K.y),z.index++):ve>.001&&Xr(j,ee.x+ue/ve*Ae,ee.y+_e/ve*Ae)}}catch(fe){T={error:fe}}finally{try{Z&&!Z.done&&(b=O.return)&&b.call(O)}finally{if(T)throw T.error}}}function xy(c,y,w){var T,b,U=[],R=[],H=function(V){var z=L.get(V.componentId),j=V.parameters.dragMode==="anywhere"?Bi(z).find(function(ue){return Ti(ue)}):w.find(function(ue){var _e;return((_e=ue.prototypeId)!==null&&_e!==void 0?_e:ue.id)===z.id});if(!j)return"continue";if(V.kind==="swipe-input")R.push({behavior:V,c:j});else{var K=V.parameters,ee=Math.max(K.min,Math.min(K.max,Number($[K.variableId])));$[K.variableId]=ee,U.push({behavior:V,c:j,charge:Vm(K,ee)}),Un(or("holdStart",j))}};try{for(var O=ze(n.gameplay.filter(function(V){var z;return["swipe-input","hold-charge"].includes(V.kind)&&((z=L.get(V.componentId))===null||z===void 0?void 0:z.sceneId)===oe})),Z=O.next();!Z.done;Z=O.next()){var B=Z.value;H(B)}}catch(V){T={error:V}}finally{try{Z&&!Z.done&&(b=O.return)&&b.call(O)}finally{if(T)throw T.error}}(U.length||R.length)&&(lt={pointerId:c.pointerId,start:y,current:y,holds:U,swipes:R})}function _y(c,y){var w,T,b,U,R,H,O,Z;if(!(!lt||lt.pointerId!==c.pointerId)){var B=lt,V=new Set;lt=void 0;try{for(var z=ze($e($e([],Ue(B.holds),!1),Ue(B.swipes),!1)),j=z.next();!j.done;j=z.next()){var K=j.value,ee=K.behavior,ue=K.c;V.has(ee.componentId)||(V.add(ee.componentId),Un(or("pointerUp",ue,void 0,{targetId:ue.id,pointerId:c.pointerId})))}}catch(Oe){w={error:Oe}}finally{try{j&&!j.done&&(T=z.return)&&T.call(z)}finally{if(w)throw w.error}}try{for(var _e=ze(B.holds),ve=_e.next();!ve.done;ve=_e.next()){var Ae=ve.value,fe=Ae.behavior.parameters;if(Un(or("holdRelease",Ae.c)),fe.resetOnRelease!==!1){var pe=$[fe.variableId];$[fe.variableId]=fe.min,pe!==fe.min&&Un({kind:"variableChange",variableId:fe.variableId,selfInstanceId:(O=Ae.c.instanceId)!==null&&O!==void 0?O:Ae.c.id,instanceId:Ae.c.instanceId})}}}catch(Oe){b={error:Oe}}finally{try{ve&&!ve.done&&(U=_e.return)&&U.call(_e)}finally{if(b)throw b.error}}try{for(var Re=ze(B.swipes),de=Re.next();!de.done;de=Re.next()){var Fe=de.value,Be=zm(B.start,y,Fe.behavior.parameters.minDistancePx,(Z=si.get(Fe.behavior.id))!==null&&Z!==void 0?Z:-1/0,xe*1e3,Fe.behavior.parameters.cooldownMs);Be&&(si.set(Fe.behavior.id,xe*1e3),Un(or("swipe",Fe.c,void 0,{direction:Be})))}}catch(Oe){R={error:Oe}}finally{try{de&&!de.done&&(H=Re.return)&&H.call(Re)}finally{if(R)throw R.error}}return V}}function My(c,y,w){var T,b,U;if(w.some(function(ee){return ee.contract==="native.button.v1"&&tn(ee).enabled}))return!1;try{for(var R=ze(n.gameplay.filter(function(ee){var ue;return ee.kind==="virtual-joystick"&&((ue=L.get(ee.componentId))===null||ue===void 0?void 0:ue.sceneId)===oe})),H=R.next();!H.done;H=R.next()){var O=H.value,Z=L.get(O.componentId);if(Ti(Z)){var B=et.get(O.id);if(!(B&&B.pointerId!==null)){var V=oi(Or(ci(Z)),y.x,y.y),z=tn(Z);if(!(V.x<0||V.y<0||V.x>z.width||V.y>z.height)){var j=O.parameters.mode==="floating"?ht({},y):ki(Z),K=ch(j,y,O.parameters.radiusPx,O.parameters.deadZone);return B=ht({behavior:O,c:Z,pointerId:c.pointerId,origin:j,current:y},K),et.set(O.id,B),ss(B),Un(or("joystickStart",Z)),(U=e.setPointerCapture)===null||U===void 0||U.call(e,c.pointerId),!0}}}}}catch(ee){T={error:ee}}finally{try{H&&!H.done&&(b=R.return)&&b.call(R)}finally{if(T)throw T.error}}return!1}var vm=function(c){var y,w,T,b,U,R,H,O,Z,B,V,z,j;ce();var K=ou(c),ee=Ol(K);if(Ft=K,!(!ee&&f)){if(f){ee&&(De=ee.c.id,_((U=ee.c.prototypeId)!==null&&U!==void 0?U:ee.c.id));return}var ue=n.gameplay.some(function(ft){return ft.kind==="virtual-joystick"||ft.kind==="fps-controller-3d"});if(!(!c.isTrusted||c.button!==void 0&&c.button!==0||!ue&&c.isPrimary===!1||pt||he||!ue&&(ne&&ne.pointerId!==c.pointerId||lt&&lt.pointerId!==c.pointerId||Ge&&Ge.pointerId!==c.pointerId||Dt&&Dt.pointerId!==c.pointerId)||N&&(!Kt||!nn))){var _e=!Gt;Rt=xe,Mt=!0,Gt=!0,Jf(!0),_e&&!Vt&&(at=ot=0,Yr());var ve=ee?Bl(ee.c):[];if(My(c,K,ve)){at=ot=0,Vt=!1,Yr(),Ri();return}if(py(c,K,ve)){Yr(),Ri();return}xy(c,K,ve);var Ae=Zt&&!ve.some(function(ft){return ft.contract==="native.button.v1"})?n.gameplay.find(function(ft){var st;return ft.kind==="aim-launch-3d"&&((st=L.get(ft.componentId))===null||st===void 0?void 0:st.sceneId)===oe}):void 0;if(Ae){var fe=L.get(Ae.componentId),pe=Vn("physics-3d",fe.id),Re=pe?ia(fe,pe):void 0,de=kf(fe.id),Fe=Ae.parameters.dragMode==="anywhere"||de&&Math.hypot(K.x-de.x,K.y-de.y)<=Ae.parameters.hitRadiusPx;if(Re&&Re.atRest&&!Re.captured&&Fe){Dt={behavior:Ae,targetId:fe.id,sourceId:fe.id,stageId:Ae.parameters.stageId,pointerId:c.pointerId,start:K,current:K,power:0},om(K),(R=e.setPointerCapture)===null||R===void 0||R.call(e,c.pointerId);return}}var Be=ve.some(function(ft){return ft.contract==="native.button.v1"&&tn(ft).enabled}),Oe=Be||ve.some(function(ft){return n.events.some(function(st){var Dn;return st.kind==="click"&&st.componentId===((Dn=ft.prototypeId)!==null&&Dn!==void 0?Dn:ft.id)})});if(Zt&&!Be){var Xe=n.gameplay.find(function(ft){var st;return ft.kind==="fps-controller-3d"&&((st=L.get(ft.componentId))===null||st===void 0?void 0:st.sceneId)===oe});if(Xe){var vt=L.get(Xe.componentId),Pt=oi(Or(ci(vt)),K.x,K.y),Tt=tn(vt);if(Kn.has(vt.id)||Pt.x>=0&&Pt.y>=0&&Pt.x<=Tt.width&&Pt.y<=Tt.height){var Ct=n.events.some(function(ft){return ft.kind==="click"&&ft.componentId===vt.id});if(!Ln&&Xe.parameters.lookMode!=="none"&&(Xa(Xe),Ln={pointerId:c.pointerId,stageId:vt.id,behavior:Xe,last:K},(H=e.setPointerCapture)===null||H===void 0||H.call(e,c.pointerId)),Ct){at=ot=0,Vt=!1,Un({kind:"click",componentId:vt.id,targetId:vt.id,pointerId:c.pointerId}),Yr(),Ri();return}if(!Oe)return}}}var kt=n.gameplay.find(function(ft){return ft.kind==="aim-launch"&&L.get(ft.componentId).sceneId===oe&&(ft.parameters.dragMode==="anywhere"&&!ve.some(function(st){return st.contract==="native.button.v1"})||ve.some(function(st){var Dn;return((Dn=st.prototypeId)!==null&&Dn!==void 0?Dn:st.id)===ft.componentId}))});if(kt){var At=L.get(kt.componentId),_t=(O=ve.find(function(st){var Dn;return((Dn=st.prototypeId)!==null&&Dn!==void 0?Dn:st.id)===At.id}))!==null&&O!==void 0?O:Bi(At).find(function(st){return Ti(st)}),Re=_t&&Ca(_t,Vn("physics-body",At.id));if(Re&&(!kt.parameters.onlyWhenAtRest||Re.atRest)){Ge={behavior:kt,targetId:_t.id,sourceId:At.id,pointerId:c.pointerId,start:K,current:K,power:0},mm(K),(Z=e.setPointerCapture)===null||Z===void 0||Z.call(e,c.pointerId),Ri();return}}try{for(var St=ze(ve),bt=St.next();!bt.done;bt=St.next()){var Ve=bt.value,tt=Vn("press-feedback",(B=Ve.prototypeId)!==null&&B!==void 0?B:Ve.id);tt&&(Ve.contract!=="native.button.v1"||tn(Ve).enabled)&&en.set(Ve.id,{behavior:tt.parameters,pointerId:c.pointerId,held:!0})}}catch(ft){y={error:ft}}finally{try{bt&&!bt.done&&(w=St.return)&&w.call(St)}finally{if(y)throw y.error}}var xt=ve.find(function(ft){var st;return((st=Ht.get(ft.id))===null||st===void 0?void 0:st.sceneId)===oe});if(xt){var Qe=Nn.get(xt.parentId);if(Qe?.snapshot().busy)return;Kg(xt),Qe&&!Qe.snapshot().busy&&(Ot={pointerId:c.pointerId,boardId:xt.parentId,tileId:xt.id,start:K},(V=e.setPointerCapture)===null||V===void 0||V.call(e,c.pointerId))}gn=(z=ve.find(function(ft){return ft.contract==="native.button.v1"&&tn(ft).enabled}))===null||z===void 0?void 0:z.id,Q=gn?c.pointerId:void 0;var zt=n.gameplay.find(function(ft){return ft.kind==="drag"&&ve.some(function(st){var Dn;return((Dn=st.prototypeId)!==null&&Dn!==void 0?Dn:st.id)===ft.componentId})});if(zt){var Ve=ve.find(function(st){var Dn;return((Dn=st.prototypeId)!==null&&Dn!==void 0?Dn:st.id)===zt.componentId}),jt=ki(Ve),Sn=dn.zoneOf(Ve.id);ii.set(Ve.id,jt),dn.release(Ve.id),ne={b:zt,targetId:Ve.id,start:K,current:K,origin:jt,originZone:Sn,m:$e([],Ue(Qi(Ve)),!1),pointerId:c.pointerId},Un(or("dragStart",Ve)),e.setPointerCapture(c.pointerId)}at=ot=0,Vt=!1;try{for(var Xt=ze(ve),Jt=Xt.next();!Jt.done;Jt=Xt.next()){var Ve=Jt.value;(Ve.contract!=="native.button.v1"||tn(Ve).enabled)&&Un({kind:"click",componentId:(j=Ve.prototypeId)!==null&&j!==void 0?j:Ve.id,instanceId:Ve.instanceId,targetId:Ve.id,pointerId:c.pointerId})}}catch(ft){T={error:ft}}finally{try{Jt&&!Jt.done&&(b=Xt.return)&&b.call(Xt)}finally{if(T)throw T.error}}Yr(),Ri()}}};function gm(c,y){if(!Ot||Ot.pointerId!==c.pointerId)return!1;if(!c.isTrusted||!Gn())return!0;var w=Ot,T=Nn.get(w.boardId);if(T.snapshot().busy)return Ot=void 0,!0;var b=Or(ci(L.get(w.boardId))),U=oi(b,w.start.x,w.start.y),R=oi(b,y.x,y.y),H=R.x-U.x,O=R.y-U.y,Z=L.get(w.tileId);if(Math.max(Math.abs(H),Math.abs(O))<Math.min(Z.parameters.width,Z.parameters.height)*.35)return!0;var B=Ht.get(Z.id),V=Math.abs(H)>Math.abs(O),z=B.row+(V?0:Math.sign(O)),j=B.column+(V?Math.sign(H):0),K=$e([],Ue(Ht),!1).find(function(ee){var ue=Ue(ee,2),_e=ue[1];return _e.boardId===w.boardId&&_e.row===z&&_e.column===j});return K&&T.swap(Z.id,K[0])&&(Yt=void 0,Ri()),Ot=void 0,!0}var ym=function(c){var y,w,T,b;if(!pt){ce();var U=q(),R=ou(c);Ft=R,lt?.pointerId===c.pointerId&&(lt.current=R);var H=function(At){var _t,St;if(At.pointerId===c.pointerId){var bt=R.x-At.current.x,Ve=R.y-At.current.y;if(c.isTrusted&&Gn())try{for(var tt=(_t=void 0,ze(n.gameplay.filter(function(zt){var jt,Sn;return zt.kind==="fps-controller-3d"&&zt.parameters.aimJoystickBehaviorId===At.behavior.id&&((jt=zt.parameters.aimMode)!==null&&jt!==void 0?jt:"delta")==="delta"&&((Sn=L.get(zt.componentId))===null||Sn===void 0?void 0:Sn.sceneId)===oe}))),xt=tt.next();!xt.done;xt=tt.next()){var Qe=xt.value;Co(Qe,bt,Ve)}}catch(zt){_t={error:zt}}finally{try{xt&&!xt.done&&(St=tt.return)&&St.call(tt)}finally{if(_t)throw _t.error}}return Object.assign(At,{current:R},ch(At.origin,R,At.behavior.parameters.radiusPx,At.behavior.parameters.deadZone)),ss(At),Ri(),{value:void 0}}};try{for(var O=ze(et.values()),Z=O.next();!Z.done;Z=O.next()){var B=Z.value,V=H(B);if(typeof V=="object")return V.value}}catch(At){y={error:At}}finally{try{Z&&!Z.done&&(w=O.return)&&w.call(O)}finally{if(y)throw y.error}}if(Ce?.pointerId===c.pointerId){if(Ce.kind==="mask"){var z=Ce,j=oi(Or(ci(z.c)),R.x,R.y);Ts(z.c,z.behavior).stampSegment(z.last,j),z.last=j}else vy(R,Ce);Yr(),Ri();return}if(Ln?.pointerId===c.pointerId){c.isTrusted&&Gn()&&(Co(Ln.behavior,R.x-Ln.last.x,R.y-Ln.last.y),Ln.last=R,Ri());return}if(Dt?.pointerId===c.pointerId){c.isTrusted&&Gn()&&om(R);return}if(Ge?.pointerId===c.pointerId){c.isTrusted&&Gn()&&mm(R),Ri();return}var K=Ol(R);if(Tn=K?(T=Bl(K.c).find(function(At){return At.contract==="native.button.v1"}))===null||T===void 0?void 0:T.id:void 0,!gm(c,R)&&!(!ne||ne.pointerId!==c.pointerId)){var ee=nt(ne.targetId);if(!ee){na();return}var ue=ee.parentId?ci(nt(ee.parentId)):Na(),_e=Or(ue),ve=oi(_e,ne.start.x,ne.start.y),Ae=oi(_e,R.x,R.y),fe=$e([],Ue(ne.m),!1),pe=ne.b.parameters.axis;if(pe!=="y"){var Re=ne.m[4]+Ae.x-ve.x;Number.isFinite(ne.b.parameters.minX)&&(Re=Math.max(ne.b.parameters.minX,Re)),Number.isFinite(ne.b.parameters.maxX)&&(Re=Math.min(ne.b.parameters.maxX,Re)),fe[4]=Re}if(pe!=="x"){var de=ne.m[5]+Ae.y-ve.y;Number.isFinite(ne.b.parameters.minY)&&(de=Math.max(ne.b.parameters.minY,de)),Number.isFinite(ne.b.parameters.maxY)&&(de=Math.min(ne.b.parameters.maxY,de)),fe[5]=de}if(!ee.parentId)pe!=="y"&&(fe[4]=Math.max(0,Math.min(U.width-ee.parameters.width,fe[4])));else{var Fe=lr(ee,Uo(ue,fe)),Be=0;Fe.left<0||Fe.right-Fe.left>U.width?Be=-Fe.left:Fe.right>U.width&&(Be=U.width-Fe.right);var Oe=pe==="y"?0:ue[0],Xe=pe==="x"?0:ue[2];Math.abs(Oe)>=Math.abs(Xe)&&Math.abs(Oe)>1e-8?fe[4]+=Be/Oe:Math.abs(Xe)>1e-8&&(fe[5]+=Be/Xe)}var vt=(b=Ee.get(ee.id))!==null&&b!==void 0?b:{parameters:{}};Ee.set(ee.id,ht(ht({},vt),{transform:fe})),ne.current=R;var Pt=Gf(ee),Tt=Pt.zones,Ct=Pt.tag,kt=xu({itemId:ee.id,tag:Ct,zones:Tt,occupancy:dn});It=kt&&kt.kind!=="reject"?kt.zone:void 0}}},xm=function(c){var y,w,T,b,U;ce();var R=ou(c),H=je;Ft=R,ya(c.pointerId,!0),xr(c.pointerId),gy(c);var O=(T=_y(c,R))!==null&&T!==void 0?T:new Set;if(Qg(c),c.isTrusted&&Gn()){var Z=Ol(R);try{for(var B=ze(Z?Bl(Z.c):[]),V=B.next();!V.done;V=B.next()){var z=V.value;!O.has((b=z.prototypeId)!==null&&b!==void 0?b:z.id)&&(z.contract!=="native.button.v1"||tn(z).enabled)&&Un(or("pointerUp",z,void 0,{targetId:z.id,pointerId:c.pointerId}))}}catch(ve){y={error:ve}}finally{try{V&&!V.done&&(w=B.return)&&w.call(B)}finally{if(y)throw y.error}}}if(Yr(),Ri(),Dt?.pointerId===c.pointerId){var j=Dt,K=sm(),ee=sn.get(j.targetId);(U=Zt?.getStage(L.get(j.stageId)))===null||U===void 0||U.setGuide([]),Dt=void 0,j.behavior.parameters.powerVariableId&&($[j.behavior.parameters.powerVariableId]=0);var ue=Math.hypot(K.vx,K.vz);c.isTrusted&&Jf(!0),ee&&c.isTrusted&&Gn()&&K.pull>=j.behavior.parameters.minPullPx&&ue>=j.behavior.parameters.minSpeed&&(ee.vx=K.vx,ee.vy=0,ee.vz=K.vz,ee.atRest=!1,ee.restElapsed=0,ee.movingTime=0,ee.captured=!1,ee.lastSafe={x:ee.x,y:ee.y,z:ee.z},Un({kind:"launch",componentId:j.sourceId})),xa(c),Yr();return}if(Ge?.pointerId===c.pointerId){var j=Ge,K=Zf(),ee=wn.get(j.targetId);Ge=void 0,j.behavior.parameters.powerVariableId&&($[j.behavior.parameters.powerVariableId]=0),ee&&c.isTrusted&&Gn()&&K.pull>=j.behavior.parameters.minPullPx&&(ee.vx=K.vx,ee.vy=K.vy,ee.atRest=!1,ee.restElapsed=0,ee.captured=!1,ee.exited=!1,Un({kind:"launch",componentId:j.sourceId,instanceId:ee.instanceId})),xa(c),Yr(),Ri();return}if(gm(c,R),Ot?.pointerId===c.pointerId&&(Ot=void 0),xa(c),!(H?.pointerId!==c.pointerId||!c.isTrusted||!Gn()||navigator.userActivation&&navigator.userActivation.isActive!==!0||!_a(H.condition))){var _e=Ol(R);if(!(!_e||!Bl(_e.c).some(function(ve){return ve.id===H.targetId&&(ve.contract!=="native.button.v1"||tn(ve).enabled)}))){if(P){Sm.push(n.base.storeUrl);return}N?N.openStore(n.base.storeUrl):window.open(n.base.storeUrl,"_blank","noopener")}}},lu=function(c){var y,w;if(Dt?.pointerId===c.pointerId&&fi(c.pointerId),Ln?.pointerId===c.pointerId&&xr(c.pointerId),ya(c.pointerId,!0),Ge?.pointerId===c.pointerId&&(Ge.behavior.parameters.powerVariableId&&($[Ge.behavior.parameters.powerVariableId]=0),Ge=void 0),Ot?.pointerId===c.pointerId&&(Ot=void 0),Ce?.pointerId===c.pointerId&&(Ce.kind==="stroke"&&Ce.store.cancel(),Ce=void 0),lt?.pointerId===c.pointerId){try{for(var T=ze(lt.holds),b=T.next();!b.done;b=T.next()){var U=b.value;U.behavior.parameters.resetOnRelease!==!1&&($[U.behavior.parameters.variableId]=U.behavior.parameters.min)}}catch(R){y={error:R}}finally{try{b&&!b.done&&(w=T.return)&&w.call(T)}finally{if(y)throw y.error}}lt=void 0}xa(c)},_m=function(c){c?.isTrusted&&!f&&!pt&&!he&&Jf(!0)},$f=function(){dt||Ri()},Is=typeof globalThis.ResizeObserver=="function"?new globalThis.ResizeObserver($f):void 0;try{(s=Is?.observe)===null||s===void 0||s.call(Is,e)}catch{}var Mm=function(){He=0,qe=0,document.hidden&&jn(),Ze&&(document.hidden?Ze.suspend().catch(function(){}):!pt&&Gt&&Po())};document.addEventListener("visibilitychange",Mm),(o=globalThis.addEventListener)===null||o===void 0||o.call(globalThis,"resize",$f),e.addEventListener("pointerdown",vm),e.addEventListener("pointermove",ym),e.addEventListener("pointerup",xm),e.addEventListener("pointercancel",lu),e.addEventListener("lostpointercapture",lu),e.addEventListener("click",_m);var Kf=N?.onVisibilityChanged(function(c){nn=c,He=0,qe=0,c||jn(),Ze&&(c?!pt&&Gt&&Po():Ze.suspend().catch(function(){}))}),Qf=N?.onClosed(function(){he=!0,He=0,qe=0,jn(),Cn()}),jf=(u=N?.onVolumeChanged)===null||u===void 0?void 0:u.call(N,function(c){typeof c=="number"&&Number.isFinite(c)&&c>=0&&($n=Math.min(1,c>1?c/100:c),Vf())}),Lr,us,Sm=[];function bm(c){var y=!f&&!pt&&!document.hidden&&Kt&&nn&&!he;if(y&&qe&&(Ye+=Math.min((c-qe)/1e3,5/60)),Gn()){at=ot=0,Vt=!1,qe&&(He+=Math.min((c-qe)/1e3,5/60));for(var w=0;w<5&&He>=1/60;w++)us?.(),hm(1/60),He-=1/60;Yr(),Lr?.()&&(pt=!0,Lr=void 0,us=void 0)}else He=0;qe=c,Ri(),I=requestAnimationFrame(bm)}Ul(),f&&(oe=m),Ri(),I=requestAnimationFrame(bm),N&&N.init().then(function(){dt||(Kt=!0,nn=N.isVisible(),He=0,qe=0)}).catch(function(){dt||(he=!0,jn(),Cn())});var Sy=P?{freezeReview:function(){pt=!0,Lr=void 0,us=void 0,He=0,qe=0,wi(),na(),Ot=void 0,Ze?.suspend().catch(function(){}),Ri()},seekReview:function(c,y){var w,T,b,U,R=y===void 0?{}:y,H=R.motion,O=H===void 0?!1:H,Z=R.trustedEvent;pt=!0,Lr=void 0,us=void 0,Ul();var B=Nn.get("harvest.board"),V=O&&Z instanceof globalThis.Event&&Z.isTrusted,z=function(){var Ve=Ze;Ze=void 0;try{at=ot=0,Vt=!1,hm(1/60),Yr()}finally{Ze=Ve}},j=function(){var Ve;if(V)try{var tt=(Ve=globalThis.AudioContext)!==null&&Ve!==void 0?Ve:globalThis.webkitAudioContext;tt&&(Ze??(Ze=new tt)),Po()}catch{}He=0,qe=0,pt=!1,Ri()};if(L.has("salvage.ship")&&Object.hasOwn($,"salvage.phase")){if(!["opening","first-catch","end-card","timeout"].includes(c))throw Error("Review moment unavailable");var K=L.get("salvage.ship"),ee=function(Ve){var tt,xt=Te.filter(function(jt){return jt.prototypeId.startsWith("salvage.core")}).sort(function(jt,Sn){return Sn.transform[5]-jt.transform[5]})[0],Qe=Ee.get(K.id),zt=$e([],Ue((tt=Qe?.transform)!==null&&tt!==void 0?tt:K.transform),!1);zt[4]=Ve&&xt?Math.max(20,Math.min(306,xt.transform[4]-8)):20,Ee.set(K.id,ht(ht({},Qe),{transform:zt,parameters:ht(ht({},Qe?.parameters),{visible:Ve})}))},ue,_e,ve=function(){return $["salvage.phase"]!=="cta"?!1:(ue??(ue=xe),xe-ue>=.65)};if(c==="opening"){if(O){Lr=function(){return xe>=4},j();return}Ri();return}if(c==="timeout"){var Ae=(w=n.gameplay.find(function(Ve){return Ve.id==="salvage.deadline"}))===null||w===void 0?void 0:w.parameters.seconds;if(!Number.isFinite(Ae))throw Error("Timeout replay unavailable");if(ee(!1),O){for(;xe<Ae-.25&&$["salvage.phase"]!=="cta";)ee(!1),z();if($["salvage.phase"]==="cta")throw Error("Timeout replay unavailable");us=function(){$["salvage.phase"]!=="cta"&&ee(!1)},Lr=function(){return ve()||xe>=Ae+1},j();return}for(var fe=0;$["salvage.phase"]!=="cta"&&fe<3600;fe++)ee(!1),z();if($["salvage.phase"]!=="cta")throw Error("Timeout card unavailable");Ri();return}var pe=c==="first-catch"?1:3;if(O){for(var fe=0;$["salvage.catches"]<pe-1&&fe<3600;fe++)ee(!0),z();if($["salvage.catches"]!==pe-1)throw Error("Review replay unavailable");us=function(){$["salvage.catches"]<pe&&ee(!0)},Lr=function(){return pe===1&&$["salvage.catches"]>=1?(_e??(_e=xe),xe-_e>=1):pe===3&&ve()||xe>=20},j();return}for(var fe=0;$["salvage.catches"]<pe&&fe<3600;fe++)ee(!0),z();if($["salvage.catches"]!==pe)throw Error("Review catch unavailable");if(pe===1)for(var fe=0;fe<84;fe++)z();else{for(var fe=0;$["salvage.phase"]!=="cta"&&fe<300;fe++)z();if($["salvage.phase"]!=="cta")throw Error("End card unavailable")}Ri();return}if(!B){if(!["opening","first-input","end-card","timeout"].includes(c))throw Error("Review moment unavailable");if(c==="opening"){O?(Lr=function(){return xe>=4},j()):Ri();return}var Re=n.gameplay.find(function(Ve){return Ve.kind==="aim-launch"&&L.get(Ve.componentId).sceneId===oe}),de=n.gameplay.find(function(Ve){return Ve.kind==="aim-launch-3d"&&L.get(Ve.componentId).sceneId===oe}),Fe=n.events.find(function(Ve){var tt;return Ve.kind==="click"&&((tt=L.get(Ve.componentId))===null||tt===void 0?void 0:tt.sceneId)===oe&&n.eventBindings.some(function(xt){return xt.eventId===Ve.id})}),Be=function(){var Ve,tt;if(de){var xt=L.get(de.componentId),Qe=Vn("physics-3d",xt.id),zt=ia(xt,Qe),jt=n.gameplay.find(function(An){return An.kind==="capture-zone-3d"&&L.get(An.componentId).sceneId===oe}),Sn=0,Xt=-de.parameters.maxSpeed*.45;if(jt){var Jt=L.get(jt.componentId),ft=tn(Jt),st=((Ve=ft.x)!==null&&Ve!==void 0?Ve:0)-zt.x,Dn=((tt=ft.z)!==null&&tt!==void 0?tt:0)-zt.z,Ni=Math.hypot(st,Dn)||1;Sn=st/Ni*de.parameters.maxSpeed*.55,Xt=Dn/Ni*de.parameters.maxSpeed*.55}zt.vx=Sn,zt.vy=0,zt.vz=Xt,zt.atRest=!1,zt.restElapsed=0,zt.movingTime=0,zt.lastSafe={x:zt.x,y:zt.y,z:zt.z},Un({kind:"launch",componentId:xt.id}),Yr();return}if(Re){var xt=L.get(Re.componentId),_i=Bi(xt)[0],zt=Ca(_i,Vn("physics-body",xt.id)),jt=n.gameplay.find(function(Gi){return Gi.kind==="capture-zone"&&L.get(Gi.componentId).sceneId===oe}),Sn=Re.parameters.maxSpeed*.45,on=0;if(jt){var Jt=L.get(jt.componentId),Qn=oi(ci(Jt),tn(Jt).width/2,tn(Jt).height/2),st=Qn.x-zt.x,gi=Qn.y-zt.y,ei=Math.hypot(st,gi)||1;Sn=st/ei*Re.parameters.maxSpeed*.45,on=gi/ei*Re.parameters.maxSpeed*.45}zt.vx=Sn,zt.vy=on,zt.atRest=!1,zt.restElapsed=0,Un({kind:"launch",componentId:xt.id,instanceId:_i.instanceId})}else if(Fe)Un({kind:"click",componentId:Fe.componentId,targetId:Fe.componentId});else throw Error("Review primary input unavailable");Yr()};if(c==="first-input"){if(Be(),O)Lr=function(){return xe>=2},j();else{for(var fe=0;fe<60;fe++)z();Ri()}return}c==="end-card"&&Be();var Oe=c==="timeout"?Math.min(60,Math.max(1,(b=(T=n.gameplay.find(function(Ve){return Ve.kind==="timer"}))===null||T===void 0?void 0:T.parameters.seconds)!==null&&b!==void 0?b:10)):60,Xe=function(){var Ve;return((Ve=n.scenes.find(function(tt){return tt.id===oe}))===null||Ve===void 0?void 0:Ve.role)==="end-card"},vt=function(){var Ve,tt;return c==="timeout"?(Ve=n.scenes.find(function(xt){return xt.role==="end-card"&&/fail|loss|timeout/i.test(xt.id)}))!==null&&Ve!==void 0?Ve:n.scenes.find(function(xt){return xt.role==="end-card"}):(tt=n.scenes.find(function(xt){return xt.role==="end-card"&&!/fail|loss|timeout/i.test(xt.id)}))!==null&&tt!==void 0?tt:n.scenes.find(function(xt){return xt.role==="end-card"})};if(O){Lr=function(){return Xe()&&xe>=1||xe>=Oe+1},j();return}for(var fe=0;fe<Oe*60&&!Xe();fe++)z();if(!Xe()||c==="timeout"&&!/fail|loss|timeout/i.test(oe)||c==="end-card"&&/fail|loss|timeout/i.test(oe)){var Pt=vt();if(!Pt)throw Error("End card unavailable");oe=Pt.id,Ge=void 0,jn(),Un({kind:"sceneEnter",sceneId:oe}),Yr()}for(var fe=0;fe<45;fe++)z();Ri();return}var Tt,Ct=function(){return $["harvest.phase"]!=="cta"?!1:(Tt??(Tt=xe),xe-Tt>=.65)};if(c==="opening"&&O&&(Lr=function(){return xe>=7},He=0,qe=0,pt=!1),c==="timeout"){if(!B)throw Error("Review moment unavailable");if(O){var kt=(U=n.gameplay.find(function(Ve){return Ve.id==="harvest.deadline"}))===null||U===void 0?void 0:U.parameters.seconds;if(!Number.isFinite(kt))throw Error("Timeout replay unavailable");for(;xe<kt-.25&&$["harvest.phase"]!=="cta";)z();if($["harvest.phase"]==="cta")throw Error("Timeout replay unavailable");Lr=function(){return Ct()||xe>=kt+1},j();return}for(var fe=0;$["harvest.phase"]!=="cta"&&fe<3600;fe++)z();if($["harvest.phase"]!=="cta")throw Error("Timeout card unavailable")}else if(c!=="opening"){if(!B||!["first-harvest","end-card"].includes(c))throw Error("Review moment unavailable");for(var At=c==="first-harvest"?1:3,_t=function(Ve){var tt=B.snapshot().legalMoves[0];if(!tt||!B.swap(tt.from,tt.to))throw Error("Review move unavailable");if(O&&Ve===At-1){var xt=xe+(At===1?3:8);return Lr=function(){return xe>=xt||At===3&&Ct()},j(),{value:void 0}}for(var Qe=0;B.snapshot().busy&&Qe<240;Qe++)z();if(B.snapshot().busy)throw Error("Review replay did not settle")},St=0;St<At;St++){var bt=_t(St);if(typeof bt=="object")return bt.value}if(At===1)for(var fe=0;fe<84;fe++)z();else{for(var fe=0;$["harvest.phase"]!=="cta"&&fe<300;fe++)z();if($["harvest.phase"]!=="cta")throw Error("End card unavailable")}}Ri()},storeInvocations:function(){return $e([],Ue(Sm),!1)},canApplyVariantInPlace:function(c){var y,w,T=function(pe){return JSON.stringify(n[pe])===JSON.stringify(c[pe])};if(!c||!["scenes","variables","gameplay","events","tombstones"].every(T)||!Array.isArray(c.assets)||n.assets.length!==c.assets.length)return!1;for(var b=0;b<n.assets.length;b++){var U=n.assets[b],R=c.assets[b];if(U.id!==R.id||U.hash!==R.hash||U.mime!==R.mime||U.bytes!==R.bytes)return!1}var H=ht({},n.base);delete H.storeUrl;var O=ht({},c.base);if(delete O.storeUrl,JSON.stringify(H)!==JSON.stringify(O)||n.creativeBrief.goal!==c.creativeBrief.goal||n.components.length!==c.components.length||n.eventBindings.length!==c.eventBindings.length)return!1;for(var Z=new Set(["text","color","fontSize","fontFamily","fontWeight","align","direction","wrap","autoFit","minFontSize","padding","lineHeight","pixelPanel","panelFill","panelStroke"]),B=new Set(["fill","stroke","hoverFill","pressedFill","skyColor","tintColor"]),b=0;b<n.components.length;b++){var U=n.components[b],R=c.components[b],V=U.contract==="native.text.v1"?Z:B;if(U.id!==R.id||JSON.stringify(ht(ht({},U),{parameters:void 0}))!==JSON.stringify(ht(ht({},R),{parameters:void 0})))return!1;var z=new Set($e($e([],Ue(Object.keys(U.parameters)),!1),Ue(Object.keys(R.parameters)),!1));try{for(var j=(y=void 0,ze(z)),K=j.next();!K.done;K=j.next()){var ee=K.value;if(!V.has(ee)&&JSON.stringify(U.parameters[ee])!==JSON.stringify(R.parameters[ee]))return!1}}catch(Fe){y={error:Fe}}finally{try{K&&!K.done&&(w=j.return)&&w.call(j)}finally{if(y)throw y.error}}}for(var b=0;b<n.eventBindings.length;b++){var U=n.eventBindings[b],R=c.eventBindings[b];if(U.id!==R.id||U.eventId!==R.eventId||JSON.stringify(U.condition)!==JSON.stringify(R.condition)||U.actions.length!==R.actions.length)return!1;for(var ue=0;ue<U.actions.length;ue++){var _e=U.actions[ue],ve=R.actions[ue],Ae=ht({},_e),fe=ht({},ve);if(_e.kind==="setComponent"&&_e.key==="text"?(delete Ae.value,delete fe.value):_e.kind==="floatingText"&&(delete Ae.text,delete fe.text),JSON.stringify(Ae)!==JSON.stringify(fe))return!1}}return!0},applyVariantPreview:function(c){var y,w;if(!this.canApplyVariantInPlace(c))throw Error("E_NATIVE_VARIANT_REMOUNT");n.creativeBrief.language=c.creativeBrief.language,n.base.storeUrl=c.base.storeUrl;try{for(var T=ze(c.components),b=T.next();!b.done;b=T.next()){var U=b.value;L.get(U.id).parameters=globalThis.structuredClone(U.parameters)}}catch(R){y={error:R}}finally{try{b&&!b.done&&(w=T.return)&&w.call(T)}finally{if(y)throw y.error}}return n.eventBindings=globalThis.structuredClone(c.eventBindings),Ul(),Ri(),!0},pickReview:function(c,y){var w=Ol(ou({clientX:c,clientY:y}));return w?Bl(w.c).map(function(T){var b;return(b=T.prototypeId)!==null&&b!==void 0?b:T.id}):[]},reviewBounds:function(c){var y=q(),w=e.clientWidth,T=e.clientHeight,b=Math.min(w/y.width,T/y.height);return Je.filter(function(U){return c.includes(U.c.id)}).map(function(U){var R=lr(U.c,U.m);return{left:(w-y.width*b)/2+R.left*b,top:(T-y.height*b)/2+R.top*b,width:(R.right-R.left)*b,height:(R.bottom-R.top)*b}})}}:void 0;return ht(ht({},Sy),{state:Oi,auditViewport:dy,auditSceneLayout:fy,restart:function(){var c;Lr=void 0,us=void 0,(c=N?.notifyGameRetry)===null||c===void 0||c.call(N),Ul(),Ri()},select:function(c){De=c},inspectScene:function(c){f&&n.scenes.some(function(y){return y.id===c})&&(oe=c,De=void 0)},pause:function(c){pt=c,He=0,qe=0,c&&jn(),Ze&&(c?Ze.suspend().catch(function(){}):Gt&&Po())},destroy:function(){var c,y;dt=!0,cancelAnimationFrame(I),jn(),Cn(),Zt?.dispose(),Kf?.(),Qf?.(),jf?.(),N?.destroy(),(c=Is?.disconnect)===null||c===void 0||c.call(Is),document.removeEventListener("visibilitychange",Mm),(y=globalThis.removeEventListener)===null||y===void 0||y.call(globalThis,"resize",$f),e.removeEventListener("pointerdown",vm),e.removeEventListener("pointermove",ym),e.removeEventListener("pointerup",xm),e.removeEventListener("pointercancel",lu),e.removeEventListener("lostpointercapture",lu),e.removeEventListener("click",_m),Ze?.close().catch(function(){})}})}return ky(A1);})();